From 03f22bcdaf1f80083618856d6e4140d3062f175b Mon Sep 17 00:00:00 2001 From: Michael Goddard Date: Thu, 6 Oct 2011 14:31:58 +1000 Subject: Rename QtMultimediaKit to QtMultimedia. There are a few legacy bits left in place so it passes CI, and then qt5.git etc can be updated. Change-Id: I6b082e50e6958c72fdabc2974992e16d90dafa3a Reviewed-on: http://codereview.qt-project.org/5368 Reviewed-by: Qt Sanity Bot Reviewed-by: Jonas Rabbe --- doc/src/examples/camera.qdoc | 2 +- doc/src/multimedia.qdoc | 8 +- doc/src/plugins/qml-multimedia.qdoc | 6 +- .../snippets/multimedia-snippets/audiorecorder.cpp | 2 +- doc/src/snippets/multimedia-snippets/media.cpp | 2 +- .../multimedia-snippets/multimedia-snippets.pro | 10 +- doc/src/snippets/multimedia-snippets/player.cpp | 8 +- .../snippets/multimedia-snippets/soundeffect.qml | 2 +- examples/audiodevices/audiodevices.pro | 6 +- examples/audioinput/audioinput.pro | 6 +- examples/audiooutput/audiooutput.pro | 6 +- examples/audiorecorder/audiorecorder.cpp | 10 +- examples/audiorecorder/audiorecorder.pro | 6 +- examples/camera/camera.cpp | 2 +- examples/camera/camera.pro | 6 +- examples/camera/imagesettings.cpp | 4 +- examples/camera/videosettings.cpp | 8 +- .../declarative-camera/CameraPropertyButton.qml | 2 +- examples/declarative-camera/CaptureControls.qml | 2 +- examples/declarative-camera/FocusButton.qml | 2 +- examples/declarative-camera/PhotoPreview.qml | 2 +- examples/declarative-camera/ZoomControl.qml | 2 +- examples/declarative-camera/declarative-camera.pro | 6 +- examples/declarative-camera/declarative-camera.qml | 2 +- examples/declarative-radio/declarative-radio.pro | 2 +- examples/declarative-radio/view.qml | 2 +- examples/player/player.cpp | 8 +- examples/player/player.pro | 8 +- examples/player/playlistmodel.h | 2 +- examples/radio/radio.pro | 6 +- examples/slideshow/slideshow.pro | 6 +- examples/spectrum/3rdparty/fftreal/fftreal.pro | 2 +- examples/spectrum/README.txt | 4 +- examples/spectrum/app/app.pro | 6 +- examples/spectrum/app/engine.cpp | 4 +- examples/spectrum/app/engine.h | 6 +- examples/spectrum/app/main.cpp | 2 +- examples/spectrum/app/mainwidget.h | 2 +- examples/spectrum/app/settingsdialog.h | 2 +- examples/spectrum/app/spectrumanalyser.cpp | 2 +- examples/spectrum/app/tonegenerator.cpp | 2 +- examples/spectrum/app/tonegeneratordialog.h | 2 +- examples/spectrum/app/utils.cpp | 2 +- examples/spectrum/app/waveform.h | 2 +- examples/spectrum/app/wavfile.h | 2 +- examples/spectrum/spectrum.pro | 2 +- examples/videographicsitem/videographicsitem.pro | 6 +- examples/videowidget/videowidget.pro | 6 +- modules/qt_multimedia.pri | 17 + modules/qt_multimediakit.pri | 17 - modules/qt_multimediakitwidgets.pri | 17 - modules/qt_multimediawidgets.pri | 17 + qtmultimedia.pro | 21 + qtmultimediakit.pro | 23 +- src/imports/multimedia/multimedia.cpp | 3 +- src/imports/multimedia/multimedia.pro | 18 +- src/imports/multimedia/qdeclarativeaudio.cpp | 94 +- src/imports/multimedia/qdeclarativecamera.cpp | 4 +- .../multimedia/qdeclarativecameraexposure.cpp | 4 +- src/imports/multimedia/qdeclarativecameraflash.cpp | 4 +- src/imports/multimedia/qdeclarativecamerafocus.cpp | 4 +- src/imports/multimedia/qdeclarativemediabase.cpp | 6 +- .../multimedia/qdeclarativemediametadata_p.h | 92 +- src/imports/multimedia/qdeclarativevideo.cpp | 146 +- src/imports/multimedia/qdeclarativevideooutput.cpp | 12 +- src/imports/multimedia/qdeclarativevideooutput_p.h | 4 +- src/imports/multimedia/qmldir.qtmultimediakit | 1 + src/imports/multimedia/qsgvideonode_i420.h | 2 +- src/imports/multimedia/qsgvideonode_p.h | 4 +- src/imports/qimportbase.pri | 2 +- src/meegoinstalls/Makefile | 40 - src/meegoinstalls/README | 95 -- src/meegoinstalls/qt-mobility.spec | 1360 --------------- src/meegoinstalls/qt-mobility.yaml | 353 ---- src/multimedia/audio/audio.pri | 60 + src/multimedia/audio/qaudio.cpp | 103 ++ src/multimedia/audio/qaudio.h | 74 + src/multimedia/audio/qaudio_mac.cpp | 145 ++ src/multimedia/audio/qaudio_mac_p.h | 145 ++ src/multimedia/audio/qaudiodevicefactory.cpp | 288 ++++ src/multimedia/audio/qaudiodevicefactory_p.h | 100 ++ src/multimedia/audio/qaudiodeviceinfo.cpp | 483 ++++++ src/multimedia/audio/qaudiodeviceinfo.h | 116 ++ src/multimedia/audio/qaudiodeviceinfo_alsa_p.cpp | 535 ++++++ src/multimedia/audio/qaudiodeviceinfo_alsa_p.h | 129 ++ src/multimedia/audio/qaudiodeviceinfo_mac_p.cpp | 351 ++++ src/multimedia/audio/qaudiodeviceinfo_mac_p.h | 99 ++ src/multimedia/audio/qaudiodeviceinfo_win32_p.cpp | 465 ++++++ src/multimedia/audio/qaudiodeviceinfo_win32_p.h | 120 ++ src/multimedia/audio/qaudioformat.cpp | 407 +++++ src/multimedia/audio/qaudioformat.h | 109 ++ src/multimedia/audio/qaudioinput.cpp | 402 +++++ src/multimedia/audio/qaudioinput.h | 114 ++ src/multimedia/audio/qaudioinput_alsa_p.cpp | 867 ++++++++++ src/multimedia/audio/qaudioinput_alsa_p.h | 191 +++ src/multimedia/audio/qaudioinput_mac_p.cpp | 989 +++++++++++ src/multimedia/audio/qaudioinput_mac_p.h | 174 ++ src/multimedia/audio/qaudioinput_win32_p.cpp | 642 ++++++++ src/multimedia/audio/qaudioinput_win32_p.h | 179 ++ src/multimedia/audio/qaudiooutput.cpp | 404 +++++ src/multimedia/audio/qaudiooutput.h | 117 ++ src/multimedia/audio/qaudiooutput_alsa_p.cpp | 834 ++++++++++ src/multimedia/audio/qaudiooutput_alsa_p.h | 175 ++ src/multimedia/audio/qaudiooutput_mac_p.cpp | 734 +++++++++ src/multimedia/audio/qaudiooutput_mac_p.h | 174 ++ src/multimedia/audio/qaudiooutput_win32_p.cpp | 715 ++++++++ src/multimedia/audio/qaudiooutput_win32_p.h | 175 ++ src/multimedia/audio/qaudiopluginloader.cpp | 176 ++ src/multimedia/audio/qaudiopluginloader_p.h | 100 ++ src/multimedia/audio/qaudiosystem.cpp | 436 +++++ src/multimedia/audio/qaudiosystem.h | 141 ++ src/multimedia/audio/qaudiosystemplugin.cpp | 143 ++ src/multimedia/audio/qaudiosystemplugin.h | 96 ++ src/multimedia/effects/effects.pri | 36 + src/multimedia/effects/qsamplecache_p.cpp | 398 +++++ src/multimedia/effects/qsamplecache_p.h | 161 ++ src/multimedia/effects/qsoundeffect.cpp | 301 ++++ src/multimedia/effects/qsoundeffect_p.h | 143 ++ src/multimedia/effects/qsoundeffect_pulse_p.cpp | 957 +++++++++++ src/multimedia/effects/qsoundeffect_pulse_p.h | 163 ++ src/multimedia/effects/qsoundeffect_qmedia_p.cpp | 233 +++ src/multimedia/effects/qsoundeffect_qmedia_p.h | 122 ++ src/multimedia/effects/qsoundeffect_qsound_p.cpp | 222 +++ src/multimedia/effects/qsoundeffect_qsound_p.h | 121 ++ src/multimedia/effects/qwavedecoder_p.cpp | 232 +++ src/multimedia/effects/qwavedecoder_p.h | 137 ++ src/multimedia/multimedia.pro | 156 ++ src/multimedia/qaudiocapturesource.cpp | 275 ++++ src/multimedia/qaudiocapturesource.h | 103 ++ src/multimedia/qaudioencodercontrol.cpp | 167 ++ src/multimedia/qaudioencodercontrol.h | 95 ++ src/multimedia/qaudioendpointselector.cpp | 140 ++ src/multimedia/qaudioendpointselector.h | 86 + src/multimedia/qaudionamespace.qdoc | 70 + src/multimedia/qcamera.cpp | 1035 ++++++++++++ src/multimedia/qcamera.h | 238 +++ .../qcameracapturebufferformatcontrol.cpp | 117 ++ src/multimedia/qcameracapturebufferformatcontrol.h | 81 + .../qcameracapturedestinationcontrol.cpp | 121 ++ src/multimedia/qcameracapturedestinationcontrol.h | 81 + src/multimedia/qcameracontrol.cpp | 215 +++ src/multimedia/qcameracontrol.h | 101 ++ src/multimedia/qcameraexposure.cpp | 646 ++++++++ src/multimedia/qcameraexposure.h | 185 +++ src/multimedia/qcameraexposurecontrol.cpp | 252 +++ src/multimedia/qcameraexposurecontrol.h | 124 ++ src/multimedia/qcameraflashcontrol.cpp | 141 ++ src/multimedia/qcameraflashcontrol.h | 87 + src/multimedia/qcamerafocus.cpp | 478 ++++++ src/multimedia/qcamerafocus.h | 183 +++ src/multimedia/qcamerafocuscontrol.cpp | 253 +++ src/multimedia/qcamerafocuscontrol.h | 103 ++ src/multimedia/qcameraimagecapture.cpp | 681 ++++++++ src/multimedia/qcameraimagecapture.h | 170 ++ src/multimedia/qcameraimagecapturecontrol.cpp | 208 +++ src/multimedia/qcameraimagecapturecontrol.h | 99 ++ src/multimedia/qcameraimageprocessing.cpp | 352 ++++ src/multimedia/qcameraimageprocessing.h | 124 ++ src/multimedia/qcameraimageprocessingcontrol.cpp | 169 ++ src/multimedia/qcameraimageprocessingcontrol.h | 100 ++ src/multimedia/qcameralockscontrol.cpp | 134 ++ src/multimedia/qcameralockscontrol.h | 86 + src/multimedia/qimageencodercontrol.cpp | 142 ++ src/multimedia/qimageencodercontrol.h | 91 ++ src/multimedia/qlocalmediaplaylistprovider.cpp | 194 +++ src/multimedia/qlocalmediaplaylistprovider.h | 87 + src/multimedia/qmediabackgroundplaybackcontrol.cpp | 149 ++ src/multimedia/qmediabackgroundplaybackcontrol.h | 83 + src/multimedia/qmediabindableinterface.cpp | 85 + src/multimedia/qmediabindableinterface.h | 77 + src/multimedia/qmediacontainercontrol.cpp | 126 ++ src/multimedia/qmediacontainercontrol.h | 80 + src/multimedia/qmediacontent.cpp | 254 +++ src/multimedia/qmediacontent.h | 95 ++ src/multimedia/qmediacontrol.cpp | 138 ++ src/multimedia/qmediacontrol.h | 87 + src/multimedia/qmediacontrol_p.h | 80 + src/multimedia/qmediaencodersettings.cpp | 822 ++++++++++ src/multimedia/qmediaencodersettings.h | 168 ++ src/multimedia/qmediaenumdebug.h | 79 + src/multimedia/qmediaimageviewer.cpp | 604 +++++++ src/multimedia/qmediaimageviewer.h | 142 ++ src/multimedia/qmediaimageviewerservice.cpp | 463 ++++++ src/multimedia/qmediaimageviewerservice_p.h | 147 ++ src/multimedia/qmedianetworkaccesscontrol.cpp | 103 ++ src/multimedia/qmedianetworkaccesscontrol.h | 83 + src/multimedia/qmediaobject.cpp | 423 +++++ src/multimedia/qmediaobject.h | 118 ++ src/multimedia/qmediaobject_p.h | 99 ++ src/multimedia/qmediaplayer.cpp | 1139 +++++++++++++ src/multimedia/qmediaplayer.h | 227 +++ src/multimedia/qmediaplayercontrol.cpp | 414 +++++ src/multimedia/qmediaplayercontrol.h | 131 ++ src/multimedia/qmediaplaylist.cpp | 756 +++++++++ src/multimedia/qmediaplaylist.h | 154 ++ src/multimedia/qmediaplaylist_p.h | 177 ++ src/multimedia/qmediaplaylistcontrol.cpp | 219 +++ src/multimedia/qmediaplaylistcontrol.h | 98 ++ src/multimedia/qmediaplaylistioplugin.cpp | 204 +++ src/multimedia/qmediaplaylistioplugin.h | 126 ++ src/multimedia/qmediaplaylistnavigator.cpp | 568 +++++++ src/multimedia/qmediaplaylistnavigator.h | 115 ++ src/multimedia/qmediaplaylistprovider.cpp | 329 ++++ src/multimedia/qmediaplaylistprovider.h | 115 ++ src/multimedia/qmediaplaylistprovider_p.h | 80 + src/multimedia/qmediaplaylistsourcecontrol.cpp | 128 ++ src/multimedia/qmediaplaylistsourcecontrol.h | 82 + src/multimedia/qmediapluginloader.cpp | 213 +++ src/multimedia/qmediapluginloader_p.h | 99 ++ src/multimedia/qmediarecorder.cpp | 904 ++++++++++ src/multimedia/qmediarecorder.h | 197 +++ src/multimedia/qmediarecordercontrol.cpp | 209 +++ src/multimedia/qmediarecordercontrol.h | 101 ++ src/multimedia/qmediaresource.cpp | 440 +++++ src/multimedia/qmediaresource.h | 134 ++ src/multimedia/qmediaservice.cpp | 151 ++ src/multimedia/qmediaservice.h | 97 ++ src/multimedia/qmediaservice_p.h | 80 + src/multimedia/qmediaserviceprovider.cpp | 783 +++++++++ src/multimedia/qmediaserviceprovider.h | 186 +++ src/multimedia/qmediaserviceproviderplugin.h | 129 ++ src/multimedia/qmediastreamscontrol.cpp | 161 ++ src/multimedia/qmediastreamscontrol.h | 95 ++ src/multimedia/qmediatimerange.cpp | 759 +++++++++ src/multimedia/qmediatimerange.h | 140 ++ src/multimedia/qmetadatareadercontrol.cpp | 163 ++ src/multimedia/qmetadatareadercontrol.h | 92 ++ src/multimedia/qmetadatawritercontrol.cpp | 195 +++ src/multimedia/qmetadatawritercontrol.h | 97 ++ src/multimedia/qradiotuner.cpp | 614 +++++++ src/multimedia/qradiotuner.h | 158 ++ src/multimedia/qradiotunercontrol.cpp | 364 +++++ src/multimedia/qradiotunercontrol.h | 123 ++ src/multimedia/qtmedianamespace.h | 339 ++++ src/multimedia/qtmedianamespace.qdoc | 208 +++ src/multimedia/qtmultimediadefs.h | 90 + src/multimedia/qvideodevicecontrol.cpp | 159 ++ src/multimedia/qvideodevicecontrol.h | 88 + src/multimedia/qvideoencodercontrol.cpp | 190 +++ src/multimedia/qvideoencodercontrol.h | 98 ++ src/multimedia/qvideorenderercontrol.cpp | 114 ++ src/multimedia/qvideorenderercontrol.h | 81 + src/multimedia/qvideosurfaceoutput.cpp | 100 ++ src/multimedia/qvideosurfaceoutput_p.h | 86 + src/multimedia/video/qabstractvideobuffer.cpp | 202 +++ src/multimedia/video/qabstractvideobuffer.h | 112 ++ src/multimedia/video/qabstractvideobuffer_p.h | 88 + src/multimedia/video/qabstractvideosurface.cpp | 340 ++++ src/multimedia/video/qabstractvideosurface.h | 115 ++ src/multimedia/video/qimagevideobuffer.cpp | 106 ++ src/multimedia/video/qimagevideobuffer_p.h | 87 + src/multimedia/video/qmemoryvideobuffer.cpp | 132 ++ src/multimedia/video/qmemoryvideobuffer_p.h | 89 + src/multimedia/video/qvideoframe.cpp | 776 +++++++++ src/multimedia/video/qvideoframe.h | 174 ++ src/multimedia/video/qvideosurfaceformat.cpp | 707 ++++++++ src/multimedia/video/qvideosurfaceformat.h | 148 ++ src/multimedia/video/video.pri | 22 + src/multimediakit/audio/audio.pri | 60 - src/multimediakit/audio/qaudio.cpp | 103 -- src/multimediakit/audio/qaudio.h | 74 - src/multimediakit/audio/qaudio_mac.cpp | 145 -- src/multimediakit/audio/qaudio_mac_p.h | 145 -- src/multimediakit/audio/qaudiodevicefactory.cpp | 288 ---- src/multimediakit/audio/qaudiodevicefactory_p.h | 100 -- src/multimediakit/audio/qaudiodeviceinfo.cpp | 483 ------ src/multimediakit/audio/qaudiodeviceinfo.h | 116 -- .../audio/qaudiodeviceinfo_alsa_p.cpp | 535 ------ src/multimediakit/audio/qaudiodeviceinfo_alsa_p.h | 129 -- src/multimediakit/audio/qaudiodeviceinfo_mac_p.cpp | 351 ---- src/multimediakit/audio/qaudiodeviceinfo_mac_p.h | 99 -- .../audio/qaudiodeviceinfo_win32_p.cpp | 465 ------ src/multimediakit/audio/qaudiodeviceinfo_win32_p.h | 120 -- src/multimediakit/audio/qaudioformat.cpp | 407 ----- src/multimediakit/audio/qaudioformat.h | 109 -- src/multimediakit/audio/qaudioinput.cpp | 402 ----- src/multimediakit/audio/qaudioinput.h | 114 -- src/multimediakit/audio/qaudioinput_alsa_p.cpp | 867 ---------- src/multimediakit/audio/qaudioinput_alsa_p.h | 191 --- src/multimediakit/audio/qaudioinput_mac_p.cpp | 989 ----------- src/multimediakit/audio/qaudioinput_mac_p.h | 174 -- src/multimediakit/audio/qaudioinput_win32_p.cpp | 642 -------- src/multimediakit/audio/qaudioinput_win32_p.h | 179 -- src/multimediakit/audio/qaudiooutput.cpp | 404 ----- src/multimediakit/audio/qaudiooutput.h | 117 -- src/multimediakit/audio/qaudiooutput_alsa_p.cpp | 834 ---------- src/multimediakit/audio/qaudiooutput_alsa_p.h | 175 -- src/multimediakit/audio/qaudiooutput_mac_p.cpp | 734 --------- src/multimediakit/audio/qaudiooutput_mac_p.h | 174 -- src/multimediakit/audio/qaudiooutput_win32_p.cpp | 715 -------- src/multimediakit/audio/qaudiooutput_win32_p.h | 175 -- src/multimediakit/audio/qaudiopluginloader.cpp | 176 -- src/multimediakit/audio/qaudiopluginloader_p.h | 100 -- src/multimediakit/audio/qaudiosystem.cpp | 436 ----- src/multimediakit/audio/qaudiosystem.h | 141 -- src/multimediakit/audio/qaudiosystemplugin.cpp | 143 -- src/multimediakit/audio/qaudiosystemplugin.h | 96 -- src/multimediakit/effects/effects.pri | 36 - src/multimediakit/effects/qsamplecache_p.cpp | 398 ----- src/multimediakit/effects/qsamplecache_p.h | 161 -- src/multimediakit/effects/qsoundeffect.cpp | 301 ---- src/multimediakit/effects/qsoundeffect_p.h | 143 -- src/multimediakit/effects/qsoundeffect_pulse_p.cpp | 957 ----------- src/multimediakit/effects/qsoundeffect_pulse_p.h | 163 -- .../effects/qsoundeffect_qmedia_p.cpp | 233 --- src/multimediakit/effects/qsoundeffect_qmedia_p.h | 122 -- .../effects/qsoundeffect_qsound_p.cpp | 222 --- src/multimediakit/effects/qsoundeffect_qsound_p.h | 121 -- src/multimediakit/effects/qwavedecoder_p.cpp | 232 --- src/multimediakit/effects/qwavedecoder_p.h | 137 -- src/multimediakit/multimediakit.pro | 157 -- src/multimediakit/qaudiocapturesource.cpp | 275 ---- src/multimediakit/qaudiocapturesource.h | 103 -- src/multimediakit/qaudioencodercontrol.cpp | 167 -- src/multimediakit/qaudioencodercontrol.h | 95 -- src/multimediakit/qaudioendpointselector.cpp | 140 -- src/multimediakit/qaudioendpointselector.h | 86 - src/multimediakit/qaudionamespace.qdoc | 70 - src/multimediakit/qcamera.cpp | 1035 ------------ src/multimediakit/qcamera.h | 238 --- .../qcameracapturebufferformatcontrol.cpp | 117 -- .../qcameracapturebufferformatcontrol.h | 81 - .../qcameracapturedestinationcontrol.cpp | 121 -- .../qcameracapturedestinationcontrol.h | 81 - src/multimediakit/qcameracontrol.cpp | 215 --- src/multimediakit/qcameracontrol.h | 101 -- src/multimediakit/qcameraexposure.cpp | 646 -------- src/multimediakit/qcameraexposure.h | 185 --- src/multimediakit/qcameraexposurecontrol.cpp | 252 --- src/multimediakit/qcameraexposurecontrol.h | 124 -- src/multimediakit/qcameraflashcontrol.cpp | 141 -- src/multimediakit/qcameraflashcontrol.h | 87 - src/multimediakit/qcamerafocus.cpp | 478 ------ src/multimediakit/qcamerafocus.h | 183 --- src/multimediakit/qcamerafocuscontrol.cpp | 253 --- src/multimediakit/qcamerafocuscontrol.h | 103 -- src/multimediakit/qcameraimagecapture.cpp | 681 -------- src/multimediakit/qcameraimagecapture.h | 170 -- src/multimediakit/qcameraimagecapturecontrol.cpp | 208 --- src/multimediakit/qcameraimagecapturecontrol.h | 99 -- src/multimediakit/qcameraimageprocessing.cpp | 352 ---- src/multimediakit/qcameraimageprocessing.h | 124 -- .../qcameraimageprocessingcontrol.cpp | 169 -- src/multimediakit/qcameraimageprocessingcontrol.h | 100 -- src/multimediakit/qcameralockscontrol.cpp | 134 -- src/multimediakit/qcameralockscontrol.h | 86 - src/multimediakit/qimageencodercontrol.cpp | 142 -- src/multimediakit/qimageencodercontrol.h | 91 -- src/multimediakit/qlocalmediaplaylistprovider.cpp | 194 --- src/multimediakit/qlocalmediaplaylistprovider.h | 87 - .../qmediabackgroundplaybackcontrol.cpp | 149 -- .../qmediabackgroundplaybackcontrol.h | 83 - src/multimediakit/qmediabindableinterface.cpp | 85 - src/multimediakit/qmediabindableinterface.h | 77 - src/multimediakit/qmediacontainercontrol.cpp | 126 -- src/multimediakit/qmediacontainercontrol.h | 80 - src/multimediakit/qmediacontent.cpp | 254 --- src/multimediakit/qmediacontent.h | 95 -- src/multimediakit/qmediacontrol.cpp | 138 -- src/multimediakit/qmediacontrol.h | 87 - src/multimediakit/qmediacontrol_p.h | 80 - src/multimediakit/qmediaencodersettings.cpp | 822 ---------- src/multimediakit/qmediaencodersettings.h | 168 -- src/multimediakit/qmediaenumdebug.h | 79 - src/multimediakit/qmediaimageviewer.cpp | 604 ------- src/multimediakit/qmediaimageviewer.h | 142 -- src/multimediakit/qmediaimageviewerservice.cpp | 463 ------ src/multimediakit/qmediaimageviewerservice_p.h | 147 -- src/multimediakit/qmedianetworkaccesscontrol.cpp | 103 -- src/multimediakit/qmedianetworkaccesscontrol.h | 83 - src/multimediakit/qmediaobject.cpp | 423 ----- src/multimediakit/qmediaobject.h | 118 -- src/multimediakit/qmediaobject_p.h | 99 -- src/multimediakit/qmediaplayer.cpp | 1139 ------------- src/multimediakit/qmediaplayer.h | 227 --- src/multimediakit/qmediaplayercontrol.cpp | 414 ----- src/multimediakit/qmediaplayercontrol.h | 131 -- src/multimediakit/qmediaplaylist.cpp | 756 --------- src/multimediakit/qmediaplaylist.h | 154 -- src/multimediakit/qmediaplaylist_p.h | 177 -- src/multimediakit/qmediaplaylistcontrol.cpp | 219 --- src/multimediakit/qmediaplaylistcontrol.h | 98 -- src/multimediakit/qmediaplaylistioplugin.cpp | 204 --- src/multimediakit/qmediaplaylistioplugin.h | 126 -- src/multimediakit/qmediaplaylistnavigator.cpp | 568 ------- src/multimediakit/qmediaplaylistnavigator.h | 115 -- src/multimediakit/qmediaplaylistprovider.cpp | 329 ---- src/multimediakit/qmediaplaylistprovider.h | 115 -- src/multimediakit/qmediaplaylistprovider_p.h | 80 - src/multimediakit/qmediaplaylistsourcecontrol.cpp | 128 -- src/multimediakit/qmediaplaylistsourcecontrol.h | 82 - src/multimediakit/qmediapluginloader.cpp | 213 --- src/multimediakit/qmediapluginloader_p.h | 99 -- src/multimediakit/qmediarecorder.cpp | 904 ---------- src/multimediakit/qmediarecorder.h | 197 --- src/multimediakit/qmediarecordercontrol.cpp | 209 --- src/multimediakit/qmediarecordercontrol.h | 101 -- src/multimediakit/qmediaresource.cpp | 440 ----- src/multimediakit/qmediaresource.h | 134 -- src/multimediakit/qmediaservice.cpp | 151 -- src/multimediakit/qmediaservice.h | 97 -- src/multimediakit/qmediaservice_p.h | 80 - src/multimediakit/qmediaserviceprovider.cpp | 783 --------- src/multimediakit/qmediaserviceprovider.h | 186 --- src/multimediakit/qmediaserviceproviderplugin.h | 129 -- src/multimediakit/qmediastreamscontrol.cpp | 162 -- src/multimediakit/qmediastreamscontrol.h | 95 -- src/multimediakit/qmediatimerange.cpp | 759 --------- src/multimediakit/qmediatimerange.h | 140 -- src/multimediakit/qmetadatareadercontrol.cpp | 163 -- src/multimediakit/qmetadatareadercontrol.h | 92 -- src/multimediakit/qmetadatawritercontrol.cpp | 195 --- src/multimediakit/qmetadatawritercontrol.h | 97 -- src/multimediakit/qradiotuner.cpp | 614 ------- src/multimediakit/qradiotuner.h | 158 -- src/multimediakit/qradiotunercontrol.cpp | 364 ----- src/multimediakit/qradiotunercontrol.h | 123 -- src/multimediakit/qtmedianamespace.h | 198 --- src/multimediakit/qtmedianamespace.qdoc | 208 --- src/multimediakit/qtmultimediakitdefs.h | 90 - src/multimediakit/qvideodevicecontrol.cpp | 159 -- src/multimediakit/qvideodevicecontrol.h | 88 - src/multimediakit/qvideoencodercontrol.cpp | 190 --- src/multimediakit/qvideoencodercontrol.h | 98 -- src/multimediakit/qvideorenderercontrol.cpp | 114 -- src/multimediakit/qvideorenderercontrol.h | 81 - src/multimediakit/qvideosurfaceoutput.cpp | 100 -- src/multimediakit/qvideosurfaceoutput_p.h | 86 - src/multimediakit/video/qabstractvideobuffer.cpp | 202 --- src/multimediakit/video/qabstractvideobuffer.h | 112 -- src/multimediakit/video/qabstractvideobuffer_p.h | 88 - src/multimediakit/video/qabstractvideosurface.cpp | 340 ---- src/multimediakit/video/qabstractvideosurface.h | 115 -- src/multimediakit/video/qimagevideobuffer.cpp | 106 -- src/multimediakit/video/qimagevideobuffer_p.h | 87 - src/multimediakit/video/qmemoryvideobuffer.cpp | 132 -- src/multimediakit/video/qmemoryvideobuffer_p.h | 89 - src/multimediakit/video/qvideoframe.cpp | 776 --------- src/multimediakit/video/qvideoframe.h | 174 -- src/multimediakit/video/qvideosurfaceformat.cpp | 707 -------- src/multimediakit/video/qvideosurfaceformat.h | 148 -- src/multimediakit/video/video.pri | 22 - src/multimediakitwidgets/multimediakitwidgets.pro | 68 - src/multimediakitwidgets/qcameraviewfinder.cpp | 113 -- src/multimediakitwidgets/qcameraviewfinder.h | 90 - .../qeglimagetexturesurface.cpp | 554 ------- .../qeglimagetexturesurface_p.h | 150 -- src/multimediakitwidgets/qgraphicsvideoitem.cpp | 432 ----- src/multimediakitwidgets/qgraphicsvideoitem.h | 115 -- .../qgraphicsvideoitem_maemo6.cpp | 498 ------ src/multimediakitwidgets/qpaintervideosurface.cpp | 1728 -------------------- .../qpaintervideosurface_mac.mm | 285 ---- .../qpaintervideosurface_mac_p.h | 103 -- src/multimediakitwidgets/qpaintervideosurface_p.h | 191 --- .../qtmultimediakitwidgetdefs.h | 89 - src/multimediakitwidgets/qvideowidget.cpp | 1043 ------------ src/multimediakitwidgets/qvideowidget.h | 139 -- src/multimediakitwidgets/qvideowidget_p.h | 290 ---- src/multimediakitwidgets/qvideowidgetcontrol.cpp | 245 --- src/multimediakitwidgets/qvideowidgetcontrol.h | 105 -- src/multimediakitwidgets/qvideowindowcontrol.cpp | 284 ---- src/multimediakitwidgets/qvideowindowcontrol.h | 112 -- src/multimediawidgets/multimediawidgets.pro | 68 + src/multimediawidgets/qcameraviewfinder.cpp | 113 ++ src/multimediawidgets/qcameraviewfinder.h | 90 + src/multimediawidgets/qeglimagetexturesurface.cpp | 554 +++++++ src/multimediawidgets/qeglimagetexturesurface_p.h | 150 ++ src/multimediawidgets/qgraphicsvideoitem.cpp | 432 +++++ src/multimediawidgets/qgraphicsvideoitem.h | 115 ++ .../qgraphicsvideoitem_maemo6.cpp | 498 ++++++ src/multimediawidgets/qpaintervideosurface.cpp | 1728 ++++++++++++++++++++ src/multimediawidgets/qpaintervideosurface_mac.mm | 285 ++++ src/multimediawidgets/qpaintervideosurface_mac_p.h | 103 ++ src/multimediawidgets/qpaintervideosurface_p.h | 191 +++ src/multimediawidgets/qtmultimediawidgetdefs.h | 89 + src/multimediawidgets/qvideowidget.cpp | 1043 ++++++++++++ src/multimediawidgets/qvideowidget.h | 139 ++ src/multimediawidgets/qvideowidget_p.h | 290 ++++ src/multimediawidgets/qvideowidgetcontrol.cpp | 245 +++ src/multimediawidgets/qvideowidgetcontrol.h | 105 ++ src/multimediawidgets/qvideowindowcontrol.cpp | 284 ++++ src/multimediawidgets/qvideowindowcontrol.h | 112 ++ src/plugins/audiocapture/audiocapture.pro | 4 +- src/plugins/audiocapture/audioencodercontrol.cpp | 10 +- src/plugins/directshow/directshow.pro | 5 +- .../player/directshowmetadatacontrol.cpp | 114 +- .../directshow/player/directshowmetadatacontrol.h | 4 +- src/plugins/fakeradio/fakeradio.pro | 4 +- src/plugins/fakeradio/fakeradiotunercontrol.cpp | 4 +- src/plugins/fakeradio/fakeradiotunercontrol.h | 2 +- .../gstreamer/camerabin/camerabinimagecapture.cpp | 32 +- .../gstreamer/camerabin/camerabinmetadata.cpp | 108 +- .../gstreamer/camerabin/camerabinmetadata.h | 6 +- src/plugins/gstreamer/gstreamer.pro | 4 +- .../mediacapture/qgstreameraudioencode.cpp | 4 +- .../qgstreamercapturemetadatacontrol.cpp | 108 +- .../qgstreamercapturemetadatacontrol.h | 6 +- .../mediacapture/qgstreamervideoencode.cpp | 4 +- .../mediaplayer/qgstreamermetadataprovider.cpp | 106 +- .../mediaplayer/qgstreamermetadataprovider.h | 4 +- .../mediaplayer/qgstreamerplayersession.cpp | 8 +- .../mediaplayer/qgstreamerplayersession.h | 4 +- .../mediaplayer/qgstreamerstreamscontrol.cpp | 2 +- .../mediaplayer/qgstreamerstreamscontrol.h | 2 +- src/plugins/gstreamer/qgstreamerserviceplugin.cpp | 8 +- src/plugins/gstreamer/qgstreamerserviceplugin.h | 2 +- src/plugins/m3u/m3u.pro | 6 +- src/plugins/m3u/main.cpp | 2 +- src/plugins/plugins.pro | 2 +- src/plugins/pulseaudio/pulseaudio.pro | 4 +- src/plugins/qt7/mediaplayer/qt7playermetadata.h | 6 +- src/plugins/qt7/mediaplayer/qt7playermetadata.mm | 18 +- src/plugins/qt7/qcvdisplaylink.h | 2 +- src/plugins/qt7/qt7.pro | 4 +- src/plugins/qt7/qt7backend.h | 2 +- src/plugins/qt7/qt7serviceplugin.h | 2 +- src/plugins/qt7/qt7serviceplugin.mm | 6 +- src/plugins/simulator/qsimulatormultimediadata_p.h | 2 +- src/plugins/v4l/radio/v4lradiocontrol.cpp | 6 +- src/plugins/v4l/radio/v4lradiocontrol.h | 2 +- src/plugins/v4l/v4l.pro | 4 +- src/plugins/wmf/player/mfmetadatacontrol.cpp | 24 +- src/plugins/wmf/player/mfmetadatacontrol.h | 6 +- src/plugins/wmf/wmf.pro | 4 +- src/src.pro | 8 +- sync.profile | 13 +- tests/auto/auto.pro | 2 +- .../qabstractvideobuffer/qabstractvideobuffer.pro | 2 +- .../qabstractvideosurface.pro | 2 +- .../qaudiocapturesource/qaudiocapturesource.pro | 2 +- .../tst_qaudiocapturesource.cpp | 4 +- tests/auto/qaudiodeviceinfo/qaudiodeviceinfo.pro | 2 +- tests/auto/qaudioformat/qaudioformat.pro | 2 +- tests/auto/qaudioinput/qaudioinput.pro | 2 +- tests/auto/qaudiooutput/qaudiooutput.pro | 2 +- tests/auto/qcamera/qcamera.pro | 2 +- tests/auto/qcamera/tst_qcamera.cpp | 32 +- tests/auto/qcamerabackend/qcamerabackend.pro | 2 +- tests/auto/qcamerabackend/tst_qcamerabackend.cpp | 6 +- .../qcameraimagecapture/qcameraimagecapture.pro | 2 +- .../tst_qcameraimagecapture.cpp | 10 +- tests/auto/qcameraviewfinder/qcameraviewfinder.pro | 2 +- tests/auto/qcamerawidgets/qcamerawidgets.pro | 2 +- tests/auto/qcamerawidgets/tst_qcamerawidgets.cpp | 4 +- tests/auto/qdeclarativeaudio/qdeclarativeaudio.pro | 14 +- .../qdeclarativeaudio/tst_qdeclarativeaudio.cpp | 20 +- tests/auto/qdeclarativevideo/qdeclarativevideo.pro | 14 +- .../qdeclarativevideo/tst_qdeclarativevideo.cpp | 2 +- .../auto/qgraphicsvideoitem/qgraphicsvideoitem.pro | 2 +- .../qgraphicsvideoitem/tst_qgraphicsvideoitem.cpp | 2 +- .../qmediabindableinterface.pro | 2 +- .../qmediacontainercontrol.pro | 2 +- tests/auto/qmediacontent/qmediacontent.pro | 2 +- tests/auto/qmediaimageviewer/qmediaimageviewer.pro | 2 +- .../qmediaimageviewer/tst_qmediaimageviewer.cpp | 2 +- .../qmediaimageviewerwidgets.pro | 2 +- .../tst_qmediaimageviewerwidgets.cpp | 2 +- tests/auto/qmediaobject/qmediaobject.pro | 2 +- tests/auto/qmediaobject/tst_qmediaobject.cpp | 26 +- tests/auto/qmediaplayer/qmediaplayer.pro | 2 +- tests/auto/qmediaplayer/tst_qmediaplayer.cpp | 4 +- .../qmediaplayerbackend/qmediaplayerbackend.pro | 2 +- .../qmediaplayerwidgets/qmediaplayerwidgets.pro | 2 +- tests/auto/qmediaplaylist/qmediaplaylist.pro | 8 +- .../qmediaplaylistnavigator.pro | 2 +- .../auto/qmediapluginloader/qmediapluginloader.pro | 2 +- tests/auto/qmediarecorder/qmediarecorder.pro | 2 +- tests/auto/qmediarecorder/tst_qmediarecorder.cpp | 198 +-- tests/auto/qmediaresource/qmediaresource.pro | 2 +- tests/auto/qmediaservice/qmediaservice.pro | 2 +- .../qmediaserviceprovider.pro | 2 +- .../tst_qmediaserviceprovider.cpp | 50 +- .../qmediastreamscontrol/qmediastreamscontrol.pro | 2 +- .../tst_qmediastreamscontrol.cpp | 12 +- tests/auto/qmediatimerange/qmediatimerange.pro | 2 +- .../qmetadatareadercontrol.pro | 2 +- .../tst_qmetadatareadercontrol.cpp | 2 +- .../qmetadatawritercontrol.pro | 2 +- .../tst_qmetadatawritercontrol.cpp | 4 +- .../mockcameraimagecapturecontrol.h | 4 +- tests/auto/qmultimedia_common/mockcameraservice.h | 10 +- .../qmultimedia_common/mockimageencodercontrol.h | 4 +- .../qmultimedia_common/mockmediaplayerservice.h | 12 +- .../qmultimedia_common/mockmediastreamscontrol.h | 6 +- .../qmultimedia_common/mockmetadatareadercontrol.h | 6 +- .../qmultimedia_common/mockmetadatawritercontrol.h | 8 +- .../qmultimedia_common/mockradiotunercontrol.h | 4 +- tests/auto/qmultimedia_common/mockvideo.pri | 4 +- .../qmultimedia_common/mockvideowindowcontrol.h | 4 +- .../qpaintervideosurface/qpaintervideosurface.pro | 2 +- tests/auto/qradiotuner/qradiotuner.pro | 2 +- tests/auto/qradiotuner/tst_qradiotuner.cpp | 6 +- tests/auto/qsoundeffect/qsoundeffect.pro | 2 +- .../qvideodevicecontrol/qvideodevicecontrol.pro | 2 +- .../qvideoencodercontrol/qvideoencodercontrol.pro | 2 +- tests/auto/qvideoframe/qvideoframe.pro | 2 +- .../qvideosurfaceformat/qvideosurfaceformat.pro | 2 +- tests/auto/qvideowidget/qvideowidget.pro | 2 +- tests/auto/qvideowidget/tst_qvideowidget.cpp | 2 +- 599 files changed, 51625 insertions(+), 53320 deletions(-) create mode 100644 modules/qt_multimedia.pri delete mode 100644 modules/qt_multimediakit.pri delete mode 100644 modules/qt_multimediakitwidgets.pri create mode 100644 modules/qt_multimediawidgets.pri create mode 100644 qtmultimedia.pro create mode 100644 src/imports/multimedia/qmldir.qtmultimediakit delete mode 100644 src/meegoinstalls/Makefile delete mode 100644 src/meegoinstalls/README delete mode 100644 src/meegoinstalls/qt-mobility.spec delete mode 100644 src/meegoinstalls/qt-mobility.yaml create mode 100644 src/multimedia/audio/audio.pri create mode 100644 src/multimedia/audio/qaudio.cpp create mode 100644 src/multimedia/audio/qaudio.h create mode 100644 src/multimedia/audio/qaudio_mac.cpp create mode 100644 src/multimedia/audio/qaudio_mac_p.h create mode 100644 src/multimedia/audio/qaudiodevicefactory.cpp create mode 100644 src/multimedia/audio/qaudiodevicefactory_p.h create mode 100644 src/multimedia/audio/qaudiodeviceinfo.cpp create mode 100644 src/multimedia/audio/qaudiodeviceinfo.h create mode 100644 src/multimedia/audio/qaudiodeviceinfo_alsa_p.cpp create mode 100644 src/multimedia/audio/qaudiodeviceinfo_alsa_p.h create mode 100644 src/multimedia/audio/qaudiodeviceinfo_mac_p.cpp create mode 100644 src/multimedia/audio/qaudiodeviceinfo_mac_p.h create mode 100644 src/multimedia/audio/qaudiodeviceinfo_win32_p.cpp create mode 100644 src/multimedia/audio/qaudiodeviceinfo_win32_p.h create mode 100644 src/multimedia/audio/qaudioformat.cpp create mode 100644 src/multimedia/audio/qaudioformat.h create mode 100644 src/multimedia/audio/qaudioinput.cpp create mode 100644 src/multimedia/audio/qaudioinput.h create mode 100644 src/multimedia/audio/qaudioinput_alsa_p.cpp create mode 100644 src/multimedia/audio/qaudioinput_alsa_p.h create mode 100644 src/multimedia/audio/qaudioinput_mac_p.cpp create mode 100644 src/multimedia/audio/qaudioinput_mac_p.h create mode 100644 src/multimedia/audio/qaudioinput_win32_p.cpp create mode 100644 src/multimedia/audio/qaudioinput_win32_p.h create mode 100644 src/multimedia/audio/qaudiooutput.cpp create mode 100644 src/multimedia/audio/qaudiooutput.h create mode 100644 src/multimedia/audio/qaudiooutput_alsa_p.cpp create mode 100644 src/multimedia/audio/qaudiooutput_alsa_p.h create mode 100644 src/multimedia/audio/qaudiooutput_mac_p.cpp create mode 100644 src/multimedia/audio/qaudiooutput_mac_p.h create mode 100644 src/multimedia/audio/qaudiooutput_win32_p.cpp create mode 100644 src/multimedia/audio/qaudiooutput_win32_p.h create mode 100644 src/multimedia/audio/qaudiopluginloader.cpp create mode 100644 src/multimedia/audio/qaudiopluginloader_p.h create mode 100644 src/multimedia/audio/qaudiosystem.cpp create mode 100644 src/multimedia/audio/qaudiosystem.h create mode 100644 src/multimedia/audio/qaudiosystemplugin.cpp create mode 100644 src/multimedia/audio/qaudiosystemplugin.h create mode 100644 src/multimedia/effects/effects.pri create mode 100644 src/multimedia/effects/qsamplecache_p.cpp create mode 100644 src/multimedia/effects/qsamplecache_p.h create mode 100644 src/multimedia/effects/qsoundeffect.cpp create mode 100644 src/multimedia/effects/qsoundeffect_p.h create mode 100644 src/multimedia/effects/qsoundeffect_pulse_p.cpp create mode 100644 src/multimedia/effects/qsoundeffect_pulse_p.h create mode 100644 src/multimedia/effects/qsoundeffect_qmedia_p.cpp create mode 100644 src/multimedia/effects/qsoundeffect_qmedia_p.h create mode 100644 src/multimedia/effects/qsoundeffect_qsound_p.cpp create mode 100644 src/multimedia/effects/qsoundeffect_qsound_p.h create mode 100644 src/multimedia/effects/qwavedecoder_p.cpp create mode 100644 src/multimedia/effects/qwavedecoder_p.h create mode 100644 src/multimedia/multimedia.pro create mode 100644 src/multimedia/qaudiocapturesource.cpp create mode 100644 src/multimedia/qaudiocapturesource.h create mode 100644 src/multimedia/qaudioencodercontrol.cpp create mode 100644 src/multimedia/qaudioencodercontrol.h create mode 100644 src/multimedia/qaudioendpointselector.cpp create mode 100644 src/multimedia/qaudioendpointselector.h create mode 100644 src/multimedia/qaudionamespace.qdoc create mode 100644 src/multimedia/qcamera.cpp create mode 100644 src/multimedia/qcamera.h create mode 100644 src/multimedia/qcameracapturebufferformatcontrol.cpp create mode 100644 src/multimedia/qcameracapturebufferformatcontrol.h create mode 100644 src/multimedia/qcameracapturedestinationcontrol.cpp create mode 100644 src/multimedia/qcameracapturedestinationcontrol.h create mode 100644 src/multimedia/qcameracontrol.cpp create mode 100644 src/multimedia/qcameracontrol.h create mode 100644 src/multimedia/qcameraexposure.cpp create mode 100644 src/multimedia/qcameraexposure.h create mode 100644 src/multimedia/qcameraexposurecontrol.cpp create mode 100644 src/multimedia/qcameraexposurecontrol.h create mode 100644 src/multimedia/qcameraflashcontrol.cpp create mode 100644 src/multimedia/qcameraflashcontrol.h create mode 100644 src/multimedia/qcamerafocus.cpp create mode 100644 src/multimedia/qcamerafocus.h create mode 100644 src/multimedia/qcamerafocuscontrol.cpp create mode 100644 src/multimedia/qcamerafocuscontrol.h create mode 100644 src/multimedia/qcameraimagecapture.cpp create mode 100644 src/multimedia/qcameraimagecapture.h create mode 100644 src/multimedia/qcameraimagecapturecontrol.cpp create mode 100644 src/multimedia/qcameraimagecapturecontrol.h create mode 100644 src/multimedia/qcameraimageprocessing.cpp create mode 100644 src/multimedia/qcameraimageprocessing.h create mode 100644 src/multimedia/qcameraimageprocessingcontrol.cpp create mode 100644 src/multimedia/qcameraimageprocessingcontrol.h create mode 100644 src/multimedia/qcameralockscontrol.cpp create mode 100644 src/multimedia/qcameralockscontrol.h create mode 100644 src/multimedia/qimageencodercontrol.cpp create mode 100644 src/multimedia/qimageencodercontrol.h create mode 100644 src/multimedia/qlocalmediaplaylistprovider.cpp create mode 100644 src/multimedia/qlocalmediaplaylistprovider.h create mode 100644 src/multimedia/qmediabackgroundplaybackcontrol.cpp create mode 100644 src/multimedia/qmediabackgroundplaybackcontrol.h create mode 100644 src/multimedia/qmediabindableinterface.cpp create mode 100644 src/multimedia/qmediabindableinterface.h create mode 100644 src/multimedia/qmediacontainercontrol.cpp create mode 100644 src/multimedia/qmediacontainercontrol.h create mode 100644 src/multimedia/qmediacontent.cpp create mode 100644 src/multimedia/qmediacontent.h create mode 100644 src/multimedia/qmediacontrol.cpp create mode 100644 src/multimedia/qmediacontrol.h create mode 100644 src/multimedia/qmediacontrol_p.h create mode 100644 src/multimedia/qmediaencodersettings.cpp create mode 100644 src/multimedia/qmediaencodersettings.h create mode 100644 src/multimedia/qmediaenumdebug.h create mode 100644 src/multimedia/qmediaimageviewer.cpp create mode 100644 src/multimedia/qmediaimageviewer.h create mode 100644 src/multimedia/qmediaimageviewerservice.cpp create mode 100644 src/multimedia/qmediaimageviewerservice_p.h create mode 100644 src/multimedia/qmedianetworkaccesscontrol.cpp create mode 100644 src/multimedia/qmedianetworkaccesscontrol.h create mode 100644 src/multimedia/qmediaobject.cpp create mode 100644 src/multimedia/qmediaobject.h create mode 100644 src/multimedia/qmediaobject_p.h create mode 100644 src/multimedia/qmediaplayer.cpp create mode 100644 src/multimedia/qmediaplayer.h create mode 100644 src/multimedia/qmediaplayercontrol.cpp create mode 100644 src/multimedia/qmediaplayercontrol.h create mode 100644 src/multimedia/qmediaplaylist.cpp create mode 100644 src/multimedia/qmediaplaylist.h create mode 100644 src/multimedia/qmediaplaylist_p.h create mode 100644 src/multimedia/qmediaplaylistcontrol.cpp create mode 100644 src/multimedia/qmediaplaylistcontrol.h create mode 100644 src/multimedia/qmediaplaylistioplugin.cpp create mode 100644 src/multimedia/qmediaplaylistioplugin.h create mode 100644 src/multimedia/qmediaplaylistnavigator.cpp create mode 100644 src/multimedia/qmediaplaylistnavigator.h create mode 100644 src/multimedia/qmediaplaylistprovider.cpp create mode 100644 src/multimedia/qmediaplaylistprovider.h create mode 100644 src/multimedia/qmediaplaylistprovider_p.h create mode 100644 src/multimedia/qmediaplaylistsourcecontrol.cpp create mode 100644 src/multimedia/qmediaplaylistsourcecontrol.h create mode 100644 src/multimedia/qmediapluginloader.cpp create mode 100644 src/multimedia/qmediapluginloader_p.h create mode 100644 src/multimedia/qmediarecorder.cpp create mode 100644 src/multimedia/qmediarecorder.h create mode 100644 src/multimedia/qmediarecordercontrol.cpp create mode 100644 src/multimedia/qmediarecordercontrol.h create mode 100644 src/multimedia/qmediaresource.cpp create mode 100644 src/multimedia/qmediaresource.h create mode 100644 src/multimedia/qmediaservice.cpp create mode 100644 src/multimedia/qmediaservice.h create mode 100644 src/multimedia/qmediaservice_p.h create mode 100644 src/multimedia/qmediaserviceprovider.cpp create mode 100644 src/multimedia/qmediaserviceprovider.h create mode 100644 src/multimedia/qmediaserviceproviderplugin.h create mode 100644 src/multimedia/qmediastreamscontrol.cpp create mode 100644 src/multimedia/qmediastreamscontrol.h create mode 100644 src/multimedia/qmediatimerange.cpp create mode 100644 src/multimedia/qmediatimerange.h create mode 100644 src/multimedia/qmetadatareadercontrol.cpp create mode 100644 src/multimedia/qmetadatareadercontrol.h create mode 100644 src/multimedia/qmetadatawritercontrol.cpp create mode 100644 src/multimedia/qmetadatawritercontrol.h create mode 100644 src/multimedia/qradiotuner.cpp create mode 100644 src/multimedia/qradiotuner.h create mode 100644 src/multimedia/qradiotunercontrol.cpp create mode 100644 src/multimedia/qradiotunercontrol.h create mode 100644 src/multimedia/qtmedianamespace.h create mode 100644 src/multimedia/qtmedianamespace.qdoc create mode 100644 src/multimedia/qtmultimediadefs.h create mode 100644 src/multimedia/qvideodevicecontrol.cpp create mode 100644 src/multimedia/qvideodevicecontrol.h create mode 100644 src/multimedia/qvideoencodercontrol.cpp create mode 100644 src/multimedia/qvideoencodercontrol.h create mode 100644 src/multimedia/qvideorenderercontrol.cpp create mode 100644 src/multimedia/qvideorenderercontrol.h create mode 100644 src/multimedia/qvideosurfaceoutput.cpp create mode 100644 src/multimedia/qvideosurfaceoutput_p.h create mode 100644 src/multimedia/video/qabstractvideobuffer.cpp create mode 100644 src/multimedia/video/qabstractvideobuffer.h create mode 100644 src/multimedia/video/qabstractvideobuffer_p.h create mode 100644 src/multimedia/video/qabstractvideosurface.cpp create mode 100644 src/multimedia/video/qabstractvideosurface.h create mode 100644 src/multimedia/video/qimagevideobuffer.cpp create mode 100644 src/multimedia/video/qimagevideobuffer_p.h create mode 100644 src/multimedia/video/qmemoryvideobuffer.cpp create mode 100644 src/multimedia/video/qmemoryvideobuffer_p.h create mode 100644 src/multimedia/video/qvideoframe.cpp create mode 100644 src/multimedia/video/qvideoframe.h create mode 100644 src/multimedia/video/qvideosurfaceformat.cpp create mode 100644 src/multimedia/video/qvideosurfaceformat.h create mode 100644 src/multimedia/video/video.pri delete mode 100644 src/multimediakit/audio/audio.pri delete mode 100644 src/multimediakit/audio/qaudio.cpp delete mode 100644 src/multimediakit/audio/qaudio.h delete mode 100644 src/multimediakit/audio/qaudio_mac.cpp delete mode 100644 src/multimediakit/audio/qaudio_mac_p.h delete mode 100644 src/multimediakit/audio/qaudiodevicefactory.cpp delete mode 100644 src/multimediakit/audio/qaudiodevicefactory_p.h delete mode 100644 src/multimediakit/audio/qaudiodeviceinfo.cpp delete mode 100644 src/multimediakit/audio/qaudiodeviceinfo.h delete mode 100644 src/multimediakit/audio/qaudiodeviceinfo_alsa_p.cpp delete mode 100644 src/multimediakit/audio/qaudiodeviceinfo_alsa_p.h delete mode 100644 src/multimediakit/audio/qaudiodeviceinfo_mac_p.cpp delete mode 100644 src/multimediakit/audio/qaudiodeviceinfo_mac_p.h delete mode 100644 src/multimediakit/audio/qaudiodeviceinfo_win32_p.cpp delete mode 100644 src/multimediakit/audio/qaudiodeviceinfo_win32_p.h delete mode 100644 src/multimediakit/audio/qaudioformat.cpp delete mode 100644 src/multimediakit/audio/qaudioformat.h delete mode 100644 src/multimediakit/audio/qaudioinput.cpp delete mode 100644 src/multimediakit/audio/qaudioinput.h delete mode 100644 src/multimediakit/audio/qaudioinput_alsa_p.cpp delete mode 100644 src/multimediakit/audio/qaudioinput_alsa_p.h delete mode 100644 src/multimediakit/audio/qaudioinput_mac_p.cpp delete mode 100644 src/multimediakit/audio/qaudioinput_mac_p.h delete mode 100644 src/multimediakit/audio/qaudioinput_win32_p.cpp delete mode 100644 src/multimediakit/audio/qaudioinput_win32_p.h delete mode 100644 src/multimediakit/audio/qaudiooutput.cpp delete mode 100644 src/multimediakit/audio/qaudiooutput.h delete mode 100644 src/multimediakit/audio/qaudiooutput_alsa_p.cpp delete mode 100644 src/multimediakit/audio/qaudiooutput_alsa_p.h delete mode 100644 src/multimediakit/audio/qaudiooutput_mac_p.cpp delete mode 100644 src/multimediakit/audio/qaudiooutput_mac_p.h delete mode 100644 src/multimediakit/audio/qaudiooutput_win32_p.cpp delete mode 100644 src/multimediakit/audio/qaudiooutput_win32_p.h delete mode 100644 src/multimediakit/audio/qaudiopluginloader.cpp delete mode 100644 src/multimediakit/audio/qaudiopluginloader_p.h delete mode 100644 src/multimediakit/audio/qaudiosystem.cpp delete mode 100644 src/multimediakit/audio/qaudiosystem.h delete mode 100644 src/multimediakit/audio/qaudiosystemplugin.cpp delete mode 100644 src/multimediakit/audio/qaudiosystemplugin.h delete mode 100644 src/multimediakit/effects/effects.pri delete mode 100644 src/multimediakit/effects/qsamplecache_p.cpp delete mode 100644 src/multimediakit/effects/qsamplecache_p.h delete mode 100644 src/multimediakit/effects/qsoundeffect.cpp delete mode 100644 src/multimediakit/effects/qsoundeffect_p.h delete mode 100644 src/multimediakit/effects/qsoundeffect_pulse_p.cpp delete mode 100644 src/multimediakit/effects/qsoundeffect_pulse_p.h delete mode 100644 src/multimediakit/effects/qsoundeffect_qmedia_p.cpp delete mode 100644 src/multimediakit/effects/qsoundeffect_qmedia_p.h delete mode 100644 src/multimediakit/effects/qsoundeffect_qsound_p.cpp delete mode 100644 src/multimediakit/effects/qsoundeffect_qsound_p.h delete mode 100644 src/multimediakit/effects/qwavedecoder_p.cpp delete mode 100644 src/multimediakit/effects/qwavedecoder_p.h delete mode 100644 src/multimediakit/multimediakit.pro delete mode 100644 src/multimediakit/qaudiocapturesource.cpp delete mode 100644 src/multimediakit/qaudiocapturesource.h delete mode 100644 src/multimediakit/qaudioencodercontrol.cpp delete mode 100644 src/multimediakit/qaudioencodercontrol.h delete mode 100644 src/multimediakit/qaudioendpointselector.cpp delete mode 100644 src/multimediakit/qaudioendpointselector.h delete mode 100644 src/multimediakit/qaudionamespace.qdoc delete mode 100644 src/multimediakit/qcamera.cpp delete mode 100644 src/multimediakit/qcamera.h delete mode 100644 src/multimediakit/qcameracapturebufferformatcontrol.cpp delete mode 100644 src/multimediakit/qcameracapturebufferformatcontrol.h delete mode 100644 src/multimediakit/qcameracapturedestinationcontrol.cpp delete mode 100644 src/multimediakit/qcameracapturedestinationcontrol.h delete mode 100644 src/multimediakit/qcameracontrol.cpp delete mode 100644 src/multimediakit/qcameracontrol.h delete mode 100644 src/multimediakit/qcameraexposure.cpp delete mode 100644 src/multimediakit/qcameraexposure.h delete mode 100644 src/multimediakit/qcameraexposurecontrol.cpp delete mode 100644 src/multimediakit/qcameraexposurecontrol.h delete mode 100644 src/multimediakit/qcameraflashcontrol.cpp delete mode 100644 src/multimediakit/qcameraflashcontrol.h delete mode 100644 src/multimediakit/qcamerafocus.cpp delete mode 100644 src/multimediakit/qcamerafocus.h delete mode 100644 src/multimediakit/qcamerafocuscontrol.cpp delete mode 100644 src/multimediakit/qcamerafocuscontrol.h delete mode 100644 src/multimediakit/qcameraimagecapture.cpp delete mode 100644 src/multimediakit/qcameraimagecapture.h delete mode 100644 src/multimediakit/qcameraimagecapturecontrol.cpp delete mode 100644 src/multimediakit/qcameraimagecapturecontrol.h delete mode 100644 src/multimediakit/qcameraimageprocessing.cpp delete mode 100644 src/multimediakit/qcameraimageprocessing.h delete mode 100644 src/multimediakit/qcameraimageprocessingcontrol.cpp delete mode 100644 src/multimediakit/qcameraimageprocessingcontrol.h delete mode 100644 src/multimediakit/qcameralockscontrol.cpp delete mode 100644 src/multimediakit/qcameralockscontrol.h delete mode 100644 src/multimediakit/qimageencodercontrol.cpp delete mode 100644 src/multimediakit/qimageencodercontrol.h delete mode 100644 src/multimediakit/qlocalmediaplaylistprovider.cpp delete mode 100644 src/multimediakit/qlocalmediaplaylistprovider.h delete mode 100644 src/multimediakit/qmediabackgroundplaybackcontrol.cpp delete mode 100644 src/multimediakit/qmediabackgroundplaybackcontrol.h delete mode 100644 src/multimediakit/qmediabindableinterface.cpp delete mode 100644 src/multimediakit/qmediabindableinterface.h delete mode 100644 src/multimediakit/qmediacontainercontrol.cpp delete mode 100644 src/multimediakit/qmediacontainercontrol.h delete mode 100644 src/multimediakit/qmediacontent.cpp delete mode 100644 src/multimediakit/qmediacontent.h delete mode 100644 src/multimediakit/qmediacontrol.cpp delete mode 100644 src/multimediakit/qmediacontrol.h delete mode 100644 src/multimediakit/qmediacontrol_p.h delete mode 100644 src/multimediakit/qmediaencodersettings.cpp delete mode 100644 src/multimediakit/qmediaencodersettings.h delete mode 100644 src/multimediakit/qmediaenumdebug.h delete mode 100644 src/multimediakit/qmediaimageviewer.cpp delete mode 100644 src/multimediakit/qmediaimageviewer.h delete mode 100644 src/multimediakit/qmediaimageviewerservice.cpp delete mode 100644 src/multimediakit/qmediaimageviewerservice_p.h delete mode 100644 src/multimediakit/qmedianetworkaccesscontrol.cpp delete mode 100644 src/multimediakit/qmedianetworkaccesscontrol.h delete mode 100644 src/multimediakit/qmediaobject.cpp delete mode 100644 src/multimediakit/qmediaobject.h delete mode 100644 src/multimediakit/qmediaobject_p.h delete mode 100644 src/multimediakit/qmediaplayer.cpp delete mode 100644 src/multimediakit/qmediaplayer.h delete mode 100644 src/multimediakit/qmediaplayercontrol.cpp delete mode 100644 src/multimediakit/qmediaplayercontrol.h delete mode 100644 src/multimediakit/qmediaplaylist.cpp delete mode 100644 src/multimediakit/qmediaplaylist.h delete mode 100644 src/multimediakit/qmediaplaylist_p.h delete mode 100644 src/multimediakit/qmediaplaylistcontrol.cpp delete mode 100644 src/multimediakit/qmediaplaylistcontrol.h delete mode 100644 src/multimediakit/qmediaplaylistioplugin.cpp delete mode 100644 src/multimediakit/qmediaplaylistioplugin.h delete mode 100644 src/multimediakit/qmediaplaylistnavigator.cpp delete mode 100644 src/multimediakit/qmediaplaylistnavigator.h delete mode 100644 src/multimediakit/qmediaplaylistprovider.cpp delete mode 100644 src/multimediakit/qmediaplaylistprovider.h delete mode 100644 src/multimediakit/qmediaplaylistprovider_p.h delete mode 100644 src/multimediakit/qmediaplaylistsourcecontrol.cpp delete mode 100644 src/multimediakit/qmediaplaylistsourcecontrol.h delete mode 100644 src/multimediakit/qmediapluginloader.cpp delete mode 100644 src/multimediakit/qmediapluginloader_p.h delete mode 100644 src/multimediakit/qmediarecorder.cpp delete mode 100644 src/multimediakit/qmediarecorder.h delete mode 100644 src/multimediakit/qmediarecordercontrol.cpp delete mode 100644 src/multimediakit/qmediarecordercontrol.h delete mode 100644 src/multimediakit/qmediaresource.cpp delete mode 100644 src/multimediakit/qmediaresource.h delete mode 100644 src/multimediakit/qmediaservice.cpp delete mode 100644 src/multimediakit/qmediaservice.h delete mode 100644 src/multimediakit/qmediaservice_p.h delete mode 100644 src/multimediakit/qmediaserviceprovider.cpp delete mode 100644 src/multimediakit/qmediaserviceprovider.h delete mode 100644 src/multimediakit/qmediaserviceproviderplugin.h delete mode 100644 src/multimediakit/qmediastreamscontrol.cpp delete mode 100644 src/multimediakit/qmediastreamscontrol.h delete mode 100644 src/multimediakit/qmediatimerange.cpp delete mode 100644 src/multimediakit/qmediatimerange.h delete mode 100644 src/multimediakit/qmetadatareadercontrol.cpp delete mode 100644 src/multimediakit/qmetadatareadercontrol.h delete mode 100644 src/multimediakit/qmetadatawritercontrol.cpp delete mode 100644 src/multimediakit/qmetadatawritercontrol.h delete mode 100644 src/multimediakit/qradiotuner.cpp delete mode 100644 src/multimediakit/qradiotuner.h delete mode 100644 src/multimediakit/qradiotunercontrol.cpp delete mode 100644 src/multimediakit/qradiotunercontrol.h delete mode 100644 src/multimediakit/qtmedianamespace.h delete mode 100644 src/multimediakit/qtmedianamespace.qdoc delete mode 100644 src/multimediakit/qtmultimediakitdefs.h delete mode 100644 src/multimediakit/qvideodevicecontrol.cpp delete mode 100644 src/multimediakit/qvideodevicecontrol.h delete mode 100644 src/multimediakit/qvideoencodercontrol.cpp delete mode 100644 src/multimediakit/qvideoencodercontrol.h delete mode 100644 src/multimediakit/qvideorenderercontrol.cpp delete mode 100644 src/multimediakit/qvideorenderercontrol.h delete mode 100644 src/multimediakit/qvideosurfaceoutput.cpp delete mode 100644 src/multimediakit/qvideosurfaceoutput_p.h delete mode 100644 src/multimediakit/video/qabstractvideobuffer.cpp delete mode 100644 src/multimediakit/video/qabstractvideobuffer.h delete mode 100644 src/multimediakit/video/qabstractvideobuffer_p.h delete mode 100644 src/multimediakit/video/qabstractvideosurface.cpp delete mode 100644 src/multimediakit/video/qabstractvideosurface.h delete mode 100644 src/multimediakit/video/qimagevideobuffer.cpp delete mode 100644 src/multimediakit/video/qimagevideobuffer_p.h delete mode 100644 src/multimediakit/video/qmemoryvideobuffer.cpp delete mode 100644 src/multimediakit/video/qmemoryvideobuffer_p.h delete mode 100644 src/multimediakit/video/qvideoframe.cpp delete mode 100644 src/multimediakit/video/qvideoframe.h delete mode 100644 src/multimediakit/video/qvideosurfaceformat.cpp delete mode 100644 src/multimediakit/video/qvideosurfaceformat.h delete mode 100644 src/multimediakit/video/video.pri delete mode 100644 src/multimediakitwidgets/multimediakitwidgets.pro delete mode 100644 src/multimediakitwidgets/qcameraviewfinder.cpp delete mode 100644 src/multimediakitwidgets/qcameraviewfinder.h delete mode 100644 src/multimediakitwidgets/qeglimagetexturesurface.cpp delete mode 100644 src/multimediakitwidgets/qeglimagetexturesurface_p.h delete mode 100644 src/multimediakitwidgets/qgraphicsvideoitem.cpp delete mode 100644 src/multimediakitwidgets/qgraphicsvideoitem.h delete mode 100644 src/multimediakitwidgets/qgraphicsvideoitem_maemo6.cpp delete mode 100644 src/multimediakitwidgets/qpaintervideosurface.cpp delete mode 100644 src/multimediakitwidgets/qpaintervideosurface_mac.mm delete mode 100644 src/multimediakitwidgets/qpaintervideosurface_mac_p.h delete mode 100644 src/multimediakitwidgets/qpaintervideosurface_p.h delete mode 100644 src/multimediakitwidgets/qtmultimediakitwidgetdefs.h delete mode 100644 src/multimediakitwidgets/qvideowidget.cpp delete mode 100644 src/multimediakitwidgets/qvideowidget.h delete mode 100644 src/multimediakitwidgets/qvideowidget_p.h delete mode 100644 src/multimediakitwidgets/qvideowidgetcontrol.cpp delete mode 100644 src/multimediakitwidgets/qvideowidgetcontrol.h delete mode 100644 src/multimediakitwidgets/qvideowindowcontrol.cpp delete mode 100644 src/multimediakitwidgets/qvideowindowcontrol.h create mode 100644 src/multimediawidgets/multimediawidgets.pro create mode 100644 src/multimediawidgets/qcameraviewfinder.cpp create mode 100644 src/multimediawidgets/qcameraviewfinder.h create mode 100644 src/multimediawidgets/qeglimagetexturesurface.cpp create mode 100644 src/multimediawidgets/qeglimagetexturesurface_p.h create mode 100644 src/multimediawidgets/qgraphicsvideoitem.cpp create mode 100644 src/multimediawidgets/qgraphicsvideoitem.h create mode 100644 src/multimediawidgets/qgraphicsvideoitem_maemo6.cpp create mode 100644 src/multimediawidgets/qpaintervideosurface.cpp create mode 100644 src/multimediawidgets/qpaintervideosurface_mac.mm create mode 100644 src/multimediawidgets/qpaintervideosurface_mac_p.h create mode 100644 src/multimediawidgets/qpaintervideosurface_p.h create mode 100644 src/multimediawidgets/qtmultimediawidgetdefs.h create mode 100644 src/multimediawidgets/qvideowidget.cpp create mode 100644 src/multimediawidgets/qvideowidget.h create mode 100644 src/multimediawidgets/qvideowidget_p.h create mode 100644 src/multimediawidgets/qvideowidgetcontrol.cpp create mode 100644 src/multimediawidgets/qvideowidgetcontrol.h create mode 100644 src/multimediawidgets/qvideowindowcontrol.cpp create mode 100644 src/multimediawidgets/qvideowindowcontrol.h diff --git a/doc/src/examples/camera.qdoc b/doc/src/examples/camera.qdoc index a87869e13..455e45fd3 100644 --- a/doc/src/examples/camera.qdoc +++ b/doc/src/examples/camera.qdoc @@ -36,7 +36,7 @@ or video. -The Camera Example demonstrates how you can use the QtMultimediaKit to implement +The Camera Example demonstrates how you can use QtMultimedia to implement some basic Camera functionality to take still images and record video clips with audio. diff --git a/doc/src/multimedia.qdoc b/doc/src/multimedia.qdoc index 04f6b5691..8cdf1386c 100644 --- a/doc/src/multimedia.qdoc +++ b/doc/src/multimedia.qdoc @@ -42,7 +42,7 @@ collection of media content. Multimedia provides a set of APIs that allow the developer to play, record and manage a collection of media content. It is dependent on the -QtMultimediaKit module. QtMultimediaKit is the recommended API to build multimedia +QtMultimedia module. QtMultimedia is the recommended API to build multimedia applications using Qt. The Phonon API is no longer recommended. \tableofcontents @@ -67,7 +67,7 @@ from a remote location and identified by a URL. Finally, many different codecs are supported 'out of the box'. -The supplied \l {qtmultimediakit examples}{examples} give a good idea at the ease of use of the API. When +The supplied \l {qtmultimedia examples}{examples} give a good idea at the ease of use of the API. When the supporting user interface code is ignored we can see that functionality is immediately available with minimal effort. @@ -304,7 +304,7 @@ the operation can be cancelled by calling cancellation can be done by calling \l {QCamera::unlock()}{unlock}(QCamera::LockFocus). -\target qtmultimediakit examples +\target qtmultimedia examples \section1 Examples \section2 Record a Sound Source @@ -326,7 +326,7 @@ QVideoWidget classes. \section2 Camera Example -The \l{Camera Example} shows how use the QtMultimediaKit API to quickly +The \l{Camera Example} shows how use the QtMultimedia API to quickly write a camera application in C++. \section2 QML Camera Example diff --git a/doc/src/plugins/qml-multimedia.qdoc b/doc/src/plugins/qml-multimedia.qdoc index 2d5d010ba..b539cf499 100644 --- a/doc/src/plugins/qml-multimedia.qdoc +++ b/doc/src/plugins/qml-multimedia.qdoc @@ -55,7 +55,7 @@ \qml import Qt 4.7 - import QtMultimediaKit 1.1 + import QtMultimedia 4.0 // ... Audio { @@ -238,7 +238,7 @@ \qml import Qt 4.7 - import QtMultimediaKit 1.1 + import QtMultimedia 4.0 SoundEffect { @@ -265,7 +265,7 @@ \qml import Qt 4.7 - import QtMultimediaKit 1.1 + import QtMultimedia 4.0 Camera { focus : visible // to receive focus and capture key events when visible diff --git a/doc/src/snippets/multimedia-snippets/audiorecorder.cpp b/doc/src/snippets/multimedia-snippets/audiorecorder.cpp index 9d292c48f..6ff496510 100644 --- a/doc/src/snippets/multimedia-snippets/audiorecorder.cpp +++ b/doc/src/snippets/multimedia-snippets/audiorecorder.cpp @@ -45,7 +45,7 @@ #include #include -#include +#include #include "audiorecorder.h" diff --git a/doc/src/snippets/multimedia-snippets/media.cpp b/doc/src/snippets/multimedia-snippets/media.cpp index 44f2327bf..baff4d3b1 100644 --- a/doc/src/snippets/multimedia-snippets/media.cpp +++ b/doc/src/snippets/multimedia-snippets/media.cpp @@ -210,7 +210,7 @@ void MediaExample::MediaRecorder() QAudioEncoderSettings audioSettings; audioSettings.setCodec("audio/vorbis"); - audioSettings.setQuality(QtMultimediaKit::HighQuality); + audioSettings.setQuality(QtMultimedia::HighQuality); recorder->setEncodingSettings(audioSettings); diff --git a/doc/src/snippets/multimedia-snippets/multimedia-snippets.pro b/doc/src/snippets/multimedia-snippets/multimedia-snippets.pro index b04d16979..bf5c0945d 100644 --- a/doc/src/snippets/multimedia-snippets/multimedia-snippets.pro +++ b/doc/src/snippets/multimedia-snippets/multimedia-snippets.pro @@ -4,14 +4,14 @@ TEMPLATE = lib TARGET = qtmmksnippets INCLUDEPATH += ../../../../src/global \ - ../../../../src/multimediakit \ - ../../../../src/multimediakit/audio \ - ../../../../src/multimediakit/video \ - ../../../../src/multimediakit/effects + ../../../../src/multimedia \ + ../../../../src/multimedia/audio \ + ../../../../src/multimedia/video \ + ../../../../src/multimedia/effects CONFIG += console -qtAddLibrary(QtMultimediaKit) +QT += multimedia SOURCES += \ audio.cpp \ diff --git a/doc/src/snippets/multimedia-snippets/player.cpp b/doc/src/snippets/multimedia-snippets/player.cpp index 0db3c1447..1280baba3 100644 --- a/doc/src/snippets/multimedia-snippets/player.cpp +++ b/doc/src/snippets/multimedia-snippets/player.cpp @@ -177,14 +177,14 @@ void Player::positionChanged(qint64 progress) void Player::metaDataChanged() { - //qDebug() << "update metadata" << player->metaData(QtMultimediaKit::Title).toString(); + //qDebug() << "update metadata" << player->metaData(QtMultimedia::Title).toString(); if (player->isMetaDataAvailable()) { setTrackInfo(QString("%1 - %2") - .arg(player->metaData(QtMultimediaKit::AlbumArtist).toString()) - .arg(player->metaData(QtMultimediaKit::Title).toString())); + .arg(player->metaData(QtMultimedia::AlbumArtist).toString()) + .arg(player->metaData(QtMultimedia::Title).toString())); if (coverLabel) { - QUrl url = player->metaData(QtMultimediaKit::CoverArtUrlLarge).value(); + QUrl url = player->metaData(QtMultimedia::CoverArtUrlLarge).value(); coverLabel->setPixmap(!url.isEmpty() ? QPixmap(url.toString()) diff --git a/doc/src/snippets/multimedia-snippets/soundeffect.qml b/doc/src/snippets/multimedia-snippets/soundeffect.qml index 629c11cb1..21e75f116 100644 --- a/doc/src/snippets/multimedia-snippets/soundeffect.qml +++ b/doc/src/snippets/multimedia-snippets/soundeffect.qml @@ -41,7 +41,7 @@ //! [complete snippet] import Qt 4.7 -import QtMultimediaKit 1.1 +import QtMultimedia 4.0 Text { text: "Click Me!"; diff --git a/examples/audiodevices/audiodevices.pro b/examples/audiodevices/audiodevices.pro index 87391db1f..7bd598762 100644 --- a/examples/audiodevices/audiodevices.pro +++ b/examples/audiodevices/audiodevices.pro @@ -1,7 +1,7 @@ TEMPLATE = app TARGET = audiodevices -QT += multimediakit +QT += multimedia HEADERS = audiodevices.h @@ -10,9 +10,9 @@ SOURCES = audiodevices.cpp \ FORMS += audiodevicesbase.ui -target.path = $$[QT_INSTALL_EXAMPLES]/qtmultimediakit/audiodevices +target.path = $$[QT_INSTALL_EXAMPLES]/qtmultimedia/audiodevices sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS *.pro -sources.path = $$[QT_INSTALL_EXAMPLES]/qtmultimediakit/audiodevices +sources.path = $$[QT_INSTALL_EXAMPLES]/qtmultimedia/audiodevices INSTALLS += target sources diff --git a/examples/audioinput/audioinput.pro b/examples/audioinput/audioinput.pro index cd6306673..f4cdc3141 100644 --- a/examples/audioinput/audioinput.pro +++ b/examples/audioinput/audioinput.pro @@ -1,16 +1,16 @@ TEMPLATE = app TARGET = audioinput -QT += multimediakit +QT += multimedia HEADERS = audioinput.h SOURCES = audioinput.cpp \ main.cpp -target.path = $$[QT_INSTALL_EXAMPLES]/qtmultimediakit/audioinput +target.path = $$[QT_INSTALL_EXAMPLES]/qtmultimedia/audioinput sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS *.pro -sources.path = $$[QT_INSTALL_EXAMPLES]/qtmultimediakit/audioinput +sources.path = $$[QT_INSTALL_EXAMPLES]/qtmultimedia/audioinput INSTALLS += target sources diff --git a/examples/audiooutput/audiooutput.pro b/examples/audiooutput/audiooutput.pro index b289cdbfc..f2a2244d2 100644 --- a/examples/audiooutput/audiooutput.pro +++ b/examples/audiooutput/audiooutput.pro @@ -1,16 +1,16 @@ TEMPLATE = app TARGET += audiooutput -QT += multimediakit +QT += multimedia HEADERS = audiooutput.h SOURCES = audiooutput.cpp \ main.cpp -target.path = $$[QT_INSTALL_EXAMPLES]/qtmultimediakit/audiooutput +target.path = $$[QT_INSTALL_EXAMPLES]/qtmultimedia/audiooutput sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS *.pro -sources.path = $$[QT_INSTALL_EXAMPLES]/qtmultimediakit/audiooutput +sources.path = $$[QT_INSTALL_EXAMPLES]/qtmultimedia/audiooutput INSTALLS += target sources diff --git a/examples/audiorecorder/audiorecorder.cpp b/examples/audiorecorder/audiorecorder.cpp index 38f08ac4b..ad4dc3540 100644 --- a/examples/audiorecorder/audiorecorder.cpp +++ b/examples/audiorecorder/audiorecorder.cpp @@ -88,8 +88,8 @@ AudioRecorder::AudioRecorder(QWidget *parent) sampleRate)); } - ui->qualitySlider->setRange(0, int(QtMultimediaKit::VeryHighQuality)); - ui->qualitySlider->setValue(int(QtMultimediaKit::NormalQuality)); + ui->qualitySlider->setRange(0, int(QtMultimedia::VeryHighQuality)); + ui->qualitySlider->setValue(int(QtMultimedia::NormalQuality)); //bitrates: ui->bitrateBox->addItem(QString("Default"), QVariant(0)); @@ -172,10 +172,10 @@ void AudioRecorder::toggleRecord() settings.setCodec(boxValue(ui->audioCodecBox).toString()); settings.setSampleRate(boxValue(ui->sampleRateBox).toInt()); settings.setBitRate(boxValue(ui->bitrateBox).toInt()); - settings.setQuality(QtMultimediaKit::EncodingQuality(ui->qualitySlider->value())); + settings.setQuality(QtMultimedia::EncodingQuality(ui->qualitySlider->value())); settings.setEncodingMode(ui->constantQualityRadioButton->isChecked() ? - QtMultimediaKit::ConstantQualityEncoding : - QtMultimediaKit::ConstantBitRateEncoding); + QtMultimedia::ConstantQualityEncoding : + QtMultimedia::ConstantBitRateEncoding); QString container = boxValue(ui->containerBox).toString(); diff --git a/examples/audiorecorder/audiorecorder.pro b/examples/audiorecorder/audiorecorder.pro index b5b5d1055..f2af6387e 100644 --- a/examples/audiorecorder/audiorecorder.pro +++ b/examples/audiorecorder/audiorecorder.pro @@ -1,7 +1,7 @@ TEMPLATE = app TARGET = audiorecorder -QT += multimediakit +QT += multimedia HEADERS = \ audiorecorder.h @@ -16,9 +16,9 @@ maemo*: { FORMS += audiorecorder.ui } -target.path = $$[QT_INSTALL_EXAMPLES]/qtmultimediakit/audiorecorder +target.path = $$[QT_INSTALL_EXAMPLES]/qtmultimedia/audiorecorder sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS *.pro -sources.path = $$[QT_INSTALL_EXAMPLES]/qtmultimediakit/audiorecorder +sources.path = $$[QT_INSTALL_EXAMPLES]/qtmultimedia/audiorecorder INSTALLS += target sources diff --git a/examples/camera/camera.cpp b/examples/camera/camera.cpp index b8bb675be..d30d6c19d 100644 --- a/examples/camera/camera.cpp +++ b/examples/camera/camera.cpp @@ -124,7 +124,7 @@ void Camera::setCamera(const QByteArray &cameraDevice) connect(mediaRecorder, SIGNAL(durationChanged(qint64)), this, SLOT(updateRecordTime())); connect(mediaRecorder, SIGNAL(error(QMediaRecorder::Error)), this, SLOT(displayRecorderError())); - mediaRecorder->setMetaData(QtMultimediaKit::Title, QVariant(QLatin1String("Test Title"))); + mediaRecorder->setMetaData(QtMultimedia::Title, QVariant(QLatin1String("Test Title"))); connect(ui->exposureCompensation, SIGNAL(valueChanged(int)), SLOT(setExposureCompensation(int))); diff --git a/examples/camera/camera.pro b/examples/camera/camera.pro index a519354ed..f7dd8b787 100644 --- a/examples/camera/camera.pro +++ b/examples/camera/camera.pro @@ -1,7 +1,7 @@ TEMPLATE = app TARGET = camera -QT += multimediakit multimediakitwidgets +QT += multimedia multimediawidgets HEADERS = \ camera.h \ @@ -19,9 +19,9 @@ FORMS += \ videosettings.ui \ imagesettings.ui -target.path = $$[QT_INSTALL_EXAMPLES]/qtmultimediakit/camera +target.path = $$[QT_INSTALL_EXAMPLES]/qtmultimedia/camera sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS *.pro -sources.path = $$[QT_INSTALL_EXAMPLES]/qtmultimediakit/camera +sources.path = $$[QT_INSTALL_EXAMPLES]/qtmultimedia/camera INSTALLS += target sources diff --git a/examples/camera/imagesettings.cpp b/examples/camera/imagesettings.cpp index c3b9b22c2..bb73f3a02 100644 --- a/examples/camera/imagesettings.cpp +++ b/examples/camera/imagesettings.cpp @@ -62,7 +62,7 @@ ImageSettings::ImageSettings(QCameraImageCapture *imageCapture, QWidget *parent) ui->imageCodecBox->addItem(codecName+": "+description, QVariant(codecName)); } - ui->imageQualitySlider->setRange(0, int(QtMultimediaKit::VeryHighQuality)); + ui->imageQualitySlider->setRange(0, int(QtMultimedia::VeryHighQuality)); ui->imageResolutionBox->addItem(tr("Default Resolution")); QList supportedResolutions = imagecapture->supportedResolutions(); @@ -93,7 +93,7 @@ QImageEncoderSettings ImageSettings::imageSettings() const { QImageEncoderSettings settings = imagecapture->encodingSettings(); settings.setCodec(boxValue(ui->imageCodecBox).toString()); - settings.setQuality(QtMultimediaKit::EncodingQuality(ui->imageQualitySlider->value())); + settings.setQuality(QtMultimedia::EncodingQuality(ui->imageQualitySlider->value())); settings.setResolution(boxValue(ui->imageResolutionBox).toSize()); return settings; diff --git a/examples/camera/videosettings.cpp b/examples/camera/videosettings.cpp index c1d816012..f97f4adf2 100644 --- a/examples/camera/videosettings.cpp +++ b/examples/camera/videosettings.cpp @@ -66,7 +66,7 @@ VideoSettings::VideoSettings(QMediaRecorder *mediaRecorder, QWidget *parent) : ui->audioSampleRateBox->addItem(QString::number(sampleRate), QVariant(sampleRate)); } - ui->audioQualitySlider->setRange(0, int(QtMultimediaKit::VeryHighQuality)); + ui->audioQualitySlider->setRange(0, int(QtMultimedia::VeryHighQuality)); //video codecs ui->videoCodecBox->addItem(tr("Default video codec"), QVariant(QString())); @@ -75,7 +75,7 @@ VideoSettings::VideoSettings(QMediaRecorder *mediaRecorder, QWidget *parent) : ui->videoCodecBox->addItem(codecName+": "+description, QVariant(codecName)); } - ui->videoQualitySlider->setRange(0, int(QtMultimediaKit::VeryHighQuality)); + ui->videoQualitySlider->setRange(0, int(QtMultimedia::VeryHighQuality)); ui->videoResolutionBox->addItem(tr("Default")); @@ -122,7 +122,7 @@ QAudioEncoderSettings VideoSettings::audioSettings() const { QAudioEncoderSettings settings = mediaRecorder->audioSettings(); settings.setCodec(boxValue(ui->audioCodecBox).toString()); - settings.setQuality(QtMultimediaKit::EncodingQuality(ui->audioQualitySlider->value())); + settings.setQuality(QtMultimedia::EncodingQuality(ui->audioQualitySlider->value())); settings.setSampleRate(boxValue(ui->audioSampleRateBox).toInt()); return settings; } @@ -138,7 +138,7 @@ QVideoEncoderSettings VideoSettings::videoSettings() const { QVideoEncoderSettings settings = mediaRecorder->videoSettings(); settings.setCodec(boxValue(ui->videoCodecBox).toString()); - settings.setQuality(QtMultimediaKit::EncodingQuality(ui->videoQualitySlider->value())); + settings.setQuality(QtMultimedia::EncodingQuality(ui->videoQualitySlider->value())); settings.setResolution(boxValue(ui->videoResolutionBox).toSize()); settings.setFrameRate(boxValue(ui->videoFramerateBox).value()); diff --git a/examples/declarative-camera/CameraPropertyButton.qml b/examples/declarative-camera/CameraPropertyButton.qml index 91ddeffa0..152bb9375 100644 --- a/examples/declarative-camera/CameraPropertyButton.qml +++ b/examples/declarative-camera/CameraPropertyButton.qml @@ -39,7 +39,7 @@ ****************************************************************************/ import Qt 4.7 -import QtMultimediaKit 1.1 +import QtMultimedia 4.0 Item { id: propertyButton diff --git a/examples/declarative-camera/CaptureControls.qml b/examples/declarative-camera/CaptureControls.qml index 3332fe1d2..6120dad01 100644 --- a/examples/declarative-camera/CaptureControls.qml +++ b/examples/declarative-camera/CaptureControls.qml @@ -39,7 +39,7 @@ ****************************************************************************/ import Qt 4.7 -import QtMultimediaKit 1.1 +import QtMultimedia 4.0 FocusScope { property Camera camera diff --git a/examples/declarative-camera/FocusButton.qml b/examples/declarative-camera/FocusButton.qml index 3522b0e68..6a54c8d22 100644 --- a/examples/declarative-camera/FocusButton.qml +++ b/examples/declarative-camera/FocusButton.qml @@ -39,7 +39,7 @@ ****************************************************************************/ import Qt 4.7 -import QtMultimediaKit 1.1 +import QtMultimedia 4.0 CameraButton { property Camera camera diff --git a/examples/declarative-camera/PhotoPreview.qml b/examples/declarative-camera/PhotoPreview.qml index 97deec8fb..6cd7f35b0 100644 --- a/examples/declarative-camera/PhotoPreview.qml +++ b/examples/declarative-camera/PhotoPreview.qml @@ -39,7 +39,7 @@ ****************************************************************************/ import Qt 4.7 -import QtMultimediaKit 1.1 +import QtMultimedia 4.0 Item { property alias source : preview.source diff --git a/examples/declarative-camera/ZoomControl.qml b/examples/declarative-camera/ZoomControl.qml index 0d804d3d9..b141523c1 100644 --- a/examples/declarative-camera/ZoomControl.qml +++ b/examples/declarative-camera/ZoomControl.qml @@ -39,7 +39,7 @@ ****************************************************************************/ import Qt 4.7 -import QtMultimediaKit 1.1 +import QtMultimedia 4.0 Item { id : zoomControl diff --git a/examples/declarative-camera/declarative-camera.pro b/examples/declarative-camera/declarative-camera.pro index ad544e9f4..f1599741d 100644 --- a/examples/declarative-camera/declarative-camera.pro +++ b/examples/declarative-camera/declarative-camera.pro @@ -1,7 +1,7 @@ TEMPLATE=app -QT += declarative qtquick1 network multimediakit +QT += declarative qtquick1 network multimedia contains(QT_CONFIG, opengl) { QT += opengl @@ -13,9 +13,9 @@ else:TARGET = QmlCamera RESOURCES += declarative-camera.qrc -target.path = $$[QT_INSTALL_EXAMPLES]/qtmultimediakit/qml_camera +target.path = $$[QT_INSTALL_EXAMPLES]/qtmultimedia/qml_camera sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS *.pro -sources.path = $$[QT_INSTALL_EXAMPLES]/qtmultimediakit/qml_camera +sources.path = $$[QT_INSTALL_EXAMPLES]/qtmultimedia/qml_camera INSTALLS += target sources diff --git a/examples/declarative-camera/declarative-camera.qml b/examples/declarative-camera/declarative-camera.qml index 000185459..fdc210de6 100644 --- a/examples/declarative-camera/declarative-camera.qml +++ b/examples/declarative-camera/declarative-camera.qml @@ -39,7 +39,7 @@ ****************************************************************************/ import Qt 4.7 -import QtMultimediaKit 1.1 +import QtMultimedia 4.0 Rectangle { id : cameraUI diff --git a/examples/declarative-radio/declarative-radio.pro b/examples/declarative-radio/declarative-radio.pro index f3dab6411..4ade74285 100644 --- a/examples/declarative-radio/declarative-radio.pro +++ b/examples/declarative-radio/declarative-radio.pro @@ -2,7 +2,7 @@ TEMPLATE = app TARGET = declarative-radio DEPENDPATH += . INCLUDEPATH += . -QT += declarative multimediakit +QT += declarative multimedia # Input SOURCES += main.cpp diff --git a/examples/declarative-radio/view.qml b/examples/declarative-radio/view.qml index 4e2882d45..71cca9d11 100644 --- a/examples/declarative-radio/view.qml +++ b/examples/declarative-radio/view.qml @@ -39,7 +39,7 @@ ****************************************************************************/ import QtQuick 2.0 -import Qt.multimediakit 4.0 +import Qt.multimedia 4.0 Rectangle { width: 400; height: 300; diff --git a/examples/player/player.cpp b/examples/player/player.cpp index 18c9885aa..8b822e18c 100644 --- a/examples/player/player.cpp +++ b/examples/player/player.cpp @@ -221,14 +221,14 @@ void Player::positionChanged(qint64 progress) void Player::metaDataChanged() { - //qDebug() << "update metadata" << player->metaData(QtMultimediaKit::Title).toString(); + //qDebug() << "update metadata" << player->metaData(QtMultimedia::Title).toString(); if (player->isMetaDataAvailable()) { setTrackInfo(QString("%1 - %2") - .arg(player->metaData(QtMultimediaKit::AlbumArtist).toString()) - .arg(player->metaData(QtMultimediaKit::Title).toString())); + .arg(player->metaData(QtMultimedia::AlbumArtist).toString()) + .arg(player->metaData(QtMultimedia::Title).toString())); if (coverLabel) { - QUrl url = player->metaData(QtMultimediaKit::CoverArtUrlLarge).value(); + QUrl url = player->metaData(QtMultimedia::CoverArtUrlLarge).value(); coverLabel->setPixmap(!url.isEmpty() ? QPixmap(url.toString()) diff --git a/examples/player/player.pro b/examples/player/player.pro index 58b6f8ed7..3bc6c654d 100644 --- a/examples/player/player.pro +++ b/examples/player/player.pro @@ -5,8 +5,8 @@ CONFIG += qt warn_on QT += network \ xml \ - multimediakit \ - multimediakitwidgets + multimedia \ + multimediawidgets HEADERS = \ player.h \ @@ -24,9 +24,9 @@ maemo* { } #install -target.path = $$[QT_INSTALL_EXAMPLES]/qtmultimediakit/player +target.path = $$[QT_INSTALL_EXAMPLES]/qtmultimedia/player sources.files = $$SOURCES $HEADERS $$RESOURCES $$FORMS *.pro -sources.path = $$[QT_INSTALL_EXAMPLES]/qtmultimediakit/player +sources.path = $$[QT_INSTALL_EXAMPLES]/qtmultimedia/player INSTALLS += target sources QT+=widgets diff --git a/examples/player/playlistmodel.h b/examples/player/playlistmodel.h index 45461260c..247f4ceb8 100644 --- a/examples/player/playlistmodel.h +++ b/examples/player/playlistmodel.h @@ -41,7 +41,7 @@ #ifndef PLAYLISTMODEL_H #define PLAYLISTMODEL_H -#include +#include #include QT_BEGIN_NAMESPACE diff --git a/examples/radio/radio.pro b/examples/radio/radio.pro index de55c591b..6931879dd 100644 --- a/examples/radio/radio.pro +++ b/examples/radio/radio.pro @@ -1,7 +1,7 @@ TEMPLATE = app TARGET = radio -QT += multimediakit +QT += multimedia HEADERS = \ radio.h @@ -10,9 +10,9 @@ SOURCES = \ main.cpp \ radio.cpp -target.path = $$[QT_INSTALL_EXAMPLES]/qtmultimediakit/radio +target.path = $$[QT_INSTALL_EXAMPLES]/qtmultimedia/radio sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS *.pro -sources.path = $$[QT_INSTALL_EXAMPLES]/qtmultimediakit/radio +sources.path = $$[QT_INSTALL_EXAMPLES]/qtmultimedia/radio INSTALLS += target sources diff --git a/examples/slideshow/slideshow.pro b/examples/slideshow/slideshow.pro index c4cb38080..133735d6f 100644 --- a/examples/slideshow/slideshow.pro +++ b/examples/slideshow/slideshow.pro @@ -1,7 +1,7 @@ TEMPLATE = app TARGET = slideshow -QT += multimediakit multimediakitwidgets +QT += multimedia multimediawidgets HEADERS = \ slideshow.h @@ -10,9 +10,9 @@ SOURCES = \ main.cpp \ slideshow.cpp -target.path = $$[QT_INSTALL_EXAMPLES]/qtmultimediakit/slideshow +target.path = $$[QT_INSTALL_EXAMPLES]/qtmultimedia/slideshow sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS *.pro -sources.path = $$[QT_INSTALL_EXAMPLES]/qtmultimediakit/slideshow +sources.path = $$[QT_INSTALL_EXAMPLES]/qtmultimedia/slideshow INSTALLS += target sources diff --git a/examples/spectrum/3rdparty/fftreal/fftreal.pro b/examples/spectrum/3rdparty/fftreal/fftreal.pro index 2c667ef76..19019b1d4 100644 --- a/examples/spectrum/3rdparty/fftreal/fftreal.pro +++ b/examples/spectrum/3rdparty/fftreal/fftreal.pro @@ -41,6 +41,6 @@ macx { sources.files = $$SOURCES $$HEADERS fftreal.pro readme.txt license.txt sources.files += bwins/fftreal.def eabi/fftreal.def -sources.path = $$[QT_INSTALL_EXAMPLES]/qtmultimediakit/spectrum/3rdparty/fftreal +sources.path = $$[QT_INSTALL_EXAMPLES]/qtmultimedia/spectrum/3rdparty/fftreal INSTALLS += sources diff --git a/examples/spectrum/README.txt b/examples/spectrum/README.txt index 8d9a81f3b..c39d4a709 100644 --- a/examples/spectrum/README.txt +++ b/examples/spectrum/README.txt @@ -4,7 +4,7 @@ Spectrum analyser demo app Introduction ------------ -This application is a demo which uses the QtMultimediaKit APIs to capture and play back PCM audio. While either recording or playback is ongoing, the application performs real-time level and frequency spectrum analysis, displaying the results in its main window. +This application is a demo which uses the QtMultimedia APIs to capture and play back PCM audio. While either recording or playback is ongoing, the application performs real-time level and frequency spectrum analysis, displaying the results in its main window. Acknowledgments @@ -96,7 +96,7 @@ If you don't like the combination of the waveform and progress bar in a single w The spectrum.h file defines a number of parameters which can be played with. These control things such as the number of audio samples analysed per FFT calculation, the range and number of bands displayed by the spectrograph, and so on. -The part of the application which interacts with QtMultimediaKit is in the Engine class. +The part of the application which interacts with QtMultimedia is in the Engine class. Some ideas for enhancements to the app are listed in TODO.txt. Feel free to start work on any of them :) diff --git a/examples/spectrum/app/app.pro b/examples/spectrum/app/app.pro index 28cc16ab0..aec69d239 100644 --- a/examples/spectrum/app/app.pro +++ b/examples/spectrum/app/app.pro @@ -6,7 +6,7 @@ TEMPLATE = app TARGET = spectrum -QT += multimediakit +QT += multimedia SOURCES += main.cpp \ engine.cpp \ @@ -59,9 +59,9 @@ RESOURCES = spectrum.qrc # Install sources.files = $$SOURCES $$HEADERS $$RESOURCES app.pro -sources.path = $$[QT_INSTALL_EXAMPLES]/qtmultimediakit/spectrum/app +sources.path = $$[QT_INSTALL_EXAMPLES]/qtmultimedia/spectrum/app images.files += images/record.png images/settings.png -images.path = $$[QT_INSTALL_EXAMPLES]/qtmultimediakit/spectrum/app/images +images.path = $$[QT_INSTALL_EXAMPLES]/qtmultimedia/spectrum/app/images INSTALLS += sources images # Deployment diff --git a/examples/spectrum/app/engine.cpp b/examples/spectrum/app/engine.cpp index 6373b439d..bea24523e 100644 --- a/examples/spectrum/app/engine.cpp +++ b/examples/spectrum/app/engine.cpp @@ -47,8 +47,8 @@ #include #include #include -#include -#include +#include +#include #include #include #include diff --git a/examples/spectrum/app/engine.h b/examples/spectrum/app/engine.h index bd263ac1b..51c63b370 100644 --- a/examples/spectrum/app/engine.h +++ b/examples/spectrum/app/engine.h @@ -49,8 +49,8 @@ #include #include #include -#include -#include +#include +#include #ifdef DUMP_CAPTURED_AUDIO #define DUMP_DATA @@ -70,7 +70,7 @@ QT_FORWARD_DECLARE_CLASS(QAudioOutput) QT_FORWARD_DECLARE_CLASS(QFile) /** - * This class interfaces with the QtMultimediaKit audio classes, and also with + * This class interfaces with the QtMultimedia audio classes, and also with * the SpectrumAnalyser class. Its role is to manage the capture and playback * of audio data, meanwhile performing real-time analysis of the audio level * and frequency spectrum. diff --git a/examples/spectrum/app/main.cpp b/examples/spectrum/app/main.cpp index af567a000..c776499dc 100644 --- a/examples/spectrum/app/main.cpp +++ b/examples/spectrum/app/main.cpp @@ -44,7 +44,7 @@ int main(int argc, char **argv) { QApplication app(argc, argv); - app.setApplicationName("QtMultimediaKit spectrum analyzer"); + app.setApplicationName("QtMultimedia spectrum analyzer"); MainWidget w; w.show(); diff --git a/examples/spectrum/app/mainwidget.h b/examples/spectrum/app/mainwidget.h index 5a9574832..14c62a2d3 100644 --- a/examples/spectrum/app/mainwidget.h +++ b/examples/spectrum/app/mainwidget.h @@ -43,7 +43,7 @@ #include #include -#include +#include class Engine; class FrequencySpectrum; diff --git a/examples/spectrum/app/settingsdialog.h b/examples/spectrum/app/settingsdialog.h index ab043f3b1..71d1796b1 100644 --- a/examples/spectrum/app/settingsdialog.h +++ b/examples/spectrum/app/settingsdialog.h @@ -43,7 +43,7 @@ #include "spectrum.h" #include -#include +#include QT_FORWARD_DECLARE_CLASS(QComboBox) QT_FORWARD_DECLARE_CLASS(QCheckBox) diff --git a/examples/spectrum/app/spectrumanalyser.cpp b/examples/spectrum/app/spectrumanalyser.cpp index 6198c6b1d..8c3212d34 100644 --- a/examples/spectrum/app/spectrumanalyser.cpp +++ b/examples/spectrum/app/spectrumanalyser.cpp @@ -43,7 +43,7 @@ #include #include -#include +#include #include #include "fftreal_wrapper.h" diff --git a/examples/spectrum/app/tonegenerator.cpp b/examples/spectrum/app/tonegenerator.cpp index d1d606684..f3cad99d9 100644 --- a/examples/spectrum/app/tonegenerator.cpp +++ b/examples/spectrum/app/tonegenerator.cpp @@ -41,7 +41,7 @@ #include "spectrum.h" #include "utils.h" #include -#include +#include #include #include diff --git a/examples/spectrum/app/tonegeneratordialog.h b/examples/spectrum/app/tonegeneratordialog.h index 7d9ccc459..788a0ea74 100644 --- a/examples/spectrum/app/tonegeneratordialog.h +++ b/examples/spectrum/app/tonegeneratordialog.h @@ -43,7 +43,7 @@ #include "spectrum.h" #include -#include +#include QT_FORWARD_DECLARE_CLASS(QCheckBox) QT_FORWARD_DECLARE_CLASS(QSlider) diff --git a/examples/spectrum/app/utils.cpp b/examples/spectrum/app/utils.cpp index d13aa0be5..31cc25b26 100644 --- a/examples/spectrum/app/utils.cpp +++ b/examples/spectrum/app/utils.cpp @@ -38,7 +38,7 @@ ** ****************************************************************************/ -#include +#include #include "utils.h" qint64 audioDuration(const QAudioFormat &format, qint64 bytes) diff --git a/examples/spectrum/app/waveform.h b/examples/spectrum/app/waveform.h index 2d3a4883f..a3b706d7c 100644 --- a/examples/spectrum/app/waveform.h +++ b/examples/spectrum/app/waveform.h @@ -42,7 +42,7 @@ #define WAVEFORM_H #include -#include +#include #include #include diff --git a/examples/spectrum/app/wavfile.h b/examples/spectrum/app/wavfile.h index 37bc8505b..b974c475d 100644 --- a/examples/spectrum/app/wavfile.h +++ b/examples/spectrum/app/wavfile.h @@ -44,7 +44,7 @@ #include #include -#include +#include class WavFile : public QFile { diff --git a/examples/spectrum/spectrum.pro b/examples/spectrum/spectrum.pro index 989ad11d9..662d6522a 100644 --- a/examples/spectrum/spectrum.pro +++ b/examples/spectrum/spectrum.pro @@ -14,7 +14,7 @@ SUBDIRS += app TARGET = spectrum sources.files = README.txt spectrum.pri spectrum.pro TODO.txt -sources.path = $$[QT_INSTALL_EXAMPLES]/qtmultimediakit/spectrum +sources.path = $$[QT_INSTALL_EXAMPLES]/qtmultimedia/spectrum INSTALLS += sources QT+=widgets diff --git a/examples/videographicsitem/videographicsitem.pro b/examples/videographicsitem/videographicsitem.pro index 54002cf50..66ed4f683 100644 --- a/examples/videographicsitem/videographicsitem.pro +++ b/examples/videographicsitem/videographicsitem.pro @@ -1,7 +1,7 @@ TEMPLATE = app TARGET = videographicsitem -QT += multimediakit multimediakitwidgets +QT += multimedia multimediawidgets contains(QT_CONFIG, opengl): QT += opengl @@ -12,9 +12,9 @@ SOURCES += main.cpp \ videoplayer.cpp \ videoitem.cpp -target.path = $$[QT_INSTALL_EXAMPLES]/qtmultimediakit/videographicsitem +target.path = $$[QT_INSTALL_EXAMPLES]/qtmultimedia/videographicsitem sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS *.pro -sources.path = $$[QT_INSTALL_EXAMPLES]/qtmultimediakit/videographicsitem +sources.path = $$[QT_INSTALL_EXAMPLES]/qtmultimedia/videographicsitem INSTALLS += target sources diff --git a/examples/videowidget/videowidget.pro b/examples/videowidget/videowidget.pro index 4e442563b..76e5f36da 100644 --- a/examples/videowidget/videowidget.pro +++ b/examples/videowidget/videowidget.pro @@ -1,7 +1,7 @@ TEMPLATE = app TARGET = videowidget -QT += multimediakit multimediakitwidgets +QT += multimedia multimediawidgets HEADERS = \ videoplayer.h \ @@ -14,9 +14,9 @@ SOURCES = \ videowidget.cpp \ videowidgetsurface.cpp -target.path = $$[QT_INSTALL_EXAMPLES]/qtmultimediakit/videowidget +target.path = $$[QT_INSTALL_EXAMPLES]/qtmultimedia/videowidget sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS *.pro -sources.path = $$[QT_INSTALL_EXAMPLES]/qtmultimediakit/videowidget +sources.path = $$[QT_INSTALL_EXAMPLES]/qtmultimedia/videowidget INSTALLS += target sources diff --git a/modules/qt_multimedia.pri b/modules/qt_multimedia.pri new file mode 100644 index 000000000..cb87b0ae7 --- /dev/null +++ b/modules/qt_multimedia.pri @@ -0,0 +1,17 @@ +QT.multimedia.VERSION = 5.0.0 +QT.multimedia.MAJOR_VERSION = 5 +QT.multimedia.MINOR_VERSION = 0 +QT.multimedia.PATCH_VERSION = 0 + +QT.multimedia.name = QtMultimedia +QT.multimedia.bins = $$QT_MODULE_BIN_BASE +QT.multimedia.includes = $$QT_MODULE_INCLUDE_BASE $$QT_MODULE_INCLUDE_BASE/QtMultimedia +QT.multimedia.private_includes = $$QT_MODULE_INCLUDE_BASE/QtMultimedia/$$QT.multimedia.VERSION +QT.multimedia.sources = $$QT_MODULE_BASE/src/multimedia +QT.multimedia.libs = $$QT_MODULE_LIB_BASE +QT.multimedia.plugins = $$QT_MODULE_PLUGIN_BASE +QT.multimedia.imports = $$QT_MODULE_IMPORT_BASE +QT.multimedia.depends = gui network +QT.multimedia.DEFINES = QT_MULTIMEDIA_LIB + +QT_CONFIG += multimedia diff --git a/modules/qt_multimediakit.pri b/modules/qt_multimediakit.pri deleted file mode 100644 index 3400e1480..000000000 --- a/modules/qt_multimediakit.pri +++ /dev/null @@ -1,17 +0,0 @@ -QT.multimediakit.VERSION = 5.0.0 -QT.multimediakit.MAJOR_VERSION = 5 -QT.multimediakit.MINOR_VERSION = 0 -QT.multimediakit.PATCH_VERSION = 0 - -QT.multimediakit.name = QtMultimediaKit -QT.multimediakit.bins = $$QT_MODULE_BIN_BASE -QT.multimediakit.includes = $$QT_MODULE_INCLUDE_BASE $$QT_MODULE_INCLUDE_BASE/QtMultimediaKit -QT.multimediakit.private_includes = $$QT_MODULE_INCLUDE_BASE/QtMultimediaKit/$$QT.multimediakit.VERSION -QT.multimediakit.sources = $$QT_MODULE_BASE/src/multimediakit -QT.multimediakit.libs = $$QT_MODULE_LIB_BASE -QT.multimediakit.plugins = $$QT_MODULE_PLUGIN_BASE -QT.multimediakit.imports = $$QT_MODULE_IMPORT_BASE -QT.multimediakit.depends = gui network -QT.multimediakit.DEFINES = QT_MULTIMEDIAKIT_LIB - -QT_CONFIG += multimediakit diff --git a/modules/qt_multimediakitwidgets.pri b/modules/qt_multimediakitwidgets.pri deleted file mode 100644 index 55faee924..000000000 --- a/modules/qt_multimediakitwidgets.pri +++ /dev/null @@ -1,17 +0,0 @@ -QT.multimediakitwidgets.VERSION = 5.0.0 -QT.multimediakitwidgets.MAJOR_VERSION = 5 -QT.multimediakitwidgets.MINOR_VERSION = 0 -QT.multimediakitwidgets.PATCH_VERSION = 0 - -QT.multimediakitwidgets.name = QtMultimediaKitWidgets -QT.multimediakitwidgets.bins = $$QT_MODULE_BIN_BASE -QT.multimediakitwidgets.includes = $$QT_MODULE_INCLUDE_BASE $$QT_MODULE_INCLUDE_BASE/QtMultimediaKitWidgets -QT.multimediakitwidgets.private_includes = $$QT_MODULE_INCLUDE_BASE/QtMultimediaKitWidgets/$$QT.multimediakitwidgets.VERSION -QT.multimediakitwidgets.sources = $$QT_MODULE_BASE/src/multimediakitwidgets -QT.multimediakitwidgets.libs = $$QT_MODULE_LIB_BASE -QT.multimediakitwidgets.plugins = $$QT_MODULE_PLUGIN_BASE -QT.multimediakitwidgets.imports = $$QT_MODULE_IMPORT_BASE -QT.multimediakitwidgets.depends = gui network -QT.multimediakitwidgets.DEFINES = QT_MULTIMEDIAKITWIDGETS_LIB - -QT_CONFIG += multimediakitwidgets diff --git a/modules/qt_multimediawidgets.pri b/modules/qt_multimediawidgets.pri new file mode 100644 index 000000000..4dcbf4143 --- /dev/null +++ b/modules/qt_multimediawidgets.pri @@ -0,0 +1,17 @@ +QT.multimediawidgets.VERSION = 5.0.0 +QT.multimediawidgets.MAJOR_VERSION = 5 +QT.multimediawidgets.MINOR_VERSION = 0 +QT.multimediawidgets.PATCH_VERSION = 0 + +QT.multimediawidgets.name = QtMultimediaWidgets +QT.multimediawidgets.bins = $$QT_MODULE_BIN_BASE +QT.multimediawidgets.includes = $$QT_MODULE_INCLUDE_BASE $$QT_MODULE_INCLUDE_BASE/QtMultimediaWidgets +QT.multimediawidgets.private_includes = $$QT_MODULE_INCLUDE_BASE/QtMultimediaWidgets/$$QT.multimediawidgets.VERSION +QT.multimediawidgets.sources = $$QT_MODULE_BASE/src/multimediawidgets +QT.multimediawidgets.libs = $$QT_MODULE_LIB_BASE +QT.multimediawidgets.plugins = $$QT_MODULE_PLUGIN_BASE +QT.multimediawidgets.imports = $$QT_MODULE_IMPORT_BASE +QT.multimediawidgets.depends = gui network +QT.multimediawidgets.DEFINES = QT_MULTIMEDIAWIDGETS_LIB + +QT_CONFIG += multimediawidgets diff --git a/qtmultimedia.pro b/qtmultimedia.pro new file mode 100644 index 000000000..4ebfd8402 --- /dev/null +++ b/qtmultimedia.pro @@ -0,0 +1,21 @@ +TEMPLATE = subdirs + +module_qtmultimedia_src.subdir = src +module_qtmultimedia_src.target = module-qtmultimedia-src + +module_qtmultimedia_examples.subdir = examples +module_qtmultimedia_examples.target = module-qtmultimedia-examples +module_qtmultimedia_examples.depends = module_qtmultimedia_src +!contains(QT_BUILD_PARTS,examples) { + module_qtmultimedia_examples.CONFIG = no_default_target no_default_install +} + +module_qtmultimedia_tests.subdir = tests +module_qtmultimedia_tests.target = module-qtmultimedia-tests +module_qtmultimedia_tests.depends = module_qtmultimedia_src +module_qtmultimedia_tests.CONFIG = no_default_target no_default_install + +SUBDIRS += module_qtmultimedia_src \ + module_qtmultimedia_examples \ + module_qtmultimedia_tests \ + diff --git a/qtmultimediakit.pro b/qtmultimediakit.pro index 54eb4058a..55aa22007 100644 --- a/qtmultimediakit.pro +++ b/qtmultimediakit.pro @@ -1,21 +1,4 @@ -TEMPLATE = subdirs - -module_qtmultimediakit_src.subdir = src -module_qtmultimediakit_src.target = module-qtmultimediakit-src - -module_qtmultimediakit_examples.subdir = examples -module_qtmultimediakit_examples.target = module-qtmultimediakit-examples -module_qtmultimediakit_examples.depends = module_qtmultimediakit_src -!contains(QT_BUILD_PARTS,examples) { - module_qtmultimediakit_examples.CONFIG = no_default_target no_default_install -} - -module_qtmultimediakit_tests.subdir = tests -module_qtmultimediakit_tests.target = module-qtmultimediakit-tests -module_qtmultimediakit_tests.depends = module_qtmultimediakit_src -module_qtmultimediakit_tests.CONFIG = no_default_target no_default_install - -SUBDIRS += module_qtmultimediakit_src \ - module_qtmultimediakit_examples \ - module_qtmultimediakit_tests \ +# This is only so that Qt5.git still builds, since it's expecting +# the .pro file to match the directory name +include(qtmultimedia.pro) diff --git a/src/imports/multimedia/multimedia.cpp b/src/imports/multimedia/multimedia.cpp index 2de7401c9..20333f218 100644 --- a/src/imports/multimedia/multimedia.cpp +++ b/src/imports/multimedia/multimedia.cpp @@ -68,7 +68,8 @@ class QMultimediaDeclarativeModule : public QDeclarativeExtensionPlugin public: virtual void registerTypes(const char *uri) { - Q_ASSERT(QLatin1String(uri) == QLatin1String("Qt.multimediakit")); + Q_ASSERT(QLatin1String(uri) == QLatin1String("QtMultimedia") + || QLatin1String(uri) == QLatin1String("Qt.multimediakit")); qmlRegisterType(uri, 4, 0, "SoundEffect"); qmlRegisterType(uri, 4, 0, "Audio"); diff --git a/src/imports/multimedia/multimedia.pro b/src/imports/multimedia/multimedia.pro index 4574d0247..f6aa36486 100644 --- a/src/imports/multimedia/multimedia.pro +++ b/src/imports/multimedia/multimedia.pro @@ -1,11 +1,11 @@ TARGET = declarative_multimedia -TARGETPATH = Qt/multimediakit +TARGETPATH = QtMultimedia include(../qimportbase.pri) -QT += declarative network multimediakit-private +QT += declarative network multimedia-private -DESTDIR = $$QT.multimediakit.imports/$$TARGETPATH +DESTDIR = $$QT.multimedia.imports/$$TARGETPATH target.path = $$[QT_INSTALL_IMPORTS]/$$TARGETPATH HEADERS += \ @@ -59,4 +59,16 @@ disabled { qmldir.files += $$PWD/qmldir qmldir.path += $$[QT_INSTALL_IMPORTS]/$$TARGETPATH +# another copy of the qmldir file so the old import works +OLDQMLDIRFILE = $${_PRO_FILE_PWD_}/qmldir.qtmultimediakit +oldcopy2build.input = OLDQMLDIRFILE +oldcopy2build.output = $$QT.multimedia.imports/Qt/multimediakit/qmldir +!contains(TEMPLATE_PREFIX, vc):oldcopy2build.variable_out = PRE_TARGETDEPS +oldcopy2build.commands = $$QMAKE_COPY ${QMAKE_FILE_IN} ${QMAKE_FILE_OUT} +oldcopy2build.name = COPY ${QMAKE_FILE_IN} +oldcopy2build.CONFIG += no_link +# `clean' should leave the build in a runnable state, which means it shouldn't delete qmldir +oldcopy2build.CONFIG += no_clean +QMAKE_EXTRA_COMPILERS += oldcopy2build + INSTALLS += target qmldir diff --git a/src/imports/multimedia/qdeclarativeaudio.cpp b/src/imports/multimedia/qdeclarativeaudio.cpp index c15d31235..c12ef22d1 100644 --- a/src/imports/multimedia/qdeclarativeaudio.cpp +++ b/src/imports/multimedia/qdeclarativeaudio.cpp @@ -52,11 +52,11 @@ QT_BEGIN_NAMESPACE \ingroup qml-multimedia - This element is part of the \bold{QtMultimediaKit 1.1} module. + This element is part of the \bold{QtMultimedia 4.0} module. \qml import Qt 4.7 - import QtMultimediaKit 1.1 + import QtMultimedia 4.0 Text { text: "Click Me!"; @@ -333,7 +333,7 @@ void QDeclarativeAudio::componentComplete() This property holds the tile of the media. - \sa {QtMultimediaKit::Title} + \sa {QtMultimedia::Title} */ /*! @@ -341,7 +341,7 @@ void QDeclarativeAudio::componentComplete() This property holds the sub-title of the media. - \sa {QtMultimediaKit::SubTitle} + \sa {QtMultimedia::SubTitle} */ /*! @@ -349,7 +349,7 @@ void QDeclarativeAudio::componentComplete() This property holds the author of the media. - \sa {QtMultimediaKit::Author} + \sa {QtMultimedia::Author} */ /*! @@ -357,7 +357,7 @@ void QDeclarativeAudio::componentComplete() This property holds a user comment about the media. - \sa {QtMultimediaKit::Comment} + \sa {QtMultimedia::Comment} */ /*! @@ -365,7 +365,7 @@ void QDeclarativeAudio::componentComplete() This property holds a description of the media. - \sa {QtMultimediaKit::Description} + \sa {QtMultimedia::Description} */ /*! @@ -373,7 +373,7 @@ void QDeclarativeAudio::componentComplete() This property holds the category of the media - \sa {QtMultimediaKit::Category} + \sa {QtMultimedia::Category} */ /*! @@ -381,7 +381,7 @@ void QDeclarativeAudio::componentComplete() This property holds the genre of the media. - \sa {QtMultimediaKit::Genre} + \sa {QtMultimedia::Genre} */ /*! @@ -389,7 +389,7 @@ void QDeclarativeAudio::componentComplete() This property holds the year of release of the media. - \sa {QtMultimediaKit::Year} + \sa {QtMultimedia::Year} */ /*! @@ -397,7 +397,7 @@ void QDeclarativeAudio::componentComplete() This property holds the date of the media. - \sa {QtMultimediaKit::Date} + \sa {QtMultimedia::Date} */ /*! @@ -405,7 +405,7 @@ void QDeclarativeAudio::componentComplete() This property holds a user rating of the media in the range of 0 to 100. - \sa {QtMultimediaKit::UserRating} + \sa {QtMultimedia::UserRating} */ /*! @@ -413,7 +413,7 @@ void QDeclarativeAudio::componentComplete() This property holds a list of keywords describing the media. - \sa {QtMultimediaKit::Keywords} + \sa {QtMultimedia::Keywords} */ /*! @@ -421,7 +421,7 @@ void QDeclarativeAudio::componentComplete() This property holds the language of the media, as an ISO 639-2 code. - \sa {QtMultimediaKit::Language} + \sa {QtMultimedia::Language} */ /*! @@ -429,7 +429,7 @@ void QDeclarativeAudio::componentComplete() This property holds the publisher of the media. - \sa {QtMultimediaKit::Publisher} + \sa {QtMultimedia::Publisher} */ /*! @@ -437,7 +437,7 @@ void QDeclarativeAudio::componentComplete() This property holds the media's copyright notice. - \sa {QtMultimediaKit::Copyright} + \sa {QtMultimedia::Copyright} */ /*! @@ -445,7 +445,7 @@ void QDeclarativeAudio::componentComplete() This property holds the parental rating of the media. - \sa {QtMultimediaKit::ParentalRating} + \sa {QtMultimedia::ParentalRating} */ /*! @@ -454,7 +454,7 @@ void QDeclarativeAudio::componentComplete() This property holds the name of the rating organisation responsible for the parental rating of the media. - \sa {QtMultimediaKit::RatingOrganisation} + \sa {QtMultimedia::RatingOrganisation} */ /*! @@ -462,7 +462,7 @@ void QDeclarativeAudio::componentComplete() This property property holds the size of the media in bytes. - \sa {QtMultimediaKit::Size} + \sa {QtMultimedia::Size} */ /*! @@ -470,7 +470,7 @@ void QDeclarativeAudio::componentComplete() This property holds the type of the media. - \sa {QtMultimediaKit::MediaType} + \sa {QtMultimedia::MediaType} */ /*! @@ -479,7 +479,7 @@ void QDeclarativeAudio::componentComplete() This property holds the bit rate of the media's audio stream ni bits per second. - \sa {QtMultimediaKit::AudioBitRate} + \sa {QtMultimedia::AudioBitRate} */ /*! @@ -487,7 +487,7 @@ void QDeclarativeAudio::componentComplete() This property holds the encoding of the media audio stream. - \sa {QtMultimediaKit::AudioCodec} + \sa {QtMultimedia::AudioCodec} */ /*! @@ -495,7 +495,7 @@ void QDeclarativeAudio::componentComplete() This property holds the average volume level of the media. - \sa {QtMultimediaKit::AverageLevel} + \sa {QtMultimedia::AverageLevel} */ /*! @@ -503,7 +503,7 @@ void QDeclarativeAudio::componentComplete() This property holds the number of channels in the media's audio stream. - \sa {QtMultimediaKit::ChannelCount} + \sa {QtMultimedia::ChannelCount} */ /*! @@ -511,7 +511,7 @@ void QDeclarativeAudio::componentComplete() This property holds the peak volume of media's audio stream. - \sa {QtMultimediaKit::PeakValue} + \sa {QtMultimedia::PeakValue} */ /*! @@ -519,7 +519,7 @@ void QDeclarativeAudio::componentComplete() This property holds the sample rate of the media's audio stream in hertz. - \sa {QtMultimediaKit::SampleRate} + \sa {QtMultimedia::SampleRate} */ /*! @@ -527,7 +527,7 @@ void QDeclarativeAudio::componentComplete() This property holds the title of the album the media belongs to. - \sa {QtMultimediaKit::AlbumTitle} + \sa {QtMultimedia::AlbumTitle} */ /*! @@ -536,7 +536,7 @@ void QDeclarativeAudio::componentComplete() This property holds the name of the principal artist of the album the media belongs to. - \sa {QtMultimediaKit::AlbumArtist} + \sa {QtMultimedia::AlbumArtist} */ /*! @@ -544,7 +544,7 @@ void QDeclarativeAudio::componentComplete() This property holds the names of artists contributing to the media. - \sa {QtMultimediaKit::ContributingArtist} + \sa {QtMultimedia::ContributingArtist} */ /*! @@ -552,7 +552,7 @@ void QDeclarativeAudio::componentComplete() This property holds the composer of the media. - \sa {QtMultimediaKit::Composer} + \sa {QtMultimedia::Composer} */ /*! @@ -560,7 +560,7 @@ void QDeclarativeAudio::componentComplete() This property holds the conductor of the media. - \sa {QtMultimediaKit::Conductor} + \sa {QtMultimedia::Conductor} */ /*! @@ -568,7 +568,7 @@ void QDeclarativeAudio::componentComplete() This property holds the lyrics to the media. - \sa {QtMultimediaKit::Lyrics} + \sa {QtMultimedia::Lyrics} */ /*! @@ -576,7 +576,7 @@ void QDeclarativeAudio::componentComplete() This property holds the mood of the media. - \sa {QtMultimediaKit::Mood} + \sa {QtMultimedia::Mood} */ /*! @@ -584,7 +584,7 @@ void QDeclarativeAudio::componentComplete() This property holds the track number of the media. - \sa {QtMultimediaKit::TrackNumber} + \sa {QtMultimedia::TrackNumber} */ /*! @@ -592,7 +592,7 @@ void QDeclarativeAudio::componentComplete() This property holds the number of track on the album containing the media. - \sa {QtMultimediaKit::TrackNumber} + \sa {QtMultimedia::TrackNumber} */ /*! @@ -600,7 +600,7 @@ void QDeclarativeAudio::componentComplete() This property holds the URL of a small cover art image. - \sa {QtMultimediaKit::CoverArtUrlSmall} + \sa {QtMultimedia::CoverArtUrlSmall} */ /*! @@ -608,7 +608,7 @@ void QDeclarativeAudio::componentComplete() This property holds the URL of a large cover art image. - \sa {QtMultimediaKit::CoverArtUrlLarge} + \sa {QtMultimedia::CoverArtUrlLarge} */ /*! @@ -616,7 +616,7 @@ void QDeclarativeAudio::componentComplete() This property holds the dimension of an image or video. - \sa {QtMultimediaKit::Resolution} + \sa {QtMultimedia::Resolution} */ /*! @@ -624,7 +624,7 @@ void QDeclarativeAudio::componentComplete() This property holds the pixel aspect ratio of an image or video. - \sa {QtMultimediaKit::PixelAspectRatio} + \sa {QtMultimedia::PixelAspectRatio} */ /*! @@ -632,7 +632,7 @@ void QDeclarativeAudio::componentComplete() This property holds the frame rate of the media's video stream. - \sa {QtMultimediaKit::VideoFrameRate} + \sa {QtMultimedia::VideoFrameRate} */ /*! @@ -641,7 +641,7 @@ void QDeclarativeAudio::componentComplete() This property holds the bit rate of the media's video stream in bits per second. - \sa {QtMultimediaKit::VideoBitRate} + \sa {QtMultimedia::VideoBitRate} */ /*! @@ -649,7 +649,7 @@ void QDeclarativeAudio::componentComplete() This property holds the encoding of the media's video stream. - \sa {QtMultimediaKit::VideoCodec} + \sa {QtMultimedia::VideoCodec} */ /*! @@ -657,7 +657,7 @@ void QDeclarativeAudio::componentComplete() This property holds the URL of a poster image. - \sa {QtMultimediaKit::PosterUrl} + \sa {QtMultimedia::PosterUrl} */ /*! @@ -665,7 +665,7 @@ void QDeclarativeAudio::componentComplete() This property holds the chapter number of the media. - \sa {QtMultimediaKit::ChapterNumber} + \sa {QtMultimedia::ChapterNumber} */ /*! @@ -673,7 +673,7 @@ void QDeclarativeAudio::componentComplete() This property holds the director of the media. - \sa {QtMultimediaKit::Director} + \sa {QtMultimedia::Director} */ /*! @@ -681,7 +681,7 @@ void QDeclarativeAudio::componentComplete() This property holds the lead performer in the media. - \sa {QtMultimediaKit::LeadPerformer} + \sa {QtMultimedia::LeadPerformer} */ /*! @@ -689,7 +689,7 @@ void QDeclarativeAudio::componentComplete() This property holds the writer of the media. - \sa {QtMultimediaKit::Writer} + \sa {QtMultimedia::Writer} */ QT_END_NAMESPACE diff --git a/src/imports/multimedia/qdeclarativecamera.cpp b/src/imports/multimedia/qdeclarativecamera.cpp index b8fab3661..71b3b0697 100644 --- a/src/imports/multimedia/qdeclarativecamera.cpp +++ b/src/imports/multimedia/qdeclarativecamera.cpp @@ -75,11 +75,11 @@ void QDeclarativeCamera::_q_updateState(QCamera::State state) \ingroup qml-multimedia \inherits Item - This element is part of the \bold{QtMultimediaKit 1.1} module. + This element is part of the \bold{QtMultimedia 4.0} module. \qml import Qt 4.7 - import QtMultimediaKit 1.1 + import QtMultimedia 4.0 Camera { id: camera diff --git a/src/imports/multimedia/qdeclarativecameraexposure.cpp b/src/imports/multimedia/qdeclarativecameraexposure.cpp index c7a8335b0..2dc92243a 100644 --- a/src/imports/multimedia/qdeclarativecameraexposure.cpp +++ b/src/imports/multimedia/qdeclarativecameraexposure.cpp @@ -50,13 +50,13 @@ QT_BEGIN_NAMESPACE \brief The CameraExposure element provides interface for exposure related camera settings. \ingroup qml-multimedia - This element is part of the \bold{Qt.multimediakit 4.0} module. + This element is part of the \bold{QtMultimedia 4.0} module. It should not be constructed separately but provided by Camera.exposure. \qml import QtQuick 2.0 - import Qt.multimediakit 4.0 + import QtMultimedia 4.0 Camera { id: camera diff --git a/src/imports/multimedia/qdeclarativecameraflash.cpp b/src/imports/multimedia/qdeclarativecameraflash.cpp index 6150c6f5b..13f21d6b9 100644 --- a/src/imports/multimedia/qdeclarativecameraflash.cpp +++ b/src/imports/multimedia/qdeclarativecameraflash.cpp @@ -50,13 +50,13 @@ QT_BEGIN_NAMESPACE \brief The CameraFlash element provides interface for flash related camera settings. \ingroup qml-multimedia - This element is part of the \bold{Qt.multimediakit 4.0} module. + This element is part of the \bold{QtMultimedia 4.0} module. It should not be constructed separately but provided by Camera.flash. \qml import QtQuick 2.0 - import Qt.multimediakit 4.0 + import QtMultimedia 4.0 Camera { id: camera diff --git a/src/imports/multimedia/qdeclarativecamerafocus.cpp b/src/imports/multimedia/qdeclarativecamerafocus.cpp index c356d4fd6..03460bfd7 100644 --- a/src/imports/multimedia/qdeclarativecamerafocus.cpp +++ b/src/imports/multimedia/qdeclarativecamerafocus.cpp @@ -50,13 +50,13 @@ QT_BEGIN_NAMESPACE \brief The CameraFocus element provides interface for focus related camera settings. \ingroup qml-multimedia - This element is part of the \bold{Qt.multimediakit 4.0} module. + This element is part of the \bold{QtMultimedia 4.0} module. It should not be constructed separately but provided by Camera.focus. \qml import QtQuick 2.0 - import Qt.multimediakit 4.0 + import QtMultimedia 4.0 Camera { id: camera diff --git a/src/imports/multimedia/qdeclarativemediabase.cpp b/src/imports/multimedia/qdeclarativemediabase.cpp index 5d562d074..b2068627b 100644 --- a/src/imports/multimedia/qdeclarativemediabase.cpp +++ b/src/imports/multimedia/qdeclarativemediabase.cpp @@ -109,9 +109,9 @@ public: bool isMetaDataAvailable() const { return false; } - QVariant metaData(QtMultimediaKit::MetaData) const { return QVariant(); } - QList availableMetaData() const { - return QList(); } + QVariant metaData(QtMultimedia::MetaData) const { return QVariant(); } + QList availableMetaData() const { + return QList(); } QVariant extendedMetaData(const QString &) const { return QVariant(); } QStringList availableExtendedMetaData() const { return QStringList(); } diff --git a/src/imports/multimedia/qdeclarativemediametadata_p.h b/src/imports/multimedia/qdeclarativemediametadata_p.h index 72e9cbf3d..4a737052c 100644 --- a/src/imports/multimedia/qdeclarativemediametadata_p.h +++ b/src/imports/multimedia/qdeclarativemediametadata_p.h @@ -117,57 +117,57 @@ public: { } - QVariant title() const { return m_control->metaData(QtMultimediaKit::Title); } - QVariant subTitle() const { return m_control->metaData(QtMultimediaKit::SubTitle); } - QVariant author() const { return m_control->metaData(QtMultimediaKit::Author); } - QVariant comment() const { return m_control->metaData(QtMultimediaKit::Comment); } - QVariant description() const { return m_control->metaData(QtMultimediaKit::Description); } - QVariant category() const { return m_control->metaData(QtMultimediaKit::Category); } - QVariant genre() const { return m_control->metaData(QtMultimediaKit::Genre); } - QVariant year() const { return m_control->metaData(QtMultimediaKit::Year); } - QVariant date() const { return m_control->metaData(QtMultimediaKit::Date); } - QVariant userRating() const { return m_control->metaData(QtMultimediaKit::UserRating); } - QVariant keywords() const { return m_control->metaData(QtMultimediaKit::Keywords); } - QVariant language() const { return m_control->metaData(QtMultimediaKit::Language); } - QVariant publisher() const { return m_control->metaData(QtMultimediaKit::Publisher); } - QVariant copyright() const { return m_control->metaData(QtMultimediaKit::Copyright); } - QVariant parentalRating() const { return m_control->metaData(QtMultimediaKit::ParentalRating); } + QVariant title() const { return m_control->metaData(QtMultimedia::Title); } + QVariant subTitle() const { return m_control->metaData(QtMultimedia::SubTitle); } + QVariant author() const { return m_control->metaData(QtMultimedia::Author); } + QVariant comment() const { return m_control->metaData(QtMultimedia::Comment); } + QVariant description() const { return m_control->metaData(QtMultimedia::Description); } + QVariant category() const { return m_control->metaData(QtMultimedia::Category); } + QVariant genre() const { return m_control->metaData(QtMultimedia::Genre); } + QVariant year() const { return m_control->metaData(QtMultimedia::Year); } + QVariant date() const { return m_control->metaData(QtMultimedia::Date); } + QVariant userRating() const { return m_control->metaData(QtMultimedia::UserRating); } + QVariant keywords() const { return m_control->metaData(QtMultimedia::Keywords); } + QVariant language() const { return m_control->metaData(QtMultimedia::Language); } + QVariant publisher() const { return m_control->metaData(QtMultimedia::Publisher); } + QVariant copyright() const { return m_control->metaData(QtMultimedia::Copyright); } + QVariant parentalRating() const { return m_control->metaData(QtMultimedia::ParentalRating); } QVariant ratingOrganisation() const { - return m_control->metaData(QtMultimediaKit::RatingOrganisation); } - QVariant size() const { return m_control->metaData(QtMultimediaKit::Size); } - QVariant mediaType() const { return m_control->metaData(QtMultimediaKit::MediaType); } - QVariant duration() const { return m_control->metaData(QtMultimediaKit::Duration); } - QVariant audioBitRate() const { return m_control->metaData(QtMultimediaKit::AudioBitRate); } - QVariant audioCodec() const { return m_control->metaData(QtMultimediaKit::AudioCodec); } - QVariant averageLevel() const { return m_control->metaData(QtMultimediaKit::AverageLevel); } - QVariant channelCount() const { return m_control->metaData(QtMultimediaKit::ChannelCount); } - QVariant peakValue() const { return m_control->metaData(QtMultimediaKit::PeakValue); } - QVariant sampleRate() const { return m_control->metaData(QtMultimediaKit::SampleRate); } - QVariant albumTitle() const { return m_control->metaData(QtMultimediaKit::AlbumTitle); } - QVariant albumArtist() const { return m_control->metaData(QtMultimediaKit::AlbumArtist); } + return m_control->metaData(QtMultimedia::RatingOrganisation); } + QVariant size() const { return m_control->metaData(QtMultimedia::Size); } + QVariant mediaType() const { return m_control->metaData(QtMultimedia::MediaType); } + QVariant duration() const { return m_control->metaData(QtMultimedia::Duration); } + QVariant audioBitRate() const { return m_control->metaData(QtMultimedia::AudioBitRate); } + QVariant audioCodec() const { return m_control->metaData(QtMultimedia::AudioCodec); } + QVariant averageLevel() const { return m_control->metaData(QtMultimedia::AverageLevel); } + QVariant channelCount() const { return m_control->metaData(QtMultimedia::ChannelCount); } + QVariant peakValue() const { return m_control->metaData(QtMultimedia::PeakValue); } + QVariant sampleRate() const { return m_control->metaData(QtMultimedia::SampleRate); } + QVariant albumTitle() const { return m_control->metaData(QtMultimedia::AlbumTitle); } + QVariant albumArtist() const { return m_control->metaData(QtMultimedia::AlbumArtist); } QVariant contributingArtist() const { - return m_control->metaData(QtMultimediaKit::ContributingArtist); } - QVariant composer() const { return m_control->metaData(QtMultimediaKit::Composer); } - QVariant conductor() const { return m_control->metaData(QtMultimediaKit::Conductor); } - QVariant lyrics() const { return m_control->metaData(QtMultimediaKit::Lyrics); } - QVariant mood() const { return m_control->metaData(QtMultimediaKit::Mood); } - QVariant trackNumber() const { return m_control->metaData(QtMultimediaKit::TrackNumber); } - QVariant trackCount() const { return m_control->metaData(QtMultimediaKit::TrackCount); } + return m_control->metaData(QtMultimedia::ContributingArtist); } + QVariant composer() const { return m_control->metaData(QtMultimedia::Composer); } + QVariant conductor() const { return m_control->metaData(QtMultimedia::Conductor); } + QVariant lyrics() const { return m_control->metaData(QtMultimedia::Lyrics); } + QVariant mood() const { return m_control->metaData(QtMultimedia::Mood); } + QVariant trackNumber() const { return m_control->metaData(QtMultimedia::TrackNumber); } + QVariant trackCount() const { return m_control->metaData(QtMultimedia::TrackCount); } QVariant coverArtUrlSmall() const { - return m_control->metaData(QtMultimediaKit::CoverArtUrlSmall); } + return m_control->metaData(QtMultimedia::CoverArtUrlSmall); } QVariant coverArtUrlLarge() const { - return m_control->metaData(QtMultimediaKit::CoverArtUrlLarge); } - QVariant resolution() const { return m_control->metaData(QtMultimediaKit::Resolution); } + return m_control->metaData(QtMultimedia::CoverArtUrlLarge); } + QVariant resolution() const { return m_control->metaData(QtMultimedia::Resolution); } QVariant pixelAspectRatio() const { - return m_control->metaData(QtMultimediaKit::PixelAspectRatio); } - QVariant videoFrameRate() const { return m_control->metaData(QtMultimediaKit::VideoFrameRate); } - QVariant videoBitRate() const { return m_control->metaData(QtMultimediaKit::VideoBitRate); } - QVariant videoCodec() const { return m_control->metaData(QtMultimediaKit::VideoCodec); } - QVariant posterUrl() const { return m_control->metaData(QtMultimediaKit::PosterUrl); } - QVariant chapterNumber() const { return m_control->metaData(QtMultimediaKit::ChapterNumber); } - QVariant director() const { return m_control->metaData(QtMultimediaKit::Director); } - QVariant leadPerformer() const { return m_control->metaData(QtMultimediaKit::LeadPerformer); } - QVariant writer() const { return m_control->metaData(QtMultimediaKit::Writer); } + return m_control->metaData(QtMultimedia::PixelAspectRatio); } + QVariant videoFrameRate() const { return m_control->metaData(QtMultimedia::VideoFrameRate); } + QVariant videoBitRate() const { return m_control->metaData(QtMultimedia::VideoBitRate); } + QVariant videoCodec() const { return m_control->metaData(QtMultimedia::VideoCodec); } + QVariant posterUrl() const { return m_control->metaData(QtMultimedia::PosterUrl); } + QVariant chapterNumber() const { return m_control->metaData(QtMultimedia::ChapterNumber); } + QVariant director() const { return m_control->metaData(QtMultimedia::Director); } + QVariant leadPerformer() const { return m_control->metaData(QtMultimedia::LeadPerformer); } + QVariant writer() const { return m_control->metaData(QtMultimedia::Writer); } Q_SIGNALS: void metaDataChanged(); diff --git a/src/imports/multimedia/qdeclarativevideo.cpp b/src/imports/multimedia/qdeclarativevideo.cpp index b2b4f33d0..956d1d796 100644 --- a/src/imports/multimedia/qdeclarativevideo.cpp +++ b/src/imports/multimedia/qdeclarativevideo.cpp @@ -72,11 +72,11 @@ void QDeclarativeVideo::_q_error(int errorCode, const QString &errorString) \inherits Item \ingroup qml-multimedia - This element is part of the \bold{QtMultimediaKit 1.1} module. + This element is part of the \bold{QtMultimedia 4.0} module. \qml import Qt 4.7 - import QtMultimediaKit 1.1 + import QtMultimedia 4.0 Video { id: video @@ -427,7 +427,7 @@ QT_END_NAMESPACE This property holds the tile of the media. - \sa {QtMultimediaKit::Title} + \sa {QtMultimedia::Title} */ /*! @@ -435,7 +435,7 @@ QT_END_NAMESPACE This property holds the sub-title of the media. - \sa {QtMultimediaKit::SubTitle} + \sa {QtMultimedia::SubTitle} */ /*! @@ -443,7 +443,7 @@ QT_END_NAMESPACE This property holds the author of the media. - \sa {QtMultimediaKit::Author} + \sa {QtMultimedia::Author} */ /*! @@ -451,7 +451,7 @@ QT_END_NAMESPACE This property holds a user comment about the media. - \sa {QtMultimediaKit::Comment} + \sa {QtMultimedia::Comment} */ /*! @@ -459,7 +459,7 @@ QT_END_NAMESPACE This property holds a description of the media. - \sa {QtMultimediaKit::Description} + \sa {QtMultimedia::Description} */ /*! @@ -467,7 +467,7 @@ QT_END_NAMESPACE This property holds the category of the media - \sa {QtMultimediaKit::Category} + \sa {QtMultimedia::Category} */ /*! @@ -475,7 +475,7 @@ QT_END_NAMESPACE This property holds the genre of the media. - \sa {QtMultimediaKit::Genre} + \sa {QtMultimedia::Genre} */ /*! @@ -483,7 +483,7 @@ QT_END_NAMESPACE This property holds the year of release of the media. - \sa {QtMultimediaKit::Year} + \sa {QtMultimedia::Year} */ /*! @@ -491,7 +491,7 @@ QT_END_NAMESPACE This property holds the date of the media. - \sa {QtMultimediaKit::Date} + \sa {QtMultimedia::Date} */ /*! @@ -499,7 +499,7 @@ QT_END_NAMESPACE This property holds a user rating of the media in the range of 0 to 100. - \sa {QtMultimediaKit::UserRating} + \sa {QtMultimedia::UserRating} */ /*! @@ -507,7 +507,7 @@ QT_END_NAMESPACE This property holds a list of keywords describing the media. - \sa {QtMultimediaKit::Keywords} + \sa {QtMultimedia::Keywords} */ /*! @@ -515,7 +515,7 @@ QT_END_NAMESPACE This property holds the language of the media, as an ISO 639-2 code. - \sa {QtMultimediaKit::Language} + \sa {QtMultimedia::Language} */ /*! @@ -523,7 +523,7 @@ QT_END_NAMESPACE This property holds the publisher of the media. - \sa {QtMultimediaKit::Publisher} + \sa {QtMultimedia::Publisher} */ /*! @@ -531,7 +531,7 @@ QT_END_NAMESPACE This property holds the media's copyright notice. - \sa {QtMultimediaKit::Copyright} + \sa {QtMultimedia::Copyright} */ /*! @@ -539,7 +539,7 @@ QT_END_NAMESPACE This property holds the parental rating of the media. - \sa {QtMultimediaKit::ParentalRating} + \sa {QtMultimedia::ParentalRating} */ /*! @@ -548,7 +548,7 @@ QT_END_NAMESPACE This property holds the name of the rating organisation responsible for the parental rating of the media. - \sa {QtMultimediaKit::RatingOrganisation} + \sa {QtMultimedia::RatingOrganisation} */ /*! @@ -556,7 +556,7 @@ QT_END_NAMESPACE This property property holds the size of the media in bytes. - \sa {QtMultimediaKit::Size} + \sa {QtMultimedia::Size} */ /*! @@ -564,7 +564,7 @@ QT_END_NAMESPACE This property holds the type of the media. - \sa {QtMultimediaKit::MediaType} + \sa {QtMultimedia::MediaType} */ /*! @@ -573,7 +573,7 @@ QT_END_NAMESPACE This property holds the bit rate of the media's audio stream ni bits per second. - \sa {QtMultimediaKit::AudioBitRate} + \sa {QtMultimedia::AudioBitRate} */ /*! @@ -581,7 +581,7 @@ QT_END_NAMESPACE This property holds the encoding of the media audio stream. - \sa {QtMultimediaKit::AudioCodec} + \sa {QtMultimedia::AudioCodec} */ /*! @@ -589,7 +589,7 @@ QT_END_NAMESPACE This property holds the average volume level of the media. - \sa {QtMultimediaKit::AverageLevel} + \sa {QtMultimedia::AverageLevel} */ /*! @@ -597,7 +597,7 @@ QT_END_NAMESPACE This property holds the number of channels in the media's audio stream. - \sa {QtMultimediaKit::ChannelCount} + \sa {QtMultimedia::ChannelCount} */ /*! @@ -605,7 +605,7 @@ QT_END_NAMESPACE This property holds the peak volume of media's audio stream. - \sa {QtMultimediaKit::PeakValue} + \sa {QtMultimedia::PeakValue} */ /*! @@ -613,7 +613,7 @@ QT_END_NAMESPACE This property holds the sample rate of the media's audio stream in hertz. - \sa {QtMultimediaKit::SampleRate} + \sa {QtMultimedia::SampleRate} */ /*! @@ -621,7 +621,7 @@ QT_END_NAMESPACE This property holds the title of the album the media belongs to. - \sa {QtMultimediaKit::AlbumTitle} + \sa {QtMultimedia::AlbumTitle} */ /*! @@ -630,7 +630,7 @@ QT_END_NAMESPACE This property holds the name of the principal artist of the album the media belongs to. - \sa {QtMultimediaKit::AlbumArtist} + \sa {QtMultimedia::AlbumArtist} */ /*! @@ -638,7 +638,7 @@ QT_END_NAMESPACE This property holds the names of artists contributing to the media. - \sa {QtMultimediaKit::ContributingArtist} + \sa {QtMultimedia::ContributingArtist} */ /*! @@ -646,7 +646,7 @@ QT_END_NAMESPACE This property holds the composer of the media. - \sa {QtMultimediaKit::Composer} + \sa {QtMultimedia::Composer} */ /*! @@ -654,7 +654,7 @@ QT_END_NAMESPACE This property holds the conductor of the media. - \sa {QtMultimediaKit::Conductor} + \sa {QtMultimedia::Conductor} */ /*! @@ -662,7 +662,7 @@ QT_END_NAMESPACE This property holds the lyrics to the media. - \sa {QtMultimediaKit::Lyrics} + \sa {QtMultimedia::Lyrics} */ /*! @@ -670,7 +670,7 @@ QT_END_NAMESPACE This property holds the mood of the media. - \sa {QtMultimediaKit::Mood} + \sa {QtMultimedia::Mood} */ /*! @@ -678,7 +678,7 @@ QT_END_NAMESPACE This property holds the track number of the media. - \sa {QtMultimediaKit::TrackNumber} + \sa {QtMultimedia::TrackNumber} */ /*! @@ -686,7 +686,7 @@ QT_END_NAMESPACE This property holds the number of track on the album containing the media. - \sa {QtMultimediaKit::TrackNumber} + \sa {QtMultimedia::TrackNumber} */ /*! @@ -694,7 +694,7 @@ QT_END_NAMESPACE This property holds the URL of a small cover art image. - \sa {QtMultimediaKit::CoverArtUrlSmall} + \sa {QtMultimedia::CoverArtUrlSmall} */ /*! @@ -702,7 +702,7 @@ QT_END_NAMESPACE This property holds the URL of a large cover art image. - \sa {QtMultimediaKit::CoverArtUrlLarge} + \sa {QtMultimedia::CoverArtUrlLarge} */ /*! @@ -710,7 +710,7 @@ QT_END_NAMESPACE This property holds the dimension of an image or video. - \sa {QtMultimediaKit::Resolution} + \sa {QtMultimedia::Resolution} */ /*! @@ -718,7 +718,7 @@ QT_END_NAMESPACE This property holds the pixel aspect ratio of an image or video. - \sa {QtMultimediaKit::PixelAspectRatio} + \sa {QtMultimedia::PixelAspectRatio} */ /*! @@ -726,7 +726,7 @@ QT_END_NAMESPACE This property holds the frame rate of the media's video stream. - \sa {QtMultimediaKit::VideoFrameRate} + \sa {QtMultimedia::VideoFrameRate} */ /*! @@ -735,7 +735,7 @@ QT_END_NAMESPACE This property holds the bit rate of the media's video stream in bits per second. - \sa {QtMultimediaKit::VideoBitRate} + \sa {QtMultimedia::VideoBitRate} */ /*! @@ -743,7 +743,7 @@ QT_END_NAMESPACE This property holds the encoding of the media's video stream. - \sa {QtMultimediaKit::VideoCodec} + \sa {QtMultimedia::VideoCodec} */ /*! @@ -751,7 +751,7 @@ QT_END_NAMESPACE This property holds the URL of a poster image. - \sa {QtMultimediaKit::PosterUrl} + \sa {QtMultimedia::PosterUrl} */ /*! @@ -759,7 +759,7 @@ QT_END_NAMESPACE This property holds the chapter number of the media. - \sa {QtMultimediaKit::ChapterNumber} + \sa {QtMultimedia::ChapterNumber} */ /*! @@ -767,7 +767,7 @@ QT_END_NAMESPACE This property holds the director of the media. - \sa {QtMultimediaKit::Director} + \sa {QtMultimedia::Director} */ /*! @@ -775,7 +775,7 @@ QT_END_NAMESPACE This property holds the lead performer in the media. - \sa {QtMultimediaKit::LeadPerformer} + \sa {QtMultimedia::LeadPerformer} */ /*! @@ -783,7 +783,7 @@ QT_END_NAMESPACE This property holds the writer of the media. - \sa {QtMultimediaKit::Writer} + \sa {QtMultimedia::Writer} */ // The remaining properties are related to photos, and are technically @@ -793,157 +793,157 @@ QT_END_NAMESPACE /*! \qmlproperty variant Video::metaData.cameraManufacturer - \sa {QtMultimediaKit::CameraManufacturer} + \sa {QtMultimedia::CameraManufacturer} */ /*! \qmlproperty variant Video::metaData.cameraModel - \sa {QtMultimediaKit::CameraModel} + \sa {QtMultimedia::CameraModel} */ /*! \qmlproperty variant Video::metaData.event - \sa {QtMultimediaKit::Event} + \sa {QtMultimedia::Event} */ /*! \qmlproperty variant Video::metaData.subject - \sa {QtMultimediaKit::Subject} + \sa {QtMultimedia::Subject} */ /*! \qmlproperty variant Video::metaData.orientation - \sa {QtMultimediaKit::Orientation} + \sa {QtMultimedia::Orientation} */ /*! \qmlproperty variant Video::metaData.exposureTime - \sa {QtMultimediaKit::ExposureTime} + \sa {QtMultimedia::ExposureTime} */ /*! \qmlproperty variant Video::metaData.fNumber - \sa {QtMultimediaKit::FNumber} + \sa {QtMultimedia::FNumber} */ /*! \qmlproperty variant Video::metaData.exposureProgram - \sa {QtMultimediaKit::ExposureProgram} + \sa {QtMultimedia::ExposureProgram} */ /*! \qmlproperty variant Video::metaData.isoSpeedRatings - \sa {QtMultimediaKit::ISOSpeedRatings} + \sa {QtMultimedia::ISOSpeedRatings} */ /*! \qmlproperty variant Video::metaData.exposureBiasValue - \sa {QtMultimediaKit::ExposureBiasValue} + \sa {QtMultimedia::ExposureBiasValue} */ /*! \qmlproperty variant Video::metaData.dateTimeDigitized - \sa {QtMultimediaKit::DateTimeDigitized} + \sa {QtMultimedia::DateTimeDigitized} */ /*! \qmlproperty variant Video::metaData.subjectDistance - \sa {QtMultimediaKit::SubjectDistance} + \sa {QtMultimedia::SubjectDistance} */ /*! \qmlproperty variant Video::metaData.meteringMode - \sa {QtMultimediaKit::MeteringMode} + \sa {QtMultimedia::MeteringMode} */ /*! \qmlproperty variant Video::metaData.lightSource - \sa {QtMultimediaKit::LightSource} + \sa {QtMultimedia::LightSource} */ /*! \qmlproperty variant Video::metaData.flash - \sa {QtMultimediaKit::Flash} + \sa {QtMultimedia::Flash} */ /*! \qmlproperty variant Video::metaData.focalLength - \sa {QtMultimediaKit::FocalLength} + \sa {QtMultimedia::FocalLength} */ /*! \qmlproperty variant Video::metaData.exposureMode - \sa {QtMultimediaKit::ExposureMode} + \sa {QtMultimedia::ExposureMode} */ /*! \qmlproperty variant Video::metaData.whiteBalance - \sa {QtMultimediaKit::WhiteBalance} + \sa {QtMultimedia::WhiteBalance} */ /*! \qmlproperty variant Video::metaData.DigitalZoomRatio - \sa {QtMultimediaKit::DigitalZoomRatio} + \sa {QtMultimedia::DigitalZoomRatio} */ /*! \qmlproperty variant Video::metaData.focalLengthIn35mmFilm - \sa {QtMultimediaKit::FocalLengthIn35mmFile} + \sa {QtMultimedia::FocalLengthIn35mmFile} */ /*! \qmlproperty variant Video::metaData.sceneCaptureType - \sa {QtMultimediaKit::SceneCaptureType} + \sa {QtMultimedia::SceneCaptureType} */ /*! \qmlproperty variant Video::metaData.gainControl - \sa {QtMultimediaKit::GainControl} + \sa {QtMultimedia::GainControl} */ /*! \qmlproperty variant Video::metaData.contrast - \sa {QtMultimediaKit::contrast} + \sa {QtMultimedia::contrast} */ /*! \qmlproperty variant Video::metaData.saturation - \sa {QtMultimediaKit::Saturation} + \sa {QtMultimedia::Saturation} */ /*! \qmlproperty variant Video::metaData.sharpness - \sa {QtMultimediaKit::Sharpness} + \sa {QtMultimedia::Sharpness} */ /*! \qmlproperty variant Video::metaData.deviceSettingDescription - \sa {QtMultimediaKit::DeviceSettingDescription} + \sa {QtMultimedia::DeviceSettingDescription} */ #endif diff --git a/src/imports/multimedia/qdeclarativevideooutput.cpp b/src/imports/multimedia/qdeclarativevideooutput.cpp index e715c55fa..ceefc7eb0 100644 --- a/src/imports/multimedia/qdeclarativevideooutput.cpp +++ b/src/imports/multimedia/qdeclarativevideooutput.cpp @@ -46,10 +46,10 @@ #include -#include -#include -#include -#include +#include +#include +#include +#include #include @@ -112,11 +112,11 @@ private: \ingroup qml-multimedia - This element is part of the \bold{QtMultimediaKit 4.0} module. + This element is part of the \bold{QtMultimedia 4.0} module. \qml import QtQuick 2.0 - import Qt.multimediakit 4.0 + import QtMultimedia 4.0 Rectangle { width: 800 diff --git a/src/imports/multimedia/qdeclarativevideooutput_p.h b/src/imports/multimedia/qdeclarativevideooutput_p.h index 3fbeb0fb7..9286fec8b 100644 --- a/src/imports/multimedia/qdeclarativevideooutput_p.h +++ b/src/imports/multimedia/qdeclarativevideooutput_p.h @@ -44,8 +44,8 @@ #include -#include -#include +#include +#include #include diff --git a/src/imports/multimedia/qmldir.qtmultimediakit b/src/imports/multimedia/qmldir.qtmultimediakit new file mode 100644 index 000000000..494204875 --- /dev/null +++ b/src/imports/multimedia/qmldir.qtmultimediakit @@ -0,0 +1 @@ +plugin declarative_multimedia ../../QtMultimedia diff --git a/src/imports/multimedia/qsgvideonode_i420.h b/src/imports/multimedia/qsgvideonode_i420.h index 516f70cc5..b02864a7c 100644 --- a/src/imports/multimedia/qsgvideonode_i420.h +++ b/src/imports/multimedia/qsgvideonode_i420.h @@ -43,7 +43,7 @@ #define QSGVIDEONODE_I420_H #include "qsgvideonode_p.h" -#include +#include class QSGVideoMaterial_YUV420; class QSGVideoNode_I420 : public QSGVideoNode diff --git a/src/imports/multimedia/qsgvideonode_p.h b/src/imports/multimedia/qsgvideonode_p.h index 49d5a5c76..466b4566c 100644 --- a/src/imports/multimedia/qsgvideonode_p.h +++ b/src/imports/multimedia/qsgvideonode_p.h @@ -44,8 +44,8 @@ #include -#include -#include +#include +#include #include class QSGVideoNode : public QSGGeometryNode diff --git a/src/imports/qimportbase.pri b/src/imports/qimportbase.pri index 86e9c3df5..999bc5c87 100644 --- a/src/imports/qimportbase.pri +++ b/src/imports/qimportbase.pri @@ -14,7 +14,7 @@ isEmpty(TARGET) { QMLDIRFILE = $${_PRO_FILE_PWD_}/qmldir copy2build.input = QMLDIRFILE -copy2build.output = $$QT.multimediakit.imports/$$TARGETPATH/qmldir +copy2build.output = $$QT.multimedia.imports/$$TARGETPATH/qmldir !contains(TEMPLATE_PREFIX, vc):copy2build.variable_out = PRE_TARGETDEPS copy2build.commands = $$QMAKE_COPY ${QMAKE_FILE_IN} ${QMAKE_FILE_OUT} copy2build.name = COPY ${QMAKE_FILE_IN} diff --git a/src/meegoinstalls/Makefile b/src/meegoinstalls/Makefile deleted file mode 100644 index de0b65142..000000000 --- a/src/meegoinstalls/Makefile +++ /dev/null @@ -1,40 +0,0 @@ -PKG_NAME := qt-mobility -SPECFILE = $(addsuffix .spec, $(PKG_NAME)) -YAMLFILE = $(addsuffix .yaml, $(PKG_NAME)) - -first: custom-help - -include /usr/share/meego-packaging-tools/Makefile.common - -custom-help: help - @echo "The above are common MeeGo packaging targets." - @echo "$(PKG_NAME) also has these additional targets:" - @echo " spec-git Create spec file, with options appropriate for git" - @echo " build-trunk-i686 Do a local i686 build against Trunk, without using OBS" - @echo " build-trunk-testing-i686 Do a local i686 build against Trunk:Testing, without using OBS" - -spec-git: - specify --skip-scm --not-download --non-interactive - -git-archive: spec-git - @VER=$$(sed -n -r -e 's|^Version: +||p' $(SPECFILE)); \ - TARGZ=$$(sed -n -r \ - -e 's|^Source0:.*/([^/]+)$$|\1|' \ - -e 's|%\{name\}|$(PKG_NAME)|' \ - -e "s|%\{version\}|$$VER|" \ - -e 's|.tar.gz||p' \ - $(SPECFILE) ); \ - DIR="$$PWD"; \ - cd $$(git rev-parse --git-dir) && \ - echo "Creating $$DIR/$$TARGZ.tar.gz ..." && \ - git archive HEAD --prefix=$$TARGZ/ --format=tar | gzip > "$$DIR/$$TARGZ.tar.gz" - -build-no-obs = sudo build $(SPECFILE) --repository $1 --arch $2 - -build-no-obs-deps: /usr/bin/build git-archive - -build-trunk-i686: build-no-obs-deps - $(call build-no-obs,http://download.meego.com/live/Trunk/standard/,i686) - -build-trunk-testing-i686: build-no-obs-deps - $(call build-no-obs,http://download.meego.com/live/Trunk:/Testing/standard/,i686) diff --git a/src/meegoinstalls/README b/src/meegoinstalls/README deleted file mode 100644 index fa3fc3049..000000000 --- a/src/meegoinstalls/README +++ /dev/null @@ -1,95 +0,0 @@ -This directory contains the MeeGo.com packaging metadata for Qt Mobility, -for use with the MeeGo.com OpenSuSE Build Service (OBS). - -Please see http://build.meego.com/ for more information about OBS. - -Quick Start: run `make' in this directory to see some useful things you -can do. - - - -PATCHES -======= - -At the time of writing, there are some MeeGo-specific patches hosted -on the MeeGo OBS. These patches are unable to be hosted in the Mobility -git repository at this time. - -In order to successfully build Mobility for MeeGo, you must also obtain -these patches, or you must modify qt-mobility.yaml and qt-mobility.spec -to remove the usage of the patches. - -Please do not add any more patches. - - - -HOW TO MAKE CHANGES -=================== - -Within this directory, there is a yaml file and a spec file. The yaml -file is maintained by hand; the spec file is partially generated from the -yaml file, but partially maintained by hand also, in specially marked -sections. - -The command used to generate the spec file from the yaml file is `specify'. -This is part of a tool named Spectacle. This can be installed from the -MeeGo tools repositories. It does not require a full MeeGo SDK install. -For example, on Ubuntu: - - $ sudo /bin/sh -c 'echo deb http://repo.meego.com/MeeGo/tools/repos/ubuntu/10.04/ / > /etc/apt/sources.list.d/meego-tools.list' - $ gpg --keyserver pgpkeys.mit.edu --recv 0BC7BEC479FC1F8A && gpg --export --armor 0BC7BEC479FC1F8A | sudo apt-key add - - $ sudo apt-get update - $ sudo apt-get install meego-packaging-tools - -Once you have installed meego-packaging-tools, you can run `make spec-git' -in this directory to regenerate the spec file from the yaml file. -The spec file and yaml file should be maintained together, so if you -modify the yaml file, you should do `make spec-git' and put the -modifications to the spec file in the same commit. - -Please see http://wiki.meego.com/Spectacle for more information about -spectacle. - - - -HOW TO BUILD -============ - -Note: these instructions are not canonical or supported in any way. -They are here as a quick start for people who want to contribute to -Qt Mobility and do not know how to compile for MeeGo. - -The most accurate way to build is to use the OpenSuSE build service -on build.meego.com. Unfortunately, at time of writing, anonymous -access to this service is not available. Therefore, using build.meego.com -is not an option for most people. - -However, a fairly accurate build can still be done using the `build' command -and referring to the live MeeGo repos. - - -Abbreviated example of how to install `build' for Ubuntu: - - $ sudo /bin/sh -c 'echo deb http://repo.meego.com/MeeGo/tools/repos/ubuntu/10.04/ / > /etc/apt/sources.list.d/meego-tools.list' - $ gpg --keyserver pgpkeys.mit.edu --recv 0BC7BEC479FC1F8A && gpg --export --armor 0BC7BEC479FC1F8A | sudo apt-key add - - $ sudo apt-get update - $ sudo apt-get install build - $ gpg --keyserver pgpkeys.mit.edu --recv 79FC1F8A && gpg --export --armor 79FC1F8A | sudo rpm --import - - - -Then, to do the build (for i686): - - $ make build-trunk-i686 - - -Or, to use the Trunk:Testing repository (which may contain newer versions of some packages): - - $ make build-trunk-testing-i686 - - -These builds will take place in a chroot, and hence will require root access. -They will attempt to use `sudo' for this. - -If you hit an error, `rpm: error while loading shared libraries: liblua-5.1.so', -edit /usr/lib/build/configs/default.conf and add liblua to one of the `Preinstall:' lines -(see http://comments.gmane.org/gmane.comp.handhelds.meego.devel/7139 ) diff --git a/src/meegoinstalls/qt-mobility.spec b/src/meegoinstalls/qt-mobility.spec deleted file mode 100644 index fab3effff..000000000 --- a/src/meegoinstalls/qt-mobility.spec +++ /dev/null @@ -1,1360 +0,0 @@ -# -# Do NOT Edit the Auto-generated Part! -# Generated by: spectacle version 0.21 -# -# >> macros -# << macros - -Name: qt-mobility -Summary: APIs for mobile device functionality -Version: 1.1.0+git2438 -Release: 1 -Group: System/Libraries -License: LGPLv2.1 with exception or GPLv3 -URL: http://qt.gitorious.org/qt-mobility -Source0: http://get.qt.nokia.com/qt/add-ons/%{name}-opensource-src-%{version}.tar.gz -Source100: qt-mobility.yaml -Requires: libqtconnectivity1 = %{version} -Requires: libqtcontacts1 = %{version} -Requires: libqtfeedback1 = %{version} -Requires: libqtgallery1 = %{version} -Requires: libqtlocation1 = %{version} -Requires: libqtmessaging1 = %{version} -Requires: libqtmultimediakit1 = %{version} -Requires: libqtorganizer1 = %{version} -Requires: libqtpublishsubscribe1 = %{version} -Requires: libqtsensors1 = %{version} -Requires: libqtserviceframework1 = %{version} -Requires: libqtsysteminfo1 = %{version} -Requires: libqtversit1 = %{version} -Requires: libqtversitorganizer1 = %{version} -BuildRequires: pkgconfig(QtGui) -BuildRequires: pkgconfig(QtOpenGL) -BuildRequires: pkgconfig(alsa) -BuildRequires: pkgconfig(blkid) -BuildRequires: pkgconfig(bluez) -BuildRequires: pkgconfig(connman) -BuildRequires: pkgconfig(contextsubscriber-1.0) -BuildRequires: pkgconfig(gconf-2.0) -BuildRequires: pkgconfig(geoclue) -BuildRequires: pkgconfig(gstreamer-plugins-bad-free-0.10) -BuildRequires: pkgconfig(gstreamer-plugins-base-0.10) -BuildRequires: pkgconfig(gypsy) -BuildRequires: pkgconfig(libiphb) -BuildRequires: pkgconfig(libpulse) -BuildRequires: pkgconfig(libmkcal) -BuildRequires: pkgconfig(meegotouch) -BuildRequires: pkgconfig(qttracker) -BuildRequires: pkgconfig(qmfclient) -BuildRequires: pkgconfig(sensord) -BuildRequires: pkgconfig(udev) -BuildRequires: pkgconfig(x11) -BuildRequires: pkgconfig(xext) -BuildRequires: pkgconfig(xrandr) -BuildRequires: pkgconfig(xrender) -BuildRequires: pkgconfig(xv) -BuildRequires: pkgconfig(QtSparql) -BuildRequires: pkgconfig(QtSparqlTrackerExtensions) -BuildRequires: qt-devel-tools -BuildRequires: fdupes - - -%description -Qt Mobility delivers a set of new APIs for mobile device functionality. These -APIs allow the developer to use these features with ease from one framework and -apply them to phones, netbooks and non-mobile personal computers. - - - -%package devel -Summary: APIs for mobile device functionality - development files -Group: Development/Libraries -Requires: %{name} = %{version}-%{release} -Requires: servicefw - -%description devel -Qt Mobility delivers a set of new APIs for mobile device functionality. - -This package contains the development files needed to build Qt applications -using Qt Mobility libraries. - - -%package -n libqtconnectivity1 -Summary: Qt Mobility Connectivity module -Group: System/Libraries -Requires: %{name} = %{version}-%{release} -Requires(post): /sbin/ldconfig -Requires(postun): /sbin/ldconfig - -%description -n libqtconnectivity1 -Qt Mobility delivers a set of new APIs for mobile device functionality. - -This package contains the Connectivity API. It provides APIs for working with -local devices. - - -%package -n libqtcontacts1 -Summary: Qt Mobility Contacts module -Group: System/Libraries -Requires: %{name} = %{version}-%{release} -Requires(post): /sbin/ldconfig -Requires(postun): /sbin/ldconfig - -%description -n libqtcontacts1 -Qt Mobility delivers a set of new APIs for mobile device functionality. - -This package contains an API enabling clients to request contact data from -local or remote backends. - - -%package -n libqtfeedback1 -Summary: Qt Mobility Feedback module -Group: System/Libraries -Requires: %{name} = %{version}-%{release} -Requires(post): /sbin/ldconfig -Requires(postun): /sbin/ldconfig - -%description -n libqtfeedback1 -Qt Mobility delivers a set of new APIs for mobile device functionality. - -This package contains the Feedback API. It enables a client to control -the vibration of the device or the piezo feedback from the screen. - - -%package -n libqtgallery1 -Summary: Qt Mobility Document Gallery module -Group: System/Libraries -Requires: %{name} = %{version}-%{release} -Requires(post): /sbin/ldconfig -Requires(postun): /sbin/ldconfig - -%description -n libqtgallery1 -Qt Mobility delivers a set of new APIs for mobile device functionality. - -This package contains an API for accessing collections of documents and media -and their meta-data. - - -%package -n libqtlocation1 -Summary: Qt Mobility Location module -Group: System/Libraries -Requires: %{name} = %{version}-%{release} -Requires(post): /sbin/ldconfig -Requires(postun): /sbin/ldconfig - -%description -n libqtlocation1 -Qt Mobility delivers a set of new APIs for mobile device functionality. - -This package contains the Location API. It provides a library for distributing -and receiving location data using arbitrary data sources. - - -%package -n libqtmessaging1 -Summary: Qt Mobility Messaging module -Group: System/Libraries -Requires: %{name} = %{version}-%{release} -Requires(post): /sbin/ldconfig -Requires(postun): /sbin/ldconfig - -%description -n libqtmessaging1 -Qt Mobility delivers a set of new APIs for mobile device functionality. - -This package contains the Messaging API. It is a common interface for handling -SMS, MMS, MIME Email and TNEF Email messages. - - -%package -n libqtmultimediakit1 -Summary: Qt Mobility MultimediaKit module -Group: System/Libraries -Requires: %{name} = %{version}-%{release} -Requires(post): /sbin/ldconfig -Requires(postun): /sbin/ldconfig - -%description -n libqtmultimediakit1 -Qt Mobility delivers a set of new APIs for mobile device functionality. - -This package contains a set of APIs to play and record media, and manage a -collection of media content. - - -%package -n libqtorganizer1 -Summary: Qt Mobility Organizer module -Group: System/Libraries -Requires: %{name} = %{version}-%{release} -Requires(post): /sbin/ldconfig -Requires(postun): /sbin/ldconfig - -%description -n libqtorganizer1 -Qt Mobility delivers a set of new APIs for mobile device functionality. - -This package contains an API for management of calendar, scheduling and -personal data from local or remote backends. It includes the ability to create, -edit, list, delete and lookup organizer information whether it is stored -locally or remotely. - - -%package -n libqtpublishsubscribe1 -Summary: Qt Mobility Publish and Subscribe module -Group: System/Libraries -Requires: %{name} = %{version}-%{release} -Requires(post): /sbin/ldconfig -Requires(postun): /sbin/ldconfig - -%description -n libqtpublishsubscribe1 -Qt Mobility delivers a set of new APIs for mobile device functionality. - -This package contains the Publish and Subscribe API (containing Value Space). -It enables applications to read item values, navigate through and subscribe to -change notifications. - - -%package -n libqtsensors1 -Summary: Qt Mobility Sensors module -Group: System/Libraries -Requires: %{name} = %{version}-%{release} -Requires: libqtsql4-sqlite -Requires: sensorfw -Requires(post): /sbin/ldconfig -Requires(postun): /sbin/ldconfig - -%description -n libqtsensors1 -Qt Mobility delivers a set of new APIs for mobile device functionality. - -This package contains the Sensors API. It provides access to sensors. - - -%package -n libqtserviceframework1 -Summary: Qt Mobility Service Framework module -Group: System/Libraries -Requires: %{name} = %{version}-%{release} -Requires(post): /sbin/ldconfig -Requires(postun): /sbin/ldconfig - -%description -n libqtserviceframework1 -Qt Mobility delivers a set of new APIs for mobile device functionality. - -This package contains a set of APIs to that allows clients to discover and -instantiate arbitrary services. - - -%package -n libqtsysteminfo1 -Summary: Qt Mobility System Information module -Group: System/Libraries -Requires: %{name} = %{version}-%{release} -Requires(post): /sbin/ldconfig -Requires(postun): /sbin/ldconfig - -%description -n libqtsysteminfo1 -Qt Mobility delivers a set of new APIs for mobile device functionality. - -This package contains a set of APIs to discover system related information and -capabilities. - - -%package -n libqtversit1 -Summary: Qt Mobility Versit (vCard) module -Group: System/Libraries -Requires: %{name} = %{version}-%{release} -Requires(post): /sbin/ldconfig -Requires(postun): /sbin/ldconfig - -%description -n libqtversit1 -Qt Mobility delivers a set of new APIs for mobile device functionality. - -This package contains an API to manage Versit documents, such as vCards. - - -%package -n libqtversitorganizer1 -Summary: Qt Mobility Versit (Organizer) module -Group: System/Libraries -Requires: %{name} = %{version}-%{release} -Requires(post): /sbin/ldconfig -Requires(postun): /sbin/ldconfig - -%description -n libqtversitorganizer1 -Qt Mobility delivers a set of new APIs for mobile device functionality. - -This package contains an API to manage Versit documents, such as iCalendar -documents. It interfaces the Organizer API and uses the same framework as for -vCards. - - -%package -n libdeclarative-contacts -Summary: Qt Mobility Contacts QML plugin -Group: System/Libraries -Requires: %{name} = %{version}-%{release} - -%description -n libdeclarative-contacts -Qt Mobility delivers a set of new APIs for mobile device functionality. - -This package contains the Contacts QML plugin for QtDeclarative. - - -%package -n libdeclarative-feedback -Summary: Qt Mobility Feedback QML plugin -Group: System/Libraries -Requires: %{name} = %{version}-%{release} - -%description -n libdeclarative-feedback -Qt Mobility delivers a set of new APIs for mobile device functionality. - -This package contains the Feedback QML plugin for QtDeclarative. - - -%package -n libdeclarative-gallery -Summary: Qt Mobility Document Gallery QML plugin -Group: System/Libraries -Requires: %{name} = %{version}-%{release} - -%description -n libdeclarative-gallery -Qt Mobility delivers a set of new APIs for mobile device functionality. - -This package contains the Document Gallery QML plugin for QtDeclarative. - - -%package -n libdeclarative-location -Summary: Qt Mobility Location QML plugin -Group: System/Libraries -Requires: %{name} = %{version}-%{release} - -%description -n libdeclarative-location -Qt Mobility delivers a set of new APIs for mobile device functionality. - -This package contains the Location QML plugin for QtDeclarative. - - -%package -n libdeclarative-messaging -Summary: Qt Mobility Messaging QML plugin -Group: System/Libraries -Requires: %{name} = %{version}-%{release} - -%description -n libdeclarative-messaging -Qt Mobility delivers a set of new APIs for mobile device functionality. - -This package contains the Messaging QML plugin for QtDeclarative. - - -%package -n libdeclarative-multimedia -Summary: Qt Mobility Multimedia QML plugin -Group: System/Libraries -Requires: %{name} = %{version}-%{release} - -%description -n libdeclarative-multimedia -Qt Mobility delivers a set of new APIs for mobile device functionality. - -This package contains the Multimedia QML plugin for QtDeclarative. - - -%package -n libdeclarative-organizer -Summary: Qt Mobility Organizer QML plugin -Group: System/Libraries -Requires: %{name} = %{version}-%{release} - -%description -n libdeclarative-organizer -Qt Mobility delivers a set of new APIs for mobile device functionality. - -This package contains the Organizer QML plugin for QtDeclarative. - - -%package -n libdeclarative-publishsubscribe -Summary: Qt Mobility Publish and Subscribe QML plugin -Group: System/Libraries -Requires: %{name} = %{version}-%{release} - -%description -n libdeclarative-publishsubscribe -Qt Mobility delivers a set of new APIs for mobile device functionality. - -This package contains the Publish and Subscribe QML plugin for QtDeclarative. - - -%package -n libdeclarative-sensors -Summary: Qt Mobility Sensors Framework QML plugin -Group: System/Libraries -Requires: %{name} = %{version}-%{release} - -%description -n libdeclarative-sensors -Qt Mobility delivers a set of new APIs for mobile device functionality. - -This package contains the Sensors QML plugin for QtDeclarative. - - -%package -n libdeclarative-serviceframework -Summary: Qt Mobility Service Framework QML plugin -Group: System/Libraries -Requires: %{name} = %{version}-%{release} - -%description -n libdeclarative-serviceframework -Qt Mobility delivers a set of new APIs for mobile device functionality. - -This package contains the Service Framework QML plugin for QtDeclarative. - - -%package -n libdeclarative-systeminfo -Summary: Qt Mobility System Information QML plugin -Group: System/Libraries -Requires: %{name} = %{version}-%{release} - -%description -n libdeclarative-systeminfo -Qt Mobility delivers a set of new APIs for mobile device functionality. - -This package contains the System Information QML plugin for QtDeclarative. - - -%package -n libdeclarative-connectivity -Summary: Qt Mobility Connectivity QML plugin -Group: System/Libraries -Requires: %{name} = %{version}-%{release} - -%description -n libdeclarative-connectivity -Qt Mobility delivers a set of new APIs for mobile device functionality. - -This package contains the Connectivity QML plugin for QtDeclarative. - - -%package -n servicefw -Summary: Qt Mobility Service Framework tool -Group: Development/Tools -Requires: %{name} = %{version}-%{release} - -%description -n servicefw -Qt Mobility delivers a set of new APIs for mobile device functionality. - -This package contains the Service Framework tool (servicefw). It allows -to register services and make them available over the Service Framework. - - -%package examples -Summary: Qt Mobility examples -Group: System/X11 -Requires: %{name} = %{version}-%{release} - -%description examples -Qt Mobility delivers a set of new APIs for mobile device functionality. - -This package contains Qt Mobility examples. - - -%package l10n -Summary: APIs for mobile device functionality - localization files -Group: System/I18n -Requires: %{name} = %{version}-%{release} - -%description l10n -Qt Mobility delivers a set of new APIs for mobile device functionality. - -This package contains Qt Mobility translations. - - - -%prep -%setup -q -n %{name}-opensource-src-%{version} - -# >> setup -# << setup - -%build -# >> build pre -# QMF environment variables should be set -export QMF_INCLUDEDIR=%{_includedir}/qmfclient -export QMF_LIBDIR=%{_libdir} -./configure \ --prefix "%{_prefix}" \ --headerdir "%{_includedir}" \ --libdir "%{_libdir}" \ --bindir "%{_bindir}" \ --plugindir "%{_libdir}/qt4/plugins" \ --demosdir "%{_libdir}/qtmobility/demos" \ --examplesdir "%{_libdir}/qtmobility/examples" \ --languages "ar cs da de es fr he hu ja pl pt ru sk sl sv zh_CN zh_TW" \ --examples \ --demos \ --modules "location contacts multimedia publishsubscribe versit messaging systeminfo serviceframework sensors gallery organizer feedback connectivity" \ --meego -make %{?_smp_mflags} -# << build pre - - - -# >> build post -# << build post -%install -rm -rf %{buildroot} -# >> install pre -# << install pre - -# >> install post -%qmake_install -# Fix wrong path in pkgconfig files -find %{buildroot}%{_libdir}/pkgconfig -type f -name '*.pc' \ --exec perl -pi -e "s, -L%{_builddir}/%{name}-opensource-src-\Q%{version}\E/?\S+,,g" {} \; -# Fix executable permissions -find %{buildroot}%{_libdir}/qtmobility -type f -perm /u+x,g+x,o+x \( -false \ --o -name \*.qml \ --o -name \*.sci \ --o -name qmldir \ --o -name \*.txt \ -\) -exec chmod -x \{\} + -# Fix duplicate files -%fdupes %{buildroot}%{_includedir} -%fdupes %{buildroot}%{_libdir}/qtmobility -# << install post -%fdupes %{buildroot}/%{_datadir}/qtmobility/translations - - - - - - - - - - -%post -n libqtconnectivity1 -p /sbin/ldconfig - -%postun -n libqtconnectivity1 -p /sbin/ldconfig - - -%post -n libqtcontacts1 -p /sbin/ldconfig - -%postun -n libqtcontacts1 -p /sbin/ldconfig - - -%post -n libqtfeedback1 -p /sbin/ldconfig - -%postun -n libqtfeedback1 -p /sbin/ldconfig - - -%post -n libqtgallery1 -p /sbin/ldconfig - -%postun -n libqtgallery1 -p /sbin/ldconfig - - -%post -n libqtlocation1 -p /sbin/ldconfig - -%postun -n libqtlocation1 -p /sbin/ldconfig - - -%post -n libqtmessaging1 -p /sbin/ldconfig - -%postun -n libqtmessaging1 -p /sbin/ldconfig - - -%post -n libqtmultimediakit1 -p /sbin/ldconfig - -%postun -n libqtmultimediakit1 -p /sbin/ldconfig - - -%post -n libqtorganizer1 -p /sbin/ldconfig - -%postun -n libqtorganizer1 -p /sbin/ldconfig - - -%post -n libqtpublishsubscribe1 -p /sbin/ldconfig - -%postun -n libqtpublishsubscribe1 -p /sbin/ldconfig - - -%post -n libqtsensors1 -p /sbin/ldconfig - -%postun -n libqtsensors1 -p /sbin/ldconfig - - -%post -n libqtserviceframework1 -p /sbin/ldconfig - -%postun -n libqtserviceframework1 -p /sbin/ldconfig - - -%post -n libqtsysteminfo1 -p /sbin/ldconfig - -%postun -n libqtsysteminfo1 -p /sbin/ldconfig - - -%post -n libqtversit1 -p /sbin/ldconfig - -%postun -n libqtversit1 -p /sbin/ldconfig - - -%post -n libqtversitorganizer1 -p /sbin/ldconfig - -%postun -n libqtversitorganizer1 -p /sbin/ldconfig - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -%files -%defattr(-,root,root,-) -# >> files -# << files - - -%files devel -%defattr(-,root,root,-) -# >> files devel -%{_bindir}/icheck -%{_bindir}/ndefhandlergen -%{_bindir}/qcrmlgen -%{_bindir}/servicedbgen -%{_bindir}/servicexmlgen -%{_bindir}/vsexplorer -%{_includedir}/QtConnectivity/*.h -%{_includedir}/QtConnectivity/QBluetoothAddress -%{_includedir}/QtConnectivity/QBluetoothDeviceDiscoveryAgent -%{_includedir}/QtConnectivity/QBluetoothDeviceInfo -%{_includedir}/QtConnectivity/QBluetoothHostInfo -%{_includedir}/QtConnectivity/QBluetoothLocalDevice -%{_includedir}/QtConnectivity/QBluetoothServiceDiscoveryAgent -%{_includedir}/QtConnectivity/QBluetoothServiceInfo -%{_includedir}/QtConnectivity/QBluetoothSocket -%{_includedir}/QtConnectivity/QBluetoothTransferManager -%{_includedir}/QtConnectivity/QBluetoothTransferReply -%{_includedir}/QtConnectivity/QBluetoothTransferRequest -%{_includedir}/QtConnectivity/QBluetoothUuid -%{_includedir}/QtConnectivity/QDeclarativeNdefRecord -%{_includedir}/QtConnectivity/QL2capServer -%{_includedir}/QtConnectivity/QL2capSocket -%{_includedir}/QtConnectivity/QLlcpServer -%{_includedir}/QtConnectivity/QLlcpSocket -%{_includedir}/QtConnectivity/QNdefFilter -%{_includedir}/QtConnectivity/QNdefMessage -%{_includedir}/QtConnectivity/QNdefNfcTextRecord -%{_includedir}/QtConnectivity/QNdefNfcUriRecord -%{_includedir}/QtConnectivity/QNdefRecord -%{_includedir}/QtConnectivity/QNearFieldManager -%{_includedir}/QtConnectivity/QNearFieldTagType1 -%{_includedir}/QtConnectivity/QNearFieldTagType2 -%{_includedir}/QtConnectivity/QNearFieldTagType3 -%{_includedir}/QtConnectivity/QNearFieldTagType4 -%{_includedir}/QtConnectivity/QNearFieldTarget -%{_includedir}/QtConnectivity/QRfcommServer -%{_includedir}/QtConnectivity/QRfcommSocket -%{_includedir}/QtContacts/*.h -%{_includedir}/QtContacts/QContact -%{_includedir}/QtContacts/QContactAbstractRequest -%{_includedir}/QtContacts/QContactAction -%{_includedir}/QtContacts/QContactActionDescriptor -%{_includedir}/QtContacts/QContactActionFactory -%{_includedir}/QtContacts/QContactActionFilter -%{_includedir}/QtContacts/QContactActionTarget -%{_includedir}/QtContacts/QContactAddress -%{_includedir}/QtContacts/QContactAnniversary -%{_includedir}/QtContacts/QContactAvatar -%{_includedir}/QtContacts/QContactBirthday -%{_includedir}/QtContacts/QContactChangeLogFilter -%{_includedir}/QtContacts/QContactChangeSet -%{_includedir}/QtContacts/QContactDetail -%{_includedir}/QtContacts/QContactDetailDefinition -%{_includedir}/QtContacts/QContactDetailDefinitionFetchRequest -%{_includedir}/QtContacts/QContactDetailDefinitionRemoveRequest -%{_includedir}/QtContacts/QContactDetailDefinitionSaveRequest -%{_includedir}/QtContacts/QContactDetailFieldDefinition -%{_includedir}/QtContacts/QContactDetailFilter -%{_includedir}/QtContacts/QContactDetailRangeFilter -%{_includedir}/QtContacts/QContactDisplayLabel -%{_includedir}/QtContacts/QContactEmailAddress -%{_includedir}/QtContacts/QContactFamily -%{_includedir}/QtContacts/QContactFavorite -%{_includedir}/QtContacts/QContactFetchByIdRequest -%{_includedir}/QtContacts/QContactFetchHint -%{_includedir}/QtContacts/QContactFetchRequest -%{_includedir}/QtContacts/QContactFilter -%{_includedir}/QtContacts/QContactGender -%{_includedir}/QtContacts/QContactGeoLocation -%{_includedir}/QtContacts/QContactGlobalPresence -%{_includedir}/QtContacts/QContactGuid -%{_includedir}/QtContacts/QContactHobby -%{_includedir}/QtContacts/QContactId -%{_includedir}/QtContacts/QContactIntersectionFilter -%{_includedir}/QtContacts/QContactInvalidFilter -%{_includedir}/QtContacts/QContactLocalIdFetchRequest -%{_includedir}/QtContacts/QContactLocalIdFilter -%{_includedir}/QtContacts/QContactManager -%{_includedir}/QtContacts/QContactManagerEngine -%{_includedir}/QtContacts/QContactManagerEngineFactory -%{_includedir}/QtContacts/QContactManagerEngineV2 -%{_includedir}/QtContacts/QContactName -%{_includedir}/QtContacts/QContactNickname -%{_includedir}/QtContacts/QContactNote -%{_includedir}/QtContacts/QContactObserver -%{_includedir}/QtContacts/QContactOnlineAccount -%{_includedir}/QtContacts/QContactOrganization -%{_includedir}/QtContacts/QContactPhoneNumber -%{_includedir}/QtContacts/QContactPresence -%{_includedir}/QtContacts/QContactRelationship -%{_includedir}/QtContacts/QContactRelationshipFetchRequest -%{_includedir}/QtContacts/QContactRelationshipFilter -%{_includedir}/QtContacts/QContactRelationshipRemoveRequest -%{_includedir}/QtContacts/QContactRelationshipSaveRequest -%{_includedir}/QtContacts/QContactRemoveRequest -%{_includedir}/QtContacts/QContactRingtone -%{_includedir}/QtContacts/QContactSaveRequest -%{_includedir}/QtContacts/QContactSortOrder -%{_includedir}/QtContacts/QContactSyncTarget -%{_includedir}/QtContacts/QContactTag -%{_includedir}/QtContacts/QContactThumbnail -%{_includedir}/QtContacts/QContactTimestamp -%{_includedir}/QtContacts/QContactType -%{_includedir}/QtContacts/QContactUnionFilter -%{_includedir}/QtContacts/QContactUrl -%{_includedir}/QtFeedback/*.h -%{_includedir}/QtFeedback/QFeedbackActuator -%{_includedir}/QtFeedback/QFeedbackEffect -%{_includedir}/QtFeedback/QFeedbackFileEffect -%{_includedir}/QtFeedback/QFeedbackFileInterface -%{_includedir}/QtFeedback/QFeedbackHapticsEffect -%{_includedir}/QtFeedback/QFeedbackHapticsInterface -%{_includedir}/QtFeedback/QFeedbackInterface -%{_includedir}/QtFeedback/QFeedbackThemeInterface -%{_includedir}/QtGallery/*.h -%{_includedir}/QtGallery/QAbstractGallery -%{_includedir}/QtGallery/QDocumentGallery -%{_includedir}/QtGallery/QGalleryAbstractRequest -%{_includedir}/QtGallery/QGalleryAbstractResponse -%{_includedir}/QtGallery/QGalleryFilter -%{_includedir}/QtGallery/QGalleryIntersectionFilter -%{_includedir}/QtGallery/QGalleryItemRequest -%{_includedir}/QtGallery/QGalleryMetaDataFilter -%{_includedir}/QtGallery/QGalleryQueryModel -%{_includedir}/QtGallery/QGalleryQueryRequest -%{_includedir}/QtGallery/QGalleryResource -%{_includedir}/QtGallery/QGalleryResultSet -%{_includedir}/QtGallery/QGalleryTypeRequest -%{_includedir}/QtGallery/QGalleryUnionFilter -%{_includedir}/QtLocation/*.h -%{_includedir}/QtLocation/QGeoAddress -%{_includedir}/QtLocation/QGeoAreaMonitor -%{_includedir}/QtLocation/QGeoBoundingArea -%{_includedir}/QtLocation/QGeoBoundingBox -%{_includedir}/QtLocation/QGeoBoundingCircle -%{_includedir}/QtLocation/QGeoCoordinate -%{_includedir}/QtLocation/QGeoManeuver -%{_includedir}/QtLocation/QGeoMapCircleObject -%{_includedir}/QtLocation/QGeoMapCustomObject -%{_includedir}/QtLocation/QGeoMapData -%{_includedir}/QtLocation/QGeoMapGroupObject -%{_includedir}/QtLocation/QGeoMapObject -%{_includedir}/QtLocation/QGeoMapObjectInfo -%{_includedir}/QtLocation/QGeoMapOverlay -%{_includedir}/QtLocation/QGeoMapPixmapObject -%{_includedir}/QtLocation/QGeoMapPolygonObject -%{_includedir}/QtLocation/QGeoMapPolylineObject -%{_includedir}/QtLocation/QGeoMapRectangleObject -%{_includedir}/QtLocation/QGeoMapRouteObject -%{_includedir}/QtLocation/QGeoMapTextObject -%{_includedir}/QtLocation/QGeoMappingManager -%{_includedir}/QtLocation/QGeoMappingManagerEngine -%{_includedir}/QtLocation/QGeoPlace -%{_includedir}/QtLocation/QGeoPositionInfo -%{_includedir}/QtLocation/QGeoPositionInfoSource -%{_includedir}/QtLocation/QGeoPositionInfoSourceFactory -%{_includedir}/QtLocation/QGeoRoute -%{_includedir}/QtLocation/QGeoRouteReply -%{_includedir}/QtLocation/QGeoRouteRequest -%{_includedir}/QtLocation/QGeoRouteSegment -%{_includedir}/QtLocation/QGeoRoutingManager -%{_includedir}/QtLocation/QGeoRoutingManagerEngine -%{_includedir}/QtLocation/QGeoSatelliteInfo -%{_includedir}/QtLocation/QGeoSatelliteInfoSource -%{_includedir}/QtLocation/QGeoSearchManager -%{_includedir}/QtLocation/QGeoSearchManagerEngine -%{_includedir}/QtLocation/QGeoSearchReply -%{_includedir}/QtLocation/QGeoServiceProvider -%{_includedir}/QtLocation/QGeoServiceProviderFactory -%{_includedir}/QtLocation/QGeoTiledMapData -%{_includedir}/QtLocation/QGeoTiledMapReply -%{_includedir}/QtLocation/QGeoTiledMapRequest -%{_includedir}/QtLocation/QGeoTiledMappingManagerEngine -%{_includedir}/QtLocation/QGraphicsGeoMap -%{_includedir}/QtLocation/QLandmark -%{_includedir}/QtLocation/QLandmarkAbstractRequest -%{_includedir}/QtLocation/QLandmarkAttributeFilter -%{_includedir}/QtLocation/QLandmarkBoxFilter -%{_includedir}/QtLocation/QLandmarkCategory -%{_includedir}/QtLocation/QLandmarkCategoryFetchByIdRequest -%{_includedir}/QtLocation/QLandmarkCategoryFetchRequest -%{_includedir}/QtLocation/QLandmarkCategoryFilter -%{_includedir}/QtLocation/QLandmarkCategoryId -%{_includedir}/QtLocation/QLandmarkCategoryIdFetchRequest -%{_includedir}/QtLocation/QLandmarkCategoryRemoveRequest -%{_includedir}/QtLocation/QLandmarkCategorySaveRequest -%{_includedir}/QtLocation/QLandmarkExportRequest -%{_includedir}/QtLocation/QLandmarkFetchByIdRequest -%{_includedir}/QtLocation/QLandmarkFetchRequest -%{_includedir}/QtLocation/QLandmarkFilter -%{_includedir}/QtLocation/QLandmarkId -%{_includedir}/QtLocation/QLandmarkIdFetchRequest -%{_includedir}/QtLocation/QLandmarkIdFilter -%{_includedir}/QtLocation/QLandmarkImportRequest -%{_includedir}/QtLocation/QLandmarkIntersectionFilter -%{_includedir}/QtLocation/QLandmarkManager -%{_includedir}/QtLocation/QLandmarkManagerEngine -%{_includedir}/QtLocation/QLandmarkManagerEngineFactory -%{_includedir}/QtLocation/QLandmarkNameFilter -%{_includedir}/QtLocation/QLandmarkNameSort -%{_includedir}/QtLocation/QLandmarkProximityFilter -%{_includedir}/QtLocation/QLandmarkRemoveRequest -%{_includedir}/QtLocation/QLandmarkSaveRequest -%{_includedir}/QtLocation/QLandmarkSortOrder -%{_includedir}/QtLocation/QLandmarkUnionFilter -%{_includedir}/QtLocation/QNmeaPositionInfoSource -%{_includedir}/QtMessaging/*.h -%{_includedir}/QtMessaging/QMessage -%{_includedir}/QtMessaging/QMessageAccount -%{_includedir}/QtMessaging/QMessageAccountFilter -%{_includedir}/QtMessaging/QMessageAccountId -%{_includedir}/QtMessaging/QMessageAccountSortOrder -%{_includedir}/QtMessaging/QMessageAddress -%{_includedir}/QtMessaging/QMessageContentContainer -%{_includedir}/QtMessaging/QMessageContentContainerId -%{_includedir}/QtMessaging/QMessageDataComparator -%{_includedir}/QtMessaging/QMessageFilter -%{_includedir}/QtMessaging/QMessageFolder -%{_includedir}/QtMessaging/QMessageFolderFilter -%{_includedir}/QtMessaging/QMessageFolderId -%{_includedir}/QtMessaging/QMessageFolderSortOrder -%{_includedir}/QtMessaging/QMessageId -%{_includedir}/QtMessaging/QMessageManager -%{_includedir}/QtMessaging/QMessageService -%{_includedir}/QtMessaging/QMessageSortOrder -%{_includedir}/QtMobility/*.h -%{_includedir}/QtMobility/QLatin1Constant -%{_includedir}/QtMultimediaKit/*.h -%{_includedir}/QtMultimediaKit/QAbstractAudioDeviceInfo -%{_includedir}/QtMultimediaKit/QAbstractAudioInput -%{_includedir}/QtMultimediaKit/QAbstractAudioOutput -%{_includedir}/QtMultimediaKit/QAbstractVideoBuffer -%{_includedir}/QtMultimediaKit/QAbstractVideoSurface -%{_includedir}/QtMultimediaKit/QAudio -%{_includedir}/QtMultimediaKit/QAudioCaptureSource -%{_includedir}/QtMultimediaKit/QAudioDeviceInfo -%{_includedir}/QtMultimediaKit/QAudioEncoderControl -%{_includedir}/QtMultimediaKit/QAudioEncoderSettings -%{_includedir}/QtMultimediaKit/QAudioEndpointSelector -%{_includedir}/QtMultimediaKit/QAudioFormat -%{_includedir}/QtMultimediaKit/QAudioInput -%{_includedir}/QtMultimediaKit/QAudioOutput -%{_includedir}/QtMultimediaKit/QAudioSystemPlugin -%{_includedir}/QtMultimediaKit/QCamera -%{_includedir}/QtMultimediaKit/QCameraControl -%{_includedir}/QtMultimediaKit/QCameraExposure -%{_includedir}/QtMultimediaKit/QCameraExposureControl -%{_includedir}/QtMultimediaKit/QCameraFlashControl -%{_includedir}/QtMultimediaKit/QCameraFocus -%{_includedir}/QtMultimediaKit/QCameraFocusControl -%{_includedir}/QtMultimediaKit/QCameraFocusZone -%{_includedir}/QtMultimediaKit/QCameraImageCapture -%{_includedir}/QtMultimediaKit/QCameraImageCaptureControl -%{_includedir}/QtMultimediaKit/QCameraImageProcessing -%{_includedir}/QtMultimediaKit/QCameraImageProcessingControl -%{_includedir}/QtMultimediaKit/QCameraCaptureBufferFormatControl -%{_includedir}/QtMultimediaKit/QCameraCaptureDestinationControl -%{_includedir}/QtMultimediaKit/QCameraLocksControl -%{_includedir}/QtMultimediaKit/QCameraViewfinder -%{_includedir}/QtMultimediaKit/QGraphicsVideoItem -%{_includedir}/QtMultimediaKit/QImageEncoderControl -%{_includedir}/QtMultimediaKit/QImageEncoderSettings -%{_includedir}/QtMultimediaKit/QLocalMediaPlaylistProvider -%{_includedir}/QtMultimediaKit/QMediaBindableInterface -%{_includedir}/QtMultimediaKit/QMediaContainerControl -%{_includedir}/QtMultimediaKit/QMediaContent -%{_includedir}/QtMultimediaKit/QMediaControl -%{_includedir}/QtMultimediaKit/QMediaImageViewer -%{_includedir}/QtMultimediaKit/QMediaObject -%{_includedir}/QtMultimediaKit/QMediaPlayer -%{_includedir}/QtMultimediaKit/QMediaPlayerControl -%{_includedir}/QtMultimediaKit/QMediaPlaylist -%{_includedir}/QtMultimediaKit/QMediaPlaylistControl -%{_includedir}/QtMultimediaKit/QMediaPlaylistIOPlugin -%{_includedir}/QtMultimediaKit/QMediaPlaylistNavigator -%{_includedir}/QtMultimediaKit/QMediaPlaylistProvider -%{_includedir}/QtMultimediaKit/QMediaPlaylistReader -%{_includedir}/QtMultimediaKit/QMediaPlaylistSourceControl -%{_includedir}/QtMultimediaKit/QMediaPlaylistWriter -%{_includedir}/QtMultimediaKit/QMediaRecorder -%{_includedir}/QtMultimediaKit/QMediaRecorderControl -%{_includedir}/QtMultimediaKit/QMediaResource -%{_includedir}/QtMultimediaKit/QMediaService -%{_includedir}/QtMultimediaKit/QMediaServiceProvider -%{_includedir}/QtMultimediaKit/QMediaServiceProviderHint -%{_includedir}/QtMultimediaKit/QMediaServiceProviderPlugin -%{_includedir}/QtMultimediaKit/QMediaStreamsControl -%{_includedir}/QtMultimediaKit/QMediaTimeInterval -%{_includedir}/QtMultimediaKit/QMediaTimeRange -%{_includedir}/QtMultimediaKit/QMetaDataReaderControl -%{_includedir}/QtMultimediaKit/QMetaDataWriterControl -%{_includedir}/QtMultimediaKit/QRadioTuner -%{_includedir}/QtMultimediaKit/QRadioTunerControl -%{_includedir}/QtMultimediaKit/QVideoDeviceControl -%{_includedir}/QtMultimediaKit/QVideoEncoderControl -%{_includedir}/QtMultimediaKit/QVideoEncoderSettings -%{_includedir}/QtMultimediaKit/QVideoFrame -%{_includedir}/QtMultimediaKit/QVideoRendererControl -%{_includedir}/QtMultimediaKit/QVideoSurfaceFormat -%{_includedir}/QtMultimediaKit/QVideoWidget -%{_includedir}/QtMultimediaKit/QVideoWidgetControl -%{_includedir}/QtMultimediaKit/QVideoWindowControl -%{_includedir}/QtMultimediaKit/QMediaNetworkAccessControl -%{_includedir}/QtOrganizer/*.h -%{_includedir}/QtOrganizer/QOrganizerAbstractRequest -%{_includedir}/QtOrganizer/QOrganizerCollection -%{_includedir}/QtOrganizer/QOrganizerCollectionChangeSet -%{_includedir}/QtOrganizer/QOrganizerCollectionEngineId -%{_includedir}/QtOrganizer/QOrganizerCollectionFetchRequest -%{_includedir}/QtOrganizer/QOrganizerCollectionId -%{_includedir}/QtOrganizer/QOrganizerCollectionRemoveRequest -%{_includedir}/QtOrganizer/QOrganizerCollectionSaveRequest -%{_includedir}/QtOrganizer/QOrganizerEvent -%{_includedir}/QtOrganizer/QOrganizerEventOccurrence -%{_includedir}/QtOrganizer/QOrganizerEventTime -%{_includedir}/QtOrganizer/QOrganizerItem -%{_includedir}/QtOrganizer/QOrganizerItemAudibleReminder -%{_includedir}/QtOrganizer/QOrganizerItemChangeLogFilter -%{_includedir}/QtOrganizer/QOrganizerItemChangeSet -%{_includedir}/QtOrganizer/QOrganizerItemCollectionFilter -%{_includedir}/QtOrganizer/QOrganizerItemComment -%{_includedir}/QtOrganizer/QOrganizerItemDescription -%{_includedir}/QtOrganizer/QOrganizerItemDetail -%{_includedir}/QtOrganizer/QOrganizerItemDetailDefinition -%{_includedir}/QtOrganizer/QOrganizerItemDetailDefinitionFetchRequest -%{_includedir}/QtOrganizer/QOrganizerItemDetailDefinitionRemoveRequest -%{_includedir}/QtOrganizer/QOrganizerItemDetailDefinitionSaveRequest -%{_includedir}/QtOrganizer/QOrganizerItemDetailFieldDefinition -%{_includedir}/QtOrganizer/QOrganizerItemDetailFilter -%{_includedir}/QtOrganizer/QOrganizerItemDetailRangeFilter -%{_includedir}/QtOrganizer/QOrganizerItemDisplayLabel -%{_includedir}/QtOrganizer/QOrganizerItemEmailReminder -%{_includedir}/QtOrganizer/QOrganizerItemEngineId -%{_includedir}/QtOrganizer/QOrganizerItemFetchByIdRequest -%{_includedir}/QtOrganizer/QOrganizerItemFetchForExportRequest -%{_includedir}/QtOrganizer/QOrganizerItemFetchHint -%{_includedir}/QtOrganizer/QOrganizerItemFetchRequest -%{_includedir}/QtOrganizer/QOrganizerItemFilter -%{_includedir}/QtOrganizer/QOrganizerItemGuid -%{_includedir}/QtOrganizer/QOrganizerItemId -%{_includedir}/QtOrganizer/QOrganizerItemIdFetchRequest -%{_includedir}/QtOrganizer/QOrganizerItemIdFilter -%{_includedir}/QtOrganizer/QOrganizerItemIntersectionFilter -%{_includedir}/QtOrganizer/QOrganizerItemInvalidFilter -%{_includedir}/QtOrganizer/QOrganizerItemLocation -%{_includedir}/QtOrganizer/QOrganizerItemObserver -%{_includedir}/QtOrganizer/QOrganizerItemOccurrenceFetchRequest -%{_includedir}/QtOrganizer/QOrganizerItemParent -%{_includedir}/QtOrganizer/QOrganizerItemPriority -%{_includedir}/QtOrganizer/QOrganizerItemRecurrence -%{_includedir}/QtOrganizer/QOrganizerItemReminder -%{_includedir}/QtOrganizer/QOrganizerItemRemoveRequest -%{_includedir}/QtOrganizer/QOrganizerItemSaveRequest -%{_includedir}/QtOrganizer/QOrganizerItemSortOrder -%{_includedir}/QtOrganizer/QOrganizerItemTag -%{_includedir}/QtOrganizer/QOrganizerItemTimestamp -%{_includedir}/QtOrganizer/QOrganizerItemType -%{_includedir}/QtOrganizer/QOrganizerItemUnionFilter -%{_includedir}/QtOrganizer/QOrganizerItemVisualReminder -%{_includedir}/QtOrganizer/QOrganizerJournal -%{_includedir}/QtOrganizer/QOrganizerJournalTime -%{_includedir}/QtOrganizer/QOrganizerManager -%{_includedir}/QtOrganizer/QOrganizerManagerEngine -%{_includedir}/QtOrganizer/QOrganizerManagerEngineFactory -%{_includedir}/QtOrganizer/QOrganizerManagerEngineV2 -%{_includedir}/QtOrganizer/QOrganizerNote -%{_includedir}/QtOrganizer/QOrganizerRecurrenceRule -%{_includedir}/QtOrganizer/QOrganizerTodo -%{_includedir}/QtOrganizer/QOrganizerTodoOccurrence -%{_includedir}/QtOrganizer/QOrganizerTodoProgress -%{_includedir}/QtOrganizer/QOrganizerTodoTime -%{_includedir}/QtPublishSubscribe/*.h -%{_includedir}/QtPublishSubscribe/QValueSpace -%{_includedir}/QtPublishSubscribe/QValueSpacePublisher -%{_includedir}/QtPublishSubscribe/QValueSpaceSubscriber -%{_includedir}/QtSensors/*.h -%{_includedir}/QtSensors/QAccelerometer -%{_includedir}/QtSensors/QAccelerometerFilter -%{_includedir}/QtSensors/QAccelerometerReading -%{_includedir}/QtSensors/QAmbientLightFilter -%{_includedir}/QtSensors/QAmbientLightReading -%{_includedir}/QtSensors/QAmbientLightSensor -%{_includedir}/QtSensors/QCompass -%{_includedir}/QtSensors/QCompassFilter -%{_includedir}/QtSensors/QCompassReading -%{_includedir}/QtSensors/QGyroscope -%{_includedir}/QtSensors/QGyroscopeFilter -%{_includedir}/QtSensors/QGyroscopeReading -%{_includedir}/QtSensors/QLightFilter -%{_includedir}/QtSensors/QLightReading -%{_includedir}/QtSensors/QLightSensor -%{_includedir}/QtSensors/QMagnetometer -%{_includedir}/QtSensors/QMagnetometerFilter -%{_includedir}/QtSensors/QMagnetometerReading -%{_includedir}/QtSensors/QOrientationFilter -%{_includedir}/QtSensors/QOrientationReading -%{_includedir}/QtSensors/QOrientationSensor -%{_includedir}/QtSensors/QProximityFilter -%{_includedir}/QtSensors/QProximityReading -%{_includedir}/QtSensors/QProximitySensor -%{_includedir}/QtSensors/QRotationFilter -%{_includedir}/QtSensors/QRotationReading -%{_includedir}/QtSensors/QRotationSensor -%{_includedir}/QtSensors/QSensor -%{_includedir}/QtSensors/QSensorBackend -%{_includedir}/QtSensors/QSensorBackendFactory -%{_includedir}/QtSensors/QSensorChangesInterface -%{_includedir}/QtSensors/QSensorFilter -%{_includedir}/QtSensors/QSensorManager -%{_includedir}/QtSensors/QSensorPluginInterface -%{_includedir}/QtSensors/QSensorReading -%{_includedir}/QtSensors/QTapFilter -%{_includedir}/QtSensors/QTapReading -%{_includedir}/QtSensors/QTapSensor -%{_includedir}/QtServiceFramework/*.h -%{_includedir}/QtServiceFramework/QAbstractSecuritySession -%{_includedir}/QtServiceFramework/QRemoteServiceRegister -%{_includedir}/QtServiceFramework/QService -%{_includedir}/QtServiceFramework/QServiceContext -%{_includedir}/QtServiceFramework/QServiceFilter -%{_includedir}/QtServiceFramework/QServiceInterfaceDescriptor -%{_includedir}/QtServiceFramework/QServiceManager -%{_includedir}/QtServiceFramework/QServicePluginInterface -%{_includedir}/QtSystemInfo/*.h -%{_includedir}/QtSystemInfo/QSystemAlignedTimer -%{_includedir}/QtSystemInfo/QSystemBatteryInfo -%{_includedir}/QtSystemInfo/QSystemDeviceInfo -%{_includedir}/QtSystemInfo/QSystemDisplayInfo -%{_includedir}/QtSystemInfo/QSystemInfo -%{_includedir}/QtSystemInfo/QSystemNetworkInfo -%{_includedir}/QtSystemInfo/QSystemScreenSaver -%{_includedir}/QtSystemInfo/QSystemStorageInfo -%{_includedir}/QtVersit/*.h -%{_includedir}/QtVersit/QVersitContactExporter -%{_includedir}/QtVersit/QVersitContactExporterDetailHandler -%{_includedir}/QtVersit/QVersitContactExporterDetailHandlerV2 -%{_includedir}/QtVersit/QVersitContactHandler -%{_includedir}/QtVersit/QVersitContactHandlerFactory -%{_includedir}/QtVersit/QVersitContactImporter -%{_includedir}/QtVersit/QVersitContactImporterPropertyHandler -%{_includedir}/QtVersit/QVersitContactImporterPropertyHandlerV2 -%{_includedir}/QtVersit/QVersitDefaultResourceHandler -%{_includedir}/QtVersit/QVersitDocument -%{_includedir}/QtVersit/QVersitProperty -%{_includedir}/QtVersit/QVersitReader -%{_includedir}/QtVersit/QVersitResourceHandler -%{_includedir}/QtVersit/QVersitWriter -%{_includedir}/QtVersitOrganizer/*.h -%{_includedir}/QtVersitOrganizer/QVersitOrganizerExporter -%{_includedir}/QtVersitOrganizer/QVersitOrganizerExporterDetailHandler -%{_includedir}/QtVersitOrganizer/QVersitOrganizerHandler -%{_includedir}/QtVersitOrganizer/QVersitOrganizerHandlerFactory -%{_includedir}/QtVersitOrganizer/QVersitOrganizerImporter -%{_includedir}/QtVersitOrganizer/QVersitOrganizerImporterPropertyHandler -%{_includedir}/QtVersitOrganizer/QVersitTimeZoneHandler -%{_libdir}/libQtConnectivity.prl -%{_libdir}/libQtConnectivity.so -%{_libdir}/libQtContacts.prl -%{_libdir}/libQtContacts.so -%{_libdir}/libQtFeedback.prl -%{_libdir}/libQtFeedback.so -%{_libdir}/libQtGallery.prl -%{_libdir}/libQtGallery.so -%{_libdir}/libQtLocation.prl -%{_libdir}/libQtLocation.so -%{_libdir}/libQtMessaging.prl -%{_libdir}/libQtMessaging.so -%{_libdir}/libQtMultimediaKit.prl -%{_libdir}/libQtMultimediaKit.so -%{_libdir}/libQtOrganizer.prl -%{_libdir}/libQtOrganizer.so -%{_libdir}/libQtPublishSubscribe.prl -%{_libdir}/libQtPublishSubscribe.so -%{_libdir}/libQtSensors.prl -%{_libdir}/libQtSensors.so -%{_libdir}/libQtServiceFramework.prl -%{_libdir}/libQtServiceFramework.so -%{_libdir}/libQtSystemInfo.prl -%{_libdir}/libQtSystemInfo.so -%{_libdir}/libQtVersit.prl -%{_libdir}/libQtVersit.so -%{_libdir}/libQtVersitOrganizer.prl -%{_libdir}/libQtVersitOrganizer.so -%{_libdir}/pkgconfig/QtConnectivity.pc -%{_libdir}/pkgconfig/QtContacts.pc -%{_libdir}/pkgconfig/QtFeedback.pc -%{_libdir}/pkgconfig/QtGallery.pc -%{_libdir}/pkgconfig/QtLocation.pc -%{_libdir}/pkgconfig/QtMessaging.pc -%{_libdir}/pkgconfig/QtMultimediaKit.pc -%{_libdir}/pkgconfig/QtOrganizer.pc -%{_libdir}/pkgconfig/QtPublishSubscribe.pc -%{_libdir}/pkgconfig/QtSensors.pc -%{_libdir}/pkgconfig/QtServiceFramework.pc -%{_libdir}/pkgconfig/QtSystemInfo.pc -%{_libdir}/pkgconfig/QtVersit.pc -%{_libdir}/pkgconfig/QtVersitOrganizer.pc -%{_datadir}/qt4/mkspecs/features/mobility.prf -%{_datadir}/qt4/mkspecs/features/mobilityconfig.prf -# << files devel - -%files -n libqtconnectivity1 -%defattr(-,root,root,-) -# >> files libqtconnectivity1 -%{_libdir}/libQtConnectivity.so.* -# << files libqtconnectivity1 - -%files -n libqtcontacts1 -%defattr(-,root,root,-) -# >> files libqtcontacts1 -%{_libdir}/libQtContacts.so.* -%{_libdir}/qt4/plugins/contacts/libqtcontacts_serviceactionmanager.so -# << files libqtcontacts1 - -%files -n libqtfeedback1 -%defattr(-,root,root,-) -# >> files libqtfeedback1 -%{_libdir}/libQtFeedback.so.* -%{_libdir}/qt4/plugins/feedback/libqtfeedback_meegotouch.so -%{_libdir}/qt4/plugins/feedback/libqtfeedback_mmk.so -# << files libqtfeedback1 - -%files -n libqtgallery1 -%defattr(-,root,root,-) -# >> files libqtgallery1 -%{_libdir}/libQtGallery.so.* -# << files libqtgallery1 - -%files -n libqtlocation1 -%defattr(-,root,root,-) -# >> files libqtlocation1 -%{_libdir}/libQtLocation.so.* -%{_libdir}/qt4/plugins/geoservices/libqtgeoservices_nokia.so -%{_libdir}/qt4/plugins/landmarks/libqtlandmarks_qsparql.so -# << files libqtlocation1 - -%files -n libqtmessaging1 -%defattr(-,root,root,-) -# >> files libqtmessaging1 -%{_libdir}/libQtMessaging.so.* -# << files libqtmessaging1 - -%files -n libqtmultimediakit1 -%defattr(-,root,root,-) -# >> files libqtmultimediakit1 -%{_libdir}/libQtMultimediaKit.so.* -%{_libdir}/qt4/plugins/mediaservice/libqgstengine.so -%{_libdir}/qt4/plugins/mediaservice/libqtmedia_v4lengine.so -%{_libdir}/qt4/plugins/playlistformats/libqtmultimediakit_m3u.so -%{_libdir}/qt4/plugins/audio/libqtmedia_pulse.so -# << files libqtmultimediakit1 - -%files -n libqtorganizer1 -%defattr(-,root,root,-) -# >> files libqtorganizer1 -%{_libdir}/libQtOrganizer.so.* -%{_libdir}/qt4/plugins/organizer/libqtorganizer_mkcal.so -# << files libqtorganizer1 - -%files -n libqtpublishsubscribe1 -%defattr(-,root,root,-) -# >> files libqtpublishsubscribe1 -%{_libdir}/libQtPublishSubscribe.so.* -# << files libqtpublishsubscribe1 - -%files -n libqtsensors1 -%defattr(-,root,root,-) -# >> files libqtsensors1 -%config %{_sysconfdir}/xdg/Nokia/Sensors.conf -%{_libdir}/libQtSensors.so.* -%{_libdir}/qt4/plugins/sensors/libqtsensors_generic.so -%{_libdir}/qt4/plugins/sensors/libqtsensors_meego.so -# << files libqtsensors1 - -%files -n libqtserviceframework1 -%defattr(-,root,root,-) -# >> files libqtserviceframework1 -%{_libdir}/libQtServiceFramework.so.* -# << files libqtserviceframework1 - -%files -n libqtsysteminfo1 -%defattr(-,root,root,-) -# >> files libqtsysteminfo1 -%{_libdir}/libQtSystemInfo.so.* -# << files libqtsysteminfo1 - -%files -n libqtversit1 -%defattr(-,root,root,-) -# >> files libqtversit1 -%{_libdir}/libQtVersit.so.* -%{_libdir}/qt4/plugins/versit/libqtversit_backuphandler.so -%{_libdir}/qt4/plugins/versit/libqtversit_vcardpreserver.so -# << files libqtversit1 - -%files -n libqtversitorganizer1 -%defattr(-,root,root,-) -# >> files libqtversitorganizer1 -%{_libdir}/libQtVersitOrganizer.so.* -# << files libqtversitorganizer1 - -%files -n libdeclarative-contacts -%defattr(-,root,root,-) -# >> files libdeclarative-contacts -%{_libdir}/qt4/imports/QtMobility/contacts/libdeclarative_contacts.so -%{_libdir}/qt4/imports/QtMobility/contacts/qmldir -# << files libdeclarative-contacts - -%files -n libdeclarative-feedback -%defattr(-,root,root,-) -# >> files libdeclarative-feedback -%{_libdir}/qt4/imports/QtMobility/feedback/libdeclarative_feedback.so -%{_libdir}/qt4/imports/QtMobility/feedback/qmldir -# << files libdeclarative-feedback - -%files -n libdeclarative-gallery -%defattr(-,root,root,-) -# >> files libdeclarative-gallery -%{_libdir}/qt4/imports/QtMobility/gallery/libdeclarative_gallery.so -%{_libdir}/qt4/imports/QtMobility/gallery/qmldir -# << files libdeclarative-gallery - -%files -n libdeclarative-location -%defattr(-,root,root,-) -# >> files libdeclarative-location -%{_libdir}/qt4/imports/QtMobility/location/libdeclarative_location.so -%{_libdir}/qt4/imports/QtMobility/location/qmldir -# << files libdeclarative-location - -%files -n libdeclarative-messaging -%defattr(-,root,root,-) -# >> files libdeclarative-messaging -%{_libdir}/qt4/imports/QtMobility/messaging/libdeclarative_messaging.so -%{_libdir}/qt4/imports/QtMobility/messaging/qmldir -# << files libdeclarative-messaging - -%files -n libdeclarative-multimedia -%defattr(-,root,root,-) -# >> files libdeclarative-multimedia -%{_libdir}/qt4/imports/QtMultimediaKit/libdeclarative_multimedia.so -%{_libdir}/qt4/imports/QtMultimediaKit/qmldir -# << files libdeclarative-multimedia - -%files -n libdeclarative-organizer -%defattr(-,root,root,-) -# >> files libdeclarative-organizer -%{_libdir}/qt4/imports/QtMobility/organizer/libdeclarative_organizer.so -%{_libdir}/qt4/imports/QtMobility/organizer/qmldir -# << files libdeclarative-organizer - -%files -n libdeclarative-publishsubscribe -%defattr(-,root,root,-) -# >> files libdeclarative-publishsubscribe -%{_libdir}/qt4/imports/QtMobility/publishsubscribe/libdeclarative_publishsubscribe.so -%{_libdir}/qt4/imports/QtMobility/publishsubscribe/qmldir -# << files libdeclarative-publishsubscribe - -%files -n libdeclarative-sensors -%defattr(-,root,root,-) -# >> files libdeclarative-sensors -%{_libdir}/qt4/imports/QtMobility/sensors/libdeclarative_sensors.so -%{_libdir}/qt4/imports/QtMobility/sensors/qmldir -# << files libdeclarative-sensors - -%files -n libdeclarative-serviceframework -%defattr(-,root,root,-) -# >> files libdeclarative-serviceframework -%{_libdir}/qt4/imports/QtMobility/serviceframework/libdeclarative_serviceframework.so -%{_libdir}/qt4/imports/QtMobility/serviceframework/qmldir -# << files libdeclarative-serviceframework - -%files -n libdeclarative-systeminfo -%defattr(-,root,root,-) -# >> files libdeclarative-systeminfo -%{_libdir}/qt4/imports/QtMobility/systeminfo/libdeclarative_systeminfo.so -%{_libdir}/qt4/imports/QtMobility/systeminfo/qmldir -# << files libdeclarative-systeminfo - -%files -n libdeclarative-connectivity -%defattr(-,root,root,-) -# >> files libdeclarative-connectivity -%{_libdir}/qt4/imports/QtMobility/connectivity/libdeclarative_connectivity.so -%{_libdir}/qt4/imports/QtMobility/connectivity/qmldir -# << files libdeclarative-connectivity - -%files -n servicefw -%defattr(-,root,root,-) -# >> files servicefw -%{_bindir}/servicefw -# << files servicefw - -%files examples -%defattr(-,root,root,-) -# >> files examples -%{_libdir}/qt4/plugins/sensors/libqtsensors_grueplugin.so -%{_libdir}/qt4/plugins/serviceframework/libserviceframework_bluetoothtransferplugin.so -%{_libdir}/qt4/plugins/serviceframework/libserviceframework_filemanagerplugin.so -%{_libdir}/qt4/plugins/serviceframework/libserviceframework_landlinedialerservice.so -%{_libdir}/qt4/plugins/serviceframework/libserviceframework_notesmanagerplugin.so -%{_libdir}/qt4/plugins/serviceframework/libserviceframework_voipdialerservice.so -%{_libdir}/qtmobility/demos/ -%{_libdir}/qtmobility/examples/ -# << files examples - -%files l10n -%defattr(-,root,root,-) -# >> files l10n -%{_datadir}/qtmobility/translations/qtmobility_ar.qm -%{_datadir}/qtmobility/translations/qtmobility_cs.qm -%{_datadir}/qtmobility/translations/qtmobility_da.qm -%{_datadir}/qtmobility/translations/qtmobility_de.qm -%{_datadir}/qtmobility/translations/qtmobility_es.qm -%{_datadir}/qtmobility/translations/qtmobility_fr.qm -%{_datadir}/qtmobility/translations/qtmobility_he.qm -%{_datadir}/qtmobility/translations/qtmobility_hu.qm -%{_datadir}/qtmobility/translations/qtmobility_ja.qm -%{_datadir}/qtmobility/translations/qtmobility_pl.qm -%{_datadir}/qtmobility/translations/qtmobility_pt.qm -%{_datadir}/qtmobility/translations/qtmobility_ru.qm -%{_datadir}/qtmobility/translations/qtmobility_sk.qm -%{_datadir}/qtmobility/translations/qtmobility_sl.qm -%{_datadir}/qtmobility/translations/qtmobility_sv.qm -#%{_datadir}/qtmobility/translations/qtmobility_uk.qm -%{_datadir}/qtmobility/translations/qtmobility_zh_CN.qm -%{_datadir}/qtmobility/translations/qtmobility_zh_TW.qm -# << files l10n - diff --git a/src/meegoinstalls/qt-mobility.yaml b/src/meegoinstalls/qt-mobility.yaml deleted file mode 100644 index 99c84c16c..000000000 --- a/src/meegoinstalls/qt-mobility.yaml +++ /dev/null @@ -1,353 +0,0 @@ -Name: qt-mobility -Summary: APIs for mobile device functionality -Version: 1.1.0+git2438 -Release: 1 -Group: System/Libraries -License: LGPLv2.1 with exception or GPLv3 -URL: http://qt.gitorious.org/qt-mobility -Sources: - - http://get.qt.nokia.com/qt/add-ons/%{name}-opensource-src-%{version}.tar.gz -SourcePrefix: "%{name}-opensource-src-%{version}" -Patches: -Description: | - Qt Mobility delivers a set of new APIs for mobile device functionality. These - APIs allow the developer to use these features with ease from one framework and - apply them to phones, netbooks and non-mobile personal computers. -Requires: - - libqtconnectivity1 = %{version} - - libqtcontacts1 = %{version} - - libqtfeedback1 = %{version} - - libqtgallery1 = %{version} - - libqtlocation1 = %{version} - - libqtmessaging1 = %{version} - - libqtmultimediakit1 = %{version} - - libqtorganizer1 = %{version} - - libqtpublishsubscribe1 = %{version} - - libqtsensors1 = %{version} - - libqtserviceframework1 = %{version} - - libqtsysteminfo1 = %{version} - - libqtversit1 = %{version} - - libqtversitorganizer1 = %{version} -PkgConfigBR: - - QtGui - - QtOpenGL - - alsa - - blkid - - bluez - - connman - - contextsubscriber-1.0 - - gconf-2.0 - - geoclue - - gstreamer-plugins-bad-free-0.10 - - gstreamer-plugins-base-0.10 - - gypsy - - libiphb - - libpulse - - libmkcal - - meegotouch - - qttracker - - qmfclient - - sensord - - udev - - x11 - - xext - - xrandr - - xrender - - xv - - QtSparql - - QtSparqlTrackerExtensions -PkgBR: - - qt-devel-tools -Configure: none -Builder: none -RunFdupes: "%{_datadir}/qtmobility/translations" -SubPackages: - - Name: devel - Summary: APIs for mobile device functionality - development files - Group: Development/Libraries - Description: | - Qt Mobility delivers a set of new APIs for mobile device functionality. - - This package contains the development files needed to build Qt applications - using Qt Mobility libraries. - Requires: - - servicefw - - - Name: libqtconnectivity1 - AsWholeName: yes - Summary: Qt Mobility Connectivity module - Group: System/Libraries - Description: | - Qt Mobility delivers a set of new APIs for mobile device functionality. - - This package contains the Connectivity API. It provides APIs for working with - local devices. - - - Name: libqtcontacts1 - AsWholeName: yes - Summary: Qt Mobility Contacts module - Group: System/Libraries - Description: | - Qt Mobility delivers a set of new APIs for mobile device functionality. - - This package contains an API enabling clients to request contact data from - local or remote backends. - - - Name: libqtfeedback1 - AsWholeName: yes - Summary: Qt Mobility Feedback module - Group: System/Libraries - Description: | - Qt Mobility delivers a set of new APIs for mobile device functionality. - - This package contains the Feedback API. It enables a client to control - the vibration of the device or the piezo feedback from the screen. - - - Name: libqtgallery1 - AsWholeName: yes - Summary: Qt Mobility Document Gallery module - Group: System/Libraries - Description: | - Qt Mobility delivers a set of new APIs for mobile device functionality. - - This package contains an API for accessing collections of documents and media - and their meta-data. - - - Name: libqtlocation1 - AsWholeName: yes - Summary: Qt Mobility Location module - Group: System/Libraries - Description: | - Qt Mobility delivers a set of new APIs for mobile device functionality. - - This package contains the Location API. It provides a library for distributing - and receiving location data using arbitrary data sources. - - - Name: libqtmessaging1 - AsWholeName: yes - Summary: Qt Mobility Messaging module - Group: System/Libraries - Description: | - Qt Mobility delivers a set of new APIs for mobile device functionality. - - This package contains the Messaging API. It is a common interface for handling - SMS, MMS, MIME Email and TNEF Email messages. - - - Name: libqtmultimediakit1 - AsWholeName: yes - Summary: Qt Mobility MultimediaKit module - Group: System/Libraries - Description: | - Qt Mobility delivers a set of new APIs for mobile device functionality. - - This package contains a set of APIs to play and record media, and manage a - collection of media content. - - - Name: libqtorganizer1 - AsWholeName: yes - Summary: Qt Mobility Organizer module - Group: System/Libraries - Description: | - Qt Mobility delivers a set of new APIs for mobile device functionality. - - This package contains an API for management of calendar, scheduling and - personal data from local or remote backends. It includes the ability to create, - edit, list, delete and lookup organizer information whether it is stored - locally or remotely. - - - Name: libqtpublishsubscribe1 - AsWholeName: yes - Summary: Qt Mobility Publish and Subscribe module - Group: System/Libraries - Description: | - Qt Mobility delivers a set of new APIs for mobile device functionality. - - This package contains the Publish and Subscribe API (containing Value Space). - It enables applications to read item values, navigate through and subscribe to - change notifications. - - - Name: libqtsensors1 - AsWholeName: yes - Summary: Qt Mobility Sensors module - Group: System/Libraries - Description: | - Qt Mobility delivers a set of new APIs for mobile device functionality. - - This package contains the Sensors API. It provides access to sensors. - Requires: - - libqtsql4-sqlite - - sensorfw - - - Name: libqtserviceframework1 - AsWholeName: yes - Summary: Qt Mobility Service Framework module - Group: System/Libraries - Description: | - Qt Mobility delivers a set of new APIs for mobile device functionality. - - This package contains a set of APIs to that allows clients to discover and - instantiate arbitrary services. - - - Name: libqtsysteminfo1 - AsWholeName: yes - Summary: Qt Mobility System Information module - Group: System/Libraries - Description: | - Qt Mobility delivers a set of new APIs for mobile device functionality. - - This package contains a set of APIs to discover system related information and - capabilities. - - - Name: libqtversit1 - AsWholeName: yes - Summary: Qt Mobility Versit (vCard) module - Group: System/Libraries - Description: | - Qt Mobility delivers a set of new APIs for mobile device functionality. - - This package contains an API to manage Versit documents, such as vCards. - - - Name: libqtversitorganizer1 - AsWholeName: yes - Summary: Qt Mobility Versit (Organizer) module - Group: System/Libraries - Description: | - Qt Mobility delivers a set of new APIs for mobile device functionality. - - This package contains an API to manage Versit documents, such as iCalendar - documents. It interfaces the Organizer API and uses the same framework as for - vCards. - - - Name: libdeclarative-contacts - AsWholeName: yes - Summary: Qt Mobility Contacts QML plugin - Group: System/Libraries - Description: | - Qt Mobility delivers a set of new APIs for mobile device functionality. - - This package contains the Contacts QML plugin for QtDeclarative. - - - Name: libdeclarative-feedback - AsWholeName: yes - Summary: Qt Mobility Feedback QML plugin - Group: System/Libraries - Description: | - Qt Mobility delivers a set of new APIs for mobile device functionality. - - This package contains the Feedback QML plugin for QtDeclarative. - - - Name: libdeclarative-gallery - AsWholeName: yes - Summary: Qt Mobility Document Gallery QML plugin - Group: System/Libraries - Description: | - Qt Mobility delivers a set of new APIs for mobile device functionality. - - This package contains the Document Gallery QML plugin for QtDeclarative. - - - Name: libdeclarative-location - AsWholeName: yes - Summary: Qt Mobility Location QML plugin - Group: System/Libraries - Description: | - Qt Mobility delivers a set of new APIs for mobile device functionality. - - This package contains the Location QML plugin for QtDeclarative. - - - Name: libdeclarative-messaging - AsWholeName: yes - Summary: Qt Mobility Messaging QML plugin - Group: System/Libraries - Description: | - Qt Mobility delivers a set of new APIs for mobile device functionality. - - This package contains the Messaging QML plugin for QtDeclarative. - - - Name: libdeclarative-multimedia - AsWholeName: yes - Summary: Qt Mobility Multimedia QML plugin - Group: System/Libraries - Description: | - Qt Mobility delivers a set of new APIs for mobile device functionality. - - This package contains the Multimedia QML plugin for QtDeclarative. - - - Name: libdeclarative-organizer - AsWholeName: yes - Summary: Qt Mobility Organizer QML plugin - Group: System/Libraries - Description: | - Qt Mobility delivers a set of new APIs for mobile device functionality. - - This package contains the Organizer QML plugin for QtDeclarative. - - - Name: libdeclarative-publishsubscribe - AsWholeName: yes - Summary: Qt Mobility Publish and Subscribe QML plugin - Group: System/Libraries - Description: | - Qt Mobility delivers a set of new APIs for mobile device functionality. - - This package contains the Publish and Subscribe QML plugin for QtDeclarative. - - - Name: libdeclarative-sensors - AsWholeName: yes - Summary: Qt Mobility Sensors Framework QML plugin - Group: System/Libraries - Description: | - Qt Mobility delivers a set of new APIs for mobile device functionality. - - This package contains the Sensors QML plugin for QtDeclarative. - - - Name: libdeclarative-serviceframework - AsWholeName: yes - Summary: Qt Mobility Service Framework QML plugin - Group: System/Libraries - Description: | - Qt Mobility delivers a set of new APIs for mobile device functionality. - - This package contains the Service Framework QML plugin for QtDeclarative. - - - Name: libdeclarative-systeminfo - AsWholeName: yes - Summary: Qt Mobility System Information QML plugin - Group: System/Libraries - Description: | - Qt Mobility delivers a set of new APIs for mobile device functionality. - - This package contains the System Information QML plugin for QtDeclarative. - - - Name: libdeclarative-connectivity - AsWholeName: yes - Summary: Qt Mobility Connectivity QML plugin - Group: System/Libraries - Description: | - Qt Mobility delivers a set of new APIs for mobile device functionality. - - This package contains the Connectivity QML plugin for QtDeclarative. - - - Name: servicefw - AsWholeName: yes - Summary: Qt Mobility Service Framework tool - Group: Development/Tools - Description: | - Qt Mobility delivers a set of new APIs for mobile device functionality. - - This package contains the Service Framework tool (servicefw). It allows - to register services and make them available over the Service Framework. - - - Name: examples - Summary: Qt Mobility examples - Group: System/X11 - Description: | - Qt Mobility delivers a set of new APIs for mobile device functionality. - - This package contains Qt Mobility examples. - - - Name: l10n - Summary: APIs for mobile device functionality - localization files - Group: System/I18n - Description: | - Qt Mobility delivers a set of new APIs for mobile device functionality. - - This package contains Qt Mobility translations. diff --git a/src/multimedia/audio/audio.pri b/src/multimedia/audio/audio.pri new file mode 100644 index 000000000..4bedbd4d5 --- /dev/null +++ b/src/multimedia/audio/audio.pri @@ -0,0 +1,60 @@ +INCLUDEPATH += audio + +PUBLIC_HEADERS += audio/qaudio.h \ + audio/qaudioformat.h \ + audio/qaudioinput.h \ + audio/qaudiooutput.h \ + audio/qaudiodeviceinfo.h \ + audio/qaudiosystemplugin.h \ + audio/qaudiosystem.h + +PRIVATE_HEADERS += audio/qaudiodevicefactory_p.h audio/qaudiopluginloader_p.h + + +SOURCES += audio/qaudio.cpp \ + audio/qaudioformat.cpp \ + audio/qaudiodeviceinfo.cpp \ + audio/qaudiooutput.cpp \ + audio/qaudioinput.cpp \ + audio/qaudiosystemplugin.cpp \ + audio/qaudiosystem.cpp \ + audio/qaudiodevicefactory.cpp \ + audio/qaudiopluginloader.cpp + +mac { + PRIVATE_HEADERS += audio/qaudioinput_mac_p.h \ + audio/qaudiooutput_mac_p.h \ + audio/qaudiodeviceinfo_mac_p.h \ + audio/qaudio_mac_p.h + + SOURCES += audio/qaudiodeviceinfo_mac_p.cpp \ + audio/qaudiooutput_mac_p.cpp \ + audio/qaudioinput_mac_p.cpp \ + audio/qaudio_mac.cpp + + LIBS += -framework ApplicationServices -framework CoreAudio -framework AudioUnit -framework AudioToolbox +} + +win32 { + PRIVATE_HEADERS += audio/qaudioinput_win32_p.h audio/qaudiooutput_win32_p.h audio/qaudiodeviceinfo_win32_p.h + SOURCES += audio/qaudiodeviceinfo_win32_p.cpp \ + audio/qaudiooutput_win32_p.cpp \ + audio/qaudioinput_win32_p.cpp + LIBS += -lwinmm -lstrmiids -lole32 -loleaut32 +} + +unix:!mac { + contains(config_test_pulseaudio, yes) { + DEFINES += QT_NO_AUDIO_BACKEND + } + else:contains(QT_CONFIG, alsa) { + linux-*|freebsd-*|openbsd-* { + DEFINES += HAS_ALSA + PRIVATE_HEADERS += audio/qaudiooutput_alsa_p.h audio/qaudioinput_alsa_p.h audio/qaudiodeviceinfo_alsa_p.h + SOURCES += audio/qaudiodeviceinfo_alsa_p.cpp \ + audio/qaudiooutput_alsa_p.cpp \ + audio/qaudioinput_alsa_p.cpp + LIBS_PRIVATE += -lasound + } + } +} diff --git a/src/multimedia/audio/qaudio.cpp b/src/multimedia/audio/qaudio.cpp new file mode 100644 index 000000000..bb18f8448 --- /dev/null +++ b/src/multimedia/audio/qaudio.cpp @@ -0,0 +1,103 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + + +#include + + +QT_BEGIN_NAMESPACE + +namespace QAudio +{ + +class RegisterMetaTypes +{ +public: + RegisterMetaTypes() + { + qRegisterMetaType(); + qRegisterMetaType(); + qRegisterMetaType(); + } + +} _register; + +} + +/* + \namespace QAudio + \brief The QAudio namespace contains enums used by the audio classes. + \inmodule QtMultimedia + \ingroup multimedia +*/ + +/* + \enum QAudio::Error + + \value NoError No errors have occurred + \value OpenError An error occurred opening the audio device + \value IOError An error occurred during read/write of audio device + \value UnderrunError Audio data is not being fed to the audio device at a fast enough rate + \value FatalError A non-recoverable error has occurred, the audio device is not usable at this time. +*/ + +/* + \enum QAudio::State + + \value ActiveState Audio data is being processed, this state is set after start() is called + and while audio data is available to be processed. + \value SuspendedState The audio device is in a suspended state, this state will only be entered + after suspend() is called. + \value StoppedState The audio device is closed, and is not processing any audio data + \value IdleState The QIODevice passed in has no data and audio system's buffer is empty, this state + is set after start() is called and while no audio data is available to be processed. +*/ + +/* + \enum QAudio::Mode + + \value AudioOutput audio output device + \value AudioInput audio input device +*/ + + +QT_END_NAMESPACE + diff --git a/src/multimedia/audio/qaudio.h b/src/multimedia/audio/qaudio.h new file mode 100644 index 000000000..fff1094c0 --- /dev/null +++ b/src/multimedia/audio/qaudio.h @@ -0,0 +1,74 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + + +#ifndef QAUDIO_H +#define QAUDIO_H + +#include +#include + +#include + +QT_BEGIN_HEADER + +QT_BEGIN_NAMESPACE + +QT_MODULE(Multimedia) + +//QTM_SYNC_HEADER_EXPORT QAudio + +namespace QAudio +{ + enum Error { NoError, OpenError, IOError, UnderrunError, FatalError }; + enum State { ActiveState, SuspendedState, StoppedState, IdleState }; + enum Mode { AudioInput, AudioOutput }; +} + +QT_END_NAMESPACE + +QT_END_HEADER + +Q_DECLARE_METATYPE(QAudio::Error) +Q_DECLARE_METATYPE(QAudio::State) +Q_DECLARE_METATYPE(QAudio::Mode) + +#endif // QAUDIO_H diff --git a/src/multimedia/audio/qaudio_mac.cpp b/src/multimedia/audio/qaudio_mac.cpp new file mode 100644 index 000000000..461508304 --- /dev/null +++ b/src/multimedia/audio/qaudio_mac.cpp @@ -0,0 +1,145 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + + +#include "qaudio_mac_p.h" + +QT_BEGIN_NAMESPACE + +// Debugging +QDebug operator<<(QDebug dbg, const QAudioFormat& audioFormat) +{ + dbg.nospace() << "QAudioFormat(" << + audioFormat.frequency() << "," << + audioFormat.channels() << "," << + audioFormat.sampleSize()<< "," << + audioFormat.codec() << "," << + audioFormat.byteOrder() << "," << + audioFormat.sampleType() << ")"; + + return dbg.space(); +} + + +// Conversion +QAudioFormat toQAudioFormat(AudioStreamBasicDescription const& sf) +{ + QAudioFormat audioFormat; + + audioFormat.setFrequency(sf.mSampleRate); + audioFormat.setChannels(sf.mChannelsPerFrame); + audioFormat.setSampleSize(sf.mBitsPerChannel); + audioFormat.setCodec(QString::fromLatin1("audio/pcm")); + audioFormat.setByteOrder((sf.mFormatFlags & kAudioFormatFlagIsBigEndian) != 0 ? QAudioFormat::BigEndian : QAudioFormat::LittleEndian); + QAudioFormat::SampleType type = QAudioFormat::UnSignedInt; + if ((sf.mFormatFlags & kAudioFormatFlagIsSignedInteger) != 0) + type = QAudioFormat::SignedInt; + else if ((sf.mFormatFlags & kAudioFormatFlagIsFloat) != 0) + type = QAudioFormat::Float; + audioFormat.setSampleType(type); + + return audioFormat; +} + +AudioStreamBasicDescription toAudioStreamBasicDescription(QAudioFormat const& audioFormat) +{ + AudioStreamBasicDescription sf; + + sf.mFormatFlags = kAudioFormatFlagIsPacked; + sf.mSampleRate = audioFormat.frequency(); + sf.mFramesPerPacket = 1; + sf.mChannelsPerFrame = audioFormat.channels(); + sf.mBitsPerChannel = audioFormat.sampleSize(); + sf.mBytesPerFrame = sf.mChannelsPerFrame * (sf.mBitsPerChannel / 8); + sf.mBytesPerPacket = sf.mFramesPerPacket * sf.mBytesPerFrame; + sf.mFormatID = kAudioFormatLinearPCM; + + switch (audioFormat.sampleType()) { + case QAudioFormat::SignedInt: sf.mFormatFlags |= kAudioFormatFlagIsSignedInteger; break; + case QAudioFormat::UnSignedInt: /* default */ break; + case QAudioFormat::Float: sf.mFormatFlags |= kAudioFormatFlagIsFloat; break; + case QAudioFormat::Unknown: default: break; + } + + if (audioFormat.byteOrder() == QAudioFormat::BigEndian) + sf.mFormatFlags |= kAudioFormatFlagIsBigEndian; + + return sf; +} + +// QAudioRingBuffer +QAudioRingBuffer::QAudioRingBuffer(int bufferSize): + m_bufferSize(bufferSize) +{ + m_buffer = new char[m_bufferSize]; + reset(); +} + +QAudioRingBuffer::~QAudioRingBuffer() +{ + delete m_buffer; +} + +int QAudioRingBuffer::used() const +{ + return m_bufferUsed; +} + +int QAudioRingBuffer::free() const +{ + return m_bufferSize - m_bufferUsed; +} + +int QAudioRingBuffer::size() const +{ + return m_bufferSize; +} + +void QAudioRingBuffer::reset() +{ + m_readPos = 0; + m_writePos = 0; + m_bufferUsed = 0; +} + +QT_END_NAMESPACE + + diff --git a/src/multimedia/audio/qaudio_mac_p.h b/src/multimedia/audio/qaudio_mac_p.h new file mode 100644 index 000000000..06ce43010 --- /dev/null +++ b/src/multimedia/audio/qaudio_mac_p.h @@ -0,0 +1,145 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists for the convenience +// of other Qt classes. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + + +#ifndef QAUDIO_MAC_P_H +#define QAUDIO_MAC_P_H + +#include + +#include +#include + +#include + +QT_BEGIN_HEADER + +QT_BEGIN_NAMESPACE + +QT_MODULE(Multimedia) + + + +extern QDebug operator<<(QDebug dbg, const QAudioFormat& audioFormat); + +extern QAudioFormat toQAudioFormat(const AudioStreamBasicDescription& streamFormat); +extern AudioStreamBasicDescription toAudioStreamBasicDescription(QAudioFormat const& audioFormat); + +class QAudioRingBuffer +{ +public: + typedef QPair Region; + + QAudioRingBuffer(int bufferSize); + ~QAudioRingBuffer(); + + Region acquireReadRegion(int size) + { + const int used = m_bufferUsed.fetchAndAddAcquire(0); + + if (used > 0) { + const int readSize = qMin(size, qMin(m_bufferSize - m_readPos, used)); + + return readSize > 0 ? Region(m_buffer + m_readPos, readSize) : Region(0, 0); + } + + return Region(0, 0); + } + + void releaseReadRegion(Region const& region) + { + m_readPos = (m_readPos + region.second) % m_bufferSize; + + m_bufferUsed.fetchAndAddRelease(-region.second); + } + + Region acquireWriteRegion(int size) + { + const int free = m_bufferSize - m_bufferUsed.fetchAndAddAcquire(0); + + if (free > 0) { + const int writeSize = qMin(size, qMin(m_bufferSize - m_writePos, free)); + + return writeSize > 0 ? Region(m_buffer + m_writePos, writeSize) : Region(0, 0); + } + + return Region(0, 0); + } + + void releaseWriteRegion(Region const& region) + { + m_writePos = (m_writePos + region.second) % m_bufferSize; + + m_bufferUsed.fetchAndAddRelease(region.second); + } + + int used() const; + int free() const; + int size() const; + + void reset(); + +private: + int m_bufferSize; + int m_readPos; + int m_writePos; + char* m_buffer; + QAtomicInt m_bufferUsed; +}; + +QT_END_NAMESPACE + +QT_END_HEADER + +#endif // QAUDIO_MAC_P_H + + diff --git a/src/multimedia/audio/qaudiodevicefactory.cpp b/src/multimedia/audio/qaudiodevicefactory.cpp new file mode 100644 index 000000000..19071e78f --- /dev/null +++ b/src/multimedia/audio/qaudiodevicefactory.cpp @@ -0,0 +1,288 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include + +#include "qaudiosystem.h" +#include "qaudiosystemplugin.h" + +#include "qaudiopluginloader_p.h" +#include "qaudiodevicefactory_p.h" + +#ifndef QT_NO_AUDIO_BACKEND +#if defined(Q_OS_WIN) +#include "qaudiodeviceinfo_win32_p.h" +#include "qaudiooutput_win32_p.h" +#include "qaudioinput_win32_p.h" +#elif defined(Q_OS_MAC) +#include "qaudiodeviceinfo_mac_p.h" +#include "qaudiooutput_mac_p.h" +#include "qaudioinput_mac_p.h" +#elif defined(HAS_ALSA) +#include "qaudiodeviceinfo_alsa_p.h" +#include "qaudiooutput_alsa_p.h" +#include "qaudioinput_alsa_p.h" +#endif +#endif + +QT_BEGIN_NAMESPACE + +#if !defined (QT_NO_LIBRARY) && !defined(QT_NO_SETTINGS) +Q_GLOBAL_STATIC_WITH_ARGS(QAudioPluginLoader, audioLoader, + (QAudioSystemFactoryInterface_iid, QLatin1String("/audio"), Qt::CaseInsensitive)) +#endif + +class QNullDeviceInfo : public QAbstractAudioDeviceInfo +{ +public: + QAudioFormat preferredFormat() const { qWarning()<<"using null deviceinfo, none available"; return QAudioFormat(); } + bool isFormatSupported(const QAudioFormat& ) const { return false; } + QAudioFormat nearestFormat(const QAudioFormat& ) const { return QAudioFormat(); } + QString deviceName() const { return QString(); } + QStringList supportedCodecs() { return QStringList(); } + QList supportedSampleRates() { return QList(); } + QList supportedChannelCounts() { return QList(); } + QList supportedSampleSizes() { return QList(); } + QList supportedByteOrders() { return QList(); } + QList supportedSampleTypes() { return QList(); } +}; + +class QNullInputDevice : public QAbstractAudioInput +{ +public: + void start(QIODevice*) { qWarning()<<"using null input device, none available";} + QIODevice* start() { qWarning()<<"using null input device, none available"; return 0; } + void stop() {} + void reset() {} + void suspend() {} + void resume() {} + int bytesReady() const { return 0; } + int periodSize() const { return 0; } + void setBufferSize(int ) {} + int bufferSize() const { return 0; } + void setNotifyInterval(int ) {} + int notifyInterval() const { return 0; } + qint64 processedUSecs() const { return 0; } + qint64 elapsedUSecs() const { return 0; } + QAudio::Error error() const { return QAudio::OpenError; } + QAudio::State state() const { return QAudio::StoppedState; } + void setFormat(const QAudioFormat&) {} + QAudioFormat format() const { return QAudioFormat(); } +}; + +class QNullOutputDevice : public QAbstractAudioOutput +{ +public: + void start(QIODevice*) {qWarning()<<"using null output device, none available";} + QIODevice* start() { qWarning()<<"using null output device, none available"; return 0; } + void stop() {} + void reset() {} + void suspend() {} + void resume() {} + int bytesFree() const { return 0; } + int periodSize() const { return 0; } + void setBufferSize(int ) {} + int bufferSize() const { return 0; } + void setNotifyInterval(int ) {} + int notifyInterval() const { return 0; } + qint64 processedUSecs() const { return 0; } + qint64 elapsedUSecs() const { return 0; } + QAudio::Error error() const { return QAudio::OpenError; } + QAudio::State state() const { return QAudio::StoppedState; } + void setFormat(const QAudioFormat&) {} + QAudioFormat format() const { return QAudioFormat(); } +}; + +QList QAudioDeviceFactory::availableDevices(QAudio::Mode mode) +{ + QList devices; +#ifndef QT_NO_AUDIO_BACKEND +#if (defined(Q_OS_WIN) || defined(Q_OS_MAC) || defined(HAS_ALSA)) + foreach (const QByteArray &handle, QAudioDeviceInfoInternal::availableDevices(mode)) + devices << QAudioDeviceInfo(QLatin1String("builtin"), handle, mode); +#endif +#endif + +#if !defined (QT_NO_LIBRARY) && !defined(QT_NO_SETTINGS) + QAudioPluginLoader* l = audioLoader(); + foreach (const QString& key, l->keys()) { + QAudioSystemFactoryInterface* plugin = qobject_cast(l->instance(key)); + if (plugin) { + foreach (QByteArray const& handle, plugin->availableDevices(mode)) + devices << QAudioDeviceInfo(key, handle, mode); + } + + delete plugin; + } +#endif + + return devices; +} + +QAudioDeviceInfo QAudioDeviceFactory::defaultInputDevice() +{ +#if !defined (QT_NO_LIBRARY) && !defined(QT_NO_SETTINGS) + QAudioSystemFactoryInterface* plugin = qobject_cast(audioLoader()->instance(QLatin1String("default"))); + + if (plugin) { + QList list = plugin->availableDevices(QAudio::AudioInput); + if (list.size() > 0) + return QAudioDeviceInfo(QLatin1String("default"), list.at(0), QAudio::AudioInput); + } +#endif + +#ifndef QT_NO_AUDIO_BACKEND +#if (defined(Q_OS_WIN) || defined(Q_OS_MAC) || defined(HAS_ALSA)) + return QAudioDeviceInfo(QLatin1String("builtin"), QAudioDeviceInfoInternal::defaultInputDevice(), QAudio::AudioInput); +#endif +#endif + return QAudioDeviceInfo(); +} + +QAudioDeviceInfo QAudioDeviceFactory::defaultOutputDevice() +{ +#if !defined (QT_NO_LIBRARY) && !defined(QT_NO_SETTINGS) + QAudioSystemFactoryInterface* plugin = qobject_cast(audioLoader()->instance(QLatin1String("default"))); + + if (plugin) { + QList list = plugin->availableDevices(QAudio::AudioOutput); + if (list.size() > 0) + return QAudioDeviceInfo(QLatin1String("default"), list.at(0), QAudio::AudioOutput); + } +#endif + +#ifndef QT_NO_AUDIO_BACKEND +#if (defined(Q_OS_WIN) || defined(Q_OS_MAC) || defined(HAS_ALSA)) + return QAudioDeviceInfo(QLatin1String("builtin"), QAudioDeviceInfoInternal::defaultOutputDevice(), QAudio::AudioOutput); +#endif +#endif + return QAudioDeviceInfo(); +} + +QAbstractAudioDeviceInfo* QAudioDeviceFactory::audioDeviceInfo(const QString &realm, const QByteArray &handle, QAudio::Mode mode) +{ + QAbstractAudioDeviceInfo *rc = 0; + +#ifndef QT_NO_AUDIO_BACKEND +#if (defined(Q_OS_WIN) || defined(Q_OS_MAC) || defined(HAS_ALSA)) + if (realm == QLatin1String("builtin")) + return new QAudioDeviceInfoInternal(handle, mode); +#endif +#endif + +#if !defined (QT_NO_LIBRARY) && !defined(QT_NO_SETTINGS) + QAudioSystemFactoryInterface* plugin = + qobject_cast(audioLoader()->instance(realm)); + + if (plugin) + rc = plugin->createDeviceInfo(handle, mode); +#endif + + return rc == 0 ? new QNullDeviceInfo() : rc; +} + +QAbstractAudioInput* QAudioDeviceFactory::createDefaultInputDevice(QAudioFormat const &format) +{ + return createInputDevice(defaultInputDevice(), format); +} + +QAbstractAudioOutput* QAudioDeviceFactory::createDefaultOutputDevice(QAudioFormat const &format) +{ + return createOutputDevice(defaultOutputDevice(), format); +} + +QAbstractAudioInput* QAudioDeviceFactory::createInputDevice(QAudioDeviceInfo const& deviceInfo, QAudioFormat const &format) +{ + if (deviceInfo.isNull()) + return new QNullInputDevice(); +#ifndef QT_NO_AUDIO_BACKEND +#if (defined(Q_OS_WIN) || defined(Q_OS_MAC) || defined(HAS_ALSA)) + if (deviceInfo.realm() == QLatin1String("builtin")) { + QAbstractAudioInput* p = new QAudioInputPrivate(deviceInfo.handle()); + if (p) p->setFormat(format); + return p; + } +#endif +#endif +#if !defined (QT_NO_LIBRARY) && !defined(QT_NO_SETTINGS) + QAudioSystemFactoryInterface* plugin = + qobject_cast(audioLoader()->instance(deviceInfo.realm())); + + if (plugin) { + QAbstractAudioInput* p = plugin->createInput(deviceInfo.handle()); + if (p) p->setFormat(format); + return p; + } +#endif + + return new QNullInputDevice(); +} + +QAbstractAudioOutput* QAudioDeviceFactory::createOutputDevice(QAudioDeviceInfo const& deviceInfo, QAudioFormat const &format) +{ + if (deviceInfo.isNull()) + return new QNullOutputDevice(); +#ifndef QT_NO_AUDIO_BACKEND +#if (defined(Q_OS_WIN) || defined(Q_OS_MAC) || defined(HAS_ALSA)) + if (deviceInfo.realm() == QLatin1String("builtin")) { + QAbstractAudioOutput* p = new QAudioOutputPrivate(deviceInfo.handle()); + if (p) p->setFormat(format); + return p; + } +#endif +#endif + +#if !defined (QT_NO_LIBRARY) && !defined(QT_NO_SETTINGS) + QAudioSystemFactoryInterface* plugin = + qobject_cast(audioLoader()->instance(deviceInfo.realm())); + + if (plugin) { + QAbstractAudioOutput* p = plugin->createOutput(deviceInfo.handle()); + if (p) p->setFormat(format); + return p; + } +#endif + + return new QNullOutputDevice(); +} + +QT_END_NAMESPACE + diff --git a/src/multimedia/audio/qaudiodevicefactory_p.h b/src/multimedia/audio/qaudiodevicefactory_p.h new file mode 100644 index 000000000..26b3a48e5 --- /dev/null +++ b/src/multimedia/audio/qaudiodevicefactory_p.h @@ -0,0 +1,100 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists for the convenience +// of other Qt classes. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#ifndef QAUDIODEVICEFACTORY_P_H +#define QAUDIODEVICEFACTORY_P_H + +#include +#include + +#include +#include + +#include "qaudiodeviceinfo.h" + +QT_BEGIN_HEADER + +QT_BEGIN_NAMESPACE + +QT_MODULE(Multimedia) + + +class QAbstractAudioInput; +class QAbstractAudioOutput; +class QAbstractAudioDeviceInfo; + +class QAudioDeviceFactory +{ +public: + static QList availableDevices(QAudio::Mode mode); + + static QAudioDeviceInfo defaultInputDevice(); + static QAudioDeviceInfo defaultOutputDevice(); + + static QAbstractAudioDeviceInfo* audioDeviceInfo(const QString &realm, const QByteArray &handle, QAudio::Mode mode); + + static QAbstractAudioInput* createDefaultInputDevice(QAudioFormat const &format); + static QAbstractAudioOutput* createDefaultOutputDevice(QAudioFormat const &format); + + static QAbstractAudioInput* createInputDevice(QAudioDeviceInfo const &device, QAudioFormat const &format); + static QAbstractAudioOutput* createOutputDevice(QAudioDeviceInfo const &device, QAudioFormat const &format); + + static QAbstractAudioInput* createNullInput(); + static QAbstractAudioOutput* createNullOutput(); +}; + +QT_END_NAMESPACE + +QT_END_HEADER + +#endif // QAUDIODEVICEFACTORY_P_H + diff --git a/src/multimedia/audio/qaudiodeviceinfo.cpp b/src/multimedia/audio/qaudiodeviceinfo.cpp new file mode 100644 index 000000000..f45805dbc --- /dev/null +++ b/src/multimedia/audio/qaudiodeviceinfo.cpp @@ -0,0 +1,483 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qaudiodevicefactory_p.h" +#include "qaudiosystem.h" +#include "qaudiodeviceinfo.h" + +#include + +QT_BEGIN_NAMESPACE + +class QAudioDeviceInfoPrivate : public QSharedData +{ +public: + QAudioDeviceInfoPrivate():info(0) {} + QAudioDeviceInfoPrivate(const QString &r, const QByteArray &h, QAudio::Mode m): + realm(r), handle(h), mode(m) + { + if (!handle.isEmpty()) + info = QAudioDeviceFactory::audioDeviceInfo(realm, handle, mode); + else + info = NULL; + } + + QAudioDeviceInfoPrivate(const QAudioDeviceInfoPrivate &other): + QSharedData(other), + realm(other.realm), handle(other.handle), mode(other.mode) + { + info = QAudioDeviceFactory::audioDeviceInfo(realm, handle, mode); + } + + QAudioDeviceInfoPrivate& operator=(const QAudioDeviceInfoPrivate &other) + { + delete info; + + realm = other.realm; + handle = other.handle; + mode = other.mode; + info = QAudioDeviceFactory::audioDeviceInfo(realm, handle, mode); + return *this; + } + + ~QAudioDeviceInfoPrivate() + { + delete info; + } + + QString realm; + QByteArray handle; + QAudio::Mode mode; + QAbstractAudioDeviceInfo* info; +}; + + +/*! + \class QAudioDeviceInfo + \brief The QAudioDeviceInfo class provides an interface to query audio devices and their functionality. + \inmodule QtMultimedia + \ingroup multimedia + + QAudioDeviceInfo lets you query for audio devices--such as sound + cards and USB headsets--that are currently available on the system. + The audio devices available are dependent on the platform or audio plugins installed. + + A QAudioDeviceInfo is used by Qt to construct + classes that communicate with the device--such as + QAudioInput, and QAudioOutput. + + You can also query each device for the formats it supports. A + format in this context is a set consisting of a specific byte + order, channel, codec, frequency, sample rate, and sample type. A + format is represented by the QAudioFormat class. + + The values supported by the the device for each of these + parameters can be fetched with + supportedByteOrders(), supportedChannelCounts(), supportedCodecs(), + supportedSampleRates(), supportedSampleSizes(), and + supportedSampleTypes(). The combinations supported are dependent on the platform, + audio plugins installed and the audio device capabilities. If you need a + specific format, you can check if + the device supports it with isFormatSupported(), or fetch a + supported format that is as close as possible to the format with + nearestFormat(). For instance: + + \snippet doc/src/snippets/multimedia-snippets/audio.cpp Setting audio format + + The static + functions defaultInputDevice(), defaultOutputDevice(), and + availableDevices() let you get a list of all available + devices. Devices are fetched according to the value of mode + this is specified by the \l {QAudio}::Mode enum. + The QAudioDeviceInfo returned are only valid for the \l {QAudio}::Mode. + + For instance: + + \snippet doc/src/snippets/multimedia-snippets/audio.cpp Dumping audio formats + + In this code sample, we loop through all devices that are able to output + sound, i.e., play an audio stream in a supported format. For each device we + find, we simply print the deviceName(). + + \sa QAudioOutput, QAudioInput +*/ + +/*! + Constructs an empty QAudioDeviceInfo object. +*/ +QAudioDeviceInfo::QAudioDeviceInfo(): + d(new QAudioDeviceInfoPrivate) +{ +} + +/*! + Constructs a copy of \a other. + \since 1.0 +*/ +QAudioDeviceInfo::QAudioDeviceInfo(const QAudioDeviceInfo& other): + d(other.d) +{ +} + +/*! + Destroy this audio device info. +*/ +QAudioDeviceInfo::~QAudioDeviceInfo() +{ +} + +/*! + Sets the QAudioDeviceInfo object to be equal to \a other. + \since 1.0 +*/ +QAudioDeviceInfo& QAudioDeviceInfo::operator=(const QAudioDeviceInfo &other) +{ + d = other.d; + return *this; +} + +/*! + Returns whether this QAudioDeviceInfo object holds a device definition. + \since 1.0 +*/ +bool QAudioDeviceInfo::isNull() const +{ + return d->info == 0; +} + +/*! + Returns the human readable name of the audio device. + + Device names vary depending on the platform/audio plugin being used. + + They are a unique string identifier for the audio device. + + eg. default, Intel, U0x46d0x9a4 + \since 1.0 +*/ +QString QAudioDeviceInfo::deviceName() const +{ + return isNull() ? QString() : d->info->deviceName(); +} + +/*! + Returns true if the supplied \a settings are supported by the audio + device described by this QAudioDeviceInfo. + \since 1.0 +*/ +bool QAudioDeviceInfo::isFormatSupported(const QAudioFormat &settings) const +{ + return isNull() ? false : d->info->isFormatSupported(settings); +} + +/*! + Returns the default audio format settings for this device. + + These settings are provided by the platform/audio plugin being used. + + They are also dependent on the \l {QAudio}::Mode being used. + + A typical audio system would provide something like: + \list + \o Input settings: 8000Hz mono 8 bit. + \o Output settings: 44100Hz stereo 16 bit little endian. + \endlist + \since 1.0 +*/ +QAudioFormat QAudioDeviceInfo::preferredFormat() const +{ + return isNull() ? QAudioFormat() : d->info->preferredFormat(); +} + +/*! + Returns the closest QAudioFormat to the supplied \a settings that the system supports. + + These settings are provided by the platform/audio plugin being used. + + They are also dependent on the \l {QAudio}::Mode being used. + \since 1.0 +*/ +QAudioFormat QAudioDeviceInfo::nearestFormat(const QAudioFormat &settings) const +{ + if (isFormatSupported(settings)) + return settings; + + QAudioFormat nearest = settings; + + QList testCodecs = supportedCodecs(); + QList testChannels = supportedChannels(); + QList testByteOrders = supportedByteOrders(); + QList testSampleTypes; + QList sampleTypesAvailable = supportedSampleTypes(); + QMap testFrequencies; + QList frequenciesAvailable = supportedFrequencies(); + QMap testSampleSizes; + QList sampleSizesAvailable = supportedSampleSizes(); + + // Get sorted lists for checking + if (testCodecs.contains(settings.codec())) { + testCodecs.removeAll(settings.codec()); + testCodecs.insert(0, settings.codec()); + } + testChannels.removeAll(settings.channels()); + testChannels.insert(0, settings.channels()); + testByteOrders.removeAll(settings.byteOrder()); + testByteOrders.insert(0, settings.byteOrder()); + + if (sampleTypesAvailable.contains(settings.sampleType())) + testSampleTypes.append(settings.sampleType()); + if (sampleTypesAvailable.contains(QAudioFormat::SignedInt)) + testSampleTypes.append(QAudioFormat::SignedInt); + if (sampleTypesAvailable.contains(QAudioFormat::UnSignedInt)) + testSampleTypes.append(QAudioFormat::UnSignedInt); + if (sampleTypesAvailable.contains(QAudioFormat::Float)) + testSampleTypes.append(QAudioFormat::Float); + + if (sampleSizesAvailable.contains(settings.sampleSize())) + testSampleSizes.insert(0,settings.sampleSize()); + sampleSizesAvailable.removeAll(settings.sampleSize()); + foreach (int size, sampleSizesAvailable) { + int larger = (size > settings.sampleSize()) ? size : settings.sampleSize(); + int smaller = (size > settings.sampleSize()) ? settings.sampleSize() : size; + bool isMultiple = ( 0 == (larger % smaller)); + int diff = larger - smaller; + testSampleSizes.insert((isMultiple ? diff : diff+100000), size); + } + if (frequenciesAvailable.contains(settings.frequency())) + testFrequencies.insert(0,settings.frequency()); + frequenciesAvailable.removeAll(settings.frequency()); + foreach (int frequency, frequenciesAvailable) { + int larger = (frequency > settings.frequency()) ? frequency : settings.frequency(); + int smaller = (frequency > settings.frequency()) ? settings.frequency() : frequency; + bool isMultiple = ( 0 == (larger % smaller)); + int diff = larger - smaller; + testFrequencies.insert((isMultiple ? diff : diff+100000), frequency); + } + + // Try to find nearest + foreach (QString codec, testCodecs) { + nearest.setCodec(codec); + foreach (QAudioFormat::Endian order, testByteOrders) { + nearest.setByteOrder(order); + foreach (QAudioFormat::SampleType sample, testSampleTypes) { + nearest.setSampleType(sample); + QMapIterator sz(testSampleSizes); + while (sz.hasNext()) { + sz.next(); + nearest.setSampleSize(sz.value()); + foreach (int channel, testChannels) { + nearest.setChannels(channel); + QMapIterator i(testFrequencies); + while (i.hasNext()) { + i.next(); + nearest.setFrequency(i.value()); + if (isFormatSupported(nearest)) + return nearest; + } + } + } + } + } + } + //Fallback + return preferredFormat(); +} + +/*! + Returns a list of supported codecs. + + All platform and plugin implementations should provide support for: + + "audio/pcm" - Linear PCM + + For writing plugins to support additional codecs refer to: + + http://www.iana.org/assignments/media-types/audio/ + \since 1.0 +*/ +QStringList QAudioDeviceInfo::supportedCodecs() const +{ + return isNull() ? QStringList() : d->info->supportedCodecs(); +} + +/*! + Returns a list of supported sample rates (in Hertz). + + \since 1.0 +*/ +QList QAudioDeviceInfo::supportedSampleRates() const +{ + return supportedFrequencies(); +} + +/*! + \obsolete + + Use supportedSampleRates() instead. + \since 1.0 +*/ +QList QAudioDeviceInfo::supportedFrequencies() const +{ + return isNull() ? QList() : d->info->supportedSampleRates(); +} + +/*! + Returns a list of supported channel counts. + + This is typically 1 for mono sound, or 2 for stereo sound. + + \since 1.0 +*/ +QList QAudioDeviceInfo::supportedChannelCounts() const +{ + return supportedChannels(); +} + +/*! + \obsolete + + Use supportedChannelCount() instead. + \since 1.0 +*/ +QList QAudioDeviceInfo::supportedChannels() const +{ + return isNull() ? QList() : d->info->supportedChannelCounts(); +} + +/*! + Returns a list of supported sample sizes (in bits). + + Typically this will include 8 and 16 bit sample sizes. + + \since 1.0 +*/ +QList QAudioDeviceInfo::supportedSampleSizes() const +{ + return isNull() ? QList() : d->info->supportedSampleSizes(); +} + +/*! + Returns a list of supported byte orders. + \since 1.0 +*/ +QList QAudioDeviceInfo::supportedByteOrders() const +{ + return isNull() ? QList() : d->info->supportedByteOrders(); +} + +/*! + Returns a list of supported sample types. + \since 1.0 +*/ +QList QAudioDeviceInfo::supportedSampleTypes() const +{ + return isNull() ? QList() : d->info->supportedSampleTypes(); +} + +/*! + Returns the information for the default input audio device. + All platform and audio plugin implementations provide a default audio device to use. + \since 1.0 +*/ +QAudioDeviceInfo QAudioDeviceInfo::defaultInputDevice() +{ + return QAudioDeviceFactory::defaultInputDevice(); +} + +/*! + Returns the information for the default output audio device. + All platform and audio plugin implementations provide a default audio device to use. + \since 1.0 +*/ +QAudioDeviceInfo QAudioDeviceInfo::defaultOutputDevice() +{ + return QAudioDeviceFactory::defaultOutputDevice(); +} + +/*! + Returns a list of audio devices that support \a mode. + \since 1.0 +*/ +QList QAudioDeviceInfo::availableDevices(QAudio::Mode mode) +{ + return QAudioDeviceFactory::availableDevices(mode); +} + + +/*! + \internal + \since 1.0 +*/ +QAudioDeviceInfo::QAudioDeviceInfo(const QString &realm, const QByteArray &handle, QAudio::Mode mode): + d(new QAudioDeviceInfoPrivate(realm, handle, mode)) +{ +} + +/*! + \internal + \since 1.0 +*/ +QString QAudioDeviceInfo::realm() const +{ + return d->realm; +} + +/*! + \internal + \since 1.0 +*/ +QByteArray QAudioDeviceInfo::handle() const +{ + return d->handle; +} + + +/*! + \internal + \since 1.0 +*/ +QAudio::Mode QAudioDeviceInfo::mode() const +{ + return d->mode; +} + +QT_END_NAMESPACE + diff --git a/src/multimedia/audio/qaudiodeviceinfo.h b/src/multimedia/audio/qaudiodeviceinfo.h new file mode 100644 index 000000000..f16122b4d --- /dev/null +++ b/src/multimedia/audio/qaudiodeviceinfo.h @@ -0,0 +1,116 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + + +#ifndef QAUDIODEVICEINFO_H +#define QAUDIODEVICEINFO_H + +#include +#include +#include +#include +#include + +#include +#include + +#include +#include + +QT_BEGIN_HEADER + +QT_BEGIN_NAMESPACE + +QT_MODULE(Multimedia) + + +class QAudioDeviceFactory; + +class QAudioDeviceInfoPrivate; +class Q_MULTIMEDIA_EXPORT QAudioDeviceInfo +{ + friend class QAudioDeviceFactory; + +public: + QAudioDeviceInfo(); + QAudioDeviceInfo(const QAudioDeviceInfo& other); + ~QAudioDeviceInfo(); + + QAudioDeviceInfo& operator=(const QAudioDeviceInfo& other); + + bool isNull() const; + + QString deviceName() const; + + bool isFormatSupported(const QAudioFormat &format) const; + QAudioFormat preferredFormat() const; + QAudioFormat nearestFormat(const QAudioFormat &format) const; + + QStringList supportedCodecs() const; + QList supportedFrequencies() const; + QList supportedSampleRates() const; + QList supportedChannels() const; + QList supportedChannelCounts() const; + QList supportedSampleSizes() const; + QList supportedByteOrders() const; + QList supportedSampleTypes() const; + + static QAudioDeviceInfo defaultInputDevice(); + static QAudioDeviceInfo defaultOutputDevice(); + + static QList availableDevices(QAudio::Mode mode); + +private: + QAudioDeviceInfo(const QString &realm, const QByteArray &handle, QAudio::Mode mode); + QString realm() const; + QByteArray handle() const; + QAudio::Mode mode() const; + + QSharedDataPointer d; +}; + +QT_END_NAMESPACE + +QT_END_HEADER + +Q_DECLARE_METATYPE(QAudioDeviceInfo) + +#endif // QAUDIODEVICEINFO_H diff --git a/src/multimedia/audio/qaudiodeviceinfo_alsa_p.cpp b/src/multimedia/audio/qaudiodeviceinfo_alsa_p.cpp new file mode 100644 index 000000000..113b330d4 --- /dev/null +++ b/src/multimedia/audio/qaudiodeviceinfo_alsa_p.cpp @@ -0,0 +1,535 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists for the convenience +// of other Qt classes. This header file may change from version to +// version without notice, or even be removed. +// +// INTERNAL USE ONLY: Do NOT use for any other purpose. +// + +#include "qaudiodeviceinfo_alsa_p.h" + +#include + +QT_BEGIN_NAMESPACE + +QAudioDeviceInfoInternal::QAudioDeviceInfoInternal(QByteArray dev, QAudio::Mode mode) +{ + handle = 0; + + device = QLatin1String(dev); + this->mode = mode; + + checkSurround(); +} + +QAudioDeviceInfoInternal::~QAudioDeviceInfoInternal() +{ + close(); +} + +bool QAudioDeviceInfoInternal::isFormatSupported(const QAudioFormat& format) const +{ + return testSettings(format); +} + +QAudioFormat QAudioDeviceInfoInternal::preferredFormat() const +{ + QAudioFormat nearest; + if(mode == QAudio::AudioOutput) { + nearest.setFrequency(44100); + nearest.setChannels(2); + nearest.setByteOrder(QAudioFormat::LittleEndian); + nearest.setSampleType(QAudioFormat::SignedInt); + nearest.setSampleSize(16); + nearest.setCodec(QLatin1String("audio/pcm")); + } else { + nearest.setFrequency(8000); + nearest.setChannels(1); + nearest.setSampleType(QAudioFormat::UnSignedInt); + nearest.setSampleSize(8); + nearest.setCodec(QLatin1String("audio/pcm")); + if(!testSettings(nearest)) { + nearest.setChannels(2); + nearest.setSampleSize(16); + nearest.setSampleType(QAudioFormat::SignedInt); + } + } + return nearest; +} + +QString QAudioDeviceInfoInternal::deviceName() const +{ + return device; +} + +QStringList QAudioDeviceInfoInternal::supportedCodecs() +{ + updateLists(); + return codecz; +} + +QList QAudioDeviceInfoInternal::supportedSampleRates() +{ + updateLists(); + return freqz; +} + +QList QAudioDeviceInfoInternal::supportedChannelCounts() +{ + updateLists(); + return channelz; +} + +QList QAudioDeviceInfoInternal::supportedSampleSizes() +{ + updateLists(); + return sizez; +} + +QList QAudioDeviceInfoInternal::supportedByteOrders() +{ + updateLists(); + return byteOrderz; +} + +QList QAudioDeviceInfoInternal::supportedSampleTypes() +{ + updateLists(); + return typez; +} + +bool QAudioDeviceInfoInternal::open() +{ + int err = 0; + QString dev = device; + QList devices = availableDevices(mode); + + if(dev.compare(QLatin1String("default")) == 0) { +#if(SND_LIB_MAJOR == 1 && SND_LIB_MINOR == 0 && SND_LIB_SUBMINOR >= 14) + if (devices.size() > 0) + dev = QLatin1String(devices.first().constData()); + else + return false; +#else + dev = QLatin1String("hw:0,0"); +#endif + } else { +#if(SND_LIB_MAJOR == 1 && SND_LIB_MINOR == 0 && SND_LIB_SUBMINOR >= 14) + dev = device; +#else + int idx = 0; + char *name; + + QString shortName = device.mid(device.indexOf(QLatin1String("="),0)+1); + + while(snd_card_get_name(idx,&name) == 0) { + if(dev.contains(QLatin1String(name))) + break; + idx++; + } + dev = QString(QLatin1String("hw:%1,0")).arg(idx); +#endif + } + if(mode == QAudio::AudioOutput) { + err=snd_pcm_open( &handle,dev.toLocal8Bit().constData(),SND_PCM_STREAM_PLAYBACK,0); + } else { + err=snd_pcm_open( &handle,dev.toLocal8Bit().constData(),SND_PCM_STREAM_CAPTURE,0); + } + if(err < 0) { + handle = 0; + return false; + } + return true; +} + +void QAudioDeviceInfoInternal::close() +{ + if(handle) + snd_pcm_close(handle); + handle = 0; +} + +bool QAudioDeviceInfoInternal::testSettings(const QAudioFormat& format) const +{ + // Set nearest to closest settings that do work. + // See if what is in settings will work (return value). + int err = 0; + snd_pcm_t* handle; + snd_pcm_hw_params_t *params; + QString dev = device; + + QList devices = QAudioDeviceInfoInternal::availableDevices(QAudio::AudioOutput); + + if(dev.compare(QLatin1String("default")) == 0) { +#if(SND_LIB_MAJOR == 1 && SND_LIB_MINOR == 0 && SND_LIB_SUBMINOR >= 14) + dev = QLatin1String(devices.first().constData()); +#else + dev = QLatin1String("hw:0,0"); +#endif + } else { +#if(SND_LIB_MAJOR == 1 && SND_LIB_MINOR == 0 && SND_LIB_SUBMINOR >= 14) + dev = device; +#else + int idx = 0; + char *name; + + QString shortName = device.mid(device.indexOf(QLatin1String("="),0)+1); + + while(snd_card_get_name(idx,&name) == 0) { + if(shortName.compare(QLatin1String(name)) == 0) + break; + idx++; + } + dev = QString(QLatin1String("hw:%1,0")).arg(idx); +#endif + } + if(mode == QAudio::AudioOutput) { + err=snd_pcm_open( &handle,dev.toLocal8Bit().constData(),SND_PCM_STREAM_PLAYBACK,0); + } else { + err=snd_pcm_open( &handle,dev.toLocal8Bit().constData(),SND_PCM_STREAM_CAPTURE,0); + } + if(err < 0) { + handle = 0; + return false; + } + + bool testChannel = false; + bool testCodec = false; + bool testFreq = false; + bool testType = false; + bool testSize = false; + + int dir = 0; + + snd_pcm_nonblock( handle, 0 ); + snd_pcm_hw_params_alloca( ¶ms ); + snd_pcm_hw_params_any( handle, params ); + + // set the values! + snd_pcm_hw_params_set_channels(handle,params,format.channels()); + snd_pcm_hw_params_set_rate(handle,params,format.frequency(),dir); + + err = -1; + + switch(format.sampleSize()) { + case 8: + if(format.sampleType() == QAudioFormat::SignedInt) + err = snd_pcm_hw_params_set_format(handle,params,SND_PCM_FORMAT_S8); + else if(format.sampleType() == QAudioFormat::UnSignedInt) + err = snd_pcm_hw_params_set_format(handle,params,SND_PCM_FORMAT_U8); + break; + case 16: + if(format.sampleType() == QAudioFormat::SignedInt) { + if(format.byteOrder() == QAudioFormat::LittleEndian) + err = snd_pcm_hw_params_set_format(handle,params,SND_PCM_FORMAT_S16_LE); + else if(format.byteOrder() == QAudioFormat::BigEndian) + err = snd_pcm_hw_params_set_format(handle,params,SND_PCM_FORMAT_S16_BE); + } else if(format.sampleType() == QAudioFormat::UnSignedInt) { + if(format.byteOrder() == QAudioFormat::LittleEndian) + err = snd_pcm_hw_params_set_format(handle,params,SND_PCM_FORMAT_U16_LE); + else if(format.byteOrder() == QAudioFormat::BigEndian) + err = snd_pcm_hw_params_set_format(handle,params,SND_PCM_FORMAT_U16_BE); + } + break; + case 32: + if(format.sampleType() == QAudioFormat::SignedInt) { + if(format.byteOrder() == QAudioFormat::LittleEndian) + err = snd_pcm_hw_params_set_format(handle,params,SND_PCM_FORMAT_S32_LE); + else if(format.byteOrder() == QAudioFormat::BigEndian) + err = snd_pcm_hw_params_set_format(handle,params,SND_PCM_FORMAT_S32_BE); + } else if(format.sampleType() == QAudioFormat::UnSignedInt) { + if(format.byteOrder() == QAudioFormat::LittleEndian) + err = snd_pcm_hw_params_set_format(handle,params,SND_PCM_FORMAT_U32_LE); + else if(format.byteOrder() == QAudioFormat::BigEndian) + err = snd_pcm_hw_params_set_format(handle,params,SND_PCM_FORMAT_U32_BE); + } + } + + // For now, just accept only audio/pcm codec + if(!format.codec().startsWith(QLatin1String("audio/pcm"))) { + err=-1; + } else + testCodec = true; + + if(err>=0 && format.channels() != -1) { + err = snd_pcm_hw_params_test_channels(handle,params,format.channels()); + if(err>=0) + err = snd_pcm_hw_params_set_channels(handle,params,format.channels()); + if(err>=0) + testChannel = true; + } + + if(err>=0 && format.frequency() != -1) { + err = snd_pcm_hw_params_test_rate(handle,params,format.frequency(),0); + if(err>=0) + err = snd_pcm_hw_params_set_rate(handle,params,format.frequency(),dir); + if(err>=0) + testFreq = true; + } + + if((err>=0 && format.sampleSize() != -1) && + (format.sampleType() != QAudioFormat::Unknown)) { + switch(format.sampleSize()) { + case 8: + if(format.sampleType() == QAudioFormat::SignedInt) + err = snd_pcm_hw_params_set_format(handle,params,SND_PCM_FORMAT_S8); + else if(format.sampleType() == QAudioFormat::UnSignedInt) + err = snd_pcm_hw_params_set_format(handle,params,SND_PCM_FORMAT_U8); + break; + case 16: + if(format.sampleType() == QAudioFormat::SignedInt) { + if(format.byteOrder() == QAudioFormat::LittleEndian) + err = snd_pcm_hw_params_set_format(handle,params,SND_PCM_FORMAT_S16_LE); + else if(format.byteOrder() == QAudioFormat::BigEndian) + err = snd_pcm_hw_params_set_format(handle,params,SND_PCM_FORMAT_S16_BE); + } else if(format.sampleType() == QAudioFormat::UnSignedInt) { + if(format.byteOrder() == QAudioFormat::LittleEndian) + err = snd_pcm_hw_params_set_format(handle,params,SND_PCM_FORMAT_U16_LE); + else if(format.byteOrder() == QAudioFormat::BigEndian) + err = snd_pcm_hw_params_set_format(handle,params,SND_PCM_FORMAT_U16_BE); + } + break; + case 32: + if(format.sampleType() == QAudioFormat::SignedInt) { + if(format.byteOrder() == QAudioFormat::LittleEndian) + err = snd_pcm_hw_params_set_format(handle,params,SND_PCM_FORMAT_S32_LE); + else if(format.byteOrder() == QAudioFormat::BigEndian) + err = snd_pcm_hw_params_set_format(handle,params,SND_PCM_FORMAT_S32_BE); + } else if(format.sampleType() == QAudioFormat::UnSignedInt) { + if(format.byteOrder() == QAudioFormat::LittleEndian) + err = snd_pcm_hw_params_set_format(handle,params,SND_PCM_FORMAT_U32_LE); + else if(format.byteOrder() == QAudioFormat::BigEndian) + err = snd_pcm_hw_params_set_format(handle,params,SND_PCM_FORMAT_U32_BE); + } + } + if(err>=0) { + testSize = true; + testType = true; + } + } + if(err>=0) + err = snd_pcm_hw_params(handle, params); + + if(err == 0) { + // settings work + // close() + if(handle) + snd_pcm_close(handle); + return true; + } + if(handle) + snd_pcm_close(handle); + + return false; +} + +void QAudioDeviceInfoInternal::updateLists() +{ + // redo all lists based on current settings + freqz.clear(); + channelz.clear(); + sizez.clear(); + byteOrderz.clear(); + typez.clear(); + codecz.clear(); + + if(!handle) + open(); + + if(!handle) + return; + + for(int i=0; i<(int)MAX_SAMPLE_RATES; i++) { + //if(snd_pcm_hw_params_test_rate(handle, params, SAMPLE_RATES[i], dir) == 0) + freqz.append(SAMPLE_RATES[i]); + } + channelz.append(1); + channelz.append(2); + if (surround40) channelz.append(4); + if (surround51) channelz.append(6); + if (surround71) channelz.append(8); + sizez.append(8); + sizez.append(16); + sizez.append(32); + byteOrderz.append(QAudioFormat::LittleEndian); + byteOrderz.append(QAudioFormat::BigEndian); + typez.append(QAudioFormat::SignedInt); + typez.append(QAudioFormat::UnSignedInt); + typez.append(QAudioFormat::Float); + codecz.append(QLatin1String("audio/pcm")); + close(); +} + +QList QAudioDeviceInfoInternal::availableDevices(QAudio::Mode mode) +{ + QList allDevices; + QList devices; + QByteArray filter; + +#if(SND_LIB_MAJOR == 1 && SND_LIB_MINOR == 0 && SND_LIB_SUBMINOR >= 14) + // Create a list of all current audio devices that support mode + void **hints, **n; + char *name, *descr, *io; + + if(snd_device_name_hint(-1, "pcm", &hints) < 0) { + qWarning() << "no alsa devices available"; + return devices; + } + n = hints; + + if(mode == QAudio::AudioInput) { + filter = "Input"; + } else { + filter = "Output"; + } + + while (*n != NULL) { + name = snd_device_name_get_hint(*n, "NAME"); + if (name != 0 && qstrcmp(name, "null") != 0) { + descr = snd_device_name_get_hint(*n, "DESC"); + io = snd_device_name_get_hint(*n, "IOID"); + + if ((descr != NULL) && ((io == NULL) || (io == filter))) { + QString deviceName = QLatin1String(name); + QString deviceDescription = QLatin1String(descr); + allDevices.append(deviceName.toLocal8Bit().constData()); + if (deviceDescription.contains(QLatin1String("Default Audio Device"))) + devices.append(deviceName.toLocal8Bit().constData()); + } + + free(name); + if (descr != NULL) + free(descr); + if (io != NULL) + free(io); + } + ++n; + } + snd_device_name_free_hint(hints); + + if(devices.size() > 0) { + devices.append("default"); + } +#else + int idx = 0; + char* name; + + while(snd_card_get_name(idx,&name) == 0) { + devices.append(name); + idx++; + } + if (idx > 0) + devices.append("default"); +#endif +#if !defined(Q_WS_MAEMO_6) + if (devices.size() == 0 && allDevices.size() > 0) + return allDevices; +#endif + + return devices; +} + +QByteArray QAudioDeviceInfoInternal::defaultInputDevice() +{ + QList devices = availableDevices(QAudio::AudioInput); + if(devices.size() == 0) + return QByteArray(); + + return devices.first(); +} + +QByteArray QAudioDeviceInfoInternal::defaultOutputDevice() +{ + QList devices = availableDevices(QAudio::AudioOutput); + if(devices.size() == 0) + return QByteArray(); + + return devices.first(); +} + +void QAudioDeviceInfoInternal::checkSurround() +{ + QList devices; + surround40 = false; + surround51 = false; + surround71 = false; + + void **hints, **n; + char *name, *descr, *io; + + if(snd_device_name_hint(-1, "pcm", &hints) < 0) + return; + + n = hints; + + while (*n != NULL) { + name = snd_device_name_get_hint(*n, "NAME"); + descr = snd_device_name_get_hint(*n, "DESC"); + io = snd_device_name_get_hint(*n, "IOID"); + if((name != NULL) && (descr != NULL)) { + QString deviceName = QLatin1String(name); + if (mode == QAudio::AudioOutput) { + if(deviceName.contains(QLatin1String("surround40"))) + surround40 = true; + if(deviceName.contains(QLatin1String("surround51"))) + surround51 = true; + if(deviceName.contains(QLatin1String("surround71"))) + surround71 = true; + } + } + if(name != NULL) + free(name); + if(descr != NULL) + free(descr); + if(io != NULL) + free(io); + ++n; + } + snd_device_name_free_hint(hints); +} + +QT_END_NAMESPACE diff --git a/src/multimedia/audio/qaudiodeviceinfo_alsa_p.h b/src/multimedia/audio/qaudiodeviceinfo_alsa_p.h new file mode 100644 index 000000000..cf19d2554 --- /dev/null +++ b/src/multimedia/audio/qaudiodeviceinfo_alsa_p.h @@ -0,0 +1,129 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists for the convenience +// of other Qt classes. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + + +#ifndef QAUDIODEVICEINFOALSA_H +#define QAUDIODEVICEINFOALSA_H + +#include + +#include +#include +#include +#include + +#include "qaudio.h" +#include "qaudiodeviceinfo.h" +#include "qaudiosystem.h" + +QT_BEGIN_HEADER + +QT_BEGIN_NAMESPACE + +QT_MODULE(Multimedia) + + +const unsigned int MAX_SAMPLE_RATES = 5; +const unsigned int SAMPLE_RATES[] = + { 8000, 11025, 22050, 44100, 48000 }; + +class QAudioDeviceInfoInternal : public QAbstractAudioDeviceInfo +{ + Q_OBJECT +public: + QAudioDeviceInfoInternal(QByteArray dev,QAudio::Mode mode); + ~QAudioDeviceInfoInternal(); + + bool testSettings(const QAudioFormat& format) const; + void updateLists(); + QAudioFormat preferredFormat() const; + bool isFormatSupported(const QAudioFormat& format) const; + QString deviceName() const; + QStringList supportedCodecs(); + QList supportedSampleRates(); + QList supportedChannelCounts(); + QList supportedSampleSizes(); + QList supportedByteOrders(); + QList supportedSampleTypes(); + static QByteArray defaultInputDevice(); + static QByteArray defaultOutputDevice(); + static QList availableDevices(QAudio::Mode); + +private: + bool open(); + void close(); + + void checkSurround(); + bool surround40; + bool surround51; + bool surround71; + + QString device; + QAudio::Mode mode; + QAudioFormat nearest; + QList freqz; + QList channelz; + QList sizez; + QList byteOrderz; + QStringList codecz; + QList typez; + snd_pcm_t* handle; + snd_pcm_hw_params_t *params; +}; + +QT_END_NAMESPACE + +QT_END_HEADER + + +#endif + diff --git a/src/multimedia/audio/qaudiodeviceinfo_mac_p.cpp b/src/multimedia/audio/qaudiodeviceinfo_mac_p.cpp new file mode 100644 index 000000000..4c7779f91 --- /dev/null +++ b/src/multimedia/audio/qaudiodeviceinfo_mac_p.cpp @@ -0,0 +1,351 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists for the convenience +// of other Qt classes. This header file may change from version to +// version without notice, or even be removed. +// +// INTERNAL USE ONLY: Do NOT use for any other purpose. +// + +#include +#include +#include +#include +#include + +#include +#include "qaudio_mac_p.h" +#include "qaudiodeviceinfo_mac_p.h" + + + +QT_BEGIN_NAMESPACE + +// XXX: remove at some future date +static inline QString cfStringToQString(CFStringRef str) +{ + CFIndex length = CFStringGetLength(str); + const UniChar *chars = CFStringGetCharactersPtr(str); + if (chars) + return QString(reinterpret_cast(chars), length); + + UniChar buffer[length]; + CFStringGetCharacters(str, CFRangeMake(0, length), buffer); + return QString(reinterpret_cast(buffer), length); +} + +QAudioDeviceInfoInternal::QAudioDeviceInfoInternal(QByteArray const& handle, QAudio::Mode) +{ + QDataStream ds(handle); + quint32 did, tm; + + ds >> did >> tm >> name; + deviceId = AudioDeviceID(did); + mode = QAudio::Mode(tm); +} + +bool QAudioDeviceInfoInternal::isFormatSupported(const QAudioFormat& format) const +{ + QAudioDeviceInfoInternal *self = const_cast(this); + + return format.isValid() + && format.codec() == QString::fromLatin1("audio/pcm") + && self->supportedSampleRates().contains(format.sampleRate()) + && self->supportedChannelCounts().contains(format.channelCount()) + && self->supportedSampleSizes().contains(format.sampleSize()); +} + +QAudioFormat QAudioDeviceInfoInternal::preferredFormat() const +{ + QAudioFormat rc; + + UInt32 propSize = 0; + + if (AudioDeviceGetPropertyInfo(deviceId, + 0, + mode == QAudio::AudioInput, + kAudioDevicePropertyStreams, + &propSize, + 0) == noErr) { + + const int sc = propSize / sizeof(AudioStreamID); + + if (sc > 0) { + AudioStreamID* streams = new AudioStreamID[sc]; + + if (AudioDeviceGetProperty(deviceId, + 0, + mode == QAudio::AudioInput, + kAudioDevicePropertyStreams, + &propSize, + streams) == noErr) { + + for (int i = 0; i < sc; ++i) { + if (AudioStreamGetPropertyInfo(streams[i], + 0, + kAudioStreamPropertyPhysicalFormat, + &propSize, + 0) == noErr) { + + AudioStreamBasicDescription sf; + + if (AudioStreamGetProperty(streams[i], + 0, + kAudioStreamPropertyPhysicalFormat, + &propSize, + &sf) == noErr) { + rc = toQAudioFormat(sf); + break; + } + } + } + } + + delete streams; + } + } + + return rc; +} + +QString QAudioDeviceInfoInternal::deviceName() const +{ + return name; +} + +QStringList QAudioDeviceInfoInternal::supportedCodecs() +{ + return QStringList() << QString::fromLatin1("audio/pcm"); +} + +QList QAudioDeviceInfoInternal::supportedSampleRates() +{ + QSet rc; + + // Add some common frequencies + rc << 8000 << 11025 << 22050 << 44100; + + // + UInt32 propSize = 0; + + if (AudioDeviceGetPropertyInfo(deviceId, + 0, + mode == QAudio::AudioInput, + kAudioDevicePropertyAvailableNominalSampleRates, + &propSize, + 0) == noErr) { + + const int pc = propSize / sizeof(AudioValueRange); + + if (pc > 0) { + AudioValueRange* vr = new AudioValueRange[pc]; + + if (AudioDeviceGetProperty(deviceId, + 0, + mode == QAudio::AudioInput, + kAudioDevicePropertyAvailableNominalSampleRates, + &propSize, + vr) == noErr) { + + for (int i = 0; i < pc; ++i) + rc << vr[i].mMaximum; + } + + delete vr; + } + } + + return rc.toList(); +} + +QList QAudioDeviceInfoInternal::supportedChannelCounts() +{ + QList rc; + + // Can mix down to 1 channel + rc << 1; + + UInt32 propSize = 0; + int channels = 0; + + if (AudioDeviceGetPropertyInfo(deviceId, + 0, + mode == QAudio::AudioInput, + kAudioDevicePropertyStreamConfiguration, + &propSize, + 0) == noErr) { + + AudioBufferList* audioBufferList = static_cast(qMalloc(propSize)); + + if (audioBufferList != 0) { + if (AudioDeviceGetProperty(deviceId, + 0, + mode == QAudio::AudioInput, + kAudioDevicePropertyStreamConfiguration, + &propSize, + audioBufferList) == noErr) { + + for (int i = 0; i < int(audioBufferList->mNumberBuffers); ++i) { + channels += audioBufferList->mBuffers[i].mNumberChannels; + rc << channels; + } + } + + qFree(audioBufferList); + } + } + + return rc; +} + +QList QAudioDeviceInfoInternal::supportedSampleSizes() +{ + return QList() << 8 << 16 << 24 << 32 << 64; +} + +QList QAudioDeviceInfoInternal::supportedByteOrders() +{ + return QList() << QAudioFormat::LittleEndian << QAudioFormat::BigEndian; +} + +QList QAudioDeviceInfoInternal::supportedSampleTypes() +{ + return QList() << QAudioFormat::SignedInt << QAudioFormat::UnSignedInt << QAudioFormat::Float; +} + +static QByteArray get_device_info(AudioDeviceID audioDevice, QAudio::Mode mode) +{ + UInt32 size; + QByteArray device; + QDataStream ds(&device, QIODevice::WriteOnly); + AudioStreamBasicDescription sf; + CFStringRef name; + Boolean isInput = mode == QAudio::AudioInput; + + // Id + ds << quint32(audioDevice); + + // Mode + size = sizeof(AudioStreamBasicDescription); + if (AudioDeviceGetProperty(audioDevice, 0, isInput, kAudioDevicePropertyStreamFormat, + &size, &sf) != noErr) { + return QByteArray(); + } + ds << quint32(mode); + + // Name + size = sizeof(CFStringRef); + if (AudioDeviceGetProperty(audioDevice, 0, isInput, kAudioObjectPropertyName, + &size, &name) != noErr) { + qWarning() << "QAudioDeviceInfo: Unable to find device name"; + return QByteArray(); + } + ds << cfStringToQString(name); + + CFRelease(name); + + return device; +} + +QByteArray QAudioDeviceInfoInternal::defaultInputDevice() +{ + AudioDeviceID audioDevice; + UInt32 size = sizeof(audioDevice); + + if (AudioHardwareGetProperty(kAudioHardwarePropertyDefaultInputDevice, &size, + &audioDevice) != noErr) { + qWarning() << "QAudioDeviceInfo: Unable to find default input device"; + return QByteArray(); + } + + return get_device_info(audioDevice, QAudio::AudioInput); +} + +QByteArray QAudioDeviceInfoInternal::defaultOutputDevice() +{ + AudioDeviceID audioDevice; + UInt32 size = sizeof(audioDevice); + + if (AudioHardwareGetProperty(kAudioHardwarePropertyDefaultOutputDevice, &size, + &audioDevice) != noErr) { + qWarning() << "QAudioDeviceInfo: Unable to find default output device"; + return QByteArray(); + } + + return get_device_info(audioDevice, QAudio::AudioOutput); +} + +QList QAudioDeviceInfoInternal::availableDevices(QAudio::Mode mode) +{ + QList devices; + + UInt32 propSize = 0; + + if (AudioHardwareGetPropertyInfo(kAudioHardwarePropertyDevices, &propSize, 0) == noErr) { + + const int dc = propSize / sizeof(AudioDeviceID); + + if (dc > 0) { + AudioDeviceID* audioDevices = new AudioDeviceID[dc]; + + if (AudioHardwareGetProperty(kAudioHardwarePropertyDevices, &propSize, audioDevices) == noErr) { + for (int i = 0; i < dc; ++i) { + QByteArray info = get_device_info(audioDevices[i], mode); + if (!info.isNull()) + devices << info; + } + } + + delete audioDevices; + } + } + + return devices; +} + + +QT_END_NAMESPACE + diff --git a/src/multimedia/audio/qaudiodeviceinfo_mac_p.h b/src/multimedia/audio/qaudiodeviceinfo_mac_p.h new file mode 100644 index 000000000..3b9ca4676 --- /dev/null +++ b/src/multimedia/audio/qaudiodeviceinfo_mac_p.h @@ -0,0 +1,99 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists for the convenience +// of other Qt classes. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + + +#ifndef QDEVICEINFO_MAC_P_H +#define QDEVICEINFO_MAC_P_H + +#include + +#include + +QT_BEGIN_HEADER + +QT_BEGIN_NAMESPACE + +QT_MODULE(Multimedia) + + +class QAudioDeviceInfoInternal : public QAbstractAudioDeviceInfo +{ +public: + AudioDeviceID deviceId; + QString name; + QAudio::Mode mode; + + QAudioDeviceInfoInternal(QByteArray const& handle, QAudio::Mode mode); + + bool isFormatSupported(const QAudioFormat& format) const; + QAudioFormat preferredFormat() const; + + QString deviceName() const; + + QStringList supportedCodecs(); + QList supportedSampleRates(); + QList supportedChannelCounts(); + QList supportedSampleSizes(); + QList supportedByteOrders(); + QList supportedSampleTypes(); + + static QByteArray defaultInputDevice(); + static QByteArray defaultOutputDevice(); + + static QList availableDevices(QAudio::Mode mode); +}; + +QT_END_NAMESPACE + +QT_END_HEADER + +#endif // QDEVICEINFO_MAC_P_H diff --git a/src/multimedia/audio/qaudiodeviceinfo_win32_p.cpp b/src/multimedia/audio/qaudiodeviceinfo_win32_p.cpp new file mode 100644 index 000000000..10b9b777d --- /dev/null +++ b/src/multimedia/audio/qaudiodeviceinfo_win32_p.cpp @@ -0,0 +1,465 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists for the convenience +// of other Qt classes. This header file may change from version to +// version without notice, or even be removed. +// +// INTERNAL USE ONLY: Do NOT use for any other purpose. +// + + +#include +#include +#include "qaudiodeviceinfo_win32_p.h" +#include + +#if defined(Q_CC_MINGW) + +extern GUID CLSID_AudioInputDeviceCategory; + +#ifndef __IErrorLog_INTERFACE_DEFINED__ +#define __IErrorLog_INTERFACE_DEFINED__ + +DECLARE_INTERFACE_(IErrorLog, IUnknown) +{ + STDMETHOD(AddError)(THIS_ LPCOLESTR, EXCEPINFO *) PURE; +}; + +#endif /* __IErrorLog_INTERFACE_DEFINED__ */ + +#ifndef __IPropertyBag_INTERFACE_DEFINED__ +#define __IPropertyBag_INTERFACE_DEFINED__ + +const GUID IID_IPropertyBag = {0x55272A00, 0x42CB, 0x11CE, {0x81, 0x35, 0x00, 0xAA, 0x00, 0x4B, 0xB8, 0x51}}; + +DECLARE_INTERFACE_(IPropertyBag, IUnknown) +{ + STDMETHOD(Read)(THIS_ LPCOLESTR, VARIANT *, IErrorLog *) PURE; + STDMETHOD(Write)(THIS_ LPCOLESTR, VARIANT *) PURE; +}; + +#endif /* __IPropertyBag_INTERFACE_DEFINED__ */ + +#endif//Q_CC_MINGW + +QT_BEGIN_NAMESPACE + +// For mingw toolchain mmsystem.h only defines half the defines, so add if needed. +#ifndef WAVE_FORMAT_44M08 +#define WAVE_FORMAT_44M08 0x00000100 +#define WAVE_FORMAT_44S08 0x00000200 +#define WAVE_FORMAT_44M16 0x00000400 +#define WAVE_FORMAT_44S16 0x00000800 +#define WAVE_FORMAT_48M08 0x00001000 +#define WAVE_FORMAT_48S08 0x00002000 +#define WAVE_FORMAT_48M16 0x00004000 +#define WAVE_FORMAT_48S16 0x00008000 +#define WAVE_FORMAT_96M08 0x00010000 +#define WAVE_FORMAT_96S08 0x00020000 +#define WAVE_FORMAT_96M16 0x00040000 +#define WAVE_FORMAT_96S16 0x00080000 +#endif + + +QAudioDeviceInfoInternal::QAudioDeviceInfoInternal(QByteArray dev, QAudio::Mode mode) +{ + QDataStream ds(&dev, QIODevice::ReadOnly); + ds >> devId >> device; + this->mode = mode; + + updateLists(); +} + +QAudioDeviceInfoInternal::~QAudioDeviceInfoInternal() +{ + close(); +} + +bool QAudioDeviceInfoInternal::isFormatSupported(const QAudioFormat& format) const +{ + return testSettings(format); +} + +QAudioFormat QAudioDeviceInfoInternal::preferredFormat() const +{ + QAudioFormat nearest; + if(mode == QAudio::AudioOutput) { + nearest.setFrequency(44100); + nearest.setChannelCount(2); + nearest.setByteOrder(QAudioFormat::LittleEndian); + nearest.setSampleType(QAudioFormat::SignedInt); + nearest.setSampleSize(16); + nearest.setCodec(QLatin1String("audio/pcm")); + } else { + nearest.setFrequency(11025); + nearest.setChannelCount(1); + nearest.setByteOrder(QAudioFormat::LittleEndian); + nearest.setSampleType(QAudioFormat::SignedInt); + nearest.setSampleSize(8); + nearest.setCodec(QLatin1String("audio/pcm")); + } + return nearest; +} + +QString QAudioDeviceInfoInternal::deviceName() const +{ + return device; +} + +QStringList QAudioDeviceInfoInternal::supportedCodecs() +{ + updateLists(); + return codecz; +} + +QList QAudioDeviceInfoInternal::supportedSampleRates() +{ + updateLists(); + return freqz; +} + +QList QAudioDeviceInfoInternal::supportedChannelCounts() +{ + updateLists(); + return channelz; +} + +QList QAudioDeviceInfoInternal::supportedSampleSizes() +{ + updateLists(); + return sizez; +} + +QList QAudioDeviceInfoInternal::supportedByteOrders() +{ + updateLists(); + return byteOrderz; +} + +QList QAudioDeviceInfoInternal::supportedSampleTypes() +{ + updateLists(); + return typez; +} + + +bool QAudioDeviceInfoInternal::open() +{ + return true; +} + +void QAudioDeviceInfoInternal::close() +{ +} + +bool QAudioDeviceInfoInternal::testSettings(const QAudioFormat& format) const +{ + // Set nearest to closest settings that do work. + // See if what is in settings will work (return value). + + bool failed = false; + bool match = false; + + // check codec + for( int i = 0; i < codecz.count(); i++) { + if (format.codec() == codecz.at(i)) + match = true; + } + if (!match) failed = true; + + // check channel + match = false; + if (!failed) { + for( int i = 0; i < channelz.count(); i++) { + if (format.channels() == channelz.at(i)) { + match = true; + break; + } + } + if (!match) + failed = true; + } + + // check frequency + match = false; + if (!failed) { + for( int i = 0; i < freqz.count(); i++) { + if (format.frequency() == freqz.at(i)) { + match = true; + break; + } + } + if (!match) + failed = true; + } + + // check sample size + match = false; + if (!failed) { + for( int i = 0; i < sizez.count(); i++) { + if (format.sampleSize() == sizez.at(i)) { + match = true; + break; + } + } + if (!match) + failed = true; + } + + // check byte order + match = false; + if (!failed) { + for( int i = 0; i < byteOrderz.count(); i++) { + if (format.byteOrder() == byteOrderz.at(i)) { + match = true; + break; + } + } + if (!match) + failed = true; + } + + // check sample type + match = false; + if (!failed) { + for( int i = 0; i < typez.count(); i++) { + if (format.sampleType() == typez.at(i)) { + match = true; + break; + } + } + if (!match) + failed = true; + } + + if(!failed) { + // settings work + return true; + } + return false; +} + +void QAudioDeviceInfoInternal::updateLists() +{ + // redo all lists based on current settings + bool match = false; + DWORD fmt = NULL; + + if(mode == QAudio::AudioOutput) { + WAVEOUTCAPS woc; + if (waveOutGetDevCaps(devId, &woc, sizeof(WAVEOUTCAPS)) == MMSYSERR_NOERROR) { + match = true; + fmt = woc.dwFormats; + } + } else { + WAVEINCAPS woc; + if (waveInGetDevCaps(devId, &woc, sizeof(WAVEINCAPS)) == MMSYSERR_NOERROR) { + match = true; + fmt = woc.dwFormats; + } + } + sizez.clear(); + freqz.clear(); + channelz.clear(); + byteOrderz.clear(); + typez.clear(); + codecz.clear(); + + if(match) { + if((fmt && WAVE_FORMAT_1M08) + || (fmt && WAVE_FORMAT_1S08) + || (fmt && WAVE_FORMAT_2M08) + || (fmt && WAVE_FORMAT_2S08) + || (fmt && WAVE_FORMAT_4M08) + || (fmt && WAVE_FORMAT_4S08) + || (fmt && WAVE_FORMAT_48M08) + || (fmt && WAVE_FORMAT_48S08) + || (fmt && WAVE_FORMAT_96M08) + || (fmt && WAVE_FORMAT_96S08) + ) { + sizez.append(8); + } + if((fmt && WAVE_FORMAT_1M16) + || (fmt && WAVE_FORMAT_1S16) + || (fmt && WAVE_FORMAT_2M16) + || (fmt && WAVE_FORMAT_2S16) + || (fmt && WAVE_FORMAT_4M16) + || (fmt && WAVE_FORMAT_4S16) + || (fmt && WAVE_FORMAT_48M16) + || (fmt && WAVE_FORMAT_48S16) + || (fmt && WAVE_FORMAT_96M16) + || (fmt && WAVE_FORMAT_96S16) + ) { + sizez.append(16); + } + if((fmt && WAVE_FORMAT_1M08) + || (fmt && WAVE_FORMAT_1S08) + || (fmt && WAVE_FORMAT_1M16) + || (fmt && WAVE_FORMAT_1S16)) { + freqz.append(11025); + } + if((fmt && WAVE_FORMAT_2M08) + || (fmt && WAVE_FORMAT_2S08) + || (fmt && WAVE_FORMAT_2M16) + || (fmt && WAVE_FORMAT_2S16)) { + freqz.append(22050); + } + if((fmt && WAVE_FORMAT_4M08) + || (fmt && WAVE_FORMAT_4S08) + || (fmt && WAVE_FORMAT_4M16) + || (fmt && WAVE_FORMAT_4S16)) { + freqz.append(44100); + } + if((fmt && WAVE_FORMAT_48M08) + || (fmt && WAVE_FORMAT_48S08) + || (fmt && WAVE_FORMAT_48M16) + || (fmt && WAVE_FORMAT_48S16)) { + freqz.append(48000); + } + if((fmt && WAVE_FORMAT_96M08) + || (fmt && WAVE_FORMAT_96S08) + || (fmt && WAVE_FORMAT_96M16) + || (fmt && WAVE_FORMAT_96S16)) { + freqz.append(96000); + } + channelz.append(1); + channelz.append(2); + if (mode == QAudio::AudioOutput) { + channelz.append(4); + channelz.append(6); + channelz.append(8); + } + + byteOrderz.append(QAudioFormat::LittleEndian); + + typez.append(QAudioFormat::SignedInt); + typez.append(QAudioFormat::UnSignedInt); + + codecz.append(QLatin1String("audio/pcm")); + } + if (freqz.count() > 0) + freqz.prepend(8000); +} + +QList QAudioDeviceInfoInternal::availableDevices(QAudio::Mode mode) +{ + Q_UNUSED(mode) + + QList devices; + //enumerate device fullnames through directshow api + CoInitialize(NULL); + ICreateDevEnum *pDevEnum = NULL; + IEnumMoniker *pEnum = NULL; + // Create the System device enumerator + HRESULT hr = CoCreateInstance(CLSID_SystemDeviceEnum, NULL, + CLSCTX_INPROC_SERVER, IID_ICreateDevEnum, + reinterpret_cast(&pDevEnum)); + + unsigned long iNumDevs = mode == QAudio::AudioOutput ? waveOutGetNumDevs() : waveInGetNumDevs(); + if (SUCCEEDED(hr)) { + // Create the enumerator for the audio input/output category + if (pDevEnum->CreateClassEnumerator( + mode == QAudio::AudioOutput ? CLSID_AudioRendererCategory : CLSID_AudioInputDeviceCategory, + &pEnum, 0) == S_OK) { + pEnum->Reset(); + // go through and find all audio devices + IMoniker *pMoniker = NULL; + while (pEnum->Next(1, &pMoniker, NULL) == S_OK) { + IPropertyBag *pPropBag; + hr = pMoniker->BindToStorage(0,0,IID_IPropertyBag, + reinterpret_cast(&pPropBag)); + if (FAILED(hr)) { + pMoniker->Release(); + continue; // skip this one + } + // Find if it is a wave device + VARIANT var; + VariantInit(&var); + hr = pPropBag->Read(mode == QAudio::AudioOutput ? L"WaveOutID" : L"WaveInID", &var, 0); + if (SUCCEEDED(hr)) { + LONG waveID = var.lVal; + if (waveID >= 0 && waveID < LONG(iNumDevs)) { + VariantClear(&var); + // Find the description + hr = pPropBag->Read(L"FriendlyName", &var, 0); + if (SUCCEEDED(hr)) { + QByteArray device; + QDataStream ds(&device, QIODevice::WriteOnly); + ds << quint32(waveID) << QString::fromWCharArray(var.bstrVal); + devices.append(device); + } + } + } + + pPropBag->Release(); + pMoniker->Release(); + } + } + } + CoUninitialize(); + + return devices; +} + +QByteArray QAudioDeviceInfoInternal::defaultOutputDevice() +{ + QList list = availableDevices(QAudio::AudioOutput); + if (list.size() > 0) + return list.at(0); + else + return QByteArray(); +} + +QByteArray QAudioDeviceInfoInternal::defaultInputDevice() +{ + QList list = availableDevices(QAudio::AudioInput); + if (list.size() > 0) + return list.at(0); + else + return QByteArray(); +} + +QT_END_NAMESPACE diff --git a/src/multimedia/audio/qaudiodeviceinfo_win32_p.h b/src/multimedia/audio/qaudiodeviceinfo_win32_p.h new file mode 100644 index 000000000..2d4e27106 --- /dev/null +++ b/src/multimedia/audio/qaudiodeviceinfo_win32_p.h @@ -0,0 +1,120 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists for the convenience +// of other Qt classes. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + + +#ifndef QAUDIODEVICEINFOWIN_H +#define QAUDIODEVICEINFOWIN_H + +#include +#include +#include +#include + +#include +#include + + +QT_BEGIN_HEADER + +QT_BEGIN_NAMESPACE + +QT_MODULE(Multimedia) + + +const unsigned int MAX_SAMPLE_RATES = 5; +const unsigned int SAMPLE_RATES[] = { 8000, 11025, 22050, 44100, 48000 }; + +class QAudioDeviceInfoInternal : public QAbstractAudioDeviceInfo +{ + Q_OBJECT + +public: + QAudioDeviceInfoInternal(QByteArray dev,QAudio::Mode mode); + ~QAudioDeviceInfoInternal(); + + bool open(); + void close(); + + bool testSettings(const QAudioFormat& format) const; + void updateLists(); + QAudioFormat preferredFormat() const; + bool isFormatSupported(const QAudioFormat& format) const; + QString deviceName() const; + QStringList supportedCodecs(); + QList supportedSampleRates(); + QList supportedChannelCounts(); + QList supportedSampleSizes(); + QList supportedByteOrders(); + QList supportedSampleTypes(); + static QByteArray defaultInputDevice(); + static QByteArray defaultOutputDevice(); + static QList availableDevices(QAudio::Mode); + +private: + QAudio::Mode mode; + QString device; + quint32 devId; + QAudioFormat nearest; + QList freqz; + QList channelz; + QList sizez; + QList byteOrderz; + QStringList codecz; + QList typez; +}; + +QT_END_NAMESPACE + +QT_END_HEADER + + +#endif diff --git a/src/multimedia/audio/qaudioformat.cpp b/src/multimedia/audio/qaudioformat.cpp new file mode 100644 index 000000000..6ed72516c --- /dev/null +++ b/src/multimedia/audio/qaudioformat.cpp @@ -0,0 +1,407 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include +#include + + +QT_BEGIN_NAMESPACE + + +class QAudioFormatPrivate : public QSharedData +{ +public: + QAudioFormatPrivate() + { + frequency = -1; + channels = -1; + sampleSize = -1; + byteOrder = QAudioFormat::Endian(QSysInfo::ByteOrder); + sampleType = QAudioFormat::Unknown; + } + + QAudioFormatPrivate(const QAudioFormatPrivate &other): + QSharedData(other), + codec(other.codec), + byteOrder(other.byteOrder), + sampleType(other.sampleType), + frequency(other.frequency), + channels(other.channels), + sampleSize(other.sampleSize) + { + } + + QAudioFormatPrivate& operator=(const QAudioFormatPrivate &other) + { + codec = other.codec; + byteOrder = other.byteOrder; + sampleType = other.sampleType; + frequency = other.frequency; + channels = other.channels; + sampleSize = other.sampleSize; + + return *this; + } + + QString codec; + QAudioFormat::Endian byteOrder; + QAudioFormat::SampleType sampleType; + int frequency; + int channels; + int sampleSize; +}; + +/*! + \class QAudioFormat + \brief The QAudioFormat class stores audio stream parameter information. + + \inmodule QtMultimedia + \ingroup multimedia + \since 1.0 + + An audio format specifies how data in an audio stream is arranged, + i.e, how the stream is to be interpreted. The encoding itself is + specified by the codec() used for the stream. + + In addition to the encoding, QAudioFormat contains other + parameters that further specify how the audio sample data is arranged. + These are the frequency, the number of channels, the sample size, + the sample type, and the byte order. The following table describes + these in more detail. + + \table + \header + \o Parameter + \o Description + \row + \o Sample Rate + \o Samples per second of audio data in Hertz. + \row + \o Number of channels + \o The number of audio channels (typically one for mono + or two for stereo) + \row + \o Sample size + \o How much data is stored in each sample (typically 8 + or 16 bits) + \row + \o Sample type + \o Numerical representation of sample (typically signed integer, + unsigned integer or float) + \row + \o Byte order + \o Byte ordering of sample (typically little endian, big endian) + \endtable + + This class is typically used in conjunction with QAudioInput or + QAudioOutput to allow you to specify the parameters of the audio + stream being read or written. + + You can obtain audio formats compatible with the audio device used + through functions in QAudioDeviceInfo. This class also lets you + query available parameter values for a device, so that you can set + the parameters yourself. See the \l QAudioDeviceInfo class + description for details. You need to know the format of the audio + streams you wish to play or record. +*/ + +/*! + Construct a new audio format. + + Values are initialized as follows: + \list + \o sampleRate() = -1 + \o channelCount() = -1 + \o sampleSize() = -1 + \o byteOrder() = QAudioFormat::Endian(QSysInfo::ByteOrder) + \o sampleType() = QAudioFormat::Unknown + \c codec() = "" + \endlist +*/ +QAudioFormat::QAudioFormat(): + d(new QAudioFormatPrivate) +{ +} + +/*! + Construct a new audio format using \a other. + \since 1.0 +*/ +QAudioFormat::QAudioFormat(const QAudioFormat &other): + d(other.d) +{ +} + +/*! + Destroy this audio format. +*/ +QAudioFormat::~QAudioFormat() +{ +} + +/*! + Assigns \a other to this QAudioFormat implementation. + \since 1.0 +*/ +QAudioFormat& QAudioFormat::operator=(const QAudioFormat &other) +{ + d = other.d; + return *this; +} + +/*! + Returns true if this QAudioFormat is equal to the \a other + QAudioFormat; otherwise returns false. + + All elements of QAudioFormat are used for the comparison. + \since 1.0 +*/ +bool QAudioFormat::operator==(const QAudioFormat &other) const +{ + return d->frequency == other.d->frequency && + d->channels == other.d->channels && + d->sampleSize == other.d->sampleSize && + d->byteOrder == other.d->byteOrder && + d->codec == other.d->codec && + d->sampleType == other.d->sampleType; +} + +/*! + Returns true if this QAudioFormat is not equal to the \a other + QAudioFormat; otherwise returns false. + + All elements of QAudioFormat are used for the comparison. + \since 1.0 +*/ +bool QAudioFormat::operator!=(const QAudioFormat& other) const +{ + return !(*this == other); +} + +/*! + Returns true if all of the parameters are valid. + \since 1.0 +*/ +bool QAudioFormat::isValid() const +{ + return d->frequency != -1 && d->channels != -1 && d->sampleSize != -1 && + d->sampleType != QAudioFormat::Unknown && !d->codec.isEmpty(); +} + +/*! + Sets the sample rate to \a samplerate Hertz. + + \since 1.0 +*/ +void QAudioFormat::setSampleRate(int samplerate) +{ + d->frequency = samplerate; +} + +/*! + \obsolete + + Use setSampleRate() instead. +*/ +void QAudioFormat::setFrequency(int frequency) +{ + d->frequency = frequency; +} + +/*! + Returns the current sample rate in Hertz. + + \since 1.0 +*/ +int QAudioFormat::sampleRate() const +{ + return d->frequency; +} + +/*! + \obsolete + + Use sampleRate() instead. +*/ +int QAudioFormat::frequency() const +{ + return d->frequency; +} + +/*! + Sets the channel count to \a channels. + + \since 1.0 +*/ +void QAudioFormat::setChannelCount(int channels) +{ + d->channels = channels; +} + +/*! + \obsolete + + Use setChannelCount() instead. +*/ +void QAudioFormat::setChannels(int channels) +{ + d->channels = channels; +} + +/*! + Returns the current channel count value. + + \since 1.0 +*/ +int QAudioFormat::channelCount() const +{ + return d->channels; +} + +/*! + \obsolete + + Use channelCount() instead. +*/ +int QAudioFormat::channels() const +{ + return d->channels; +} + +/*! + Sets the sample size to the \a sampleSize specified, in bits. + + This is typically 8 or 16, but some systems may support higher sample sizes. + \since 1.0 +*/ +void QAudioFormat::setSampleSize(int sampleSize) +{ + d->sampleSize = sampleSize; +} + +/*! + Returns the current sample size value, in bits. + \since 1.0 +*/ +int QAudioFormat::sampleSize() const +{ + return d->sampleSize; +} + +/*! + Sets the codec to \a codec. + + The parameter to this function should be one of the types + reported by the QAudioDeviceInfo::supportedCodecs() function + for the audio device you are working with. + + \since 1.0 + \sa QAudioDeviceInfo::supportedCodecs() +*/ +void QAudioFormat::setCodec(const QString &codec) +{ + d->codec = codec; +} + +/*! + Returns the current codec identifier. + + \since 1.0 + \sa QAudioDeviceInfo::supportedCodecs() +*/ +QString QAudioFormat::codec() const +{ + return d->codec; +} + +/*! + Sets the byteOrder to \a byteOrder. + \since 1.0 +*/ +void QAudioFormat::setByteOrder(QAudioFormat::Endian byteOrder) +{ + d->byteOrder = byteOrder; +} + +/*! + Returns the current byteOrder value. + \since 1.0 +*/ +QAudioFormat::Endian QAudioFormat::byteOrder() const +{ + return d->byteOrder; +} + +/*! + Sets the sampleType to \a sampleType. + \since 1.0 +*/ +void QAudioFormat::setSampleType(QAudioFormat::SampleType sampleType) +{ + d->sampleType = sampleType; +} + +/*! + Returns the current SampleType value. + \since 1.0 +*/ +QAudioFormat::SampleType QAudioFormat::sampleType() const +{ + return d->sampleType; +} + +/*! + \enum QAudioFormat::SampleType + + \value Unknown Not Set + \value SignedInt Samples are signed integers + \value UnSignedInt Samples are unsigned intergers + \value Float Samples are floats +*/ + +/*! + \enum QAudioFormat::Endian + + \value BigEndian Samples are big endian byte order + \value LittleEndian Samples are little endian byte order +*/ + +QT_END_NAMESPACE + diff --git a/src/multimedia/audio/qaudioformat.h b/src/multimedia/audio/qaudioformat.h new file mode 100644 index 000000000..087a16a9d --- /dev/null +++ b/src/multimedia/audio/qaudioformat.h @@ -0,0 +1,109 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + + +#ifndef QAUDIOFORMAT_H +#define QAUDIOFORMAT_H + +#include +#include + +#include +#include + +QT_BEGIN_HEADER + +QT_BEGIN_NAMESPACE + +QT_MODULE(Multimedia) + + + +class QAudioFormatPrivate; + +class Q_MULTIMEDIA_EXPORT QAudioFormat +{ +public: + enum SampleType { Unknown, SignedInt, UnSignedInt, Float }; + enum Endian { BigEndian = QSysInfo::BigEndian, LittleEndian = QSysInfo::LittleEndian }; + + QAudioFormat(); + QAudioFormat(const QAudioFormat &other); + ~QAudioFormat(); + + QAudioFormat& operator=(const QAudioFormat &other); + bool operator==(const QAudioFormat &other) const; + bool operator!=(const QAudioFormat &other) const; + + bool isValid() const; + + void setFrequency(int frequency); + int frequency() const; + void setSampleRate(int sampleRate); + int sampleRate() const; + + void setChannels(int channels); + int channels() const; + void setChannelCount(int channelCount); + int channelCount() const; + + void setSampleSize(int sampleSize); + int sampleSize() const; + + void setCodec(const QString &codec); + QString codec() const; + + void setByteOrder(QAudioFormat::Endian byteOrder); + QAudioFormat::Endian byteOrder() const; + + void setSampleType(QAudioFormat::SampleType sampleType); + QAudioFormat::SampleType sampleType() const; + +private: + QSharedDataPointer d; +}; + + +QT_END_NAMESPACE + +QT_END_HEADER + +#endif // QAUDIOFORMAT_H diff --git a/src/multimedia/audio/qaudioinput.cpp b/src/multimedia/audio/qaudioinput.cpp new file mode 100644 index 000000000..2a5cefcc5 --- /dev/null +++ b/src/multimedia/audio/qaudioinput.cpp @@ -0,0 +1,402 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + + +#include "qaudio.h" +#include "qaudiodeviceinfo.h" +#include "qaudiosystem.h" +#include "qaudioinput.h" + +#include "qaudiodevicefactory_p.h" + +QT_BEGIN_NAMESPACE + +/*! + \class QAudioInput + \brief The QAudioInput class provides an interface for receiving audio data from an audio input device. + + \inmodule QtMultimedia + \ingroup multimedia + \since 1.0 + + You can construct an audio input with the system's + \l{QAudioDeviceInfo::defaultInputDevice()}{default audio input + device}. It is also possible to create QAudioInput with a + specific QAudioDeviceInfo. When you create the audio input, you + should also send in the QAudioFormat to be used for the recording + (see the QAudioFormat class description for details). + + To record to a file: + + QAudioInput lets you record audio with an audio input device. The + default constructor of this class will use the systems default + audio device, but you can also specify a QAudioDeviceInfo for a + specific device. You also need to pass in the QAudioFormat in + which you wish to record. + + Starting up the QAudioInput is simply a matter of calling start() + with a QIODevice opened for writing. For instance, to record to a + file, you can: + + \snippet doc/src/snippets/multimedia-snippets/audio.cpp Audio input class members + + \snippet doc/src/snippets/multimedia-snippets/audio.cpp Audio input setup + + This will start recording if the format specified is supported by + the input device (you can check this with + QAudioDeviceInfo::isFormatSupported(). In case there are any + snags, use the error() function to check what went wrong. We stop + recording in the \c stopRecording() slot. + + \snippet doc/src/snippets/multimedia-snippets/audio.cpp Audio input stop recording + + At any point in time, QAudioInput will be in one of four states: + active, suspended, stopped, or idle. These states are specified by + the QAudio::State enum. You can request a state change directly through + suspend(), resume(), stop(), reset(), and start(). The current + state is reported by state(). QAudioOutput will also signal you + when the state changes (stateChanged()). + + QAudioInput provides several ways of measuring the time that has + passed since the start() of the recording. The \c processedUSecs() + function returns the length of the stream in microseconds written, + i.e., it leaves out the times the audio input was suspended or idle. + The elapsedUSecs() function returns the time elapsed since start() was called regardless of + which states the QAudioInput has been in. + + If an error should occur, you can fetch its reason with error(). + The possible error reasons are described by the QAudio::Error + enum. The QAudioInput will enter the \l{QAudio::}{StoppedState} when + an error is encountered. Connect to the stateChanged() signal to + handle the error: + + \snippet doc/src/snippets/multimedia-snippets/audio.cpp Audio input state changed + + \sa QAudioOutput, QAudioDeviceInfo +*/ + +/*! + Construct a new audio input and attach it to \a parent. + The default audio input device is used with the output + \a format parameters. + \since 1.0 +*/ + +QAudioInput::QAudioInput(const QAudioFormat &format, QObject *parent): + QObject(parent) +{ + d = QAudioDeviceFactory::createDefaultInputDevice(format); + connect(d, SIGNAL(notify()), SIGNAL(notify())); + connect(d, SIGNAL(stateChanged(QAudio::State)), SIGNAL(stateChanged(QAudio::State))); +} + +/*! + Construct a new audio input and attach it to \a parent. + The device referenced by \a audioDevice is used with the input + \a format parameters. + \since 1.0 +*/ + +QAudioInput::QAudioInput(const QAudioDeviceInfo &audioDevice, const QAudioFormat &format, QObject *parent): + QObject(parent) +{ + d = QAudioDeviceFactory::createInputDevice(audioDevice, format); + connect(d, SIGNAL(notify()), SIGNAL(notify())); + connect(d, SIGNAL(stateChanged(QAudio::State)), SIGNAL(stateChanged(QAudio::State))); +} + +/*! + Destroy this audio input. +*/ + +QAudioInput::~QAudioInput() +{ + delete d; +} + +/*! + Uses the \a device as the QIODevice to transfer data. + Passing a QIODevice allows the data to be transferred without any extra code. + All that is required is to open the QIODevice. + + If able to successfully get audio data from the systems audio device the + state() is set to either QAudio::ActiveState or QAudio::IdleState, + error() is set to QAudio::NoError and the stateChanged() signal is emitted. + + If a problem occurs during this process the error() is set to QAudio::OpenError, + state() is set to QAudio::StoppedState and stateChanged() signal is emitted. + + \since 1.0 + \sa QIODevice +*/ + +void QAudioInput::start(QIODevice* device) +{ + d->start(device); +} + +/*! + Returns a pointer to the QIODevice being used to handle the data + transfer. This QIODevice can be used to read() audio data + directly. + + If able to access the systems audio device the state() is set to + QAudio::IdleState, error() is set to QAudio::NoError + and the stateChanged() signal is emitted. + + If a problem occurs during this process the error() is set to QAudio::OpenError, + state() is set to QAudio::StoppedState and stateChanged() signal is emitted. + + \since 1.0 + \sa QIODevice +*/ + +QIODevice* QAudioInput::start() +{ + return d->start(); +} + +/*! + Returns the QAudioFormat being used. + \since 1.0 +*/ + +QAudioFormat QAudioInput::format() const +{ + return d->format(); +} + +/*! + Stops the audio input, detaching from the system resource. + + Sets error() to QAudio::NoError, state() to QAudio::StoppedState and + emit stateChanged() signal. + \since 1.0 +*/ + +void QAudioInput::stop() +{ + d->stop(); +} + +/*! + Drops all audio data in the buffers, resets buffers to zero. + \since 1.0 +*/ + +void QAudioInput::reset() +{ + d->reset(); +} + +/*! + Stops processing audio data, preserving buffered audio data. + + Sets error() to QAudio::NoError, state() to QAudio::SuspendedState and + emit stateChanged() signal. + \since 1.0 +*/ + +void QAudioInput::suspend() +{ + d->suspend(); +} + +/*! + Resumes processing audio data after a suspend(). + + Sets error() to QAudio::NoError. + Sets state() to QAudio::ActiveState if you previously called start(QIODevice*). + Sets state() to QAudio::IdleState if you previously called start(). + emits stateChanged() signal. + \since 1.0 +*/ + +void QAudioInput::resume() +{ + d->resume(); +} + +/*! + Sets the audio buffer size to \a value milliseconds. + + Note: This function can be called anytime before start(), calls to this + are ignored after start(). It should not be assumed that the buffer size + set is the actual buffer size used, calling bufferSize() anytime after start() + will return the actual buffer size being used. + + \since 1.0 +*/ + +void QAudioInput::setBufferSize(int value) +{ + d->setBufferSize(value); +} + +/*! + Returns the audio buffer size in milliseconds. + + If called before start(), returns platform default value. + If called before start() but setBufferSize() was called prior, returns value set by setBufferSize(). + If called after start(), returns the actual buffer size being used. This may not be what was set previously + by setBufferSize(). + + \since 1.0 +*/ + +int QAudioInput::bufferSize() const +{ + return d->bufferSize(); +} + +/*! + Returns the amount of audio data available to read in bytes. + + NOTE: returned value is only valid while in QAudio::ActiveState or QAudio::IdleState + state, otherwise returns zero. + \since 1.0 +*/ + +int QAudioInput::bytesReady() const +{ + /* + -If not ActiveState|IdleState, return 0 + -return amount of audio data available to read + */ + return d->bytesReady(); +} + +/*! + Returns the period size in bytes. + + Note: This is the recommended read size in bytes. + \since 1.0 +*/ + +int QAudioInput::periodSize() const +{ + return d->periodSize(); +} + +/*! + Sets the interval for notify() signal to be emitted. + This is based on the \a ms of audio data processed + not on actual real-time. + The minimum resolution of the timer is platform specific and values + should be checked with notifyInterval() to confirm actual value + being used. + \since 1.0 +*/ + +void QAudioInput::setNotifyInterval(int ms) +{ + d->setNotifyInterval(ms); +} + +/*! + Returns the notify interval in milliseconds. + \since 1.0 +*/ + +int QAudioInput::notifyInterval() const +{ + return d->notifyInterval(); +} + +/*! + Returns the amount of audio data processed since start() + was called in microseconds. + \since 1.0 +*/ + +qint64 QAudioInput::processedUSecs() const +{ + return d->processedUSecs(); +} + +/*! + Returns the microseconds since start() was called, including time in Idle and + Suspend states. + \since 1.0 +*/ + +qint64 QAudioInput::elapsedUSecs() const +{ + return d->elapsedUSecs(); +} + +/*! + Returns the error state. + \since 1.0 +*/ + +QAudio::Error QAudioInput::error() const +{ + return d->error(); +} + +/*! + Returns the state of audio processing. + \since 1.0 +*/ + +QAudio::State QAudioInput::state() const +{ + return d->state(); +} + +/*! + \fn QAudioInput::stateChanged(QAudio::State state) + This signal is emitted when the device \a state has changed. + \since 1.0 +*/ + +/*! + \fn QAudioInput::notify() + This signal is emitted when x ms of audio data has been processed + the interval set by setNotifyInterval(x). + \since 1.0 +*/ + +QT_END_NAMESPACE + +#include "moc_qaudioinput.cpp" + diff --git a/src/multimedia/audio/qaudioinput.h b/src/multimedia/audio/qaudioinput.h new file mode 100644 index 000000000..9c893ce95 --- /dev/null +++ b/src/multimedia/audio/qaudioinput.h @@ -0,0 +1,114 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + + +#ifndef QAUDIOINPUT_H +#define QAUDIOINPUT_H + +#include + +#include +#include + +#include +#include +#include + + +QT_BEGIN_HEADER + +QT_BEGIN_NAMESPACE + +QT_MODULE(Multimedia) + + + +class QAbstractAudioInput; + +class Q_MULTIMEDIA_EXPORT QAudioInput : public QObject +{ + Q_OBJECT + +public: + explicit QAudioInput(const QAudioFormat &format = QAudioFormat(), QObject *parent = 0); + explicit QAudioInput(const QAudioDeviceInfo &audioDeviceInfo, const QAudioFormat &format = QAudioFormat(), QObject *parent = 0); + ~QAudioInput(); + + QAudioFormat format() const; + + void start(QIODevice *device); + QIODevice* start(); + + void stop(); + void reset(); + void suspend(); + void resume(); + + void setBufferSize(int bytes); + int bufferSize() const; + + int bytesReady() const; + int periodSize() const; + + void setNotifyInterval(int milliSeconds); + int notifyInterval() const; + + qint64 processedUSecs() const; + qint64 elapsedUSecs() const; + + QAudio::Error error() const; + QAudio::State state() const; + +Q_SIGNALS: + void stateChanged(QAudio::State); + void notify(); + +private: + Q_DISABLE_COPY(QAudioInput) + + QAbstractAudioInput* d; +}; + +QT_END_NAMESPACE + +QT_END_HEADER + +#endif // QAUDIOINPUT_H diff --git a/src/multimedia/audio/qaudioinput_alsa_p.cpp b/src/multimedia/audio/qaudioinput_alsa_p.cpp new file mode 100644 index 000000000..044458cd0 --- /dev/null +++ b/src/multimedia/audio/qaudioinput_alsa_p.cpp @@ -0,0 +1,867 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists for the convenience +// of other Qt classes. This header file may change from version to +// version without notice, or even be removed. +// +// INTERNAL USE ONLY: Do NOT use for any other purpose. +// + +#include +#include "qaudioinput_alsa_p.h" +#include "qaudiodeviceinfo_alsa_p.h" + +QT_BEGIN_NAMESPACE + +//#define DEBUG_AUDIO 1 + +QAudioInputPrivate::QAudioInputPrivate(const QByteArray &device) +{ + bytesAvailable = 0; + handle = 0; + ahandler = 0; + access = SND_PCM_ACCESS_RW_INTERLEAVED; + pcmformat = SND_PCM_FORMAT_S16; + buffer_size = 0; + period_size = 0; + buffer_time = 100000; + period_time = 20000; + totalTimeValue = 0; + intervalTime = 1000; + errorState = QAudio::NoError; + deviceState = QAudio::StoppedState; + audioSource = 0; + pullMode = true; + resuming = false; + + m_device = device; + + timer = new QTimer(this); + connect(timer,SIGNAL(timeout()),SLOT(userFeed())); +} + +QAudioInputPrivate::~QAudioInputPrivate() +{ + close(); + disconnect(timer, SIGNAL(timeout())); + QCoreApplication::processEvents(); + delete timer; +} + +QAudio::Error QAudioInputPrivate::error() const +{ + return errorState; +} + +QAudio::State QAudioInputPrivate::state() const +{ + return deviceState; +} + +void QAudioInputPrivate::setFormat(const QAudioFormat& fmt) +{ + if (deviceState == QAudio::StoppedState) + settings = fmt; +} + +QAudioFormat QAudioInputPrivate::format() const +{ + return settings; +} + +int QAudioInputPrivate::xrun_recovery(int err) +{ + int count = 0; + bool reset = false; + + if(err == -EPIPE) { + errorState = QAudio::UnderrunError; + err = snd_pcm_prepare(handle); + if(err < 0) + reset = true; + else { + bytesAvailable = checkBytesReady(); + if (bytesAvailable <= 0) + reset = true; + } + + } else if((err == -ESTRPIPE)||(err == -EIO)) { + errorState = QAudio::IOError; + while((err = snd_pcm_resume(handle)) == -EAGAIN){ + usleep(100); + count++; + if(count > 5) { + reset = true; + break; + } + } + if(err < 0) { + err = snd_pcm_prepare(handle); + if(err < 0) + reset = true; + } + } + if(reset) { + close(); + open(); + snd_pcm_prepare(handle); + return 0; + } + return err; +} + +int QAudioInputPrivate::setFormat() +{ + snd_pcm_format_t format = SND_PCM_FORMAT_UNKNOWN; + + if(settings.sampleSize() == 8) { + format = SND_PCM_FORMAT_U8; + } else if(settings.sampleSize() == 16) { + if(settings.sampleType() == QAudioFormat::SignedInt) { + if(settings.byteOrder() == QAudioFormat::LittleEndian) + format = SND_PCM_FORMAT_S16_LE; + else + format = SND_PCM_FORMAT_S16_BE; + } else if(settings.sampleType() == QAudioFormat::UnSignedInt) { + if(settings.byteOrder() == QAudioFormat::LittleEndian) + format = SND_PCM_FORMAT_U16_LE; + else + format = SND_PCM_FORMAT_U16_BE; + } + } else if(settings.sampleSize() == 24) { + if(settings.sampleType() == QAudioFormat::SignedInt) { + if(settings.byteOrder() == QAudioFormat::LittleEndian) + format = SND_PCM_FORMAT_S24_LE; + else + format = SND_PCM_FORMAT_S24_BE; + } else if(settings.sampleType() == QAudioFormat::UnSignedInt) { + if(settings.byteOrder() == QAudioFormat::LittleEndian) + format = SND_PCM_FORMAT_U24_LE; + else + format = SND_PCM_FORMAT_U24_BE; + } + } else if(settings.sampleSize() == 32) { + if(settings.sampleType() == QAudioFormat::SignedInt) { + if(settings.byteOrder() == QAudioFormat::LittleEndian) + format = SND_PCM_FORMAT_S32_LE; + else + format = SND_PCM_FORMAT_S32_BE; + } else if(settings.sampleType() == QAudioFormat::UnSignedInt) { + if(settings.byteOrder() == QAudioFormat::LittleEndian) + format = SND_PCM_FORMAT_U32_LE; + else + format = SND_PCM_FORMAT_U32_BE; + } else if(settings.sampleType() == QAudioFormat::Float) { + if(settings.byteOrder() == QAudioFormat::LittleEndian) + format = SND_PCM_FORMAT_FLOAT_LE; + else + format = SND_PCM_FORMAT_FLOAT_BE; + } + } else if(settings.sampleSize() == 64) { + if(settings.byteOrder() == QAudioFormat::LittleEndian) + format = SND_PCM_FORMAT_FLOAT64_LE; + else + format = SND_PCM_FORMAT_FLOAT64_BE; + } + + return format != SND_PCM_FORMAT_UNKNOWN + ? snd_pcm_hw_params_set_format( handle, hwparams, format) + : -1; +} + +void QAudioInputPrivate::start(QIODevice* device) +{ + if(deviceState != QAudio::StoppedState) + close(); + + if(!pullMode && audioSource) + delete audioSource; + + pullMode = true; + audioSource = device; + + deviceState = QAudio::ActiveState; + + if( !open() ) + return; + + emit stateChanged(deviceState); +} + +QIODevice* QAudioInputPrivate::start() +{ + if(deviceState != QAudio::StoppedState) + close(); + + if(!pullMode && audioSource) + delete audioSource; + + pullMode = false; + audioSource = new InputPrivate(this); + audioSource->open(QIODevice::ReadOnly | QIODevice::Unbuffered); + + deviceState = QAudio::IdleState; + + if( !open() ) + return 0; + + emit stateChanged(deviceState); + + return audioSource; +} + +void QAudioInputPrivate::stop() +{ + if(deviceState == QAudio::StoppedState) + return; + + deviceState = QAudio::StoppedState; + + close(); + emit stateChanged(deviceState); +} + +bool QAudioInputPrivate::open() +{ +#ifdef DEBUG_AUDIO + QTime now(QTime::currentTime()); + qDebug()< devices = QAudioDeviceInfoInternal::availableDevices(QAudio::AudioInput); + if(dev.compare(QLatin1String("default")) == 0) { +#if(SND_LIB_MAJOR == 1 && SND_LIB_MINOR == 0 && SND_LIB_SUBMINOR >= 14) + if (devices.size() > 0) + dev = QLatin1String(devices.first()); + else + return false; +#else + dev = QLatin1String("hw:0,0"); +#endif + } else { +#if(SND_LIB_MAJOR == 1 && SND_LIB_MINOR == 0 && SND_LIB_SUBMINOR >= 14) + dev = QLatin1String(m_device); +#else + int idx = 0; + char *name; + + QString shortName = QLatin1String(m_device.mid(m_device.indexOf('=',0)+1).constData()); + + while(snd_card_get_name(idx,&name) == 0) { + if(qstrncmp(shortName.toLocal8Bit().constData(),name,shortName.length()) == 0) + break; + idx++; + } + dev = QString(QLatin1String("hw:%1,0")).arg(idx); +#endif + } + + // Step 1: try and open the device + while((count < 5) && (err < 0)) { + err=snd_pcm_open(&handle,dev.toLocal8Bit().constData(),SND_PCM_STREAM_CAPTURE,0); + if(err < 0) + count++; + } + if (( err < 0)||(handle == 0)) { + errorState = QAudio::OpenError; + deviceState = QAudio::StoppedState; + emit stateChanged(deviceState); + return false; + } + snd_pcm_nonblock( handle, 0 ); + + // Step 2: Set the desired HW parameters. + snd_pcm_hw_params_alloca( &hwparams ); + + bool fatal = false; + QString errMessage; + unsigned int chunks = 8; + + err = snd_pcm_hw_params_any( handle, hwparams ); + if ( err < 0 ) { + fatal = true; + errMessage = QString::fromLatin1("QAudioInput: snd_pcm_hw_params_any: err = %1").arg(err); + } + if ( !fatal ) { + err = snd_pcm_hw_params_set_rate_resample( handle, hwparams, 1 ); + if ( err < 0 ) { + fatal = true; + errMessage = QString::fromLatin1("QAudioInput: snd_pcm_hw_params_set_rate_resample: err = %1").arg(err); + } + } + if ( !fatal ) { + err = snd_pcm_hw_params_set_access( handle, hwparams, access ); + if ( err < 0 ) { + fatal = true; + errMessage = QString::fromLatin1("QAudioInput: snd_pcm_hw_params_set_access: err = %1").arg(err); + } + } + if ( !fatal ) { + err = setFormat(); + if ( err < 0 ) { + fatal = true; + errMessage = QString::fromLatin1("QAudioInput: snd_pcm_hw_params_set_format: err = %1").arg(err); + } + } + if ( !fatal ) { + err = snd_pcm_hw_params_set_channels( handle, hwparams, (unsigned int)settings.channels() ); + if ( err < 0 ) { + fatal = true; + errMessage = QString::fromLatin1("QAudioInput: snd_pcm_hw_params_set_channels: err = %1").arg(err); + } + } + if ( !fatal ) { + err = snd_pcm_hw_params_set_rate_near( handle, hwparams, &freakuency, 0 ); + if ( err < 0 ) { + fatal = true; + errMessage = QString::fromLatin1("QAudioInput: snd_pcm_hw_params_set_rate_near: err = %1").arg(err); + } + } + if ( !fatal ) { + err = snd_pcm_hw_params_set_buffer_time_near(handle, hwparams, &buffer_time, &dir); + if ( err < 0 ) { + fatal = true; + errMessage = QString::fromLatin1("QAudioInput: snd_pcm_hw_params_set_buffer_time_near: err = %1").arg(err); + } + } + if ( !fatal ) { + err = snd_pcm_hw_params_set_period_time_near(handle, hwparams, &period_time, &dir); + if ( err < 0 ) { + fatal = true; + errMessage = QString::fromLatin1("QAudioInput: snd_pcm_hw_params_set_period_time_near: err = %1").arg(err); + } + } + if ( !fatal ) { + err = snd_pcm_hw_params_set_periods_near(handle, hwparams, &chunks, &dir); + if ( err < 0 ) { + fatal = true; + errMessage = QString::fromLatin1("QAudioInput: snd_pcm_hw_params_set_periods_near: err = %1").arg(err); + } + } + if ( !fatal ) { + err = snd_pcm_hw_params(handle, hwparams); + if ( err < 0 ) { + fatal = true; + errMessage = QString::fromLatin1("QAudioInput: snd_pcm_hw_params: err = %1").arg(err); + } + } + if( err < 0) { + qWarning()<start(period_time*chunks/2000); + + errorState = QAudio::NoError; + + totalTimeValue = 0; + + return true; +} + +void QAudioInputPrivate::close() +{ + timer->stop(); + + if ( handle ) { + snd_pcm_drop( handle ); + snd_pcm_close( handle ); + handle = 0; + } +} + +int QAudioInputPrivate::checkBytesReady() +{ + if(resuming) + bytesAvailable = period_size; + else if(deviceState != QAudio::ActiveState + && deviceState != QAudio::IdleState) + bytesAvailable = 0; + else { + int frames = snd_pcm_avail_update(handle); + if (frames < 0) { + bytesAvailable = frames; + } else { + if((int)frames > (int)buffer_frames) + frames = buffer_frames; + bytesAvailable = snd_pcm_frames_to_bytes(handle, frames); + } + } + return bytesAvailable; +} + +int QAudioInputPrivate::bytesReady() const +{ + return qMax(bytesAvailable, 0); +} + +qint64 QAudioInputPrivate::read(char* data, qint64 len) +{ + // Read in some audio data and write it to QIODevice, pull mode + if ( !handle ) + return 0; + + int bytesRead = 0; + int bytesInRingbufferBeforeRead = ringBuffer.bytesOfDataInBuffer(); + + if (ringBuffer.bytesOfDataInBuffer() < len) { + + // bytesAvaiable is saved as a side effect of checkBytesReady(). + int bytesToRead = checkBytesReady(); + + if (bytesToRead < 0) { + // bytesAvailable as negative is error code, try to recover from it. + xrun_recovery(bytesToRead); + bytesToRead = checkBytesReady(); + if (bytesToRead < 0) { + // recovery failed must stop and set error. + close(); + errorState = QAudio::IOError; + deviceState = QAudio::StoppedState; + emit stateChanged(deviceState); + return 0; + } + } + + bytesToRead = qMin(len, bytesToRead); + bytesToRead = qMin(ringBuffer.freeBytes(), bytesToRead); + bytesToRead -= bytesToRead % period_size; + + int count=0; + int err = 0; + while(count < 5 && bytesToRead > 0) { + char buffer[bytesToRead]; + int chunks = bytesToRead / period_size; + int frames = chunks * period_frames; + if (frames > (int)buffer_frames) + frames = buffer_frames; + + int readFrames = snd_pcm_readi(handle, buffer, frames); + + if (readFrames >= 0) { + bytesRead = snd_pcm_frames_to_bytes(handle, readFrames); + ringBuffer.write(buffer, bytesRead); +#ifdef DEBUG_AUDIO + qDebug() << QString::fromLatin1("read in bytes = %1 (frames=%2)").arg(bytesRead).arg(readFrames).toLatin1().constData(); +#endif + break; + } else if((readFrames == -EAGAIN) || (readFrames == -EINTR)) { + errorState = QAudio::IOError; + err = 0; + break; + } else { + if(readFrames == -EPIPE) { + errorState = QAudio::UnderrunError; + err = snd_pcm_prepare(handle); + } else if(readFrames == -ESTRPIPE) { + err = snd_pcm_prepare(handle); + } + if(err != 0) break; + } + count++; + } + + } + + bytesRead += bytesInRingbufferBeforeRead; + + if (bytesRead > 0) { + // got some send it onward +#ifdef DEBUG_AUDIO + qDebug() << "frames to write to QIODevice = " << + snd_pcm_bytes_to_frames( handle, (int)bytesRead ) << " (" << bytesRead << ") bytes"; +#endif + if (deviceState != QAudio::ActiveState && deviceState != QAudio::IdleState) + return 0; + + if (pullMode) { + qint64 l = 0; + qint64 bytesWritten = 0; + while (ringBuffer.bytesOfDataInBuffer() > 0) { + l = audioSource->write(ringBuffer.availableData(), ringBuffer.availableDataBlockSize()); + if (l > 0) { + ringBuffer.readBytes(l); + bytesWritten += l; + } else { + break; + } + } + + if (l < 0) { + close(); + errorState = QAudio::IOError; + deviceState = QAudio::StoppedState; + emit stateChanged(deviceState); + } else if (l == 0 && bytesWritten == 0) { + if (deviceState != QAudio::IdleState) { + errorState = QAudio::NoError; + deviceState = QAudio::IdleState; + emit stateChanged(deviceState); + } + } else { + bytesAvailable -= bytesWritten; + totalTimeValue += bytesWritten; + resuming = false; + if (deviceState != QAudio::ActiveState) { + errorState = QAudio::NoError; + deviceState = QAudio::ActiveState; + emit stateChanged(deviceState); + } + } + + return bytesWritten; + } else { + while (ringBuffer.bytesOfDataInBuffer() > 0) { + int size = ringBuffer.availableDataBlockSize(); + memcpy(data, ringBuffer.availableData(), size); + data += size; + ringBuffer.readBytes(size); + } + + bytesAvailable -= bytesRead; + totalTimeValue += bytesRead; + resuming = false; + if (deviceState != QAudio::ActiveState) { + errorState = QAudio::NoError; + deviceState = QAudio::ActiveState; + emit stateChanged(deviceState); + } + + return bytesRead; + } + } + + return 0; +} + +void QAudioInputPrivate::resume() +{ + if(deviceState == QAudio::SuspendedState) { + int err = 0; + + if(handle) { + err = snd_pcm_prepare( handle ); + if(err < 0) + xrun_recovery(err); + + err = snd_pcm_start(handle); + if(err < 0) + xrun_recovery(err); + + bytesAvailable = buffer_size; + } + resuming = true; + deviceState = QAudio::ActiveState; + int chunks = buffer_size/period_size; + timer->start(period_time*chunks/2000); + emit stateChanged(deviceState); + } +} + +void QAudioInputPrivate::setBufferSize(int value) +{ + buffer_size = value; +} + +int QAudioInputPrivate::bufferSize() const +{ + return buffer_size; +} + +int QAudioInputPrivate::periodSize() const +{ + return period_size; +} + +void QAudioInputPrivate::setNotifyInterval(int ms) +{ + intervalTime = qMax(0, ms); +} + +int QAudioInputPrivate::notifyInterval() const +{ + return intervalTime; +} + +qint64 QAudioInputPrivate::processedUSecs() const +{ + qint64 result = qint64(1000000) * totalTimeValue / + (settings.channels()*(settings.sampleSize()/8)) / + settings.frequency(); + + return result; +} + +void QAudioInputPrivate::suspend() +{ + if(deviceState == QAudio::ActiveState||resuming) { + timer->stop(); + deviceState = QAudio::SuspendedState; + emit stateChanged(deviceState); + } +} + +void QAudioInputPrivate::userFeed() +{ + if(deviceState == QAudio::StoppedState || deviceState == QAudio::SuspendedState) + return; +#ifdef DEBUG_AUDIO + QTime now(QTime::currentTime()); + qDebug()<(audioSource); + a->trigger(); + } + bytesAvailable = checkBytesReady(); + + if(deviceState != QAudio::ActiveState) + return true; + + if (bytesAvailable < 0) { + // bytesAvailable as negative is error code, try to recover from it. + xrun_recovery(bytesAvailable); + bytesAvailable = checkBytesReady(); + if (bytesAvailable < 0) { + // recovery failed must stop and set error. + close(); + errorState = QAudio::IOError; + deviceState = QAudio::StoppedState; + emit stateChanged(deviceState); + return 0; + } + } + + if(intervalTime && (timeStamp.elapsed() + elapsedTimeOffset) > intervalTime) { + emit notify(); + elapsedTimeOffset = timeStamp.elapsed() + elapsedTimeOffset - intervalTime; + timeStamp.restart(); + } + return true; +} + +qint64 QAudioInputPrivate::elapsedUSecs() const +{ + if (deviceState == QAudio::StoppedState) + return 0; + + return clockStamp.elapsed()*1000; +} + +void QAudioInputPrivate::reset() +{ + if(handle) + snd_pcm_reset(handle); + stop(); + bytesAvailable = 0; +} + +void QAudioInputPrivate::drain() +{ + if(handle) + snd_pcm_drain(handle); +} + +InputPrivate::InputPrivate(QAudioInputPrivate* audio) +{ + audioDevice = qobject_cast(audio); +} + +InputPrivate::~InputPrivate() +{ +} + +qint64 InputPrivate::readData( char* data, qint64 len) +{ + return audioDevice->read(data,len); +} + +qint64 InputPrivate::writeData(const char* data, qint64 len) +{ + Q_UNUSED(data) + Q_UNUSED(len) + return 0; +} + +void InputPrivate::trigger() +{ + emit readyRead(); +} + +RingBuffer::RingBuffer() : + m_head(0), + m_tail(0) +{ +} + +void RingBuffer::resize(int size) +{ + m_data.resize(size); +} + +int RingBuffer::bytesOfDataInBuffer() const +{ + if (m_head < m_tail) + return m_tail - m_head; + else if (m_tail < m_head) + return m_data.size() + m_tail - m_head; + else + return 0; +} + +int RingBuffer::freeBytes() const +{ + if (m_head > m_tail) + return m_head - m_tail - 1; + else if (m_tail > m_head) + return m_data.size() - m_tail + m_head - 1; + else + return m_data.size() - 1; +} + +const char *RingBuffer::availableData() const +{ + return (m_data.constData() + m_head); +} + +int RingBuffer::availableDataBlockSize() const +{ + if (m_head > m_tail) + return m_data.size() - m_head; + else if (m_tail > m_head) + return m_tail - m_head; + else + return 0; +} + +void RingBuffer::readBytes(int bytes) +{ + m_head = (m_head + bytes) % m_data.size(); +} + +void RingBuffer::write(char *data, int len) +{ + if (m_tail + len < m_data.size()) { + memcpy(m_data.data() + m_tail, data, len); + m_tail += len; + } else { + int bytesUntilEnd = m_data.size() - m_tail; + memcpy(m_data.data() + m_tail, data, bytesUntilEnd); + if (len - bytesUntilEnd > 0) + memcpy(m_data.data(), data + bytesUntilEnd, len - bytesUntilEnd); + m_tail = len - bytesUntilEnd; + } +} + +QT_END_NAMESPACE + +#include "moc_qaudioinput_alsa_p.cpp" diff --git a/src/multimedia/audio/qaudioinput_alsa_p.h b/src/multimedia/audio/qaudioinput_alsa_p.h new file mode 100644 index 000000000..a05f6954d --- /dev/null +++ b/src/multimedia/audio/qaudioinput_alsa_p.h @@ -0,0 +1,191 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists for the convenience +// of other Qt classes. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + + +#ifndef QAUDIOINPUTALSA_H +#define QAUDIOINPUTALSA_H + +#include + +#include +#include +#include +#include +#include +#include + +#include "qaudio.h" +#include "qaudiodeviceinfo.h" +#include "qaudiosystem.h" + +QT_BEGIN_HEADER + +QT_BEGIN_NAMESPACE + +QT_MODULE(Multimedia) + + +class InputPrivate; + +class RingBuffer +{ +public: + RingBuffer(); + + void resize(int size); + + int bytesOfDataInBuffer() const; + int freeBytes() const; + + const char *availableData() const; + int availableDataBlockSize() const; + void readBytes(int bytes); + + void write(char *data, int len); + +private: + int m_head; + int m_tail; + + QByteArray m_data; +}; + +class QAudioInputPrivate : public QAbstractAudioInput +{ + Q_OBJECT +public: + QAudioInputPrivate(const QByteArray &device); + ~QAudioInputPrivate(); + + qint64 read(char* data, qint64 len); + + void start(QIODevice* device); + QIODevice* start(); + void stop(); + void reset(); + void suspend(); + void resume(); + int bytesReady() const; + int periodSize() const; + void setBufferSize(int value); + int bufferSize() const; + void setNotifyInterval(int milliSeconds); + int notifyInterval() const; + qint64 processedUSecs() const; + qint64 elapsedUSecs() const; + QAudio::Error error() const; + QAudio::State state() const; + void setFormat(const QAudioFormat& fmt); + QAudioFormat format() const; + bool resuming; + snd_pcm_t* handle; + qint64 totalTimeValue; + QIODevice* audioSource; + QAudioFormat settings; + QAudio::Error errorState; + QAudio::State deviceState; + +private slots: + void userFeed(); + bool deviceReady(); + +private: + int checkBytesReady(); + int xrun_recovery(int err); + int setFormat(); + bool open(); + void close(); + void drain(); + + QTimer* timer; + QTime timeStamp; + QTime clockStamp; + qint64 elapsedTimeOffset; + int intervalTime; + RingBuffer ringBuffer; + int bytesAvailable; + QByteArray m_device; + bool pullMode; + int buffer_size; + int period_size; + unsigned int buffer_time; + unsigned int period_time; + snd_pcm_uframes_t buffer_frames; + snd_pcm_uframes_t period_frames; + snd_async_handler_t* ahandler; + snd_pcm_access_t access; + snd_pcm_format_t pcmformat; + snd_timestamp_t* timestamp; + snd_pcm_hw_params_t *hwparams; +}; + +class InputPrivate : public QIODevice +{ + Q_OBJECT +public: + InputPrivate(QAudioInputPrivate* audio); + ~InputPrivate(); + + qint64 readData( char* data, qint64 len); + qint64 writeData(const char* data, qint64 len); + + void trigger(); +private: + QAudioInputPrivate *audioDevice; +}; + +QT_END_NAMESPACE + +QT_END_HEADER + + +#endif diff --git a/src/multimedia/audio/qaudioinput_mac_p.cpp b/src/multimedia/audio/qaudioinput_mac_p.cpp new file mode 100644 index 000000000..184935add --- /dev/null +++ b/src/multimedia/audio/qaudioinput_mac_p.cpp @@ -0,0 +1,989 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists for the convenience +// of other Qt classes. This header file may change from version to +// version without notice, or even be removed. +// +// INTERNAL USE ONLY: Do NOT use for any other purpose. +// + +#include +#include +#include + +#include + +#include "qaudio_mac_p.h" +#include "qaudioinput_mac_p.h" +#include "qaudiodeviceinfo_mac_p.h" + +QT_BEGIN_NAMESPACE + + +namespace QtMultimediaInternal +{ + +static const int default_buffer_size = 4 * 1024; + +class QAudioBufferList +{ +public: + QAudioBufferList(AudioStreamBasicDescription const& streamFormat): + owner(false), + sf(streamFormat) + { + const bool isInterleaved = (sf.mFormatFlags & kAudioFormatFlagIsNonInterleaved) == 0; + const int numberOfBuffers = isInterleaved ? 1 : sf.mChannelsPerFrame; + + dataSize = 0; + + bfs = reinterpret_cast(qMalloc(sizeof(AudioBufferList) + + (sizeof(AudioBuffer) * numberOfBuffers))); + + bfs->mNumberBuffers = numberOfBuffers; + for (int i = 0; i < numberOfBuffers; ++i) { + bfs->mBuffers[i].mNumberChannels = isInterleaved ? numberOfBuffers : 1; + bfs->mBuffers[i].mDataByteSize = 0; + bfs->mBuffers[i].mData = 0; + } + } + + QAudioBufferList(AudioStreamBasicDescription const& streamFormat, char* buffer, int bufferSize): + owner(false), + sf(streamFormat), + bfs(0) + { + dataSize = bufferSize; + + bfs = reinterpret_cast(qMalloc(sizeof(AudioBufferList) + sizeof(AudioBuffer))); + + bfs->mNumberBuffers = 1; + bfs->mBuffers[0].mNumberChannels = 1; + bfs->mBuffers[0].mDataByteSize = dataSize; + bfs->mBuffers[0].mData = buffer; + } + + QAudioBufferList(AudioStreamBasicDescription const& streamFormat, int framesToBuffer): + owner(true), + sf(streamFormat), + bfs(0) + { + const bool isInterleaved = (sf.mFormatFlags & kAudioFormatFlagIsNonInterleaved) == 0; + const int numberOfBuffers = isInterleaved ? 1 : sf.mChannelsPerFrame; + + dataSize = framesToBuffer * sf.mBytesPerFrame; + + bfs = reinterpret_cast(qMalloc(sizeof(AudioBufferList) + + (sizeof(AudioBuffer) * numberOfBuffers))); + bfs->mNumberBuffers = numberOfBuffers; + for (int i = 0; i < numberOfBuffers; ++i) { + bfs->mBuffers[i].mNumberChannels = isInterleaved ? numberOfBuffers : 1; + bfs->mBuffers[i].mDataByteSize = dataSize; + bfs->mBuffers[i].mData = qMalloc(dataSize); + } + } + + ~QAudioBufferList() + { + if (owner) { + for (UInt32 i = 0; i < bfs->mNumberBuffers; ++i) + qFree(bfs->mBuffers[i].mData); + } + + qFree(bfs); + } + + AudioBufferList* audioBufferList() const + { + return bfs; + } + + char* data(int buffer = 0) const + { + return static_cast(bfs->mBuffers[buffer].mData); + } + + qint64 bufferSize(int buffer = 0) const + { + return bfs->mBuffers[buffer].mDataByteSize; + } + + int frameCount(int buffer = 0) const + { + return bfs->mBuffers[buffer].mDataByteSize / sf.mBytesPerFrame; + } + + int packetCount(int buffer = 0) const + { + return bfs->mBuffers[buffer].mDataByteSize / sf.mBytesPerPacket; + } + + int packetSize() const + { + return sf.mBytesPerPacket; + } + + void reset() + { + for (UInt32 i = 0; i < bfs->mNumberBuffers; ++i) { + bfs->mBuffers[i].mDataByteSize = dataSize; + bfs->mBuffers[i].mData = 0; + } + } + +private: + bool owner; + int dataSize; + AudioStreamBasicDescription sf; + AudioBufferList* bfs; +}; + +class QAudioPacketFeeder +{ +public: + QAudioPacketFeeder(QAudioBufferList* abl): + audioBufferList(abl) + { + totalPackets = audioBufferList->packetCount(); + position = 0; + } + + bool feed(AudioBufferList& dst, UInt32& packetCount) + { + if (position == totalPackets) { + dst.mBuffers[0].mDataByteSize = 0; + packetCount = 0; + return false; + } + + if (totalPackets - position < packetCount) + packetCount = totalPackets - position; + + dst.mBuffers[0].mDataByteSize = packetCount * audioBufferList->packetSize(); + dst.mBuffers[0].mData = audioBufferList->data() + (position * audioBufferList->packetSize()); + + position += packetCount; + + return true; + } + + bool empty() const + { + return position == totalPackets; + } + +private: + UInt32 totalPackets; + UInt32 position; + QAudioBufferList* audioBufferList; +}; + +class QAudioInputBuffer : public QObject +{ + Q_OBJECT + +public: + QAudioInputBuffer(int bufferSize, + int maxPeriodSize, + AudioStreamBasicDescription const& inputFormat, + AudioStreamBasicDescription const& outputFormat, + QObject* parent): + QObject(parent), + m_deviceError(false), + m_audioConverter(0), + m_inputFormat(inputFormat), + m_outputFormat(outputFormat) + { + m_maxPeriodSize = maxPeriodSize; + m_periodTime = m_maxPeriodSize / m_outputFormat.mBytesPerFrame * 1000 / m_outputFormat.mSampleRate; + m_buffer = new QAudioRingBuffer(bufferSize + (bufferSize % maxPeriodSize == 0 ? 0 : maxPeriodSize - (bufferSize % maxPeriodSize))); + m_inputBufferList = new QAudioBufferList(m_inputFormat); + + m_flushTimer = new QTimer(this); + connect(m_flushTimer, SIGNAL(timeout()), SLOT(flushBuffer())); + + if (toQAudioFormat(inputFormat) != toQAudioFormat(outputFormat)) { + if (AudioConverterNew(&m_inputFormat, &m_outputFormat, &m_audioConverter) != noErr) { + qWarning() << "QAudioInput: Unable to create an Audio Converter"; + m_audioConverter = 0; + } + } + } + + ~QAudioInputBuffer() + { + delete m_buffer; + } + + qint64 renderFromDevice(AudioUnit audioUnit, + AudioUnitRenderActionFlags* ioActionFlags, + const AudioTimeStamp* inTimeStamp, + UInt32 inBusNumber, + UInt32 inNumberFrames) + { + const bool pullMode = m_device == 0; + + OSStatus err; + qint64 framesRendered = 0; + + m_inputBufferList->reset(); + err = AudioUnitRender(audioUnit, + ioActionFlags, + inTimeStamp, + inBusNumber, + inNumberFrames, + m_inputBufferList->audioBufferList()); + + if (m_audioConverter != 0) { + QAudioPacketFeeder feeder(m_inputBufferList); + + int copied = 0; + const int available = m_buffer->free(); + + while (err == noErr && !feeder.empty()) { + QAudioRingBuffer::Region region = m_buffer->acquireWriteRegion(available); + + if (region.second == 0) + break; + + AudioBufferList output; + output.mNumberBuffers = 1; + output.mBuffers[0].mNumberChannels = 1; + output.mBuffers[0].mDataByteSize = region.second; + output.mBuffers[0].mData = region.first; + + UInt32 packetSize = region.second / m_outputFormat.mBytesPerPacket; + err = AudioConverterFillComplexBuffer(m_audioConverter, + converterCallback, + &feeder, + &packetSize, + &output, + 0); + region.second = output.mBuffers[0].mDataByteSize; + copied += region.second; + + m_buffer->releaseWriteRegion(region); + } + + framesRendered += copied / m_outputFormat.mBytesPerFrame; + } + else { + const int available = m_inputBufferList->bufferSize(); + bool wecan = true; + int copied = 0; + + while (wecan && copied < available) { + QAudioRingBuffer::Region region = m_buffer->acquireWriteRegion(available - copied); + + if (region.second > 0) { + memcpy(region.first, m_inputBufferList->data() + copied, region.second); + copied += region.second; + } + else + wecan = false; + + m_buffer->releaseWriteRegion(region); + } + + framesRendered = copied / m_outputFormat.mBytesPerFrame; + } + + if (pullMode && framesRendered > 0) + emit readyRead(); + + return framesRendered; + } + + qint64 readBytes(char* data, qint64 len) + { + bool wecan = true; + qint64 bytesCopied = 0; + + len -= len % m_maxPeriodSize; + while (wecan && bytesCopied < len) { + QAudioRingBuffer::Region region = m_buffer->acquireReadRegion(len - bytesCopied); + + if (region.second > 0) { + memcpy(data + bytesCopied, region.first, region.second); + bytesCopied += region.second; + } + else + wecan = false; + + m_buffer->releaseReadRegion(region); + } + + return bytesCopied; + } + + void setFlushDevice(QIODevice* device) + { + if (m_device != device) + m_device = device; + } + + void startFlushTimer() + { + if (m_device != 0) { + m_flushTimer->start((m_buffer->size() - (m_maxPeriodSize * 2)) / m_maxPeriodSize * m_periodTime); + } + } + + void stopFlushTimer() + { + m_flushTimer->stop(); + } + + void flush(bool all = false) + { + if (m_device == 0) + return; + + const int used = m_buffer->used(); + const int readSize = all ? used : used - (used % m_maxPeriodSize); + + if (readSize > 0) { + bool wecan = true; + int flushed = 0; + + while (!m_deviceError && wecan && flushed < readSize) { + QAudioRingBuffer::Region region = m_buffer->acquireReadRegion(readSize - flushed); + + if (region.second > 0) { + int bytesWritten = m_device->write(region.first, region.second); + if (bytesWritten < 0) { + stopFlushTimer(); + m_deviceError = true; + } + else { + region.second = bytesWritten; + flushed += bytesWritten; + wecan = bytesWritten != 0; + } + } + else + wecan = false; + + m_buffer->releaseReadRegion(region); + } + } + } + + void reset() + { + m_buffer->reset(); + m_deviceError = false; + } + + int available() const + { + return m_buffer->free(); + } + + int used() const + { + return m_buffer->used(); + } + +signals: + void readyRead(); + +private slots: + void flushBuffer() + { + flush(); + } + +private: + bool m_deviceError; + int m_maxPeriodSize; + int m_periodTime; + QIODevice* m_device; + QTimer* m_flushTimer; + QAudioRingBuffer* m_buffer; + QAudioBufferList* m_inputBufferList; + AudioConverterRef m_audioConverter; + AudioStreamBasicDescription m_inputFormat; + AudioStreamBasicDescription m_outputFormat; + + const static OSStatus as_empty = 'qtem'; + + // Converter callback + static OSStatus converterCallback(AudioConverterRef inAudioConverter, + UInt32* ioNumberDataPackets, + AudioBufferList* ioData, + AudioStreamPacketDescription** outDataPacketDescription, + void* inUserData) + { + Q_UNUSED(inAudioConverter); + Q_UNUSED(outDataPacketDescription); + + QAudioPacketFeeder* feeder = static_cast(inUserData); + + if (!feeder->feed(*ioData, *ioNumberDataPackets)) + return as_empty; + + return noErr; + } +}; + + +class MacInputDevice : public QIODevice +{ + Q_OBJECT + +public: + MacInputDevice(QAudioInputBuffer* audioBuffer, QObject* parent): + QIODevice(parent), + m_audioBuffer(audioBuffer) + { + open(QIODevice::ReadOnly | QIODevice::Unbuffered); + connect(m_audioBuffer, SIGNAL(readyRead()), SIGNAL(readyRead())); + } + + qint64 readData(char* data, qint64 len) + { + return m_audioBuffer->readBytes(data, len); + } + + qint64 writeData(const char* data, qint64 len) + { + Q_UNUSED(data); + Q_UNUSED(len); + + return 0; + } + + bool isSequential() const + { + return true; + } + +private: + QAudioInputBuffer* m_audioBuffer; +}; + +} + + +QAudioInputPrivate::QAudioInputPrivate(const QByteArray& device) +{ + QDataStream ds(device); + quint32 did, mode; + + ds >> did >> mode; + + if (QAudio::Mode(mode) == QAudio::AudioOutput) + errorCode = QAudio::OpenError; + else { + audioDeviceInfo = new QAudioDeviceInfoInternal(device, QAudio::AudioInput); + isOpen = false; + audioDeviceId = AudioDeviceID(did); + audioUnit = 0; + startTime = 0; + totalFrames = 0; + audioBuffer = 0; + internalBufferSize = QtMultimediaInternal::default_buffer_size; + clockFrequency = AudioGetHostClockFrequency() / 1000; + errorCode = QAudio::NoError; + stateCode = QAudio::StoppedState; + + intervalTimer = new QTimer(this); + intervalTimer->setInterval(1000); + connect(intervalTimer, SIGNAL(timeout()), SIGNAL(notify())); + } +} + +QAudioInputPrivate::~QAudioInputPrivate() +{ + close(); + delete audioDeviceInfo; +} + +bool QAudioInputPrivate::open() +{ + UInt32 size = 0; + + if (isOpen) + return true; + + ComponentDescription cd; + cd.componentType = kAudioUnitType_Output; + cd.componentSubType = kAudioUnitSubType_HALOutput; + cd.componentManufacturer = kAudioUnitManufacturer_Apple; + cd.componentFlags = 0; + cd.componentFlagsMask = 0; + + // Open + Component cp = FindNextComponent(NULL, &cd); + if (cp == 0) { + qWarning() << "QAudioInput: Failed to find HAL Output component"; + return false; + } + + if (OpenAComponent(cp, &audioUnit) != noErr) { + qWarning() << "QAudioInput: Unable to Open Output Component"; + return false; + } + + // Set mode + // switch to input mode + UInt32 enable = 1; + if (AudioUnitSetProperty(audioUnit, + kAudioOutputUnitProperty_EnableIO, + kAudioUnitScope_Input, + 1, + &enable, + sizeof(enable)) != noErr) { + qWarning() << "QAudioInput: Unable to switch to input mode (Enable Input)"; + return false; + } + + enable = 0; + if (AudioUnitSetProperty(audioUnit, + kAudioOutputUnitProperty_EnableIO, + kAudioUnitScope_Output, + 0, + &enable, + sizeof(enable)) != noErr) { + qWarning() << "QAudioInput: Unable to switch to input mode (Disable output)"; + return false; + } + + // register callback + AURenderCallbackStruct cb; + cb.inputProc = inputCallback; + cb.inputProcRefCon = this; + + if (AudioUnitSetProperty(audioUnit, + kAudioOutputUnitProperty_SetInputCallback, + kAudioUnitScope_Global, + 0, + &cb, + sizeof(cb)) != noErr) { + qWarning() << "QAudioInput: Failed to set AudioUnit callback"; + return false; + } + + // Set Audio Device + if (AudioUnitSetProperty(audioUnit, + kAudioOutputUnitProperty_CurrentDevice, + kAudioUnitScope_Global, + 0, + &audioDeviceId, + sizeof(audioDeviceId)) != noErr) { + qWarning() << "QAudioInput: Unable to use configured device"; + return false; + } + + // Set format + // Wanted + streamFormat = toAudioStreamBasicDescription(audioFormat); + + // Required on unit + if (audioFormat == audioDeviceInfo->preferredFormat()) { + deviceFormat = streamFormat; + AudioUnitSetProperty(audioUnit, + kAudioUnitProperty_StreamFormat, + kAudioUnitScope_Output, + 1, + &deviceFormat, + sizeof(deviceFormat)); + } + else { + size = sizeof(deviceFormat); + if (AudioUnitGetProperty(audioUnit, + kAudioUnitProperty_StreamFormat, + kAudioUnitScope_Input, + 1, + &deviceFormat, + &size) != noErr) { + qWarning() << "QAudioInput: Unable to retrieve device format"; + return false; + } + + if (AudioUnitSetProperty(audioUnit, + kAudioUnitProperty_StreamFormat, + kAudioUnitScope_Output, + 1, + &deviceFormat, + sizeof(deviceFormat)) != noErr) { + qWarning() << "QAudioInput: Unable to set device format"; + return false; + } + } + + // Setup buffers + UInt32 numberOfFrames; + size = sizeof(UInt32); + if (AudioUnitGetProperty(audioUnit, + kAudioDevicePropertyBufferFrameSize, + kAudioUnitScope_Global, + 0, + &numberOfFrames, + &size) != noErr) { + qWarning() << "QAudioInput: Failed to get audio period size"; + return false; + } + + // Allocate buffer + periodSizeBytes = numberOfFrames * streamFormat.mBytesPerFrame; + + if (internalBufferSize < periodSizeBytes * 2) + internalBufferSize = periodSizeBytes * 2; + else + internalBufferSize -= internalBufferSize % streamFormat.mBytesPerFrame; + + audioBuffer = new QtMultimediaInternal::QAudioInputBuffer(internalBufferSize, + periodSizeBytes, + deviceFormat, + streamFormat, + this); + + audioIO = new QtMultimediaInternal::MacInputDevice(audioBuffer, this); + + // Init + if (AudioUnitInitialize(audioUnit) != noErr) { + qWarning() << "QAudioInput: Failed to initialize AudioUnit"; + return false; + } + + isOpen = true; + + return isOpen; +} + +void QAudioInputPrivate::close() +{ + if (audioUnit != 0) { + AudioOutputUnitStop(audioUnit); + AudioUnitUninitialize(audioUnit); + CloseComponent(audioUnit); + } + + delete audioBuffer; +} + +QAudioFormat QAudioInputPrivate::format() const +{ + return audioFormat; +} + +void QAudioInputPrivate::setFormat(const QAudioFormat& fmt) +{ + if (stateCode == QAudio::StoppedState) + audioFormat = fmt; +} + +void QAudioInputPrivate::start(QIODevice* device) +{ + QIODevice* op = device; + + if (!audioDeviceInfo->isFormatSupported(audioFormat) || !open()) { + stateCode = QAudio::StoppedState; + errorCode = QAudio::OpenError; + return; + } + + reset(); + audioBuffer->reset(); + audioBuffer->setFlushDevice(op); + + if (op == 0) + op = audioIO; + + // Start + startTime = AudioGetCurrentHostTime(); + totalFrames = 0; + + audioThreadStart(); + + stateCode = QAudio::ActiveState; + errorCode = QAudio::NoError; + emit stateChanged(stateCode); +} + +QIODevice* QAudioInputPrivate::start() +{ + QIODevice* op = 0; + + if (!audioDeviceInfo->isFormatSupported(audioFormat) || !open()) { + stateCode = QAudio::StoppedState; + errorCode = QAudio::OpenError; + return audioIO; + } + + reset(); + audioBuffer->reset(); + audioBuffer->setFlushDevice(op); + + if (op == 0) + op = audioIO; + + // Start + startTime = AudioGetCurrentHostTime(); + totalFrames = 0; + + audioThreadStart(); + + stateCode = QAudio::ActiveState; + errorCode = QAudio::NoError; + emit stateChanged(stateCode); + + return op; +} + +void QAudioInputPrivate::stop() +{ + QMutexLocker lock(&mutex); + if (stateCode != QAudio::StoppedState) { + audioThreadStop(); + audioBuffer->flush(true); + + errorCode = QAudio::NoError; + stateCode = QAudio::StoppedState; + QMetaObject::invokeMethod(this, "stateChanged", Qt::QueuedConnection, Q_ARG(QAudio::State, stateCode)); + } +} + +void QAudioInputPrivate::reset() +{ + QMutexLocker lock(&mutex); + if (stateCode != QAudio::StoppedState) { + audioThreadStop(); + + errorCode = QAudio::NoError; + stateCode = QAudio::StoppedState; + QMetaObject::invokeMethod(this, "stateChanged", Qt::QueuedConnection, Q_ARG(QAudio::State, stateCode)); + } +} + +void QAudioInputPrivate::suspend() +{ + QMutexLocker lock(&mutex); + if (stateCode == QAudio::ActiveState || stateCode == QAudio::IdleState) { + audioThreadStop(); + + errorCode = QAudio::NoError; + stateCode = QAudio::SuspendedState; + QMetaObject::invokeMethod(this, "stateChanged", Qt::QueuedConnection, Q_ARG(QAudio::State, stateCode)); + } +} + +void QAudioInputPrivate::resume() +{ + QMutexLocker lock(&mutex); + if (stateCode == QAudio::SuspendedState) { + audioThreadStart(); + + errorCode = QAudio::NoError; + stateCode = QAudio::ActiveState; + QMetaObject::invokeMethod(this, "stateChanged", Qt::QueuedConnection, Q_ARG(QAudio::State, stateCode)); + } +} + +int QAudioInputPrivate::bytesReady() const +{ + return audioBuffer->used(); +} + +int QAudioInputPrivate::periodSize() const +{ + return periodSizeBytes; +} + +void QAudioInputPrivate::setBufferSize(int bs) +{ + internalBufferSize = bs; +} + +int QAudioInputPrivate::bufferSize() const +{ + return internalBufferSize; +} + +void QAudioInputPrivate::setNotifyInterval(int milliSeconds) +{ + if (intervalTimer->interval() == milliSeconds) + return; + + if (milliSeconds <= 0) + milliSeconds = 0; + + intervalTimer->setInterval(milliSeconds); +} + +int QAudioInputPrivate::notifyInterval() const +{ + return intervalTimer->interval(); +} + +qint64 QAudioInputPrivate::processedUSecs() const +{ + return totalFrames * 1000000 / audioFormat.frequency(); +} + +qint64 QAudioInputPrivate::elapsedUSecs() const +{ + if (stateCode == QAudio::StoppedState) + return 0; + + return (AudioGetCurrentHostTime() - startTime) / (clockFrequency / 1000); +} + +QAudio::Error QAudioInputPrivate::error() const +{ + return errorCode; +} + +QAudio::State QAudioInputPrivate::state() const +{ + return stateCode; +} + +void QAudioInputPrivate::audioThreadStop() +{ + stopTimers(); + if (audioThreadState.testAndSetAcquire(Running, Stopped)) + threadFinished.wait(&mutex); +} + +void QAudioInputPrivate::audioThreadStart() +{ + startTimers(); + audioThreadState = Running; + AudioOutputUnitStart(audioUnit); +} + +void QAudioInputPrivate::audioDeviceStop() +{ + AudioOutputUnitStop(audioUnit); + audioThreadState = Stopped; + threadFinished.wakeOne(); +} + +void QAudioInputPrivate::audioDeviceFull() +{ + QMutexLocker lock(&mutex); + if (stateCode == QAudio::ActiveState) { + audioDeviceStop(); + + errorCode = QAudio::UnderrunError; + stateCode = QAudio::IdleState; + QMetaObject::invokeMethod(this, "deviceStopped", Qt::QueuedConnection); + } +} + +void QAudioInputPrivate::audioDeviceError() +{ + QMutexLocker lock(&mutex); + if (stateCode == QAudio::ActiveState) { + audioDeviceStop(); + + errorCode = QAudio::IOError; + stateCode = QAudio::StoppedState; + QMetaObject::invokeMethod(this, "deviceStopped", Qt::QueuedConnection); + } +} + +void QAudioInputPrivate::startTimers() +{ + audioBuffer->startFlushTimer(); + if (intervalTimer->interval() > 0) + intervalTimer->start(); +} + +void QAudioInputPrivate::stopTimers() +{ + audioBuffer->stopFlushTimer(); + intervalTimer->stop(); +} + +void QAudioInputPrivate::deviceStopped() +{ + stopTimers(); + emit stateChanged(stateCode); +} + +// Input callback +OSStatus QAudioInputPrivate::inputCallback(void* inRefCon, + AudioUnitRenderActionFlags* ioActionFlags, + const AudioTimeStamp* inTimeStamp, + UInt32 inBusNumber, + UInt32 inNumberFrames, + AudioBufferList* ioData) +{ + Q_UNUSED(ioData); + + QAudioInputPrivate* d = static_cast(inRefCon); + + const int threadState = d->audioThreadState.fetchAndAddAcquire(0); + if (threadState == Stopped) + d->audioDeviceStop(); + else { + qint64 framesWritten; + + framesWritten = d->audioBuffer->renderFromDevice(d->audioUnit, + ioActionFlags, + inTimeStamp, + inBusNumber, + inNumberFrames); + + if (framesWritten > 0) + d->totalFrames += framesWritten; + else if (framesWritten == 0) + d->audioDeviceFull(); + else if (framesWritten < 0) + d->audioDeviceError(); + } + + return noErr; +} + + +QT_END_NAMESPACE + +#include "qaudioinput_mac_p.moc" diff --git a/src/multimedia/audio/qaudioinput_mac_p.h b/src/multimedia/audio/qaudioinput_mac_p.h new file mode 100644 index 000000000..99aaba978 --- /dev/null +++ b/src/multimedia/audio/qaudioinput_mac_p.h @@ -0,0 +1,174 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists for the convenience +// of other Qt classes. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + + +#ifndef QAUDIOINPUT_MAC_P_H +#define QAUDIOINPUT_MAC_P_H + +#include +#include +#include +#include + +#include +#include +#include +#include + +#include +#include +#include + +QT_BEGIN_HEADER + +QT_BEGIN_NAMESPACE + +QT_MODULE(Multimedia) + + +class QTimer; +class QIODevice; +class QAbstractAudioDeviceInfo; + +namespace QtMultimediaInternal +{ +class QAudioInputBuffer; +} + +class QAudioInputPrivate : public QAbstractAudioInput +{ + Q_OBJECT + +public: + bool isOpen; + int periodSizeBytes; + int internalBufferSize; + qint64 totalFrames; + QAudioFormat audioFormat; + QIODevice* audioIO; + AudioUnit audioUnit; + AudioDeviceID audioDeviceId; + Float64 clockFrequency; + UInt64 startTime; + QAudio::Error errorCode; + QAudio::State stateCode; + QtMultimediaInternal::QAudioInputBuffer* audioBuffer; + QMutex mutex; + QWaitCondition threadFinished; + QAtomicInt audioThreadState; + QTimer* intervalTimer; + AudioStreamBasicDescription streamFormat; + AudioStreamBasicDescription deviceFormat; + QAbstractAudioDeviceInfo *audioDeviceInfo; + + QAudioInputPrivate(const QByteArray& device); + ~QAudioInputPrivate(); + + bool open(); + void close(); + + QAudioFormat format() const; + void setFormat(const QAudioFormat& fmt); + + QIODevice* start(); + void start(QIODevice* device); + void stop(); + void reset(); + void suspend(); + void resume(); + void idle(); + + int bytesReady() const; + int periodSize() const; + + void setBufferSize(int value); + int bufferSize() const; + + void setNotifyInterval(int milliSeconds); + int notifyInterval() const; + + qint64 processedUSecs() const; + qint64 elapsedUSecs() const; + + QAudio::Error error() const; + QAudio::State state() const; + + void audioThreadStart(); + void audioThreadStop(); + + void audioDeviceStop(); + void audioDeviceFull(); + void audioDeviceError(); + + void startTimers(); + void stopTimers(); + +private slots: + void deviceStopped(); + +private: + enum { Running, Stopped }; + + // Input callback + static OSStatus inputCallback(void* inRefCon, + AudioUnitRenderActionFlags* ioActionFlags, + const AudioTimeStamp* inTimeStamp, + UInt32 inBusNumber, + UInt32 inNumberFrames, + AudioBufferList* ioData); +}; + +QT_END_NAMESPACE + +QT_END_HEADER + +#endif // QAUDIOINPUT_MAC_P_H diff --git a/src/multimedia/audio/qaudioinput_win32_p.cpp b/src/multimedia/audio/qaudioinput_win32_p.cpp new file mode 100644 index 000000000..718656ba3 --- /dev/null +++ b/src/multimedia/audio/qaudioinput_win32_p.cpp @@ -0,0 +1,642 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists for the convenience +// of other Qt classes. This header file may change from version to +// version without notice, or even be removed. +// +// INTERNAL USE ONLY: Do NOT use for any other purpose. +// + + +#include "qaudioinput_win32_p.h" + +QT_BEGIN_NAMESPACE + +//#define DEBUG_AUDIO 1 + +QAudioInputPrivate::QAudioInputPrivate(const QByteArray &device) +{ + bytesAvailable = 0; + buffer_size = 0; + period_size = 0; + m_device = device; + totalTimeValue = 0; + intervalTime = 1000; + errorState = QAudio::NoError; + deviceState = QAudio::StoppedState; + audioSource = 0; + pullMode = true; + resuming = false; + finished = false; + waveBlockOffset = 0; +} + +QAudioInputPrivate::~QAudioInputPrivate() +{ + stop(); +} + +void QT_WIN_CALLBACK QAudioInputPrivate::waveInProc( HWAVEIN hWaveIn, UINT uMsg, + DWORD dwInstance, DWORD dwParam1, DWORD dwParam2 ) +{ + Q_UNUSED(dwParam1) + Q_UNUSED(dwParam2) + Q_UNUSED(hWaveIn) + + QAudioInputPrivate* qAudio; + qAudio = (QAudioInputPrivate*)(dwInstance); + if(!qAudio) + return; + + QMutexLocker(&qAudio->mutex); + + switch(uMsg) { + case WIM_OPEN: + break; + case WIM_DATA: + if(qAudio->waveFreeBlockCount > 0) + qAudio->waveFreeBlockCount--; + qAudio->feedback(); + break; + case WIM_CLOSE: + qAudio->finished = true; + break; + default: + return; + } +} + +WAVEHDR* QAudioInputPrivate::allocateBlocks(int size, int count) +{ + int i; + unsigned char* buffer; + WAVEHDR* blocks; + DWORD totalBufferSize = (size + sizeof(WAVEHDR))*count; + + if((buffer=(unsigned char*)HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY, + totalBufferSize)) == 0) { + qWarning("QAudioInput: Memory allocation error"); + return 0; + } + blocks = (WAVEHDR*)buffer; + buffer += sizeof(WAVEHDR)*count; + for(i = 0; i < count; i++) { + blocks[i].dwBufferLength = size; + blocks[i].lpData = (LPSTR)buffer; + blocks[i].dwBytesRecorded=0; + blocks[i].dwUser = 0L; + blocks[i].dwFlags = 0L; + blocks[i].dwLoops = 0L; + result = waveInPrepareHeader(hWaveIn,&blocks[i], sizeof(WAVEHDR)); + if(result != MMSYSERR_NOERROR) { + qWarning("QAudioInput: Can't prepare block %d",i); + return 0; + } + buffer += size; + } + return blocks; +} + +void QAudioInputPrivate::freeBlocks(WAVEHDR* blockArray) +{ + WAVEHDR* blocks = blockArray; + + int count = buffer_size/period_size; + + for(int i = 0; i < count; i++) { + waveInUnprepareHeader(hWaveIn,blocks, sizeof(WAVEHDR)); + blocks++; + } + HeapFree(GetProcessHeap(), 0, blockArray); +} + +QAudio::Error QAudioInputPrivate::error() const +{ + return errorState; +} + +QAudio::State QAudioInputPrivate::state() const +{ + return deviceState; +} + +void QAudioInputPrivate::setFormat(const QAudioFormat& fmt) +{ + if (deviceState == QAudio::StoppedState) + settings = fmt; +} + +QAudioFormat QAudioInputPrivate::format() const +{ + return settings; +} + +void QAudioInputPrivate::start(QIODevice* device) +{ + if(deviceState != QAudio::StoppedState) + close(); + + if(!pullMode && audioSource) + delete audioSource; + + pullMode = true; + audioSource = device; + + deviceState = QAudio::ActiveState; + + if(!open()) + return; + + emit stateChanged(deviceState); +} + +QIODevice* QAudioInputPrivate::start() +{ + if(deviceState != QAudio::StoppedState) + close(); + + if(!pullMode && audioSource) + delete audioSource; + + pullMode = false; + audioSource = new InputPrivate(this); + audioSource->open(QIODevice::ReadOnly | QIODevice::Unbuffered); + + deviceState = QAudio::IdleState; + + if(!open()) + return 0; + + emit stateChanged(deviceState); + + return audioSource; +} + +void QAudioInputPrivate::stop() +{ + if(deviceState == QAudio::StoppedState) + return; + + close(); + emit stateChanged(deviceState); +} + +bool QAudioInputPrivate::open() +{ +#ifdef DEBUG_AUDIO + QTime now(QTime::currentTime()); + qDebug()< 48000) { + qWarning("QAudioInput: open error, frequency out of range (%d).", settings.frequency()); + } else if (buffer_size == 0) { + + buffer_size + = (settings.frequency() + * settings.channelCount() + * settings.sampleSize() + + 39) / 40; + period_size = buffer_size / 5; + } else { + period_size = buffer_size / 5; + } + + if (period_size == 0) { + errorState = QAudio::OpenError; + deviceState = QAudio::StoppedState; + emit stateChanged(deviceState); + return false; + } + + timeStamp.restart(); + elapsedTimeOffset = 0; + wfx.nSamplesPerSec = settings.frequency(); + wfx.wBitsPerSample = settings.sampleSize(); + wfx.nChannels = settings.channels(); + wfx.cbSize = 0; + + wfx.wFormatTag = WAVE_FORMAT_PCM; + wfx.nBlockAlign = (wfx.wBitsPerSample >> 3) * wfx.nChannels; + wfx.nAvgBytesPerSec = wfx.nBlockAlign * wfx.nSamplesPerSec; + + QDataStream ds(&m_device, QIODevice::ReadOnly); + quint32 deviceId; + ds >> deviceId; + + if (waveInOpen(&hWaveIn, UINT_PTR(deviceId), &wfx, + (DWORD_PTR)&waveInProc, + (DWORD_PTR) this, + CALLBACK_FUNCTION) != MMSYSERR_NOERROR) { + errorState = QAudio::OpenError; + deviceState = QAudio::StoppedState; + emit stateChanged(deviceState); + qWarning("QAudioInput: failed to open audio device"); + return false; + } + waveBlocks = allocateBlocks(period_size, buffer_size/period_size); + waveBlockOffset = 0; + + if(waveBlocks == 0) { + errorState = QAudio::OpenError; + deviceState = QAudio::StoppedState; + emit stateChanged(deviceState); + qWarning("QAudioInput: failed to allocate blocks. open failed"); + return false; + } + + mutex.lock(); + waveFreeBlockCount = buffer_size/period_size; + mutex.unlock(); + + for(int i=0; i 0 && waveBlocks[header].dwFlags & WHDR_DONE) { + if(pullMode) { + l = audioSource->write(waveBlocks[header].lpData + waveBlockOffset, + waveBlocks[header].dwBytesRecorded - waveBlockOffset); +#ifdef DEBUG_AUDIO + qDebug()<<"IN: "<(len, waveBlocks[header].dwBytesRecorded - waveBlockOffset); + // push mode + memcpy(p, waveBlocks[header].lpData + waveBlockOffset, l); + + len -= l; + +#ifdef DEBUG_AUDIO + qDebug()<<"IN: "<= buffer_size/period_size) + header = 0; + p+=l; + + mutex.lock(); + if(!pullMode) { + if(len < period_size || waveFreeBlockCount == buffer_size/period_size) + done = true; + } else { + if(waveFreeBlockCount == buffer_size/period_size) + done = true; + } + mutex.unlock(); + } + + written+=l; + } +#ifdef DEBUG_AUDIO + qDebug()<<"read in len="<(audioSource); + a->trigger(); + } + + if(intervalTime && (timeStamp.elapsed() + elapsedTimeOffset) > intervalTime) { + emit notify(); + elapsedTimeOffset = timeStamp.elapsed() + elapsedTimeOffset - intervalTime; + timeStamp.restart(); + } + return true; +} + +qint64 QAudioInputPrivate::elapsedUSecs() const +{ + if (deviceState == QAudio::StoppedState) + return 0; + + return timeStampOpened.elapsed()*1000; +} + +void QAudioInputPrivate::reset() +{ + stop(); + if (period_size > 0) + waveFreeBlockCount = buffer_size / period_size; +} + +InputPrivate::InputPrivate(QAudioInputPrivate* audio) +{ + audioDevice = qobject_cast(audio); +} + +InputPrivate::~InputPrivate() {} + +qint64 InputPrivate::readData( char* data, qint64 len) +{ + // push mode, user read() called + if(audioDevice->deviceState != QAudio::ActiveState && + audioDevice->deviceState != QAudio::IdleState) + return 0; + // Read in some audio data + return audioDevice->read(data,len); +} + +qint64 InputPrivate::writeData(const char* data, qint64 len) +{ + Q_UNUSED(data) + Q_UNUSED(len) + + emit readyRead(); + return 0; +} + +void InputPrivate::trigger() +{ + emit readyRead(); +} + +QT_END_NAMESPACE + +#include "moc_qaudioinput_win32_p.cpp" + diff --git a/src/multimedia/audio/qaudioinput_win32_p.h b/src/multimedia/audio/qaudioinput_win32_p.h new file mode 100644 index 000000000..10d41a552 --- /dev/null +++ b/src/multimedia/audio/qaudioinput_win32_p.h @@ -0,0 +1,179 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists for the convenience +// of other Qt classes. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#ifndef QAUDIOINPUTWIN_H +#define QAUDIOINPUTWIN_H + +#include +#include + +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include + + +QT_BEGIN_HEADER + +QT_BEGIN_NAMESPACE + +QT_MODULE(Multimedia) + + +// For compat with 4.6 +#if !defined(QT_WIN_CALLBACK) +# if defined(Q_CC_MINGW) +# define QT_WIN_CALLBACK CALLBACK __attribute__ ((force_align_arg_pointer)) +# else +# define QT_WIN_CALLBACK CALLBACK +# endif +#endif + +class QAudioInputPrivate : public QAbstractAudioInput +{ + Q_OBJECT +public: + QAudioInputPrivate(const QByteArray &device); + ~QAudioInputPrivate(); + + qint64 read(char* data, qint64 len); + + void setFormat(const QAudioFormat& fmt); + QAudioFormat format() const; + QIODevice* start(); + void start(QIODevice* device); + void stop(); + void reset(); + void suspend(); + void resume(); + int bytesReady() const; + int periodSize() const; + void setBufferSize(int value); + int bufferSize() const; + void setNotifyInterval(int milliSeconds); + int notifyInterval() const; + qint64 processedUSecs() const; + qint64 elapsedUSecs() const; + QAudio::Error error() const; + QAudio::State state() const; + + QIODevice* audioSource; + QAudioFormat settings; + QAudio::Error errorState; + QAudio::State deviceState; + +private: + qint32 buffer_size; + qint32 period_size; + qint32 header; + QByteArray m_device; + int bytesAvailable; + int intervalTime; + QTime timeStamp; + qint64 elapsedTimeOffset; + QTime timeStampOpened; + qint64 totalTimeValue; + bool pullMode; + bool resuming; + WAVEFORMATEX wfx; + HWAVEIN hWaveIn; + MMRESULT result; + WAVEHDR* waveBlocks; + volatile bool finished; + volatile int waveFreeBlockCount; + int waveBlockOffset; + + QMutex mutex; + static void QT_WIN_CALLBACK waveInProc( HWAVEIN hWaveIn, UINT uMsg, + DWORD dwInstance, DWORD dwParam1, DWORD dwParam2 ); + + WAVEHDR* allocateBlocks(int size, int count); + void freeBlocks(WAVEHDR* blockArray); + bool open(); + void close(); + +private slots: + void feedback(); + bool deviceReady(); + +signals: + void processMore(); +}; + +class InputPrivate : public QIODevice +{ + Q_OBJECT +public: + InputPrivate(QAudioInputPrivate* audio); + ~InputPrivate(); + + qint64 readData( char* data, qint64 len); + qint64 writeData(const char* data, qint64 len); + + void trigger(); +private: + QAudioInputPrivate *audioDevice; +}; + +QT_END_NAMESPACE + +QT_END_HEADER + + +#endif diff --git a/src/multimedia/audio/qaudiooutput.cpp b/src/multimedia/audio/qaudiooutput.cpp new file mode 100644 index 000000000..05db98bd6 --- /dev/null +++ b/src/multimedia/audio/qaudiooutput.cpp @@ -0,0 +1,404 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + + +#include "qaudio.h" +#include "qaudiodeviceinfo.h" +#include "qaudiosystem.h" +#include "qaudiooutput.h" + +#include "qaudiodevicefactory_p.h" + + +QT_BEGIN_NAMESPACE + +/*! + \class QAudioOutput + \brief The QAudioOutput class provides an interface for sending audio data to an audio output device. + + \inmodule QtMultimedia + \ingroup multimedia + \since 1.0 + + You can construct an audio output with the system's + \l{QAudioDeviceInfo::defaultOutputDevice()}{default audio output + device}. It is also possible to create QAudioOutput with a + specific QAudioDeviceInfo. When you create the audio output, you + should also send in the QAudioFormat to be used for the playback + (see the QAudioFormat class description for details). + + To play a file: + + Starting to play an audio stream is simply a matter of calling + start() with a QIODevice. QAudioOutput will then fetch the data it + needs from the io device. So playing back an audio file is as + simple as: + + \snippet doc/src/snippets/multimedia-snippets/audio.cpp Audio output class members + + \snippet doc/src/snippets/multimedia-snippets/audio.cpp Audio output setup + + The file will start playing assuming that the audio system and + output device support it. If you run out of luck, check what's + up with the error() function. + + After the file has finished playing, we need to stop the device: + + \snippet doc/src/snippets/multimedia-snippets/audio.cpp Audio output state changed + + At any given time, the QAudioOutput will be in one of four states: + active, suspended, stopped, or idle. These states are described + by the QAudio::State enum. + State changes are reported through the stateChanged() signal. You + can use this signal to, for instance, update the GUI of the + application; the mundane example here being changing the state of + a \c { play/pause } button. You request a state change directly + with suspend(), stop(), reset(), resume(), and start(). + + While the stream is playing, you can set a notify interval in + milliseconds with setNotifyInterval(). This interval specifies the + time between two emissions of the notify() signal. This is + relative to the position in the stream, i.e., if the QAudioOutput + is in the SuspendedState or the IdleState, the notify() signal is + not emitted. A typical use-case would be to update a + \l{QSlider}{slider} that allows seeking in the stream. + If you want the time since playback started regardless of which + states the audio output has been in, elapsedUSecs() is the function for you. + + If an error occurs, you can fetch the \l{QAudio::Error}{error + type} with the error() function. Please see the QAudio::Error enum + for a description of the possible errors that are reported. When + an error is encountered, the state changes to QAudio::StoppedState. + You can check for errors by connecting to the stateChanged() + signal: + + \snippet doc/src/snippets/multimedia-snippets/audio.cpp Audio output state changed + + \sa QAudioInput, QAudioDeviceInfo +*/ + +/*! + Construct a new audio output and attach it to \a parent. + The default audio output device is used with the output + \a format parameters. + \since 1.0 +*/ +QAudioOutput::QAudioOutput(const QAudioFormat &format, QObject *parent): + QObject(parent) +{ + d = QAudioDeviceFactory::createDefaultOutputDevice(format); + connect(d, SIGNAL(notify()), SIGNAL(notify())); + connect(d, SIGNAL(stateChanged(QAudio::State)), SIGNAL(stateChanged(QAudio::State))); +} + +/*! + Construct a new audio output and attach it to \a parent. + The device referenced by \a audioDevice is used with the output + \a format parameters. + \since 1.0 +*/ +QAudioOutput::QAudioOutput(const QAudioDeviceInfo &audioDevice, const QAudioFormat &format, QObject *parent): + QObject(parent) +{ + d = QAudioDeviceFactory::createOutputDevice(audioDevice, format); + connect(d, SIGNAL(notify()), SIGNAL(notify())); + connect(d, SIGNAL(stateChanged(QAudio::State)), SIGNAL(stateChanged(QAudio::State))); +} + +/*! + Destroys this audio output. + + This will release any system resources used and free any buffers. +*/ +QAudioOutput::~QAudioOutput() +{ + delete d; +} + +/*! + Returns the QAudioFormat being used. + + \since 1.0 +*/ +QAudioFormat QAudioOutput::format() const +{ + return d->format(); +} + +/*! + Uses the \a device as the QIODevice to transfer data. + Passing a QIODevice allows the data to be transferred without any extra code. + All that is required is to open the QIODevice. + + If able to successfully output audio data to the systems audio device the + state() is set to QAudio::ActiveState, error() is set to QAudio::NoError + and the stateChanged() signal is emitted. + + If a problem occurs during this process the error() is set to QAudio::OpenError, + state() is set to QAudio::StoppedState and stateChanged() signal is emitted. + + \since 1.0 + \sa QIODevice +*/ +void QAudioOutput::start(QIODevice* device) +{ + d->start(device); +} + +/*! + Returns a pointer to the QIODevice being used to handle the data + transfer. This QIODevice can be used to write() audio data directly. + + If able to access the systems audio device the state() is set to + QAudio::IdleState, error() is set to QAudio::NoError + and the stateChanged() signal is emitted. + + If a problem occurs during this process the error() is set to QAudio::OpenError, + state() is set to QAudio::StoppedState and stateChanged() signal is emitted. + + \since 1.0 + \sa QIODevice +*/ +QIODevice* QAudioOutput::start() +{ + return d->start(); +} + +/*! + Stops the audio output, detaching from the system resource. + + Sets error() to QAudio::NoError, state() to QAudio::StoppedState and + emit stateChanged() signal. + \since 1.0 +*/ +void QAudioOutput::stop() +{ + d->stop(); +} + +/*! + Drops all audio data in the buffers, resets buffers to zero. + + \since 1.0 +*/ +void QAudioOutput::reset() +{ + d->reset(); +} + +/*! + Stops processing audio data, preserving buffered audio data. + + Sets error() to QAudio::NoError, state() to QAudio::SuspendedState and + emits stateChanged() signal. + \since 1.0 +*/ +void QAudioOutput::suspend() +{ + d->suspend(); +} + +/*! + Resumes processing audio data after a suspend(). + + Sets error() to QAudio::NoError. + Sets state() to QAudio::ActiveState if you previously called start(QIODevice*). + Sets state() to QAudio::IdleState if you previously called start(). + emits stateChanged() signal. + \since 1.0 +*/ +void QAudioOutput::resume() +{ + d->resume(); +} + +/*! + Returns the number of free bytes available in the audio buffer. + + \note The returned value is only valid while in QAudio::ActiveState or QAudio::IdleState + state, otherwise returns zero. + \since 1.0 +*/ +int QAudioOutput::bytesFree() const +{ + return d->bytesFree(); +} + +/*! + Returns the period size in bytes. This is the amount of data required each period + to prevent buffer underrun, and to ensure uninterrupted playback. + + \note It is recommended to provide at least enough data for a full period with each + write operation. + \since 1.0 +*/ +int QAudioOutput::periodSize() const +{ + return d->periodSize(); +} + +/*! + Sets the audio buffer size to \a value in bytes. + + \note This function can be called anytime before start(). Calls to this + are ignored after start(). It should not be assumed that the buffer size + set is the actual buffer size used - call bufferSize() anytime after start() + to return the actual buffer size being used. + \since 1.0 +*/ +void QAudioOutput::setBufferSize(int value) +{ + d->setBufferSize(value); +} + +/*! + Returns the audio buffer size in bytes. + + If called before start(), returns platform default value. + If called before start() but setBufferSize() was called prior, returns value set by setBufferSize(). + If called after start(), returns the actual buffer size being used. This may not be what was set previously + by setBufferSize(). + + \since 1.0 +*/ +int QAudioOutput::bufferSize() const +{ + return d->bufferSize(); +} + +/*! + Sets the interval for notify() signal to be emitted. + This is based on the \a ms of audio data processed, + not on wall clock time. + The minimum resolution of the timer is platform specific and values + should be checked with notifyInterval() to confirm the actual value + being used. + \since 1.0 +*/ +void QAudioOutput::setNotifyInterval(int ms) +{ + d->setNotifyInterval(ms); +} + +/*! + Returns the notify interval in milliseconds. + \since 1.0 +*/ +int QAudioOutput::notifyInterval() const +{ + return d->notifyInterval(); +} + +/*! + Returns the amount of audio data processed since start() + was called (in microseconds). + \since 1.0 +*/ +qint64 QAudioOutput::processedUSecs() const +{ + return d->processedUSecs(); +} + +/*! + Returns the microseconds since start() was called, including time in Idle and + Suspend states. + \since 1.0 +*/ +qint64 QAudioOutput::elapsedUSecs() const +{ + return d->elapsedUSecs(); +} + +/*! + Returns the error state. + \since 1.0 +*/ +QAudio::Error QAudioOutput::error() const +{ + return d->error(); +} + +/*! + Returns the state of audio processing. + \since 1.0 +*/ +QAudio::State QAudioOutput::state() const +{ + return d->state(); +} + +/*! + Sets the volume. + Where \a volume is between 0.0 and 1.0 inclusive. + \since 5.0 +*/ +void QAudioOutput::setVolume(qreal volume) +{ + d->setVolume(volume); +} + +/*! + Returns the volume between 0.0 and 1.0 inclusive. + \since 5.0 +*/ +qreal QAudioOutput::volume() const +{ + return d->volume(); +} + +/*! + \fn QAudioOutput::stateChanged(QAudio::State state) + This signal is emitted when the device \a state has changed. + This is the current state of the audio output. + \since 1.0 +*/ + +/*! + \fn QAudioOutput::notify() + This signal is emitted when a certain interval of milliseconds + of audio data has been processed. The interval is set by + setNotifyInterval(). + \since 1.0 +*/ + +QT_END_NAMESPACE + +#include "moc_qaudiooutput.cpp" diff --git a/src/multimedia/audio/qaudiooutput.h b/src/multimedia/audio/qaudiooutput.h new file mode 100644 index 000000000..3edec1b4a --- /dev/null +++ b/src/multimedia/audio/qaudiooutput.h @@ -0,0 +1,117 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + + +#ifndef QAUDIOOUTPUT_H +#define QAUDIOOUTPUT_H + +#include + +#include +#include + +#include +#include +#include + + +QT_BEGIN_HEADER + +QT_BEGIN_NAMESPACE + +QT_MODULE(Multimedia) + + + +class QAbstractAudioOutput; + +class Q_MULTIMEDIA_EXPORT QAudioOutput : public QObject +{ + Q_OBJECT + +public: + explicit QAudioOutput(const QAudioFormat &format = QAudioFormat(), QObject *parent = 0); + explicit QAudioOutput(const QAudioDeviceInfo &audioDeviceInfo, const QAudioFormat &format = QAudioFormat(), QObject *parent = 0); + ~QAudioOutput(); + + QAudioFormat format() const; + + void start(QIODevice *device); + QIODevice* start(); + + void stop(); + void reset(); + void suspend(); + void resume(); + + void setBufferSize(int bytes); + int bufferSize() const; + + int bytesFree() const; + int periodSize() const; + + void setNotifyInterval(int milliSeconds); + int notifyInterval() const; + + qint64 processedUSecs() const; + qint64 elapsedUSecs() const; + + QAudio::Error error() const; + QAudio::State state() const; + + void setVolume(qreal); + qreal volume() const; + +Q_SIGNALS: + void stateChanged(QAudio::State); + void notify(); + +private: + Q_DISABLE_COPY(QAudioOutput) + + QAbstractAudioOutput* d; +}; + +QT_END_NAMESPACE + +QT_END_HEADER + +#endif // QAUDIOOUTPUT_H diff --git a/src/multimedia/audio/qaudiooutput_alsa_p.cpp b/src/multimedia/audio/qaudiooutput_alsa_p.cpp new file mode 100644 index 000000000..8ef4e2819 --- /dev/null +++ b/src/multimedia/audio/qaudiooutput_alsa_p.cpp @@ -0,0 +1,834 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists for the convenience +// of other Qt classes. This header file may change from version to +// version without notice, or even be removed. +// +// INTERNAL USE ONLY: Do NOT use for any other purpose. +// + +#include +#include "qaudiooutput_alsa_p.h" +#include "qaudiodeviceinfo_alsa_p.h" + +QT_BEGIN_NAMESPACE + +//#define DEBUG_AUDIO 1 + +QAudioOutputPrivate::QAudioOutputPrivate(const QByteArray &device) +{ + bytesAvailable = 0; + handle = 0; + ahandler = 0; + access = SND_PCM_ACCESS_RW_INTERLEAVED; + pcmformat = SND_PCM_FORMAT_S16; + buffer_frames = 0; + period_frames = 0; + buffer_size = 0; + period_size = 0; + buffer_time = 100000; + period_time = 20000; + totalTimeValue = 0; + intervalTime = 1000; + audioBuffer = 0; + errorState = QAudio::NoError; + deviceState = QAudio::StoppedState; + audioSource = 0; + pullMode = true; + resuming = false; + opened = false; + + m_device = device; + + timer = new QTimer(this); + connect(timer,SIGNAL(timeout()),SLOT(userFeed())); +} + +QAudioOutputPrivate::~QAudioOutputPrivate() +{ + close(); + disconnect(timer, SIGNAL(timeout())); + QCoreApplication::processEvents(); + delete timer; +} + +QAudio::Error QAudioOutputPrivate::error() const +{ + return errorState; +} + +QAudio::State QAudioOutputPrivate::state() const +{ + return deviceState; +} + +void QAudioOutputPrivate::async_callback(snd_async_handler_t *ahandler) +{ + QAudioOutputPrivate* audioOut; + + audioOut = static_cast + (snd_async_handler_get_callback_private(ahandler)); + + if((audioOut->deviceState==QAudio::ActiveState)||(audioOut->resuming)) + audioOut->feedback(); +} + +int QAudioOutputPrivate::xrun_recovery(int err) +{ + int count = 0; + bool reset = false; + + if(err == -EPIPE) { + errorState = QAudio::UnderrunError; + emit errorChanged(errorState); + err = snd_pcm_prepare(handle); + if(err < 0) + reset = true; + + } else if((err == -ESTRPIPE)||(err == -EIO)) { + errorState = QAudio::IOError; + emit errorChanged(errorState); + while((err = snd_pcm_resume(handle)) == -EAGAIN){ + usleep(100); + count++; + if(count > 5) { + reset = true; + break; + } + } + if(err < 0) { + err = snd_pcm_prepare(handle); + if(err < 0) + reset = true; + } + } + if(reset) { + close(); + open(); + snd_pcm_prepare(handle); + return 0; + } + return err; +} + +int QAudioOutputPrivate::setFormat() +{ + snd_pcm_format_t pcmformat = SND_PCM_FORMAT_UNKNOWN; + + if(settings.sampleSize() == 8) { + pcmformat = SND_PCM_FORMAT_U8; + + } else if(settings.sampleSize() == 16) { + if(settings.sampleType() == QAudioFormat::SignedInt) { + if(settings.byteOrder() == QAudioFormat::LittleEndian) + pcmformat = SND_PCM_FORMAT_S16_LE; + else + pcmformat = SND_PCM_FORMAT_S16_BE; + } else if(settings.sampleType() == QAudioFormat::UnSignedInt) { + if(settings.byteOrder() == QAudioFormat::LittleEndian) + pcmformat = SND_PCM_FORMAT_U16_LE; + else + pcmformat = SND_PCM_FORMAT_U16_BE; + } + } else if(settings.sampleSize() == 24) { + if(settings.sampleType() == QAudioFormat::SignedInt) { + if(settings.byteOrder() == QAudioFormat::LittleEndian) + pcmformat = SND_PCM_FORMAT_S24_LE; + else + pcmformat = SND_PCM_FORMAT_S24_BE; + } else if(settings.sampleType() == QAudioFormat::UnSignedInt) { + if(settings.byteOrder() == QAudioFormat::LittleEndian) + pcmformat = SND_PCM_FORMAT_U24_LE; + else + pcmformat = SND_PCM_FORMAT_U24_BE; + } + } else if(settings.sampleSize() == 32) { + if(settings.sampleType() == QAudioFormat::SignedInt) { + if(settings.byteOrder() == QAudioFormat::LittleEndian) + pcmformat = SND_PCM_FORMAT_S32_LE; + else + pcmformat = SND_PCM_FORMAT_S32_BE; + } else if(settings.sampleType() == QAudioFormat::UnSignedInt) { + if(settings.byteOrder() == QAudioFormat::LittleEndian) + pcmformat = SND_PCM_FORMAT_U32_LE; + else + pcmformat = SND_PCM_FORMAT_U32_BE; + } else if(settings.sampleType() == QAudioFormat::Float) { + if(settings.byteOrder() == QAudioFormat::LittleEndian) + pcmformat = SND_PCM_FORMAT_FLOAT_LE; + else + pcmformat = SND_PCM_FORMAT_FLOAT_BE; + } + } else if(settings.sampleSize() == 64) { + if(settings.byteOrder() == QAudioFormat::LittleEndian) + pcmformat = SND_PCM_FORMAT_FLOAT64_LE; + else + pcmformat = SND_PCM_FORMAT_FLOAT64_BE; + } + + return pcmformat != SND_PCM_FORMAT_UNKNOWN + ? snd_pcm_hw_params_set_format( handle, hwparams, pcmformat) + : -1; +} + +void QAudioOutputPrivate::start(QIODevice* device) +{ + if(deviceState != QAudio::StoppedState) + deviceState = QAudio::StoppedState; + + errorState = QAudio::NoError; + + // Handle change of mode + if(audioSource && !pullMode) { + delete audioSource; + audioSource = 0; + } + + close(); + + pullMode = true; + audioSource = device; + + deviceState = QAudio::ActiveState; + + open(); + + emit stateChanged(deviceState); +} + +QIODevice* QAudioOutputPrivate::start() +{ + if(deviceState != QAudio::StoppedState) + deviceState = QAudio::StoppedState; + + errorState = QAudio::NoError; + + // Handle change of mode + if(audioSource && !pullMode) { + delete audioSource; + audioSource = 0; + } + + close(); + + audioSource = new OutputPrivate(this); + audioSource->open(QIODevice::WriteOnly|QIODevice::Unbuffered); + pullMode = false; + + deviceState = QAudio::IdleState; + + open(); + + emit stateChanged(deviceState); + + return audioSource; +} + +void QAudioOutputPrivate::stop() +{ + if(deviceState == QAudio::StoppedState) + return; + errorState = QAudio::NoError; + deviceState = QAudio::StoppedState; + close(); + emit stateChanged(deviceState); +} + +bool QAudioOutputPrivate::open() +{ + if(opened) + return true; + +#ifdef DEBUG_AUDIO + QTime now(QTime::currentTime()); + qDebug()< devices = QAudioDeviceInfoInternal::availableDevices(QAudio::AudioOutput); + if(dev.compare(QLatin1String("default")) == 0) { +#if(SND_LIB_MAJOR == 1 && SND_LIB_MINOR == 0 && SND_LIB_SUBMINOR >= 14) + if (devices.size() > 0) + dev = QLatin1String(devices.first()); + else + return false; +#else + dev = QLatin1String("hw:0,0"); +#endif + } else { +#if(SND_LIB_MAJOR == 1 && SND_LIB_MINOR == 0 && SND_LIB_SUBMINOR >= 14) + dev = QLatin1String(m_device); +#else + int idx = 0; + char *name; + + QString shortName = QLatin1String(m_device.mid(m_device.indexOf('=',0)+1).constData()); + + while(snd_card_get_name(idx,&name) == 0) { + if(qstrncmp(shortName.toLocal8Bit().constData(),name,shortName.length()) == 0) + break; + idx++; + } + dev = QString(QLatin1String("hw:%1,0")).arg(idx); +#endif + } + + // Step 1: try and open the device + while((count < 5) && (err < 0)) { + err=snd_pcm_open(&handle,dev.toLocal8Bit().constData(),SND_PCM_STREAM_PLAYBACK,0); + if(err < 0) + count++; + } + if (( err < 0)||(handle == 0)) { + errorState = QAudio::OpenError; + emit errorChanged(errorState); + deviceState = QAudio::StoppedState; + return false; + } + snd_pcm_nonblock( handle, 0 ); + + // Step 2: Set the desired HW parameters. + snd_pcm_hw_params_alloca( &hwparams ); + + bool fatal = false; + QString errMessage; + unsigned int chunks = 8; + + err = snd_pcm_hw_params_any( handle, hwparams ); + if ( err < 0 ) { + fatal = true; + errMessage = QString::fromLatin1("QAudioOutput: snd_pcm_hw_params_any: err = %1").arg(err); + } + if ( !fatal ) { + err = snd_pcm_hw_params_set_rate_resample( handle, hwparams, 1 ); + if ( err < 0 ) { + fatal = true; + errMessage = QString::fromLatin1("QAudioOutput: snd_pcm_hw_params_set_rate_resample: err = %1").arg(err); + } + } + if ( !fatal ) { + err = snd_pcm_hw_params_set_access( handle, hwparams, access ); + if ( err < 0 ) { + fatal = true; + errMessage = QString::fromLatin1("QAudioOutput: snd_pcm_hw_params_set_access: err = %1").arg(err); + } + } + if ( !fatal ) { + err = setFormat(); + if ( err < 0 ) { + fatal = true; + errMessage = QString::fromLatin1("QAudioOutput: snd_pcm_hw_params_set_format: err = %1").arg(err); + } + } + if ( !fatal ) { + err = snd_pcm_hw_params_set_channels( handle, hwparams, (unsigned int)settings.channels() ); + if ( err < 0 ) { + fatal = true; + errMessage = QString::fromLatin1("QAudioOutput: snd_pcm_hw_params_set_channels: err = %1").arg(err); + } + } + if ( !fatal ) { + err = snd_pcm_hw_params_set_rate_near( handle, hwparams, &freakuency, 0 ); + if ( err < 0 ) { + fatal = true; + errMessage = QString::fromLatin1("QAudioOutput: snd_pcm_hw_params_set_rate_near: err = %1").arg(err); + } + } + if ( !fatal ) { + unsigned int maxBufferTime = 0; + unsigned int minBufferTime = 0; + unsigned int maxPeriodTime = 0; + unsigned int minPeriodTime = 0; + + err = snd_pcm_hw_params_get_buffer_time_max(hwparams, &maxBufferTime, &dir); + if ( err >= 0) + err = snd_pcm_hw_params_get_buffer_time_min(hwparams, &minBufferTime, &dir); + if ( err >= 0) + err = snd_pcm_hw_params_get_period_time_max(hwparams, &maxPeriodTime, &dir); + if ( err >= 0) + err = snd_pcm_hw_params_get_period_time_min(hwparams, &minPeriodTime, &dir); + + if ( err < 0 ) { + fatal = true; + errMessage = QString::fromLatin1("QAudioOutput: buffer/period min and max: err = %1").arg(err); + } else { + if (maxBufferTime < buffer_time || buffer_time < minBufferTime || maxPeriodTime < period_time || minPeriodTime > period_time) { +#ifdef DEBUG_AUDIO + qDebug()<<"defaults out of range"; + qDebug()<<"pmin="<start(period_time/1000); + + clockStamp.restart(); + timeStamp.restart(); + elapsedTimeOffset = 0; + errorState = QAudio::NoError; + totalTimeValue = 0; + opened = true; + + return true; +} + +void QAudioOutputPrivate::close() +{ + timer->stop(); + + if ( handle ) { + snd_pcm_drain( handle ); + snd_pcm_close( handle ); + handle = 0; + delete [] audioBuffer; + audioBuffer=0; + } + if(!pullMode && audioSource) { + delete audioSource; + audioSource = 0; + } + opened = false; +} + +int QAudioOutputPrivate::bytesFree() const +{ + if(resuming) + return period_size; + + if(deviceState != QAudio::ActiveState && deviceState != QAudio::IdleState) + return 0; + + int frames = snd_pcm_avail_update(handle); + if (frames == -EPIPE) { + // Try and handle buffer underrun + int err = snd_pcm_recover(handle, frames, 0); + if (err < 0) + return 0; + else + frames = snd_pcm_avail_update(handle); + } else if (frames < 0) { + return 0; + } + + if ((int)frames > (int)buffer_frames) + frames = buffer_frames; + + return snd_pcm_frames_to_bytes(handle, frames); +} + +qint64 QAudioOutputPrivate::write( const char *data, qint64 len ) +{ + // Write out some audio data + if ( !handle ) + return 0; +#ifdef DEBUG_AUDIO + qDebug()<<"frames to write out = "<< + snd_pcm_bytes_to_frames( handle, (int)len )<<" ("< 0) { + totalTimeValue += err; + resuming = false; + errorState = QAudio::NoError; + if (deviceState != QAudio::ActiveState) { + deviceState = QAudio::ActiveState; + emit stateChanged(deviceState); + } + return snd_pcm_frames_to_bytes( handle, err ); + } else + err = xrun_recovery(err); + + if(err < 0) { + close(); + errorState = QAudio::FatalError; + emit errorChanged(errorState); + deviceState = QAudio::StoppedState; + emit stateChanged(deviceState); + } + return 0; +} + +int QAudioOutputPrivate::periodSize() const +{ + return period_size; +} + +void QAudioOutputPrivate::setBufferSize(int value) +{ + if(deviceState == QAudio::StoppedState) + buffer_size = value; +} + +int QAudioOutputPrivate::bufferSize() const +{ + return buffer_size; +} + +void QAudioOutputPrivate::setNotifyInterval(int ms) +{ + intervalTime = qMax(0, ms); +} + +int QAudioOutputPrivate::notifyInterval() const +{ + return intervalTime; +} + +qint64 QAudioOutputPrivate::processedUSecs() const +{ + return qint64(1000000) * totalTimeValue / settings.frequency(); +} + +void QAudioOutputPrivate::resume() +{ + if(deviceState == QAudio::SuspendedState) { + int err = 0; + + if(handle) { + err = snd_pcm_prepare( handle ); + if(err < 0) + xrun_recovery(err); + + err = snd_pcm_start(handle); + if(err < 0) + xrun_recovery(err); + + bytesAvailable = (int)snd_pcm_frames_to_bytes(handle, buffer_frames); + } + resuming = true; + + deviceState = QAudio::ActiveState; + + errorState = QAudio::NoError; + timer->start(period_time/1000); + emit stateChanged(deviceState); + } +} + +void QAudioOutputPrivate::setFormat(const QAudioFormat& fmt) +{ + if (deviceState == QAudio::StoppedState) + settings = fmt; +} + +QAudioFormat QAudioOutputPrivate::format() const +{ + return settings; +} + +void QAudioOutputPrivate::suspend() +{ + if(deviceState == QAudio::ActiveState || deviceState == QAudio::IdleState || resuming) { + timer->stop(); + deviceState = QAudio::SuspendedState; + errorState = QAudio::NoError; + emit stateChanged(deviceState); + } +} + +void QAudioOutputPrivate::userFeed() +{ + if(deviceState == QAudio::StoppedState || deviceState == QAudio::SuspendedState) + return; +#ifdef DEBUG_AUDIO + QTime now(QTime::currentTime()); + qDebug()< + +#include +#include +#include +#include +#include +#include + +#include "qaudio.h" +#include "qaudiodeviceinfo.h" +#include "qaudiosystem.h" + +QT_BEGIN_HEADER + +QT_BEGIN_NAMESPACE + +QT_MODULE(Multimedia) + + +class OutputPrivate; + +class QAudioOutputPrivate : public QAbstractAudioOutput +{ + friend class OutputPrivate; + Q_OBJECT +public: + QAudioOutputPrivate(const QByteArray &device); + ~QAudioOutputPrivate(); + + qint64 write( const char *data, qint64 len ); + + void start(QIODevice* device); + QIODevice* start(); + void stop(); + void reset(); + void suspend(); + void resume(); + int bytesFree() const; + int periodSize() const; + void setBufferSize(int value); + int bufferSize() const; + void setNotifyInterval(int milliSeconds); + int notifyInterval() const; + qint64 processedUSecs() const; + qint64 elapsedUSecs() const; + QAudio::Error error() const; + QAudio::State state() const; + void setFormat(const QAudioFormat& fmt); + QAudioFormat format() const; + + QIODevice* audioSource; + QAudioFormat settings; + QAudio::Error errorState; + QAudio::State deviceState; + +private slots: + void userFeed(); + void feedback(); + void updateAvailable(); + bool deviceReady(); + +signals: + void processMore(); + +private: + bool opened; + bool pullMode; + bool resuming; + int buffer_size; + int period_size; + int intervalTime; + qint64 totalTimeValue; + unsigned int buffer_time; + unsigned int period_time; + snd_pcm_uframes_t buffer_frames; + snd_pcm_uframes_t period_frames; + static void async_callback(snd_async_handler_t *ahandler); + int xrun_recovery(int err); + + int setFormat(); + bool open(); + void close(); + + QTimer* timer; + QByteArray m_device; + int bytesAvailable; + QTime timeStamp; + QTime clockStamp; + qint64 elapsedTimeOffset; + char* audioBuffer; + snd_pcm_t* handle; + snd_async_handler_t* ahandler; + snd_pcm_access_t access; + snd_pcm_format_t pcmformat; + snd_timestamp_t* timestamp; + snd_pcm_hw_params_t *hwparams; +}; + +class OutputPrivate : public QIODevice +{ + friend class QAudioOutputPrivate; + Q_OBJECT +public: + OutputPrivate(QAudioOutputPrivate* audio); + ~OutputPrivate(); + + qint64 readData( char* data, qint64 len); + qint64 writeData(const char* data, qint64 len); + +private: + QAudioOutputPrivate *audioDevice; +}; + +QT_END_NAMESPACE + +QT_END_HEADER + + +#endif diff --git a/src/multimedia/audio/qaudiooutput_mac_p.cpp b/src/multimedia/audio/qaudiooutput_mac_p.cpp new file mode 100644 index 000000000..5e0c1cb07 --- /dev/null +++ b/src/multimedia/audio/qaudiooutput_mac_p.cpp @@ -0,0 +1,734 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists for the convenience +// of other Qt classes. This header file may change from version to +// version without notice, or even be removed. +// +// INTERNAL USE ONLY: Do NOT use for any other purpose. +// + +#include +#include +#include +#include + +#include +#include +#include +#include + +#include + +#include "qaudio_mac_p.h" +#include "qaudiooutput_mac_p.h" +#include "qaudiodeviceinfo_mac_p.h" + + +QT_BEGIN_NAMESPACE + + +namespace QtMultimediaInternal +{ + +static const int default_buffer_size = 8 * 1024; + + +class QAudioOutputBuffer : public QObject +{ + Q_OBJECT + +public: + QAudioOutputBuffer(int bufferSize, int maxPeriodSize, QAudioFormat const& audioFormat): + m_deviceError(false), + m_maxPeriodSize(maxPeriodSize), + m_device(0) + { + m_buffer = new QAudioRingBuffer(bufferSize + (bufferSize % maxPeriodSize == 0 ? 0 : maxPeriodSize - (bufferSize % maxPeriodSize))); + m_bytesPerFrame = (audioFormat.sampleSize() / 8) * audioFormat.channels(); + m_periodTime = m_maxPeriodSize / m_bytesPerFrame * 1000 / audioFormat.frequency(); + + m_fillTimer = new QTimer(this); + connect(m_fillTimer, SIGNAL(timeout()), SLOT(fillBuffer())); + } + + ~QAudioOutputBuffer() + { + delete m_buffer; + } + + qint64 readFrames(char* data, qint64 maxFrames) + { + bool wecan = true; + qint64 framesRead = 0; + + while (wecan && framesRead < maxFrames) { + QAudioRingBuffer::Region region = m_buffer->acquireReadRegion((maxFrames - framesRead) * m_bytesPerFrame); + + if (region.second > 0) { + // Ensure that we only read whole frames. + region.second -= region.second % m_bytesPerFrame; + + if (region.second > 0) { + memcpy(data + (framesRead * m_bytesPerFrame), region.first, region.second); + framesRead += region.second / m_bytesPerFrame; + } else + wecan = false; // If there is only a partial frame left we should exit. + } + else + wecan = false; + + m_buffer->releaseReadRegion(region); + } + + if (framesRead == 0 && m_deviceError) + framesRead = -1; + + return framesRead; + } + + qint64 writeBytes(const char* data, qint64 maxSize) + { + bool wecan = true; + qint64 bytesWritten = 0; + + maxSize -= maxSize % m_bytesPerFrame; + while (wecan && bytesWritten < maxSize) { + QAudioRingBuffer::Region region = m_buffer->acquireWriteRegion(maxSize - bytesWritten); + + if (region.second > 0) { + memcpy(region.first, data + bytesWritten, region.second); + bytesWritten += region.second; + } + else + wecan = false; + + m_buffer->releaseWriteRegion(region); + } + + if (bytesWritten > 0) + emit readyRead(); + + return bytesWritten; + } + + int available() const + { + return m_buffer->free(); + } + + void reset() + { + m_buffer->reset(); + m_device = 0; + m_deviceError = false; + } + + void setPrefetchDevice(QIODevice* device) + { + if (m_device != device) { + m_device = device; + if (m_device != 0) + fillBuffer(); + } + } + + void startFillTimer() + { + if (m_device != 0) + m_fillTimer->start(m_buffer->size() / 2 / m_maxPeriodSize * m_periodTime); + } + + void stopFillTimer() + { + m_fillTimer->stop(); + } + +signals: + void readyRead(); + +private slots: + void fillBuffer() + { + const int free = m_buffer->free(); + const int writeSize = free - (free % m_maxPeriodSize); + + if (writeSize > 0) { + bool wecan = true; + int filled = 0; + + while (!m_deviceError && wecan && filled < writeSize) { + QAudioRingBuffer::Region region = m_buffer->acquireWriteRegion(writeSize - filled); + + if (region.second > 0) { + region.second = m_device->read(region.first, region.second); + if (region.second > 0) + filled += region.second; + else if (region.second == 0) + wecan = false; + else if (region.second < 0) { + m_fillTimer->stop(); + region.second = 0; + m_deviceError = true; + } + } + else + wecan = false; + + m_buffer->releaseWriteRegion(region); + } + + if (filled > 0) + emit readyRead(); + } + } + +private: + bool m_deviceError; + int m_maxPeriodSize; + int m_bytesPerFrame; + int m_periodTime; + QIODevice* m_device; + QTimer* m_fillTimer; + QAudioRingBuffer* m_buffer; +}; + + +} + +class MacOutputDevice : public QIODevice +{ + Q_OBJECT + +public: + MacOutputDevice(QtMultimediaInternal::QAudioOutputBuffer* audioBuffer, QObject* parent): + QIODevice(parent), + m_audioBuffer(audioBuffer) + { + open(QIODevice::WriteOnly | QIODevice::Unbuffered); + } + + qint64 readData(char* data, qint64 len) + { + Q_UNUSED(data); + Q_UNUSED(len); + + return 0; + } + + qint64 writeData(const char* data, qint64 len) + { + return m_audioBuffer->writeBytes(data, len); + } + + bool isSequential() const + { + return true; + } + +private: + QtMultimediaInternal::QAudioOutputBuffer* m_audioBuffer; +}; + + +QAudioOutputPrivate::QAudioOutputPrivate(const QByteArray& device) +{ + QDataStream ds(device); + quint32 did, mode; + + ds >> did >> mode; + + if (QAudio::Mode(mode) == QAudio::AudioInput) + errorCode = QAudio::OpenError; + else { + audioDeviceInfo = new QAudioDeviceInfoInternal(device, QAudio::AudioOutput); + isOpen = false; + audioDeviceId = AudioDeviceID(did); + audioUnit = 0; + audioIO = 0; + startTime = 0; + totalFrames = 0; + audioBuffer = 0; + internalBufferSize = QtMultimediaInternal::default_buffer_size; + clockFrequency = AudioGetHostClockFrequency() / 1000; + errorCode = QAudio::NoError; + stateCode = QAudio::StoppedState; + audioThreadState = Stopped; + + intervalTimer = new QTimer(this); + intervalTimer->setInterval(1000); + connect(intervalTimer, SIGNAL(timeout()), SIGNAL(notify())); + } +} + +QAudioOutputPrivate::~QAudioOutputPrivate() +{ + delete audioDeviceInfo; + close(); +} + +bool QAudioOutputPrivate::open() +{ + if (errorCode != QAudio::NoError) + return false; + + if (isOpen) + return true; + + ComponentDescription cd; + cd.componentType = kAudioUnitType_Output; + cd.componentSubType = kAudioUnitSubType_HALOutput; + cd.componentManufacturer = kAudioUnitManufacturer_Apple; + cd.componentFlags = 0; + cd.componentFlagsMask = 0; + + // Open + Component cp = FindNextComponent(NULL, &cd); + if (cp == 0) { + qWarning() << "QAudioOutput: Failed to find HAL Output component"; + return false; + } + + if (OpenAComponent(cp, &audioUnit) != noErr) { + qWarning() << "QAudioOutput: Unable to Open Output Component"; + return false; + } + + // register callback + AURenderCallbackStruct cb; + cb.inputProc = renderCallback; + cb.inputProcRefCon = this; + + if (AudioUnitSetProperty(audioUnit, + kAudioUnitProperty_SetRenderCallback, + kAudioUnitScope_Global, + 0, + &cb, + sizeof(cb)) != noErr) { + qWarning() << "QAudioOutput: Failed to set AudioUnit callback"; + return false; + } + + // Set Audio Device + if (AudioUnitSetProperty(audioUnit, + kAudioOutputUnitProperty_CurrentDevice, + kAudioUnitScope_Global, + 0, + &audioDeviceId, + sizeof(audioDeviceId)) != noErr) { + qWarning() << "QAudioOutput: Unable to use configured device"; + return false; + } + + // Set stream format + streamFormat = toAudioStreamBasicDescription(audioFormat); + + UInt32 size = sizeof(streamFormat); + if (AudioUnitSetProperty(audioUnit, + kAudioUnitProperty_StreamFormat, + kAudioUnitScope_Input, + 0, + &streamFormat, + sizeof(streamFormat)) != noErr) { + qWarning() << "QAudioOutput: Unable to Set Stream information"; + return false; + } + + // Allocate buffer + UInt32 numberOfFrames = 0; + size = sizeof(UInt32); + if (AudioUnitGetProperty(audioUnit, + kAudioDevicePropertyBufferFrameSize, + kAudioUnitScope_Global, + 0, + &numberOfFrames, + &size) != noErr) { + qWarning() << "QAudioInput: Failed to get audio period size"; + return false; + } + + periodSizeBytes = numberOfFrames * streamFormat.mBytesPerFrame; + if (internalBufferSize < periodSizeBytes * 2) + internalBufferSize = periodSizeBytes * 2; + else + internalBufferSize -= internalBufferSize % streamFormat.mBytesPerFrame; + + audioBuffer = new QtMultimediaInternal::QAudioOutputBuffer(internalBufferSize, periodSizeBytes, audioFormat); + connect(audioBuffer, SIGNAL(readyRead()), SLOT(inputReady())); // Pull + + audioIO = new MacOutputDevice(audioBuffer, this); + + // Init + if (AudioUnitInitialize(audioUnit)) { + qWarning() << "QAudioOutput: Failed to initialize AudioUnit"; + return false; + } + + isOpen = true; + + return true; +} + +void QAudioOutputPrivate::close() +{ + if (audioUnit != 0) { + AudioOutputUnitStop(audioUnit); + AudioUnitUninitialize(audioUnit); + CloseComponent(audioUnit); + } + + delete audioBuffer; +} + +QAudioFormat QAudioOutputPrivate::format() const +{ + return audioFormat; +} + +void QAudioOutputPrivate::setFormat(const QAudioFormat& fmt) +{ + if (stateCode == QAudio::StoppedState) + audioFormat = fmt; +} + +void QAudioOutputPrivate::start(QIODevice* device) +{ + QIODevice* op = device; + + if (!audioDeviceInfo->isFormatSupported(audioFormat) || !open()) { + stateCode = QAudio::StoppedState; + errorCode = QAudio::OpenError; + } + + reset(); + audioBuffer->reset(); + audioBuffer->setPrefetchDevice(op); + + if (op == 0) { + op = audioIO; + stateCode = QAudio::IdleState; + } + else + stateCode = QAudio::ActiveState; + + // Start + errorCode = QAudio::NoError; + totalFrames = 0; + startTime = AudioGetCurrentHostTime(); + + if (stateCode == QAudio::ActiveState) + audioThreadStart(); + + emit stateChanged(stateCode); +} + +QIODevice* QAudioOutputPrivate::start() +{ + if (!audioDeviceInfo->isFormatSupported(audioFormat) || !open()) { + stateCode = QAudio::StoppedState; + errorCode = QAudio::OpenError; + return audioIO; + } + + reset(); + audioBuffer->reset(); + audioBuffer->setPrefetchDevice(0); + + stateCode = QAudio::IdleState; + + // Start + errorCode = QAudio::NoError; + totalFrames = 0; + startTime = AudioGetCurrentHostTime(); + + emit stateChanged(stateCode); + + return audioIO; +} + +void QAudioOutputPrivate::stop() +{ + QMutexLocker lock(&mutex); + if (stateCode != QAudio::StoppedState) { + audioThreadDrain(); + + stateCode = QAudio::StoppedState; + errorCode = QAudio::NoError; + QMetaObject::invokeMethod(this, "stateChanged", Qt::QueuedConnection, Q_ARG(QAudio::State, stateCode)); + } +} + +void QAudioOutputPrivate::reset() +{ + QMutexLocker lock(&mutex); + if (stateCode != QAudio::StoppedState) { + audioThreadStop(); + + stateCode = QAudio::StoppedState; + errorCode = QAudio::NoError; + QMetaObject::invokeMethod(this, "stateChanged", Qt::QueuedConnection, Q_ARG(QAudio::State, stateCode)); + } +} + +void QAudioOutputPrivate::suspend() +{ + QMutexLocker lock(&mutex); + if (stateCode == QAudio::ActiveState || stateCode == QAudio::IdleState) { + audioThreadStop(); + + stateCode = QAudio::SuspendedState; + errorCode = QAudio::NoError; + QMetaObject::invokeMethod(this, "stateChanged", Qt::QueuedConnection, Q_ARG(QAudio::State, stateCode)); + } +} + +void QAudioOutputPrivate::resume() +{ + QMutexLocker lock(&mutex); + if (stateCode == QAudio::SuspendedState) { + audioThreadStart(); + + stateCode = QAudio::ActiveState; + errorCode = QAudio::NoError; + QMetaObject::invokeMethod(this, "stateChanged", Qt::QueuedConnection, Q_ARG(QAudio::State, stateCode)); + } +} + +int QAudioOutputPrivate::bytesFree() const +{ + return audioBuffer->available(); +} + +int QAudioOutputPrivate::periodSize() const +{ + return periodSizeBytes; +} + +void QAudioOutputPrivate::setBufferSize(int bs) +{ + if (stateCode == QAudio::StoppedState) + internalBufferSize = bs; +} + +int QAudioOutputPrivate::bufferSize() const +{ + return internalBufferSize; +} + +void QAudioOutputPrivate::setNotifyInterval(int milliSeconds) +{ + if (intervalTimer->interval() == milliSeconds) + return; + + if (milliSeconds <= 0) + milliSeconds = 0; + + intervalTimer->setInterval(milliSeconds); +} + +int QAudioOutputPrivate::notifyInterval() const +{ + return intervalTimer->interval(); +} + +qint64 QAudioOutputPrivate::processedUSecs() const +{ + return totalFrames * 1000000 / audioFormat.frequency(); +} + +qint64 QAudioOutputPrivate::elapsedUSecs() const +{ + if (stateCode == QAudio::StoppedState) + return 0; + + return (AudioGetCurrentHostTime() - startTime) / (clockFrequency / 1000); +} + +QAudio::Error QAudioOutputPrivate::error() const +{ + return errorCode; +} + +QAudio::State QAudioOutputPrivate::state() const +{ + return stateCode; +} + +void QAudioOutputPrivate::audioThreadStart() +{ + startTimers(); + audioThreadState = Running; + AudioOutputUnitStart(audioUnit); +} + +void QAudioOutputPrivate::audioThreadStop() +{ + stopTimers(); + if (audioThreadState.testAndSetAcquire(Running, Stopped)) + threadFinished.wait(&mutex); +} + +void QAudioOutputPrivate::audioThreadDrain() +{ + stopTimers(); + if (audioThreadState.testAndSetAcquire(Running, Draining)) + threadFinished.wait(&mutex); +} + +void QAudioOutputPrivate::audioDeviceStop() +{ + AudioOutputUnitStop(audioUnit); + audioThreadState = Stopped; + threadFinished.wakeOne(); +} + +void QAudioOutputPrivate::audioDeviceIdle() +{ + QMutexLocker lock(&mutex); + if (stateCode == QAudio::ActiveState) { + audioDeviceStop(); + + errorCode = QAudio::UnderrunError; + stateCode = QAudio::IdleState; + QMetaObject::invokeMethod(this, "deviceStopped", Qt::QueuedConnection); + } +} + +void QAudioOutputPrivate::audioDeviceError() +{ + QMutexLocker lock(&mutex); + if (stateCode == QAudio::ActiveState) { + audioDeviceStop(); + + errorCode = QAudio::IOError; + stateCode = QAudio::StoppedState; + QMetaObject::invokeMethod(this, "deviceStopped", Qt::QueuedConnection); + } +} + +void QAudioOutputPrivate::startTimers() +{ + audioBuffer->startFillTimer(); + if (intervalTimer->interval() > 0) + intervalTimer->start(); +} + +void QAudioOutputPrivate::stopTimers() +{ + audioBuffer->stopFillTimer(); + intervalTimer->stop(); +} + + +void QAudioOutputPrivate::deviceStopped() +{ + intervalTimer->stop(); + emit stateChanged(stateCode); +} + +void QAudioOutputPrivate::inputReady() +{ + QMutexLocker lock(&mutex); + if (stateCode == QAudio::IdleState) { + audioThreadStart(); + + stateCode = QAudio::ActiveState; + errorCode = QAudio::NoError; + + QMetaObject::invokeMethod(this, "stateChanged", Qt::QueuedConnection, Q_ARG(QAudio::State, stateCode)); + } +} + + +OSStatus QAudioOutputPrivate::renderCallback(void* inRefCon, + AudioUnitRenderActionFlags* ioActionFlags, + const AudioTimeStamp* inTimeStamp, + UInt32 inBusNumber, + UInt32 inNumberFrames, + AudioBufferList* ioData) +{ + Q_UNUSED(ioActionFlags) + Q_UNUSED(inTimeStamp) + Q_UNUSED(inBusNumber) + Q_UNUSED(inNumberFrames) + + QAudioOutputPrivate* d = static_cast(inRefCon); + + const int threadState = d->audioThreadState.fetchAndAddAcquire(0); + if (threadState == Stopped) { + ioData->mBuffers[0].mDataByteSize = 0; + d->audioDeviceStop(); + } + else { + const UInt32 bytesPerFrame = d->streamFormat.mBytesPerFrame; + qint64 framesRead; + + framesRead = d->audioBuffer->readFrames((char*)ioData->mBuffers[0].mData, + ioData->mBuffers[0].mDataByteSize / bytesPerFrame); + + if (framesRead > 0) { + ioData->mBuffers[0].mDataByteSize = framesRead * bytesPerFrame; + d->totalFrames += framesRead; + } + else { + ioData->mBuffers[0].mDataByteSize = 0; + if (framesRead == 0) { + if (threadState == Draining) + d->audioDeviceStop(); + else + d->audioDeviceIdle(); + } + else + d->audioDeviceError(); + } + } + + return noErr; +} + + +QT_END_NAMESPACE + +#include "qaudiooutput_mac_p.moc" diff --git a/src/multimedia/audio/qaudiooutput_mac_p.h b/src/multimedia/audio/qaudiooutput_mac_p.h new file mode 100644 index 000000000..ded618cbb --- /dev/null +++ b/src/multimedia/audio/qaudiooutput_mac_p.h @@ -0,0 +1,174 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists for the convenience +// of other Qt classes. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#ifndef QAUDIOOUTPUT_MAC_P_H +#define QAUDIOOUTPUT_MAC_P_H + +#include +#include +#include +#include + +#include +#include +#include +#include +#include + +#include +#include +#include + +QT_BEGIN_HEADER + +QT_BEGIN_NAMESPACE + +QT_MODULE(Multimedia) + + +class QIODevice; +class QAbstractAudioDeviceInfo; + +namespace QtMultimediaInternal +{ +class QAudioOutputBuffer; +} + +class QAudioOutputPrivate : public QAbstractAudioOutput +{ + Q_OBJECT + +public: + bool isOpen; + int internalBufferSize; + int periodSizeBytes; + qint64 totalFrames; + QAudioFormat audioFormat; + QIODevice* audioIO; + AudioDeviceID audioDeviceId; + AudioUnit audioUnit; + Float64 clockFrequency; + UInt64 startTime; + AudioStreamBasicDescription deviceFormat; + AudioStreamBasicDescription streamFormat; + QtMultimediaInternal::QAudioOutputBuffer* audioBuffer; + QAtomicInt audioThreadState; + QWaitCondition threadFinished; + QMutex mutex; + QTimer* intervalTimer; + QAbstractAudioDeviceInfo *audioDeviceInfo; + + QAudio::Error errorCode; + QAudio::State stateCode; + + QAudioOutputPrivate(const QByteArray& device); + ~QAudioOutputPrivate(); + + bool open(); + void close(); + + QAudioFormat format() const; + void setFormat(const QAudioFormat& fmt); + + QIODevice* start(); + void start(QIODevice* device); + void stop(); + void reset(); + void suspend(); + void resume(); + + int bytesFree() const; + int periodSize() const; + + void setBufferSize(int value); + int bufferSize() const; + + void setNotifyInterval(int milliSeconds); + int notifyInterval() const; + + qint64 processedUSecs() const; + qint64 elapsedUSecs() const; + + QAudio::Error error() const; + QAudio::State state() const; + + void audioThreadStart(); + void audioThreadStop(); + void audioThreadDrain(); + + void audioDeviceStop(); + void audioDeviceIdle(); + void audioDeviceError(); + + void startTimers(); + void stopTimers(); + +private slots: + void deviceStopped(); + void inputReady(); + +private: + enum { Running, Draining, Stopped }; + + static OSStatus renderCallback(void* inRefCon, + AudioUnitRenderActionFlags* ioActionFlags, + const AudioTimeStamp* inTimeStamp, + UInt32 inBusNumber, + UInt32 inNumberFrames, + AudioBufferList* ioData); +}; + +QT_END_NAMESPACE + +QT_END_HEADER + +#endif diff --git a/src/multimedia/audio/qaudiooutput_win32_p.cpp b/src/multimedia/audio/qaudiooutput_win32_p.cpp new file mode 100644 index 000000000..d5b31a30f --- /dev/null +++ b/src/multimedia/audio/qaudiooutput_win32_p.cpp @@ -0,0 +1,715 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists for the convenience +// of other Qt classes. This header file may change from version to +// version without notice, or even be removed. +// +// INTERNAL USE ONLY: Do NOT use for any other purpose. +// + +#include "qaudiooutput_win32_p.h" + +#ifndef SPEAKER_FRONT_LEFT + #define SPEAKER_FRONT_LEFT 0x00000001 + #define SPEAKER_FRONT_RIGHT 0x00000002 + #define SPEAKER_FRONT_CENTER 0x00000004 + #define SPEAKER_LOW_FREQUENCY 0x00000008 + #define SPEAKER_BACK_LEFT 0x00000010 + #define SPEAKER_BACK_RIGHT 0x00000020 + #define SPEAKER_FRONT_LEFT_OF_CENTER 0x00000040 + #define SPEAKER_FRONT_RIGHT_OF_CENTER 0x00000080 + #define SPEAKER_BACK_CENTER 0x00000100 + #define SPEAKER_SIDE_LEFT 0x00000200 + #define SPEAKER_SIDE_RIGHT 0x00000400 + #define SPEAKER_TOP_CENTER 0x00000800 + #define SPEAKER_TOP_FRONT_LEFT 0x00001000 + #define SPEAKER_TOP_FRONT_CENTER 0x00002000 + #define SPEAKER_TOP_FRONT_RIGHT 0x00004000 + #define SPEAKER_TOP_BACK_LEFT 0x00008000 + #define SPEAKER_TOP_BACK_CENTER 0x00010000 + #define SPEAKER_TOP_BACK_RIGHT 0x00020000 + #define SPEAKER_RESERVED 0x7FFC0000 + #define SPEAKER_ALL 0x80000000 +#endif + +#ifndef _WAVEFORMATEXTENSIBLE_ + + #define _WAVEFORMATEXTENSIBLE_ + typedef struct + { + WAVEFORMATEX Format; // Base WAVEFORMATEX data + union + { + WORD wValidBitsPerSample; // Valid bits in each sample container + WORD wSamplesPerBlock; // Samples per block of audio data; valid + // if wBitsPerSample=0 (but rarely used). + WORD wReserved; // Zero if neither case above applies. + } Samples; + DWORD dwChannelMask; // Positions of the audio channels + GUID SubFormat; // Format identifier GUID + } WAVEFORMATEXTENSIBLE, *PWAVEFORMATEXTENSIBLE, *LPPWAVEFORMATEXTENSIBLE; + typedef const WAVEFORMATEXTENSIBLE* LPCWAVEFORMATEXTENSIBLE; + +#endif + +#if !defined(WAVE_FORMAT_EXTENSIBLE) +#define WAVE_FORMAT_EXTENSIBLE 0xFFFE +#endif + +//#define DEBUG_AUDIO 1 + +QT_BEGIN_NAMESPACE + +QAudioOutputPrivate::QAudioOutputPrivate(const QByteArray &device) +{ + bytesAvailable = 0; + buffer_size = 0; + period_size = 0; + m_device = device; + totalTimeValue = 0; + intervalTime = 1000; + audioBuffer = 0; + errorState = QAudio::NoError; + deviceState = QAudio::StoppedState; + audioSource = 0; + pullMode = true; + finished = false; +} + +QAudioOutputPrivate::~QAudioOutputPrivate() +{ + mutex.lock(); + finished = true; + mutex.unlock(); + + close(); +} + +void CALLBACK QAudioOutputPrivate::waveOutProc( HWAVEOUT hWaveOut, UINT uMsg, + DWORD dwInstance, DWORD dwParam1, DWORD dwParam2 ) +{ + Q_UNUSED(dwParam1) + Q_UNUSED(dwParam2) + Q_UNUSED(hWaveOut) + + QAudioOutputPrivate* qAudio; + qAudio = (QAudioOutputPrivate*)(dwInstance); + if(!qAudio) + return; + + QMutexLocker(&qAudio->mutex); + + switch(uMsg) { + case WOM_OPEN: + qAudio->feedback(); + break; + case WOM_CLOSE: + return; + case WOM_DONE: + if(qAudio->finished || qAudio->buffer_size == 0 || qAudio->period_size == 0) { + return; + } + qAudio->waveFreeBlockCount++; + if(qAudio->waveFreeBlockCount >= qAudio->buffer_size/qAudio->period_size) + qAudio->waveFreeBlockCount = qAudio->buffer_size/qAudio->period_size; + qAudio->feedback(); + break; + default: + return; + } +} + +WAVEHDR* QAudioOutputPrivate::allocateBlocks(int size, int count) +{ + int i; + unsigned char* buffer; + WAVEHDR* blocks; + DWORD totalBufferSize = (size + sizeof(WAVEHDR))*count; + + if((buffer=(unsigned char*)HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY, + totalBufferSize)) == 0) { + qWarning("QAudioOutput: Memory allocation error"); + return 0; + } + blocks = (WAVEHDR*)buffer; + buffer += sizeof(WAVEHDR)*count; + for(i = 0; i < count; i++) { + blocks[i].dwBufferLength = size; + blocks[i].lpData = (LPSTR)buffer; + buffer += size; + } + return blocks; +} + +void QAudioOutputPrivate::freeBlocks(WAVEHDR* blockArray) +{ + WAVEHDR* blocks = blockArray; + + int count = buffer_size/period_size; + + for(int i = 0; i < count; i++) { + waveOutUnprepareHeader(hWaveOut,blocks, sizeof(WAVEHDR)); + blocks++; + } + HeapFree(GetProcessHeap(), 0, blockArray); +} + +QAudioFormat QAudioOutputPrivate::format() const +{ + return settings; +} + +void QAudioOutputPrivate::setFormat(const QAudioFormat& fmt) +{ + if (deviceState == QAudio::StoppedState) + settings = fmt; +} + +void QAudioOutputPrivate::start(QIODevice* device) +{ + if(deviceState != QAudio::StoppedState) + close(); + + if(!pullMode && audioSource) + delete audioSource; + + pullMode = true; + audioSource = device; + + deviceState = QAudio::ActiveState; + + if(!open()) + return; + + emit stateChanged(deviceState); +} + +QIODevice* QAudioOutputPrivate::start() +{ + if(deviceState != QAudio::StoppedState) + close(); + + if(!pullMode && audioSource) + delete audioSource; + + pullMode = false; + audioSource = new OutputPrivate(this); + audioSource->open(QIODevice::WriteOnly|QIODevice::Unbuffered); + + deviceState = QAudio::IdleState; + + if(!open()) + return 0; + + emit stateChanged(deviceState); + + return audioSource; +} + +void QAudioOutputPrivate::stop() +{ + if(deviceState == QAudio::StoppedState) + return; + close(); + if(!pullMode && audioSource) { + delete audioSource; + audioSource = 0; + } + emit stateChanged(deviceState); +} + +bool QAudioOutputPrivate::open() +{ +#ifdef DEBUG_AUDIO + QTime now(QTime::currentTime()); + qDebug()< 96000) { + qWarning("QAudioOutput: open error, frequency out of range (%d).", settings.frequency()); + } else if (buffer_size == 0) { + // Default buffer size, 200ms, default period size is 40ms + buffer_size + = (settings.frequency() + * settings.channelCount() + * settings.sampleSize() + + 39) / 40; + period_size = buffer_size / 5; + } else { + period_size = buffer_size / 5; + } + + if (period_size == 0) { + errorState = QAudio::OpenError; + deviceState = QAudio::StoppedState; + emit stateChanged(deviceState); + return false; + } + + waveBlocks = allocateBlocks(period_size, buffer_size/period_size); + + mutex.lock(); + waveFreeBlockCount = buffer_size/period_size; + mutex.unlock(); + + waveCurrentBlock = 0; + + if(audioBuffer == 0) + audioBuffer = new char[buffer_size]; + + timeStamp.restart(); + elapsedTimeOffset = 0; + + wfx.nSamplesPerSec = settings.frequency(); + wfx.wBitsPerSample = settings.sampleSize(); + wfx.nChannels = settings.channels(); + wfx.cbSize = 0; + + bool surround = false; + + if (settings.channels() > 2) + surround = true; + + wfx.wFormatTag = WAVE_FORMAT_PCM; + wfx.nBlockAlign = (wfx.wBitsPerSample >> 3) * wfx.nChannels; + wfx.nAvgBytesPerSec = wfx.nBlockAlign * wfx.nSamplesPerSec; + + QDataStream ds(&m_device, QIODevice::ReadOnly); + quint32 deviceId; + ds >> deviceId; + + if (!surround) { + if (waveOutOpen(&hWaveOut, UINT_PTR(deviceId), &wfx, + (DWORD_PTR)&waveOutProc, + (DWORD_PTR) this, + CALLBACK_FUNCTION) != MMSYSERR_NOERROR) { + errorState = QAudio::OpenError; + deviceState = QAudio::StoppedState; + emit stateChanged(deviceState); + qWarning("QAudioOutput: open error"); + return false; + } + } else { + WAVEFORMATEXTENSIBLE wfex; + wfex.Format.wFormatTag = WAVE_FORMAT_EXTENSIBLE; + wfex.Format.nChannels = settings.channels(); + wfex.Format.wBitsPerSample = settings.sampleSize(); + wfex.Format.nSamplesPerSec = settings.frequency(); + wfex.Format.nBlockAlign = wfex.Format.nChannels*wfex.Format.wBitsPerSample/8; + wfex.Format.nAvgBytesPerSec=wfex.Format.nSamplesPerSec*wfex.Format.nBlockAlign; + wfex.Samples.wValidBitsPerSample=wfex.Format.wBitsPerSample; + static const GUID _KSDATAFORMAT_SUBTYPE_PCM = { + 0x00000001, 0x0000, 0x0010, {0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}}; + wfex.SubFormat=_KSDATAFORMAT_SUBTYPE_PCM; + wfex.Format.cbSize=22; + + wfex.dwChannelMask = SPEAKER_FRONT_LEFT | SPEAKER_FRONT_RIGHT; + if (settings.channels() >= 4) + wfex.dwChannelMask |= SPEAKER_BACK_LEFT | SPEAKER_BACK_RIGHT; + if (settings.channels() >= 6) + wfex.dwChannelMask |= SPEAKER_FRONT_CENTER | SPEAKER_LOW_FREQUENCY; + if (settings.channels() == 8) + wfex.dwChannelMask |= SPEAKER_SIDE_LEFT | SPEAKER_SIDE_RIGHT; + + if (waveOutOpen(&hWaveOut, UINT_PTR(deviceId), &wfex.Format, + (DWORD_PTR)&waveOutProc, + (DWORD_PTR) this, + CALLBACK_FUNCTION) != MMSYSERR_NOERROR) { + errorState = QAudio::OpenError; + deviceState = QAudio::StoppedState; + emit stateChanged(deviceState); + qWarning("QAudioOutput: open error"); + return false; + } + } + + totalTimeValue = 0; + timeStampOpened.restart(); + elapsedTimeOffset = 0; + + errorState = QAudio::NoError; + if(pullMode) { + deviceState = QAudio::ActiveState; + QTimer::singleShot(10, this, SLOT(feedback())); + } else + deviceState = QAudio::IdleState; + + return true; +} + +void QAudioOutputPrivate::close() +{ + if(deviceState == QAudio::StoppedState) + return; + + deviceState = QAudio::StoppedState; + errorState = QAudio::NoError; + int delay = (buffer_size-bytesFree())*1000/(settings.frequency() + *settings.channels()*(settings.sampleSize()/8)); + waveOutReset(hWaveOut); + Sleep(delay+10); + + freeBlocks(waveBlocks); + waveOutClose(hWaveOut); + delete [] audioBuffer; + audioBuffer = 0; + buffer_size = 0; +} + +int QAudioOutputPrivate::bytesFree() const +{ + int buf; + buf = waveFreeBlockCount*period_size; + + return buf; +} + +int QAudioOutputPrivate::periodSize() const +{ + return period_size; +} + +void QAudioOutputPrivate::setBufferSize(int value) +{ + if(deviceState == QAudio::StoppedState) + buffer_size = value; +} + +int QAudioOutputPrivate::bufferSize() const +{ + return buffer_size; +} + +void QAudioOutputPrivate::setNotifyInterval(int ms) +{ + intervalTime = qMax(0, ms); +} + +int QAudioOutputPrivate::notifyInterval() const +{ + return intervalTime; +} + +qint64 QAudioOutputPrivate::processedUSecs() const +{ + if (deviceState == QAudio::StoppedState) + return 0; + qint64 result = qint64(1000000) * totalTimeValue / + (settings.channels()*(settings.sampleSize()/8)) / + settings.frequency(); + + return result; +} + +qint64 QAudioOutputPrivate::write( const char *data, qint64 len ) +{ + // Write out some audio data + if (deviceState != QAudio::ActiveState && deviceState != QAudio::IdleState) + return 0; + + char* p = (char*)data; + int l = (int)len; + + WAVEHDR* current; + int remain; + current = &waveBlocks[waveCurrentBlock]; + while(l > 0) { + mutex.lock(); + if(waveFreeBlockCount==0) { + mutex.unlock(); + break; + } + mutex.unlock(); + + if(current->dwFlags & WHDR_PREPARED) + waveOutUnprepareHeader(hWaveOut, current, sizeof(WAVEHDR)); + + if(l < period_size) + remain = l; + else + remain = period_size; + memcpy(current->lpData, p, remain); + + l -= remain; + p += remain; + current->dwBufferLength = remain; + waveOutPrepareHeader(hWaveOut, current, sizeof(WAVEHDR)); + waveOutWrite(hWaveOut, current, sizeof(WAVEHDR)); + + mutex.lock(); + waveFreeBlockCount--; +#ifdef DEBUG_AUDIO + qDebug("write out l=%d, waveFreeBlockCount=%d", + current->dwBufferLength,waveFreeBlockCount); +#endif + mutex.unlock(); + + totalTimeValue += current->dwBufferLength; + waveCurrentBlock++; + waveCurrentBlock %= buffer_size/period_size; + current = &waveBlocks[waveCurrentBlock]; + current->dwUser = 0; + errorState = QAudio::NoError; + if (deviceState != QAudio::ActiveState) { + deviceState = QAudio::ActiveState; + emit stateChanged(deviceState); + } + } + return (len-l); +} + +void QAudioOutputPrivate::resume() +{ + if(deviceState == QAudio::SuspendedState) { + deviceState = QAudio::ActiveState; + errorState = QAudio::NoError; + waveOutRestart(hWaveOut); + QTimer::singleShot(10, this, SLOT(feedback())); + emit stateChanged(deviceState); + } +} + +void QAudioOutputPrivate::suspend() +{ + if(deviceState == QAudio::ActiveState || deviceState == QAudio::IdleState) { + int delay = (buffer_size-bytesFree())*1000/(settings.frequency() + *settings.channels()*(settings.sampleSize()/8)); + waveOutPause(hWaveOut); + Sleep(delay+10); + deviceState = QAudio::SuspendedState; + errorState = QAudio::NoError; + emit stateChanged(deviceState); + } +} + +void QAudioOutputPrivate::feedback() +{ +#ifdef DEBUG_AUDIO + QTime now(QTime::currentTime()); + qDebug()<= period_size) + QMetaObject::invokeMethod(this, "deviceReady", Qt::QueuedConnection); + } +} + +bool QAudioOutputPrivate::deviceReady() +{ + if(deviceState == QAudio::StoppedState || deviceState == QAudio::SuspendedState) + return false; + + if(pullMode) { + int chunks = bytesAvailable/period_size; +#ifdef DEBUG_AUDIO + qDebug()<<"deviceReady() avail="< intervalTime ) { + emit notify(); + elapsedTimeOffset = timeStamp.elapsed() + elapsedTimeOffset - intervalTime; + timeStamp.restart(); + } + return true; + } + + if(startup) + waveOutPause(hWaveOut); + int input = period_size*chunks; + int l = audioSource->read(audioBuffer,input); + if(l > 0) { + int out= write(audioBuffer,l); + if(out > 0) { + if (deviceState != QAudio::ActiveState) { + deviceState = QAudio::ActiveState; + emit stateChanged(deviceState); + } + } + if ( out < l) { + // Didn't write all data + audioSource->seek(audioSource->pos()-(l-out)); + } + if(startup) + waveOutRestart(hWaveOut); + } else if(l == 0) { + bytesAvailable = bytesFree(); + + int check = 0; + + mutex.lock(); + check = waveFreeBlockCount; + mutex.unlock(); + + if(check == buffer_size/period_size) { + if (deviceState != QAudio::IdleState) { + errorState = QAudio::UnderrunError; + deviceState = QAudio::IdleState; + emit stateChanged(deviceState); + } + } + + } else if(l < 0) { + bytesAvailable = bytesFree(); + if (errorState != QAudio::IOError) + errorState = QAudio::IOError; + } + } else { + int buffered; + + mutex.lock(); + buffered = waveFreeBlockCount; + mutex.unlock(); + + if (buffered >= buffer_size/period_size && deviceState == QAudio::ActiveState) { + if (deviceState != QAudio::IdleState) { + errorState = QAudio::UnderrunError; + deviceState = QAudio::IdleState; + emit stateChanged(deviceState); + } + } + } + if(deviceState != QAudio::ActiveState && deviceState != QAudio::IdleState) + return true; + + if(intervalTime && (timeStamp.elapsed() + elapsedTimeOffset) > intervalTime) { + emit notify(); + elapsedTimeOffset = timeStamp.elapsed() + elapsedTimeOffset - intervalTime; + timeStamp.restart(); + } + + return true; +} + +qint64 QAudioOutputPrivate::elapsedUSecs() const +{ + if (deviceState == QAudio::StoppedState) + return 0; + + return timeStampOpened.elapsed()*1000; +} + +QAudio::Error QAudioOutputPrivate::error() const +{ + return errorState; +} + +QAudio::State QAudioOutputPrivate::state() const +{ + return deviceState; +} + +void QAudioOutputPrivate::reset() +{ + close(); +} + +OutputPrivate::OutputPrivate(QAudioOutputPrivate* audio) +{ + audioDevice = qobject_cast(audio); +} + +OutputPrivate::~OutputPrivate() {} + +qint64 OutputPrivate::readData( char* data, qint64 len) +{ + Q_UNUSED(data) + Q_UNUSED(len) + + return 0; +} + +qint64 OutputPrivate::writeData(const char* data, qint64 len) +{ + int retry = 0; + qint64 written = 0; + + if((audioDevice->deviceState == QAudio::ActiveState) + ||(audioDevice->deviceState == QAudio::IdleState)) { + qint64 l = len; + while(written < l) { + int chunk = audioDevice->write(data+written,(l-written)); + if(chunk <= 0) + retry++; + else + written+=chunk; + + if(retry > 10) + return written; + } + audioDevice->deviceState = QAudio::ActiveState; + } + return written; +} + +QT_END_NAMESPACE + +#include "moc_qaudiooutput_win32_p.cpp" diff --git a/src/multimedia/audio/qaudiooutput_win32_p.h b/src/multimedia/audio/qaudiooutput_win32_p.h new file mode 100644 index 000000000..aa86d4e9b --- /dev/null +++ b/src/multimedia/audio/qaudiooutput_win32_p.h @@ -0,0 +1,175 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists for the convenience +// of other Qt classes. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#ifndef QAUDIOOUTPUTWIN_H +#define QAUDIOOUTPUTWIN_H + +#include +#include + +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +// For compat with 4.6 +#if !defined(QT_WIN_CALLBACK) +# if defined(Q_CC_MINGW) +# define QT_WIN_CALLBACK CALLBACK __attribute__ ((force_align_arg_pointer)) +# else +# define QT_WIN_CALLBACK CALLBACK +# endif +#endif + +QT_BEGIN_HEADER + +QT_BEGIN_NAMESPACE + +QT_MODULE(Multimedia) + + +class QAudioOutputPrivate : public QAbstractAudioOutput +{ + Q_OBJECT +public: + QAudioOutputPrivate(const QByteArray &device); + ~QAudioOutputPrivate(); + + qint64 write( const char *data, qint64 len ); + + void setFormat(const QAudioFormat& fmt); + QAudioFormat format() const; + QIODevice* start(); + void start(QIODevice* device); + void stop(); + void reset(); + void suspend(); + void resume(); + int bytesFree() const; + int periodSize() const; + void setBufferSize(int value); + int bufferSize() const; + void setNotifyInterval(int milliSeconds); + int notifyInterval() const; + qint64 processedUSecs() const; + qint64 elapsedUSecs() const; + QAudio::Error error() const; + QAudio::State state() const; + + QIODevice* audioSource; + QAudioFormat settings; + QAudio::Error errorState; + QAudio::State deviceState; + +private slots: + void feedback(); + bool deviceReady(); + +private: + QByteArray m_device; + bool resuming; + int bytesAvailable; + QTime timeStamp; + qint64 elapsedTimeOffset; + QTime timeStampOpened; + qint32 buffer_size; + qint32 period_size; + qint64 totalTimeValue; + bool pullMode; + int intervalTime; + static void QT_WIN_CALLBACK waveOutProc( HWAVEOUT hWaveOut, UINT uMsg, + DWORD dwInstance, DWORD dwParam1, DWORD dwParam2 ); + + QMutex mutex; + + WAVEHDR* allocateBlocks(int size, int count); + void freeBlocks(WAVEHDR* blockArray); + bool open(); + void close(); + + WAVEFORMATEX wfx; + HWAVEOUT hWaveOut; + MMRESULT result; + WAVEHDR header; + WAVEHDR* waveBlocks; + volatile bool finished; + volatile int waveFreeBlockCount; + int waveCurrentBlock; + char* audioBuffer; +}; + +class OutputPrivate : public QIODevice +{ + Q_OBJECT +public: + OutputPrivate(QAudioOutputPrivate* audio); + ~OutputPrivate(); + + qint64 readData( char* data, qint64 len); + qint64 writeData(const char* data, qint64 len); + +private: + QAudioOutputPrivate *audioDevice; +}; + +QT_END_NAMESPACE + +QT_END_HEADER + + +#endif diff --git a/src/multimedia/audio/qaudiopluginloader.cpp b/src/multimedia/audio/qaudiopluginloader.cpp new file mode 100644 index 000000000..58006356a --- /dev/null +++ b/src/multimedia/audio/qaudiopluginloader.cpp @@ -0,0 +1,176 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qaudiosystemplugin.h" +#include "qaudiopluginloader_p.h" + +#include +#include +#include +#include +#include + +QT_BEGIN_NAMESPACE + +QAudioPluginLoader::QAudioPluginLoader(const char *iid, const QString &location, Qt::CaseSensitivity): + m_iid(iid) +{ + m_location = location + QLatin1Char('/'); + load(); +} + +QAudioPluginLoader::~QAudioPluginLoader() +{ + for (int i = 0; i < m_plugins.count(); i++ ) { + delete m_plugins.at(i); + } +} + +QStringList QAudioPluginLoader::pluginList() const +{ +#if !defined QT_NO_DEBUG + const bool showDebug = qgetenv("QT_DEBUG_PLUGINS").toInt() > 0; +#endif + + QStringList paths = QCoreApplication::libraryPaths(); +#ifdef QTM_PLUGIN_PATH + paths << QLatin1String(QTM_PLUGIN_PATH); +#endif +#if !defined QT_NO_DEBUG + if (showDebug) + qDebug() << "Plugin paths:" << paths; +#endif + + //temp variable to avoid multiple identic path + QSet processed; + + /* Discover a bunch o plugins */ + QStringList plugins; + + /* Enumerate our plugin paths */ + for (int i=0; i < paths.count(); i++) { + if (processed.contains(paths.at(i))) + continue; + processed.insert(paths.at(i)); + QDir pluginsDir(paths.at(i)+m_location); + if (!pluginsDir.exists()) + continue; + + QStringList files = pluginsDir.entryList(QDir::Files); +#if !defined QT_NO_DEBUG + if (showDebug) + qDebug()<<"Looking for plugins in "<(&m_mutex)); + + QStringList list; + for (int i = 0; i < m_plugins.count(); i++) { + QAudioSystemPlugin* p = qobject_cast(m_plugins.at(i)->instance()); + if (p) list << p->keys(); + } + + return list; +} + +QObject* QAudioPluginLoader::instance(QString const &key) +{ + QMutexLocker locker(&m_mutex); + + for (int i = 0; i < m_plugins.count(); i++) { + QAudioSystemPlugin* p = qobject_cast(m_plugins.at(i)->instance()); + if (p && p->keys().contains(key)) + return m_plugins.at(i)->instance(); + } + return 0; +} + +QList QAudioPluginLoader::instances(QString const &key) +{ + QMutexLocker locker(&m_mutex); + + QList list; + for (int i = 0; i < m_plugins.count(); i++) { + QAudioSystemPlugin* p = qobject_cast(m_plugins.at(i)->instance()); + if (p && p->keys().contains(key)) + list << m_plugins.at(i)->instance(); + } + return list; +} + +void QAudioPluginLoader::load() +{ + if (!m_plugins.isEmpty()) + return; + +#if !defined QT_NO_DEBUG + const bool showDebug = qgetenv("QT_DEBUG_PLUGINS").toInt() > 0; +#endif + + QStringList plugins = pluginList(); + for (int i=0; i < plugins.count(); i++) { + QPluginLoader* loader = new QPluginLoader(plugins.at(i)); + QObject *o = loader->instance(); + if (o != 0 && o->qt_metacast(m_iid) != 0) { + m_plugins.append(loader); + } else { +#if !defined QT_NO_DEBUG + if (showDebug) + qWarning() << "QAudioPluginLoader: Failed to load plugin: " + << plugins.at(i) << loader->errorString(); +#endif + delete o; + //we are not calling loader->unload here for it may cause problem on some device + delete loader; + } + } +} +QT_END_NAMESPACE + diff --git a/src/multimedia/audio/qaudiopluginloader_p.h b/src/multimedia/audio/qaudiopluginloader_p.h new file mode 100644 index 000000000..2e6fdbdd7 --- /dev/null +++ b/src/multimedia/audio/qaudiopluginloader_p.h @@ -0,0 +1,100 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QAUDIOPLUGINLOADER_H +#define QAUDIOPLUGINLOADER_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 +#include +#include +#include +#include +#include + + +QT_BEGIN_HEADER + +QT_BEGIN_NAMESPACE + +QT_MODULE(Multimedia) + + +class QAudioPluginLoader +{ +public: + QAudioPluginLoader(const char *iid, + const QString &suffix = QString(), + Qt::CaseSensitivity = Qt::CaseSensitive); + + ~QAudioPluginLoader(); + + QStringList keys() const; + QObject* instance(QString const &key); + QList instances(QString const &key); + +private: + QStringList pluginList() const; + void load(); + + QMutex m_mutex; + + QByteArray m_iid; + QString m_location; + QList m_plugins; +}; + +QT_END_NAMESPACE + +QT_END_HEADER + + +#endif // QAUDIOPLUGINLOADER_H diff --git a/src/multimedia/audio/qaudiosystem.cpp b/src/multimedia/audio/qaudiosystem.cpp new file mode 100644 index 000000000..a8837b06f --- /dev/null +++ b/src/multimedia/audio/qaudiosystem.cpp @@ -0,0 +1,436 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qaudiosystem.h" + +QT_BEGIN_NAMESPACE + +/*! + \class QAbstractAudioDeviceInfo + \brief The QAbstractAudioDeviceInfo class is a base class for audio backends. + + \ingroup multimedia + \inmodule QtMultimedia + \internal + \since 1.0 + + This class implements the audio functionality for + QAudioDeviceInfo, i.e., QAudioDeviceInfo keeps a + QAbstractAudioDeviceInfo and routes function calls to it. For a + description of the functionality that QAbstractAudioDeviceInfo + implements, you can read the class and functions documentation of + QAudioDeviceInfo. + + \sa QAudioDeviceInfo + \sa QAbstractAudioOutput, QAbstractAudioInput +*/ + +/*! + \fn virtual QAudioFormat QAbstractAudioDeviceInfo::preferredFormat() const + Returns the recommended settings to use. + \since 1.0 +*/ + +/*! + \fn virtual bool QAbstractAudioDeviceInfo::isFormatSupported(const QAudioFormat& format) const + Returns true if \a format is available from audio device. + \since 1.0 +*/ + +/*! + \fn virtual QString QAbstractAudioDeviceInfo::deviceName() const + Returns the audio device name. + \since 1.0 +*/ + +/*! + \fn virtual QStringList QAbstractAudioDeviceInfo::supportedCodecs() + Returns the list of currently available codecs. + \since 1.0 +*/ + +/*! + \fn virtual QList QAbstractAudioDeviceInfo::supportedSampleRates() + Returns the list of currently available sample rates. + \since 1.0 +*/ + +/*! + \fn virtual QList QAbstractAudioDeviceInfo::supportedChannelCounts() + Returns the list of currently available channels. + \since 1.0 +*/ + +/*! + \fn virtual QList QAbstractAudioDeviceInfo::supportedSampleSizes() + Returns the list of currently available sample sizes. + \since 1.0 +*/ + +/*! + \fn virtual QList QAbstractAudioDeviceInfo::supportedByteOrders() + Returns the list of currently available byte orders. + \since 1.0 +*/ + +/*! + \fn virtual QList QAbstractAudioDeviceInfo::supportedSampleTypes() + Returns the list of currently available sample types. + \since 1.0 +*/ + +/*! + \class QAbstractAudioOutput + \brief The QAbstractAudioOutput class is a base class for audio backends. + \since 1.0 + + \ingroup multimedia + \inmodule QtMultimedia + \internal + + QAbstractAudioOutput implements audio functionality for + QAudioOutput, i.e., QAudioOutput routes function calls to + QAbstractAudioOutput. For a description of the functionality that + is implemented, see the QAudioOutput class and function + descriptions. + + \sa QAudioOutput +*/ + +/*! + \fn virtual void QAbstractAudioOutput::start(QIODevice* device) + Uses the \a device as the QIODevice to transfer data. + \since 1.0 +*/ + +/*! + \fn virtual QIODevice* QAbstractAudioOutput::start() + Returns a pointer to the QIODevice being used to handle + the data transfer. This QIODevice can be used to write() audio data directly. + \since 1.0 +*/ + +/*! + \fn virtual void QAbstractAudioOutput::stop() + Stops the audio output. + \since 1.0 +*/ + +/*! + \fn virtual void QAbstractAudioOutput::reset() + Drops all audio data in the buffers, resets buffers to zero. + \since 1.0 +*/ + +/*! + \fn virtual void QAbstractAudioOutput::suspend() + Stops processing audio data, preserving buffered audio data. + \since 1.0 +*/ + +/*! + \fn virtual void QAbstractAudioOutput::resume() + Resumes processing audio data after a suspend() + \since 1.0 +*/ + +/*! + \fn virtual int QAbstractAudioOutput::bytesFree() const + Returns the free space available in bytes in the audio buffer. + \since 1.0 +*/ + +/*! + \fn virtual int QAbstractAudioOutput::periodSize() const + Returns the period size in bytes. + \since 1.0 +*/ + +/*! + \fn virtual void QAbstractAudioOutput::setBufferSize(int value) + Sets the audio buffer size to \a value in bytes. + \since 1.0 +*/ + +/*! + \fn virtual int QAbstractAudioOutput::bufferSize() const + Returns the audio buffer size in bytes. + \since 1.0 +*/ + +/*! + \fn virtual void QAbstractAudioOutput::setNotifyInterval(int ms) + Sets the interval for notify() signal to be emitted. This is based on the \a ms + of audio data processed not on actual real-time. The resolution of the timer + is platform specific. + \since 1.0 +*/ + +/*! + \fn virtual int QAbstractAudioOutput::notifyInterval() const + Returns the notify interval in milliseconds. + \since 1.0 +*/ + +/*! + \fn virtual qint64 QAbstractAudioOutput::processedUSecs() const + Returns the amount of audio data processed since start() was called in milliseconds. + \since 1.0 +*/ + +/*! + \fn virtual qint64 QAbstractAudioOutput::elapsedUSecs() const + Returns the milliseconds since start() was called, including time in Idle and suspend states. + \since 1.0 +*/ + +/*! + \fn virtual QAudio::Error QAbstractAudioOutput::error() const + Returns the error state. + \since 1.0 +*/ + +/*! + \fn virtual QAudio::State QAbstractAudioOutput::state() const + Returns the state of audio processing. + \since 1.0 +*/ + +/*! + \fn virtual void QAbstractAudioOutput::setFormat(const QAudioFormat& fmt) + Set the QAudioFormat to use to \a fmt. + Setting the format is only allowable while in QAudio::StoppedState. + \since 1.0 +*/ + +/*! + \fn virtual QAudioFormat QAbstractAudioOutput::format() const + Returns the QAudioFormat being used. + \since 1.0 +*/ + +/*! + \fn virtual void QAbstractAudioOutput::setVolume(qreal volume) + Sets the volume. + Where \a volume is between 0.0 and 1.0. + \since 5.0 +*/ + +/*! + \fn virtual qreal QAbstractAudioOutput::volume() const + Returns the volume in the range 0.0 and 1.0. + \since 5.0 +*/ + +/*! + \fn QAbstractAudioOutput::errorChanged(QAudio::Error error) + This signal is emitted when the \a error state has changed. + \since 1.0 +*/ + +/*! + \fn QAbstractAudioOutput::stateChanged(QAudio::State state) + This signal is emitted when the device \a state has changed. + \since 1.0 +*/ + +/*! + \fn QAbstractAudioOutput::notify() + This signal is emitted when x ms of audio data has been processed + the interval set by setNotifyInterval(x). + \since 1.0 +*/ + + +/*! + \class QAbstractAudioInput + \brief The QAbstractAudioInput class provides access for QAudioInput to access the audio + device provided by the plugin. + \since 1.0 + + \ingroup multimedia + \inmodule QtMultimedia + \internal + + QAudioDeviceInput keeps an instance of QAbstractAudioInput and + routes calls to functions of the same name to QAbstractAudioInput. + This means that it is QAbstractAudioInput that implements the + audio functionality. For a description of the functionality, see + the QAudioInput class description. + + \sa QAudioInput +*/ + +/*! + \fn virtual void QAbstractAudioInput::start(QIODevice* device) + Uses the \a device as the QIODevice to transfer data. + \since 1.0 +*/ + +/*! + \fn virtual QIODevice* QAbstractAudioInput::start() + Returns a pointer to the QIODevice being used to handle + the data transfer. This QIODevice can be used to read() audio data directly. + \since 1.0 +*/ + +/*! + \fn virtual void QAbstractAudioInput::stop() + Stops the audio input. + \since 1.0 +*/ + +/*! + \fn virtual void QAbstractAudioInput::reset() + Drops all audio data in the buffers, resets buffers to zero. + \since 1.0 +*/ + +/*! + \fn virtual void QAbstractAudioInput::suspend() + Stops processing audio data, preserving buffered audio data. + \since 1.0 +*/ + +/*! + \fn virtual void QAbstractAudioInput::resume() + Resumes processing audio data after a suspend(). + \since 1.0 +*/ + +/*! + \fn virtual int QAbstractAudioInput::bytesReady() const + Returns the amount of audio data available to read in bytes. + \since 1.0 +*/ + +/*! + \fn virtual int QAbstractAudioInput::periodSize() const + Returns the period size in bytes. + \since 1.0 +*/ + +/*! + \fn virtual void QAbstractAudioInput::setBufferSize(int value) + Sets the audio buffer size to \a value in milliseconds. + \since 1.0 +*/ + +/*! + \fn virtual int QAbstractAudioInput::bufferSize() const + Returns the audio buffer size in milliseconds. + \since 1.0 +*/ + +/*! + \fn virtual void QAbstractAudioInput::setNotifyInterval(int ms) + Sets the interval for notify() signal to be emitted. This is based + on the \a ms of audio data processed not on actual real-time. + The resolution of the timer is platform specific. + \since 1.0 +*/ + +/*! + \fn virtual int QAbstractAudioInput::notifyInterval() const + Returns the notify interval in milliseconds. + \since 1.0 +*/ + +/*! + \fn virtual qint64 QAbstractAudioInput::processedUSecs() const + Returns the amount of audio data processed since start() was called in milliseconds. + \since 1.0 +*/ + +/*! + \fn virtual qint64 QAbstractAudioInput::elapsedUSecs() const + Returns the milliseconds since start() was called, including time in Idle and suspend states. + \since 1.0 +*/ + +/*! + \fn virtual QAudio::Error QAbstractAudioInput::error() const + Returns the error state. + \since 1.0 +*/ + +/*! + \fn virtual QAudio::State QAbstractAudioInput::state() const + Returns the state of audio processing. + \since 1.0 +*/ + +/*! + \fn virtual void QAbstractAudioInput::setFormat(const QAudioFormat& fmt) + Set the QAudioFormat to use to \a fmt. + Setting the format is only allowable while in QAudio::StoppedState. + \since 1.0 +*/ + +/*! + \fn virtual QAudioFormat QAbstractAudioInput::format() const + Returns the QAudioFormat being used + \since 1.0 +*/ + +/*! + \fn QAbstractAudioInput::errorChanged(QAudio::Error error) + This signal is emitted when the \a error state has changed. + \since 1.0 +*/ + +/*! + \fn QAbstractAudioInput::stateChanged(QAudio::State state) + This signal is emitted when the device \a state has changed. + \since 1.0 +*/ + +/*! + \fn QAbstractAudioInput::notify() + This signal is emitted when x ms of audio data has been processed + the interval set by setNotifyInterval(x). + \since 1.0 +*/ + + +QT_END_NAMESPACE + +#include "moc_qaudiosystem.cpp" diff --git a/src/multimedia/audio/qaudiosystem.h b/src/multimedia/audio/qaudiosystem.h new file mode 100644 index 000000000..59b4eb432 --- /dev/null +++ b/src/multimedia/audio/qaudiosystem.h @@ -0,0 +1,141 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QAUDIOSYSTEM_H +#define QAUDIOSYSTEM_H + +#include +#include + +#include "qaudio.h" +#include "qaudioformat.h" +#include "qaudiodeviceinfo.h" + +QT_BEGIN_HEADER + +QT_BEGIN_NAMESPACE + +QT_MODULE(Multimedia) + + +class Q_MULTIMEDIA_EXPORT QAbstractAudioDeviceInfo : public QObject +{ + Q_OBJECT + +public: + virtual QAudioFormat preferredFormat() const = 0; + virtual bool isFormatSupported(const QAudioFormat &format) const = 0; + virtual QString deviceName() const = 0; + virtual QStringList supportedCodecs() = 0; + virtual QList supportedSampleRates() = 0; + virtual QList supportedChannelCounts() = 0; + virtual QList supportedSampleSizes() = 0; + virtual QList supportedByteOrders() = 0; + virtual QList supportedSampleTypes() = 0; +}; + +class Q_MULTIMEDIA_EXPORT QAbstractAudioOutput : public QObject +{ + Q_OBJECT + +public: + virtual void start(QIODevice *device) = 0; + virtual QIODevice* start() = 0; + virtual void stop() = 0; + virtual void reset() = 0; + virtual void suspend() = 0; + virtual void resume() = 0; + virtual int bytesFree() const = 0; + virtual int periodSize() const = 0; + virtual void setBufferSize(int value) = 0; + virtual int bufferSize() const = 0; + virtual void setNotifyInterval(int milliSeconds) = 0; + virtual int notifyInterval() const = 0; + virtual qint64 processedUSecs() const = 0; + virtual qint64 elapsedUSecs() const = 0; + virtual QAudio::Error error() const = 0; + virtual QAudio::State state() const = 0; + virtual void setFormat(const QAudioFormat& fmt) = 0; + virtual QAudioFormat format() const = 0; + virtual void setVolume(qreal) {} + virtual qreal volume() const { return 1.0; } + +Q_SIGNALS: + void errorChanged(QAudio::Error); + void stateChanged(QAudio::State); + void notify(); +}; + +class Q_MULTIMEDIA_EXPORT QAbstractAudioInput : public QObject +{ + Q_OBJECT + +public: + virtual void start(QIODevice *device) = 0; + virtual QIODevice* start() = 0; + virtual void stop() = 0; + virtual void reset() = 0; + virtual void suspend() = 0; + virtual void resume() = 0; + virtual int bytesReady() const = 0; + virtual int periodSize() const = 0; + virtual void setBufferSize(int value) = 0; + virtual int bufferSize() const = 0; + virtual void setNotifyInterval(int milliSeconds) = 0; + virtual int notifyInterval() const = 0; + virtual qint64 processedUSecs() const = 0; + virtual qint64 elapsedUSecs() const = 0; + virtual QAudio::Error error() const = 0; + virtual QAudio::State state() const = 0; + virtual void setFormat(const QAudioFormat& fmt) = 0; + virtual QAudioFormat format() const = 0; + +Q_SIGNALS: + void errorChanged(QAudio::Error); + void stateChanged(QAudio::State); + void notify(); +}; + +QT_END_NAMESPACE + +QT_END_HEADER + +#endif // QAUDIOSYSTEM_H diff --git a/src/multimedia/audio/qaudiosystemplugin.cpp b/src/multimedia/audio/qaudiosystemplugin.cpp new file mode 100644 index 000000000..5cbcf1d60 --- /dev/null +++ b/src/multimedia/audio/qaudiosystemplugin.cpp @@ -0,0 +1,143 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + + +#include "qaudiosystemplugin.h" + +QT_BEGIN_NAMESPACE + +/*! + \class QAudioSystemPlugin + \brief The QAudioSystemPlugin class provides an abstract base for audio plugins. + \since 1.0 + + \ingroup multimedia + \inmodule QtMultimedia + \internal + + Writing a audio plugin is achieved by subclassing this base class, + reimplementing the pure virtual functions keys(), availableDevices(), + createInput(), createOutput() and createDeviceInfo() then exporting + the class with the Q_EXPORT_PLUGIN2() macro. + + Unit tests are available to help in debugging new plugins. + + \sa QAbstractAudioDeviceInfo, QAbstractAudioOutput, QAbstractAudioInput + + Qt supports win32, linux(alsa) and Mac OS X standard (builtin to the + QtMultimedia library at compile time). + + You can support other backends other than these predefined ones by + creating a plugin subclassing QAudioSystemPlugin, QAbstractAudioDeviceInfo, + QAbstractAudioOutput and QAbstractAudioInput. + + Add "default" to your list of keys() available to override the default + audio device to be provided by your plugin. + + -audio-backend configure option will force compiling in of the builtin backend + into the QtMultimedia library at compile time. This is automatic by default + and will only be compiled into the library if the dependencies are installed. + eg. alsa-devel package installed for linux. + + If the builtin backend is not compiled into the QtMultimedia library and + no audio plugins are available a fallback dummy backend will be used. + This should print out warnings if this is the case when you try and use QAudioInput or QAudioOutput. To fix this problem + reconfigure Qt using -audio-backend or create your own plugin with a default + key to always override the dummy fallback. The easiest way to determine + if you have only a dummy backend is to get a list of available audio devices. + + QAudioDeviceInfo::availableDevices(QAudio::AudioOutput).size() = 0 (dummy backend) +*/ + +/*! + Construct a new audio plugin with \a parent. + This is invoked automatically by the Q_EXPORT_PLUGIN2() macro. +*/ + +QAudioSystemPlugin::QAudioSystemPlugin(QObject* parent) : + QObject(parent) +{} + +/*! + Destroy the audio plugin + + You never have to call this explicitly. Qt destroys a plugin automatically when it is no longer used. +*/ + +QAudioSystemPlugin::~QAudioSystemPlugin() +{} + +/*! + \fn QStringList QAudioSystemPlugin::keys() const + Returns the list of device identifiers this plugin supports. + \since 1.0 +*/ + +/*! + \fn QList QAudioSystemPlugin::availableDevices(QAudio::Mode mode) const + Returns a list of available audio devices for \a mode + \since 1.0 +*/ + +/*! + \fn QAbstractAudioInput* QAudioSystemPlugin::createInput(const QByteArray& device) + Returns a pointer to a QAbstractAudioInput created using \a device identifier + \since 1.0 +*/ + +/*! + \fn QAbstractAudioOutput* QAudioSystemPlugin::createOutput(const QByteArray& device) + Returns a pointer to a QAbstractAudioOutput created using \a device identifier + + \since 1.0 +*/ + +/*! + \fn QAbstractAudioDeviceInfo* QAudioSystemPlugin::createDeviceInfo(const QByteArray& device, QAudio::Mode mode) + Returns a pointer to a QAbstractAudioDeviceInfo created using \a device and \a mode + + \since 1.0 +*/ + + +QT_END_NAMESPACE + +#include "moc_qaudiosystemplugin.cpp" diff --git a/src/multimedia/audio/qaudiosystemplugin.h b/src/multimedia/audio/qaudiosystemplugin.h new file mode 100644 index 000000000..f61dbcfd1 --- /dev/null +++ b/src/multimedia/audio/qaudiosystemplugin.h @@ -0,0 +1,96 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + + +#ifndef QAUDIOSYSTEMPLUGIN_H +#define QAUDIOSYSTEMPLUGIN_H + +#include +#include +#include + +#include +#include + +#include "qaudioformat.h" +#include "qaudiodeviceinfo.h" +#include "qaudiosystem.h" + +QT_BEGIN_HEADER + +QT_BEGIN_NAMESPACE + +QT_MODULE(Multimedia) + + +struct Q_MULTIMEDIA_EXPORT QAudioSystemFactoryInterface : public QFactoryInterface +{ + virtual QList availableDevices(QAudio::Mode) const = 0; + virtual QAbstractAudioInput* createInput(const QByteArray& device) = 0; + virtual QAbstractAudioOutput* createOutput(const QByteArray& device) = 0; + virtual QAbstractAudioDeviceInfo* createDeviceInfo(const QByteArray& device, QAudio::Mode mode) = 0; +}; + +#define QAudioSystemFactoryInterface_iid \ + "com.nokia.qt.QAudioSystemFactoryInterface" +Q_DECLARE_INTERFACE(QAudioSystemFactoryInterface, QAudioSystemFactoryInterface_iid) + +class Q_MULTIMEDIA_EXPORT QAudioSystemPlugin : public QObject, public QAudioSystemFactoryInterface +{ + Q_OBJECT + Q_INTERFACES(QAudioSystemFactoryInterface:QFactoryInterface) + +public: + QAudioSystemPlugin(QObject *parent = 0); + ~QAudioSystemPlugin(); + + virtual QStringList keys() const = 0; + virtual QList availableDevices(QAudio::Mode) const = 0; + virtual QAbstractAudioInput* createInput(const QByteArray& device) = 0; + virtual QAbstractAudioOutput* createOutput(const QByteArray& device) = 0; + virtual QAbstractAudioDeviceInfo* createDeviceInfo(const QByteArray& device, QAudio::Mode mode) = 0; +}; + +QT_END_NAMESPACE + +QT_END_HEADER + +#endif // QAUDIOSYSTEMPLUGIN_H diff --git a/src/multimedia/effects/effects.pri b/src/multimedia/effects/effects.pri new file mode 100644 index 000000000..48c9906b6 --- /dev/null +++ b/src/multimedia/effects/effects.pri @@ -0,0 +1,36 @@ +INCLUDEPATH += effects + +unix:!mac { + contains(config_test_pulseaudio, yes) { + CONFIG += link_pkgconfig + PKGCONFIG += libpulse + + DEFINES += QT_MULTIMEDIA_PULSEAUDIO + PRIVATE_HEADERS += effects/qsoundeffect_pulse_p.h + SOURCES += effects/qsoundeffect_pulse_p.cpp + !maemo*:DEFINES += QTM_PULSEAUDIO_DEFAULTBUFFER + } else { + DEFINES += QT_MULTIMEDIA_QMEDIAPLAYER + PRIVATE_HEADERS += effects/qsoundeffect_qmedia_p.h + SOURCES += effects/qsoundeffect_qmedia_p.cpp + } +} else:!qpa { + PRIVATE_HEADERS += effects/qsoundeffect_qsound_p.h + SOURCES += effects/qsoundeffect_qsound_p.cpp +} else { + DEFINES += QT_MULTIMEDIA_QMEDIAPLAYER + PRIVATE_HEADERS += effects/qsoundeffect_qmedia_p.h + SOURCES += effects/qsoundeffect_qmedia_p.cpp +} + +PRIVATE_HEADERS += \ + effects/qsoundeffect_p.h \ + effects/qwavedecoder_p.h \ + effects/qsamplecache_p.h + +SOURCES += \ + effects/qsoundeffect.cpp \ + effects/qwavedecoder_p.cpp \ + effects/qsamplecache_p.cpp + +HEADERS += diff --git a/src/multimedia/effects/qsamplecache_p.cpp b/src/multimedia/effects/qsamplecache_p.cpp new file mode 100644 index 000000000..1610a4382 --- /dev/null +++ b/src/multimedia/effects/qsamplecache_p.cpp @@ -0,0 +1,398 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qsamplecache_p.h" +#include "qwavedecoder_p.h" +#include + +//#define QT_SAMPLECACHE_DEBUG + +QT_BEGIN_NAMESPACE + + +/*! + \class QSampleCache + \internal + + When you want to get a sound sample data, you need to request the QSample reference from QSampleCache. + + \since 1.1 + + \code + QSample *m_sample; // class member. + + private Q_SLOTS: + void decoderError(); + void sampleReady(); + \endcode + + \code + Q_GLOBAL_STATIC(QSampleCache, sampleCache) //declare a singleton manager + \endcode + + \code + m_sample = sampleCache()->requestSample(url); + switch(m_sample->state()) { + case QSample::Ready: + sampleReady(); + break; + case QSample::Error: + decoderError(); + break; + default: + connect(m_sample, SIGNAL(error()), this, SLOT(decoderError())); + connect(m_sample, SIGNAL(ready()), this, SLOT(sampleReady())); + break; + } + \endcode + + When you no longer need the sound sample data, you need to release it: + + \code + if (m_sample) { + m_sample->release(); + m_sample = 0; + } + \endcode +*/ + +QSampleCache::QSampleCache() + : m_networkAccessManager(0) + , m_mutex(QMutex::Recursive) + , m_capacity(0) + , m_usage(0) +{ + m_loadingThread.setObjectName(QLatin1String("QSampleCache::LoadingThread")); +} + +QNetworkAccessManager& QSampleCache::networkAccessManager() +{ + if (!m_networkAccessManager) + m_networkAccessManager = new QNetworkAccessManager(); + return *m_networkAccessManager; +} + +QSampleCache::~QSampleCache() +{ + QMutexLocker m(&m_mutex); + + m_loadingThread.quit(); + m_loadingThread.wait(); + + // Killing the loading thread means that no samples can be + // deleted using deleteLater. And some samples that had deleteLater + // already called won't have been processed (m_staleSamples) + foreach (QSample* sample, m_samples) + delete sample; + + foreach (QSample* sample, m_staleSamples) + delete sample; // deleting a sample does affect the m_staleSamples list, but foreach copies it + + delete m_networkAccessManager; +} + +QSample* QSampleCache::requestSample(const QUrl& url) +{ + if (!m_loadingThread.isRunning()) + m_loadingThread.start(); +#ifdef QT_SAMPLECACHE_DEBUG + qDebug() << "QSampleCache: request sample [" << url << "]"; +#endif + QMutexLocker locker(&m_mutex); + QMap::iterator it = m_samples.find(url); + QSample* sample; + if (it == m_samples.end()) { + sample = new QSample(url, this); + m_samples.insert(url, sample); + sample->moveToThread(&m_loadingThread); + } else { + sample = *it; + } + + sample->addRef(); + locker.unlock(); + + sample->loadIfNecessary(); + return sample; +} + +void QSampleCache::setCapacity(qint64 capacity) +{ + QMutexLocker locker(&m_mutex); + if (m_capacity == capacity) + return; +#ifdef QT_SAMPLECACHE_DEBUG + qDebug() << "QSampleCache: capacity changes from " << m_capacity << "to " << capacity; +#endif + if (m_capacity > 0 && capacity <= 0) { //memory management strategy changed + for (QMap::iterator it = m_samples.begin(); it != m_samples.end();) { + QSample* sample = *it; + if (sample->m_ref == 0) { + unloadSample(sample); + it = m_samples.erase(it); + } else + it++; + } + } + + m_capacity = capacity; + refresh(0); +} + +// Called locked +void QSampleCache::unloadSample(QSample *sample) +{ + m_usage -= sample->m_soundData.size(); + m_staleSamples.insert(sample); + sample->deleteLater(); +} + +// Called in both threads +void QSampleCache::refresh(qint64 usageChange) +{ + QMutexLocker locker(&m_mutex); + m_usage += usageChange; + if (m_capacity <= 0 || m_usage <= m_capacity) + return; + +#ifdef QT_SAMPLECACHE_DEBUG + qint64 recoveredSize = 0; +#endif + + //free unused samples to keep usage under capacity limit. + for (QMap::iterator it = m_samples.begin(); it != m_samples.end();) { + QSample* sample = *it; + if (sample->m_ref > 0) { + ++it; + continue; + } +#ifdef QT_SAMPLECACHE_DEBUG + recoveredSize += sample->m_soundData.size(); +#endif + unloadSample(sample); + it = m_samples.erase(it); + if (m_usage <= m_capacity) + return; + } + +#ifdef QT_SAMPLECACHE_DEBUG + qDebug() << "QSampleCache: refresh(" << usageChange + << ") recovered size =" << recoveredSize + << "new usage =" << m_usage; +#endif + + if (m_usage > m_capacity) + qWarning() << "QSampleCache: usage[" << m_usage << " out of limit[" << m_capacity << "]"; +} + +// Called in both threads +void QSampleCache::removeUnreferencedSample(QSample *sample) +{ + QMutexLocker m(&m_mutex); + m_staleSamples.remove(sample); +} + +// Called in loader thread (since this lives in that thread) +// Also called from application thread after loader thread dies. +QSample::~QSample() +{ + // Remove ourselves from our parent + m_parent->removeUnreferencedSample(this); + + QMutexLocker locker(&m_mutex); +#ifdef QT_SAMPLECACHE_DEBUG + qDebug() << "~QSample" << this << ": deleted [" << m_url << "]" << QThread::currentThread(); +#endif + cleanup(); +} + +// Called in application thread +void QSample::loadIfNecessary() +{ + QMutexLocker locker(&m_mutex); + if (m_state == QSample::Error || m_state == QSample::Creating) { + m_state = QSample::Loading; + QMetaObject::invokeMethod(this, "load", Qt::QueuedConnection); + } +} + +// Called in both threads +bool QSampleCache::notifyUnreferencedSample(QSample* sample) +{ + QMutexLocker locker(&m_mutex); + if (m_capacity > 0) + return false; + m_samples.remove(sample->m_url); + m_staleSamples.insert(sample); + sample->deleteLater(); + return true; +} + +// Called in application threadd +void QSample::release() +{ + QMutexLocker locker(&m_mutex); +#ifdef QT_SAMPLECACHE_DEBUG + qDebug() << "Sample:: release" << this << QThread::currentThread() << m_ref; +#endif + m_ref--; + if (m_ref == 0) + m_parent->notifyUnreferencedSample(this); +} + +// Called in dtor and when stream is loaded +// must be called locked. +void QSample::cleanup() +{ + delete m_waveDecoder; + delete m_stream; + m_waveDecoder = 0; + m_stream = 0; +} + +// Called in application thread +void QSample::addRef() +{ + m_ref++; +} + +// Called in loading thread +void QSample::readSample() +{ + Q_ASSERT(QThread::currentThread()->objectName() == QLatin1String("QSampleCache::LoadingThread")); + QMutexLocker m(&m_mutex); +#ifdef QT_SAMPLECACHE_DEBUG + qDebug() << "QSample: readSample"; +#endif + qint64 read = m_waveDecoder->read(m_soundData.data() + m_sampleReadLength, + qMin(m_waveDecoder->bytesAvailable(), + qint64(m_waveDecoder->size() - m_sampleReadLength))); + if (read > 0) + m_sampleReadLength += read; + if (m_sampleReadLength < m_waveDecoder->size()) + return; + Q_ASSERT(m_sampleReadLength == qint64(m_soundData.size())); + onReady(); +} + +// Called in loading thread +void QSample::decoderReady() +{ + Q_ASSERT(QThread::currentThread()->objectName() == QLatin1String("QSampleCache::LoadingThread")); + QMutexLocker m(&m_mutex); +#ifdef QT_SAMPLECACHE_DEBUG + qDebug() << "QSample: decoder ready"; +#endif + m_parent->refresh(m_waveDecoder->size()); + + m_soundData.resize(m_waveDecoder->size()); + m_sampleReadLength = 0; + qint64 read = m_waveDecoder->read(m_soundData.data(), m_waveDecoder->size()); + if (read > 0) + m_sampleReadLength += read; + if (m_sampleReadLength >= m_waveDecoder->size()) + onReady(); +} + +// Called in all threads +QSample::State QSample::state() const +{ + QMutexLocker m(&m_mutex); + return m_state; +} + +// Called in loading thread +// Essentially a second ctor, doesn't need locks (?) +void QSample::load() +{ + Q_ASSERT(QThread::currentThread()->objectName() == QLatin1String("QSampleCache::LoadingThread")); +#ifdef QT_SAMPLECACHE_DEBUG + qDebug() << "QSample: load [" << m_url << "]"; +#endif + m_stream = m_parent->networkAccessManager().get(QNetworkRequest(m_url)); + connect(m_stream, SIGNAL(error(QNetworkReply::NetworkError)), SLOT(decoderError())); + m_waveDecoder = new QWaveDecoder(m_stream); + connect(m_waveDecoder, SIGNAL(formatKnown()), SLOT(decoderReady())); + connect(m_waveDecoder, SIGNAL(invalidFormat()), SLOT(decoderError())); + connect(m_waveDecoder, SIGNAL(readyRead()), SLOT(readSample())); +} + +// Called in loading thread +void QSample::decoderError() +{ + Q_ASSERT(QThread::currentThread()->objectName() == QLatin1String("QSampleCache::LoadingThread")); + QMutexLocker m(&m_mutex); +#ifdef QT_SAMPLECACHE_DEBUG + qDebug() << "QSample: decoder error"; +#endif + cleanup(); + m_state = QSample::Error; + emit error(); +} + +// Called in loading thread from decoder when sample is done. Locked already. +void QSample::onReady() +{ + Q_ASSERT(QThread::currentThread()->objectName() == QLatin1String("QSampleCache::LoadingThread")); +#ifdef QT_SAMPLECACHE_DEBUG + qDebug() << "QSample: load ready"; +#endif + m_audioFormat = m_waveDecoder->audioFormat(); + cleanup(); + m_state = QSample::Ready; + emit ready(); +} + +// Called in application thread, then moved to loader thread +QSample::QSample(const QUrl& url, QSampleCache *parent) + : m_parent(parent) + , m_stream(0) + , m_waveDecoder(0) + , m_url(url) + , m_sampleReadLength(0) + , m_state(Creating) + , m_ref(0) +{ +} + +QT_END_NAMESPACE + +#include "moc_qsamplecache_p.cpp" diff --git a/src/multimedia/effects/qsamplecache_p.h b/src/multimedia/effects/qsamplecache_p.h new file mode 100644 index 000000000..91ca457e6 --- /dev/null +++ b/src/multimedia/effects/qsamplecache_p.h @@ -0,0 +1,161 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QSAMPLECACHE_P_H +#define QSAMPLECACHE_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 +#include +#include +#include +#include +#include +#include + + +QT_BEGIN_HEADER + +QT_BEGIN_NAMESPACE + +QT_MODULE(Multimedia) + + +class QNetworkAccessManager; +class QSampleCache; +class QWaveDecoder; + +// Lives in application thread +class QSample : public QObject +{ + Q_OBJECT +public: + friend class QSampleCache; + enum State + { + Creating, + Loading, + Error, + Ready, + }; + + State state() const; + // These are not (currently) locked because they are only meant to be called after these + // variables are updated to their final states + const QByteArray& data() const { Q_ASSERT(state() == Ready); return m_soundData; } + const QAudioFormat& format() const { Q_ASSERT(state() == Ready); return m_audioFormat; } + void release(); + +Q_SIGNALS: + void error(); + void ready(); + +protected: + QSample(const QUrl& url, QSampleCache *parent); + +private Q_SLOTS: + void load(); + void decoderError(); + void readSample(); + void decoderReady(); + +private: + void onReady(); + void cleanup(); + void addRef(); + void loadIfNecessary(); + QSample(); + ~QSample(); + + mutable QMutex m_mutex; + QSampleCache *m_parent; + QByteArray m_soundData; + QAudioFormat m_audioFormat; + QIODevice *m_stream; + QWaveDecoder *m_waveDecoder; + QUrl m_url; + qint64 m_sampleReadLength; + State m_state; + int m_ref; +}; + +class QSampleCache +{ +public: + friend class QSample; + + QSampleCache(); + ~QSampleCache(); + + QSample* requestSample(const QUrl& url); + void setCapacity(qint64 capacity); + +private: + QMap m_samples; + QSet m_staleSamples; + QNetworkAccessManager *m_networkAccessManager; + QMutex m_mutex; + qint64 m_capacity; + qint64 m_usage; + QThread m_loadingThread; + + QNetworkAccessManager& networkAccessManager(); + void refresh(qint64 usageChange); + bool notifyUnreferencedSample(QSample* sample); + void removeUnreferencedSample(QSample* sample); + void unloadSample(QSample* sample); +}; + +QT_END_NAMESPACE + +QT_END_HEADER + +#endif // QSAMPLECACHE_P_H diff --git a/src/multimedia/effects/qsoundeffect.cpp b/src/multimedia/effects/qsoundeffect.cpp new file mode 100644 index 000000000..b1137a22e --- /dev/null +++ b/src/multimedia/effects/qsoundeffect.cpp @@ -0,0 +1,301 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qsoundeffect_p.h" + +#if defined(QT_MULTIMEDIA_PULSEAUDIO) +#include "qsoundeffect_pulse_p.h" +#elif(QT_MULTIMEDIA_QMEDIAPLAYER) +#include "qsoundeffect_qmedia_p.h" +#else +#include "qsoundeffect_qsound_p.h" +#endif + +QT_BEGIN_NAMESPACE + +/*! + \qmlclass SoundEffect QSoundEffect + \brief The SoundEffect element provides a way to play sound effects in QML. + \since 1.0 + + \inmodule QtMultimedia + + This element is part of the \bold{QtMultimedia 4.0} module. + + The following example plays a WAV file on mouse click. + + \snippet doc/src/snippets/multimedia-snippets/soundeffect.qml complete snippet +*/ + +/*! + \qmlproperty url SoundEffect::source + \since 1.0 + + This property provides a way to control the sound to play. +*/ + +/*! + \qmlproperty int SoundEffect::loops + \since 1.0 + + This property provides a way to control the number of times to repeat the sound on each play(). + + Set to -1 (infinite) to enable infinite loop. +*/ + +/*! + \qmlproperty qreal SoundEffect::volume + \since 1.0 + + This property holds the volume of the playback, from 0.0 (silent) to 1.0 (maximum volume). + Note: Currently this has no effect on Mac OS X. +*/ + +/*! + \qmlproperty bool SoundEffect::muted + \since 1.0 + + This property provides a way to control muting. +*/ + +/*! + \qmlproperty bool SoundEffect::playing + \since 1.1 + + This property indicates if the soundeffect is playing or not. +*/ + +/*! + \qmlproperty int SoundEffect::status + \since 1.0 + + This property indicates the following status of the soundeffect. + + Null: no source has been set or is null. + Loading: the soundeffect is trying to load the source. + Ready: the source is loaded and ready for play. + Error: some error happened during operation, such as failure of loading the source. +*/ + +/*! + \qmlsignal SoundEffect::sourceChanged() + \since 1.0 + + This handler is called when the source has changed. +*/ + +/*! + \qmlsignal SoundEffect::loopsChanged() + \since 1.0 + + This handler is called when the number of loops has changed. +*/ + +/*! + \qmlsignal SoundEffect::volumeChanged() + \since 1.0 + + This handler is called when the volume has changed. +*/ + +/*! + \qmlsignal SoundEffect::mutedChanged() + \since 1.0 + + This handler is called when the mute state has changed. +*/ + +/*! + \qmlsignal SoundEffect::playingChanged() + \since 1.0 + + This handler is called when the playing property has changed. +*/ + +/*! + \qmlsignal SoundEffect::statusChanged() + + This handler is called when the status property has changed. + \since 1.0 +*/ + + +/*! + \internal + \since 1.0 +*/ + +QSoundEffect::QSoundEffect(QObject *parent) : + QObject(parent) +{ + d = new QSoundEffectPrivate(this); + connect(d, SIGNAL(volumeChanged()), SIGNAL(volumeChanged())); + connect(d, SIGNAL(mutedChanged()), SIGNAL(mutedChanged())); + connect(d, SIGNAL(loadedChanged()), SIGNAL(loadedChanged())); + connect(d, SIGNAL(playingChanged()), SIGNAL(playingChanged())); + connect(d, SIGNAL(statusChanged()), SIGNAL(statusChanged())); +} + +QSoundEffect::~QSoundEffect() +{ + d->deleteLater(); +} + +QStringList QSoundEffect::supportedMimeTypes() +{ + return QSoundEffectPrivate::supportedMimeTypes(); +} + +QUrl QSoundEffect::source() const +{ + return d->source(); +} + +void QSoundEffect::setSource(const QUrl &url) +{ + if (d->source() == url) + return; + + d->setSource(url); + + emit sourceChanged(); +} + +int QSoundEffect::loopCount() const +{ + return d->loopCount(); +} + +void QSoundEffect::setLoopCount(int loopCount) +{ + if (loopCount < 0 && loopCount != Infinite) { + qWarning("SoundEffect: loops should be SoundEffect.Infinite, 0 or positive integer"); + return; + } + if (loopCount == 0) + loopCount = 1; + if (d->loopCount() == loopCount) + return; + + d->setLoopCount(loopCount); + emit loopCountChanged(); +} + +qreal QSoundEffect::volume() const +{ + return qreal(d->volume()) / 100; +} + +void QSoundEffect::setVolume(qreal volume) +{ + if (volume < 0 || volume > 1) { + qWarning("SoundEffect: volume should be between 0.0 and 1.0"); + return; + } + int iVolume = qRound(volume * 100); + if (d->volume() == iVolume) + return; + + d->setVolume(iVolume); +} + +bool QSoundEffect::isMuted() const +{ + return d->isMuted(); +} + +void QSoundEffect::setMuted(bool muted) +{ + if (d->isMuted() == muted) + return; + + d->setMuted(muted); +} + +bool QSoundEffect::isLoaded() const +{ + return d->isLoaded(); +} + +/*! + \qmlmethod SoundEffect::play() + + Start playback of the sound effect, looping the effect for the number of + times as specificed in the loops property. + + This is the default method for SoundEffect. + + \snippet doc/src/snippets/multimedia-snippets/soundeffect.qml play sound on click + \since 1.0 +*/ +void QSoundEffect::play() +{ + d->play(); +} + +bool QSoundEffect::isPlaying() const +{ + return d->isPlaying(); +} + +QSoundEffect::Status QSoundEffect::status() const +{ + return d->status(); +} + + +/*! + \qmlmethod SoundEffect::stop() + + Stop current playback. + Note that if the backend is PulseAudio, due to the limitation of the underlying API, + tis stop will only prevent next looping but will not be able to stop current playback immediately. + + \since 1.0 + */ +void QSoundEffect::stop() +{ + d->stop(); +} + +QT_END_NAMESPACE + +#include "moc_qsoundeffect_p.cpp" diff --git a/src/multimedia/effects/qsoundeffect_p.h b/src/multimedia/effects/qsoundeffect_p.h new file mode 100644 index 000000000..93248184a --- /dev/null +++ b/src/multimedia/effects/qsoundeffect_p.h @@ -0,0 +1,143 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QSOUNDEFFECT_P_H +#define QSOUNDEFFECT_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 +#include +#include +#include + + +QT_BEGIN_HEADER + +QT_BEGIN_NAMESPACE + +QT_MODULE(Multimedia) + + +class QSoundEffectPrivate; + +class Q_MULTIMEDIA_EXPORT QSoundEffect : public QObject +{ + Q_OBJECT + Q_CLASSINFO("DefaultMethod", "play()") + Q_PROPERTY(QUrl source READ source WRITE setSource NOTIFY sourceChanged) + Q_PROPERTY(int loops READ loopCount WRITE setLoopCount NOTIFY loopCountChanged) + Q_PROPERTY(qreal volume READ volume WRITE setVolume NOTIFY volumeChanged) + Q_PROPERTY(bool muted READ isMuted WRITE setMuted NOTIFY mutedChanged) + Q_PROPERTY(bool playing READ isPlaying NOTIFY playingChanged) + Q_PROPERTY(Status status READ status NOTIFY statusChanged) + Q_ENUMS(Loop) + Q_ENUMS(Status) + +public: + enum Loop + { + Infinite = -2, + }; + + enum Status + { + Null, + Loading, + Ready, + Error + }; + + explicit QSoundEffect(QObject *parent = 0); + ~QSoundEffect(); + + static QStringList supportedMimeTypes(); + + QUrl source() const; + void setSource(const QUrl &url); + + int loopCount() const; + void setLoopCount(int loopCount); + + qreal volume() const; + void setVolume(qreal volume); + + bool isMuted() const; + void setMuted(bool muted); + + bool isLoaded() const; + + bool isPlaying() const; + Status status() const; + +Q_SIGNALS: + void sourceChanged(); + void loopCountChanged(); + void volumeChanged(); + void mutedChanged(); + void loadedChanged(); + void playingChanged(); + void statusChanged(); + +public Q_SLOTS: + void play(); + void stop(); + +private: + Q_DISABLE_COPY(QSoundEffect) + QSoundEffectPrivate* d; +}; + +QT_END_NAMESPACE + +QT_END_HEADER + + +#endif // QSOUNDEFFECT_H diff --git a/src/multimedia/effects/qsoundeffect_pulse_p.cpp b/src/multimedia/effects/qsoundeffect_pulse_p.cpp new file mode 100644 index 000000000..4570f8fd5 --- /dev/null +++ b/src/multimedia/effects/qsoundeffect_pulse_p.cpp @@ -0,0 +1,957 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +// +// 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. +// +// INTERNAL USE ONLY: Do NOT use for any other purpose. +// + +#include +#include +#include +#include + +#include "qsoundeffect_pulse_p.h" + +#if defined(Q_WS_MAEMO_6) +#include +#endif + +#include + +//#define QT_PA_DEBUG +#ifndef QTM_PULSEAUDIO_DEFAULTBUFFER +#define QT_PA_STREAM_BUFFER_SIZE_MAX (1024 * 64) //64KB is a trade-off for balancing control latency and uploading overhead +#endif + +QT_BEGIN_NAMESPACE + +namespace +{ +inline pa_sample_spec audioFormatToSampleSpec(const QAudioFormat &format) +{ + pa_sample_spec spec; + + spec.rate = format.frequency(); + spec.channels = format.channels(); + + if (format.sampleSize() == 8) + spec.format = PA_SAMPLE_U8; + else if (format.sampleSize() == 16) { + switch (format.byteOrder()) { + case QAudioFormat::BigEndian: spec.format = PA_SAMPLE_S16BE; break; + case QAudioFormat::LittleEndian: spec.format = PA_SAMPLE_S16LE; break; + } + } + else if (format.sampleSize() == 32) { + switch (format.byteOrder()) { + case QAudioFormat::BigEndian: spec.format = PA_SAMPLE_S32BE; break; + case QAudioFormat::LittleEndian: spec.format = PA_SAMPLE_S32LE; break; + } + } + + return spec; +} + +class PulseDaemon : public QObject +{ + Q_OBJECT +public: + PulseDaemon(): m_prepared(false) + { + prepare(); + } + + ~PulseDaemon() + { + if (m_prepared) + release(); + } + + inline void lock() + { + pa_threaded_mainloop_lock(m_mainLoop); + } + + inline void unlock() + { + pa_threaded_mainloop_unlock(m_mainLoop); + } + + inline pa_context *context() const + { + return m_context; + } + + inline pa_cvolume * calcVolume(pa_cvolume *dest, int soundEffectVolume) + { + dest->channels = 2; + dest->values[0] = dest->values[1] = m_vol * soundEffectVolume / 100; + return dest; + } + + void updateStatus(const pa_cvolume& volume) + { + if (m_vol != pa_cvolume_max(&volume)) { + m_vol = pa_cvolume_max(&volume); + emit volumeChanged(); + } + } + +Q_SIGNALS: + void contextReady(); + void volumeChanged(); + +private: + void prepare() + { + m_vol = PA_VOLUME_NORM; + + m_mainLoop = pa_threaded_mainloop_new(); + if (m_mainLoop == 0) { + qWarning("PulseAudioService: unable to create pulseaudio mainloop"); + return; + } + + if (pa_threaded_mainloop_start(m_mainLoop) != 0) { + qWarning("PulseAudioService: unable to start pulseaudio mainloop"); + pa_threaded_mainloop_free(m_mainLoop); + return; + } + + m_mainLoopApi = pa_threaded_mainloop_get_api(m_mainLoop); + + lock(); + m_context = pa_context_new(m_mainLoopApi, QString(QLatin1String("QtPulseAudio:%1")).arg(::getpid()).toAscii().constData()); + + pa_context_set_state_callback(m_context, context_state_callback, this); + + if (m_context == 0) { + qWarning("PulseAudioService: Unable to create new pulseaudio context"); + pa_threaded_mainloop_free(m_mainLoop); + return; + } + + if (pa_context_connect(m_context, 0, (pa_context_flags_t)0, 0) < 0) { + qWarning("PulseAudioService: pa_context_connect() failed"); + pa_context_unref(m_context); + pa_threaded_mainloop_free(m_mainLoop); + return; + } + unlock(); + + m_prepared = true; + } + + void release() + { + if (!m_prepared) return; + pa_threaded_mainloop_stop(m_mainLoop); + pa_threaded_mainloop_free(m_mainLoop); + m_prepared = false; + } + + static void context_state_callback(pa_context *c, void *userdata) + { + PulseDaemon *self = reinterpret_cast(userdata); + switch (pa_context_get_state(c)) { + case PA_CONTEXT_CONNECTING: + case PA_CONTEXT_AUTHORIZING: + case PA_CONTEXT_SETTING_NAME: + break; + case PA_CONTEXT_READY: + #if defined(Q_WS_MAEMO_6) + pa_ext_stream_restore_read(c, &stream_restore_info_callback, self); + pa_ext_stream_restore_set_subscribe_cb(c, &stream_restore_monitor_callback, self); + pa_ext_stream_restore_subscribe(c, 1, 0, self); + #endif + QMetaObject::invokeMethod(self, "contextReady", Qt::QueuedConnection); + break; + default: + break; + } + } + +#if defined(Q_WS_MAEMO_6) + + static void stream_restore_monitor_callback(pa_context *c, void *userdata) + { + PulseDaemon *self = reinterpret_cast(userdata); + pa_ext_stream_restore_read(c, &stream_restore_info_callback, self); + } + + static void stream_restore_info_callback(pa_context *c, + const pa_ext_stream_restore_info *info, + int eol, void *userdata) + { + Q_UNUSED(c) + + PulseDaemon *self = reinterpret_cast(userdata); + + if (!eol) { + if (QString(info->name).startsWith(QLatin1String("sink-input-by-media-role:x-maemo"))) { +#ifdef QT_PA_DEBUG + qDebug() << "x-maemo volume =(" << info->volume.values[0] * 100 / PA_VOLUME_NORM << "," + << info->volume.values[1] * 100 / PA_VOLUME_NORM << "), " + << "mute = " << info->mute; +#endif + self->updateStatus(info->volume); + } + } + } +#endif + + pa_volume_t m_vol; + + bool m_prepared; + pa_context *m_context; + pa_threaded_mainloop *m_mainLoop; + pa_mainloop_api *m_mainLoopApi; +}; + +} + +Q_GLOBAL_STATIC(PulseDaemon, daemon) +Q_GLOBAL_STATIC(QSampleCache, sampleCache) + +namespace +{ +class PulseDaemonLocker +{ +public: + PulseDaemonLocker() + { + daemon()->lock(); + } + + ~PulseDaemonLocker() + { + daemon()->unlock(); + } +}; +} + +QSoundEffectPrivate::QSoundEffectPrivate(QObject* parent): + QObject(parent), + m_pulseStream(0), + m_sinkInputId(-1), + m_emptying(false), + m_sampleReady(false), + m_playing(false), + m_status(QSoundEffect::Null), + m_muted(false), + m_playQueued(false), + m_stopping(false), + m_volume(100), + m_loopCount(1), + m_runningCount(0), + m_sample(0) , + m_position(0) +{ + pa_sample_spec_init(&m_pulseSpec); +} + +QSoundEffectPrivate::~QSoundEffectPrivate() +{ + unloadPulseStream(); + + if (m_sample) + m_sample->release(); +} + +QStringList QSoundEffectPrivate::supportedMimeTypes() +{ + QStringList supportedTypes; + supportedTypes << QLatin1String("audio/x-wav") << QLatin1String("audio/vnd.wave") ; + return supportedTypes; +} + +QUrl QSoundEffectPrivate::source() const +{ + return m_source; +} + +void QSoundEffectPrivate::setSource(const QUrl &url) +{ + Q_ASSERT(m_source != url); +#ifdef QT_PA_DEBUG + qDebug() << this << "setSource =" << url; +#endif + stop(); + if (m_sample) { + if (!m_sampleReady) { + disconnect(m_sample, SIGNAL(error()), this, SLOT(decoderError())); + disconnect(m_sample, SIGNAL(ready()), this, SLOT(sampleReady())); + } + m_sample->release(); + m_sample = 0; + } + + m_source = url; + m_sampleReady = false; + + PulseDaemonLocker locker; + m_runningCount = 0; + if (m_pulseStream && !pa_stream_is_corked(m_pulseStream)) { + pa_stream_set_write_callback(m_pulseStream, 0, 0); + pa_stream_set_underflow_callback(m_pulseStream, 0, 0); + pa_operation_unref(pa_stream_cork(m_pulseStream, 1, 0, 0)); + } + setPlaying(false); + + if (url.isEmpty()) { + setStatus(QSoundEffect::Null); + return; + } + + setStatus(QSoundEffect::Loading); + m_sample = sampleCache()->requestSample(url); + connect(m_sample, SIGNAL(error()), this, SLOT(decoderError())); + connect(m_sample, SIGNAL(ready()), this, SLOT(sampleReady())); + switch(m_sample->state()) { + case QSample::Ready: + sampleReady(); + break; + case QSample::Error: + decoderError(); + break; + default: + break; + } +} + +int QSoundEffectPrivate::loopCount() const +{ + return m_loopCount; +} + +void QSoundEffectPrivate::setLoopCount(int loopCount) +{ + if (loopCount == 0) + loopCount = 1; + m_loopCount = loopCount; +} + +int QSoundEffectPrivate::volume() const +{ + return m_volume; +} + +void QSoundEffectPrivate::setVolume(int volume) +{ + m_volume = volume; + emit volumeChanged(); + updateVolume(); +} + +void QSoundEffectPrivate::updateVolume() +{ + if (m_sinkInputId < 0) + return; + PulseDaemonLocker locker; + pa_cvolume volume; + pa_operation_unref(pa_context_set_sink_input_volume(daemon()->context(), m_sinkInputId, daemon()->calcVolume(&volume, m_volume), setvolume_callback, this)); + Q_ASSERT(pa_cvolume_valid(&volume)); +#ifdef QT_PA_DEBUG + qDebug() << this << "updateVolume =" << pa_cvolume_max(&volume); +#endif +} + +bool QSoundEffectPrivate::isMuted() const +{ + return m_muted; +} + +void QSoundEffectPrivate::setMuted(bool muted) +{ + m_muted = muted; + emit mutedChanged(); + updateMuted(); +} + +void QSoundEffectPrivate::updateMuted() +{ + if (m_sinkInputId < 0) + return; + PulseDaemonLocker locker; + pa_operation_unref(pa_context_set_sink_input_mute(daemon()->context(), m_sinkInputId, m_muted, setmuted_callback, this)); +#ifdef QT_PA_DEBUG + qDebug() << this << "updateMuted = " << daemon()->calcMuted(m_muted); +#endif +} + +bool QSoundEffectPrivate::isLoaded() const +{ + return m_status == QSoundEffect::Ready; +} + +bool QSoundEffectPrivate::isPlaying() const +{ + return m_playing; +} + +QSoundEffect::Status QSoundEffectPrivate::status() const +{ + return m_status; +} + +void QSoundEffectPrivate::setPlaying(bool playing) +{ +#ifdef QT_PA_DEBUG + qDebug() << this << "setPlaying(" << playing << ")"; +#endif + if (m_playing == playing) + return; + if (!playing) + m_playQueued = false; + m_playing = playing; + emit playingChanged(); +} + +void QSoundEffectPrivate::setStatus(QSoundEffect::Status status) +{ +#ifdef QT_PA_DEBUG + qDebug() << this << "setStatus" << status; +#endif + if (m_status == status) + return; + bool oldLoaded = isLoaded(); + m_status = status; + emit statusChanged(); + if (oldLoaded != isLoaded()) + emit loadedChanged(); +} + +void QSoundEffectPrivate::play() +{ +#ifdef QT_PA_DEBUG + qDebug() << this << "play"; +#endif + if (m_status == QSoundEffect::Null || m_status == QSoundEffect::Error || m_playQueued) + return; + + PulseDaemonLocker locker; + if (!m_sampleReady || m_stopping || m_emptying) { +#ifdef QT_PA_DEBUG + qDebug() << this << "play deferred"; +#endif + m_playQueued = true; + } else { + if (m_playing) { //restart playing from the beginning +#ifdef QT_PA_DEBUG + qDebug() << this << "restart playing"; +#endif + m_runningCount = 0; + m_playQueued = true; + Q_ASSERT(m_pulseStream); + emptyStream(); + return; + } + m_runningCount = m_loopCount; + playSample(); + } + + setPlaying(true); +} + +void QSoundEffectPrivate::emptyStream() +{ + m_emptying = true; + pa_stream_set_write_callback(m_pulseStream, 0, this); + pa_stream_set_underflow_callback(m_pulseStream, 0, this); + pa_operation_unref(pa_stream_flush(m_pulseStream, stream_flush_callback, this)); +} + +void QSoundEffectPrivate::emptyComplete() +{ + PulseDaemonLocker locker; + m_emptying = false; + pa_operation_unref(pa_stream_cork(m_pulseStream, 1, stream_cork_callback, this)); +} + +void QSoundEffectPrivate::sampleReady() +{ +#ifdef QT_PA_DEBUG + qDebug() << this << "sampleReady"; +#endif + disconnect(m_sample, SIGNAL(error()), this, SLOT(decoderError())); + disconnect(m_sample, SIGNAL(ready()), this, SLOT(sampleReady())); + pa_sample_spec newFormatSpec = audioFormatToSampleSpec(m_sample->format()); + + if (m_pulseStream && (memcmp(&m_pulseSpec, &newFormatSpec, sizeof(m_pulseSpec)) != 0)) { + unloadPulseStream(); + } + m_pulseSpec = newFormatSpec; + + m_sampleReady = true; + m_position = 0; + + if (m_name.isNull()) + m_name = QString(QLatin1String("QtPulseSample-%1-%2")).arg(::getpid()).arg(quintptr(this)).toUtf8(); + + PulseDaemonLocker locker; + if (m_pulseStream) { +#ifdef QT_PA_DEBUG + qDebug() << this << "reuse existing pulsestream"; +#endif +#ifdef QTM_PULSEAUDIO_DEFAULTBUFFER + const pa_buffer_attr *bufferAttr = pa_stream_get_buffer_attr(m_pulseStream); + if (bufferAttr->prebuf > uint32_t(m_sample->data().size())) { + pa_buffer_attr newBufferAttr; + newBufferAttr = *bufferAttr; + newBufferAttr.prebuf = m_sample->data().size(); + pa_stream_set_buffer_attr(m_pulseStream, &newBufferAttr, stream_adjust_prebuffer_callback, this); + } else { + streamReady(); + } +#else + const pa_buffer_attr *bufferAttr = pa_stream_get_buffer_attr(m_pulseStream); + if (bufferAttr->tlength < m_sample->data().size() && bufferAttr->tlength < QT_PA_STREAM_BUFFER_SIZE_MAX) { + pa_buffer_attr newBufferAttr; + newBufferAttr.maxlength = -1; + newBufferAttr.tlength = qMin(m_sample->data().size(), QT_PA_STREAM_BUFFER_SIZE_MAX); + newBufferAttr.minreq = bufferAttr->tlength / 2; + newBufferAttr.prebuf = -1; + newBufferAttr.fragsize = -1; + pa_stream_set_buffer_attr(m_pulseStream, &newBufferAttr, stream_reset_buffer_callback, this); + } else if (bufferAttr->prebuf > uint32_t(m_sample->data().size())) { + pa_buffer_attr newBufferAttr; + newBufferAttr = *bufferAttr; + newBufferAttr.prebuf = m_sample->data().size(); + pa_stream_set_buffer_attr(m_pulseStream, &newBufferAttr, stream_adjust_prebuffer_callback, this); + } else { + streamReady(); + } +#endif + } else { + if (pa_context_get_state(daemon()->context()) != PA_CONTEXT_READY) { + connect(daemon(), SIGNAL(contextReady()), SLOT(contextReady())); + return; + } + createPulseStream(); + } +} + +void QSoundEffectPrivate::decoderError() +{ + qWarning("QSoundEffect(pulseaudio): Error decoding source"); + disconnect(m_sample, SIGNAL(error()), this, SLOT(decoderError())); + bool playingDirty = false; + if (m_playing) { + m_playing = false; + playingDirty = true; + } + setStatus(QSoundEffect::Error); + if (playingDirty) + emit playingChanged(); +} + +void QSoundEffectPrivate::unloadPulseStream() +{ +#ifdef QT_PA_DEBUG + qDebug() << this << "unloadPulseStream"; +#endif + m_sinkInputId = -1; + PulseDaemonLocker locker; + if (m_pulseStream) { + pa_stream_set_state_callback(m_pulseStream, 0, 0); + pa_stream_set_write_callback(m_pulseStream, 0, 0); + pa_stream_set_underflow_callback(m_pulseStream, 0, 0); + pa_stream_disconnect(m_pulseStream); + pa_stream_unref(m_pulseStream); + disconnect(daemon(), SIGNAL(volumeChanged()), this, SLOT(updateVolume())); + m_pulseStream = 0; + } +} + +void QSoundEffectPrivate::prepare() +{ + if (!m_pulseStream || !m_sampleReady) + return; + PulseDaemonLocker locker; + pa_stream_set_write_callback(m_pulseStream, stream_write_callback, this); + pa_stream_set_underflow_callback(m_pulseStream, stream_underrun_callback, this); + m_stopping = false; + size_t writeBytes = size_t(qMin(m_pulseBufferSize, m_sample->data().size())); +#ifdef QT_PA_DEBUG + qDebug() << this << "prepare(): writable size =" << pa_stream_writable_size(m_pulseStream) + << "actual writeBytes =" << writeBytes + << "m_playQueued =" << m_playQueued; +#endif + m_position = int(writeBytes); + if (pa_stream_write(m_pulseStream, reinterpret_cast(const_cast(m_sample->data().data())), writeBytes, + stream_write_done_callback, 0, PA_SEEK_RELATIVE) != 0) { + qWarning("QSoundEffect(pulseaudio): pa_stream_write, error = %s", pa_strerror(pa_context_errno(daemon()->context()))); + } + if (m_playQueued) { + m_playQueued = false; + m_runningCount = m_loopCount; + playSample(); + } +} + +void QSoundEffectPrivate::uploadSample() +{ + if (m_runningCount == 0) { +#ifdef QT_PA_DEBUG + qDebug() << this << "uploadSample: return due to 0 m_runningCount"; +#endif + return; + } +#ifdef QT_PA_DEBUG + qDebug() << this << "uploadSample: m_runningCount =" << m_runningCount; +#endif + if (m_position == m_sample->data().size()) { + m_position = 0; + if (m_runningCount > 0) + m_runningCount--; + if (m_runningCount == 0) { + return; + } + } + + int writtenBytes = 0; + int writableSize = int(pa_stream_writable_size(m_pulseStream)); + int firstPartLength = qMin(m_sample->data().size() - m_position, writableSize); + if (pa_stream_write(m_pulseStream, reinterpret_cast(const_cast(m_sample->data().data()) + m_position), + firstPartLength, stream_write_done_callback, 0, PA_SEEK_RELATIVE) != 0) { + qWarning("QSoundEffect(pulseaudio): pa_stream_write, error = %s", pa_strerror(pa_context_errno(daemon()->context()))); + } + writtenBytes = firstPartLength; + m_position += firstPartLength; + if (m_position == m_sample->data().size()) { + m_position = 0; + if (m_runningCount > 0) + m_runningCount--; + if (m_runningCount != 0 && firstPartLength < writableSize) + { + while (writtenBytes < writableSize) { + int writeSize = qMin(writableSize - writtenBytes, m_sample->data().size()); + if (pa_stream_write(m_pulseStream, reinterpret_cast(const_cast(m_sample->data().data())), + writeSize, stream_write_done_callback, 0, PA_SEEK_RELATIVE) != 0) { + qWarning("QSoundEffect(pulseaudio): pa_stream_write, error = %s", pa_strerror(pa_context_errno(daemon()->context()))); + } + writtenBytes += writeSize; + if (writeSize < m_sample->data().size()) { + m_position = writeSize; + break; + } + if (m_runningCount > 0) + m_runningCount--; + if (m_runningCount == 0) + break; + } + } + } +#ifdef QT_PA_DEBUG + qDebug() << this << "uploadSample: use direct write, writeable size =" << writableSize + << "actual writtenBytes =" << writtenBytes; +#endif +} + +void QSoundEffectPrivate::playSample() +{ +#ifdef QT_PA_DEBUG + qDebug() << this << "playSample"; +#endif + Q_ASSERT(m_pulseStream); + pa_operation_unref(pa_stream_cork(m_pulseStream, 0, 0, 0)); +} + +void QSoundEffectPrivate::stop() +{ +#ifdef QT_PA_DEBUG + qDebug() << this << "stop"; +#endif + if (!m_playing) + return; + setPlaying(false); + PulseDaemonLocker locker; + m_stopping = true; + if (m_pulseStream) + emptyStream(); + m_runningCount = 0; + m_position = 0; + m_playQueued = false; +} + +void QSoundEffectPrivate::underRun() +{ + stop(); +} + +void QSoundEffectPrivate::streamReady() +{ +#ifdef QT_PA_DEBUG + qDebug() << this << "streamReady"; +#endif + PulseDaemonLocker locker; + m_sinkInputId = pa_stream_get_index(m_pulseStream); + updateMuted(); + updateVolume(); +#ifdef QT_PA_DEBUG + const pa_buffer_attr *realBufAttr = pa_stream_get_buffer_attr(m_pulseStream); + qDebug() << this << "m_sinkInputId =" << m_sinkInputId + << "tlength =" << realBufAttr->tlength << "maxlength =" << realBufAttr->maxlength + << "minreq = " << realBufAttr->minreq << "prebuf =" << realBufAttr->prebuf; +#endif + prepare(); + setStatus(QSoundEffect::Ready); +} + +void QSoundEffectPrivate::createPulseStream() +{ +#ifdef QT_PA_DEBUG + qDebug() << this << "createPulseStream"; +#endif + + pa_proplist *propList = pa_proplist_new(); + pa_proplist_sets(propList, PA_PROP_MEDIA_ROLE, "soundeffect"); + pa_stream *stream = pa_stream_new_with_proplist(daemon()->context(), m_name.constData(), &m_pulseSpec, 0, propList); + pa_proplist_free(propList); + + connect(daemon(), SIGNAL(volumeChanged()), this, SLOT(updateVolume())); + + if (stream == 0) { + qWarning("QSoundEffect(pulseaudio): Failed to create stream"); + m_pulseStream = 0; + setStatus(QSoundEffect::Error); + setPlaying(false); + return; + } + else { + pa_stream_set_state_callback(stream, stream_state_callback, this); + pa_stream_set_write_callback(stream, stream_write_callback, this); + pa_stream_set_underflow_callback(stream, stream_underrun_callback, this); + } + m_pulseStream = stream; + +#ifndef QTM_PULSEAUDIO_DEFAULTBUFFER + pa_buffer_attr bufferAttr; + bufferAttr.tlength = qMin(m_sample->data().size(), QT_PA_STREAM_BUFFER_SIZE_MAX); + bufferAttr.maxlength = -1; + bufferAttr.minreq = bufferAttr.tlength / 2; + bufferAttr.prebuf = -1; + bufferAttr.fragsize = -1; + if (pa_stream_connect_playback(m_pulseStream, 0, &bufferAttr, +#else + if (pa_stream_connect_playback(m_pulseStream, 0, 0, +#endif + m_muted ? pa_stream_flags_t(PA_STREAM_START_MUTED | PA_STREAM_START_CORKED) + : pa_stream_flags_t(PA_STREAM_START_UNMUTED | PA_STREAM_START_CORKED), + 0, 0) < 0) { + qWarning("QSoundEffect(pulseaudio): Failed to connect stream, error = %s", + pa_strerror(pa_context_errno(daemon()->context()))); + } +} + +void QSoundEffectPrivate::contextReady() +{ + disconnect(daemon(), SIGNAL(contextReady()), this, SLOT(contextReady())); + PulseDaemonLocker locker; + createPulseStream(); +} + +void QSoundEffectPrivate::stream_write_callback(pa_stream *s, size_t length, void *userdata) +{ + Q_UNUSED(length); + Q_UNUSED(s) + + QSoundEffectPrivate *self = reinterpret_cast(userdata); +#ifdef QT_PA_DEBUG + qDebug() << self << "stream_write_callback"; +#endif + self->uploadSample(); +} + +void QSoundEffectPrivate::stream_state_callback(pa_stream *s, void *userdata) +{ + QSoundEffectPrivate *self = reinterpret_cast(userdata); + switch (pa_stream_get_state(s)) { + case PA_STREAM_READY: + { +#ifdef QT_PA_DEBUG + qDebug() << self << "pulse stream ready"; +#endif + const pa_buffer_attr *bufferAttr = pa_stream_get_buffer_attr(self->m_pulseStream); + self->m_pulseBufferSize = bufferAttr->tlength; + if (bufferAttr->prebuf > uint32_t(self->m_sample->data().size())) { + pa_buffer_attr newBufferAttr; + newBufferAttr = *bufferAttr; + newBufferAttr.prebuf = self->m_sample->data().size(); + pa_stream_set_buffer_attr(self->m_pulseStream, &newBufferAttr, stream_adjust_prebuffer_callback, userdata); + } else { + QMetaObject::invokeMethod(self, "streamReady", Qt::QueuedConnection); + } + break; + } + case PA_STREAM_CREATING: +#ifdef QT_PA_DEBUG + qDebug() << self << "pulse stream creating"; +#endif + break; + case PA_STREAM_TERMINATED: +#ifdef QT_PA_DEBUG + qDebug() << self << "pulse stream terminated"; +#endif + break; + + case PA_STREAM_FAILED: + default: + qWarning("QSoundEffect(pulseaudio): Error in pulse audio stream"); + break; + } +} + +void QSoundEffectPrivate::stream_reset_buffer_callback(pa_stream *s, int success, void *userdata) +{ + Q_UNUSED(s); + if (!success) + qWarning("QSoundEffect(pulseaudio): faild to reset buffer attribute"); + QSoundEffectPrivate *self = reinterpret_cast(userdata); +#ifdef QT_PA_DEBUG + qDebug() << self << "stream_reset_buffer_callback"; +#endif + const pa_buffer_attr *bufferAttr = pa_stream_get_buffer_attr(self->m_pulseStream); + self->m_pulseBufferSize = bufferAttr->tlength; + if (bufferAttr->prebuf > uint32_t(self->m_sample->data().size())) { + pa_buffer_attr newBufferAttr; + newBufferAttr = *bufferAttr; + newBufferAttr.prebuf = self->m_sample->data().size(); + pa_stream_set_buffer_attr(self->m_pulseStream, &newBufferAttr, stream_adjust_prebuffer_callback, userdata); + } else { + QMetaObject::invokeMethod(self, "streamReady", Qt::QueuedConnection); + } +} + +void QSoundEffectPrivate::stream_adjust_prebuffer_callback(pa_stream *s, int success, void *userdata) +{ + Q_UNUSED(s); + if (!success) + qWarning("QSoundEffect(pulseaudio): faild to adjust pre-buffer attribute"); + QSoundEffectPrivate *self = reinterpret_cast(userdata); +#ifdef QT_PA_DEBUG + qDebug() << self << "stream_adjust_prebuffer_callback"; +#endif + QMetaObject::invokeMethod(self, "streamReady", Qt::QueuedConnection); +} + +void QSoundEffectPrivate::setvolume_callback(pa_context *c, int success, void *userdata) +{ + Q_UNUSED(c); + Q_UNUSED(userdata); +#ifdef QT_PA_DEBUG + qDebug() << reinterpret_cast(userdata) << "setvolume_callback"; +#endif + if (!success) { + qWarning("QSoundEffect(pulseaudio): faild to set volume"); + } +} + +void QSoundEffectPrivate::setmuted_callback(pa_context *c, int success, void *userdata) +{ + Q_UNUSED(c); + Q_UNUSED(userdata); +#ifdef QT_PA_DEBUG + qDebug() << reinterpret_cast(userdata) << "setmuted_callback"; +#endif + if (!success) { + qWarning("QSoundEffect(pulseaudio): faild to set muted"); + } +} + +void QSoundEffectPrivate::stream_underrun_callback(pa_stream *s, void *userdata) +{ + Q_UNUSED(s); + QSoundEffectPrivate *self = reinterpret_cast(userdata); +#ifdef QT_PA_DEBUG + qDebug() << self << "stream_underrun_callback"; +#endif + if (self->m_runningCount == 0 && !self->m_playQueued) + QMetaObject::invokeMethod(self, "underRun", Qt::QueuedConnection); +#ifdef QT_PA_DEBUG + else + qDebug() << "underun corked =" << pa_stream_is_corked(s); +#endif +} + +void QSoundEffectPrivate::stream_cork_callback(pa_stream *s, int success, void *userdata) +{ + Q_UNUSED(s); + if (!success) + qWarning("QSoundEffect(pulseaudio): faild to stop"); + QSoundEffectPrivate *self = reinterpret_cast(userdata); +#ifdef QT_PA_DEBUG + qDebug() << self << "stream_cork_callback"; +#endif + QMetaObject::invokeMethod(self, "prepare", Qt::QueuedConnection); +} + +void QSoundEffectPrivate::stream_flush_callback(pa_stream *s, int success, void *userdata) +{ + Q_UNUSED(s); + if (!success) + qWarning("QSoundEffect(pulseaudio): faild to drain"); + QSoundEffectPrivate *self = reinterpret_cast(userdata); +#ifdef QT_PA_DEBUG + qDebug() << self << "stream_flush_callback"; +#endif + QMetaObject::invokeMethod(self, "emptyComplete", Qt::QueuedConnection); +} + +void QSoundEffectPrivate::stream_write_done_callback(void *p) +{ + Q_UNUSED(p); +#ifdef QT_PA_DEBUG + qDebug() << "stream_write_done_callback"; +#endif +} + +QT_END_NAMESPACE + +#include "moc_qsoundeffect_pulse_p.cpp" +#include "qsoundeffect_pulse_p.moc" diff --git a/src/multimedia/effects/qsoundeffect_pulse_p.h b/src/multimedia/effects/qsoundeffect_pulse_p.h new file mode 100644 index 000000000..c78bcdec5 --- /dev/null +++ b/src/multimedia/effects/qsoundeffect_pulse_p.h @@ -0,0 +1,163 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QSOUNDEFFECT_PULSE_H +#define QSOUNDEFFECT_PULSE_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 "qsoundeffect_p.h" + +#include +#include +#include +#include +#include "qsamplecache_p.h" + +QT_BEGIN_HEADER + +QT_BEGIN_NAMESPACE + +QT_MODULE(Multimedia) + + +class QSoundEffectPrivate : public QObject +{ + Q_OBJECT +public: + explicit QSoundEffectPrivate(QObject* parent); + ~QSoundEffectPrivate(); + + static QStringList supportedMimeTypes(); + + QUrl source() const; + void setSource(const QUrl &url); + int loopCount() const; + void setLoopCount(int loopCount); + int volume() const; + void setVolume(int volume); + bool isMuted() const; + void setMuted(bool muted); + bool isLoaded() const; + bool isPlaying() const; + QSoundEffect::Status status() const; + +public Q_SLOTS: + void play(); + void stop(); + +Q_SIGNALS: + void volumeChanged(); + void mutedChanged(); + void loadedChanged(); + void playingChanged(); + void statusChanged(); + +private Q_SLOTS: + void decoderError(); + void sampleReady(); + void uploadSample(); + void contextReady(); + void underRun(); + void prepare(); + void streamReady(); + void emptyComplete(); + void updateVolume(); + void updateMuted(); + +private: + void playSample(); + + void emptyStream(); + void createPulseStream(); + void unloadPulseStream(); + + void setPlaying(bool playing); + void setStatus(QSoundEffect::Status status); + + static void stream_write_callback(pa_stream *s, size_t length, void *userdata); + static void stream_state_callback(pa_stream *s, void *userdata); + static void stream_underrun_callback(pa_stream *s, void *userdata); + static void stream_cork_callback(pa_stream *s, int success, void *userdata); + static void stream_flush_callback(pa_stream *s, int success, void *userdata); + static void stream_write_done_callback(void *p); + static void stream_adjust_prebuffer_callback(pa_stream *s, int success, void *userdata); + static void stream_reset_buffer_callback(pa_stream *s, int success, void *userdata); + static void setvolume_callback(pa_context *c, int success, void *userdata); + static void setmuted_callback(pa_context *c, int success, void *userdata); + + pa_stream *m_pulseStream; + int m_sinkInputId; + pa_sample_spec m_pulseSpec; + int m_pulseBufferSize; + + bool m_emptying; + bool m_sampleReady; + bool m_playing; + QSoundEffect::Status m_status; + bool m_muted; + bool m_playQueued; + bool m_stopping; + int m_volume; + int m_loopCount; + int m_runningCount; + QUrl m_source; + QByteArray m_name; + + QSample *m_sample; + int m_position; +}; + +QT_END_NAMESPACE + +QT_END_HEADER + +#endif // QSOUNDEFFECT_PULSE_H diff --git a/src/multimedia/effects/qsoundeffect_qmedia_p.cpp b/src/multimedia/effects/qsoundeffect_qmedia_p.cpp new file mode 100644 index 000000000..dfd56b09c --- /dev/null +++ b/src/multimedia/effects/qsoundeffect_qmedia_p.cpp @@ -0,0 +1,233 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +// +// 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. +// +// INTERNAL USE ONLY: Do NOT use for any other purpose. +// + +#include "qsoundeffect_qmedia_p.h" + +#include + +#include "qmediacontent.h" +#include "qmediaplayer.h" + + +QT_BEGIN_NAMESPACE + +QSoundEffectPrivate::QSoundEffectPrivate(QObject* parent): + QObject(parent), + m_loopCount(1), + m_runningCount(0), + m_player(0), + m_status(QSoundEffect::Null), + m_playing(false) +{ + m_player = new QMediaPlayer(this, QMediaPlayer::LowLatency); + connect(m_player, SIGNAL(stateChanged(QMediaPlayer::State)), SLOT(stateChanged(QMediaPlayer::State))); + connect(m_player, SIGNAL(mediaStatusChanged(QMediaPlayer::MediaStatus)), SLOT(mediaStatusChanged(QMediaPlayer::MediaStatus))); + connect(m_player, SIGNAL(error(QMediaPlayer::Error)), SLOT(error(QMediaPlayer::Error))); + connect(m_player, SIGNAL(mutedChanged(bool)), SIGNAL(mutedChanged())); + connect(m_player, SIGNAL(volumeChanged(int)), SIGNAL(volumeChanged())); +} + +QSoundEffectPrivate::~QSoundEffectPrivate() +{ +} + +QStringList QSoundEffectPrivate::supportedMimeTypes() +{ + return QMediaPlayer::supportedMimeTypes(); +} + +QUrl QSoundEffectPrivate::source() const +{ + return m_player->media().canonicalUrl(); +} + +void QSoundEffectPrivate::setSource(const QUrl &url) +{ + m_player->setMedia(url); +} + +int QSoundEffectPrivate::loopCount() const +{ + return m_loopCount; +} + +void QSoundEffectPrivate::setLoopCount(int loopCount) +{ + m_loopCount = loopCount; +} + +int QSoundEffectPrivate::volume() const +{ + return m_player->volume(); +} + +void QSoundEffectPrivate::setVolume(int volume) +{ + m_player->setVolume(volume); +} + +bool QSoundEffectPrivate::isMuted() const +{ + return m_player->isMuted(); +} + +void QSoundEffectPrivate::setMuted(bool muted) +{ + m_player->setMuted(muted); +} + +bool QSoundEffectPrivate::isLoaded() const +{ + return m_status == QSoundEffect::Ready; +} + +bool QSoundEffectPrivate::isPlaying() const +{ + return m_playing; +} + +QSoundEffect::Status QSoundEffectPrivate::status() const +{ + return m_status; +} + +void QSoundEffectPrivate::play() +{ + if (m_status == QSoundEffect::Null || m_status == QSoundEffect::Error) + return; + if (m_loopCount < 0) { + m_runningCount = -1; + } + else { + if (m_runningCount < 0) + m_runningCount = 0; + m_runningCount += m_loopCount; + } + m_player->play(); +} + +void QSoundEffectPrivate::stop() +{ + m_runningCount = 0; + m_player->stop(); +} + +void QSoundEffectPrivate::stateChanged(QMediaPlayer::State state) +{ + if (state == QMediaPlayer::StoppedState) { + if (m_runningCount < 0) { + m_player->play(); + } else if (m_runningCount == 0) { + setPlaying(false); + return; + } else if (--m_runningCount > 0) { + m_player->play(); + } else { + setPlaying(false); + } + } else { + setPlaying(true); + } +} + +void QSoundEffectPrivate::mediaStatusChanged(QMediaPlayer::MediaStatus status) +{ + switch(status) { + case QMediaPlayer::LoadingMedia: + setStatus(QSoundEffect::Loading); + break; + case QMediaPlayer::NoMedia: + setStatus(QSoundEffect::Null); + break; + case QMediaPlayer::InvalidMedia: + setStatus(QSoundEffect::Error); + break; + default: + setStatus(QSoundEffect::Ready); + break; + } +} + +void QSoundEffectPrivate::error(QMediaPlayer::Error err) +{ + bool playingDirty = false; + if (m_playing) { + m_playing = false; + playingDirty = true; + } + setStatus(QSoundEffect::Error); + if (playingDirty) + emit playingChanged(); +} + +void QSoundEffectPrivate::setStatus(QSoundEffect::Status status) +{ + if (m_status == status) + return; + bool oldLoaded = isLoaded(); + m_status = status; + emit statusChanged(); + if (oldLoaded != isLoaded()) + emit loadedChanged(); +} + +void QSoundEffectPrivate::setPlaying(bool playing) +{ + if (m_playing == playing) + return; + m_playing = playing; + emit playingChanged(); +} + +QT_END_NAMESPACE + +#include "moc_qsoundeffect_qmedia_p.cpp" diff --git a/src/multimedia/effects/qsoundeffect_qmedia_p.h b/src/multimedia/effects/qsoundeffect_qmedia_p.h new file mode 100644 index 000000000..adafa04a2 --- /dev/null +++ b/src/multimedia/effects/qsoundeffect_qmedia_p.h @@ -0,0 +1,122 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QSOUNDEFFECT_QMEDIA_H +#define QSOUNDEFFECT_QMEDIA_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 +#include +#include "qmediaplayer.h" +#include "qsoundeffect_p.h" + +QT_BEGIN_HEADER + +QT_BEGIN_NAMESPACE + +QT_MODULE(Multimedia) + + + +class QSoundEffectPrivate : public QObject +{ + Q_OBJECT +public: + + explicit QSoundEffectPrivate(QObject* parent); + ~QSoundEffectPrivate(); + + static QStringList supportedMimeTypes(); + + QUrl source() const; + void setSource(const QUrl &url); + int loopCount() const; + void setLoopCount(int loopCount); + int volume() const; + void setVolume(int volume); + bool isMuted() const; + void setMuted(bool muted); + bool isLoaded() const; + bool isPlaying() const; + QSoundEffect::Status status() const; + +public Q_SLOTS: + void play(); + void stop(); + +Q_SIGNALS: + void volumeChanged(); + void mutedChanged(); + void loadedChanged(); + void playingChanged(); + void statusChanged(); + +private Q_SLOTS: + void stateChanged(QMediaPlayer::State); + void mediaStatusChanged(QMediaPlayer::MediaStatus); + void error(QMediaPlayer::Error); + +private: + void setStatus(QSoundEffect::Status status); + void setPlaying(bool playing); + + int m_loopCount; + int m_runningCount; + bool m_playing; + QSoundEffect::Status m_status; + QMediaPlayer *m_player; +}; + +QT_END_NAMESPACE + +QT_END_HEADER + +#endif // QSOUNDEFFECT_QMEDIA_H diff --git a/src/multimedia/effects/qsoundeffect_qsound_p.cpp b/src/multimedia/effects/qsoundeffect_qsound_p.cpp new file mode 100644 index 000000000..0b9082eb5 --- /dev/null +++ b/src/multimedia/effects/qsoundeffect_qsound_p.cpp @@ -0,0 +1,222 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +// +// 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. +// +// INTERNAL USE ONLY: Do NOT use for any other purpose. +// + +#include "qsoundeffect_qsound_p.h" + +#include +#include +#include + + +QT_BEGIN_NAMESPACE + +QSoundEffectPrivate::QSoundEffectPrivate(QObject* parent): + QObject(parent), + m_playing(false), + m_timerID(0), + m_muted(false), + m_loopCount(1), + m_volume(100), + m_status(QSoundEffect::Null), + m_sound(0) +{ + if (!QSound::isAvailable()) + qWarning("SoundEffect(qsound) : not available"); +} + +QSoundEffectPrivate::~QSoundEffectPrivate() +{ +} + +QStringList QSoundEffectPrivate::supportedMimeTypes() +{ + QStringList supportedTypes; + supportedTypes << QLatin1String("audio/x-wav") << QLatin1String("audio/vnd.wave") ; + return supportedTypes; +} + +QUrl QSoundEffectPrivate::source() const +{ + return m_source; +} + +void QSoundEffectPrivate::setSource(const QUrl &url) +{ + if (url.isEmpty()) { + m_source = QUrl(); + setStatus(QSoundEffect::Null); + return; + } + + if (url.scheme() != QLatin1String("file")) { + m_source = url; + setStatus(QSoundEffect::Error); + return; + } + + if (m_sound != 0) + delete m_sound; + + m_source = url; + m_sound = new QSound(m_source.toLocalFile(), this); + m_sound->setLoops(m_loopCount); + m_status = QSoundEffect::Ready; + emit statusChanged(); + emit loadedChanged(); +} + +int QSoundEffectPrivate::loopCount() const +{ + return m_loopCount; +} + +void QSoundEffectPrivate::setLoopCount(int lc) +{ + m_loopCount = lc; + if (m_sound) + m_sound->setLoops(lc); +} + +int QSoundEffectPrivate::volume() const +{ + return m_volume; +} + +void QSoundEffectPrivate::setVolume(int v) +{ + m_volume = v; +} + +bool QSoundEffectPrivate::isMuted() const +{ + return m_muted; +} + +void QSoundEffectPrivate::setMuted(bool muted) +{ + m_muted = muted; +} + +bool QSoundEffectPrivate::isLoaded() const +{ + return m_status == QSoundEffect::Ready; +} + +void QSoundEffectPrivate::play() +{ + if (m_status == QSoundEffect::Null || m_status == QSoundEffect::Error) + return; + if (m_timerID != 0) + killTimer(m_timerID); + m_timerID = startTimer(500); + m_sound->play(); + setPlaying(true); +} + + +void QSoundEffectPrivate::stop() +{ + if (m_timerID != 0) + killTimer(m_timerID); + m_timerID = 0; + m_sound->stop(); + setPlaying(false); +} + +bool QSoundEffectPrivate::isPlaying() +{ + if (m_playing && m_sound && m_sound->isFinished()) { + if (m_timerID != 0) + killTimer(m_timerID); + m_timerID = 0; + setPlaying(false); + } + return m_playing; +} + +QSoundEffect::Status QSoundEffectPrivate::status() const +{ + return m_status; +} + +void QSoundEffectPrivate::timerEvent(QTimerEvent *event) +{ + Q_UNUSED(event); + setPlaying(!m_sound->isFinished()); + if (isPlaying()) + return; + killTimer(m_timerID); + m_timerID = 0; +} + +void QSoundEffectPrivate::setStatus(QSoundEffect::Status status) +{ + if (m_status == status) + return; + bool oldLoaded = isLoaded(); + m_status = status; + emit statusChanged(); + if (oldLoaded != isLoaded()) + emit loadedChanged(); +} + +void QSoundEffectPrivate::setPlaying(bool playing) +{ + if (m_playing == playing) + return; + m_playing = playing; + emit playingChanged(); +} + +QT_END_NAMESPACE + +#include "moc_qsoundeffect_qsound_p.cpp" diff --git a/src/multimedia/effects/qsoundeffect_qsound_p.h b/src/multimedia/effects/qsoundeffect_qsound_p.h new file mode 100644 index 000000000..c98ad79ce --- /dev/null +++ b/src/multimedia/effects/qsoundeffect_qsound_p.h @@ -0,0 +1,121 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QSOUNDEFFECT_QSOUND_H +#define QSOUNDEFFECT_QSOUND_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 +#include +#include "qsoundeffect_p.h" + +QT_BEGIN_HEADER + +QT_BEGIN_NAMESPACE + +QT_MODULE(Multimedia) + + +class QSound; + +class QSoundEffectPrivate : public QObject +{ + Q_OBJECT +public: + explicit QSoundEffectPrivate(QObject* parent); + ~QSoundEffectPrivate(); + + static QStringList supportedMimeTypes(); + + QUrl source() const; + void setSource(const QUrl &url); + int loopCount() const; + void setLoopCount(int loopCount); + int volume() const; + void setVolume(int volume); + bool isMuted() const; + void setMuted(bool muted); + bool isLoaded() const; + bool isPlaying(); + QSoundEffect::Status status() const; + +public Q_SLOTS: + void play(); + void stop(); + +Q_SIGNALS: + void volumeChanged(); + void mutedChanged(); + void loadedChanged(); + void playingChanged(); + void statusChanged(); + +private: + void setStatus(QSoundEffect::Status status); + void setPlaying(bool playing); + void timerEvent(QTimerEvent *event); + + bool m_playing; + int m_timerID; + bool m_muted; + int m_loopCount; + int m_volume; + QSoundEffect::Status m_status; + QSound *m_sound; + QUrl m_source; +}; + +QT_END_NAMESPACE + +QT_END_HEADER + +#endif // QSOUNDEFFECT_QSOUND_H diff --git a/src/multimedia/effects/qwavedecoder_p.cpp b/src/multimedia/effects/qwavedecoder_p.cpp new file mode 100644 index 000000000..19b262adc --- /dev/null +++ b/src/multimedia/effects/qwavedecoder_p.cpp @@ -0,0 +1,232 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qwavedecoder_p.h" + +#include +#include + +QT_BEGIN_NAMESPACE + +QWaveDecoder::QWaveDecoder(QIODevice *s, QObject *parent): + QIODevice(parent), + haveFormat(false), + dataSize(0), + remaining(0), + source(s), + state(QWaveDecoder::InitialState) +{ + open(QIODevice::ReadOnly | QIODevice::Unbuffered); + + if (enoughDataAvailable()) + QTimer::singleShot(0, this, SLOT(handleData())); + else + connect(source, SIGNAL(readyRead()), SLOT(handleData())); +} + +QWaveDecoder::~QWaveDecoder() +{ +} + +QAudioFormat QWaveDecoder::audioFormat() const +{ + return format; +} + +int QWaveDecoder::duration() const +{ + return size() * 1000 / (format.sampleSize() / 8) / format.channels() / format.frequency(); +} + +qint64 QWaveDecoder::size() const +{ + return haveFormat ? dataSize : 0; +} + +bool QWaveDecoder::isSequential() const +{ + return source->isSequential(); +} + +qint64 QWaveDecoder::bytesAvailable() const +{ + return haveFormat ? source->bytesAvailable() : 0; +} + +qint64 QWaveDecoder::readData(char *data, qint64 maxlen) +{ + return haveFormat ? source->read(data, maxlen) : 0; +} + +qint64 QWaveDecoder::writeData(const char *data, qint64 len) +{ + Q_UNUSED(data); + Q_UNUSED(len); + + return -1; +} + +void QWaveDecoder::handleData() +{ + if (state == QWaveDecoder::InitialState) { + if (source->bytesAvailable() < qint64(sizeof(RIFFHeader))) + return; + + RIFFHeader riff; + source->read(reinterpret_cast(&riff), sizeof(RIFFHeader)); + + if (qstrncmp(riff.descriptor.id, "RIFF", 4) != 0 || + qstrncmp(riff.type, "WAVE", 4) != 0) { + source->disconnect(SIGNAL(readyRead()), this, SLOT(handleData())); + emit invalidFormat(); + + return; + } else { + state = QWaveDecoder::WaitingForFormatState; + } + } + + if (state == QWaveDecoder::WaitingForFormatState) { + if (findChunk("fmt ")) { + chunk descriptor; + source->peek(reinterpret_cast(&descriptor), sizeof(chunk)); + + if (source->bytesAvailable() < qint64(descriptor.size + sizeof(chunk))) + return; + + WAVEHeader wave; + source->read(reinterpret_cast(&wave), sizeof(WAVEHeader)); + if (descriptor.size > sizeof(WAVEHeader)) + discardBytes(descriptor.size - sizeof(WAVEHeader)); + + if (wave.audioFormat != 0 && wave.audioFormat != 1) { + source->disconnect(SIGNAL(readyRead()), this, SLOT(handleData())); + emit invalidFormat(); + + return; + } else { + int bps = qFromLittleEndian(wave.bitsPerSample); + + format.setCodec(QLatin1String("audio/pcm")); + format.setSampleType(bps == 8 ? QAudioFormat::UnSignedInt : QAudioFormat::SignedInt); + format.setByteOrder(QAudioFormat::LittleEndian); + format.setFrequency(qFromLittleEndian(wave.sampleRate)); + format.setSampleSize(bps); + format.setChannels(qFromLittleEndian(wave.numChannels)); + + state = QWaveDecoder::WaitingForDataState; + } + } + } + + if (state == QWaveDecoder::WaitingForDataState) { + if (findChunk("data")) { + source->disconnect(SIGNAL(readyRead()), this, SLOT(handleData())); + + chunk descriptor; + source->read(reinterpret_cast(&descriptor), sizeof(chunk)); + dataSize = descriptor.size; + + haveFormat = true; + connect(source, SIGNAL(readyRead()), SIGNAL(readyRead())); + emit formatKnown(); + + return; + } + } + + if (source->atEnd()) { + source->disconnect(SIGNAL(readyRead()), this, SLOT(handleData())); + emit invalidFormat(); + + return; + } + +} + +bool QWaveDecoder::enoughDataAvailable() +{ + if (source->bytesAvailable() < qint64(sizeof(chunk))) + return false; + + chunk descriptor; + source->peek(reinterpret_cast(&descriptor), sizeof(chunk)); + + if (source->bytesAvailable() < qint64(sizeof(chunk) + descriptor.size)) + return false; + + return true; +} + +bool QWaveDecoder::findChunk(const char *chunkId) +{ + if (source->bytesAvailable() < qint64(sizeof(chunk))) + return false; + + chunk descriptor; + source->peek(reinterpret_cast(&descriptor), sizeof(chunk)); + + if (qstrncmp(descriptor.id, chunkId, 4) == 0) + return true; + + while (source->bytesAvailable() >= qint64(sizeof(chunk) + descriptor.size)) { + discardBytes(sizeof(chunk) + descriptor.size); + + source->peek(reinterpret_cast(&descriptor), sizeof(chunk)); + + if (qstrncmp(descriptor.id, chunkId, 4) == 0) + return true; + } + + return false; +} + +void QWaveDecoder::discardBytes(qint64 numBytes) +{ + if (source->isSequential()) + source->read(numBytes); + else + source->seek(source->pos() + numBytes); +} + +QT_END_NAMESPACE + +#include "moc_qwavedecoder_p.cpp" diff --git a/src/multimedia/effects/qwavedecoder_p.h b/src/multimedia/effects/qwavedecoder_p.h new file mode 100644 index 000000000..6c4c00c25 --- /dev/null +++ b/src/multimedia/effects/qwavedecoder_p.h @@ -0,0 +1,137 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef WAVEDECODER_H +#define WAVEDECODER_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists for the convenience +// of other Qt classes. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include +#include + + +QT_BEGIN_HEADER + +QT_BEGIN_NAMESPACE + +QT_MODULE(Multimedia) + + + +class QWaveDecoder : public QIODevice +{ + Q_OBJECT + +public: + explicit QWaveDecoder(QIODevice *source, QObject *parent = 0); + ~QWaveDecoder(); + + QAudioFormat audioFormat() const; + int duration() const; + + qint64 size() const; + bool isSequential() const; + qint64 bytesAvailable() const; + +Q_SIGNALS: + void formatKnown(); + void invalidFormat(); + +private Q_SLOTS: + void handleData(); + +private: + qint64 readData(char *data, qint64 maxlen); + qint64 writeData(const char *data, qint64 len); + + bool enoughDataAvailable(); + bool findChunk(const char *chunkId); + void discardBytes(qint64 numBytes); + + enum State { + InitialState, + WaitingForFormatState, + WaitingForDataState + }; + + struct chunk + { + char id[4]; + quint32 size; + }; + struct RIFFHeader + { + chunk descriptor; + char type[4]; + }; + struct WAVEHeader + { + chunk descriptor; + quint16 audioFormat; + quint16 numChannels; + quint32 sampleRate; + quint32 byteRate; + quint16 blockAlign; + quint16 bitsPerSample; + }; + + bool haveFormat; + qint64 dataSize; + qint64 remaining; + QAudioFormat format; + QIODevice *source; + State state; +}; + +QT_END_NAMESPACE + +QT_END_HEADER + +#endif // WAVEDECODER_H diff --git a/src/multimedia/multimedia.pro b/src/multimedia/multimedia.pro new file mode 100644 index 000000000..b955e71a0 --- /dev/null +++ b/src/multimedia/multimedia.pro @@ -0,0 +1,156 @@ +load(qt_module) + +TARGET = QtMultimedia +QPRO_PWD = $$PWD +QT = core network gui + +CONFIG += module +MODULE_PRI += ../../modules/qt_multimedia.pri + +contains(QT_CONFIG, opengl) | contains(QT_CONFIG, opengles2) { +} else { + DEFINES += QT_NO_OPENGL +} + +!static:DEFINES += QT_MAKEDLL +DEFINES += QT_BUILD_MULTIMEDIA_LIB + +load(qt_module_config) + +HEADERS += qtmultimediaversion.h + + +PRIVATE_HEADERS += \ + qmediacontrol_p.h \ + qmediaobject_p.h \ + qmediaservice_p.h \ + qmediaplaylist_p.h \ + qmediaplaylistprovider_p.h \ + qmediaimageviewerservice_p.h \ + qmediapluginloader_p.h \ + qvideosurfaceoutput_p.h + +PUBLIC_HEADERS += \ + qmediacontrol.h \ + qmediaobject.h \ + qmediaservice.h \ + qmediabindableinterface.h \ + qlocalmediaplaylistprovider.h \ + qmediaimageviewer.h \ + qmediaplayer.h \ + qmediaplayercontrol.h \ + qmediaplaylist.h \ + qmediaplaylistnavigator.h \ + qmediaplaylistprovider.h \ + qmediaplaylistioplugin.h \ + qmediabackgroundplaybackcontrol.h \ + qmediacontent.h \ + qmediaresource.h \ + qmediarecorder.h \ + qmediaencodersettings.h \ + qmediarecordercontrol.h \ + qmediaserviceprovider.h \ + qmediaserviceproviderplugin.h \ + qmetadatareadercontrol.h \ + qmetadatawritercontrol.h \ + qmediastreamscontrol.h \ + qradiotuner.h \ + qradiotunercontrol.h \ + qtmedianamespace.h \ + qaudioencodercontrol.h \ + qvideoencodercontrol.h \ + qimageencodercontrol.h \ + qaudiocapturesource.h \ + qmediacontainercontrol.h \ + qmediaplaylistcontrol.h \ + qmediaplaylistsourcecontrol.h \ + qaudioendpointselector.h \ + qvideodevicecontrol.h \ + qvideorenderercontrol.h \ + qmediatimerange.h \ + qmedianetworkaccesscontrol.h \ + qmediaenumdebug.h \ + qtmultimediadefs.h + +SOURCES += qmediacontrol.cpp \ + qmediaobject.cpp \ + qmediaservice.cpp \ + qmediabindableinterface.cpp \ + qlocalmediaplaylistprovider.cpp \ + qmediaimageviewer.cpp \ + qmediaimageviewerservice.cpp \ + qmediaplayer.cpp \ + qmediaplayercontrol.cpp \ + qmediaplaylist.cpp \ + qmediaplaylistioplugin.cpp \ + qmediaplaylistnavigator.cpp \ + qmediaplaylistprovider.cpp \ + qmediarecorder.cpp \ + qmediaencodersettings.cpp \ + qmediarecordercontrol.cpp \ + qmediacontent.cpp \ + qmediaresource.cpp \ + qmediaserviceprovider.cpp \ + qmetadatareadercontrol.cpp \ + qmetadatawritercontrol.cpp \ + qmediastreamscontrol.cpp \ + qradiotuner.cpp \ + qradiotunercontrol.cpp \ + qaudioencodercontrol.cpp \ + qvideoencodercontrol.cpp \ + qimageencodercontrol.cpp \ + qaudiocapturesource.cpp \ + qmediacontainercontrol.cpp \ + qmediaplaylistcontrol.cpp \ + qmediaplaylistsourcecontrol.cpp \ + qaudioendpointselector.cpp \ + qvideodevicecontrol.cpp \ + qmediapluginloader.cpp \ + qvideorenderercontrol.cpp \ + qmediatimerange.cpp \ + qmedianetworkaccesscontrol.cpp \ + qvideosurfaceoutput.cpp \ + qmediabackgroundplaybackcontrol.cpp + +#Camera +PUBLIC_HEADERS += \ + qcamera.h \ + qcameraimagecapture.h \ + qcameraimagecapturecontrol.h \ + qcameraexposure.h \ + qcamerafocus.h \ + qcameraimageprocessing.h \ + qcameracontrol.h \ + qcameralockscontrol.h \ + qcameraexposurecontrol.h \ + qcamerafocuscontrol.h \ + qcameraflashcontrol.h \ + qcameraimageprocessingcontrol.h \ + qcameracapturedestinationcontrol.h \ + qcameracapturebufferformatcontrol.h + +SOURCES += \ + qcamera.cpp \ + qcameraexposure.cpp \ + qcamerafocus.cpp \ + qcameraimageprocessing.cpp \ + qcameraimagecapture.cpp \ + qcameraimagecapturecontrol.cpp \ + qcameracontrol.cpp \ + qcameralockscontrol.cpp \ + qcameraexposurecontrol.cpp \ + qcamerafocuscontrol.cpp \ + qcameraflashcontrol.cpp \ + qcameraimageprocessingcontrol.cpp \ + qcameracapturedestinationcontrol.cpp \ + qcameracapturebufferformatcontrol.cpp + +include(audio/audio.pri) +include(video/video.pri) +include(effects/effects.pri) + +mac:!qpa { + LIBS += -framework AppKit -framework QuartzCore -framework QTKit +} + +HEADERS += $$PUBLIC_HEADERS $$PRIVATE_HEADERS diff --git a/src/multimedia/qaudiocapturesource.cpp b/src/multimedia/qaudiocapturesource.cpp new file mode 100644 index 000000000..469617123 --- /dev/null +++ b/src/multimedia/qaudiocapturesource.cpp @@ -0,0 +1,275 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qmediaobject_p.h" +#include +#include "qaudioendpointselector.h" + +QT_BEGIN_NAMESPACE + +/*! + \class QAudioCaptureSource + \brief The QAudioCaptureSource class provides an interface to query and select an audio input endpoint. + \inmodule QtMultimedia + \ingroup multimedia + \since 1.0 + + QAudioCaptureSource provides access to the audio inputs available on your system. + + You can query these inputs and select one to use. + + A typical implementation example: + \snippet doc/src/snippets/multimedia-snippets/media.cpp Audio capture source + + The audiocapturesource interface is then used to: + + - Get and Set the audio input to use. + + The capture interface is then used to: + + - Set the destination using setOutputLocation() + + - Set the format parameters using setAudioCodec(), + + - Control the recording using record(),stop() + + \sa QMediaRecorder +*/ + +class QAudioCaptureSourcePrivate : public QMediaObjectPrivate +{ +public: + Q_DECLARE_PUBLIC(QAudioCaptureSource) + + void initControls() + { + Q_Q(QAudioCaptureSource); + + if (service != 0) + audioEndpointSelector = qobject_cast(service->requestControl(QAudioEndpointSelector_iid)); + + if (audioEndpointSelector) { + q->connect(audioEndpointSelector, SIGNAL(activeEndpointChanged(const QString&)), + SIGNAL(activeAudioInputChanged(const QString&))); + q->connect(audioEndpointSelector, SIGNAL(availableEndpointsChanged()), + SIGNAL(availableAudioInputsChanged())); + q->connect(audioEndpointSelector, SIGNAL(availableEndpointsChanged()), + SLOT(statusChanged())); + errorState = QtMultimedia::NoError; + } + } + + QAudioCaptureSourcePrivate():provider(0), audioEndpointSelector(0), errorState(QtMultimedia::ServiceMissingError) {} + QMediaServiceProvider *provider; + QAudioEndpointSelector *audioEndpointSelector; + QtMultimedia::AvailabilityError errorState; +}; + +/*! + Construct a QAudioCaptureSource using the QMediaService from \a provider, with \a parent. + \since 1.0 +*/ + +QAudioCaptureSource::QAudioCaptureSource(QObject *parent, QMediaServiceProvider *provider): + QMediaObject(*new QAudioCaptureSourcePrivate, parent, provider->requestService(Q_MEDIASERVICE_AUDIOSOURCE)) +{ + Q_D(QAudioCaptureSource); + + d->provider = provider; + d->initControls(); +} + +/*! + Destroys the audiocapturesource object. +*/ + +QAudioCaptureSource::~QAudioCaptureSource() +{ + Q_D(QAudioCaptureSource); + + if (d->service && d->audioEndpointSelector) + d->service->releaseControl(d->audioEndpointSelector); + + if (d->provider) + d->provider->releaseService(d->service); +} + +/*! + Returns the error state of the audio capture service. + \since 1.0 +*/ + +QtMultimedia::AvailabilityError QAudioCaptureSource::availabilityError() const +{ + Q_D(const QAudioCaptureSource); + + return d->errorState; +} + +/*! + Returns true if the audio capture service is available, otherwise returns false. + \since 1.0 +*/ +bool QAudioCaptureSource::isAvailable() const +{ + Q_D(const QAudioCaptureSource); + + if (d->service != NULL) { + if (d->audioEndpointSelector && d->audioEndpointSelector->availableEndpoints().size() > 0) + return true; + } + return false; +} + + +/*! + Returns a list of available audio inputs + \since 1.0 +*/ + +QList QAudioCaptureSource::audioInputs() const +{ + Q_D(const QAudioCaptureSource); + + QList list; + if (d && d->audioEndpointSelector) + list <audioEndpointSelector->availableEndpoints(); + + return list; +} + +/*! + Returns the description of the audio input device with \a name. + \since 1.0 +*/ + +QString QAudioCaptureSource::audioDescription(const QString& name) const +{ + Q_D(const QAudioCaptureSource); + + if(d->audioEndpointSelector) + return d->audioEndpointSelector->endpointDescription(name); + else + return QString(); +} + +/*! + Returns the default audio input name. + \since 1.0 +*/ + +QString QAudioCaptureSource::defaultAudioInput() const +{ + Q_D(const QAudioCaptureSource); + + if(d->audioEndpointSelector) + return d->audioEndpointSelector->defaultEndpoint(); + else + return QString(); +} + +/*! + Returns the active audio input name. + \since 1.0 +*/ + +QString QAudioCaptureSource::activeAudioInput() const +{ + Q_D(const QAudioCaptureSource); + + if(d->audioEndpointSelector) + return d->audioEndpointSelector->activeEndpoint(); + else + return QString(); +} + +/*! + Set the active audio input to \a name. + \since 1.0 +*/ + +void QAudioCaptureSource::setAudioInput(const QString& name) +{ + Q_D(const QAudioCaptureSource); + + if(d->audioEndpointSelector) + return d->audioEndpointSelector->setActiveEndpoint(name); +} + +/*! + \fn QAudioCaptureSource::activeAudioInputChanged(const QString& name) + + Signal emitted when active audio input changes to \a name. + \since 1.0 +*/ + +/*! + \fn QAudioCaptureSource::availableAudioInputsChanged() + + Signal is emitted when the available audio inputs change. + \since 1.0 +*/ + +/*! + \internal + \since 1.0 +*/ +void QAudioCaptureSource::statusChanged() +{ + Q_D(QAudioCaptureSource); + + if (d->audioEndpointSelector) { + if (d->audioEndpointSelector->availableEndpoints().size() > 0) { + d->errorState = QtMultimedia::NoError; + emit availabilityChanged(true); + } else { + d->errorState = QtMultimedia::BusyError; + emit availabilityChanged(false); + } + } else { + d->errorState = QtMultimedia::ServiceMissingError; + emit availabilityChanged(false); + } +} + +#include "moc_qaudiocapturesource.cpp" +QT_END_NAMESPACE + diff --git a/src/multimedia/qaudiocapturesource.h b/src/multimedia/qaudiocapturesource.h new file mode 100644 index 000000000..1571b4e8a --- /dev/null +++ b/src/multimedia/qaudiocapturesource.h @@ -0,0 +1,103 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QAUDIOCAPTURESOURCE_H +#define QAUDIOCAPTURESOURCE_H + +#include +#include +#include + +#include + +#include "qmediarecorder.h" +#include "qmediacontrol.h" +#include "qmediaobject.h" +#include "qmediaservice.h" + +#include "qmediaserviceprovider.h" + +QT_BEGIN_HEADER + +QT_BEGIN_NAMESPACE + +QT_MODULE(Multimedia) + + +class QAudioCaptureSourcePrivate; + +class Q_MULTIMEDIA_EXPORT QAudioCaptureSource : public QMediaObject +{ + Q_OBJECT + +public: + QAudioCaptureSource(QObject *parent = 0, QMediaServiceProvider *service = QMediaServiceProvider::defaultServiceProvider()); + ~QAudioCaptureSource(); + + bool isAvailable() const; + QtMultimedia::AvailabilityError availabilityError() const; + + QList audioInputs() const; + + QString audioDescription(const QString& name) const; + QString defaultAudioInput() const; + QString activeAudioInput() const; + +public Q_SLOTS: + void setAudioInput(const QString& name); + +Q_SIGNALS: + void activeAudioInputChanged(const QString& name); + void availableAudioInputsChanged(); + +private Q_SLOTS: + void statusChanged(); + +private: + Q_DECLARE_PRIVATE(QAudioCaptureSource) +}; + +QT_END_NAMESPACE + +QT_END_HEADER + + +#endif // QAUDIOCAPTURESOURCE_H diff --git a/src/multimedia/qaudioencodercontrol.cpp b/src/multimedia/qaudioencodercontrol.cpp new file mode 100644 index 000000000..62fa89371 --- /dev/null +++ b/src/multimedia/qaudioencodercontrol.cpp @@ -0,0 +1,167 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qaudioencodercontrol.h" +#include + +QT_BEGIN_NAMESPACE + + +/*! + \class QAudioEncoderControl + \inmodule QtMultimedia + \ingroup multimedia-serv + \since 1.0 + + \brief The QAudioEncoderControl class provides access to the settings of a + media service that performs audio encoding. + + If a QMediaService supports encoding audio data it will implement + QAudioEncoderControl. This control provides information about the limits + of restricted audio encoder options and allows the selection of a set of + audio encoder settings as specified in a QAudioEncoderSettings object. + + The functionality provided by this control is exposed to application code through the + QMediaRecorder class. + + The interface name of QAudioEncoderControl is \c com.nokia.Qt.QAudioEncoderControl/1.0 as + defined in QAudioEncoderControl_iid. + + \sa QMediaService::requestControl(), QMediaRecorder +*/ + +/*! + \macro QAudioEncoderControl_iid + + \c com.nokia.Qt.AudioEncoderControl/1.0 + + Defines the interface name of the QAudioEncoderControl class. + + \relates QAudioEncoderControl +*/ + +/*! + Create a new audio encode control object with the given \a parent. +*/ +QAudioEncoderControl::QAudioEncoderControl(QObject *parent) + :QMediaControl(parent) +{ +} + +/*! + Destroys the audio encode control. +*/ +QAudioEncoderControl::~QAudioEncoderControl() +{ +} + +/*! + \fn QAudioEncoderControl::supportedAudioCodecs() const + + Returns the list of supported audio codec names. + \since 1.0 +*/ + +/*! + \fn QAudioEncoderControl::codecDescription(const QString &codec) const + + Returns description of audio \a codec. + \since 1.0 +*/ + +/*! + \fn QAudioEncoderControl::supportedSampleRates(const QAudioEncoderSettings &settings = QAudioEncoderSettings(), + bool *continuous) const + + Returns the list of supported audio sample rates, if known. + + If non null audio \a settings parameter is passed, + the returned list is reduced to sample rates supported with partial settings applied. + + It can be used for example to query the list of sample rates, supported by specific audio codec. + + If the encoder supports arbitrary sample rates within the supported rates range, + *\a continuous is set to true, otherwise *\a continuous is set to false. + \since 1.0 +*/ + +/*! + \fn QAudioEncoderControl::supportedEncodingOptions(const QString &codec) const + + Returns the list of \a codec specific audio encoding options. + \since 1.0 +*/ + +/*! + \fn QAudioEncoderControl::encodingOption(const QString &codec, const QString &option) const + + Returns the value of audio encoding \a option for \a codec. + \since 1.0 +*/ + +/*! + \fn QAudioEncoderControl::setEncodingOption(const QString &codec, const QString &option, const QVariant &value) + + Set the \a codec specific \a option to \a value. + \since 1.0 +*/ + +/*! + \fn QAudioEncoderControl::audioSettings() const + + Returns the audio encoder settings. + + The returned value may be different tha passed to QAudioEncoderControl::setAudioSettings() + if the settings contains the default or undefined parameters. + In this case if the undefined parameters are already resolved, they should be returned. + \since 1.0 +*/ + +/*! + \fn QAudioEncoderControl::setAudioSettings(const QAudioEncoderSettings &settings) + + Sets the selected audio \a settings. + \since 1.0 +*/ + +#include "moc_qaudioencodercontrol.cpp" +QT_END_NAMESPACE + diff --git a/src/multimedia/qaudioencodercontrol.h b/src/multimedia/qaudioencodercontrol.h new file mode 100644 index 000000000..2e3a4bf87 --- /dev/null +++ b/src/multimedia/qaudioencodercontrol.h @@ -0,0 +1,95 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QAUDIOENCODERCONTROL_H +#define QAUDIOENCODERCONTROL_H + +#include "qmediacontrol.h" +#include "qmediarecorder.h" +#include +#include + +QT_BEGIN_HEADER + +QT_BEGIN_NAMESPACE + +QT_MODULE(Multimedia) + +class QStringList; +class QAudioFormat; +QT_END_NAMESPACE + +QT_BEGIN_NAMESPACE + +class Q_MULTIMEDIA_EXPORT QAudioEncoderControl : public QMediaControl +{ + Q_OBJECT + +public: + virtual ~QAudioEncoderControl(); + + virtual QStringList supportedAudioCodecs() const = 0; + virtual QString codecDescription(const QString &codecName) const = 0; + + virtual QList supportedSampleRates(const QAudioEncoderSettings &settings, + bool *continuous = 0) const = 0; + + virtual QAudioEncoderSettings audioSettings() const = 0; + virtual void setAudioSettings(const QAudioEncoderSettings&) = 0; + + virtual QStringList supportedEncodingOptions(const QString &codec) const = 0; + virtual QVariant encodingOption(const QString &codec, const QString &name) const = 0; + virtual void setEncodingOption( + const QString &codec, const QString &name, const QVariant &value) = 0; + +protected: + QAudioEncoderControl(QObject *parent = 0); +}; + +#define QAudioEncoderControl_iid "com.nokia.Qt.QAudioEncoderControl/1.0" +Q_MEDIA_DECLARE_CONTROL(QAudioEncoderControl, QAudioEncoderControl_iid) + +QT_END_NAMESPACE + +QT_END_HEADER + + +#endif // QAUDIOCAPTUREPROPERTIESCONTROL_H diff --git a/src/multimedia/qaudioendpointselector.cpp b/src/multimedia/qaudioendpointselector.cpp new file mode 100644 index 000000000..ba02c8d15 --- /dev/null +++ b/src/multimedia/qaudioendpointselector.cpp @@ -0,0 +1,140 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qaudioendpointselector.h" + +QT_BEGIN_NAMESPACE + +/*! + \class QAudioEndpointSelector + + \brief The QAudioEndpointSelector class provides an audio endpoint selector media control. + \inmodule QtMultimedia + \ingroup multimedia + \since 1.0 + + The QAudioEndpointSelector class provides descriptions of the audio + endpoints available on a system and allows one to be selected as the audio + of a media service. + + The interface name of QAudioEndpointSelector is \c com.nokia.Qt.QAudioEndpointSelector/1.0 as + defined in QAudioEndpointSelector_iid. + + \sa QMediaService::requestControl() +*/ + +/*! + \macro QAudioEndpointSelector_iid + + \c com.nokia.Qt.QAudioEndpointSelector/1.0 + + Defines the interface name of the QAudioEndpointSelector class. + + \relates QAudioEndpointSelector +*/ + +/*! + Constructs a new audio endpoint selector with the given \a parent. +*/ +QAudioEndpointSelector::QAudioEndpointSelector(QObject *parent) + :QMediaControl(parent) +{ +} + +/*! + Destroys an audio endpoint selector. +*/ +QAudioEndpointSelector::~QAudioEndpointSelector() +{ +} + +/*! + \fn QList QAudioEndpointSelector::availableEndpoints() const + + Returns a list of the names of the available audio endpoints. + \since 1.0 +*/ + +/*! + \fn QString QAudioEndpointSelector::endpointDescription(const QString& name) const + + Returns the description of the endpoint \a name. + \since 1.0 +*/ + +/*! + \fn QString QAudioEndpointSelector::defaultEndpoint() const + + Returns the name of the default audio endpoint. + \since 1.0 +*/ + +/*! + \fn QString QAudioEndpointSelector::activeEndpoint() const + + Returns the name of the currently selected audio endpoint. + \since 1.0 +*/ + +/*! + \fn QAudioEndpointSelector::setActiveEndpoint(const QString& name) + + Set the active audio endpoint to \a name. + \since 1.0 +*/ + +/*! + \fn QAudioEndpointSelector::activeEndpointChanged(const QString& name) + + Signals that the audio endpoint has changed to \a name. + \since 1.0 +*/ + +/*! + \fn QAudioEndpointSelector::availableEndpointsChanged() + + Signals that list of available endpoints has changed. + \since 1.0 +*/ + +#include "moc_qaudioendpointselector.cpp" +QT_END_NAMESPACE + diff --git a/src/multimedia/qaudioendpointselector.h b/src/multimedia/qaudioendpointselector.h new file mode 100644 index 000000000..00250bc54 --- /dev/null +++ b/src/multimedia/qaudioendpointselector.h @@ -0,0 +1,86 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QAUDIOENDPOINTSELECTOR_H +#define QAUDIOENDPOINTSELECTOR_H + +#include +#include + +QT_BEGIN_HEADER + +QT_BEGIN_NAMESPACE + +QT_MODULE(Multimedia) + + +class Q_MULTIMEDIA_EXPORT QAudioEndpointSelector : public QMediaControl +{ + Q_OBJECT + +public: + virtual ~QAudioEndpointSelector(); + + virtual QList availableEndpoints() const = 0; + virtual QString endpointDescription(const QString& name) const = 0; + virtual QString defaultEndpoint() const = 0; + virtual QString activeEndpoint() const = 0; + +public Q_SLOTS: + virtual void setActiveEndpoint(const QString& name) = 0; + +Q_SIGNALS: + void activeEndpointChanged(const QString& name); + void availableEndpointsChanged(); + +protected: + QAudioEndpointSelector(QObject *parent = 0); +}; + +#define QAudioEndpointSelector_iid "com.nokia.Qt.QAudioEndpointSelector/1.0" +Q_MEDIA_DECLARE_CONTROL(QAudioEndpointSelector, QAudioEndpointSelector_iid) + +QT_END_NAMESPACE + +QT_END_HEADER + + +#endif // QAUDIOENDPOINTSELECTOR_H diff --git a/src/multimedia/qaudionamespace.qdoc b/src/multimedia/qaudionamespace.qdoc new file mode 100644 index 000000000..86300b065 --- /dev/null +++ b/src/multimedia/qaudionamespace.qdoc @@ -0,0 +1,70 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:FDL$ +** GNU Free Documentation License +** Alternatively, this file may be used under the terms of the GNU Free +** Documentation License version 1.3 as published by the Free Software +** Foundation and appearing in the file included in the packaging of +** this file. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms +** and conditions contained in a signed written agreement between you +** and Nokia. +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + + + +/*! + \namespace QAudio + \brief The QAudio namespace contains enums used by the audio classes. + \inmodule QtMultimedia + \ingroup multimedia +*/ + +/* + \enum QAudio::Error + + Error states + + \value NoError No errors have occurred + \value OpenError An error opening the audio device + \value IOError An error occurred during read/write of audio device + \value UnderrunError Audio data is not being fed to the audio device at a fast enough rate + \value FatalError A non-recoverable error has occurred, the audio device is not usable at this time. +*/ + +/* + \enum QAudio::State + + Audio processing states + + \value ActiveState Audio data is being processed, this state is set after start() is called + and while audio data is available to be processed. + \value SuspendedState The audio device is in a suspended state, this state will only be entered + after suspend() is called. + \value StoppedState The audio device is closed, not processing any audio data + \value IdleState The QIODevice passed in has no data and audio system's buffer is empty, this state + is set after start() is called and while no audio data is available to be processed. +*/ + +/* + \enum QAudio::Mode + + Audio I/O modes + + \value AudioOutput audio output device + \value AudioInput audio input device +*/ diff --git a/src/multimedia/qcamera.cpp b/src/multimedia/qcamera.cpp new file mode 100644 index 000000000..2b187262b --- /dev/null +++ b/src/multimedia/qcamera.cpp @@ -0,0 +1,1035 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +QT_USE_NAMESPACE + +namespace +{ +class CameraRegisterMetaTypes +{ +public: + CameraRegisterMetaTypes() + { + qRegisterMetaType("QCamera::Error"); + qRegisterMetaType("QCamera::State"); + qRegisterMetaType("QCamera::Status"); + qRegisterMetaType("QCamera::CaptureMode"); + qRegisterMetaType("QCamera::LockType"); + qRegisterMetaType("QCamera::LockStatus"); + qRegisterMetaType("QCamera::LockChangeReason"); + } +} _registerCameraMetaTypes; +} + + +/*! + \class QCamera + + + \brief The QCamera class provides interface for system camera devices. + + \inmodule QtMultimedia + \ingroup camera + \since 1.1 + + QCamera can be used with QVideoWidget for viewfinder display, + QMediaRecorder for video recording and QCameraImageCapture for image taking. + + \snippet doc/src/snippets/multimedia-snippets/media.cpp Request control + +*/ + + +class QCameraPrivate : public QMediaObjectPrivate +{ + Q_DECLARE_NON_CONST_PUBLIC(QCamera) +public: + QCameraPrivate(): + QMediaObjectPrivate(), + provider(0), + control(0), + deviceControl(0), + viewfinder(0), + capture(0), + state(QCamera::UnloadedState), + error(QCamera::NoError), + supportedLocks(QCamera::NoLock), + requestedLocks(QCamera::NoLock), + lockStatus(QCamera::Unlocked), + lockChangeReason(QCamera::UserRequest), + supressLockChangedSignal(false), + restartPending(false) + { + } + + void initControls(); + + QMediaServiceProvider *provider; + + QCameraControl *control; + QVideoDeviceControl *deviceControl; + QCameraLocksControl *locksControl; + + QCameraExposure *cameraExposure; + QCameraFocus *cameraFocus; + QCameraImageProcessing *imageProcessing; + + QObject *viewfinder; + QObject *capture; + + QCamera::State state; + + QCamera::Error error; + QString errorString; + + QCamera::LockTypes supportedLocks; + QCamera::LockTypes requestedLocks; + + QCamera::LockStatus lockStatus; + QCamera::LockChangeReason lockChangeReason; + bool supressLockChangedSignal; + + bool restartPending; + + QVideoSurfaceOutput surfaceViewfinder; + + void _q_error(int error, const QString &errorString); + void unsetError() { error = QCamera::NoError; errorString.clear(); } + + void setState(QCamera::State); + + void _q_updateLockStatus(QCamera::LockType, QCamera::LockStatus, QCamera::LockChangeReason); + void _q_updateState(QCamera::State newState); + void _q_preparePropertyChange(int changeType); + void _q_restartCamera(); + void updateLockStatus(); +}; + + +void QCameraPrivate::_q_error(int error, const QString &errorString) +{ + Q_Q(QCamera); + + this->error = QCamera::Error(error); + this->errorString = errorString; + + qWarning() << "Camera error:" << errorString; + + emit q->error(this->error); +} + +void QCameraPrivate::setState(QCamera::State newState) +{ + Q_Q(QCamera); + + unsetError(); + + if (!control) { + _q_error(QCamera::ServiceMissingError, q_ptr->tr("The camera service is missing")); + return; + } + + if (state == newState) + return; + + restartPending = false; + state = newState; + control->setState(state); + emit q->stateChanged(state); +} + +void QCameraPrivate::_q_updateState(QCamera::State newState) +{ + Q_Q(QCamera); + + //omit changins state to Loaded when the camera is temporarily + //stopped to apply shanges + if (restartPending) + return; + + if (newState != state) { + qDebug() << "Camera state changed:" << newState; + state = newState; + emit q->stateChanged(state); + } +} + +void QCameraPrivate::_q_preparePropertyChange(int changeType) +{ + if (!control) + return; + + QCamera::Status status = control->status(); + + //all the changes are allowed until the camera is starting + if (control->state() != QCamera::ActiveState) + return; + + if (control->canChangeProperty(QCameraControl::PropertyChangeType(changeType), status)) + return; + + restartPending = true; + control->setState(QCamera::LoadedState); + QMetaObject::invokeMethod(q_ptr, "_q_restartCamera", Qt::QueuedConnection); +} + +void QCameraPrivate::_q_restartCamera() +{ + if (restartPending) { + restartPending = false; + control->setState(QCamera::ActiveState); + } +} + +void QCameraPrivate::initControls() +{ + Q_Q(QCamera); + + supportedLocks = 0; + + if (service) { + control = qobject_cast(service->requestControl(QCameraControl_iid)); + locksControl = qobject_cast(service->requestControl(QCameraLocksControl_iid)); + deviceControl = qobject_cast(service->requestControl(QVideoDeviceControl_iid)); + + if (control) { + q->connect(control, SIGNAL(stateChanged(QCamera::State)), q, SLOT(_q_updateState(QCamera::State))); + q->connect(control, SIGNAL(statusChanged(QCamera::Status)), q, SIGNAL(statusChanged(QCamera::Status))); + q->connect(control, SIGNAL(captureModeChanged(QCamera::CaptureMode)), + q, SIGNAL(captureModeChanged(QCamera::CaptureMode))); + q->connect(control, SIGNAL(error(int,QString)), q, SLOT(_q_error(int,QString))); + + } + + if (locksControl) { + q->connect(locksControl, SIGNAL(lockStatusChanged(QCamera::LockType,QCamera::LockStatus,QCamera::LockChangeReason)), + q, SLOT(_q_updateLockStatus(QCamera::LockType,QCamera::LockStatus,QCamera::LockChangeReason))); + supportedLocks = locksControl->supportedLocks(); + } + + error = QCamera::NoError; + } else { + control = 0; + locksControl = 0; + deviceControl = 0; + + error = QCamera::ServiceMissingError; + errorString = QCamera::tr("The camera service is missing"); + } +} + +void QCameraPrivate::updateLockStatus() +{ + Q_Q(QCamera); + + QCamera::LockStatus oldStatus = lockStatus; + + QMap lockStatusPriority; + lockStatusPriority.insert(QCamera::Locked, 1); + lockStatusPriority.insert(QCamera::Searching, 2); + lockStatusPriority.insert(QCamera::Unlocked, 3); + + lockStatus = requestedLocks ? QCamera::Locked : QCamera::Unlocked; + int priority = 0; + + QList lockStatuses; + + if (requestedLocks & QCamera::LockFocus) + lockStatuses << q->lockStatus(QCamera::LockFocus); + + if (requestedLocks & QCamera::LockExposure) + lockStatuses << q->lockStatus(QCamera::LockExposure); + + if (requestedLocks & QCamera::LockWhiteBalance) + lockStatuses << q->lockStatus(QCamera::LockWhiteBalance); + + + foreach (QCamera::LockStatus currentStatus, lockStatuses) { + int currentPriority = lockStatusPriority.value(currentStatus, -1); + if (currentPriority > priority) { + priority = currentPriority; + lockStatus = currentStatus; + } + } + + if (!supressLockChangedSignal && oldStatus != lockStatus) { + emit q->lockStatusChanged(lockStatus, lockChangeReason); + + if (lockStatus == QCamera::Locked) + emit q->locked(); + else if (lockStatus == QCamera::Unlocked && lockChangeReason == QCamera::LockFailed) + emit q->lockFailed(); + } +/* + qDebug() << "Requested locks:" << (requestedLocks & QCamera::LockExposure ? 'e' : ' ') + << (requestedLocks & QCamera::LockFocus ? 'f' : ' ') + << (requestedLocks & QCamera::LockWhiteBalance ? 'w' : ' '); + qDebug() << "Lock status: f:" << q->lockStatus(QCamera::LockFocus) + << " e:" << q->lockStatus(QCamera::LockExposure) + << " w:" << q->lockStatus(QCamera::LockWhiteBalance) + << " composite:" << lockStatus; +*/ +} + +void QCameraPrivate::_q_updateLockStatus(QCamera::LockType type, QCamera::LockStatus status, QCamera::LockChangeReason reason) +{ + Q_Q(QCamera); + lockChangeReason = reason; + updateLockStatus(); + emit q->lockStatusChanged(type, status, reason); +} + + +/*! + Construct a QCamera from service \a provider and \a parent. +*/ + +QCamera::QCamera(QObject *parent, QMediaServiceProvider *provider): + QMediaObject(*new QCameraPrivate, parent, provider->requestService(Q_MEDIASERVICE_CAMERA)) +{ + Q_D(QCamera); + d->provider = provider; + d->initControls(); + d->cameraExposure = new QCameraExposure(this); + d->cameraFocus = new QCameraFocus(this); + d->imageProcessing = new QCameraImageProcessing(this); +} + +/*! + Construct a QCamera from device name \a device and \a parent. +*/ + +QCamera::QCamera(const QByteArray& device, QObject *parent): + QMediaObject(*new QCameraPrivate, parent, + QMediaServiceProvider::defaultServiceProvider()->requestService(Q_MEDIASERVICE_CAMERA, QMediaServiceProviderHint(device))) +{ + Q_D(QCamera); + d->provider = QMediaServiceProvider::defaultServiceProvider(); + d->initControls(); + + if (d->service != 0) { + //pass device name to service + if (d->deviceControl) { + QString deviceName = QString::fromLatin1(device); + + for (int i=0; ideviceControl->deviceCount(); i++) { + if (d->deviceControl->deviceName(i) == deviceName) { + d->deviceControl->setSelectedDevice(i); + break; + } + } + } + } + + d->cameraExposure = new QCameraExposure(this); + d->cameraFocus = new QCameraFocus(this); + d->imageProcessing = new QCameraImageProcessing(this); +} + +/*! + Destroys the camera object. +*/ + +QCamera::~QCamera() +{ + Q_D(QCamera); + delete d->cameraExposure; + d->cameraExposure = 0; + delete d->cameraFocus; + d->cameraFocus = 0; + delete d->imageProcessing; + d->imageProcessing = 0; + + if (d->service) { + if (d->control) + d->service->releaseControl(d->control); + if (d->locksControl) + d->service->releaseControl(d->locksControl); + if (d->deviceControl) + d->service->releaseControl(d->deviceControl); + + d->provider->releaseService(d->service); + } +} + + +/*! + Return true if the camera service is ready to use. + \since 1.1 +*/ +bool QCamera::isAvailable() const +{ + return availabilityError() == QtMultimedia::NoError; +} + +/*! + Returns the error state of the camera service. + \since 1.1 +*/ + +QtMultimedia::AvailabilityError QCamera::availabilityError() const +{ + Q_D(const QCamera); + if (d->control == NULL) + return QtMultimedia::ServiceMissingError; + + if (d->deviceControl && d->deviceControl->deviceCount() == 0) + return QtMultimedia::ResourceError; + + if (d->error != QCamera::NoError) + return QtMultimedia::ResourceError; + + return QtMultimedia::NoError; +} + + +/*! + Returns the camera exposure control object. + \since 1.1 +*/ +QCameraExposure *QCamera::exposure() const +{ + return d_func()->cameraExposure; +} + +/*! + Returns the camera focus control object. + \since 1.1 +*/ +QCameraFocus *QCamera::focus() const +{ + return d_func()->cameraFocus; +} + +/*! + Returns the camera image processing control object. + \since 1.1 +*/ +QCameraImageProcessing *QCamera::imageProcessing() const +{ + return d_func()->imageProcessing; +} + +/*! + Sets the QVideoWidget based camera \a viewfinder. + The previously set viewfinder is detached. + \since 1.1 +*/ + +// QVideoWidget is forward declared +void QCamera::setViewfinder(QVideoWidget *viewfinder) +{ + Q_D(QCamera); + d->_q_preparePropertyChange(QCameraControl::Viewfinder); + + if (d->viewfinder) + unbind(d->viewfinder); + + // We don't know (in this library) that QVideoWidget inherits QObject + QObject *viewFinderObject = reinterpret_cast(viewfinder); + + d->viewfinder = viewFinderObject && bind(viewFinderObject) ? viewFinderObject : 0; +} + +/*! + Sets the QGraphicsVideoItem based camera \a viewfinder. + The previously set viewfinder is detached. + \since 1.1 +*/ +// QGraphicsVideoItem is forward declared +void QCamera::setViewfinder(QGraphicsVideoItem *viewfinder) +{ + Q_D(QCamera); + d->_q_preparePropertyChange(QCameraControl::Viewfinder); + + if (d->viewfinder) + unbind(d->viewfinder); + + // We don't know (in this library) that QGraphicsVideoItem (multiply) inherits QObject + // but QObject inheritance depends on QObject coming first, so try this out. + QObject *viewFinderObject = reinterpret_cast(viewfinder); + + d->viewfinder = viewFinderObject && bind(viewFinderObject) ? viewFinderObject : 0; +} + +/*! + Sets a video \a surface as the viewfinder of a camera. + + If a viewfinder has already been set on the camera the new surface + will replace it. + \since 1.2 +*/ + +void QCamera::setViewfinder(QAbstractVideoSurface *surface) +{ + Q_D(QCamera); + + d->surfaceViewfinder.setVideoSurface(surface); + + if (d->viewfinder != &d->surfaceViewfinder) { + if (d->viewfinder) + unbind(d->viewfinder); + + d->viewfinder = bind(&d->surfaceViewfinder) ? &d->surfaceViewfinder : 0; + } +} + +/*! + Returns the error state of the object. + \since 1.1 +*/ + +QCamera::Error QCamera::error() const +{ + return d_func()->error; +} + +/*! + Returns a string describing a camera's error state. + \since 1.1 +*/ +QString QCamera::errorString() const +{ + return d_func()->errorString; +} + + +/*! + Returns true if the capture \a mode is suported. + \since 1.1 +*/ +bool QCamera::isCaptureModeSupported(QCamera::CaptureMode mode) const +{ + return d_func()->control ? d_func()->control->isCaptureModeSupported(mode) : false; +} + +/*! + \property QCamera::captureMode + + The type of media (video or still images), + the camera is configured to capture. + + It's allowed to change capture mode in any camera state, + but if the camera is currently active, + chaging capture mode is likely to lead to camera status + chaged to QCamera::LoadedStatus, QCamera::LoadingStatus, + and when the camera is ready to QCamera::ActiveStatus. + \since 1.1 +*/ + +QCamera::CaptureMode QCamera::captureMode() const +{ + return d_func()->control ? d_func()->control->captureMode() : QCamera::CaptureStillImage; +} + +void QCamera::setCaptureMode(QCamera::CaptureMode mode) +{ + Q_D(QCamera); + + if (mode != captureMode()) { + if (d->control) { + d->_q_preparePropertyChange(QCameraControl::CaptureMode); + d->control->setCaptureMode(mode); + } + } +} + + +/*! + Starts the camera. + + State is changed to QCamera::ActiveState if camera is started + successfully, otherwise error() signal is emitted. + + While the camera state is changed to QCamera::ActiveState, + starting the camera service can be asynchronous with the actual + status reported with QCamera::status property. + \since 1.1 +*/ +void QCamera::start() +{ + Q_D(QCamera); + d->setState(QCamera::ActiveState); +} + +/*! + Stops the camera. + The camera state is changed from QCamera::ActiveState to QCamera::LoadedState. + \since 1.1 +*/ +void QCamera::stop() +{ + Q_D(QCamera); + d->setState(QCamera::LoadedState); +} + +/*! + Open the camera device. + The camera state is changed to QCamera::LoadedStatus. + + It's not necessary to explcitly load the camera, + unless unless the application have to read the supported camera + settings and change the default depending on the camera capabilities. + + In all the other cases it's possible to start the camera directly + from unloaded state. + \since 1.1 +*/ +void QCamera::load() +{ + Q_D(QCamera); + d->setState(QCamera::LoadedState); +} + +/*! + Close the camera device and deallocate the related resources. + The camera state is changed to QCamera::UnloadedStatus. + \since 1.1 +*/ +void QCamera::unload() +{ + Q_D(QCamera); + d->setState(QCamera::UnloadedState); +} + + +/*! + Returns a list of camera device's available from the default service provider. + \since 1.1 +*/ + +QList QCamera::availableDevices() +{ + return QMediaServiceProvider::defaultServiceProvider()->devices(QByteArray(Q_MEDIASERVICE_CAMERA)); +} + +/*! + Returns the description of the \a device. + \since 1.1 +*/ + +QString QCamera::deviceDescription(const QByteArray &device) +{ + return QMediaServiceProvider::defaultServiceProvider()->deviceDescription(QByteArray(Q_MEDIASERVICE_CAMERA), device); +} + +QCamera::State QCamera::state() const +{ + return d_func()->state; +} + +QCamera::Status QCamera::status() const +{ + if(d_func()->control) + return (QCamera::Status)d_func()->control->status(); + + return QCamera::UnavailableStatus; +} + + +/*! + Returns the lock types, camera supports. + \since 1.1 +*/ +QCamera::LockTypes QCamera::supportedLocks() const +{ + return d_func()->supportedLocks; +} + +/*! + Returns the requested lock types. + \since 1.1 +*/ +QCamera::LockTypes QCamera::requestedLocks() const +{ + return d_func()->requestedLocks; +} + +/*! + Returns the status of requested camera settings locks. + \since 1.1 +*/ +QCamera::LockStatus QCamera::lockStatus() const +{ + return d_func()->lockStatus; +} + +/*! + Returns the status of camera settings \a lock. + \since 1.1 +*/ +QCamera::LockStatus QCamera::lockStatus(QCamera::LockType lockType) const +{ + const QCameraPrivate *d = d_func(); + + if (!(lockType & d->supportedLocks)) + return lockType & d->requestedLocks ? QCamera::Locked : QCamera::Unlocked; + + if (!(lockType & d->requestedLocks)) + return QCamera::Unlocked; + + if (d->locksControl) + return d->locksControl->lockStatus(lockType); + + return QCamera::Unlocked; +} + +/*! + \fn void QCamera::searchAndLock(QCamera::LockTypes locks) + + Locks the camera settings with the requested \a locks, including focusing in the single autofocus mode, + exposure and white balance if the exposure and white balance modes are not manual. + + The camera settings are usually locked before taking one or multiple still images, + in responce to the shutter button being half pressed. + + The QCamera::locked() signal is emitted when camera settings are successfully locked, + otherwise QCamera::lockFailed() is emitted. + + QCamera also emits lockStatusChanged(QCamera::LockType, QCamera::LockStatus) + on individual lock status changes and lockStatusChanged(QCamera::LockStatus) signal on composite status changes. + + Locking serves two roles: it initializes calculation of automatic parameter + (focusing, calculating the correct exposure and white balance) and allows + to keep some or all of those parameters during number of shots. + + If the camera doesn't support keeping one of parameters between shots, the related + lock state changes to QCamera::Unlocked. + + It's also acceptable to relock already locked settings, + depending on the lock parameter this initiates new focusing, exposure or white balance calculation. + \since 1.1 + */ +void QCamera::searchAndLock(QCamera::LockTypes locks) +{ + Q_D(QCamera); + + QCamera::LockStatus oldStatus = d->lockStatus; + d->supressLockChangedSignal = true; + + d->requestedLocks |= locks; + + locks &= d->supportedLocks; + + if (d->locksControl) + d->locksControl->searchAndLock(locks); + + d->supressLockChangedSignal = false; + + d->lockStatus = oldStatus; + d->updateLockStatus(); +} + +/*! + Lock all the supported camera settings. + \since 1.1 + */ +void QCamera::searchAndLock() +{ + searchAndLock(LockExposure | LockWhiteBalance | LockFocus); +} + +/*! + Unlocks the camera settings specified with \a locks or cancel the current locking if one is active. + \since 1.1 + */ +void QCamera::unlock(QCamera::LockTypes locks) +{ + Q_D(QCamera); + + QCamera::LockStatus oldStatus = d->lockStatus; + d->supressLockChangedSignal = true; + + d->requestedLocks &= ~locks; + + locks &= d->supportedLocks; + + if (d->locksControl) + d->locksControl->unlock(locks); + + d->supressLockChangedSignal = false; + + d->lockStatus = oldStatus; + d->updateLockStatus(); +} + +/*! + Unlock all the requested camera locks. + \since 1.1 + */ +void QCamera::unlock() +{ + unlock(d_func()->requestedLocks); +} + + +/*! + \enum QCamera::State + \value UnloadedState + The initial camera state, with camera not loaded, + the camera capabilities except of supported capture modes + are unknown. + + While the supported settings are unknown in this state, + it's allowed to set the camera capture settings like codec, + resolution, or frame rate. + + \value LoadedState + The camera is loaded and ready to be configured. + + In the Idle state it's allowed to query camera capabilities, + set capture resolution, codecs, etc. + + The viewfinder is not active in the loaded state. + + \value ActiveState + In the active state as soon as camera is started + the viewfinder displays video frames and the + camera is ready for capture. +*/ + + +/*! + \property QCamera::state + \brief The current state of the camera object. + \since 1.1 +*/ + +/*! + \enum QCamera::Status + \value ActiveStatus + The camera has been started and can produce data. + The viewfinder displays video frames in active state. + + Depending on backend, changing some camera settings like + capture mode, codecs or resolution in ActiveState may lead + to changing the camera status to LoadedStatus and StartingStatus while + the settings are applied and back to ActiveStatus when the camera is ready. + + \value StartingStatus + The camera is starting in result of state transition to QCamera::ActiveState. + The camera service is not ready to capture yet. + + \value StandbyStatus + The camera is in the power saving standby mode. + The camera may come to the standby mode after some time of inactivity + in the QCamera::LoadedState state. + + \value LoadedStatus + The camera is loaded and ready to be configured. + This status indicates the camera device is opened and + it's possible to query for supported image and video capture settings, + like resolution, framerate and codecs. + + \value LoadingStatus + The camera device loading in result of state transition from + QCamera::UnloadedState to QCamera::LoadedState or QCamera::ActiveState. + + \value UnloadedStatus + The initial camera status, with camera not loaded. + The camera capabilities including supported capture settings may be unknown. + + \value UnavailableStatus + The camera or camera backend is not available. +*/ + + +/*! + \property QCamera::status + \brief The current status of the camera object. + \since 1.1 +*/ + + +/*! + \enum QCamera::CaptureMode + \value CaptureStillImage Camera is configured for still frames capture. + \value CaptureVideo Camera is configured for video capture. + \since 1.1 +*/ + +/*! + \enum QCamera::LockType + + \value NoLock + \value LockExposure + Lock camera exposure. + \value LockWhiteBalance + Lock the white balance. + \value LockFocus + Lock camera focus. +*/ + + +/*! + \property QCamera::lockStatus + \brief The overall status for all the requested camera locks. + \since 1.1 +*/ + +/*! + \fn void QCamera::locked() + + Signals all the requested camera settings are locked. + \since 1.1 +*/ + +/*! + \fn void QCamera::lockFailed() + + Signals locking of at least one requested camera settings failed. + \since 1.1 +*/ + +/*! + \fn QCamera::lockStatusChanged(QCamera::LockStatus status, QCamera::LockChangeReason reason) + + Signals the overall \a status for all the requested camera locks was changed with specified \a reason. + \since 1.1 +*/ + +/*! + \fn QCamera::lockStatusChanged(QCamera::LockType lock, QCamera::LockStatus status, QCamera::LockChangeReason reason) + Signals the \a lock \a status was changed with specified \a reason. + \since 1.1 +*/ + +/*! + \enum QCamera::LockStatus + \value Unlocked + The application is not interested in camera settings value. + The camera may keep this parameter without changes, this is common with camera focus, + or adjust exposure and white balance constantly to keep the viewfinder image nice. + + \value Searching + The application has requested the camera focus, exposure or white balance lock with + QCamera::searchAndLock(). This state indicates the camera is focusing or calculating exposure and white balance. + + \value Locked + The camera focus, exposure or white balance is locked. + The camera is ready to capture, application may check the exposure parameters. + + The locked state usually means the requested parameter stays the same, + except of the cases when the parameter is requested to be constantly updated. + For example in continuous focusing mode, the focus is considered locked as long + and the object is in focus, even while the actual focusing distance may be constantly changing. +*/ + +/*! + \enum QCamera::LockChangeReason + + \value UserRequest + The lock status changed in result of user request, usually to unlock camera settings. + \value LockAcquired + The lock status successfuly changed to QCamera::Locked. + \value LockFailed + The camera failed to acquire the requested lock in result of + autofocus failure, exposure out of supported range, etc. + \value LockLost + The camera is not able to maintain the requested lock any more. + Lock status is changed to QCamera::Unlocked. + \value LockTemporaryLost + The lock is lost, but the camera is working hard to reacquire it. + This value may be used in continuous focusing mode, + when the camera loses the focus, the focus lock state is changed to Qcamera::Searching + with LockTemporaryLost reason. +*/ + +/*! + \enum QCamera::Error + + \value NoError No errors have occurred. + \value CameraError An error has occurred. + \value InvalidRequestError System resource doesn't support requested functionality. + \value ServiceMissingError No camera service available. + \value NotSupportedFeatureError The feature is not supported. +*/ + +/*! + \fn void QCamera::error(QCamera::Error value) + + Signal emitted when error state changes to \a value. + \since 1.1 +*/ + +/*! + \fn void QCamera::captureModeChanged(QCamera::CaptureMode mode) + + Signals the capture \a mode has changed. + \since 1.1 +*/ + +/*! + \fn QCamera::stateChanged(QCamera::State state) + + Signals the camera \a state has changed. + + Usually the state changes is caused by calling + load(), unload(), start() and stop(), + but the state can also be changed change as a result of camera error. + \since 1.1 +*/ + +/*! + \fn QCamera::statusChanged(QCamera::Status status) + + Signals the camera \a status has changed. + + \since 1.1 +*/ + + +#include "moc_qcamera.cpp" diff --git a/src/multimedia/qcamera.h b/src/multimedia/qcamera.h new file mode 100644 index 000000000..da009e161 --- /dev/null +++ b/src/multimedia/qcamera.h @@ -0,0 +1,238 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QCAMERA_H +#define QCAMERA_H + +#include +#include +#include +#include +#include + +#include +#include +#include + +#include +#include +#include + +#include +#include + +QT_BEGIN_HEADER + +QT_BEGIN_NAMESPACE + +QT_MODULE(Multimedia) + + +class QAbstractVideoSurface; +class QVideoWidget; +class QGraphicsVideoItem; + +class QCameraPrivate; +class Q_MULTIMEDIA_EXPORT QCamera : public QMediaObject +{ + Q_OBJECT + Q_PROPERTY(QCamera::State state READ state NOTIFY stateChanged) + Q_PROPERTY(QCamera::Status status READ status NOTIFY statusChanged) + Q_PROPERTY(QCamera::CaptureMode captureMode READ captureMode WRITE setCaptureMode NOTIFY captureModeChanged) + Q_PROPERTY(QCamera::LockStatus lockStatus READ lockStatus NOTIFY lockStatusChanged) + + Q_ENUMS(Status) + Q_ENUMS(State) + Q_ENUMS(CaptureMode) + Q_ENUMS(Error) + Q_ENUMS(LockStatus) + Q_ENUMS(LockChangeReason) + Q_ENUMS(LockType) +public: + enum Status { + UnavailableStatus, + UnloadedStatus, + LoadingStatus, + LoadedStatus, + StandbyStatus, + StartingStatus, + ActiveStatus + }; + + enum State { + UnloadedState, + LoadedState, + ActiveState + }; + + enum CaptureMode + { + CaptureStillImage, + CaptureVideo + }; + + enum Error + { + NoError, + CameraError, + InvalidRequestError, + ServiceMissingError, + NotSupportedFeatureError + }; + + enum LockStatus + { + Unlocked, + Searching, + Locked + }; + + enum LockChangeReason { + UserRequest, + LockAcquired, + LockFailed, + LockLost, + LockTemporaryLost + }; + + enum LockType + { + NoLock = 0, + LockExposure = 0x01, + LockWhiteBalance = 0x02, + LockFocus = 0x04 + }; + Q_DECLARE_FLAGS(LockTypes, LockType) + + QCamera(QObject *parent = 0, QMediaServiceProvider *provider = QMediaServiceProvider::defaultServiceProvider()); + QCamera(const QByteArray& device, QObject *parent = 0); + ~QCamera(); + + static QList availableDevices(); + static QString deviceDescription(const QByteArray &device); + + bool isAvailable() const; + QtMultimedia::AvailabilityError availabilityError() const; + + State state() const; + Status status() const; + + CaptureMode captureMode() const; + bool isCaptureModeSupported(CaptureMode mode) const; + + QCameraExposure *exposure() const; + QCameraFocus *focus() const; + QCameraImageProcessing *imageProcessing() const; + + void setViewfinder(QVideoWidget *viewfinder); + void setViewfinder(QGraphicsVideoItem *viewfinder); + void setViewfinder(QAbstractVideoSurface *surface); + + Error error() const; + QString errorString() const; + + QCamera::LockTypes supportedLocks() const; + QCamera::LockTypes requestedLocks() const; + + QCamera::LockStatus lockStatus() const; + QCamera::LockStatus lockStatus(QCamera::LockType lock) const; + +public Q_SLOTS: + void setCaptureMode(QCamera::CaptureMode mode); + + void load(); + void unload(); + + void start(); + void stop(); + + void searchAndLock(); + void unlock(); + + void searchAndLock(QCamera::LockTypes locks); + void unlock(QCamera::LockTypes locks); + +Q_SIGNALS: + void stateChanged(QCamera::State); + void captureModeChanged(QCamera::CaptureMode); + void statusChanged(QCamera::Status); + + void locked(); + void lockFailed(); + + void lockStatusChanged(QCamera::LockStatus, QCamera::LockChangeReason); + void lockStatusChanged(QCamera::LockType, QCamera::LockStatus, QCamera::LockChangeReason); + + void error(QCamera::Error); + +private: + Q_DISABLE_COPY(QCamera) + Q_DECLARE_PRIVATE(QCamera) + Q_PRIVATE_SLOT(d_func(), void _q_preparePropertyChange(int)) + Q_PRIVATE_SLOT(d_func(), void _q_restartCamera()) + Q_PRIVATE_SLOT(d_func(), void _q_error(int, const QString &)) + Q_PRIVATE_SLOT(d_func(), void _q_updateLockStatus(QCamera::LockType, QCamera::LockStatus, QCamera::LockChangeReason)) + Q_PRIVATE_SLOT(d_func(), void _q_updateState(QCamera::State)) +}; + +Q_DECLARE_OPERATORS_FOR_FLAGS(QCamera::LockTypes) + +QT_END_NAMESPACE + +Q_DECLARE_METATYPE(QCamera::State) +Q_DECLARE_METATYPE(QCamera::Status) +Q_DECLARE_METATYPE(QCamera::Error) +Q_DECLARE_METATYPE(QCamera::CaptureMode) +Q_DECLARE_METATYPE(QCamera::LockType) +Q_DECLARE_METATYPE(QCamera::LockStatus) +Q_DECLARE_METATYPE(QCamera::LockChangeReason) + +Q_MEDIA_ENUM_DEBUG(QCamera, State) +Q_MEDIA_ENUM_DEBUG(QCamera, Status) +Q_MEDIA_ENUM_DEBUG(QCamera, Error) +Q_MEDIA_ENUM_DEBUG(QCamera, CaptureMode) +Q_MEDIA_ENUM_DEBUG(QCamera, LockType) +Q_MEDIA_ENUM_DEBUG(QCamera, LockStatus) +Q_MEDIA_ENUM_DEBUG(QCamera, LockChangeReason) + +QT_END_HEADER + +#endif // QCAMERA_H diff --git a/src/multimedia/qcameracapturebufferformatcontrol.cpp b/src/multimedia/qcameracapturebufferformatcontrol.cpp new file mode 100644 index 000000000..536c8b329 --- /dev/null +++ b/src/multimedia/qcameracapturebufferformatcontrol.cpp @@ -0,0 +1,117 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include + +QT_BEGIN_NAMESPACE + +/*! + \class QCameraCaptureBufferFormatControl + + \brief The QCameraCaptureBufferFormatControl class provides a control for setting the capture buffer format. + + The format is of type QVideoFrame::PixelFormat. + + \inmodule QtMultimedia + \ingroup multimedia-serv + + The interface name of QCameraCaptureBufferFormatControl is \c com.nokia.Qt.QCameraCaptureBufferFormatControl/1.0 as + defined in QCameraCaptureBufferFormatControl_iid. + + \sa QMediaService::requestControl() +*/ + +/*! + \macro QCameraCaptureBufferFormatControl_iid + + \c com.nokia.Qt.QCameraCaptureBufferFormatControl/1.0 + + Defines the interface name of the QCameraCaptureBufferFormatControl class. + + \relates QCameraCaptureBufferFormatControl +*/ + +/*! + Constructs a new image buffer capture format control object with the given \a parent +*/ +QCameraCaptureBufferFormatControl::QCameraCaptureBufferFormatControl(QObject *parent) + :QMediaControl(parent) +{ +} + +/*! + Destroys an image buffer capture format control. +*/ +QCameraCaptureBufferFormatControl::~QCameraCaptureBufferFormatControl() +{ +} + +/*! + \fn QCameraCaptureBufferFormatControl::supportedBufferFormats() const + + Returns the list of the supported buffer capture formats. + \since 1.2 +*/ + +/*! + \fn QCameraCaptureBufferFormatControl::bufferFormat() const + + Returns the current buffer capture format. + \since 1.2 +*/ + +/*! + \fn QCameraCaptureBufferFormatControl::setBufferFormat(QVideoFrame::PixelFormat format) + + Sets the buffer capture \a format. + \since 1.2 +*/ + +/*! + \fn QCameraCaptureBufferFormatControl::bufferFormatChanged(QVideoFrame::PixelFormat format) + + Signals the buffer image capture format changed to \a format. + \since 1.2 +*/ + +#include "moc_qcameracapturebufferformatcontrol.cpp" +QT_END_NAMESPACE + diff --git a/src/multimedia/qcameracapturebufferformatcontrol.h b/src/multimedia/qcameracapturebufferformatcontrol.h new file mode 100644 index 000000000..81079a77d --- /dev/null +++ b/src/multimedia/qcameracapturebufferformatcontrol.h @@ -0,0 +1,81 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QCAMERACAPTUREBUFFERFORMATCONTROL_H +#define QCAMERACAPTUREBUFFERFORMATCONTROL_H + +#include +#include + +QT_BEGIN_HEADER + +QT_BEGIN_NAMESPACE + +QT_MODULE(Multimedia) + + +class Q_MULTIMEDIA_EXPORT QCameraCaptureBufferFormatControl : public QMediaControl +{ + Q_OBJECT +public: + ~QCameraCaptureBufferFormatControl(); + + virtual QList supportedBufferFormats() const = 0; + virtual QVideoFrame::PixelFormat bufferFormat() const = 0; + virtual void setBufferFormat(QVideoFrame::PixelFormat format) = 0; + +Q_SIGNALS: + void bufferFormatChanged(QVideoFrame::PixelFormat); + +protected: + QCameraCaptureBufferFormatControl(QObject* parent = 0); +}; + +#define QCameraCaptureBufferFormatControl_iid "com.nokia.Qt.QCameraCaptureBufferFormatControl/1.0" +Q_MEDIA_DECLARE_CONTROL(QCameraCaptureBufferFormatControl, QCameraCaptureBufferFormatControl_iid) + +QT_END_NAMESPACE + +QT_END_HEADER + + +#endif + diff --git a/src/multimedia/qcameracapturedestinationcontrol.cpp b/src/multimedia/qcameracapturedestinationcontrol.cpp new file mode 100644 index 000000000..5072ae774 --- /dev/null +++ b/src/multimedia/qcameracapturedestinationcontrol.cpp @@ -0,0 +1,121 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include +#include + +QT_BEGIN_NAMESPACE + +/*! + \class QCameraCaptureDestinationControl + + \brief The QCameraCaptureDestinationControl class provides a control for setting capture destination. + + Depending on backend capabilities capture to file, buffer or both can be supported. + + \inmodule QtMultimedia + \ingroup multimedia-serv + + + + The interface name of QCameraCaptureDestinationControl is \c com.nokia.Qt.QCameraCaptureDestinationControl/1.0 as + defined in QCameraCaptureDestinationControl_iid. + + + \sa QMediaService::requestControl() +*/ + +/*! + \macro QCameraCaptureDestinationControl_iid + + \c com.nokia.Qt.QCameraCaptureDestinationControl/1.0 + + Defines the interface name of the QCameraCaptureDestinationControl class. + + \relates QCameraCaptureDestinationControl +*/ + +/*! + Constructs a new image capture destination control object with the given \a parent +*/ +QCameraCaptureDestinationControl::QCameraCaptureDestinationControl(QObject *parent) + :QMediaControl(parent) +{ +} + +/*! + Destroys an image capture destination control. +*/ +QCameraCaptureDestinationControl::~QCameraCaptureDestinationControl() +{ +} + +/*! + \fn QCameraCaptureDestinationControl::isCaptureDestinationSupported(QCameraImageCapture::CaptureDestinations destination) const + + Returns true if the capture \a destination is supported; and false if it is not. + \since 1.2 +*/ + +/*! + \fn QCameraCaptureDestinationControl::captureDestination() const + + Returns the current capture \a destination. The default destination is QCameraImageCapture::CaptureToFile. + \since 1.2 +*/ + +/*! + \fn QCameraCaptureDestinationControl::setCaptureDestination(QCameraImageCapture::CaptureDestinations destination) + + Sets the capture \a destination. + \since 1.2 +*/ + +/*! + \fn QCameraCaptureDestinationControl::captureDestinationChanged(QCameraImageCapture::CaptureDestinations destination) + + Signals the image capture \a destination changed. + \since 1.2 +*/ + +#include "moc_qcameracapturedestinationcontrol.cpp" +QT_END_NAMESPACE + diff --git a/src/multimedia/qcameracapturedestinationcontrol.h b/src/multimedia/qcameracapturedestinationcontrol.h new file mode 100644 index 000000000..cdd769a4d --- /dev/null +++ b/src/multimedia/qcameracapturedestinationcontrol.h @@ -0,0 +1,81 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QCAMERACAPTUREDESTINATIONCONTROL_H +#define QCAMERACAPTUREDESTINATIONCONTROL_H + +#include +#include + +QT_BEGIN_HEADER + +QT_BEGIN_NAMESPACE + +QT_MODULE(Multimedia) + + +class Q_MULTIMEDIA_EXPORT QCameraCaptureDestinationControl : public QMediaControl +{ + Q_OBJECT +public: + ~QCameraCaptureDestinationControl(); + + virtual bool isCaptureDestinationSupported(QCameraImageCapture::CaptureDestinations destination) const = 0; + virtual QCameraImageCapture::CaptureDestinations captureDestination() const = 0; + virtual void setCaptureDestination(QCameraImageCapture::CaptureDestinations destination) = 0; + +Q_SIGNALS: + void captureDestinationChanged(QCameraImageCapture::CaptureDestinations); + +protected: + QCameraCaptureDestinationControl(QObject* parent = 0); +}; + +#define QCameraCaptureDestinationControl_iid "com.nokia.Qt.QCameraCaptureDestinationControl/1.0" +Q_MEDIA_DECLARE_CONTROL(QCameraCaptureDestinationControl, QCameraCaptureDestinationControl_iid) + +QT_END_NAMESPACE + +QT_END_HEADER + + +#endif + diff --git a/src/multimedia/qcameracontrol.cpp b/src/multimedia/qcameracontrol.cpp new file mode 100644 index 000000000..df5c44cc1 --- /dev/null +++ b/src/multimedia/qcameracontrol.cpp @@ -0,0 +1,215 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include +#include "qmediacontrol_p.h" + +QT_BEGIN_NAMESPACE + +/*! + \class QCameraControl + + + + \brief The QCameraControl class is an abstract base class for + classes that control still cameras or video cameras. + + \inmodule QtMultimedia + \ingroup multimedia-serv + \since 1.1 + + This service is provided by a QMediaService object via + QMediaService::control(). It is used by QCamera. + + The interface name of QCameraControl is \c com.nokia.Qt.QCameraControl/1.0 as + defined in QCameraControl_iid. + + + + \sa QMediaService::requestControl(), QCamera +*/ + +/*! + \macro QCameraControl_iid + + \c com.nokia.Qt.QCameraControl/1.0 + + Defines the interface name of the QCameraControl class. + + \relates QCameraControl +*/ + +/*! + Constructs a camera control object with \a parent. +*/ + +QCameraControl::QCameraControl(QObject *parent): + QMediaControl(*new QMediaControlPrivate, parent) +{ +} + +/*! + Destruct the camera control object. +*/ + +QCameraControl::~QCameraControl() +{ +} + +/*! + \fn QCameraControl::state() const + + Returns the state of the camera service. + + \since 1.1 + \sa QCamera::state +*/ + +/*! + \fn QCameraControl::setState(QCamera::State state) + + Sets the camera \a state. + + State changes are synchronous and indicate user intention, + while camera status is used as a feedback mechanism to inform application about backend status. + Status changes are reported asynchronously with QCameraControl::statusChanged() signal. + + \since 1.1 + \sa QCamera::State +*/ + +/*! + \fn void QCameraControl::stateChanged(QCamera::State state) + + Signal emitted when the camera \a state changes. + + In most cases the state chage is caused by QCameraControl::setState(), + but if critical error has occurred the state changes to QCamera::UnloadedState. + \since 1.1 +*/ + +/*! + \fn QCameraControl::status() const + + Returns the status of the camera service. + + \since 1.1 + \sa QCamera::state +*/ + +/*! + \fn void QCameraControl::statusChanged(QCamera::Status status) + + Signal emitted when the camera \a status changes. + \since 1.1 +*/ + + +/*! + \fn void QCameraControl::error(int error, const QString &errorString) + + Signal emitted when an error occurs with error code \a error and + a description of the error \a errorString. + \since 1.1 +*/ + +/*! + \fn Camera::CaptureMode QCameraControl::captureMode() const = 0 + + Returns the current capture mode. + \since 1.1 +*/ + +/*! + \fn void QCameraControl::setCaptureMode(QCamera::CaptureMode mode) = 0; + + Sets the current capture \a mode. + + The capture mode changes are synchronous and allowed in any camera state. + + If the capture mode is changed while camera is active, + it's recommended to change status to QCamera::LoadedStatus + and start activating the camera in the next event loop + with the status changed to QCamera::StartingStatus. + This allows the capture settings to be applied before camera is started. + Than change the status to QCamera::StartedStatus when the capture mode change is done. + \since 1.1 +*/ + +/*! + \fn bool QCameraControl::isCaptureModeSupported(QCamera::CaptureMode mode) const = 0; + + Returns true if the capture \a mode is suported. + \since 1.1 +*/ + +/*! + \fn QCameraControl::captureModeChanged(QCamera::CaptureMode mode) + + Signal emitted when the camera capture \a mode changes. + \since 1.1 + */ + +/*! + \fn bool QCameraControl::canChangeProperty(PropertyChangeType changeType, QCamera::Status status) const + + Returns true if backend can effectively apply changing camera properties of \a changeType type + while the camera state is QCamera::Active and camera status matches \a status parameter. + + If backend doesn't support applying this change in the active state, it will be stopped + before the settings are changed and restarted after. + Otherwise the backend should apply the change in the current state, + with the camera status indicating the progress, if necessary. + \since 1.1 +*/ + +/*! + \enum QCameraControl::PropertyChangeType + + \value CaptureMode Indicates the capture mode is changed. + \value ImageEncodingSettings Image encoder settings are changed, including resolution. + \value VideoEncodingSettings + Video encoder settings are changed, including audio, video and container settings. + \value Viewfinder Viewfinder is changed. +*/ + +#include "moc_qcameracontrol.cpp" +QT_END_NAMESPACE diff --git a/src/multimedia/qcameracontrol.h b/src/multimedia/qcameracontrol.h new file mode 100644 index 000000000..dfc2b3743 --- /dev/null +++ b/src/multimedia/qcameracontrol.h @@ -0,0 +1,101 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QCAMERACONTROL_H +#define QCAMERACONTROL_H + +#include +#include + +#include + +QT_BEGIN_HEADER + +QT_BEGIN_NAMESPACE + +QT_MODULE(Multimedia) + + +class Q_MULTIMEDIA_EXPORT QCameraControl : public QMediaControl +{ + Q_OBJECT + +public: + enum PropertyChangeType { + CaptureMode = 1, + ImageEncodingSettings = 2, + VideoEncodingSettings = 3, + Viewfinder = 4 + }; + + ~QCameraControl(); + + virtual QCamera::State state() const = 0; + virtual void setState(QCamera::State state) = 0; + + virtual QCamera::Status status() const = 0; + + virtual QCamera::CaptureMode captureMode() const = 0; + virtual void setCaptureMode(QCamera::CaptureMode) = 0; + virtual bool isCaptureModeSupported(QCamera::CaptureMode mode) const = 0; + + virtual bool canChangeProperty(PropertyChangeType changeType, QCamera::Status status) const = 0; + +Q_SIGNALS: + void stateChanged(QCamera::State); + void statusChanged(QCamera::Status); + void error(int error, const QString &errorString); + void captureModeChanged(QCamera::CaptureMode); + +protected: + QCameraControl(QObject* parent = 0); +}; + +#define QCameraControl_iid "com.nokia.Qt.QCameraControl/1.0" +Q_MEDIA_DECLARE_CONTROL(QCameraControl, QCameraControl_iid) + +QT_END_NAMESPACE + +QT_END_HEADER + + +#endif // QCAMERACONTROL_H + diff --git a/src/multimedia/qcameraexposure.cpp b/src/multimedia/qcameraexposure.cpp new file mode 100644 index 000000000..580b1cad9 --- /dev/null +++ b/src/multimedia/qcameraexposure.cpp @@ -0,0 +1,646 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include + +#include +#include + +#include +#include +#include +#include + +QT_BEGIN_NAMESPACE + +/*! + \class QCameraExposure + + + \brief The QCameraExposure class provides interface for exposure related camera settings. + + \inmodule QtMultimedia + \ingroup camera + \since 1.1 + +*/ + +//#define DEBUG_EXPOSURE_CHANGES 1 + +#ifdef DEBUG_EXPOSURE_CHANGES +#define ENUM_NAME(c,e,v) (c::staticMetaObject.enumerator(c::staticMetaObject.indexOfEnumerator(e)).valueToKey((v))) +#endif + +namespace +{ +class CameraExposureRegisterMetaTypes +{ +public: + CameraExposureRegisterMetaTypes() + { + qRegisterMetaType("QCameraExposure::ExposureMode"); + qRegisterMetaType("QCameraExposure::FlashModes"); + qRegisterMetaType("QCameraExposure::MeteringMode"); + } +} _registerCameraExposureMetaTypes; +} + + + +class QCameraExposurePrivate +{ + Q_DECLARE_NON_CONST_PUBLIC(QCameraExposure) +public: + void initControls(); + QCameraExposure *q_ptr; + + QCamera *camera; + QCameraExposureControl *exposureControl; + QCameraFlashControl *flashControl; + + void _q_exposureParameterChanged(int parameter); + void _q_exposureParameterRangeChanged(int parameter); +}; + +void QCameraExposurePrivate::initControls() +{ + Q_Q(QCameraExposure); + + QMediaService *service = camera->service(); + exposureControl = 0; + flashControl = 0; + if (service) { + exposureControl = qobject_cast(service->requestControl(QCameraExposureControl_iid)); + flashControl = qobject_cast(service->requestControl(QCameraFlashControl_iid)); + } + if (exposureControl) { + q->connect(exposureControl, SIGNAL(exposureParameterChanged(int)), + q, SLOT(_q_exposureParameterChanged(int))); + q->connect(exposureControl, SIGNAL(exposureParameterRangeChanged(int)), + q, SLOT(_q_exposureParameterRangeChanged(int))); + } + + if (flashControl) + q->connect(flashControl, SIGNAL(flashReady(bool)), q, SIGNAL(flashReady(bool))); +} + +void QCameraExposurePrivate::_q_exposureParameterChanged(int parameter) +{ + Q_Q(QCameraExposure); + +#if DEBUG_EXPOSURE_CHANGES + qDebug() << "Exposure parameter changed:" + << ENUM_NAME(QCameraExposureControl, "ExposureParameter", parameter) + << exposureControl->exposureParameter(QCameraExposureControl::ExposureParameter(parameter)); +#endif + + switch (parameter) { + case QCameraExposureControl::ISO: + emit q->isoSensitivityChanged(q->isoSensitivity()); + break; + case QCameraExposureControl::Aperture: + emit q->apertureChanged(q->aperture()); + break; + case QCameraExposureControl::ShutterSpeed: + emit q->shutterSpeedChanged(q->shutterSpeed()); + break; + case QCameraExposureControl::ExposureCompensation: + emit q->exposureCompensationChanged(q->exposureCompensation()); + break; + } +} + +void QCameraExposurePrivate::_q_exposureParameterRangeChanged(int parameter) +{ + Q_Q(QCameraExposure); + + switch (parameter) { + case QCameraExposureControl::Aperture: + emit q->apertureRangeChanged(); + break; + case QCameraExposureControl::ShutterSpeed: + emit q->shutterSpeedRangeChanged(); + break; + } +} + +/*! + Construct a QCameraExposure from service \a provider and \a parent. +*/ + +QCameraExposure::QCameraExposure(QCamera *parent): + QObject(parent), d_ptr(new QCameraExposurePrivate) +{ + Q_D(QCameraExposure); + d->camera = parent; + d->q_ptr = this; + d->initControls(); +} + + +/*! + Destroys the camera exposure object. +*/ + +QCameraExposure::~QCameraExposure() +{ + Q_D(QCameraExposure); + if (d->exposureControl) + d->camera->service()->releaseControl(d->exposureControl); +} + +/*! + Returns true if exposure settings are supported by this camera. + \since 1.1 +*/ +bool QCameraExposure::isAvailable() const +{ + return d_func()->exposureControl != 0; +} + + +/*! + \property QCameraExposure::flashMode + \brief The flash mode being used. + + Usually the single QCameraExposure::FlashMode flag is used, + but some non conflicting flags combination are also allowed, + like QCameraExposure::FlashManual | QCameraExposure::FlashSlowSyncRearCurtain. + + \since 1.1 + \sa QCameraExposure::isFlashModeSupported(), QCameraExposure::isFlashReady() +*/ + +QCameraExposure::FlashModes QCameraExposure::flashMode() const +{ + return d_func()->flashControl ? d_func()->flashControl->flashMode() : QCameraExposure::FlashOff; +} + +void QCameraExposure::setFlashMode(QCameraExposure::FlashModes mode) +{ + if (d_func()->flashControl) + d_func()->flashControl->setFlashMode(mode); +} + +/*! + Returns true if the flash \a mode is supported. + \since 1.1 +*/ + +bool QCameraExposure::isFlashModeSupported(QCameraExposure::FlashModes mode) const +{ + return d_func()->flashControl ? d_func()->flashControl->isFlashModeSupported(mode) : false; +} + +/*! + Returns true if flash is charged. +*/ + +bool QCameraExposure::isFlashReady() const +{ + return d_func()->flashControl ? d_func()->flashControl->isFlashReady() : false; +} + + +/*! + \property QCameraExposure::exposureMode + \brief The exposure mode being used. + + \since 1.1 + \sa QCameraExposure::isExposureModeSupported() +*/ + +QCameraExposure::ExposureMode QCameraExposure::exposureMode() const +{ + return d_func()->exposureControl ? d_func()->exposureControl->exposureMode() : QCameraExposure::ExposureAuto; +} + +void QCameraExposure::setExposureMode(QCameraExposure::ExposureMode mode) +{ + if (d_func()->exposureControl) + d_func()->exposureControl->setExposureMode(mode); +} + +/*! + Returns true if the exposure \a mode is supported. + \since 1.1 +*/ + +bool QCameraExposure::isExposureModeSupported(QCameraExposure::ExposureMode mode) const +{ + return d_func()->exposureControl ? + d_func()->exposureControl->isExposureModeSupported(mode) : false; +} + +/*! + \property QCameraExposure::exposureCompensation + \brief Exposure compensation in EV units. + + Exposure compensation property allows to adjust the automatically calculated exposure. + \since 1.1 +*/ + +qreal QCameraExposure::exposureCompensation() const +{ + if (d_func()->exposureControl) + return d_func()->exposureControl->exposureParameter(QCameraExposureControl::ExposureCompensation).toReal(); + else + return 0; +} + +void QCameraExposure::setExposureCompensation(qreal ev) +{ + if (d_func()->exposureControl) + d_func()->exposureControl->setExposureParameter(QCameraExposureControl::ExposureCompensation, QVariant(ev)); +} + +/*! + \property QCameraExposure::meteringMode + \brief The metering mode being used. + + \since 1.1 + \sa QCameraExposure::isMeteringModeSupported() +*/ + +QCameraExposure::MeteringMode QCameraExposure::meteringMode() const +{ + return d_func()->exposureControl ? d_func()->exposureControl->meteringMode() : QCameraExposure::MeteringMatrix; +} + +void QCameraExposure::setMeteringMode(QCameraExposure::MeteringMode mode) +{ + if (d_func()->exposureControl) + d_func()->exposureControl->setMeteringMode(mode); +} + +/*! + Returns true if the metering \a mode is supported. + \since 1.1 +*/ +bool QCameraExposure::isMeteringModeSupported(QCameraExposure::MeteringMode mode) const +{ + return d_func()->exposureControl ? d_func()->exposureControl->isMeteringModeSupported(mode) : false; +} + +int QCameraExposure::isoSensitivity() const +{ + if (d_func()->exposureControl) + return d_func()->exposureControl->exposureParameter(QCameraExposureControl::ISO).toInt(); + + return -1; +} + +/*! + Returns the list of ISO senitivities camera supports. + + If the camera supports arbitrary ISO sensitivities within the supported range, + *\a continuous is set to true, otherwise *\a continuous is set to false. + \since 1.1 +*/ +QList QCameraExposure::supportedIsoSensitivities(bool *continuous) const +{ + QList res; + QCameraExposureControl *control = d_func()->exposureControl; + + if (!control) + return res; + + foreach (const QVariant &value, + control->supportedParameterRange(QCameraExposureControl::ISO)) { + bool ok = false; + int intValue = value.toInt(&ok); + if (ok) + res.append(intValue); + else + qWarning() << "Incompatible ISO value type, int is expected"; + } + + if (continuous) + *continuous = control->exposureParameterFlags(QCameraExposureControl::ISO) & + QCameraExposureControl::ContinuousRange; + + return res; +} + +/*! + \fn QCameraExposure::setManualIsoSensitivity(int iso) + Sets the manual sensitivity to \a iso + \since 1.1 +*/ + +void QCameraExposure::setManualIsoSensitivity(int iso) +{ + if (d_func()->exposureControl) + d_func()->exposureControl->setExposureParameter(QCameraExposureControl::ISO, QVariant(iso)); +} + +/*! + \fn QCameraExposure::setAutoIsoSensitivity() + Turn on auto sensitivity + \since 1.1 +*/ + +void QCameraExposure::setAutoIsoSensitivity() +{ + if (d_func()->exposureControl) + d_func()->exposureControl->setExposureParameter(QCameraExposureControl::ISO, QVariant()); +} + +/*! + \property QCameraExposure::shutterSpeed + \brief Camera's shutter speed in seconds. + + \since 1.1 + \sa supportedShutterSpeeds(), setAutoShutterSpeed(), setManualShutterSpeed() +*/ + +/*! + \fn QCameraExposure::shutterSpeedChanged(qreal speed) + + Signals that a camera's shutter \a speed has changed. + \since 1.1 +*/ + +/*! + \property QCameraExposure::isoSensitivity + \brief The sensor ISO sensitivity. + + \sa supportedIsoSensitivities(), setAutoIsoSensitivity(), setManualIsoSensitivity() + \since 1.1 +*/ + +/*! + \property QCameraExposure::aperture + \brief Lens aperture is specified as an F number, the ratio of the focal length to effective aperture diameter. + + \since 1.1 + \sa supportedApertures(), setAutoAperture(), setManualAperture() +*/ + + +qreal QCameraExposure::aperture() const +{ + if (d_func()->exposureControl) + return d_func()->exposureControl->exposureParameter(QCameraExposureControl::Aperture).toReal(); + + return -1.0; +} + +/*! + Returns the list of aperture values camera supports. + The apertures list can change depending on the focal length, + in such a case the apertureRangeChanged() signal is emitted. + + If the camera supports arbitrary aperture values within the supported range, + *\a continuous is set to true, otherwise *\a continuous is set to false. + \since 1.1 +*/ +QList QCameraExposure::supportedApertures(bool * continuous) const +{ + QList res; + QCameraExposureControl *control = d_func()->exposureControl; + + if (!control) + return res; + + foreach (const QVariant &value, + control->supportedParameterRange(QCameraExposureControl::Aperture)) { + bool ok = false; + qreal realValue = value.toReal(&ok); + if (ok) + res.append(realValue); + else + qWarning() << "Incompatible aperture value type, qreal is expected"; + } + + if (continuous) + *continuous = control->exposureParameterFlags(QCameraExposureControl::Aperture) & + QCameraExposureControl::ContinuousRange; + + return res; +} + +/*! + \fn QCameraExposure::setManualAperture(qreal aperture) + Sets the manual camera \a aperture value. + \since 1.1 +*/ + +void QCameraExposure::setManualAperture(qreal aperture) +{ + if (d_func()->exposureControl) + d_func()->exposureControl->setExposureParameter(QCameraExposureControl::Aperture, QVariant(aperture)); +} + +/*! + \fn QCameraExposure::setAutoAperture() + Turn on auto aperture + \since 1.1 +*/ + +void QCameraExposure::setAutoAperture() +{ + if (d_func()->exposureControl) + d_func()->exposureControl->setExposureParameter(QCameraExposureControl::Aperture, QVariant()); +} + +/*! + Returns the current shutter speed in seconds. + \since 1.1 +*/ + +qreal QCameraExposure::shutterSpeed() const +{ + if (d_func()->exposureControl) + return d_func()->exposureControl->exposureParameter(QCameraExposureControl::ShutterSpeed).toReal(); + + return -1.0; +} + +/*! + Returns the list of shutter speed values in seconds camera supports. + + If the camera supports arbitrary shutter speed values within the supported range, + *\a continuous is set to true, otherwise *\a continuous is set to false. + \since 1.1 +*/ +QList QCameraExposure::supportedShutterSpeeds(bool *continuous) const +{ + QList res; + + QCameraExposureControl *control = d_func()->exposureControl; + if (!control) + return res; + + foreach (const QVariant &value, + control->supportedParameterRange(QCameraExposureControl::ShutterSpeed)) { + bool ok = false; + qreal realValue = value.toReal(&ok); + if (ok) + res.append(realValue); + else + qWarning() << "Incompatible shutter speed value type, qreal is expected"; + } + + if (continuous) + *continuous = control->exposureParameterFlags(QCameraExposureControl::ShutterSpeed) & + QCameraExposureControl::ContinuousRange; + + return res; +} + +/*! + Set the manual shutter speed to \a seconds + \since 1.1 +*/ + +void QCameraExposure::setManualShutterSpeed(qreal seconds) +{ + if (d_func()->exposureControl) + d_func()->exposureControl->setExposureParameter(QCameraExposureControl::ShutterSpeed, QVariant(seconds)); +} + +/*! + Turn on auto shutter speed + \since 1.1 +*/ + +void QCameraExposure::setAutoShutterSpeed() +{ + if (d_func()->exposureControl) + d_func()->exposureControl->setExposureParameter(QCameraExposureControl::ShutterSpeed, QVariant()); +} + + +/*! + \enum QCameraExposure::FlashMode + + \value FlashOff Flash is Off. + \value FlashOn Flash is On. + \value FlashAuto Automatic flash. + \value FlashRedEyeReduction Red eye reduction flash. + \value FlashFill Use flash to fillin shadows. + \value FlashTorch Constant light source, useful for focusing and video capture. + \value FlashSlowSyncFrontCurtain + Use the flash in conjunction with a slow shutter speed. + This mode allows better exposure of distant objects and/or motion blur effect. + \value FlashSlowSyncRearCurtain + The similar mode to FlashSlowSyncFrontCurtain but flash is fired at the end of exposure. + \value FlashManual Flash power is manualy set. +*/ + +/*! + \enum QCameraExposure::ExposureMode + + \value ExposureManual Manual mode. + \value ExposureAuto Automatic mode. + \value ExposureNight Night mode. + \value ExposureBacklight Backlight exposure mode. + \value ExposureSpotlight Spotlight exposure mode. + \value ExposureSports Spots exposure mode. + \value ExposureSnow Snow exposure mode. + \value ExposureBeach Beach exposure mode. + \value ExposureLargeAperture Use larger aperture with small depth of field. + \value ExposureSmallAperture Use smaller aperture. + \value ExposurePortrait Portrait exposure mode. + \value ExposureModeVendor The base value for device specific exposure modes. +*/ + +/*! + \enum QCameraExposure::MeteringMode + + \value MeteringAverage Center weighted average metering mode. + \value MeteringSpot Spot metering mode. + \value MeteringMatrix Matrix metering mode. +*/ + +/*! + \property QCameraExposure::flashReady + \brief Indicates if the flash is charged and ready to use. + \since 1.1 +*/ + +/*! + \fn void QCameraExposure::flashReady(bool ready) + + Signal the flash \a ready status has changed. + \since 1.1 +*/ + +/*! + \fn void QCameraExposure::apertureChanged(qreal value) + + Signal emitted when aperature changes to \a value. + \since 1.1 +*/ + +/*! + \fn void QCameraExposure::apertureRangeChanged() + + Signal emitted when aperature range has changed. + \since 1.1 +*/ + + +/*! + \fn void QCameraExposure::shutterSpeedRangeChanged() + + Signal emitted when the shutter speed range has changed. + \since 1.1 +*/ + + +/*! + \fn void QCameraExposure::isoSensitivityChanged(int value) + + Signal emitted when sensitivity changes to \a value. + \since 1.1 +*/ + +/*! + \fn void QCameraExposure::exposureCompensationChanged(qreal value) + + Signal emitted when the exposure compensation changes to \a value. + \since 1.1 +*/ + +#include "moc_qcameraexposure.cpp" +QT_END_NAMESPACE diff --git a/src/multimedia/qcameraexposure.h b/src/multimedia/qcameraexposure.h new file mode 100644 index 000000000..088e7c036 --- /dev/null +++ b/src/multimedia/qcameraexposure.h @@ -0,0 +1,185 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QCAMERAEXPOSURE_H +#define QCAMERAEXPOSURE_H + +#include +#include + +QT_BEGIN_HEADER + +QT_BEGIN_NAMESPACE + +QT_MODULE(Multimedia) + + +class QCamera; +class QCameraExposurePrivate; + +class Q_MULTIMEDIA_EXPORT QCameraExposure : public QObject +{ + Q_OBJECT + Q_PROPERTY(qreal aperture READ aperture NOTIFY apertureChanged) + Q_PROPERTY(qreal shutterSpeed READ shutterSpeed NOTIFY shutterSpeedChanged) + Q_PROPERTY(int isoSensitivity READ isoSensitivity NOTIFY isoSensitivityChanged) + Q_PROPERTY(qreal exposureCompensation READ exposureCompensation WRITE setExposureCompensation NOTIFY exposureCompensationChanged) + Q_PROPERTY(bool flashReady READ isFlashReady NOTIFY flashReady) + Q_PROPERTY(QCameraExposure::FlashModes flashMode READ flashMode WRITE setFlashMode) + Q_PROPERTY(QCameraExposure::ExposureMode exposureMode READ exposureMode WRITE setExposureMode) + Q_PROPERTY(QCameraExposure::MeteringMode meteringMode READ meteringMode WRITE setMeteringMode) + + Q_ENUMS(FlashMode) + Q_ENUMS(ExposureMode) + Q_ENUMS(MeteringMode) +public: + enum FlashMode { + FlashAuto = 0x1, + FlashOff = 0x2, + FlashOn = 0x4, + FlashRedEyeReduction = 0x8, + FlashFill = 0x10, + FlashTorch = 0x20, + FlashSlowSyncFrontCurtain = 0x40, + FlashSlowSyncRearCurtain = 0x80, + FlashManual = 0x100 + }; + Q_DECLARE_FLAGS(FlashModes, FlashMode) + + enum ExposureMode { + ExposureAuto = 0, + ExposureManual = 1, + ExposurePortrait = 2, + ExposureNight = 3, + ExposureBacklight = 4, + ExposureSpotlight = 5, + ExposureSports = 6, + ExposureSnow = 7, + ExposureBeach = 8, + ExposureLargeAperture = 9, + ExposureSmallAperture = 10, + ExposureModeVendor = 1000 + }; + + enum MeteringMode { + MeteringMatrix = 1, + MeteringAverage = 2, + MeteringSpot = 3 + }; + + bool isAvailable() const; + + FlashModes flashMode() const; + bool isFlashModeSupported(FlashModes mode) const; + bool isFlashReady() const; + + ExposureMode exposureMode() const; + bool isExposureModeSupported(ExposureMode mode) const; + + qreal exposureCompensation() const; + + MeteringMode meteringMode() const; + + bool isMeteringModeSupported(MeteringMode mode) const; + + int isoSensitivity() const; + QList supportedIsoSensitivities(bool *continuous = 0) const; + + qreal aperture() const; + QList supportedApertures(bool *continuous = 0) const; + + qreal shutterSpeed() const; + QList supportedShutterSpeeds(bool *continuous = 0) const; + +public Q_SLOTS: + void setFlashMode(FlashModes mode); + void setExposureMode(ExposureMode mode); + + void setExposureCompensation(qreal ev); + + void setMeteringMode(MeteringMode mode); + + void setManualIsoSensitivity(int iso); + void setAutoIsoSensitivity(); + + void setManualAperture(qreal aperture); + void setAutoAperture(); + + void setManualShutterSpeed(qreal seconds); + void setAutoShutterSpeed(); + +Q_SIGNALS: + void flashReady(bool); + + void apertureChanged(qreal); + void apertureRangeChanged(); + void shutterSpeedChanged(qreal); + void shutterSpeedRangeChanged(); + void isoSensitivityChanged(int); + void exposureCompensationChanged(qreal); + +private: + friend class QCamera; + explicit QCameraExposure(QCamera *parent = 0); + virtual ~QCameraExposure(); + + Q_DISABLE_COPY(QCameraExposure) + Q_DECLARE_PRIVATE(QCameraExposure) + Q_PRIVATE_SLOT(d_func(), void _q_exposureParameterChanged(int)) + Q_PRIVATE_SLOT(d_func(), void _q_exposureParameterRangeChanged(int)) + QCameraExposurePrivate *d_ptr; +}; + +Q_DECLARE_OPERATORS_FOR_FLAGS(QCameraExposure::FlashModes) + +QT_END_NAMESPACE + +Q_DECLARE_METATYPE(QCameraExposure::ExposureMode) +Q_DECLARE_METATYPE(QCameraExposure::FlashModes) +Q_DECLARE_METATYPE(QCameraExposure::MeteringMode) + +Q_MEDIA_ENUM_DEBUG(QCameraExposure, ExposureMode) +Q_MEDIA_ENUM_DEBUG(QCameraExposure, FlashMode) +Q_MEDIA_ENUM_DEBUG(QCameraExposure, MeteringMode) + +QT_END_HEADER + +#endif // QCAMERAEXPOSURE_H diff --git a/src/multimedia/qcameraexposurecontrol.cpp b/src/multimedia/qcameraexposurecontrol.cpp new file mode 100644 index 000000000..4a6f655f8 --- /dev/null +++ b/src/multimedia/qcameraexposurecontrol.cpp @@ -0,0 +1,252 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include +#include "qmediacontrol_p.h" + +QT_BEGIN_NAMESPACE + +/*! + \class QCameraExposureControl + + \brief The QCameraExposureControl class allows controlling camera exposure parameters. + + \inmodule QtMultimedia + \ingroup multimedia-serv + \since 1.1 + + You can adjust a number of parameters that will affect images and video taken with + the corresponding QCamera object. + + There are a number of different parameters that can be adjusted, including: + + \table + \row + \header + \ + + \endtable + + The interface name of QCameraExposureControl is \c com.nokia.Qt.QCameraExposureControl/1.0 as + defined in QCameraExposureControl_iid. + + \sa QCamera +*/ + +/*! + \macro QCameraExposureControl_iid + + \c com.nokia.Qt.QCameraExposureControl/1.0 + + Defines the interface name of the QCameraExposureControl class. + + \relates QCameraExposureControl +*/ + +/*! + Constructs a camera exposure control object with \a parent. +*/ +QCameraExposureControl::QCameraExposureControl(QObject *parent): + QMediaControl(*new QMediaControlPrivate, parent) +{ +} + +/*! + Destroys the camera control object. +*/ +QCameraExposureControl::~QCameraExposureControl() +{ +} + +/*! + \fn QCamera::ExposureMode QCameraExposureControl::exposureMode() const + + Returns the exposure mode. + \since 1.1 +*/ + + +/*! + \fn void QCameraExposureControl::setExposureMode(QCameraExposure::ExposureMode mode) + + Set the exposure mode to \a mode. + \since 1.1 +*/ + + +/*! + \fn bool QCameraExposureControl::isExposureModeSupported(QCameraExposure::ExposureMode mode) const + + Returns true if the exposure \a mode is supported. + \since 1.1 +*/ + + +/*! + \fn QCameraExposure::MeteringMode QCameraExposureControl::meteringMode() const + Returns the current metering mode. + \since 1.1 +*/ + +/*! + \fn void QCameraExposureControl::setMeteringMode(QCameraExposure::MeteringMode mode) + + Set the metering mode to \a mode. + \since 1.1 +*/ + + +/*! + \fn bool QCameraExposureControl::isMeteringModeSupported(QCameraExposure::MeteringMode mode) const + Returns true if the metering \a mode is supported. + \since 1.1 +*/ + +/*! + \enum QCameraExposureControl::ExposureParameter + \value InvalidParameter + Parameter is invalid. + \value ISO + Camera ISO sensitivity, specified as integer value. + \value Aperture + Lens aperture is specified as an qreal F number. + The supported apertures list can change depending on the focal length, + in such a case the exposureParameterRangeChanged() signal is emitted. + \value ShutterSpeed + Shutter speed in seconds, specified as qreal. + \value ExposureCompensation + Exposure compensation, specified as qreal EV value. + \value FlashPower + Manual flash power, specified as qreal value. + Accepted power range is [0..1.0], + with 0 value means no flash and 1.0 corresponds to full flash power. + + This value is only used in the \l{QCameraExposure::FlashManual}{manual flash mode}. + \value FlashCompensation + Flash compensation, specified as qreal EV value. + \value ExtendedExposureParameter + The base value for platform specific extended parameters. + For such parameters the sequential values starting from ExtendedExposureParameter shuld be used. +*/ + +/*! + \enum QCameraExposureControl::ParameterFlag + \value AutomaticValue + Use the automatic values for parameters. + \value ReadOnly + Parameters are read only. + \value ContinuousRange + Parameters are continuous in their range. +*/ + +/*! + \fn QCameraExposureControl::isParameterSupported(ExposureParameter parameter) const + + Returns true is exposure \a parameter is supported by backend. + \since 1.1 +*/ + +/*! + \fn QCameraExposureControl::exposureParameter(ExposureParameter parameter) const + + Returns the exposure \a parameter value, or invalid QVariant() if the value is unknown or not supported. + \since 1.1 +*/ + +/*! + \fn QCameraExposureControl::exposureParameterFlags(ExposureParameter parameter) const + + Returns the properties of exposure \a parameter. + \since 1.1 +*/ + + +/*! + \fn QCameraExposureControl::supportedParameterRange(ExposureParameter parameter) const + + Returns the list of supported \a parameter values; + \since 1.1 +*/ + +/*! + \fn bool QCameraExposureControl::setExposureParameter(ExposureParameter parameter, const QVariant& value) + + Set the exposure \a parameter to \a value. + If a null or invalid QVariant is passed, backend should choose the value automatically, + and if possible report the actual value to user with QCameraExposureControl::exposureParameter(). + + Returns true if parameter is supported and value is correct. + \since 1.1 +*/ + +/*! + \fn QCameraExposureControl::extendedParameterName(ExposureParameter parameter) + + Returns the extended exposure \a parameter name. + \since 1.1 +*/ + +/*! + \fn void QCameraExposureControl::flashReady(bool ready) + + Signal emitted when flash state changes, flash is charged \a ready. + \since 1.1 +*/ + +/*! + \fn void QCameraExposureControl::exposureParameterChanged(int parameter) + + Signal emitted when the exposure \a parameter has changed. + \since 1.1 +*/ + +/*! + + \fn void QCameraExposureControl::exposureParameterRangeChanged(int parameter) + + Signal emitted when the exposure \a parameter range has changed. + \since 1.1 +*/ + + +#include "moc_qcameraexposurecontrol.cpp" +QT_END_NAMESPACE + diff --git a/src/multimedia/qcameraexposurecontrol.h b/src/multimedia/qcameraexposurecontrol.h new file mode 100644 index 000000000..ff60784bf --- /dev/null +++ b/src/multimedia/qcameraexposurecontrol.h @@ -0,0 +1,124 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QCAMERAEXPOSURECONTROL_H +#define QCAMERAEXPOSURECONTROL_H + +#include +#include + +#include +#include +#include + +QT_BEGIN_HEADER + +QT_BEGIN_NAMESPACE + +QT_MODULE(Multimedia) + + +class Q_MULTIMEDIA_EXPORT QCameraExposureControl : public QMediaControl +{ + Q_OBJECT + Q_ENUMS(ExposureParameter) + +public: + ~QCameraExposureControl(); + + enum ExposureParameter { + InvalidParameter = 0, + ISO = 1, + Aperture = 2, + ShutterSpeed = 3, + ExposureCompensation = 4, + FlashPower = 5, + FlashCompensation = 6, + ExtendedExposureParameter = 1000 + }; + + enum ParameterFlag { + AutomaticValue = 0x01, + ReadOnly = 0x02, + ContinuousRange = 0x04 + }; + Q_DECLARE_FLAGS(ParameterFlags, ParameterFlag) + + virtual QCameraExposure::ExposureMode exposureMode() const = 0; + virtual void setExposureMode(QCameraExposure::ExposureMode mode) = 0; + virtual bool isExposureModeSupported(QCameraExposure::ExposureMode mode) const = 0; + + virtual QCameraExposure::MeteringMode meteringMode() const = 0; + virtual void setMeteringMode(QCameraExposure::MeteringMode mode) = 0; + virtual bool isMeteringModeSupported(QCameraExposure::MeteringMode mode) const = 0; + + virtual bool isParameterSupported(ExposureParameter parameter) const = 0; + virtual QVariant exposureParameter(ExposureParameter parameter) const = 0; + virtual ParameterFlags exposureParameterFlags(ExposureParameter parameter) const = 0; + virtual QVariantList supportedParameterRange(ExposureParameter parameter) const = 0; + virtual bool setExposureParameter(ExposureParameter parameter, const QVariant& value) = 0; + + virtual QString extendedParameterName(ExposureParameter parameter) = 0; + +Q_SIGNALS: + void flashReady(bool); + + void exposureParameterChanged(int parameter); + void exposureParameterRangeChanged(int parameter); + +protected: + QCameraExposureControl(QObject* parent = 0); +}; + +#define QCameraExposureControl_iid "com.nokia.Qt.QCameraExposureControl/1.0" +Q_MEDIA_DECLARE_CONTROL(QCameraExposureControl, QCameraExposureControl_iid) + +Q_DECLARE_OPERATORS_FOR_FLAGS(QCameraExposureControl::ParameterFlags) + +Q_MEDIA_ENUM_DEBUG(QCameraExposureControl, ExposureParameter) + +QT_END_NAMESPACE + +QT_END_HEADER + + +#endif // QCAMERAEXPOSURECONTROL_H + diff --git a/src/multimedia/qcameraflashcontrol.cpp b/src/multimedia/qcameraflashcontrol.cpp new file mode 100644 index 000000000..34dcbdeb5 --- /dev/null +++ b/src/multimedia/qcameraflashcontrol.cpp @@ -0,0 +1,141 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include +#include "qmediacontrol_p.h" + +QT_BEGIN_NAMESPACE + +/*! + \class QCameraFlashControl + + \brief The QCameraFlashControl class allows controlling a camera's flash. + + \ingroup multimedia-serv + \inmodule QtMultimedia + \since 1.1 + + \inmodule QtMultimedia + + You can set the type of flash effect used when an image is captured, and test to see + if the flash hardware is ready to fire. + + You can retrieve this control from the camera object in the usual way: + + Some camera devices may not have flash hardware, or may not be configurable. In that + case, there will be no QCameraFlashControl available. + + The interface name of QCameraFlashControl is \c com.nokia.Qt.QCameraFlashControl/1.0 as + defined in QCameraFlashControl_iid. + + \sa QCamera +*/ + +/*! + \macro QCameraFlashControl_iid + + \c com.nokia.Qt.QCameraFlashControl/1.0 + + Defines the interface name of the QCameraFlashControl class. + + \relates QCameraFlashControl +*/ + +/*! + Constructs a camera flash control object with \a parent. +*/ +QCameraFlashControl::QCameraFlashControl(QObject *parent): + QMediaControl(*new QMediaControlPrivate, parent) +{ +} + +/*! + Destroys the camera control object. +*/ +QCameraFlashControl::~QCameraFlashControl() +{ +} + +/*! + \fn QCamera::FlashModes QCameraFlashControl::flashMode() const + + Returns the current flash mode. + \since 1.1 +*/ + +/*! + \fn void QCameraFlashControl::setFlashMode(QCameraExposure::FlashModes mode) + + Set the current flash \a mode. + + Usually a single QCameraExposure::FlashMode flag is used, + but some non conflicting flags combination are also allowed, + like QCameraExposure::FlashManual | QCameraExposure::FlashSlowSyncRearCurtain. + \since 1.1 +*/ + + +/*! + \fn QCameraFlashControl::isFlashModeSupported(QCameraExposure::FlashModes mode) const + + Return true if the reqested flash \a mode is supported. + Some QCameraExposure::FlashMode values can be combined, + for example QCameraExposure::FlashManual | QCameraExposure::FlashSlowSyncRearCurtain + \since 1.1 +*/ + +/*! + \fn bool QCameraFlashControl::isFlashReady() const + + Returns true if flash is charged. + \since 1.1 +*/ + +/*! + \fn void QCameraFlashControl::flashReady(bool ready) + + Signal emitted when flash state changes to \a ready. + \since 1.1 +*/ + +#include "moc_qcameraflashcontrol.cpp" +QT_END_NAMESPACE + diff --git a/src/multimedia/qcameraflashcontrol.h b/src/multimedia/qcameraflashcontrol.h new file mode 100644 index 000000000..89b3b9d06 --- /dev/null +++ b/src/multimedia/qcameraflashcontrol.h @@ -0,0 +1,87 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QCAMERAFLASHCONTROL_H +#define QCAMERAFLASHCONTROL_H + +#include +#include + +#include +#include + +QT_BEGIN_HEADER + +QT_BEGIN_NAMESPACE + +QT_MODULE(Multimedia) + + +class Q_MULTIMEDIA_EXPORT QCameraFlashControl : public QMediaControl +{ + Q_OBJECT + +public: + ~QCameraFlashControl(); + + virtual QCameraExposure::FlashModes flashMode() const = 0; + virtual void setFlashMode(QCameraExposure::FlashModes mode) = 0; + virtual bool isFlashModeSupported(QCameraExposure::FlashModes mode) const = 0; + + virtual bool isFlashReady() const = 0; + +Q_SIGNALS: + void flashReady(bool); + +protected: + QCameraFlashControl(QObject* parent = 0); +}; + +#define QCameraFlashControl_iid "com.nokia.Qt.QCameraFlashControl/1.0" +Q_MEDIA_DECLARE_CONTROL(QCameraFlashControl, QCameraFlashControl_iid) + +QT_END_NAMESPACE + +QT_END_HEADER + + +#endif // QCAMERAFLASHCONTROL_H + diff --git a/src/multimedia/qcamerafocus.cpp b/src/multimedia/qcamerafocus.cpp new file mode 100644 index 000000000..22a0bbcc9 --- /dev/null +++ b/src/multimedia/qcamerafocus.cpp @@ -0,0 +1,478 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include + +#include +#include + +#include +#include +#include +#include +#include +#include +#include + +QT_BEGIN_NAMESPACE + +namespace +{ +class CameraFocusRegisterMetaTypes +{ +public: + CameraFocusRegisterMetaTypes() + { + qRegisterMetaType("QCameraFocus::FocusModes"); + qRegisterMetaType("QCameraFocus::FocusPointMode"); + } +} _registerCameraFocusMetaTypes; +} + + +class QCameraFocusZoneData : public QSharedData +{ +public: + QCameraFocusZoneData(): + status(QCameraFocusZone::Invalid) + { + + } + + QCameraFocusZoneData(const QRectF &_area, QCameraFocusZone::FocusZoneStatus _status): + area(_area), + status(_status) + { + + } + + + QCameraFocusZoneData(const QCameraFocusZoneData &other): + QSharedData(other), + area(other.area), + status(other.status) + { + } + + QCameraFocusZoneData& operator=(const QCameraFocusZoneData &other) + { + area = other.area; + status = other.status; + return *this; + } + + QRectF area; + QCameraFocusZone::FocusZoneStatus status; +}; + +QCameraFocusZone::QCameraFocusZone() + :d(new QCameraFocusZoneData) +{ + +} + +QCameraFocusZone::QCameraFocusZone(const QRectF &area, QCameraFocusZone::FocusZoneStatus status) + :d(new QCameraFocusZoneData(area, status)) +{ +} + +QCameraFocusZone::QCameraFocusZone(const QCameraFocusZone &other) + :d(other.d) +{ + +} + +QCameraFocusZone::~QCameraFocusZone() +{ + +} + +QCameraFocusZone& QCameraFocusZone::operator=(const QCameraFocusZone &other) +{ + d = other.d; + return *this; +} + +bool QCameraFocusZone::operator==(const QCameraFocusZone &other) const +{ + return d == other.d || + (d->area == other.d->area && d->status == other.d->status); +} + +bool QCameraFocusZone::operator!=(const QCameraFocusZone &other) const +{ + return !(*this == other); +} + +bool QCameraFocusZone::isValid() const +{ + return d->status != Invalid && !d->area.isValid(); +} + +QRectF QCameraFocusZone::area() const +{ + return d->area; +} + +QCameraFocusZone::FocusZoneStatus QCameraFocusZone::status() const +{ + return d->status; +} + +void QCameraFocusZone::setStatus(QCameraFocusZone::FocusZoneStatus status) +{ + d->status = status; +} + + +/*! + \class QCameraFocus + + + \brief The QCameraFocus class provides interface for + focus and zoom related camera settings. + + \inmodule QtMultimedia + \ingroup camera + \since 1.1 + +*/ + + +class QCameraFocusPrivate : public QMediaObjectPrivate +{ + Q_DECLARE_NON_CONST_PUBLIC(QCameraFocus) +public: + void initControls(); + + QCameraFocus *q_ptr; + + QCamera *camera; + QCameraFocusControl *focusControl; +}; + + +void QCameraFocusPrivate::initControls() +{ + Q_Q(QCameraFocus); + + focusControl = 0; + + QMediaService *service = camera->service(); + if (service) + focusControl = qobject_cast(service->requestControl(QCameraFocusControl_iid)); + + if (focusControl) { + q->connect(focusControl, SIGNAL(opticalZoomChanged(qreal)), q, SIGNAL(opticalZoomChanged(qreal))); + q->connect(focusControl, SIGNAL(digitalZoomChanged(qreal)), q, SIGNAL(digitalZoomChanged(qreal))); + q->connect(focusControl, SIGNAL(maximumOpticalZoomChanged(qreal)), + q, SIGNAL(maximumOpticalZoomChanged(qreal))); + q->connect(focusControl, SIGNAL(maximumDigitalZoomChanged(qreal)), + q, SIGNAL(maximumDigitalZoomChanged(qreal))); + q->connect(focusControl, SIGNAL(focusZonesChanged()), q, SIGNAL(focusZonesChanged())); + } +} + +/*! + Construct a QCameraFocus for \a camera. +*/ + +QCameraFocus::QCameraFocus(QCamera *camera): + QObject(camera), d_ptr(new QCameraFocusPrivate) +{ + Q_D(QCameraFocus); + d->camera = camera; + d->q_ptr = this; + d->initControls(); +} + + +/*! + Destroys the camera focus object. +*/ + +QCameraFocus::~QCameraFocus() +{ +} + +/*! + Returns true if focus related settings are supported by this camera. + \since 1.1 +*/ +bool QCameraFocus::isAvailable() const +{ + return d_func()->focusControl != 0; +} + +/*! + \property QCameraFocus::focusMode + \brief The current camera focus mode. + + \since 1.1 + \sa QCameraFocus::isFocusModeSupported() +*/ + +QCameraFocus::FocusMode QCameraFocus::focusMode() const +{ + return d_func()->focusControl ? d_func()->focusControl->focusMode() : QCameraFocus::AutoFocus; +} + +void QCameraFocus::setFocusMode(QCameraFocus::FocusMode mode) +{ + if (d_func()->focusControl) + d_func()->focusControl->setFocusMode(mode); +} + +/*! + Returns true if the focus \a mode is supported by camera. + \since 1.1 +*/ + +bool QCameraFocus::isFocusModeSupported(QCameraFocus::FocusMode mode) const +{ + return d_func()->focusControl ? d_func()->focusControl->isFocusModeSupported(mode) : false; +} + +/*! + \property QCameraFocus::focusPointMode + \brief The current camera focus point selection mode. + + \sa QCameraFocus::isFocusPointModeSupported() + \since 1.1 +*/ + +QCameraFocus::FocusPointMode QCameraFocus::focusPointMode() const +{ + return d_func()->focusControl ? + d_func()->focusControl->focusPointMode() : + QCameraFocus::FocusPointAuto; +} + +void QCameraFocus::setFocusPointMode(QCameraFocus::FocusPointMode mode) +{ + if (d_func()->focusControl) + d_func()->focusControl->setFocusPointMode(mode); + else + qWarning("Focus points mode selection is not supported"); +} + +/*! + Returns true if focus point \a mode is supported. + \since 1.1 + */ +bool QCameraFocus::isFocusPointModeSupported(QCameraFocus::FocusPointMode mode) const +{ + return d_func()->focusControl ? + d_func()->focusControl->isFocusPointModeSupported(mode) : + false; + +} + +/*! + \property QCameraFocus::customFocusPoint + + Position of custom focus point, in relative frame coordinates: + QPointF(0,0) points to the left top frame point, QPointF(0.5,0.5) points to the frame center. + + Custom focus point is used only in FocusPointCustom focus mode. + \since 1.1 + */ + +QPointF QCameraFocus::customFocusPoint() const +{ + return d_func()->focusControl ? + d_func()->focusControl->customFocusPoint() : + QPointF(0.5,0.5); +} + +void QCameraFocus::setCustomFocusPoint(const QPointF &point) +{ + if (d_func()->focusControl) + d_func()->focusControl->setCustomFocusPoint(point); + else + qWarning("Focus points selection is not supported"); + +} + +/*! + \property QCameraFocus::focusZones + + Returns the list of active focus zones. + + If QCamera::FocusPointAuto or QCamera::FocusPointFaceDetection focus mode is selected + this method returns the list of zones the camera is actually focused on. + + The coordinates system is the same as for custom focus points: + QPointF(0,0) points to the left top frame point, QPointF(0.5,0.5) points to the frame center. + \since 1.1 + */ +QCameraFocusZoneList QCameraFocus::focusZones() const +{ + return d_func()->focusControl ? + d_func()->focusControl->focusZones() : + QCameraFocusZoneList(); +} + +/*! + Returns the maximum optical zoom + \since 1.1 +*/ + +qreal QCameraFocus::maximumOpticalZoom() const +{ + return d_func()->focusControl ? d_func()->focusControl->maximumOpticalZoom() : 1.0; +} + +/*! + Returns the maximum digital zoom + \since 1.1 +*/ + +qreal QCameraFocus::maximumDigitalZoom() const +{ + return d_func()->focusControl ? d_func()->focusControl->maximumDigitalZoom() : 1.0; +} + +/*! + \property QCameraFocus::opticalZoom + \brief The current optical zoom value. + + \since 1.1 + \sa QCameraFocus::digitalZoom +*/ + +qreal QCameraFocus::opticalZoom() const +{ + return d_func()->focusControl ? d_func()->focusControl->opticalZoom() : 1.0; +} + +/*! + \property QCameraFocus::digitalZoom + \brief The current digital zoom value. + + \since 1.1 + \sa QCameraFocus::opticalZoom +*/ +qreal QCameraFocus::digitalZoom() const +{ + return d_func()->focusControl ? d_func()->focusControl->digitalZoom() : 1.0; +} + + +/*! + Set the camera \a optical and \a digital zoom values. + \since 1.1 +*/ +void QCameraFocus::zoomTo(qreal optical, qreal digital) +{ + if (d_func()->focusControl) + d_func()->focusControl->zoomTo(optical, digital); + else + qWarning("The camera doesn't support zooming."); +} + +/*! + \enum QCameraFocus::FocusMode + + \value ManualFocus Manual or fixed focus mode. + \value AutoFocus One-shot auto focus mode. + \value ContinuousFocus Continuous auto focus mode. + \value InfinityFocus Focus strictly to infinity. + \value HyperfocalFocus Focus to hyperfocal distance, with with the maximum depth of field achieved. + All objects at distances from half of this + distance out to infinity will be acceptably sharp. + \value MacroFocus One shot auto focus to objects close to camera. +*/ + +/*! + \enum QCameraFocus::FocusPointMode + + \value FocusPointAuto Automatically select one or multiple focus points. + \value FocusPointCenter Focus to the frame center. + \value FocusPointFaceDetection Focus on faces in the frame. + \value FocusPointCustom Focus to the custom point, defined by QCameraFocus::customFocusPoint property. +*/ + +/*! + \fn void QCameraFocus::opticalZoomChanged(qreal value) + + Signal emitted when optical zoom value changes to new \a value. + \since 1.1 +*/ + +/*! + \fn void QCameraFocus::digitalZoomChanged(qreal value) + + Signal emitted when digital zoom value changes to new \a value. + \since 1.1 +*/ + +/*! + \fn void QCameraFocus::maximumOpticalZoomChanged(qreal zoom) + + Signal emitted when the maximum supported optical \a zoom value changed. + \since 1.1 +*/ + +/*! + \fn void QCameraFocus::maximumDigitalZoomChanged(qreal zoom) + + Signal emitted when the maximum supported digital \a zoom value changed. + + The maximum supported zoom value can depend on other camera settings, + like capture mode or resolution. + \since 1.1 +*/ + + + +/*! + \fn QCameraFocus::focusZonesChanged() + + Signal is emitted when the set of zones, camera focused on is changed. + + Usually the zones list is changed when the camera is focused. + \since 1.1 +*/ + + +#include "moc_qcamerafocus.cpp" +QT_END_NAMESPACE diff --git a/src/multimedia/qcamerafocus.h b/src/multimedia/qcamerafocus.h new file mode 100644 index 000000000..064af7aa1 --- /dev/null +++ b/src/multimedia/qcamerafocus.h @@ -0,0 +1,183 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QCAMERAFOCUS_H +#define QCAMERAFOCUS_H + +#include +#include +#include +#include +#include +#include + +#include +#include + +QT_BEGIN_HEADER + +QT_BEGIN_NAMESPACE + +QT_MODULE(Multimedia) + + +class QCamera; + +class QCameraFocusZoneData; + +class Q_MULTIMEDIA_EXPORT QCameraFocusZone { +public: + enum FocusZoneStatus { + Invalid, + Unused, + Selected, + Focused + }; + + QCameraFocusZone(); + QCameraFocusZone(const QRectF &area, FocusZoneStatus status = Selected); + QCameraFocusZone(const QCameraFocusZone &other); + + QCameraFocusZone& operator=(const QCameraFocusZone &other); + bool operator==(const QCameraFocusZone &other) const; + bool operator!=(const QCameraFocusZone &other) const; + + ~QCameraFocusZone(); + + bool isValid() const; + + QRectF area() const; + + FocusZoneStatus status() const; + void setStatus(FocusZoneStatus status); + +private: + QSharedDataPointer d; +}; + +typedef QList QCameraFocusZoneList; + + +class QCameraFocusPrivate; +class Q_MULTIMEDIA_EXPORT QCameraFocus : public QObject +{ + Q_OBJECT + + Q_PROPERTY(FocusMode focusMode READ focusMode WRITE setFocusMode) + Q_PROPERTY(FocusPointMode focusPointMode READ focusPointMode WRITE setFocusPointMode) + Q_PROPERTY(QPointF customFocusPoint READ customFocusPoint WRITE setCustomFocusPoint) + Q_PROPERTY(QCameraFocusZoneList focusZones READ focusZones NOTIFY focusZonesChanged) + Q_PROPERTY(qreal opticalZoom READ opticalZoom NOTIFY opticalZoomChanged) + Q_PROPERTY(qreal digitalZoom READ digitalZoom NOTIFY digitalZoomChanged) + + Q_ENUMS(FocusMode) + Q_ENUMS(FocusPointMode) +public: + enum FocusMode { + ManualFocus = 0x1, + HyperfocalFocus = 0x02, + InfinityFocus = 0x04, + AutoFocus = 0x8, + ContinuousFocus = 0x10, + MacroFocus = 0x20 + }; + Q_DECLARE_FLAGS(FocusModes, FocusMode) + + enum FocusPointMode { + FocusPointAuto, + FocusPointCenter, + FocusPointFaceDetection, + FocusPointCustom + }; + + bool isAvailable() const; + + FocusMode focusMode() const; + void setFocusMode(FocusMode mode); + bool isFocusModeSupported(FocusMode mode) const; + + FocusPointMode focusPointMode() const; + void setFocusPointMode(FocusPointMode mode); + bool isFocusPointModeSupported(FocusPointMode) const; + QPointF customFocusPoint() const; + void setCustomFocusPoint(const QPointF &point); + + QCameraFocusZoneList focusZones() const; + + qreal maximumOpticalZoom() const; + qreal maximumDigitalZoom() const; + qreal opticalZoom() const; + qreal digitalZoom() const; + + void zoomTo(qreal opticalZoom, qreal digitalZoom); + +Q_SIGNALS: + void opticalZoomChanged(qreal); + void digitalZoomChanged(qreal); + + void focusZonesChanged(); + + void maximumOpticalZoomChanged(qreal); + void maximumDigitalZoomChanged(qreal); + +private: + friend class QCamera; + QCameraFocus(QCamera *camera); + ~QCameraFocus(); + + Q_DISABLE_COPY(QCameraFocus) + Q_DECLARE_PRIVATE(QCameraFocus) + QCameraFocusPrivate *d_ptr; +}; + +Q_DECLARE_OPERATORS_FOR_FLAGS(QCameraFocus::FocusModes) + +QT_END_NAMESPACE + +Q_DECLARE_METATYPE(QCameraFocus::FocusModes) +Q_DECLARE_METATYPE(QCameraFocus::FocusPointMode) + +Q_MEDIA_ENUM_DEBUG(QCameraFocus, FocusMode) +Q_MEDIA_ENUM_DEBUG(QCameraFocus, FocusPointMode) + +QT_END_HEADER + +#endif // QCAMERAFOCUS_H diff --git a/src/multimedia/qcamerafocuscontrol.cpp b/src/multimedia/qcamerafocuscontrol.cpp new file mode 100644 index 000000000..93c466814 --- /dev/null +++ b/src/multimedia/qcamerafocuscontrol.cpp @@ -0,0 +1,253 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include +#include "qmediacontrol_p.h" + +QT_BEGIN_NAMESPACE + +/*! + \class QCameraFocusControl + + + \brief The QCameraFocusControl class supplies control for + focusing related camera parameters. + + \inmodule QtMultimedia + \ingroup multimedia-serv + \since 1.1 + + The interface name of QCameraFocusControl is \c com.nokia.Qt.QCameraFocusControl/1.0 as + defined in QCameraFocusControl_iid. + + + \sa QMediaService::requestControl(), QCamera +*/ + +/*! + \macro QCameraFocusControl_iid + + \c com.nokia.Qt.QCameraFocusControl/1.0 + + Defines the interface name of the QCameraFocusControl class. + + \relates QCameraFocusControl +*/ + +/*! + Constructs a camera control object with \a parent. +*/ + +QCameraFocusControl::QCameraFocusControl(QObject *parent): + QMediaControl(*new QMediaControlPrivate, parent) +{ +} + +/*! + Destruct the camera control object. +*/ + +QCameraFocusControl::~QCameraFocusControl() +{ +} + + +/*! + \fn QCameraFocus::FocusMode QCameraFocusControl::focusMode() const + + Returns the focus mode being used. + \since 1.1 +*/ + + +/*! + \fn void QCameraFocusControl::setFocusMode(QCameraFocus::FocusMode mode) + + Set the focus mode to \a mode. + \since 1.1 +*/ + + +/*! + \fn bool QCameraFocusControl::isFocusModeSupported(QCameraFocus::FocusMode mode) const + + Returns true if focus \a mode is supported. + \since 1.1 +*/ + + +/*! + \fn qreal QCameraFocusControl::maximumOpticalZoom() const + + Returns the maximum optical zoom value, or 1.0 if optical zoom is not supported. + \since 1.1 +*/ + + +/*! + \fn qreal QCameraFocusControl::maximumDigitalZoom() const + + Returns the maximum digital zoom value, or 1.0 if digital zoom is not supported. + \since 1.1 +*/ + + +/*! + \fn qreal QCameraFocusControl::opticalZoom() const + + Return the current optical zoom value. + \since 1.1 +*/ + +/*! + \fn qreal QCameraFocusControl::digitalZoom() const + + Return the current digital zoom value. + \since 1.1 +*/ + + +/*! + \fn void QCameraFocusControl::zoomTo(qreal optical, qreal digital) + + Sets \a optical and \a digital zoom values. + \since 1.1 +*/ + +/*! + \fn QCameraFocusControl::focusPointMode() const + + Returns the camera focus point selection mode. + \since 1.1 +*/ + +/*! + \fn QCameraFocusControl::setFocusPointMode(QCameraFocus::FocusPointMode mode) + + Sets the camera focus point selection \a mode. + \since 1.1 +*/ + +/*! + \fn QCameraFocusControl::isFocusPointModeSupported(QCameraFocus::FocusPointMode mode) const + + Returns true if the camera focus point \a mode is supported. + \since 1.1 +*/ + +/*! + \fn QCameraFocusControl::customFocusPoint() const + + Return the position of custom focus point, in relative frame coordinates: + QPointF(0,0) points to the left top frame point, QPointF(0.5,0.5) points to the frame center. + + Custom focus point is used only in FocusPointCustom focus mode. + \since 1.1 +*/ + +/*! + \fn QCameraFocusControl::setCustomFocusPoint(const QPointF &point) + + Sets the custom focus \a point. + + If camera supports fixed set of focus points, + it should use the nearest supported focus point, + and return the actual focus point with QCameraFocusControl::focusZones(). + + \since 1.1 + \sa QCameraFocusControl::customFocusPoint(), QCameraFocusControl::focusZones() +*/ + +/*! + \fn QCameraFocusControl::focusZones() const + + Returns the list of zones, the camera is using for focusing or focused on. + \since 1.1 +*/ + +/*! + \fn void QCameraFocusControl::opticalZoomChanged(qreal zoom) + + Signal emitted when the optical \a zoom value changed. + \since 1.1 +*/ + +/*! + \fn void QCameraFocusControl::digitalZoomChanged(qreal zoom) + + Signal emitted when the digital \a zoom value changed. + \since 1.1 +*/ + +/*! + \fn void QCameraFocusControl::maximumOpticalZoomChanged(qreal zoom) + + Signal emitted when the maximum supported optical \a zoom value changed. + \since 1.1 +*/ + +/*! + \fn void QCameraFocusControl::maximumDigitalZoomChanged(qreal zoom) + + Signal emitted when the maximum supported digital \a zoom value changed. + + The maximum supported zoom value can depend on other camera settings, + like capture mode or resolution. + \since 1.1 +*/ + + +/*! + \fn QCameraFocusControl::focusZonesChanged() + + Signal is emitted when the set of zones, camera focused on is changed. + + Usually the zones list is changed when the camera is focused. + + \since 1.1 + \sa QCameraFocusControl::focusZones() +*/ + + + +#include "moc_qcamerafocuscontrol.cpp" +QT_END_NAMESPACE + diff --git a/src/multimedia/qcamerafocuscontrol.h b/src/multimedia/qcamerafocuscontrol.h new file mode 100644 index 000000000..20ffe6af1 --- /dev/null +++ b/src/multimedia/qcamerafocuscontrol.h @@ -0,0 +1,103 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QCAMERAFOCUSCONTROL_H +#define QCAMERAFOCUSCONTROL_H + +#include +#include + +#include + +QT_BEGIN_HEADER + +QT_BEGIN_NAMESPACE + +QT_MODULE(Multimedia) + + +class Q_MULTIMEDIA_EXPORT QCameraFocusControl : public QMediaControl +{ + Q_OBJECT + +public: + ~QCameraFocusControl(); + + virtual QCameraFocus::FocusMode focusMode() const = 0; + virtual void setFocusMode(QCameraFocus::FocusMode mode) = 0; + virtual bool isFocusModeSupported(QCameraFocus::FocusMode mode) const = 0; + + virtual qreal maximumOpticalZoom() const = 0; + virtual qreal maximumDigitalZoom() const = 0; + virtual qreal opticalZoom() const = 0; + virtual qreal digitalZoom() const = 0; + + virtual void zoomTo(qreal optical, qreal digital) = 0; + + virtual QCameraFocus::FocusPointMode focusPointMode() const = 0; + virtual void setFocusPointMode(QCameraFocus::FocusPointMode mode) = 0; + virtual bool isFocusPointModeSupported(QCameraFocus::FocusPointMode mode) const = 0; + virtual QPointF customFocusPoint() const = 0; + virtual void setCustomFocusPoint(const QPointF &point) = 0; + + virtual QCameraFocusZoneList focusZones() const = 0; + +Q_SIGNALS: + void opticalZoomChanged(qreal opticalZoom); + void digitalZoomChanged(qreal digitalZoom); + void focusZonesChanged(); + void maximumOpticalZoomChanged(qreal); + void maximumDigitalZoomChanged(qreal); + +protected: + QCameraFocusControl(QObject* parent = 0); +}; + +#define QCameraFocusControl_iid "com.nokia.Qt.QCameraFocusingControl/1.0" +Q_MEDIA_DECLARE_CONTROL(QCameraFocusControl, QCameraFocusControl_iid) + +QT_END_NAMESPACE + +QT_END_HEADER + + +#endif // QCAMERAFOCUSCONTROL_H + diff --git a/src/multimedia/qcameraimagecapture.cpp b/src/multimedia/qcameraimagecapture.cpp new file mode 100644 index 000000000..6b399b684 --- /dev/null +++ b/src/multimedia/qcameraimagecapture.cpp @@ -0,0 +1,681 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +QT_BEGIN_NAMESPACE + +/*! + \class QCameraImageCapture + \inmodule QtMultimedia + \ingroup camera + \since 1.1 + + + \brief The QCameraImageCapture class is used for the recording of media content. + + The QCameraImageCapture class is a high level images recording class. + It's not intended to be used alone but for accessing the media + recording functions of other media objects, like QCamera. + + \snippet doc/src/snippets/multimedia-snippets/camera.cpp Camera + + \snippet doc/src/snippets/multimedia-snippets/camera.cpp Camera keys + + \sa QCamera +*/ + +namespace +{ +class MediaRecorderRegisterMetaTypes +{ +public: + MediaRecorderRegisterMetaTypes() + { + qRegisterMetaType("QCameraImageCapture::Error"); + qRegisterMetaType("QCameraImageCapture::CaptureDestination"); + qRegisterMetaType("QCameraImageCapture::CaptureDestinations"); + } +} _registerRecorderMetaTypes; +} + + +class QCameraImageCapturePrivate +{ + Q_DECLARE_NON_CONST_PUBLIC(QCameraImageCapture) +public: + QCameraImageCapturePrivate(); + + QMediaObject *mediaObject; + + QCameraImageCaptureControl *control; + QImageEncoderControl *encoderControl; + QCameraCaptureDestinationControl *captureDestinationControl; + QCameraCaptureBufferFormatControl *bufferFormatControl; + + QCameraImageCapture::Error error; + QString errorString; + + void _q_error(int id, int error, const QString &errorString); + void _q_readyChanged(bool); + void _q_serviceDestroyed(); + + void unsetError() { error = QCameraImageCapture::NoError; errorString.clear(); } + + QCameraImageCapture *q_ptr; +}; + +QCameraImageCapturePrivate::QCameraImageCapturePrivate(): + mediaObject(0), + control(0), + encoderControl(0), + captureDestinationControl(0), + bufferFormatControl(0), + error(QCameraImageCapture::NoError) +{ +} + +void QCameraImageCapturePrivate::_q_error(int id, int error, const QString &errorString) +{ + Q_Q(QCameraImageCapture); + + this->error = QCameraImageCapture::Error(error); + this->errorString = errorString; + + emit q->error(id, this->error, errorString); +} + +void QCameraImageCapturePrivate::_q_readyChanged(bool ready) +{ + Q_Q(QCameraImageCapture); + emit q->readyForCaptureChanged(ready); +} + +void QCameraImageCapturePrivate::_q_serviceDestroyed() +{ + mediaObject = 0; + control = 0; + encoderControl = 0; + captureDestinationControl = 0; + bufferFormatControl = 0; +} + +/*! + Constructs a media recorder which records the media produced by \a mediaObject. + + The \a parent is passed to QMediaObject. +*/ + +QCameraImageCapture::QCameraImageCapture(QMediaObject *mediaObject, QObject *parent): + QObject(parent), d_ptr(new QCameraImageCapturePrivate) +{ + Q_D(QCameraImageCapture); + + d->q_ptr = this; + + if (mediaObject) + mediaObject->bind(this); +} + +/*! + Destroys images capture object. +*/ + +QCameraImageCapture::~QCameraImageCapture() +{ + Q_D(QCameraImageCapture); + + if (d->mediaObject) + d->mediaObject->unbind(this); +} + +/*! + \reimp + \since 1.1 +*/ +QMediaObject *QCameraImageCapture::mediaObject() const +{ + return d_func()->mediaObject; +} + +/*! + \reimp + \since 1.1 +*/ +bool QCameraImageCapture::setMediaObject(QMediaObject *mediaObject) +{ + Q_D(QCameraImageCapture); + + if (d->mediaObject) { + if (d->control) { + disconnect(d->control, SIGNAL(imageExposed(int)), + this, SIGNAL(imageExposed(int))); + disconnect(d->control, SIGNAL(imageCaptured(int,QImage)), + this, SIGNAL(imageCaptured(int,QImage))); + disconnect(d->control, SIGNAL(imageAvailable(int,QVideoFrame)), + this, SIGNAL(imageAvailable(int,QVideoFrame))); + disconnect(d->control, SIGNAL(imageMetadataAvailable(int,QtMultimedia::MetaData,QVariant)), + this, SIGNAL(imageMetadataAvailable(int,QtMultimedia::MetaData,QVariant))); + disconnect(d->control, SIGNAL(imageMetadataAvailable(int,QString,QVariant)), + this, SIGNAL(imageMetadataAvailable(int,QString,QVariant))); + disconnect(d->control, SIGNAL(imageSaved(int,QString)), + this, SIGNAL(imageSaved(int,QString))); + disconnect(d->control, SIGNAL(readyForCaptureChanged(bool)), + this, SLOT(_q_readyChanged(bool))); + disconnect(d->control, SIGNAL(error(int,int,QString)), + this, SLOT(_q_error(int,int,QString))); + + if (d->captureDestinationControl) { + disconnect(d->captureDestinationControl, SIGNAL(captureDestinationChanged(QCameraImageCapture::CaptureDestinations)), + this, SIGNAL(captureDestinationChanged(QCameraImageCapture::CaptureDestinations))); + } + + if (d->bufferFormatControl) { + disconnect(d->bufferFormatControl, SIGNAL(bufferFormatChanged(QVideoFrame::PixelFormat)), + this, SIGNAL(bufferFormatChanged(QVideoFrame::PixelFormat))); + } + + QMediaService *service = d->mediaObject->service(); + service->releaseControl(d->control); + if (d->encoderControl) + service->releaseControl(d->encoderControl); + if (d->captureDestinationControl) + service->releaseControl(d->captureDestinationControl); + if (d->bufferFormatControl) + service->releaseControl(d->bufferFormatControl); + + disconnect(service, SIGNAL(destroyed()), this, SLOT(_q_serviceDestroyed())); + } + } + + d->mediaObject = mediaObject; + + if (d->mediaObject) { + QMediaService *service = mediaObject->service(); + if (service) { + d->control = qobject_cast(service->requestControl(QCameraImageCaptureControl_iid)); + + if (d->control) { + d->encoderControl = qobject_cast(service->requestControl(QImageEncoderControl_iid)); + d->captureDestinationControl = qobject_cast( + service->requestControl(QCameraCaptureDestinationControl_iid)); + d->bufferFormatControl = qobject_cast( + service->requestControl(QCameraCaptureBufferFormatControl_iid)); + + connect(d->control, SIGNAL(imageExposed(int)), + this, SIGNAL(imageExposed(int))); + connect(d->control, SIGNAL(imageCaptured(int,QImage)), + this, SIGNAL(imageCaptured(int,QImage))); + connect(d->control, SIGNAL(imageMetadataAvailable(int,QtMultimedia::MetaData,QVariant)), + this, SIGNAL(imageMetadataAvailable(int,QtMultimedia::MetaData,QVariant))); + connect(d->control, SIGNAL(imageMetadataAvailable(int,QString,QVariant)), + this, SIGNAL(imageMetadataAvailable(int,QString,QVariant))); + connect(d->control, SIGNAL(imageAvailable(int,QVideoFrame)), + this, SIGNAL(imageAvailable(int,QVideoFrame))); + connect(d->control, SIGNAL(imageSaved(int, QString)), + this, SIGNAL(imageSaved(int, QString))); + connect(d->control, SIGNAL(readyForCaptureChanged(bool)), + this, SLOT(_q_readyChanged(bool))); + connect(d->control, SIGNAL(error(int,int,QString)), + this, SLOT(_q_error(int,int,QString))); + + if (d->captureDestinationControl) { + connect(d->captureDestinationControl, SIGNAL(captureDestinationChanged(QCameraImageCapture::CaptureDestinations)), + this, SIGNAL(captureDestinationChanged(QCameraImageCapture::CaptureDestinations))); + } + + if (d->bufferFormatControl) { + connect(d->bufferFormatControl, SIGNAL(bufferFormatChanged(QVideoFrame::PixelFormat)), + this, SIGNAL(bufferFormatChanged(QVideoFrame::PixelFormat))); + } + + connect(service, SIGNAL(destroyed()), this, SLOT(_q_serviceDestroyed())); + + return true; + } + } + } + + // without QCameraImageCaptureControl discard the media object + d->mediaObject = 0; + d->control = 0; + d->encoderControl = 0; + d->captureDestinationControl = 0; + d->bufferFormatControl = 0; + + return false; +} + +/*! + Returns true if the images capture service ready to use. + \since 1.1 +*/ +bool QCameraImageCapture::isAvailable() const +{ + if (d_func()->control != NULL) + return true; + else + return false; +} + +/*! + Returns the availability error code. + \since 1.1 +*/ +QtMultimedia::AvailabilityError QCameraImageCapture::availabilityError() const +{ + if (d_func()->control != NULL) + return QtMultimedia::NoError; + else + return QtMultimedia::ServiceMissingError; +} + +/*! + Returns the current error state. + + \since 1.1 + \sa errorString() +*/ + +QCameraImageCapture::Error QCameraImageCapture::error() const +{ + return d_func()->error; +} + +/*! + Returns a string describing the current error state. + + \since 1.1 + \sa error() +*/ + +QString QCameraImageCapture::errorString() const +{ + return d_func()->errorString; +} + + +/*! + Returns a list of supported image codecs. + \since 1.1 +*/ +QStringList QCameraImageCapture::supportedImageCodecs() const +{ + return d_func()->encoderControl ? + d_func()->encoderControl->supportedImageCodecs() : QStringList(); +} + +/*! + Returns a description of an image \a codec. + \since 1.1 +*/ +QString QCameraImageCapture::imageCodecDescription(const QString &codec) const +{ + return d_func()->encoderControl ? + d_func()->encoderControl->imageCodecDescription(codec) : QString(); +} + +/*! + Returns a list of resolutions images can be encoded at. + + If non null image \a settings parameter is passed, + the returned list is reduced to resolution supported with partial settings like image codec or quality applied. + + If the encoder supports arbitrary resolutions within the supported range, + *\a continuous is set to true, otherwise *\a continuous is set to false. + + \since 1.1 + \sa QImageEncoderSettings::resolution() +*/ +QList QCameraImageCapture::supportedResolutions(const QImageEncoderSettings &settings, bool *continuous) const +{ + if (continuous) + *continuous = false; + + return d_func()->encoderControl ? + d_func()->encoderControl->supportedResolutions(settings, continuous) : QList(); +} + +/*! + Returns the image encoder settings being used. + + \since 1.1 + \sa setEncodingSettings() +*/ + +QImageEncoderSettings QCameraImageCapture::encodingSettings() const +{ + return d_func()->encoderControl ? + d_func()->encoderControl->imageSettings() : QImageEncoderSettings(); +} + +/*! + Sets the image encoding \a settings. + + If some parameters are not specified, or null settings are passed, + the encoder choose the default encoding parameters. + + \since 1.1 + \sa encodingSettings() +*/ + +void QCameraImageCapture::setEncodingSettings(const QImageEncoderSettings &settings) +{ + Q_D(QCameraImageCapture); + + if (d->encoderControl) { + QCamera *camera = qobject_cast(d->mediaObject); + if (camera && camera->captureMode() == QCamera::CaptureStillImage) { + QMetaObject::invokeMethod(camera, + "_q_preparePropertyChange", + Qt::DirectConnection, + Q_ARG(int, QCameraControl::ImageEncodingSettings)); + } + + d->encoderControl->setImageSettings(settings); + } +} + +/*! + Returns the list of supported buffer image capture formats. + + \since 1.1 + \sa bufferFormat() setBufferFormat() +*/ +QList QCameraImageCapture::supportedBufferFormats() const +{ + if (d_func()->bufferFormatControl) + return d_func()->bufferFormatControl->supportedBufferFormats(); + else + return QList(); +} + +/*! + Returns the buffer image capture format being used. + + \since 1.2 + \sa supportedBufferCaptureFormats() setBufferCaptureFormat() +*/ +QVideoFrame::PixelFormat QCameraImageCapture::bufferFormat() const +{ + if (d_func()->bufferFormatControl) + return d_func()->bufferFormatControl->bufferFormat(); + else + return QVideoFrame::Format_Invalid; +} + +/*! + Sets the buffer image capture format to be used. + + \since 1.2 + \sa bufferCaptureFormat() supportedBufferCaptureFormats() captureDestination() +*/ +void QCameraImageCapture::setBufferFormat(const QVideoFrame::PixelFormat format) +{ + if (d_func()->bufferFormatControl) + d_func()->bufferFormatControl->setBufferFormat(format); +} + +/*! + Returns true if the image capture \a destination is supported; otherwise returns false. + + \since 1.2 + \sa captureDestination() setCaptureDestination() +*/ +bool QCameraImageCapture::isCaptureDestinationSupported(QCameraImageCapture::CaptureDestinations destination) const +{ + if (d_func()->captureDestinationControl) + return d_func()->captureDestinationControl->isCaptureDestinationSupported(destination); + else + return destination == CaptureToFile; +} + +/*! + Returns the image capture destination being used. + + \since 1.2 + \sa isCaptureDestinationSupported() setCaptureDestination() +*/ +QCameraImageCapture::CaptureDestinations QCameraImageCapture::captureDestination() const +{ + if (d_func()->captureDestinationControl) + return d_func()->captureDestinationControl->captureDestination(); + else + return CaptureToFile; +} + +/*! + Sets the capture \a destination to be used. + + \since 1.2 + \sa isCaptureDestinationSupported() captureDestination() +*/ +void QCameraImageCapture::setCaptureDestination(QCameraImageCapture::CaptureDestinations destination) +{ + Q_D(QCameraImageCapture); + + if (d->captureDestinationControl) + d->captureDestinationControl->setCaptureDestination(destination); +} + +/*! + \property QCameraImageCapture::readyForCapture + Indicates the service is ready to capture a an image immediately. + \since 1.1 +*/ + +bool QCameraImageCapture::isReadyForCapture() const +{ + if (d_func()->control) + return d_func()->control->isReadyForCapture(); + else + return false; +} + +/*! + \fn QCameraImageCapture::readyForCaptureChanged(bool ready) + + Signals that a camera's \a ready for capture state has changed. + \since 1.1 +*/ + + +/*! + Capture the image and save it to \a file. + This operation is asynchronous in majority of cases, + followed by signals QCameraImageCapture::imageCaptured(), QCameraImageCapture::imageSaved() + or QCameraImageCapture::error(). + + If an empty \a file is passed, the camera backend choses + the default location and naming scheme for photos on the system, + if only file name without full path is specified, the image will be saved to + the default directory, with a full path reported with imageCaptured() and imageSaved() signals. + + QCameraImageCapture::capture returns the capture Id parameter, used with + imageExposed(), imageCaptured() and imageSaved() signals. + \since 1.1 +*/ +int QCameraImageCapture::capture(const QString &file) +{ + Q_D(QCameraImageCapture); + + d->unsetError(); + + if (d->control) { + return d->control->capture(file); + } else { + d->error = NotSupportedFeatureError; + d->errorString = tr("Device does not support images capture."); + + emit error(-1, d->error, d->errorString); + } + + return -1; +} + +/*! + Cancel incomplete capture requests. + Already captured and queused for proicessing images may be discarded. + \since 1.1 +*/ +void QCameraImageCapture::cancelCapture() +{ + Q_D(QCameraImageCapture); + + d->unsetError(); + + if (d->control) { + d->control->cancelCapture(); + } else { + d->error = NotSupportedFeatureError; + d->errorString = tr("Device does not support images capture."); + + emit error(-1, d->error, d->errorString); + } +} + + +/*! + \enum QCameraImageCapture::Error + + \value NoError No Errors. + \value NotReadyError The service is not ready for capture yet. + \value ResourceError Device is not ready or not available. + \value NotSupportedFeatureError Device does not support stillimages capture. + \value FormatError Current format is not supported. + \value OutOfSpaceError No space left on device. +*/ + +/*! + \enum QCameraImageCapture::DriveMode + + \value SingleImageCapture Drive mode is capturing a single picture. +*/ + +/*! + \fn QCameraImageCapture::error(int id, QCameraImageCapture::Error error, const QString &errorString) + + Signals that the capture request \a id has failed with an \a error + and \a errorString description. + \since 1.1 +*/ + +/*! + \fn QCameraImageCapture::bufferFormatChanged(QVideoFrame::PixelFormat format) + + Signal emitted when the buffer \a format for the buffer image capture has changed. + \since 1.2 +*/ + +/*! + \fn QCameraImageCapture::captureDestinationChanged(CaptureDestinations destination) + + Signal emitted when the capture \a destination has changed. + \since 1.2 +*/ + +/*! + \fn QCameraImageCapture::imageExposed(int id) + + Signal emitted when the frame with request \a id was exposed. + \since 1.1 +*/ + +/*! + \fn QCameraImageCapture::imageCaptured(int id, const QImage &preview); + + Signal emitted when the frame with request \a id was captured, but not processed and saved yet. + Frame \a preview can be displayed to user. + \since 1.1 +*/ + +/*! + \fn QCameraImageCapture::imageMetadataAvailable(int id, QtMultimedia::MetaData key, const QVariant &value) + + Signals that a metadata for an image with request \a id is available. + This signal is emitted for metadata \a value with a \a key listed in QtMultimedia::MetaData enum. + + This signal is emitted between imageExposed and imageSaved signals. + \since 1.2 +*/ + +/*! + \fn QCameraImageCapture::imageMetadataAvailable(int id, const QString &key, const QVariant &value) + + Signals that a metadata for an image with request \a id is available. + This signal is emitted for extended metadata \a value with a \a key not listed in QtMultimedia::MetaData enum. + + This signal is emitted between imageExposed and imageSaved signals. + \since 1.2 +*/ + + +/*! + \fn QCameraImageCapture::imageAvailable(int id, const QVideoFrame &buffer) + + Signal emitted when the frame with request \a id is available as \a buffer. + \since 1.2 +*/ + +/*! + \fn QCameraImageCapture::imageSaved(int id, const QString &fileName) + + Signal emitted when the frame with request \a id was saved to \a fileName. + \since 1.1 +*/ + + +#include "moc_qcameraimagecapture.cpp" +QT_END_NAMESPACE + diff --git a/src/multimedia/qcameraimagecapture.h b/src/multimedia/qcameraimagecapture.h new file mode 100644 index 000000000..bc4162287 --- /dev/null +++ b/src/multimedia/qcameraimagecapture.h @@ -0,0 +1,170 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QCAMERAIMAGECAPTURE_H +#define QCAMERAIMAGECAPTURE_H + +#include +#include +#include +#include + +#include + +QT_BEGIN_HEADER + +QT_BEGIN_NAMESPACE + +QT_MODULE(Multimedia) + +class QSize; +QT_END_NAMESPACE + +QT_BEGIN_NAMESPACE + +class QImageEncoderSettings; + +class QCameraImageCapturePrivate; +class Q_MULTIMEDIA_EXPORT QCameraImageCapture : public QObject, public QMediaBindableInterface +{ + Q_OBJECT + Q_INTERFACES(QMediaBindableInterface) + Q_ENUMS(Error) + Q_ENUMS(CaptureDestination) + Q_PROPERTY(bool readyForCapture READ isReadyForCapture NOTIFY readyForCaptureChanged) +public: + enum Error + { + NoError, + NotReadyError, + ResourceError, + OutOfSpaceError, + NotSupportedFeatureError, + FormatError + }; + + enum DriveMode + { + SingleImageCapture + }; + + enum CaptureDestination + { + CaptureToFile = 0x01, + CaptureToBuffer = 0x02 + }; + Q_DECLARE_FLAGS(CaptureDestinations, CaptureDestination) + + QCameraImageCapture(QMediaObject *mediaObject, QObject *parent = 0); + ~QCameraImageCapture(); + + bool isAvailable() const; + QtMultimedia::AvailabilityError availabilityError() const; + + QMediaObject *mediaObject() const; + + Error error() const; + QString errorString() const; + + bool isReadyForCapture() const; + + QStringList supportedImageCodecs() const; + QString imageCodecDescription(const QString &codecName) const; + + QList supportedResolutions(const QImageEncoderSettings &settings = QImageEncoderSettings(), + bool *continuous = 0) const; + + QImageEncoderSettings encodingSettings() const; + void setEncodingSettings(const QImageEncoderSettings& settings); + + QList supportedBufferFormats() const; + QVideoFrame::PixelFormat bufferFormat() const; + void setBufferFormat(QVideoFrame::PixelFormat format); + + bool isCaptureDestinationSupported(CaptureDestinations destination) const; + CaptureDestinations captureDestination() const; + void setCaptureDestination(CaptureDestinations destination); + +public Q_SLOTS: + int capture(const QString &location = QString()); + void cancelCapture(); + +Q_SIGNALS: + void error(int id, QCameraImageCapture::Error error, const QString &errorString); + + void readyForCaptureChanged(bool); + void bufferFormatChanged(QVideoFrame::PixelFormat); + void captureDestinationChanged(QCameraImageCapture::CaptureDestinations); + + void imageExposed(int id); + void imageCaptured(int id, const QImage &preview); + void imageMetadataAvailable(int id, QtMultimedia::MetaData key, const QVariant &value); + void imageMetadataAvailable(int id, const QString &key, const QVariant &value); + void imageAvailable(int id, const QVideoFrame &image); + void imageSaved(int id, const QString &fileName); + +protected: + bool setMediaObject(QMediaObject *); + + QCameraImageCapturePrivate *d_ptr; +private: + Q_DISABLE_COPY(QCameraImageCapture) + Q_DECLARE_PRIVATE(QCameraImageCapture) + Q_PRIVATE_SLOT(d_func(), void _q_error(int, int, const QString &)) + Q_PRIVATE_SLOT(d_func(), void _q_readyChanged(bool)) + Q_PRIVATE_SLOT(d_func(), void _q_serviceDestroyed()) +}; + +Q_DECLARE_OPERATORS_FOR_FLAGS(QCameraImageCapture::CaptureDestinations) + +QT_END_NAMESPACE + +Q_DECLARE_METATYPE(QCameraImageCapture::Error) +Q_DECLARE_METATYPE(QCameraImageCapture::CaptureDestination) +Q_DECLARE_METATYPE(QCameraImageCapture::CaptureDestinations) + +Q_MEDIA_ENUM_DEBUG(QCameraImageCapture, Error) +Q_MEDIA_ENUM_DEBUG(QCameraImageCapture, CaptureDestination) + +QT_END_HEADER + +#endif + diff --git a/src/multimedia/qcameraimagecapturecontrol.cpp b/src/multimedia/qcameraimagecapturecontrol.cpp new file mode 100644 index 000000000..ad4c55edb --- /dev/null +++ b/src/multimedia/qcameraimagecapturecontrol.cpp @@ -0,0 +1,208 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include +#include + +QT_BEGIN_NAMESPACE + +/*! + \class QCameraImageCaptureControl + + \brief The QCameraImageCaptureControl class provides a control interface + for image capture services. + + \inmodule QtMultimedia + \ingroup multimedia-serv + \since 1.1 + + + + The interface name of QCameraImageCaptureControl is \c com.nokia.Qt.QCameraImageCaptureControl/1.0 as + defined in QCameraImageCaptureControl_iid. + + + \sa QMediaService::requestControl() +*/ + +/*! + \macro QCameraImageCaptureControl_iid + + \c com.nokia.Qt.QCameraImageCaptureControl/1.0 + + Defines the interface name of the QCameraImageCaptureControl class. + + \relates QCameraImageCaptureControl +*/ + +/*! + Constructs a new image capture control object with the given \a parent +*/ +QCameraImageCaptureControl::QCameraImageCaptureControl(QObject *parent) + :QMediaControl(parent) +{ +} + +/*! + Destroys an image capture control. +*/ +QCameraImageCaptureControl::~QCameraImageCaptureControl() +{ +} + +/*! + \fn QCameraImageCaptureControl::isReadyForCapture() const + + Identifies if a capture control is ready to perform a capture + immediately (all the resources necessary for image capture are allocated, + hardware initialized, flash is charged, etc). + + Returns true if the camera is ready for capture; and false if it is not. + \since 1.1 +*/ + +/*! + \fn QCameraImageCaptureControl::readyForCaptureChanged(bool ready) + + Signals that a capture control's \a ready state has changed. + \since 1.1 +*/ + +/*! + \fn QCameraImageCaptureControl::capture(const QString &fileName) + + Initiates the capture of an image to \a fileName. + The \a fileName can be relative or empty, + in this case the service should use the system specific place + and file naming scheme. + + Returns the capture request id number, which is used later + with imageExposed(), imageCaptured() and imageSaved() signals. + \since 1.1 +*/ + +/*! + \fn QCameraImageCaptureControl::cancelCapture() + + Cancel pending capture requests. + \since 1.1 +*/ + +/*! + \fn QCameraImageCaptureControl::imageExposed(int requestId) + + Signals that an image with it \a requestId + has just been exposed. + This signal can be used for the shutter sound or other indicaton. + \since 1.1 +*/ + +/*! + \fn QCameraImageCaptureControl::imageCaptured(int requestId, const QImage &preview) + + Signals that an image with it \a requestId + has been captured and a \a preview is available. + \since 1.1 +*/ + +/*! + \fn QCameraImageCaptureControl::imageMetadataAvailable(int id, QtMultimedia::MetaData key, const QVariant &value) + + Signals that a metadata for an image with request \a id is available. + This signal is emitted for metadata \a value with a \a key listed in QtMultimedia::MetaData enum. + + This signal should be emitted between imageExposed and imageSaved signals. + \since 1.2 +*/ + +/*! + \fn QCameraImageCaptureControl::imageMetadataAvailable(int id, const QString &key, const QVariant &value) + + Signals that a metadata for an image with request \a id is available. + This signal is emitted for extended metadata \a value with a \a key not listed in QtMultimedia::MetaData enum. + + This signal should be emitted between imageExposed and imageSaved signals. + \since 1.2 +*/ + +/*! + \fn QCameraImageCaptureControl::imageAvailable(int requestId, const QVideoFrame &buffer) + + Signals that a captured \a buffer with a \a requestId is available. + \since 1.2 +*/ + +/*! + \fn QCameraImageCaptureControl::imageSaved(int requestId, const QString &fileName) + + Signals that a captured image with a \a requestId has been saved + to \a fileName. + \since 1.1 +*/ + +/*! + \fn QCameraImageCaptureControl::driveMode() const + + Returns the current camera drive mode. + \since 1.1 +*/ + +/*! + \fn QCameraImageCaptureControl::setDriveMode(QCameraImageCapture::DriveMode mode) + + Sets the current camera drive \a mode. + \since 1.1 +*/ + + +/*! + \fn QCameraImageCaptureControl::error(int id, int error, const QString &errorString) + + Signals the capture request \a id failed with \a error code and message \a errorString. + + \since 1.1 + \sa QCameraImageCapture::Error +*/ + + +#include "moc_qcameraimagecapturecontrol.cpp" +QT_END_NAMESPACE + diff --git a/src/multimedia/qcameraimagecapturecontrol.h b/src/multimedia/qcameraimagecapturecontrol.h new file mode 100644 index 000000000..0459c1417 --- /dev/null +++ b/src/multimedia/qcameraimagecapturecontrol.h @@ -0,0 +1,99 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QCAMERAIMAGECAPTURECONTROL_H +#define QCAMERAIMAGECAPTURECONTROL_H + +#include +#include + +QT_BEGIN_HEADER + +QT_BEGIN_NAMESPACE + +QT_MODULE(Multimedia) + +class QImage; +QT_END_NAMESPACE + +QT_BEGIN_NAMESPACE + +class Q_MULTIMEDIA_EXPORT QCameraImageCaptureControl : public QMediaControl +{ + Q_OBJECT + +public: + ~QCameraImageCaptureControl(); + + virtual bool isReadyForCapture() const = 0; + + virtual QCameraImageCapture::DriveMode driveMode() const = 0; + virtual void setDriveMode(QCameraImageCapture::DriveMode mode) = 0; + + virtual int capture(const QString &fileName) = 0; + virtual void cancelCapture() = 0; + +Q_SIGNALS: + void readyForCaptureChanged(bool); + + void imageExposed(int id); + void imageCaptured(int id, const QImage &preview); + void imageMetadataAvailable(int id, QtMultimedia::MetaData key, const QVariant &value); + void imageMetadataAvailable(int id, const QString &key, const QVariant &value); + void imageAvailable(int id, const QVideoFrame &buffer); + void imageSaved(int id, const QString &fileName); + + void error(int id, int error, const QString &errorString); + +protected: + QCameraImageCaptureControl(QObject* parent = 0); +}; + +#define QCameraImageCaptureControl_iid "com.nokia.Qt.QCameraImageCaptureControl/1.0" +Q_MEDIA_DECLARE_CONTROL(QCameraImageCaptureControl, QCameraImageCaptureControl_iid) + +QT_END_NAMESPACE + +QT_END_HEADER + + +#endif // QCAMERAIMAGECAPTURECONTROL_H + diff --git a/src/multimedia/qcameraimageprocessing.cpp b/src/multimedia/qcameraimageprocessing.cpp new file mode 100644 index 000000000..600dfd885 --- /dev/null +++ b/src/multimedia/qcameraimageprocessing.cpp @@ -0,0 +1,352 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +QT_BEGIN_NAMESPACE + +/*! + \class QCameraImageProcessing + + + \brief The QCameraImageProcessing class provides interface for + focus and zoom related camera settings. + + \inmodule QtMultimedia + \ingroup camera + \since 1.1 + +*/ + + +class QCameraImageProcessingPrivate : public QMediaObjectPrivate +{ + Q_DECLARE_NON_CONST_PUBLIC(QCameraImageProcessing) +public: + void initControls(); + + QCameraImageProcessing *q_ptr; + + QCamera *camera; + QCameraImageProcessingControl *imageControl; +}; + + +void QCameraImageProcessingPrivate::initControls() +{ + imageControl = 0; + + QMediaService *service = camera->service(); + if (service) + imageControl = qobject_cast(service->requestControl(QCameraImageProcessingControl_iid)); +} + +/*! + Construct a QCameraImageProcessing for \a camera. +*/ + +QCameraImageProcessing::QCameraImageProcessing(QCamera *camera): + QObject(camera), d_ptr(new QCameraImageProcessingPrivate) +{ + Q_D(QCameraImageProcessing); + d->camera = camera; + d->q_ptr = this; + d->initControls(); +} + + +/*! + Destroys the camera focus object. +*/ + +QCameraImageProcessing::~QCameraImageProcessing() +{ +} + + +/*! + Returns true if image processing related settings are supported by this camera. + \since 1.1 +*/ +bool QCameraImageProcessing::isAvailable() const +{ + return d_func()->imageControl != 0; +} + + +/*! + Returns the white balance mode being used. + \since 1.1 +*/ + +QCameraImageProcessing::WhiteBalanceMode QCameraImageProcessing::whiteBalanceMode() const +{ + return d_func()->imageControl ? d_func()->imageControl->whiteBalanceMode() : QCameraImageProcessing::WhiteBalanceAuto; +} + +/*! + Sets the white balance to \a mode. + \since 1.1 +*/ + +void QCameraImageProcessing::setWhiteBalanceMode(QCameraImageProcessing::WhiteBalanceMode mode) +{ + if (d_func()->imageControl) + d_func()->imageControl->setWhiteBalanceMode(mode); +} + +/*! + Returns true if the white balance \a mode is supported. + \since 1.1 +*/ + +bool QCameraImageProcessing::isWhiteBalanceModeSupported(QCameraImageProcessing::WhiteBalanceMode mode) const +{ + return d_func()->imageControl ? d_func()->imageControl->isWhiteBalanceModeSupported(mode) : false; +} + +/*! + Returns the current color temperature if the + manual white balance is active, otherwise the + return value is undefined. + \since 1.1 +*/ + +int QCameraImageProcessing::manualWhiteBalance() const +{ + QVariant value; + + if (d_func()->imageControl) + value = d_func()->imageControl->processingParameter(QCameraImageProcessingControl::ColorTemperature); + + return value.toInt(); +} + +/*! + Sets manual white balance to \a colorTemperature + \since 1.1 +*/ + +void QCameraImageProcessing::setManualWhiteBalance(int colorTemperature) +{ + if (d_func()->imageControl) { + d_func()->imageControl->setProcessingParameter( + QCameraImageProcessingControl::ColorTemperature, + QVariant(colorTemperature)); + } +} + +/*! + Return the contrast. + \since 1.1 +*/ +int QCameraImageProcessing::contrast() const +{ + QVariant value; + + if (d_func()->imageControl) + value = d_func()->imageControl->processingParameter(QCameraImageProcessingControl::Contrast); + + return value.toInt(); +} + +/*! + Set the contrast to \a value. + + Valid contrast values range between -100 and 100, the default is 0. + \since 1.1 +*/ +void QCameraImageProcessing::setContrast(int value) +{ + if (d_func()->imageControl) + d_func()->imageControl->setProcessingParameter(QCameraImageProcessingControl::Contrast, + QVariant(value)); +} + +/*! + Returns the saturation value. + \since 1.1 +*/ +int QCameraImageProcessing::saturation() const +{ + QVariant value; + + if (d_func()->imageControl) + value = d_func()->imageControl->processingParameter(QCameraImageProcessingControl::Saturation); + + return value.toInt(); +} + +/*! + Sets the saturation value to \a value. + + Valid saturation values range between -100 and 100, the default is 0. + \since 1.1 +*/ + +void QCameraImageProcessing::setSaturation(int value) +{ + if (d_func()->imageControl) + d_func()->imageControl->setProcessingParameter(QCameraImageProcessingControl::Saturation, + QVariant(value)); +} + +/*! + Identifies if sharpening is supported. + + Returns true if sharpening is supported; and false if it is not. + \since 1.1 +*/ +bool QCameraImageProcessing::isSharpeningSupported() const +{ + if (d_func()->imageControl) + return d_func()->imageControl->isProcessingParameterSupported(QCameraImageProcessingControl::Sharpening); + else + return false; +} + +/*! + Returns the sharpening level. + \since 1.1 +*/ +int QCameraImageProcessing::sharpeningLevel() const +{ + QVariant value; + + if (d_func()->imageControl) + value = d_func()->imageControl->processingParameter(QCameraImageProcessingControl::Sharpening); + + if (value.isNull()) + return -1; + else + return value.toInt(); +} + +/*! + Sets the sharpening \a level. + + Valid sharpening level values range between -1 for default sharpening level, + 0 for sharpening disabled and 100 for maximum sharpening applied. + \since 1.1 +*/ + +void QCameraImageProcessing::setSharpeningLevel(int level) +{ + Q_D(QCameraImageProcessing); + if (d->imageControl) + d->imageControl->setProcessingParameter(QCameraImageProcessingControl::Sharpening, + level == -1 ? QVariant() : QVariant(level)); +} + +/*! + Returns true if denoising is supported. + \since 1.1 +*/ +bool QCameraImageProcessing::isDenoisingSupported() const +{ + if (d_func()->imageControl) + return d_func()->imageControl->isProcessingParameterSupported(QCameraImageProcessingControl::Denoising); + else + return false; +} + +/*! + Returns the denoising level. + \since 1.1 +*/ +int QCameraImageProcessing::denoisingLevel() const +{ + QVariant value; + + if (d_func()->imageControl) + value = d_func()->imageControl->processingParameter(QCameraImageProcessingControl::Denoising); + + if (value.isNull()) + return -1; + else + return value.toInt(); +} + +/*! + Sets the denoising \a level. + + Valid denoising level values range between -1 for default denoising level, + 0 for denoising disabled and 100 for maximum denoising applied. + \since 1.1 +*/ +void QCameraImageProcessing::setDenoisingLevel(int level) +{ + Q_D(QCameraImageProcessing); + if (d->imageControl) + d->imageControl->setProcessingParameter(QCameraImageProcessingControl::Denoising, + level == -1 ? QVariant() : QVariant(level)); +} + + +/*! + \enum QCameraImageProcessing::WhiteBalanceMode + + \value WhiteBalanceManual Manual white balance. In this mode the white balance should be set with + setManualWhiteBalance() + \value WhiteBalanceAuto Auto white balance mode. + \value WhiteBalanceSunlight Sunlight white balance mode. + \value WhiteBalanceCloudy Cloudy white balance mode. + \value WhiteBalanceShade Shade white balance mode. + \value WhiteBalanceTungsten Tungsten white balance mode. + \value WhiteBalanceFluorescent Fluorescent white balance mode. + \value WhiteBalanceFlash Flash white balance mode. + \value WhiteBalanceSunset Sunset white balance mode. + \value WhiteBalanceVendor Vendor defined white balance mode. +*/ + +#include "moc_qcameraimageprocessing.cpp" +QT_END_NAMESPACE diff --git a/src/multimedia/qcameraimageprocessing.h b/src/multimedia/qcameraimageprocessing.h new file mode 100644 index 000000000..42a7eb589 --- /dev/null +++ b/src/multimedia/qcameraimageprocessing.h @@ -0,0 +1,124 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QCAMERAIMAGEPROCESSING_H +#define QCAMERAIMAGEPROCESSING_H + +#include +#include +#include +#include +#include + +#include +#include +#include +#include + +QT_BEGIN_HEADER + +QT_BEGIN_NAMESPACE + +QT_MODULE(Multimedia) + + +class QCamera; + +class QCameraImageProcessingPrivate; +class Q_MULTIMEDIA_EXPORT QCameraImageProcessing : public QObject +{ + Q_OBJECT + Q_ENUMS(WhiteBalanceMode) +public: + enum WhiteBalanceMode { + WhiteBalanceAuto = 0, + WhiteBalanceManual = 1, + WhiteBalanceSunlight = 2, + WhiteBalanceCloudy = 3, + WhiteBalanceShade = 4, + WhiteBalanceTungsten = 5, + WhiteBalanceFluorescent = 6, + WhiteBalanceFlash = 7, + WhiteBalanceSunset = 8, + WhiteBalanceVendor = 1000 + }; + + bool isAvailable() const; + + WhiteBalanceMode whiteBalanceMode() const; + void setWhiteBalanceMode(WhiteBalanceMode mode); + bool isWhiteBalanceModeSupported(WhiteBalanceMode mode) const; + int manualWhiteBalance() const; + void setManualWhiteBalance(int colorTemperature); + + int contrast() const; + void setContrast(int value); + + int saturation() const; + void setSaturation(int value); + + bool isSharpeningSupported() const; + int sharpeningLevel() const; + void setSharpeningLevel(int value); + + bool isDenoisingSupported() const; + int denoisingLevel() const; + void setDenoisingLevel(int value); + +private: + friend class QCamera; + QCameraImageProcessing(QCamera *camera); + ~QCameraImageProcessing(); + + Q_DISABLE_COPY(QCameraImageProcessing) + Q_DECLARE_PRIVATE(QCameraImageProcessing) + QCameraImageProcessingPrivate *d_ptr; +}; + +QT_END_NAMESPACE + +Q_DECLARE_METATYPE(QCameraImageProcessing::WhiteBalanceMode) + +Q_MEDIA_ENUM_DEBUG(QCameraImageProcessing, WhiteBalanceMode) + +QT_END_HEADER + +#endif // QCAMERAIMAGEPROCESSING_H diff --git a/src/multimedia/qcameraimageprocessingcontrol.cpp b/src/multimedia/qcameraimageprocessingcontrol.cpp new file mode 100644 index 000000000..5e318cc83 --- /dev/null +++ b/src/multimedia/qcameraimageprocessingcontrol.cpp @@ -0,0 +1,169 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include +#include "qmediacontrol_p.h" + +QT_BEGIN_NAMESPACE + +/*! + \class QCameraImageProcessingControl + \inmodule QtMultimedia + \ingroup multimedia-serv + \since 1.1 + + + \brief The QCameraImageProcessingControl class provides an abstract class + for controlling image processing parameters, like white balance, + contrast, saturation, sharpening and denoising. + + The interface name of QCameraImageProcessingControl is \c com.nokia.Qt.QCameraImageProcessingControl/1.0 as + defined in QCameraImageProcessingControl_iid. + + + + \sa QMediaService::requestControl(), QCamera +*/ + +/*! + \macro QCameraImageProcessingControl_iid + + \c com.nokia.Qt.QCameraImageProcessingControl/1.0 + + Defines the interface name of the QCameraImageProcessingControl class. + + \relates QCameraImageProcessingControl +*/ + +/*! + Constructs an image processing control object with \a parent. +*/ + +QCameraImageProcessingControl::QCameraImageProcessingControl(QObject *parent): + QMediaControl(*new QMediaControlPrivate, parent) +{ +} + +/*! + Destruct the image processing control object. +*/ + +QCameraImageProcessingControl::~QCameraImageProcessingControl() +{ +} + + +/*! + \fn QCameraImageProcessingControl::whiteBalanceMode() const + Return the white balance mode being used. + \since 1.1 +*/ + +/*! + \fn QCameraImageProcessingControl::setWhiteBalanceMode(QCameraImageProcessing::WhiteBalanceMode mode) + Set the white balance mode to \a mode + \since 1.1 +*/ + +/*! + \fn QCameraImageProcessingControl::isWhiteBalanceModeSupported(QCameraImageProcessing::WhiteBalanceMode mode) const + Returns true if the white balance \a mode is supported. + The backend should support at least QCameraImageProcessing::WhiteBalanceAuto mode. + \since 1.1 +*/ + +/*! + \fn bool QCameraImageProcessingControl::isProcessingParameterSupported(ProcessingParameter parameter) const + + Returns true if the camera supports adjusting image processing \a parameter. + + Usually the the supported settings is static, + but some parameter may not be available depending on other + camera settings, like presets. + In such case the currently supported parameters should be returned. + \since 1.1 +*/ + +/*! + \fn QCameraImageProcessingControl::processingParameter(ProcessingParameter parameter) const + Returns the image processing \a parameter value. + \since 1.1 +*/ + +/*! + \fn QCameraImageProcessingControl::setProcessingParameter(ProcessingParameter parameter, QVariant value) + + Sets the image processing \a parameter \a value. + Passing the null or invalid QVariant value allows + backend to choose the suitable parameter value. + + The valid values range depends on the parameter type, + for contrast, saturation and brightness value should be + between -100 and 100, the default is 0, + + For sharpening and denoising the range is 0..100, + 0 for sharpening or denoising disabled + and 100 for maximum sharpening/denoising applied. + \since 1.1 +*/ + +/*! + \enum QCameraImageProcessingControl::ProcessingParameter + + \value Contrast + Image contrast. + \value Saturation + Image saturation. + \value Brightness + Image brightness. + \value Sharpening + Amount of sharpening applied. + \value Denoising + Amount of denoising applied. + \value ColorTemperature + Color temperature in K. This value is used when the manual white balance mode is selected. + \value ExtendedParameter + The base value for platform specific extended parameters. + */ + +#include "moc_qcameraimageprocessingcontrol.cpp" +QT_END_NAMESPACE + diff --git a/src/multimedia/qcameraimageprocessingcontrol.h b/src/multimedia/qcameraimageprocessingcontrol.h new file mode 100644 index 000000000..8c739287c --- /dev/null +++ b/src/multimedia/qcameraimageprocessingcontrol.h @@ -0,0 +1,100 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QCAMERAIMAGEPROCESSINGCONTROL_H +#define QCAMERAIMAGEPROCESSINGCONTROL_H + +#include +#include + +#include +#include + +QT_BEGIN_HEADER + +QT_BEGIN_NAMESPACE + +QT_MODULE(Multimedia) + + +class Q_MULTIMEDIA_EXPORT QCameraImageProcessingControl : public QMediaControl +{ + Q_OBJECT + Q_ENUMS(ProcessingParameter) + +public: + ~QCameraImageProcessingControl(); + + enum ProcessingParameter { + Contrast = 0, + Saturation = 1, + Brightness = 2, + Sharpening = 3, + Denoising = 4, + ColorTemperature = 5, + ExtendedParameter = 1000 + }; + + virtual QCameraImageProcessing::WhiteBalanceMode whiteBalanceMode() const = 0; + virtual void setWhiteBalanceMode(QCameraImageProcessing::WhiteBalanceMode mode) = 0; + virtual bool isWhiteBalanceModeSupported(QCameraImageProcessing::WhiteBalanceMode) const = 0; + + virtual bool isProcessingParameterSupported(ProcessingParameter) const = 0; + virtual QVariant processingParameter(ProcessingParameter parameter) const = 0; + virtual void setProcessingParameter(ProcessingParameter parameter, QVariant value) = 0; + +protected: + QCameraImageProcessingControl(QObject* parent = 0); +}; + +#define QCameraImageProcessingControl_iid "com.nokia.Qt.QCameraImageProcessingControl/1.0" +Q_MEDIA_DECLARE_CONTROL(QCameraImageProcessingControl, QCameraImageProcessingControl_iid) + +QT_END_NAMESPACE + +Q_DECLARE_METATYPE(QCameraImageProcessingControl::ProcessingParameter) + +Q_MEDIA_ENUM_DEBUG(QCameraImageProcessingControl, ProcessingParameter) + +QT_END_HEADER + +#endif + diff --git a/src/multimedia/qcameralockscontrol.cpp b/src/multimedia/qcameralockscontrol.cpp new file mode 100644 index 000000000..289a07bf5 --- /dev/null +++ b/src/multimedia/qcameralockscontrol.cpp @@ -0,0 +1,134 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include +#include "qmediacontrol_p.h" + +QT_BEGIN_NAMESPACE + +/*! + \class QCameraLocksControl + + + + \brief The QCameraLocksControl class is an abstract base class for + classes that control still cameras or video cameras. + + \inmodule QtMultimedia + \ingroup multimedia-serv + \since 1.1 + + This service is provided by a QMediaService object via + QMediaService::control(). It is used by QCamera. + + The interface name of QCameraLocksControl is \c com.nokia.Qt.QCameraLocksControl/1.0 as + defined in QCameraLocksControl_iid. + + + \sa QMediaService::requestControl(), QCamera +*/ + +/*! + \macro QCameraLocksControl_iid + + \c com.nokia.Qt.QCameraLocksControl/1.0 + + Defines the interface name of the QCameraLocksControl class. + + \relates QCameraLocksControl +*/ + +/*! + Constructs a camera locks control object with \a parent. +*/ + +QCameraLocksControl::QCameraLocksControl(QObject *parent): + QMediaControl(*new QMediaControlPrivate, parent) +{ +} + +/*! + Destruct the camera locks control object. +*/ + +QCameraLocksControl::~QCameraLocksControl() +{ +} + +/*! + \fn QCameraLocksControl::supportedLocks() const + + Returns the lock types, the camera supports. + \since 1.1 +*/ + +/*! + \fn QCameraLocksControl::lockStatus(QCamera::LockType lock) const + + Returns the camera \a lock status. + \since 1.1 +*/ + +/*! + \fn QCameraLocksControl::searchAndLock(QCamera::LockTypes locks) + + Request camera \a locks. + \since 1.1 +*/ + +/*! + \fn QCameraLocksControl::unlock(QCamera::LockTypes locks) + + Unlock camera \a locks. + \since 1.1 +*/ + +/*! + \fn QCameraLocksControl::lockStatusChanged(QCamera::LockType lock, QCamera::LockStatus status, QCamera::LockChangeReason reason) + + Signals the \a lock \a status was changed with a specified \a reason. + \since 1.1 +*/ + + + +#include "moc_qcameralockscontrol.cpp" +QT_END_NAMESPACE diff --git a/src/multimedia/qcameralockscontrol.h b/src/multimedia/qcameralockscontrol.h new file mode 100644 index 000000000..93120ee1a --- /dev/null +++ b/src/multimedia/qcameralockscontrol.h @@ -0,0 +1,86 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QCAMERALOCKSCONTROL_H +#define QCAMERALOCKSCONTROL_H + +#include +#include + +#include + +QT_BEGIN_HEADER + +QT_BEGIN_NAMESPACE + +QT_MODULE(Multimedia) + + +class Q_MULTIMEDIA_EXPORT QCameraLocksControl : public QMediaControl +{ + Q_OBJECT +public: + ~QCameraLocksControl(); + + virtual QCamera::LockTypes supportedLocks() const = 0; + + virtual QCamera::LockStatus lockStatus(QCamera::LockType lock) const = 0; + + virtual void searchAndLock(QCamera::LockTypes locks) = 0; + virtual void unlock(QCamera::LockTypes locks) = 0; + +Q_SIGNALS: + void lockStatusChanged(QCamera::LockType type, QCamera::LockStatus status, QCamera::LockChangeReason reason); + +protected: + QCameraLocksControl(QObject* parent = 0); +}; + +#define QCameraLocksControl_iid "com.nokia.Qt.QCameraLocksControl/1.0" +Q_MEDIA_DECLARE_CONTROL(QCameraLocksControl, QCameraLocksControl_iid) + +QT_END_NAMESPACE + +QT_END_HEADER + + +#endif // QCAMERALOCKSCONTROL_H + diff --git a/src/multimedia/qimageencodercontrol.cpp b/src/multimedia/qimageencodercontrol.cpp new file mode 100644 index 000000000..ee62a502d --- /dev/null +++ b/src/multimedia/qimageencodercontrol.cpp @@ -0,0 +1,142 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qimageencodercontrol.h" +#include + +QT_BEGIN_NAMESPACE + +/*! + \class QImageEncoderControl + + \inmodule QtMultimedia + \ingroup multimedia-serv + \since 1.0 + + \brief The QImageEncoderControl class provides access to the settings of a media service that + performs image encoding. + + If a QMediaService supports encoding image data it will implement QImageEncoderControl. + This control allows to \l {setImageSettings()}{set image encoding settings} and + provides functions for quering supported image \l {supportedImageCodecs()}{codecs} and + \l {supportedResolutions()}{resolutions}. + + The interface name of QImageEncoderControl is \c com.nokia.Qt.QImageEncoderControl/1.0 as + defined in QImageEncoderControl_iid. + + \sa QImageEncoderSettings, QMediaService::requestControl() +*/ + +/*! + \macro QImageEncoderControl_iid + + \c com.nokia.Qt.QImageEncoderControl/1.0 + + Defines the interface name of the QImageEncoderControl class. + + \relates QImageEncoderControl +*/ + +/*! + Constructs a new image encoder control object with the given \a parent +*/ +QImageEncoderControl::QImageEncoderControl(QObject *parent) + :QMediaControl(parent) +{ +} + +/*! + Destroys the image encoder control. +*/ +QImageEncoderControl::~QImageEncoderControl() +{ +} + +/*! + \fn QImageEncoderControl::supportedResolutions(const QImageEncoderSettings &settings = QImageEncoderSettings(), + bool *continuous = 0) const + + Returns a list of supported resolutions. + + If non null image \a settings parameter is passed, + the returned list is reduced to resolutions supported with partial settings applied. + It can be used to query the list of resolutions, supported by specific image codec. + + If the encoder supports arbitrary resolutions within the supported resolutions range, + *\a continuous is set to true, otherwise *\a continuous is set to false. + \since 1.0 +*/ + +/*! + \fn QImageEncoderControl::supportedImageCodecs() const + + Returns a list of supported image codecs. + \since 1.0 +*/ + +/*! + \fn QImageEncoderControl::imageCodecDescription(const QString &codec) const + + Returns a description of an image \a codec. + \since 1.0 +*/ + +/*! + \fn QImageEncoderControl::imageSettings() const + + Returns the currently used image encoder settings. + + The returned value may be different tha passed to QImageEncoderControl::setImageSettings() + if the settings contains the default or undefined parameters. + In this case if the undefined parameters are already resolved, they should be returned. + \since 1.0 +*/ + +/*! + \fn QImageEncoderControl::setImageSettings(const QImageEncoderSettings &settings) + + Sets the selected image encoder \a settings. + \since 1.0 +*/ + +#include "moc_qimageencodercontrol.cpp" +QT_END_NAMESPACE + diff --git a/src/multimedia/qimageencodercontrol.h b/src/multimedia/qimageencodercontrol.h new file mode 100644 index 000000000..c8a8261a4 --- /dev/null +++ b/src/multimedia/qimageencodercontrol.h @@ -0,0 +1,91 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QIMAGEENCODERCONTROL_H +#define QIMAGEENCODERCONTROL_H + +#include "qmediacontrol.h" +#include "qmediarecorder.h" +#include "qmediaencodersettings.h" + +#include + +QT_BEGIN_HEADER + +QT_BEGIN_NAMESPACE + +QT_MODULE(Multimedia) + +class QByteArray; +class QStringList; +QT_END_NAMESPACE + +QT_BEGIN_NAMESPACE + +class Q_MULTIMEDIA_EXPORT QImageEncoderControl : public QMediaControl +{ + Q_OBJECT + +public: + virtual ~QImageEncoderControl(); + + virtual QStringList supportedImageCodecs() const = 0; + virtual QString imageCodecDescription(const QString &codecName) const = 0; + + virtual QList supportedResolutions(const QImageEncoderSettings &settings, + bool *continuous = 0) const = 0; + + virtual QImageEncoderSettings imageSettings() const = 0; + virtual void setImageSettings(const QImageEncoderSettings &settings) = 0; + +protected: + QImageEncoderControl(QObject *parent = 0); +}; + +#define QImageEncoderControl_iid "com.nokia.Qt.QImageEncoderControl/1.0" +Q_MEDIA_DECLARE_CONTROL(QImageEncoderControl, QImageEncoderControl_iid) + +QT_END_NAMESPACE + +QT_END_HEADER + + +#endif diff --git a/src/multimedia/qlocalmediaplaylistprovider.cpp b/src/multimedia/qlocalmediaplaylistprovider.cpp new file mode 100644 index 000000000..84d54ecfd --- /dev/null +++ b/src/multimedia/qlocalmediaplaylistprovider.cpp @@ -0,0 +1,194 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qlocalmediaplaylistprovider.h" +#include "qmediaplaylistprovider_p.h" +#include "qmediacontent.h" + +QT_BEGIN_NAMESPACE + +class QLocalMediaPlaylistProviderPrivate: public QMediaPlaylistProviderPrivate +{ +public: + QList resources; +}; + +QLocalMediaPlaylistProvider::QLocalMediaPlaylistProvider(QObject *parent) + :QMediaPlaylistProvider(*new QLocalMediaPlaylistProviderPrivate, parent) +{ +} + +QLocalMediaPlaylistProvider::~QLocalMediaPlaylistProvider() +{ +} + +bool QLocalMediaPlaylistProvider::isReadOnly() const +{ + return false; +} + +int QLocalMediaPlaylistProvider::mediaCount() const +{ + return d_func()->resources.size(); +} + +QMediaContent QLocalMediaPlaylistProvider::media(int pos) const +{ + return d_func()->resources.value(pos); +} + +bool QLocalMediaPlaylistProvider::addMedia(const QMediaContent &content) +{ + Q_D(QLocalMediaPlaylistProvider); + + int pos = d->resources.count(); + + emit mediaAboutToBeInserted(pos, pos); + d->resources.append(content); + emit mediaInserted(pos, pos); + + return true; +} + +bool QLocalMediaPlaylistProvider::addMedia(const QList &items) +{ + Q_D(QLocalMediaPlaylistProvider); + + if (items.isEmpty()) + return true; + + int pos = d->resources.count(); + int end = pos+items.count()-1; + + emit mediaAboutToBeInserted(pos, end); + d->resources.append(items); + emit mediaInserted(pos, end); + + return true; +} + + +bool QLocalMediaPlaylistProvider::insertMedia(int pos, const QMediaContent &content) +{ + Q_D(QLocalMediaPlaylistProvider); + + emit mediaAboutToBeInserted(pos, pos); + d->resources.insert(pos, content); + emit mediaInserted(pos,pos); + + return true; +} + +bool QLocalMediaPlaylistProvider::insertMedia(int pos, const QList &items) +{ + Q_D(QLocalMediaPlaylistProvider); + + if (items.isEmpty()) + return true; + + const int last = pos+items.count()-1; + + emit mediaAboutToBeInserted(pos, last); + for (int i=0; iresources.insert(pos+i, items.at(i)); + emit mediaInserted(pos, last); + + return true; +} + +bool QLocalMediaPlaylistProvider::removeMedia(int fromPos, int toPos) +{ + Q_D(QLocalMediaPlaylistProvider); + + Q_ASSERT(fromPos >= 0); + Q_ASSERT(fromPos <= toPos); + Q_ASSERT(toPos < mediaCount()); + + emit mediaAboutToBeRemoved(fromPos, toPos); + d->resources.erase(d->resources.begin()+fromPos, d->resources.begin()+toPos+1); + emit mediaRemoved(fromPos, toPos); + + return true; +} + +bool QLocalMediaPlaylistProvider::removeMedia(int pos) +{ + Q_D(QLocalMediaPlaylistProvider); + + emit mediaAboutToBeRemoved(pos, pos); + d->resources.removeAt(pos); + emit mediaRemoved(pos, pos); + + return true; +} + +bool QLocalMediaPlaylistProvider::clear() +{ + Q_D(QLocalMediaPlaylistProvider); + if (!d->resources.isEmpty()) { + int lastPos = mediaCount()-1; + emit mediaAboutToBeRemoved(0, lastPos); + d->resources.clear(); + emit mediaRemoved(0, lastPos); + } + + return true; +} + +void QLocalMediaPlaylistProvider::shuffle() +{ + Q_D(QLocalMediaPlaylistProvider); + if (!d->resources.isEmpty()) { + QList resources; + + while (!d->resources.isEmpty()) { + resources.append(d->resources.takeAt(qrand() % d->resources.size())); + } + + d->resources = resources; + emit mediaChanged(0, mediaCount()-1); + } + +} + +#include "moc_qlocalmediaplaylistprovider.cpp" +QT_END_NAMESPACE + diff --git a/src/multimedia/qlocalmediaplaylistprovider.h b/src/multimedia/qlocalmediaplaylistprovider.h new file mode 100644 index 000000000..e712a3f73 --- /dev/null +++ b/src/multimedia/qlocalmediaplaylistprovider.h @@ -0,0 +1,87 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QLOCALMEDIAPAYLISTPROVIDER_H +#define QLOCALMEDIAPAYLISTPROVIDER_H + +#include "qmediaplaylistprovider.h" + +QT_BEGIN_HEADER + +QT_BEGIN_NAMESPACE + +QT_MODULE(Multimedia) + + +class QLocalMediaPlaylistProviderPrivate; +class Q_MULTIMEDIA_EXPORT QLocalMediaPlaylistProvider : public QMediaPlaylistProvider +{ + Q_OBJECT +public: + QLocalMediaPlaylistProvider(QObject *parent=0); + virtual ~QLocalMediaPlaylistProvider(); + + virtual int mediaCount() const; + virtual QMediaContent media(int pos) const; + + virtual bool isReadOnly() const; + + virtual bool addMedia(const QMediaContent &content); + virtual bool addMedia(const QList &items); + virtual bool insertMedia(int pos, const QMediaContent &content); + virtual bool insertMedia(int pos, const QList &items); + virtual bool removeMedia(int pos); + virtual bool removeMedia(int start, int end); + virtual bool clear(); + +public Q_SLOTS: + virtual void shuffle(); + +private: + Q_DECLARE_PRIVATE(QLocalMediaPlaylistProvider) +}; + +QT_END_NAMESPACE + +QT_END_HEADER + + +#endif // QLOCALMEDIAPAYLISTSOURCE_H diff --git a/src/multimedia/qmediabackgroundplaybackcontrol.cpp b/src/multimedia/qmediabackgroundplaybackcontrol.cpp new file mode 100644 index 000000000..d7cbd380a --- /dev/null +++ b/src/multimedia/qmediabackgroundplaybackcontrol.cpp @@ -0,0 +1,149 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qmediabackgroundplaybackcontrol.h" +#include "qmediacontrol_p.h" + +QT_BEGIN_NAMESPACE + + +/*! + \class QMediaBackgroundPlaybackControl + \inmodule QtMultimedia + \ingroup multimedia + \since 5.0 + + + \brief The QMediaBackgroundPlaybackControl class provides access to the background playback + related control of a QMediaService. + + If a QMediaService can play media in background, it should implement QMediaBackgroundPlaybackControl. + This control provides a means to set the \l {setContextId()}{contextId} for application, + \l {acquire()}{acquire the resource for playback} and \l {release()} {release the playback resource}. + + The interface name of QMediaBackgroundPlaybackControl is \c com.nokia.Qt.QMediaBackgroundPlaybackControl/1.0 as + defined in QMediaBackgroundPlaybackControl_iid. + + \sa QMediaService::requestControl(), QMediaPlayer +*/ + +/*! + \macro QMediaBackgroundPlaybackControl_iid + + \c com.nokia.Qt.QMediaBackgroundPlaybackControl/1.0 + + Defines the interface name of the QMediaBackgroundPlaybackControl class. + + \relates QMediaBackgroundPlaybackControl +*/ + +/*! + Destroys a media background playback control. +*/ +QMediaBackgroundPlaybackControl::~QMediaBackgroundPlaybackControl() +{ +} + +/*! + Constructs a new media background playback control with the given \a parent. +*/ +QMediaBackgroundPlaybackControl::QMediaBackgroundPlaybackControl(QObject *parent): + QMediaControl(*new QMediaControlPrivate, parent) +{ +} + +/*! + \fn QMediaBackgroundPlaybackControl::setContextId(const QString& contextId) + + Sets the contextId for the application, the last contextId will be released if previously set. + \l {acquire()}{acquire method} will be automatically invoked after setting a new contextId. + + contextId is an unique string set by the application and is used by the background daemon to + distinguish and manage different context for different application. + + \since 1.0 +*/ + +/*! + \fn QMediaBackgroundPlaybackControl::acquire() + + Try to acquire the playback resource for current application + \since 1.0 +*/ + +/*! + \fn QMediaBackgroundPlaybackControl::release() + + Give up the playback resource if current applicaiton holds it. + \since 1.0 +*/ + +/*! + \property QMediaBackgroundPlaybackControl::isAcquired() + \brief indicate whether the background playback resource is granted or not + + It may take sometime for the backend to actually update this value before the first use. + + By default this property is false + + \since 1.0 +*/ + +/*! + \fn QMediaBackgroundPlaybackControl::acquired() + + Signals that the playback resource is acquired + + \since 1.0 +*/ + +/*! + \fn QMediaBackgroundPlaybackControl::lost() + + Signals that the playback resource is lost + + \since 1.0 +*/ + +#include "moc_qmediabackgroundplaybackcontrol.cpp" +QT_END_NAMESPACE + + diff --git a/src/multimedia/qmediabackgroundplaybackcontrol.h b/src/multimedia/qmediabackgroundplaybackcontrol.h new file mode 100644 index 000000000..2cf8d1935 --- /dev/null +++ b/src/multimedia/qmediabackgroundplaybackcontrol.h @@ -0,0 +1,83 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QMEDIABACKGROUNDPLAYBACKCONTROL_H +#define QMEDIABACKGROUNDPLAYBACKCONTROL_H + +#include "qmediacontrol.h" + +QT_BEGIN_HEADER + +QT_BEGIN_NAMESPACE + +QT_MODULE(Multimedia) + + +class Q_MULTIMEDIA_EXPORT QMediaBackgroundPlaybackControl : public QMediaControl +{ + Q_OBJECT + +public: + virtual ~QMediaBackgroundPlaybackControl(); + + virtual void setContextId(const QString& contextId) = 0; + virtual void acquire() = 0; + virtual void release() = 0; + + virtual bool isAcquired() const = 0; + +Q_SIGNALS: + void acquired(); + void lost(); + +protected: + QMediaBackgroundPlaybackControl(QObject* parent = 0); +}; + +#define QMediaBackgroundPlaybackControl_iid "com.nokia.Qt.QMediaBackgroundPlaybackControl/1.0" +Q_MEDIA_DECLARE_CONTROL(QMediaBackgroundPlaybackControl, QMediaBackgroundPlaybackControl_iid) + +QT_END_NAMESPACE + +QT_END_HEADER + + +#endif // QMEDIABACKGROUNDPLAYBACKCONTROL_H diff --git a/src/multimedia/qmediabindableinterface.cpp b/src/multimedia/qmediabindableinterface.cpp new file mode 100644 index 000000000..f5be34dac --- /dev/null +++ b/src/multimedia/qmediabindableinterface.cpp @@ -0,0 +1,85 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include + +QT_BEGIN_NAMESPACE + +/*! + \class QMediaBindableInterface + \inmodule QtMultimedia + \ingroup multimedia + \since 1.0 + + + \brief The QMediaBindableInterface class is the base class for objects extending media objects functionality. + + \sa +*/ + +/*! + Destroys a media helper object. +*/ + +QMediaBindableInterface::~QMediaBindableInterface() +{ +} + +/*! + \fn QMediaBindableInterface::mediaObject() const; + + Return the currently attached media object. + \since 1.0 +*/ + + +/*! + \fn QMediaBindableInterface::setMediaObject(QMediaObject *object); + + Attaches to the media \a object. + Returns true if attached successfully, otherwise returns false. + \since 1.0 +*/ + + + +QT_END_NAMESPACE + diff --git a/src/multimedia/qmediabindableinterface.h b/src/multimedia/qmediabindableinterface.h new file mode 100644 index 000000000..02b5b1a21 --- /dev/null +++ b/src/multimedia/qmediabindableinterface.h @@ -0,0 +1,77 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QMEDIABINDABLEINTERFACE_H +#define QMEDIABINDABLEINTERFACE_H + +#include + +QT_BEGIN_HEADER + +QT_BEGIN_NAMESPACE + +QT_MODULE(Multimedia) + + +class QMediaObject; + +class Q_MULTIMEDIA_EXPORT QMediaBindableInterface +{ +public: + virtual ~QMediaBindableInterface(); + + virtual QMediaObject *mediaObject() const = 0; + +protected: + friend class QMediaObject; + virtual bool setMediaObject(QMediaObject *object) = 0; +}; + +#define QMediaBindableInterface_iid \ + "com.nokia.Qt.QMediaBindableInterface/1.0" +Q_DECLARE_INTERFACE(QMediaBindableInterface, QMediaBindableInterface_iid) + +QT_END_NAMESPACE + +QT_END_HEADER + + +#endif // QMEDIABINDABLEINTERFACE_H diff --git a/src/multimedia/qmediacontainercontrol.cpp b/src/multimedia/qmediacontainercontrol.cpp new file mode 100644 index 000000000..5a4e618f2 --- /dev/null +++ b/src/multimedia/qmediacontainercontrol.cpp @@ -0,0 +1,126 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + + +#include "qmediacontainercontrol.h" + +QT_BEGIN_NAMESPACE + +/*! + \class QMediaContainerControl + + \brief The QMediaContainerControl class provides access to the output container format of a QMediaService + + \inmodule QtMultimedia + \ingroup multimedia-serv + \since 1.0 + + If a QMediaService supports writing encoded data it will implement + QMediaContainerControl. This control provides information about the output + containers supported by a media service and allows one to be selected as + the current output containers. + + The functionality provided by this control is exposed to application code + through the QMediaRecorder class. + + The interface name of QMediaContainerControl is \c com.nokia.Qt.QMediaContainerControl/1.0 as + defined in QMediaContainerControl_iid. + + \sa QMediaService::requestControl(), QMediaRecorder +*/ + +/*! + \macro QMediaContainerControl_iid + + \c com.nokia.Qt.QMediaContainerControl/1.0 + + Defines the interface name of the QMediaContainerControl class. + + \relates QMediaContainerControl +*/ + +/*! + Constructs a new media container control with the given \a parent. +*/ +QMediaContainerControl::QMediaContainerControl(QObject *parent) + :QMediaControl(parent) +{ +} + +/*! + Destroys a media container control. +*/ +QMediaContainerControl::~QMediaContainerControl() +{ +} + + +/*! + \fn QMediaContainerControl::supportedContainers() const + + Returns a list of MIME types of supported container formats. + \since 1.0 +*/ + +/*! + \fn QMediaContainerControl::containerMimeType() const + + Returns the MIME type of the selected container format. + \since 1.0 +*/ + +/*! + \fn QMediaContainerControl::setContainerMimeType(const QString &mimeType) + + Sets the current container format to the format identified by the given \a mimeType. + \since 1.0 +*/ + +/*! + \fn QMediaContainerControl::containerDescription(const QString &mimeType) const + + Returns a description of the container format identified by the given \a mimeType. + \since 1.0 +*/ + +#include "moc_qmediacontainercontrol.cpp" +QT_END_NAMESPACE + diff --git a/src/multimedia/qmediacontainercontrol.h b/src/multimedia/qmediacontainercontrol.h new file mode 100644 index 000000000..af48605d0 --- /dev/null +++ b/src/multimedia/qmediacontainercontrol.h @@ -0,0 +1,80 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + + +#ifndef QMEDIACONTAINERCONTROL_H +#define QMEDIACONTAINERCONTROL_H + +#include "qmediacontrol.h" + +QT_BEGIN_HEADER + +QT_BEGIN_NAMESPACE + +QT_MODULE(Multimedia) + + +class Q_MULTIMEDIA_EXPORT QMediaContainerControl : public QMediaControl +{ + Q_OBJECT + +public: + virtual ~QMediaContainerControl(); + + virtual QStringList supportedContainers() const = 0; + virtual QString containerMimeType() const = 0; + virtual void setContainerMimeType(const QString &formatMimeType) = 0; + + virtual QString containerDescription(const QString &formatMimeType) const = 0; + +protected: + QMediaContainerControl(QObject *parent = 0); +}; + +#define QMediaContainerControl_iid "com.nokia.Qt.QMediaContainerControl/1.0" +Q_MEDIA_DECLARE_CONTROL(QMediaContainerControl, QMediaContainerControl_iid) + +QT_END_NAMESPACE + +QT_END_HEADER + + +#endif // QMEDIACONTAINERCONTROL_H diff --git a/src/multimedia/qmediacontent.cpp b/src/multimedia/qmediacontent.cpp new file mode 100644 index 000000000..8cd97bbe0 --- /dev/null +++ b/src/multimedia/qmediacontent.cpp @@ -0,0 +1,254 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include +#include + +#include "qmediacontent.h" + +QT_BEGIN_NAMESPACE + + +class QMediaContentPrivate : public QSharedData +{ +public: + QMediaContentPrivate() {} + QMediaContentPrivate(const QMediaResourceList &r): + resources(r) {} + + QMediaContentPrivate(const QMediaContentPrivate &other): + QSharedData(other), + resources(other.resources) + {} + + bool operator ==(const QMediaContentPrivate &other) const + { + return resources == other.resources; + } + + QMediaResourceList resources; +private: + QMediaContentPrivate& operator=(const QMediaContentPrivate &other); +}; + + +/*! + \class QMediaContent + + \brief The QMediaContent class provides access to the resources relating to a media content. + + \inmodule QtMultimedia + \ingroup multimedia + \since 1.0 + + QMediaContent is used within the multimedia framework as the logical handle + to media content. A QMediaContent object is composed of one or more + \l {QMediaResource}s where each resource provides the URL and format + information of a different encoding of the content. + + A non-null QMediaContent will always have a primary or canonical reference to + the content available through the canonicalUrl() or canonicalResource() + methods, any additional resources are optional. +*/ + + +/*! + Constructs a null QMediaContent. +*/ + +QMediaContent::QMediaContent() +{ +} + +/*! + Constructs a media content with \a url providing a reference to the content. + \since 1.0 +*/ + +QMediaContent::QMediaContent(const QUrl &url): + d(new QMediaContentPrivate) +{ + d->resources << QMediaResource(url); +} + +/*! + Constructs a media content with \a request providing a reference to the content. + + This constructor can be used to reference media content via network protocols such as HTTP. + This may include additional information required to obtain the resource, such as Cookies or HTTP headers. + \since 1.0 +*/ + +QMediaContent::QMediaContent(const QNetworkRequest &request): + d(new QMediaContentPrivate) +{ + d->resources << QMediaResource(request); +} + +/*! + Constructs a media content with \a resource providing a reference to the content. + \since 1.0 +*/ + +QMediaContent::QMediaContent(const QMediaResource &resource): + d(new QMediaContentPrivate) +{ + d->resources << resource; +} + +/*! + Constructs a media content with \a resources providing a reference to the content. + \since 1.0 +*/ + +QMediaContent::QMediaContent(const QMediaResourceList &resources): + d(new QMediaContentPrivate(resources)) +{ +} + +/*! + Constructs a copy of the media content \a other. + \since 1.0 +*/ + +QMediaContent::QMediaContent(const QMediaContent &other): + d(other.d) +{ +} + +/*! + Destroys the media content object. +*/ + +QMediaContent::~QMediaContent() +{ +} + +/*! + Assigns the value of \a other to this media content. + \since 1.0 +*/ + +QMediaContent& QMediaContent::operator=(const QMediaContent &other) +{ + d = other.d; + return *this; +} + +/*! + Returns true if \a other is equivalent to this media content; false otherwise. + \since 1.0 +*/ + +bool QMediaContent::operator==(const QMediaContent &other) const +{ + return (d.constData() == 0 && other.d.constData() == 0) || + (d.constData() != 0 && other.d.constData() != 0 && + *d.constData() == *other.d.constData()); +} + +/*! + Returns true if \a other is not equivalent to this media content; false otherwise. + \since 1.0 +*/ + +bool QMediaContent::operator!=(const QMediaContent &other) const +{ + return !(*this == other); +} + +/*! + Returns true if this media content is null (uninitialized); false otherwise. + \since 1.0 +*/ + +bool QMediaContent::isNull() const +{ + return d.constData() == 0; +} + +/*! + Returns a QUrl that represents that canonical resource for this media content. + \since 1.0 +*/ + +QUrl QMediaContent::canonicalUrl() const +{ + return canonicalResource().url(); +} + +/*! + Returns a QNetworkRequest that represents that canonical resource for this media content. + \since 1.0 +*/ + +QNetworkRequest QMediaContent::canonicalRequest() const +{ + return canonicalResource().request(); +} + +/*! + Returns a QMediaResource that represents that canonical resource for this media content. + \since 1.0 +*/ + +QMediaResource QMediaContent::canonicalResource() const +{ + return d.constData() != 0 + ? d->resources.value(0) + : QMediaResource(); +} + +/*! + Returns a list of alternative resources for this media content. The first item in this list + is always the canonical resource. + \since 1.0 +*/ + +QMediaResourceList QMediaContent::resources() const +{ + return d.constData() != 0 + ? d->resources + : QMediaResourceList(); +} + +QT_END_NAMESPACE + diff --git a/src/multimedia/qmediacontent.h b/src/multimedia/qmediacontent.h new file mode 100644 index 000000000..cfd109d84 --- /dev/null +++ b/src/multimedia/qmediacontent.h @@ -0,0 +1,95 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QMEDIACONTENT_H +#define QMEDIACONTENT_H + +#include +#include + +#include "qmediaresource.h" + +#include + + +QT_BEGIN_HEADER + +QT_BEGIN_NAMESPACE + +QT_MODULE(Multimedia) + + +class QMediaContentPrivate; +class Q_MULTIMEDIA_EXPORT QMediaContent +{ +public: + QMediaContent(); + QMediaContent(const QUrl &contentUrl); + QMediaContent(const QNetworkRequest &contentRequest); + QMediaContent(const QMediaResource &contentResource); + QMediaContent(const QMediaResourceList &resources); + QMediaContent(const QMediaContent &other); + ~QMediaContent(); + + QMediaContent& operator=(const QMediaContent &other); + + bool operator==(const QMediaContent &other) const; + bool operator!=(const QMediaContent &other) const; + + bool isNull() const; + + QUrl canonicalUrl() const; + QNetworkRequest canonicalRequest() const; + QMediaResource canonicalResource() const; + + QMediaResourceList resources() const; + +private: + QSharedDataPointer d; +}; + +QT_END_NAMESPACE + +Q_DECLARE_METATYPE(QMediaContent) + +QT_END_HEADER + +#endif // QMEDIACONTENT_H diff --git a/src/multimedia/qmediacontrol.cpp b/src/multimedia/qmediacontrol.cpp new file mode 100644 index 000000000..0cde2cddd --- /dev/null +++ b/src/multimedia/qmediacontrol.cpp @@ -0,0 +1,138 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include +#include + +#include "qmediacontrol.h" +#include "qmediacontrol_p.h" + + + +QT_BEGIN_NAMESPACE + +/*! + \class QMediaControl + \inmodule QtMultimedia + \ingroup multimedia-serv + \since 1.0 + + + \brief The QMediaControl class provides a base interface for media service controls. + + Media controls provide an interface to individual features provided by a + media service. Most services implement a principal control which exposes + the core functionality of the service and a number of optional controls which + expose any additional functionality. + + A pointer to a control implemented by a media service can be obtained using + the \l {QMediaService::requestControl()} member of QMediaService. If the + service doesn't implement a control it will instead return a null pointer. + + \snippet doc/src/snippets/multimedia-snippets/media.cpp Request control + + Alternatively if the IId of the control has been declared using + Q_MEDIA_DECLARE_CONTROL the template version of + QMediaService::requestControl() can be used to request the service without + explicitly passing the IId or using qobject_cast(). + + \snippet doc/src/snippets/multimedia-snippets/media.cpp Request control templated + + Most application code will not interface directly with a media service's + controls, instead the QMediaObject which owns the service acts as an + intermediary between one or more controls and the application. + + \sa QMediaService, QMediaObject +*/ + +/*! + \macro Q_MEDIA_DECLARE_CONTROL(Class, IId) + \relates QMediaControl + + The Q_MEDIA_DECLARE_CONTROL macro declares an \a IId for a \a Class that + inherits from QMediaControl. + + Declaring an IId for a QMediaControl allows an instance of that control to + be requested from QMediaService::requestControl() without explicitly + passing the IId. + + \snippet doc/src/snippets/multimedia-snippets/media.cpp Request control templated + + \sa QMediaService::requestControl() +*/ + +/*! + Destroys a media control. +*/ + +QMediaControl::~QMediaControl() +{ + delete d_ptr; +} + +/*! + Constructs a media control with the given \a parent. + \since 1.0 +*/ + +QMediaControl::QMediaControl(QObject *parent) + : QObject(parent) + , d_ptr(new QMediaControlPrivate) +{ + d_ptr->q_ptr = this; +} + +/*! + \internal + \since 1.0 +*/ + +QMediaControl::QMediaControl(QMediaControlPrivate &dd, QObject *parent) + : QObject(parent) + , d_ptr(&dd) + +{ + d_ptr->q_ptr = this; +} + +#include "moc_qmediacontrol.cpp" +QT_END_NAMESPACE + diff --git a/src/multimedia/qmediacontrol.h b/src/multimedia/qmediacontrol.h new file mode 100644 index 000000000..3d27026c5 --- /dev/null +++ b/src/multimedia/qmediacontrol.h @@ -0,0 +1,87 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QABSTRACTMEDIACONTROL_H +#define QABSTRACTMEDIACONTROL_H + +#include + +#include +#include +#include + + +QT_BEGIN_HEADER + +QT_BEGIN_NAMESPACE + +QT_MODULE(Multimedia) + + +class QMediaControlPrivate; +class Q_MULTIMEDIA_EXPORT QMediaControl : public QObject +{ + Q_OBJECT + +public: + ~QMediaControl(); + +protected: + QMediaControl(QObject *parent = 0); + QMediaControl(QMediaControlPrivate &dd, QObject *parent = 0); + + QMediaControlPrivate *d_ptr; + +private: + Q_DECLARE_PRIVATE(QMediaControl) +}; + +template const char *qmediacontrol_iid() { return 0; } + +#define Q_MEDIA_DECLARE_CONTROL(Class, IId) \ + template <> inline const char *qmediacontrol_iid() { return IId; } + +QT_END_NAMESPACE + +QT_END_HEADER + + +#endif // QABSTRACTMEDIACONTROL_H diff --git a/src/multimedia/qmediacontrol_p.h b/src/multimedia/qmediacontrol_p.h new file mode 100644 index 000000000..05693a028 --- /dev/null +++ b/src/multimedia/qmediacontrol_p.h @@ -0,0 +1,80 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QABSTRACTMEDIACONTROL_P_H +#define QABSTRACTMEDIACONTROL_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 + +QT_BEGIN_HEADER + +QT_BEGIN_NAMESPACE + +QT_MODULE(Multimedia) + + +class QMediaControl; + +class QMediaControlPrivate +{ +public: + virtual ~QMediaControlPrivate() {} + + QMediaControl *q_ptr; +}; + +QT_END_NAMESPACE + +QT_END_HEADER + + +#endif diff --git a/src/multimedia/qmediaencodersettings.cpp b/src/multimedia/qmediaencodersettings.cpp new file mode 100644 index 000000000..5f85eec37 --- /dev/null +++ b/src/multimedia/qmediaencodersettings.cpp @@ -0,0 +1,822 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qmediaencodersettings.h" + +QT_BEGIN_NAMESPACE + +class QAudioEncoderSettingsPrivate : public QSharedData +{ +public: + QAudioEncoderSettingsPrivate() : + isNull(true), + encodingMode(QtMultimedia::ConstantQualityEncoding), + bitrate(-1), + sampleRate(-1), + channels(-1), + quality(QtMultimedia::NormalQuality) + { + } + + QAudioEncoderSettingsPrivate(const QAudioEncoderSettingsPrivate &other): + QSharedData(other), + isNull(other.isNull), + encodingMode(other.encodingMode), + codec(other.codec), + bitrate(other.bitrate), + sampleRate(other.sampleRate), + channels(other.channels), + quality(other.quality) + { + } + + bool isNull; + QtMultimedia::EncodingMode encodingMode; + QString codec; + int bitrate; + int sampleRate; + int channels; + QtMultimedia::EncodingQuality quality; + +private: + QAudioEncoderSettingsPrivate& operator=(const QAudioEncoderSettingsPrivate &other); +}; + +/*! + \class QAudioEncoderSettings + + \brief The QAudioEncoderSettings class provides a set of audio encoder settings. + + \inmodule QtMultimedia + \ingroup multimedia + \since 1.0 + + A audio encoder settings object is used to specify the audio encoder + settings used by QMediaRecorder. Audio encoder settings are selected by + constructing a QAudioEncoderSettings object, setting the desired properties + and then passing it to a QMediaRecorder instance using the + QMediaRecorder::setEncodingSettings() function. + + \snippet doc/src/snippets/multimedia-snippets/media.cpp Audio encoder settings + + \sa QMediaRecorder, QAudioEncoderControl +*/ + +/*! + Construct a null audio encoder settings object. +*/ +QAudioEncoderSettings::QAudioEncoderSettings() + :d(new QAudioEncoderSettingsPrivate) +{ +} + +/*! + Constructs a copy of the audio encoder settings object \a other. + \since 1.0 +*/ + +QAudioEncoderSettings::QAudioEncoderSettings(const QAudioEncoderSettings& other) + :d(other.d) +{ +} + +/*! + Destroys an audio encoder settings object. +*/ + +QAudioEncoderSettings::~QAudioEncoderSettings() +{ +} + +/*! + Assigns the value of \a other to an audio encoder settings object. + \since 1.0 +*/ + +QAudioEncoderSettings& QAudioEncoderSettings::operator=(const QAudioEncoderSettings &other) +{ + d = other.d; + return *this; +} + +/*! + Determines if \a other is of equal value to an audio encoder settings + object. + + Returns true if the settings objects are of equal value, and false if they + are not of equal value. + \since 1.0 +*/ + +bool QAudioEncoderSettings::operator==(const QAudioEncoderSettings &other) const +{ + return (d == other.d) || + (d->isNull == other.d->isNull && + d->encodingMode == other.d->encodingMode && + d->bitrate == other.d->bitrate && + d->sampleRate == other.d->sampleRate && + d->channels == other.d->channels && + d->quality == other.d->quality && + d->codec == other.d->codec); +} + +/*! + Determines if \a other is of equal value to an audio encoder settings + object. + + Returns true if the settings objects are not of equal value, and true if + they are of equal value. + \since 1.0 +*/ + +bool QAudioEncoderSettings::operator!=(const QAudioEncoderSettings &other) const +{ + return !(*this == other); +} + +/*! + Identifies if an audio settings object is initialized. + + Returns true if the settings object is null, and false if it is not. + \since 1.0 +*/ + +bool QAudioEncoderSettings::isNull() const +{ + return d->isNull; +} + +/*! + Returns the audio encoding mode. + + \since 1.0 + \sa QtMultimedia::EncodingMode +*/ +QtMultimedia::EncodingMode QAudioEncoderSettings::encodingMode() const +{ + return d->encodingMode; +} + +/*! + Sets the audio encoding \a mode setting. + + If QtMultimedia::ConstantQualityEncoding is set, the quality + encoding parameter is used and bit rate is ignored, + otherwise the bitrate is used. + + The audio codec, channels count and sample rate settings are used in all + the encoding modes. + + \since 1.0 + \sa encodingMode(), QtMultimedia::EncodingMode +*/ +void QAudioEncoderSettings::setEncodingMode(QtMultimedia::EncodingMode mode) +{ + d->encodingMode = mode; +} + +/*! + Returns the audio codec. + \since 1.0 +*/ +QString QAudioEncoderSettings::codec() const +{ + return d->codec; +} + +/*! + Sets the audio \a codec. + \since 1.0 +*/ +void QAudioEncoderSettings::setCodec(const QString& codec) +{ + d->isNull = false; + d->codec = codec; +} + +/*! + Returns the bit rate of the compressed audio stream in bits per second. + \since 1.0 +*/ +int QAudioEncoderSettings::bitRate() const +{ + return d->bitrate; +} + +/*! + Returns the number of audio channels. + \since 1.0 +*/ +int QAudioEncoderSettings::channelCount() const +{ + return d->channels; +} + +/*! + Sets the number of audio \a channels. + + A value of -1 indicates the encoder should make an optimal choice based on + what is available from the audio source and the limitations of the codec. + \since 1.0 +*/ +void QAudioEncoderSettings::setChannelCount(int channels) +{ + d->isNull = false; + d->channels = channels; +} + +/*! + Sets the audio bit \a rate in bits per second. + \since 1.0 +*/ +void QAudioEncoderSettings::setBitRate(int rate) +{ + d->isNull = false; + d->bitrate = rate; +} + +/*! + Returns the audio sample rate in Hz. + \since 1.0 +*/ +int QAudioEncoderSettings::sampleRate() const +{ + return d->sampleRate; +} + +/*! + Sets the audio sample \a rate in Hz. + + A value of -1 indicates the encoder should make an optimal choice based on what is avaialbe + from the audio source and the limitations of the codec. + \since 1.0 + */ +void QAudioEncoderSettings::setSampleRate(int rate) +{ + d->isNull = false; + d->sampleRate = rate; +} + +/*! + Returns the audio encoding quality. + \since 1.0 +*/ + +QtMultimedia::EncodingQuality QAudioEncoderSettings::quality() const +{ + return d->quality; +} + +/*! + Set the audio encoding \a quality. + + Setting the audio quality parameter allows backend to choose the balanced + set of encoding parameters to achieve the desired quality level. + + The \a quality settings parameter is only used in the + \l {QtMultimedia::ConstantQualityEncoding}{constant quality} \l{encodingMode()}{encoding mode}. + \since 1.0 +*/ +void QAudioEncoderSettings::setQuality(QtMultimedia::EncodingQuality quality) +{ + d->isNull = false; + d->quality = quality; +} + +class QVideoEncoderSettingsPrivate : public QSharedData +{ +public: + QVideoEncoderSettingsPrivate() : + isNull(true), + encodingMode(QtMultimedia::ConstantQualityEncoding), + bitrate(-1), + frameRate(0), + quality(QtMultimedia::NormalQuality) + { + } + + QVideoEncoderSettingsPrivate(const QVideoEncoderSettingsPrivate &other): + QSharedData(other), + isNull(other.isNull), + encodingMode(other.encodingMode), + codec(other.codec), + bitrate(other.bitrate), + resolution(other.resolution), + frameRate(other.frameRate), + quality(other.quality) + { + } + + bool isNull; + QtMultimedia::EncodingMode encodingMode; + QString codec; + int bitrate; + QSize resolution; + qreal frameRate; + QtMultimedia::EncodingQuality quality; + +private: + QVideoEncoderSettingsPrivate& operator=(const QVideoEncoderSettingsPrivate &other); +}; + +/*! + \class QVideoEncoderSettings + + \brief The QVideoEncoderSettings class provides a set of video encoder settings. + \since 1.0 + + A video encoder settings object is used to specify the video encoder + settings used by QMediaRecorder. Video encoder settings are selected by + constructing a QVideoEncoderSettings object, setting the desired properties + and then passing it to a QMediaRecorder instance using the + QMediaRecorder::setEncodingSettings() function. + + \snippet doc/src/snippets/multimedia-snippets/media.cpp Video encoder settings + + \sa QMediaRecorder, QVideoEncoderControl +*/ + +/*! + Constructs a null video encoder settings object. +*/ + +QVideoEncoderSettings::QVideoEncoderSettings() + :d(new QVideoEncoderSettingsPrivate) +{ +} + +/*! + Constructs a copy of the video encoder settings object \a other. + \since 1.0 +*/ + +QVideoEncoderSettings::QVideoEncoderSettings(const QVideoEncoderSettings& other) + :d(other.d) +{ +} + +/*! + Destroys a video encoder settings object. +*/ + +QVideoEncoderSettings::~QVideoEncoderSettings() +{ +} + +/*! + Assigns the value of \a other to a video encoder settings object. + \since 1.0 +*/ +QVideoEncoderSettings &QVideoEncoderSettings::operator=(const QVideoEncoderSettings &other) +{ + d = other.d; + return *this; +} + +/*! + Determines if \a other is of equal value to a video encoder settings object. + + Returns true if the settings objects are of equal value, and false if they + are not of equal value. + \since 1.0 +*/ +bool QVideoEncoderSettings::operator==(const QVideoEncoderSettings &other) const +{ + return (d == other.d) || + (d->isNull == other.d->isNull && + d->encodingMode == other.d->encodingMode && + d->bitrate == other.d->bitrate && + d->quality == other.d->quality && + d->codec == other.d->codec && + d->resolution == other.d->resolution && + qFuzzyCompare(d->frameRate, other.d->frameRate)); +} + +/*! + Determines if \a other is of equal value to a video encoder settings object. + + Returns true if the settings objects are not of equal value, and false if + they are of equal value. + \since 1.0 +*/ +bool QVideoEncoderSettings::operator!=(const QVideoEncoderSettings &other) const +{ + return !(*this == other); +} + +/*! + Identifies if a video encoder settings object is uninitalized. + + Returns true if the settings are null, and false if they are not. + \since 1.0 +*/ +bool QVideoEncoderSettings::isNull() const +{ + return d->isNull; +} + +/*! + Returns the video encoding mode. + + \since 1.0 + \sa QtMultimedia::EncodingMode +*/ +QtMultimedia::EncodingMode QVideoEncoderSettings::encodingMode() const +{ + return d->encodingMode; +} + +/*! + Sets the video encoding \a mode. + + If QtMultimedia::ConstantQualityEncoding is set, + the quality encoding parameter is used and bit rate is ignored, + otherwise the bitrate is used. + + The rest of encoding settings are respected regardless of encoding mode. + + \since 1.0 + \sa QtMultimedia::EncodingMode +*/ +void QVideoEncoderSettings::setEncodingMode(QtMultimedia::EncodingMode mode) +{ + d->isNull = false; + d->encodingMode = mode; +} + +/*! + Returns the video codec. + \since 1.0 +*/ + +QString QVideoEncoderSettings::codec() const +{ + return d->codec; +} + +/*! + Sets the video \a codec. + \since 1.0 +*/ +void QVideoEncoderSettings::setCodec(const QString& codec) +{ + d->isNull = false; + d->codec = codec; +} + +/*! + Returns bit rate of the encoded video stream in bits per second. + \since 1.0 +*/ +int QVideoEncoderSettings::bitRate() const +{ + return d->bitrate; +} + +/*! + Sets the bit rate of the encoded video stream to \a value. + \since 1.0 +*/ + +void QVideoEncoderSettings::setBitRate(int value) +{ + d->isNull = false; + d->bitrate = value; +} + +/*! + Returns the video frame rate. + \since 1.0 +*/ +qreal QVideoEncoderSettings::frameRate() const +{ + return d->frameRate; +} + +/*! + \fn QVideoEncoderSettings::setFrameRate(qreal rate) + + Sets the video frame \a rate. + + A value of 0 indicates the encoder should make an optimal choice based on what is available + from the video source and the limitations of the codec. + \since 1.0 +*/ + +void QVideoEncoderSettings::setFrameRate(qreal rate) +{ + d->isNull = false; + d->frameRate = rate; +} + +/*! + Returns the resolution of the encoded video. + \since 1.0 +*/ + +QSize QVideoEncoderSettings::resolution() const +{ + return d->resolution; +} + +/*! + Sets the \a resolution of the encoded video. + + An empty QSize indicates the encoder should make an optimal choice based on + what is available from the video source and the limitations of the codec. + \since 1.0 +*/ + +void QVideoEncoderSettings::setResolution(const QSize &resolution) +{ + d->isNull = false; + d->resolution = resolution; +} + +/*! + Sets the \a width and \a height of the resolution of the encoded video. + + \overload + \since 1.0 +*/ + +void QVideoEncoderSettings::setResolution(int width, int height) +{ + d->isNull = false; + d->resolution = QSize(width, height); +} + +/*! + Returns the video encoding quality. + \since 1.0 +*/ + +QtMultimedia::EncodingQuality QVideoEncoderSettings::quality() const +{ + return d->quality; +} + +/*! + Sets the video encoding \a quality. + + Setting the video quality parameter allows backend to choose the balanced + set of encoding parameters to achieve the desired quality level. + + The \a quality settings parameter is only used in the + \l {QtMultimedia::ConstantQualityEncoding}{constant quality} \l{encodingMode()}{encoding mode}. + The \a quality settings parameter is only used in the \l + {QtMultimedia::ConstantQualityEncoding}{constant quality} + \l{encodingMode()}{encoding mode}. + \since 1.0 +*/ + +void QVideoEncoderSettings::setQuality(QtMultimedia::EncodingQuality quality) +{ + d->isNull = false; + d->quality = quality; +} + + + +class QImageEncoderSettingsPrivate : public QSharedData +{ +public: + QImageEncoderSettingsPrivate() : + isNull(true), + quality(QtMultimedia::NormalQuality) + { + } + + QImageEncoderSettingsPrivate(const QImageEncoderSettingsPrivate &other): + QSharedData(other), + isNull(other.isNull), + codec(other.codec), + resolution(other.resolution), + quality(other.quality) + { + } + + bool isNull; + QString codec; + QSize resolution; + QtMultimedia::EncodingQuality quality; + +private: + QImageEncoderSettingsPrivate& operator=(const QImageEncoderSettingsPrivate &other); +}; + +/*! + \class QImageEncoderSettings + + + \brief The QImageEncoderSettings class provides a set of image encoder + settings. + \since 1.0 + + A image encoder settings object is used to specify the image encoder + settings used by QCameraImageCapture. Image encoder settings are selected + by constructing a QImageEncoderSettings object, setting the desired + properties and then passing it to a QCameraImageCapture instance using the + QCameraImageCapture::setImageSettings() function. + + \snippet doc/src/snippets/multimedia-snippets/media.cpp Image encoder settings + + \sa QImageEncoderControl +*/ + +/*! + Constructs a null image encoder settings object. +*/ + +QImageEncoderSettings::QImageEncoderSettings() + :d(new QImageEncoderSettingsPrivate) +{ +} + +/*! + Constructs a copy of the image encoder settings object \a other. + \since 1.0 +*/ + +QImageEncoderSettings::QImageEncoderSettings(const QImageEncoderSettings& other) + :d(other.d) +{ +} + +/*! + Destroys a image encoder settings object. +*/ + +QImageEncoderSettings::~QImageEncoderSettings() +{ +} + +/*! + Assigns the value of \a other to a image encoder settings object. + \since 1.0 +*/ +QImageEncoderSettings &QImageEncoderSettings::operator=(const QImageEncoderSettings &other) +{ + d = other.d; + return *this; +} + +/*! + Determines if \a other is of equal value to a image encoder settings + object. + + Returns true if the settings objects are of equal value, and false if they + are not of equal value. + \since 1.0 +*/ +bool QImageEncoderSettings::operator==(const QImageEncoderSettings &other) const +{ + return (d == other.d) || + (d->isNull == other.d->isNull && + d->quality == other.d->quality && + d->codec == other.d->codec && + d->resolution == other.d->resolution); + +} + +/*! + Determines if \a other is of equal value to a image encoder settings + object. + + Returns true if the settings objects are not of equal value, and false if + they are of equal value. + \since 1.0 +*/ +bool QImageEncoderSettings::operator!=(const QImageEncoderSettings &other) const +{ + return !(*this == other); +} + +/*! + Identifies if a image encoder settings object is uninitalized. + + Returns true if the settings are null, and false if they are not. + \since 1.0 +*/ +bool QImageEncoderSettings::isNull() const +{ + return d->isNull; +} + +/*! + Returns the image codec. + \since 1.0 +*/ + +QString QImageEncoderSettings::codec() const +{ + return d->codec; +} + +/*! + Sets the image \a codec. + \since 1.0 +*/ +void QImageEncoderSettings::setCodec(const QString& codec) +{ + d->isNull = false; + d->codec = codec; +} + +/*! + Returns the resolution of the encoded image. + \since 1.0 +*/ + +QSize QImageEncoderSettings::resolution() const +{ + return d->resolution; +} + +/*! + Sets the \a resolution of the encoded image. + + An empty QSize indicates the encoder should make an optimal choice based on + what is available from the image source and the limitations of the codec. + \since 1.0 +*/ + +void QImageEncoderSettings::setResolution(const QSize &resolution) +{ + d->isNull = false; + d->resolution = resolution; +} + +/*! + Sets the \a width and \a height of the resolution of the encoded image. + + \overload + \since 1.0 +*/ + +void QImageEncoderSettings::setResolution(int width, int height) +{ + d->isNull = false; + d->resolution = QSize(width, height); +} + +/*! + Returns the image encoding quality. + \since 1.0 +*/ + +QtMultimedia::EncodingQuality QImageEncoderSettings::quality() const +{ + return d->quality; +} + +/*! + Sets the image encoding \a quality. + \since 1.0 +*/ + +void QImageEncoderSettings::setQuality(QtMultimedia::EncodingQuality quality) +{ + d->isNull = false; + d->quality = quality; +} +QT_END_NAMESPACE + diff --git a/src/multimedia/qmediaencodersettings.h b/src/multimedia/qmediaencodersettings.h new file mode 100644 index 000000000..28bf6d6c8 --- /dev/null +++ b/src/multimedia/qmediaencodersettings.h @@ -0,0 +1,168 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QMEDIAENCODERSETTINGS_H +#define QMEDIAENCODERSETTINGS_H + +#include +#include +#include +#include +#include "qtmedianamespace.h" + +QT_BEGIN_HEADER + +QT_BEGIN_NAMESPACE + +QT_MODULE(Multimedia) + + + +class QAudioEncoderSettingsPrivate; +class Q_MULTIMEDIA_EXPORT QAudioEncoderSettings +{ +public: + QAudioEncoderSettings(); + QAudioEncoderSettings(const QAudioEncoderSettings& other); + + ~QAudioEncoderSettings(); + + QAudioEncoderSettings& operator=(const QAudioEncoderSettings &other); + bool operator==(const QAudioEncoderSettings &other) const; + bool operator!=(const QAudioEncoderSettings &other) const; + + bool isNull() const; + + QtMultimedia::EncodingMode encodingMode() const; + void setEncodingMode(QtMultimedia::EncodingMode); + + QString codec() const; + void setCodec(const QString& codec); + + int bitRate() const; + void setBitRate(int bitrate); + + int channelCount() const; + void setChannelCount(int channels); + + int sampleRate() const; + void setSampleRate(int rate); + + QtMultimedia::EncodingQuality quality() const; + void setQuality(QtMultimedia::EncodingQuality quality); + +private: + QSharedDataPointer d; +}; + +class QVideoEncoderSettingsPrivate; +class Q_MULTIMEDIA_EXPORT QVideoEncoderSettings +{ +public: + QVideoEncoderSettings(); + QVideoEncoderSettings(const QVideoEncoderSettings& other); + + ~QVideoEncoderSettings(); + + QVideoEncoderSettings& operator=(const QVideoEncoderSettings &other); + bool operator==(const QVideoEncoderSettings &other) const; + bool operator!=(const QVideoEncoderSettings &other) const; + + bool isNull() const; + + QtMultimedia::EncodingMode encodingMode() const; + void setEncodingMode(QtMultimedia::EncodingMode); + + QString codec() const; + void setCodec(const QString &); + + QSize resolution() const; + void setResolution(const QSize &); + void setResolution(int width, int height); + + qreal frameRate() const; + void setFrameRate(qreal rate); + + int bitRate() const; + void setBitRate(int bitrate); + + QtMultimedia::EncodingQuality quality() const; + void setQuality(QtMultimedia::EncodingQuality quality); + +private: + QSharedDataPointer d; +}; + +class QImageEncoderSettingsPrivate; +class Q_MULTIMEDIA_EXPORT QImageEncoderSettings +{ +public: + QImageEncoderSettings(); + QImageEncoderSettings(const QImageEncoderSettings& other); + + ~QImageEncoderSettings(); + + QImageEncoderSettings& operator=(const QImageEncoderSettings &other); + bool operator==(const QImageEncoderSettings &other) const; + bool operator!=(const QImageEncoderSettings &other) const; + + bool isNull() const; + + QString codec() const; + void setCodec(const QString &); + + QSize resolution() const; + void setResolution(const QSize &); + void setResolution(int width, int height); + + QtMultimedia::EncodingQuality quality() const; + void setQuality(QtMultimedia::EncodingQuality quality); + +private: + QSharedDataPointer d; +}; + +QT_END_NAMESPACE + +QT_END_HEADER + + +#endif diff --git a/src/multimedia/qmediaenumdebug.h b/src/multimedia/qmediaenumdebug.h new file mode 100644 index 000000000..3fa7ee820 --- /dev/null +++ b/src/multimedia/qmediaenumdebug.h @@ -0,0 +1,79 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QMEDIAENUMDEBUG_H +#define QMEDIAENUMDEBUG_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 +#include + +QT_BEGIN_HEADER + +#ifndef QT_NO_DEBUG_STREAM + +#define Q_MEDIA_ENUM_DEBUG(Class,Enum) \ +inline QDebug operator<<(QDebug dbg, Class::Enum value) \ +{ \ + int index = Class::staticMetaObject.indexOfEnumerator(#Enum); \ + dbg.nospace() << #Class << "::" << Class::staticMetaObject.enumerator(index).valueToKey(value); \ + return dbg.space(); \ +} + +#else + +#define Q_MEDIA_ENUM_DEBUG(Class,Enum) + +#endif //QT_NO_DEBUG_STREAM + +QT_END_HEADER + +#endif + diff --git a/src/multimedia/qmediaimageviewer.cpp b/src/multimedia/qmediaimageviewer.cpp new file mode 100644 index 000000000..01265dc2f --- /dev/null +++ b/src/multimedia/qmediaimageviewer.cpp @@ -0,0 +1,604 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qmediaimageviewer.h" + +#include "qmediaobject_p.h" +#include "qmediaimageviewerservice_p.h" + +#include +#include +#include +#include +#include + +#include +#include +#include +#include + +QT_BEGIN_NAMESPACE + +class QMediaImageViewerPrivate : public QMediaObjectPrivate +{ + Q_DECLARE_NON_CONST_PUBLIC(QMediaImageViewer) +public: + QMediaImageViewerPrivate(): + viewerControl(0), playlist(0), + state(QMediaImageViewer::StoppedState), timeout(3000), pauseTime(0) + { + } + + void _q_mediaStatusChanged(QMediaImageViewer::MediaStatus status); + void _q_playlistMediaChanged(const QMediaContent &content); + void _q_playlistDestroyed(); + + QMediaImageViewerControl *viewerControl; + QMediaPlaylist *playlist; + QPointer videoOutput; + QVideoSurfaceOutput surfaceOutput; + QMediaImageViewer::State state; + int timeout; + int pauseTime; + QTime time; + QBasicTimer timer; + QMediaContent media; +}; + +void QMediaImageViewerPrivate::_q_mediaStatusChanged(QMediaImageViewer::MediaStatus status) +{ + switch (status) { + case QMediaImageViewer::NoMedia: + case QMediaImageViewer::LoadingMedia: + emit q_func()->mediaStatusChanged(status); + break; + case QMediaImageViewer::LoadedMedia: + if (state == QMediaImageViewer::PlayingState) { + time.start(); + timer.start(qMax(0, timeout), q_func()); + q_func()->addPropertyWatch("elapsedTime"); + } + emit q_func()->mediaStatusChanged(status); + emit q_func()->elapsedTimeChanged(0); + break; + case QMediaImageViewer::InvalidMedia: + emit q_func()->mediaStatusChanged(status); + + if (state == QMediaImageViewer::PlayingState) { + playlist->next(); + if (playlist->currentIndex() < 0) + emit q_func()->stateChanged(state = QMediaImageViewer::StoppedState); + } + break; + } +} + +void QMediaImageViewerPrivate::_q_playlistMediaChanged(const QMediaContent &content) +{ + media = content; + pauseTime = 0; + + viewerControl->showMedia(media); + + emit q_func()->mediaChanged(media); +} + +void QMediaImageViewerPrivate::_q_playlistDestroyed() +{ + playlist = 0; + timer.stop(); + + if (state != QMediaImageViewer::StoppedState) + emit q_func()->stateChanged(state = QMediaImageViewer::StoppedState); + + q_func()->setMedia(QMediaContent()); +} + +/*! + \class QMediaImageViewer + \brief The QMediaImageViewer class provides a means of viewing image media. + \inmodule QtMultimedia + \ingroup multimedia + \since 1.0 + + + QMediaImageViewer is used together with a media display object such as + QVideoWidget to present an image. A display object is attached to the + image viewer by means of the bind function. + + \snippet doc/src/snippets/multimedia-snippets/media.cpp Binding + + QMediaImageViewer can be paired with a QMediaPlaylist to create a slide + show of images. Constructing a QMediaPlaylist with a pointer to an + instance of QMediaImageViewer will attach it to the image viewer; + changing the playlist's selection will then change the media displayed + by the image viewer. With a playlist attached QMediaImageViewer's + play(), pause(), and stop() slots can be control the progression of the + playlist. The \l timeout property determines how long an image is + displayed for before progressing to the next in the playlist, and the + \l elapsedTime property holds how the duration the current image has + been displayed for. + + \snippet doc/src/snippets/multimedia-snippets/media.cpp Playlist +*/ + +/*! + \enum QMediaImageViewer::State + + Enumerates the possible control states an image viewer may be in. The + control state of an image viewer determines whether the image viewer is + automatically progressing through images in an attached playlist. + + \value StoppedState The image viewer is stopped, and will not automatically move to the next + image. The \l elapsedTime is fixed at 0. + \value PlayingState The slide show is playing, and will move to the next image when the + \l elapsedTime reaches the \l timeout. The \l elapsedTime is being incremented. + \value PausedState The image viewer is paused, and will not automatically move the to next + image. The \l elapsedTime is fixed at the time the image viewer was paused. +*/ + +/*! + \enum QMediaImageViewer::MediaStatus + + Enumerates the status of an image viewer's current media. + + \value NoMedia There is no current media. + \value LoadingMedia The image viewer is loading the current media. + \value LoadedMedia The image viewer has loaded the current media. + \value InvalidMedia The current media cannot be loaded. +*/ + +/*! + Constructs a new image viewer with the given \a parent. +*/ +QMediaImageViewer::QMediaImageViewer(QObject *parent) + : QMediaObject(*new QMediaImageViewerPrivate, parent, new QMediaImageViewerService) +{ + Q_D(QMediaImageViewer); + + d->viewerControl = qobject_cast( + d->service->requestControl(QMediaImageViewerControl_iid)); + + connect(d->viewerControl, SIGNAL(mediaStatusChanged(QMediaImageViewer::MediaStatus)), + this, SLOT(_q_mediaStatusChanged(QMediaImageViewer::MediaStatus))); +} + +/*! + Destroys an image viewer. +*/ +QMediaImageViewer::~QMediaImageViewer() +{ + Q_D(QMediaImageViewer); + + delete d->service; +} + +/*! + \property QMediaImageViewer::state + \brief the playlist control state of a slide show. + \since 1.0 +*/ + +QMediaImageViewer::State QMediaImageViewer::state() const +{ + return d_func()->state; +} + +/*! + \fn QMediaImageViewer::stateChanged(QMediaImageViewer::State state) + + Signals that the playlist control \a state of an image viewer has changed. + \since 1.0 +*/ + +/*! + \property QMediaImageViewer::mediaStatus + \brief the status of the current media. + \since 1.0 +*/ + +QMediaImageViewer::MediaStatus QMediaImageViewer::mediaStatus() const +{ + return d_func()->viewerControl->mediaStatus(); +} + +/*! + \fn QMediaImageViewer::mediaStatusChanged(QMediaImageViewer::MediaStatus status) + + Signals the the \a status of the current media has changed. + \since 1.0 +*/ + +/*! + \property QMediaImageViewer::media + \brief the media an image viewer is presenting. + \since 1.0 +*/ + +QMediaContent QMediaImageViewer::media() const +{ + Q_D(const QMediaImageViewer); + + return d->media; +} + +void QMediaImageViewer::setMedia(const QMediaContent &media) +{ + Q_D(QMediaImageViewer); + + if (d->playlist && d->playlist->currentMedia() != media) { + disconnect(d->playlist, SIGNAL(currentMediaChanged(QMediaContent)), + this, SLOT(_q_playlistMediaChanged(QMediaContent))); + disconnect(d->playlist, SIGNAL(destroyed()), this, SLOT(_q_playlistDestroyed())); + + d->playlist = 0; + } + + d->media = media; + + if (d->timer.isActive()) { + d->pauseTime = 0; + d->timer.stop(); + removePropertyWatch("elapsedTime"); + emit elapsedTimeChanged(0); + } + + if (d->state != QMediaImageViewer::StoppedState) + emit stateChanged(d->state = QMediaImageViewer::StoppedState); + + d->viewerControl->showMedia(d->media); + + emit mediaChanged(d->media); +} + +/*! + Use \a playlist as the source of images to be displayed in the viewer. + \since 1.0 +*/ +void QMediaImageViewer::setPlaylist(QMediaPlaylist *playlist) +{ + Q_D(QMediaImageViewer); + + if (d->playlist) { + disconnect(d->playlist, SIGNAL(currentMediaChanged(QMediaContent)), + this, SLOT(_q_playlistMediaChanged(QMediaContent))); + disconnect(d->playlist, SIGNAL(destroyed()), this, SLOT(_q_playlistDestroyed())); + + QMediaObject::unbind(d->playlist); + } + + d->playlist = playlist; + + if (d->playlist) { + connect(d->playlist, SIGNAL(currentMediaChanged(QMediaContent)), + this, SLOT(_q_playlistMediaChanged(QMediaContent))); + connect(d->playlist, SIGNAL(destroyed()), this, SLOT(_q_playlistDestroyed())); + + QMediaObject::bind(d->playlist); + + setMedia(d->playlist->currentMedia()); + } else { + setMedia(QMediaContent()); + } +} + +/*! + Returns the current playlist, or 0 if none. + \since 1.0 +*/ +QMediaPlaylist *QMediaImageViewer::playlist() const +{ + return d_func()->playlist; +} + +/*! + \fn QMediaImageViewer::mediaChanged(const QMediaContent &media) + + Signals that the \a media an image viewer is presenting has changed. + \since 1.0 +*/ + +/*! + \property QMediaImageViewer::timeout + \brief the amount of time in milliseconds an image is displayed for before moving to the next + image. + + The timeout only applies if the image viewer has a playlist attached and is in the PlayingState. + \since 1.0 +*/ + +int QMediaImageViewer::timeout() const +{ + return d_func()->timeout; +} + +void QMediaImageViewer::setTimeout(int timeout) +{ + Q_D(QMediaImageViewer); + + d->timeout = qMax(0, timeout); + + if (d->timer.isActive()) + d->timer.start(qMax(0, d->timeout - d->pauseTime - d->time.elapsed()), this); +} + +/*! + \property QMediaImageViewer::elapsedTime + \brief the amount of time in milliseconds that has elapsed since the current image was loaded. + + The elapsed time only increases while the image viewer is in the PlayingState. If stopped the + elapsed time will be reset to 0. + \since 1.0 +*/ + +int QMediaImageViewer::elapsedTime() const +{ + Q_D(const QMediaImageViewer); + + int elapsedTime = d->pauseTime; + + if (d->timer.isActive()) + elapsedTime += d->time.elapsed(); + + return elapsedTime; +} + +/*! + \fn QMediaImageViewer::elapsedTimeChanged(int time) + + Signals that the amount of \a time in milliseconds since the current + image was loaded has changed. + + This signal is emitted at a regular interval when the image viewer is + in the PlayingState and an image is loaded. The notification interval + is controlled by the QMediaObject::notifyInterval property. + + \since 1.0 + \sa timeout, QMediaObject::notifyInterval +*/ + +/*! + Sets a video \a widget as the current video output. + + This will unbind any previous video output bound with setVideoOutput(). + \since 1.1 +*/ + +void QMediaImageViewer::setVideoOutput(QVideoWidget *widget) +{ + Q_D(QMediaImageViewer); + + if (d->videoOutput) + unbind(d->videoOutput); + + // We don't know (in this library) that QVideoWidget inherits QObject + QObject *widgetObject = reinterpret_cast(widget); + + d->videoOutput = widgetObject && bind(widgetObject) ? widgetObject : 0; +} + +/*! + Sets a video \a item as the current video output. + + This will unbind any previous video output bound with setVideoOutput(). + \since 1.1 +*/ + +void QMediaImageViewer::setVideoOutput(QGraphicsVideoItem *item) +{ + Q_D(QMediaImageViewer); + + if (d->videoOutput) + unbind(d->videoOutput); + + // We don't know (in this library) that QGraphicsVideoItem (multiply) inherits QObject + // but QObject inheritance depends on QObject coming first, so try this out. + QObject *itemObject = reinterpret_cast(item); + + d->videoOutput = itemObject && bind(itemObject) ? itemObject : 0; +} + +/*! + Sets a video \a surface as the video output of a image viewer. + + If a video output has already been set on the image viewer the new surface + will replace it. + \since 1.2 +*/ + +void QMediaImageViewer::setVideoOutput(QAbstractVideoSurface *surface) +{ + Q_D(QMediaImageViewer); + + d->surfaceOutput.setVideoSurface(surface); + + if (d->videoOutput != &d->surfaceOutput) { + if (d->videoOutput) + unbind(d->videoOutput); + + d->videoOutput = bind(&d->surfaceOutput) ? &d->surfaceOutput : 0; + } +} + +/*! + \internal + \since 1.0 +*/ +bool QMediaImageViewer::bind(QObject *object) +{ + if (QMediaPlaylist *playlist = qobject_cast(object)) { + setPlaylist(playlist); + + return true; + } else { + return QMediaObject::bind(object); + } +} + +/*! + \internal + \since 1.0 + */ +void QMediaImageViewer::unbind(QObject *object) +{ + if (object == d_func()->playlist) + setPlaylist(0); + else + QMediaObject::unbind(object); +} + +/*! + Starts a slide show. + + If the playlist has no current media this will start at the beginning of the playlist, otherwise + it will resume from the current media. + + If no playlist is attached to an image viewer this will do nothing. + \since 1.0 +*/ +void QMediaImageViewer::play() +{ + Q_D(QMediaImageViewer); + + if (d->playlist && d->playlist->mediaCount() > 0 && d->state != PlayingState) { + d->state = PlayingState; + + switch (d->viewerControl->mediaStatus()) { + case NoMedia: + case InvalidMedia: + d->playlist->next(); + if (d->playlist->currentIndex() < 0) + d->state = StoppedState; + break; + case LoadingMedia: + break; + case LoadedMedia: + d->time.start(); + d->timer.start(qMax(0, d->timeout - d->pauseTime), this); + break; + } + + if (d->state == PlayingState) + emit stateChanged(d->state); + } +} + +/*! + Pauses a slide show. + + The current media and elapsed time are retained. If resumed, the current image will be + displayed for the remainder of the time out period before the next image is loaded. + \since 1.0 +*/ +void QMediaImageViewer::pause() +{ + Q_D(QMediaImageViewer); + + if (d->state == PlayingState) { + if (d->viewerControl->mediaStatus() == LoadedMedia) { + d->pauseTime += d->timeout - d->time.elapsed(); + d->timer.stop(); + removePropertyWatch("elapsedTime"); + } + + emit stateChanged(d->state = PausedState); + emit elapsedTimeChanged(d->pauseTime); + } +} + +/*! + Stops a slide show. + + The current media is retained, but the elapsed time is discarded. If resumed, the current + image will be displayed for the full time out period before the next image is loaded. + \since 1.0 +*/ +void QMediaImageViewer::stop() +{ + Q_D(QMediaImageViewer); + + switch (d->state) { + case PlayingState: + d->timer.stop(); + removePropertyWatch("elapsedTime"); + // fall through. + case PausedState: + d->pauseTime = 0; + d->state = QMediaImageViewer::StoppedState; + + emit stateChanged(d->state); + emit elapsedTimeChanged(0); + break; + case StoppedState: + break; + } +} + +/*! + \reimp + + \internal + \since 1.0 +*/ +void QMediaImageViewer::timerEvent(QTimerEvent *event) +{ + Q_D(QMediaImageViewer); + + if (event->timerId() == d->timer.timerId()) { + d->timer.stop(); + removePropertyWatch("elapsedTime"); + emit elapsedTimeChanged(d->pauseTime = d->timeout); + + d->playlist->next(); + + if (d->playlist->currentIndex() < 0) { + d->pauseTime = 0; + emit stateChanged(d->state = StoppedState); + emit elapsedTimeChanged(0); + } + } else { + QMediaObject::timerEvent(event); + } +} + +#include "moc_qmediaimageviewer.cpp" +QT_END_NAMESPACE + diff --git a/src/multimedia/qmediaimageviewer.h b/src/multimedia/qmediaimageviewer.h new file mode 100644 index 000000000..7010fad3f --- /dev/null +++ b/src/multimedia/qmediaimageviewer.h @@ -0,0 +1,142 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QMEDIAIMAGEVIEWER_H +#define QMEDIAIMAGEVIEWER_H + +#include "qmediaobject.h" +#include "qmediacontent.h" +#include + +QT_BEGIN_HEADER + +QT_BEGIN_NAMESPACE + +QT_MODULE(Multimedia) + + +class QAbstractVideoSurface; +class QGraphicsVideoItem; +class QMediaPlaylist; +class QVideoWidget; + +class QMediaImageViewerPrivate; +class Q_MULTIMEDIA_EXPORT QMediaImageViewer : public QMediaObject +{ + Q_OBJECT + Q_PROPERTY(State state READ state NOTIFY stateChanged) + Q_PROPERTY(MediaStatus mediaStatus READ mediaStatus NOTIFY mediaStatusChanged) + Q_PROPERTY(QMediaContent media READ media WRITE setMedia NOTIFY mediaChanged) + Q_PROPERTY(int timeout READ timeout WRITE setTimeout) + Q_PROPERTY(int elapsedTime READ elapsedTime NOTIFY elapsedTimeChanged) + Q_ENUMS(State MediaStatus) + +public: + enum State + { + StoppedState, + PlayingState, + PausedState + }; + + enum MediaStatus + { + NoMedia, + LoadingMedia, + LoadedMedia, + InvalidMedia + }; + + explicit QMediaImageViewer(QObject *parent = 0); + ~QMediaImageViewer(); + + State state() const; + MediaStatus mediaStatus() const; + + QMediaContent media() const; + QMediaPlaylist *playlist() const; + + int timeout() const; + int elapsedTime() const; + + void setVideoOutput(QVideoWidget *widget); + void setVideoOutput(QGraphicsVideoItem *item); + void setVideoOutput(QAbstractVideoSurface *surface); + + bool bind(QObject *); + void unbind(QObject *); + +public Q_SLOTS: + void setMedia(const QMediaContent &media); + void setPlaylist(QMediaPlaylist *playlist); + + void play(); + void pause(); + void stop(); + + void setTimeout(int timeout); + +Q_SIGNALS: + void stateChanged(QMediaImageViewer::State state); + void mediaStatusChanged(QMediaImageViewer::MediaStatus status); + void mediaChanged(const QMediaContent &media); + void elapsedTimeChanged(int time); +protected: + void timerEvent(QTimerEvent *event); + +private: + Q_DECLARE_PRIVATE(QMediaImageViewer) + Q_PRIVATE_SLOT(d_func(), void _q_mediaStatusChanged(QMediaImageViewer::MediaStatus)) + Q_PRIVATE_SLOT(d_func(), void _q_playlistMediaChanged(const QMediaContent &)) + Q_PRIVATE_SLOT(d_func(), void _q_playlistDestroyed()) +}; + +QT_END_NAMESPACE + +Q_DECLARE_METATYPE(QMediaImageViewer::State) +Q_DECLARE_METATYPE(QMediaImageViewer::MediaStatus) + +Q_MEDIA_ENUM_DEBUG(QMediaImageViewer, State) +Q_MEDIA_ENUM_DEBUG(QMediaImageViewer, MediaStatus) + +QT_END_HEADER + +#endif diff --git a/src/multimedia/qmediaimageviewerservice.cpp b/src/multimedia/qmediaimageviewerservice.cpp new file mode 100644 index 000000000..65de7a81b --- /dev/null +++ b/src/multimedia/qmediaimageviewerservice.cpp @@ -0,0 +1,463 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qmediaimageviewerservice_p.h" + +#include "qmediacontrol_p.h" +#include "qmediaservice_p.h" + +#include +#include +#include +#include + +#include + +#include +#include + +#include +#include +#include + +#include +#include + +QT_BEGIN_NAMESPACE + +class QMediaImageViewerServicePrivate : public QMediaServicePrivate +{ +public: + QMediaImageViewerServicePrivate() + : viewerControl(0) + , rendererControl(0) + , network(0) + , internalNetwork(0) + { + } + + bool load(QIODevice *device); + void clear(); + + QMediaImageViewerControl *viewerControl; + QMediaImageViewerRenderer *rendererControl; + QNetworkAccessManager *network; + QNetworkAccessManager *internalNetwork; + QImage m_image; +}; + + +QMediaImageViewerRenderer::QMediaImageViewerRenderer(QObject *parent) + : QVideoRendererControl(parent) + , m_surface(0) +{ +} + +QMediaImageViewerRenderer::~QMediaImageViewerRenderer() +{ + if (m_surface) + m_surface->stop(); +} + +QAbstractVideoSurface *QMediaImageViewerRenderer::surface() const +{ + return m_surface; +} + +void QMediaImageViewerRenderer::setSurface(QAbstractVideoSurface *surface) +{ + if (m_surface) + m_surface->stop(); + + m_surface = surface; + + if (m_surface && !m_image.isNull()) + showImage(m_image); +} + +void QMediaImageViewerRenderer::showImage(const QImage &image) +{ + m_image = image; + + if (m_surface) { + if (m_image.isNull()) { + m_surface->stop(); + } else { + QVideoSurfaceFormat format( + image.size(), QVideoFrame::pixelFormatFromImageFormat(image.format())); + + if (!m_surface->isFormatSupported(format)) { + foreach (QVideoFrame::PixelFormat pixelFormat, m_surface->supportedPixelFormats()) { + const QImage::Format imageFormat + = QVideoFrame::imageFormatFromPixelFormat(pixelFormat); + + if (imageFormat != QImage::Format_Invalid) { + format = QVideoSurfaceFormat(image.size(), pixelFormat); + + if (m_surface->isFormatSupported(format) && m_surface->start(format)) { + m_image = image.convertToFormat(imageFormat); + + m_surface->present(QVideoFrame(m_image)); + + return; + } + } + } + } else if (m_surface->start(format)) { + m_surface->present(QVideoFrame(image)); + } + } + } +} + +bool QMediaImageViewerServicePrivate::load(QIODevice *device) +{ + QImageReader reader(device); + + if (!reader.canRead()) { + m_image = QImage(); + } else { + m_image = reader.read(); + } + + if (rendererControl) + rendererControl->showImage(m_image); + + return !m_image.isNull(); +} + +void QMediaImageViewerServicePrivate::clear() +{ + m_image = QImage(); + + if (rendererControl) + rendererControl->showImage(m_image); +} + +/*! + \class QMediaImageViewerService + \since 1.0 + \internal +*/ + +/*! +*/ +QMediaImageViewerService::QMediaImageViewerService(QObject *parent) + : QMediaService(*new QMediaImageViewerServicePrivate, parent) +{ + Q_D(QMediaImageViewerService); + + d->viewerControl = new QMediaImageViewerControl(this); +} + +/*! +*/ +QMediaImageViewerService::~QMediaImageViewerService() +{ + Q_D(QMediaImageViewerService); + + delete d->rendererControl; + delete d->viewerControl; +} + +/*! +*/ +QMediaControl *QMediaImageViewerService::requestControl(const char *name) +{ + Q_D(QMediaImageViewerService); + + if (qstrcmp(name, QMediaImageViewerControl_iid) == 0) { + return d->viewerControl; + } else if (qstrcmp(name, QVideoRendererControl_iid) == 0) { + if (!d->rendererControl) { + d->rendererControl = new QMediaImageViewerRenderer; + d->rendererControl->showImage(d->m_image); + + return d->rendererControl; + } + } + return 0; +} + +void QMediaImageViewerService::releaseControl(QMediaControl *control) +{ + Q_D(QMediaImageViewerService); + + if (!control) { + qWarning("QMediaService::releaseControl():" + " Attempted release of null control"); + } else if (control == d->rendererControl) { + delete d->rendererControl; + + d->rendererControl = 0; + } +} + +/*! +*/ +QNetworkAccessManager *QMediaImageViewerService::networkManager() const +{ + Q_D(const QMediaImageViewerService); + + if (!d->network) { + QMediaImageViewerServicePrivate *_d = const_cast(d); + + if (!_d->internalNetwork) + _d->internalNetwork = new QNetworkAccessManager( + const_cast(this)); + + _d->network = d->internalNetwork; + } + + return d->network; +} + + +void QMediaImageViewerService::setNetworkManager(QNetworkAccessManager *manager) +{ + d_func()->network = manager; +} + +class QMediaImageViewerControlPrivate : public QMediaControlPrivate +{ + Q_DECLARE_NON_CONST_PUBLIC(QMediaImageViewerControl) +public: + QMediaImageViewerControlPrivate() + : service(0) + , getReply(0) + , headReply(0) + , status(QMediaImageViewer::NoMedia) + { + foreach (const QByteArray &format, QImageReader::supportedImageFormats()) { + supportedExtensions.append( + QLatin1Char('.') + QString::fromLatin1(format.data(), format.size())); + } + } + + bool isImageType(const QUrl &url, const QString &mimeType) const; + + void loadImage(); + void cancelRequests(); + + void _q_getFinished(); + void _q_headFinished(); + + QMediaImageViewerService *service; + QNetworkReply *getReply; + QNetworkReply *headReply; + QMediaImageViewer::MediaStatus status; + QMediaContent media; + QMediaResource currentMedia; + QList possibleResources; + QStringList supportedExtensions; +}; + +bool QMediaImageViewerControlPrivate::isImageType(const QUrl &url, const QString &mimeType) const +{ + if (!mimeType.isEmpty()) { + return mimeType.startsWith(QLatin1String("image/")) + || mimeType == QLatin1String("application/xml+svg"); + } else if (url.scheme() == QLatin1String("file")) { + QString path = url.path(); + + foreach (const QString &extension, supportedExtensions) { + if (path.endsWith(extension, Qt::CaseInsensitive)) + return true; + } + } + return false; +} + +void QMediaImageViewerControlPrivate::loadImage() +{ + cancelRequests(); + + QMediaImageViewer::MediaStatus currentStatus = status; + status = QMediaImageViewer::InvalidMedia; + + QNetworkAccessManager *network = service->networkManager(); + + while (!possibleResources.isEmpty() && !headReply && !getReply) { + currentMedia = possibleResources.takeFirst(); + + QUrl url = currentMedia.url(); + QString mimeType = currentMedia.mimeType(); + + if (isImageType(url, mimeType)) { + getReply = network->get(QNetworkRequest(url)); + QObject::connect(getReply, SIGNAL(finished()), q_func(), SLOT(_q_getFinished())); + + status = QMediaImageViewer::LoadingMedia; + } else if (mimeType.isEmpty() && url.scheme() != QLatin1String("file")) { + headReply = network->head(QNetworkRequest(currentMedia.url())); + QObject::connect(headReply, SIGNAL(finished()), q_func(), SLOT(_q_headFinished())); + + status = QMediaImageViewer::LoadingMedia; + } + } + + if (status == QMediaImageViewer::InvalidMedia) + currentMedia = QMediaResource(); + + if (status != currentStatus) + emit q_func()->mediaStatusChanged(status); +} + +void QMediaImageViewerControlPrivate::cancelRequests() +{ + if (getReply) { + getReply->abort(); + getReply->deleteLater(); + getReply = 0; + } + + if (headReply) { + headReply->abort(); + headReply->deleteLater(); + headReply = 0; + } +} + +void QMediaImageViewerControlPrivate::_q_getFinished() +{ + if (getReply != q_func()->sender()) + return; + + QImage image; + + if (service->d_func()->load(getReply)) { + possibleResources.clear(); + + status = QMediaImageViewer::LoadedMedia; + + emit q_func()->mediaStatusChanged(status); + } else { + loadImage(); + } +} + +void QMediaImageViewerControlPrivate::_q_headFinished() +{ + if (headReply != q_func()->sender()) + return; + + QString mimeType = headReply->header(QNetworkRequest::ContentTypeHeader) + .toString().section(QLatin1Char(';'), 0, 0); + QUrl url = headReply->url(); + if (url.isEmpty()) + url = headReply->request().url(); + + headReply->deleteLater(); + headReply = 0; + + if (isImageType(url, mimeType) || mimeType.isEmpty()) { + QNetworkAccessManager *network = service->networkManager(); + + getReply = network->get(QNetworkRequest(url)); + + QObject::connect(getReply, SIGNAL(finished()), q_func(), SLOT(_q_getFinished())); + } else { + loadImage(); + } +} + +/*! + \class QMediaImageViewerControl + \internal + \since 1.1 +*/ +QMediaImageViewerControl::QMediaImageViewerControl(QMediaImageViewerService *parent) + : QMediaControl(*new QMediaImageViewerControlPrivate, parent) +{ + Q_D(QMediaImageViewerControl); + + d->service = parent; +} + +/*! +*/ +QMediaImageViewerControl::~QMediaImageViewerControl() +{ + Q_D(QMediaImageViewerControl); + + delete d->getReply; +} + +/*! + \since 1.1 +*/ +QMediaImageViewer::MediaStatus QMediaImageViewerControl::mediaStatus() const +{ + return d_func()->status; +} + +/*! + \fn QMediaImageViewerControl::mediaStatusChanged(QMediaImageViewer::MediaStatus status); + \since 1.1 +*/ + +/*! + \since 1.1 +*/ +void QMediaImageViewerControl::showMedia(const QMediaContent &media) +{ + Q_D(QMediaImageViewerControl); + + d->media = media; + d->currentMedia = QMediaResource(); + d->cancelRequests(); + + if (media.isNull()) { + d->service->d_func()->clear(); + if (d->status != QMediaImageViewer::NoMedia) { + d->status = QMediaImageViewer::NoMedia; + emit mediaStatusChanged(d->status); + } + } else { + d->possibleResources = media.resources(); + d->loadImage(); + } +} + + +#include "moc_qmediaimageviewerservice_p.cpp" +QT_END_NAMESPACE + diff --git a/src/multimedia/qmediaimageviewerservice_p.h b/src/multimedia/qmediaimageviewerservice_p.h new file mode 100644 index 000000000..d1b6956d9 --- /dev/null +++ b/src/multimedia/qmediaimageviewerservice_p.h @@ -0,0 +1,147 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QMEDIASLIDESHOWSERVICE_P_H +#define QMEDIASLIDESHOWSERVICE_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 +#include +#include +#include + +#include +#include + +QT_BEGIN_HEADER + +QT_BEGIN_NAMESPACE + +QT_MODULE(Multimedia) + +class QAbstractVideoSurface; +class QNetworkAccessManager; +QT_END_NAMESPACE + +QT_BEGIN_NAMESPACE + +class QMediaImageViewerServicePrivate; + +class Q_AUTOTEST_EXPORT QMediaImageViewerService : public QMediaService +{ + Q_OBJECT +public: + explicit QMediaImageViewerService(QObject *parent = 0); + ~QMediaImageViewerService(); + + QMediaControl *requestControl(const char *name); + void releaseControl(QMediaControl *); + + QNetworkAccessManager *networkManager() const; + void setNetworkManager(QNetworkAccessManager *manager); + +private: + Q_DECLARE_PRIVATE(QMediaImageViewerService) + friend class QMediaImageViewerControl; + friend class QMediaImageViewerControlPrivate; +}; + +class QMediaImageViewerControlPrivate; + +class QMediaImageViewerControl : public QMediaControl +{ + Q_OBJECT +public: + explicit QMediaImageViewerControl(QMediaImageViewerService *parent); + ~QMediaImageViewerControl(); + + QMediaImageViewer::MediaStatus mediaStatus() const; + + void showMedia(const QMediaContent &media); + +Q_SIGNALS: + void mediaStatusChanged(QMediaImageViewer::MediaStatus status); + +private: + Q_DECLARE_PRIVATE(QMediaImageViewerControl) + Q_PRIVATE_SLOT(d_func(), void _q_headFinished()) + Q_PRIVATE_SLOT(d_func(), void _q_getFinished()) +}; + +#define QMediaImageViewerControl_iid "com.nokia.Qt.QMediaImageViewerControl/1.0" +Q_MEDIA_DECLARE_CONTROL(QMediaImageViewerControl, QMediaImageViewerControl_iid) + +class QMediaImageViewerRenderer : public QVideoRendererControl +{ + Q_OBJECT +public: + QMediaImageViewerRenderer(QObject *parent = 0); + ~QMediaImageViewerRenderer(); + + QAbstractVideoSurface *surface() const; + void setSurface(QAbstractVideoSurface *surface); + + void showImage(const QImage &image); + +Q_SIGNALS: + void surfaceChanged(QAbstractVideoSurface *surface); + +private: + QPointer m_surface; + QImage m_image; +}; + +QT_END_NAMESPACE + +QT_END_HEADER + + +#endif diff --git a/src/multimedia/qmedianetworkaccesscontrol.cpp b/src/multimedia/qmedianetworkaccesscontrol.cpp new file mode 100644 index 000000000..a976859ed --- /dev/null +++ b/src/multimedia/qmedianetworkaccesscontrol.cpp @@ -0,0 +1,103 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qmedianetworkaccesscontrol.h" + +QT_BEGIN_NAMESPACE + +/*! + \class QMediaNetworkAccessControl + \preliminary + \brief The QMediaNetworkAccessControl class allows the setting of the Network Access Point for media related activities. + \ingroup multimedia-serv + \inmodule QtMultimedia + \since 1.2 + + The functionality provided by this control allows the + setting of a Network Access Point. + + This control can be used to set a network access for various + network related activities. the exact nature in dependant on the underlying + usage by the supported QMediaObject +*/ + +QMediaNetworkAccessControl::QMediaNetworkAccessControl(QObject *parent) : + QMediaControl(parent) +{ +} + +/*! + Destroys a network access control. +*/ +QMediaNetworkAccessControl::~QMediaNetworkAccessControl() +{ +} + +/*! + \fn void QMediaNetworkAccessControl::setConfigurations(const QList &configurations); + + \a configurations contains a list of network configurations to be used for network access. + + It is assumed the list is given in highest to lowest preference order. + By calling this function all previous configurations will be invalidated + and replaced with the new list. + \since 1.2 +*/ + +/* + \fn QNetworkConfiguration QMediaNetworkAccessControl::currentConfiguration() const + + Returns the current active configuration in use. + A default constructed QNetworkConfigration is returned if no user supplied configuration are in use. +*/ + + +/*! + \fn QMediaNetworkAccessControl::configurationChanged(const QNetworkConfiguration &configuration) + This signal is emitted when the current active network configuration changes + to \a configuration. + \since 1.2 +*/ + + + +#include "moc_qmedianetworkaccesscontrol.cpp" +QT_END_NAMESPACE diff --git a/src/multimedia/qmedianetworkaccesscontrol.h b/src/multimedia/qmedianetworkaccesscontrol.h new file mode 100644 index 000000000..22ee95711 --- /dev/null +++ b/src/multimedia/qmedianetworkaccesscontrol.h @@ -0,0 +1,83 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + + +#ifndef QMEDIANETWORKACCESSCONTROL_H +#define QMEDIANETWORKACCESSCONTROL_H + +#include "qmediacontrol.h" + +#include +#include + +QT_BEGIN_HEADER + +QT_BEGIN_NAMESPACE + +QT_MODULE(Multimedia) + + +class Q_MULTIMEDIA_EXPORT QMediaNetworkAccessControl : public QMediaControl +{ + Q_OBJECT +public: + + virtual ~QMediaNetworkAccessControl(); + + virtual void setConfigurations(const QList &configuration) = 0; + virtual QNetworkConfiguration currentConfiguration() const = 0; + +Q_SIGNALS: + void configurationChanged(const QNetworkConfiguration& configuration); + +protected: + QMediaNetworkAccessControl(QObject *parent = 0); +}; + +#define QMediaNetworkAccessControl_iid "com.nokia.Qt.QMediaNetworkAccessControl/1.0" +Q_MEDIA_DECLARE_CONTROL(QMediaNetworkAccessControl, QMediaNetworkAccessControl_iid) + +QT_END_NAMESPACE + +QT_END_HEADER + + +#endif diff --git a/src/multimedia/qmediaobject.cpp b/src/multimedia/qmediaobject.cpp new file mode 100644 index 000000000..7eb1a2dfa --- /dev/null +++ b/src/multimedia/qmediaobject.cpp @@ -0,0 +1,423 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include +#include + +#include "qmediaobject_p.h" + +#include +#include +#include + + +QT_BEGIN_NAMESPACE + +void QMediaObjectPrivate::_q_notify() +{ + Q_Q(QMediaObject); + + const QMetaObject* m = q->metaObject(); + + foreach (int pi, notifyProperties) { + QMetaProperty p = m->property(pi); + p.notifySignal().invoke( + q, QGenericArgument(QMetaType::typeName(p.userType()), p.read(q).data())); + } +} + + +/*! + \class QMediaObject + + \brief The QMediaObject class provides a common base for multimedia objects. + + \inmodule QtMultimedia + \ingroup multimedia + \since 1.0 + + QMediaObject derived classes provide access to the functionality of a + QMediaService. Each media object hosts a QMediaService and uses the + QMediaControl interfaces implemented by the service to implement its + API. Most media objects when constructed will request a new + QMediaService instance from a QMediaServiceProvider, but some like + QMediaRecorder will share a service with another object. + + QMediaObject itself provides an API for accessing a media + service's \l {metaData()}{meta-data} and a means of connecting other media objects, + and peripheral classes like QVideoWidget and QMediaPlaylist. + + \sa QMediaService, QMediaControl +*/ + +/*! + Destroys this media object. +*/ + +QMediaObject::~QMediaObject() +{ + delete d_ptr; +} + +/*! + Returns the service availability error state. + \since 1.0 +*/ + +QtMultimedia::AvailabilityError QMediaObject::availabilityError() const +{ + return d_func()->service == 0 ? QtMultimedia::ServiceMissingError : QtMultimedia::NoError; +} + +/*! + Returns true if the service is available for use. + \since 1.0 +*/ + +bool QMediaObject::isAvailable() const +{ + return d_func()->service != 0; +} + +/*! + Returns the media service that provides the functionality of this multimedia object. + \since 1.0 +*/ + +QMediaService* QMediaObject::service() const +{ + return d_func()->service; +} + +int QMediaObject::notifyInterval() const +{ + return d_func()->notifyTimer->interval(); +} + +void QMediaObject::setNotifyInterval(int milliSeconds) +{ + Q_D(QMediaObject); + + if (d->notifyTimer->interval() != milliSeconds) { + d->notifyTimer->setInterval(milliSeconds); + + emit notifyIntervalChanged(milliSeconds); + } +} + +/*! + Bind \a object to this QMediaObject instance. + + This method establishes a relationship between this media object and a + helper object. The nature of the relationship depends on both parties. This + methods returns true if the helper was successfully bound, false otherwise. + + Most subclasses of QMediaObject provide more convenient functions + that wrap this functionality, so this function rarely needs to be + called directly. + + The object passed must implement the QMediaBindableInterface interface. + + \since 1.0 + \sa QMediaBindableInterface +*/ +bool QMediaObject::bind(QObject *object) +{ + QMediaBindableInterface *helper = qobject_cast(object); + if (!helper) + return false; + + QMediaObject *currentObject = helper->mediaObject(); + + if (currentObject == this) + return true; + + if (currentObject) + currentObject->unbind(object); + + return helper->setMediaObject(this); +} + +/*! + Detach \a object from the QMediaObject instance. + + Unbind the helper object from this media object. A warning + will be generated if the object was not previously bound to this + object. + + \since 1.0 + \sa QMediaBindableInterface +*/ +void QMediaObject::unbind(QObject *object) +{ + QMediaBindableInterface *helper = qobject_cast(object); + + if (helper && helper->mediaObject() == this) + helper->setMediaObject(0); + else + qWarning() << "QMediaObject: Trying to unbind not connected helper object"; +} + +/*! + Constructs a media object which uses the functionality provided by a media \a service. + + The \a parent is passed to QObject. + + This class is meant as a base class for multimedia objects so this + constructor is protected. + \since 1.0 +*/ + +QMediaObject::QMediaObject(QObject *parent, QMediaService *service): + QObject(parent), + d_ptr(new QMediaObjectPrivate) + +{ + Q_D(QMediaObject); + + d->q_ptr = this; + + d->notifyTimer = new QTimer(this); + d->notifyTimer->setInterval(1000); + connect(d->notifyTimer, SIGNAL(timeout()), SLOT(_q_notify())); + + d->service = service; + + setupMetaData(); +} + +/*! + \internal +*/ + +QMediaObject::QMediaObject(QMediaObjectPrivate &dd, QObject *parent, + QMediaService *service): + QObject(parent), + d_ptr(&dd) +{ + Q_D(QMediaObject); + d->q_ptr = this; + + d->notifyTimer = new QTimer(this); + d->notifyTimer->setInterval(1000); + connect(d->notifyTimer, SIGNAL(timeout()), SLOT(_q_notify())); + + d->service = service; + + setupMetaData(); +} + +/*! + Watch the property \a name. The property's notify signal will be emitted + once every \code notifyInterval milliseconds. + + \since 1.0 + \sa notifyInterval +*/ + +void QMediaObject::addPropertyWatch(QByteArray const &name) +{ + Q_D(QMediaObject); + + const QMetaObject* m = metaObject(); + + int index = m->indexOfProperty(name.constData()); + + if (index != -1 && m->property(index).hasNotifySignal()) { + d->notifyProperties.insert(index); + + if (!d->notifyTimer->isActive()) + d->notifyTimer->start(); + } +} + +/*! + Remove property \a name from the list of properties whose changes are + regularly signaled. + + \since 1.0 + \sa notifyInterval +*/ + +void QMediaObject::removePropertyWatch(QByteArray const &name) +{ + Q_D(QMediaObject); + + int index = metaObject()->indexOfProperty(name.constData()); + + if (index != -1) { + d->notifyProperties.remove(index); + + if (d->notifyProperties.isEmpty()) + d->notifyTimer->stop(); + } +} + +/*! + \property QMediaObject::notifyInterval + + The interval at which notifiable properties will update. + + The interval is expressed in milliseconds, the default value is 1000. + + \since 1.0 + \sa addPropertyWatch(), removePropertyWatch() +*/ + +/*! + \fn void QMediaObject::notifyIntervalChanged(int milliseconds) + + Signal a change in the notify interval period to \a milliseconds. + \since 1.0 +*/ + +/*! + Returns true if there is meta-data associated with this media object, else false. + \since 1.0 +*/ + +bool QMediaObject::isMetaDataAvailable() const +{ + Q_D(const QMediaObject); + + return d->metaDataControl + ? d->metaDataControl->isMetaDataAvailable() + : false; +} + +/*! + \fn QMediaObject::metaDataAvailableChanged(bool available) + + Signals that the \a available state of a media object's meta-data has changed. + \since 1.0 +*/ + +/*! + Returns the value associated with a meta-data \a key. + \since 1.0 +*/ +QVariant QMediaObject::metaData(QtMultimedia::MetaData key) const +{ + Q_D(const QMediaObject); + + return d->metaDataControl + ? d->metaDataControl->metaData(key) + : QVariant(); +} + +/*! + Returns a list of keys there is meta-data available for. + \since 1.0 +*/ +QList QMediaObject::availableMetaData() const +{ + Q_D(const QMediaObject); + + return d->metaDataControl + ? d->metaDataControl->availableMetaData() + : QList(); +} + +/*! + \fn QMediaObject::metaDataChanged() + + Signals that this media object's meta-data has changed. + \since 1.0 +*/ + +/*! + Returns the value associated with a meta-data \a key. + + The naming and type of extended meta-data is not standardized, so the values and meaning + of keys may vary between backends. + \since 1.0 +*/ +QVariant QMediaObject::extendedMetaData(const QString &key) const +{ + Q_D(const QMediaObject); + + return d->metaDataControl + ? d->metaDataControl->extendedMetaData(key) + : QVariant(); +} + +/*! + Returns a list of keys there is extended meta-data available for. + \since 1.0 +*/ +QStringList QMediaObject::availableExtendedMetaData() const +{ + Q_D(const QMediaObject); + + return d->metaDataControl + ? d->metaDataControl->availableExtendedMetaData() + : QStringList(); +} + + +void QMediaObject::setupMetaData() +{ + Q_D(QMediaObject); + + if (d->service != 0) { + d->metaDataControl = qobject_cast( + d->service->requestControl(QMetaDataReaderControl_iid)); + + if (d->metaDataControl) { + connect(d->metaDataControl, SIGNAL(metaDataChanged()), SIGNAL(metaDataChanged())); + connect(d->metaDataControl, + SIGNAL(metaDataAvailableChanged(bool)), + SIGNAL(metaDataAvailableChanged(bool))); + } + } +} + +/*! + \fn QMediaObject::availabilityChanged(bool available) + + Signal emitted when the availability state has changed to \a available + \since 1.0 +*/ + + +#include "moc_qmediaobject.cpp" +QT_END_NAMESPACE + diff --git a/src/multimedia/qmediaobject.h b/src/multimedia/qmediaobject.h new file mode 100644 index 000000000..aba8f7021 --- /dev/null +++ b/src/multimedia/qmediaobject.h @@ -0,0 +1,118 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QABSTRACTMEDIAOBJECT_H +#define QABSTRACTMEDIAOBJECT_H + +#include +#include + +#include +#include "qtmedianamespace.h" + +QT_BEGIN_HEADER + +QT_BEGIN_NAMESPACE + +QT_MODULE(Multimedia) + + +class QMediaService; +class QMediaBindableInterface; + +class QMediaObjectPrivate; +class Q_MULTIMEDIA_EXPORT QMediaObject : public QObject +{ + Q_OBJECT + Q_PROPERTY(int notifyInterval READ notifyInterval WRITE setNotifyInterval NOTIFY notifyIntervalChanged) +public: + ~QMediaObject(); + + virtual bool isAvailable() const; + virtual QtMultimedia::AvailabilityError availabilityError() const; + + virtual QMediaService* service() const; + + int notifyInterval() const; + void setNotifyInterval(int milliSeconds); + + virtual bool bind(QObject *); + virtual void unbind(QObject *); + + bool isMetaDataAvailable() const; + + QVariant metaData(QtMultimedia::MetaData key) const; + QList availableMetaData() const; + + QVariant extendedMetaData(const QString &key) const; + QStringList availableExtendedMetaData() const; + +Q_SIGNALS: + void notifyIntervalChanged(int milliSeconds); + + void metaDataAvailableChanged(bool available); + void metaDataChanged(); + + void availabilityChanged(bool available); + +protected: + QMediaObject(QObject *parent, QMediaService *service); + QMediaObject(QMediaObjectPrivate &dd, QObject *parent, QMediaService *service); + + void addPropertyWatch(QByteArray const &name); + void removePropertyWatch(QByteArray const &name); + + QMediaObjectPrivate *d_ptr; + +private: + void setupMetaData(); + + Q_DECLARE_PRIVATE(QMediaObject) + Q_PRIVATE_SLOT(d_func(), void _q_notify()) +}; + + +QT_END_NAMESPACE + +QT_END_HEADER + + +#endif // QABSTRACTMEDIAOBJECT_H diff --git a/src/multimedia/qmediaobject_p.h b/src/multimedia/qmediaobject_p.h new file mode 100644 index 000000000..f27420cf0 --- /dev/null +++ b/src/multimedia/qmediaobject_p.h @@ -0,0 +1,99 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QABSTRACTMEDIAOBJECT_P_H +#define QABSTRACTMEDIAOBJECT_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 +#include +#include + +#include "qmediaobject.h" + +QT_BEGIN_HEADER + +QT_BEGIN_NAMESPACE + +QT_MODULE(Multimedia) + + +class QMetaDataReaderControl; + +#define Q_DECLARE_NON_CONST_PUBLIC(Class) \ + inline Class* q_func() { return static_cast(q_ptr); } \ + friend class Class; + + +class QMediaObjectPrivate +{ + Q_DECLARE_PUBLIC(QMediaObject) + +public: + QMediaObjectPrivate():metaDataControl(0), notifyTimer(0) {} + virtual ~QMediaObjectPrivate() {} + + void _q_notify(); + + QMediaService *service; + QMetaDataReaderControl *metaDataControl; + QTimer* notifyTimer; + QSet notifyProperties; + + QMediaObject *q_ptr; +}; + +QT_END_NAMESPACE + +QT_END_HEADER + + +#endif diff --git a/src/multimedia/qmediaplayer.cpp b/src/multimedia/qmediaplayer.cpp new file mode 100644 index 000000000..5d5a7a7a3 --- /dev/null +++ b/src/multimedia/qmediaplayer.cpp @@ -0,0 +1,1139 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include +#include +#include +#include +#include + + +#include "qmediaplayer.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +QT_BEGIN_NAMESPACE + +/*! + \class QMediaPlayer + \brief The QMediaPlayer class allows the playing of a media source. + \inmodule QtMultimedia + \ingroup multimedia + \since 1.0 + + + + The QMediaPlayer class is a high level media playback class. It can be used + to playback such content as songs, movies and internet radio. The content + to playback is specified as a QMediaContent, which can be thought of as a + main or canonical URL with addition information attached. When provided + with a QMediaContent playback may be able to commence. + + \snippet doc/src/snippets/multimedia-snippets/media.cpp Player + + QVideoWidget can be used with QMediaPlayer for video rendering and QMediaPlaylist + for accessing playlist functionality. + + \snippet doc/src/snippets/multimedia-snippets/media.cpp Movie playlist + + \sa QMediaObject, QMediaService, QVideoWidget, QMediaPlaylist +*/ + +namespace +{ +class MediaPlayerRegisterMetaTypes +{ +public: + MediaPlayerRegisterMetaTypes() + { + qRegisterMetaType("QMediaPlayer::State"); + qRegisterMetaType("QMediaPlayer::MediaStatus"); + qRegisterMetaType("QMediaPlayer::Error"); + } +} _registerPlayerMetaTypes; +} + +class QMediaPlayerPrivate : public QMediaObjectPrivate +{ + Q_DECLARE_NON_CONST_PUBLIC(QMediaPlayer) + +public: + QMediaPlayerPrivate() + : provider(0) + , control(0) + , playlistSourceControl(0) + , state(QMediaPlayer::StoppedState) + , error(QMediaPlayer::NoError) + , filterStates(false) + , playlist(0) + {} + + QMediaServiceProvider *provider; + QMediaPlayerControl* control; + QMediaPlaylistSourceControl* playlistSourceControl; + QMediaPlayer::State state; + QMediaPlayer::Error error; + QString errorString; + bool filterStates; + + QPointer videoOutput; + QMediaPlaylist *playlist; + QMediaNetworkAccessControl *networkAccessControl; + QVideoSurfaceOutput surfaceOutput; + + void _q_stateChanged(QMediaPlayer::State state); + void _q_mediaStatusChanged(QMediaPlayer::MediaStatus status); + void _q_error(int error, const QString &errorString); + void _q_updateMedia(const QMediaContent&); + void _q_playlistDestroyed(); +}; + +void QMediaPlayerPrivate::_q_stateChanged(QMediaPlayer::State ps) +{ + Q_Q(QMediaPlayer); + + if (filterStates) + return; + + if (playlist + && ps != state && ps == QMediaPlayer::StoppedState + && (control->mediaStatus() == QMediaPlayer::EndOfMedia || + control->mediaStatus() == QMediaPlayer::InvalidMedia)) { + playlist->next(); + ps = control->state(); + } + + if (ps != state) { + state = ps; + + if (ps == QMediaPlayer::PlayingState) + q->addPropertyWatch("position"); + else + q->removePropertyWatch("position"); + + emit q->stateChanged(ps); + } +} + +void QMediaPlayerPrivate::_q_mediaStatusChanged(QMediaPlayer::MediaStatus status) +{ + Q_Q(QMediaPlayer); + + switch (status) { + case QMediaPlayer::StalledMedia: + case QMediaPlayer::BufferingMedia: + q->addPropertyWatch("bufferStatus"); + emit q->mediaStatusChanged(status); + break; + default: + q->removePropertyWatch("bufferStatus"); + emit q->mediaStatusChanged(status); + break; + } + +} + +void QMediaPlayerPrivate::_q_error(int error, const QString &errorString) +{ + Q_Q(QMediaPlayer); + + this->error = QMediaPlayer::Error(error); + this->errorString = errorString; + + emit q->error(this->error); +} + +void QMediaPlayerPrivate::_q_updateMedia(const QMediaContent &media) +{ + Q_Q(QMediaPlayer); + + if (!control) + return; + + const QMediaPlayer::State currentState = state; + + filterStates = true; + control->setMedia(media, 0); + + if (!media.isNull()) { + switch (currentState) { + case QMediaPlayer::PlayingState: + control->play(); + break; + case QMediaPlayer::PausedState: + control->pause(); + break; + default: + break; + } + } + filterStates = false; + + state = control->state(); + + if (state != currentState) { + if (state == QMediaPlayer::PlayingState) + q->addPropertyWatch("position"); + else + q->removePropertyWatch("position"); + + emit q->stateChanged(state); + } +} + +void QMediaPlayerPrivate::_q_playlistDestroyed() +{ + playlist = 0; + + if (!control) + return; + + if (playlistSourceControl) + playlistSourceControl->setPlaylist(0); + + control->setMedia(QMediaContent(), 0); +} + +static QMediaService *playerService(QMediaPlayer::Flags flags, QMediaServiceProvider *provider) +{ + if (flags) { + QMediaServiceProviderHint::Features features = 0; + if (flags & QMediaPlayer::LowLatency) + features |= QMediaServiceProviderHint::LowLatencyPlayback; + + if (flags & QMediaPlayer::StreamPlayback) + features |= QMediaServiceProviderHint::StreamPlayback; + + if (flags & QMediaPlayer::VideoSurface) + features |= QMediaServiceProviderHint::VideoSurface; + + return provider->requestService(Q_MEDIASERVICE_MEDIAPLAYER, + QMediaServiceProviderHint(features)); + } else + return provider->requestService(Q_MEDIASERVICE_MEDIAPLAYER); +} + + +/*! + Construct a QMediaPlayer that uses the playback service from \a provider, + parented to \a parent and with \a flags. + + If a playback service is not specified the system default will be used. + \since 1.0 +*/ + +QMediaPlayer::QMediaPlayer(QObject *parent, QMediaPlayer::Flags flags, QMediaServiceProvider *provider): + QMediaObject(*new QMediaPlayerPrivate, + parent, + playerService(flags,provider)) +{ + Q_D(QMediaPlayer); + + d->provider = provider; + + if (d->service == 0) { + d->error = ServiceMissingError; + } else { + d->control = qobject_cast(d->service->requestControl(QMediaPlayerControl_iid)); + d->playlistSourceControl = qobject_cast(d->service->requestControl(QMediaPlaylistSourceControl_iid)); + d->networkAccessControl = qobject_cast(d->service->requestControl(QMediaNetworkAccessControl_iid)); + if (d->control != 0) { + connect(d->control, SIGNAL(mediaChanged(QMediaContent)), SIGNAL(mediaChanged(QMediaContent))); + connect(d->control, SIGNAL(stateChanged(QMediaPlayer::State)), SLOT(_q_stateChanged(QMediaPlayer::State))); + connect(d->control, SIGNAL(mediaStatusChanged(QMediaPlayer::MediaStatus)), + SLOT(_q_mediaStatusChanged(QMediaPlayer::MediaStatus))); + connect(d->control, SIGNAL(error(int,QString)), SLOT(_q_error(int,QString))); + + connect(d->control, SIGNAL(durationChanged(qint64)), SIGNAL(durationChanged(qint64))); + connect(d->control, SIGNAL(positionChanged(qint64)), SIGNAL(positionChanged(qint64))); + connect(d->control, SIGNAL(audioAvailableChanged(bool)), SIGNAL(audioAvailableChanged(bool))); + connect(d->control, SIGNAL(videoAvailableChanged(bool)), SIGNAL(videoAvailableChanged(bool))); + connect(d->control, SIGNAL(volumeChanged(int)), SIGNAL(volumeChanged(int))); + connect(d->control, SIGNAL(mutedChanged(bool)), SIGNAL(mutedChanged(bool))); + connect(d->control, SIGNAL(seekableChanged(bool)), SIGNAL(seekableChanged(bool))); + connect(d->control, SIGNAL(playbackRateChanged(qreal)), SIGNAL(playbackRateChanged(qreal))); + connect(d->control, SIGNAL(bufferStatusChanged(int)), SIGNAL(bufferStatusChanged(int))); + + if (d->control->state() == PlayingState) + addPropertyWatch("position"); + + if (d->control->mediaStatus() == StalledMedia || d->control->mediaStatus() == BufferingMedia) + addPropertyWatch("bufferStatus"); + } + if (d->networkAccessControl != 0) { + connect(d->networkAccessControl, SIGNAL(configurationChanged(QNetworkConfiguration)), + this, SIGNAL(networkConfigurationChanged(QNetworkConfiguration))); + } + } +} + + +/*! + Destroys the player object. +*/ + +QMediaPlayer::~QMediaPlayer() +{ + Q_D(QMediaPlayer); + + if (d->service) { + if (d->control) + d->service->releaseControl(d->control); + } + + d->provider->releaseService(d->service); +} + +QMediaContent QMediaPlayer::media() const +{ + Q_D(const QMediaPlayer); + + if (d->control != 0) + return d->control->media(); + + return QMediaContent(); +} + +/*! + Returns the stream source of media data. + + This is only valid if a stream was passed to setMedia(). + + \since 1.0 + \sa setMedia() +*/ + +const QIODevice *QMediaPlayer::mediaStream() const +{ + Q_D(const QMediaPlayer); + + if (d->control != 0) + return d->control->mediaStream(); + + return 0; +} + +QMediaPlaylist *QMediaPlayer::playlist() const +{ + return d_func()->playlistSourceControl ? + d_func()->playlistSourceControl->playlist() : + d_func()->playlist; +} + +void QMediaPlayer::setPlaylist(QMediaPlaylist *playlist) +{ + Q_D(QMediaPlayer); + + if (d->playlistSourceControl) { + if (d->playlistSourceControl->playlist()) + disconnect(d->playlist, SIGNAL(destroyed()), this, SLOT(_q_playlistDestroyed())); + + d->playlistSourceControl->setPlaylist(playlist); + + if (playlist) + connect(d->playlist, SIGNAL(destroyed()), this, SLOT(_q_playlistDestroyed())); + } else { + if (d->playlist) { + disconnect(d->playlist, SIGNAL(currentMediaChanged(QMediaContent)), + this, SLOT(_q_updateMedia(QMediaContent))); + disconnect(d->playlist, SIGNAL(destroyed()), this, SLOT(_q_playlistDestroyed())); + } + + d->playlist = playlist; + + if (d->playlist) { + connect(d->playlist, SIGNAL(currentMediaChanged(QMediaContent)), + this, SLOT(_q_updateMedia(QMediaContent))); + connect(d->playlist, SIGNAL(destroyed()), this, SLOT(_q_playlistDestroyed())); + + if (d->control != 0) + d->control->setMedia(playlist->currentMedia(), 0); + } else { + setMedia(QMediaContent(), 0); + } + + } +} + +/*! + Sets the network access points for remote media playback. + \a configurations contains, in ascending preferential order, a list of + configuration that can be used for network access. + + This will invalidate the choice of previous configurations. + \since 1.2 +*/ +void QMediaPlayer::setNetworkConfigurations(const QList &configurations) +{ + Q_D(QMediaPlayer); + + if (d->networkAccessControl) + d->networkAccessControl->setConfigurations(configurations); +} + +QMediaPlayer::State QMediaPlayer::state() const +{ + return d_func()->state; +} + +QMediaPlayer::MediaStatus QMediaPlayer::mediaStatus() const +{ + Q_D(const QMediaPlayer); + + if (d->control != 0) + return d->control->mediaStatus(); + + return QMediaPlayer::UnknownMediaStatus; +} + +qint64 QMediaPlayer::duration() const +{ + Q_D(const QMediaPlayer); + + if (d->control != 0) + return d->control->duration(); + + return -1; +} + +qint64 QMediaPlayer::position() const +{ + Q_D(const QMediaPlayer); + + if (d->control != 0) + return d->control->position(); + + return 0; +} + +int QMediaPlayer::volume() const +{ + Q_D(const QMediaPlayer); + + if (d->control != 0) + return d->control->volume(); + + return 0; +} + +bool QMediaPlayer::isMuted() const +{ + Q_D(const QMediaPlayer); + + if (d->control != 0) + return d->control->isMuted(); + + return false; +} + +int QMediaPlayer::bufferStatus() const +{ + Q_D(const QMediaPlayer); + + if (d->control != 0) + return d->control->bufferStatus(); + + return 0; +} + +bool QMediaPlayer::isAudioAvailable() const +{ + Q_D(const QMediaPlayer); + + if (d->control != 0) + return d->control->isAudioAvailable(); + + return false; +} + +bool QMediaPlayer::isVideoAvailable() const +{ + Q_D(const QMediaPlayer); + + if (d->control != 0) + return d->control->isVideoAvailable(); + + return false; +} + +bool QMediaPlayer::isSeekable() const +{ + Q_D(const QMediaPlayer); + + if (d->control != 0) + return d->control->isSeekable(); + + return false; +} + +qreal QMediaPlayer::playbackRate() const +{ + Q_D(const QMediaPlayer); + + if (d->control != 0) + return d->control->playbackRate(); + + return 0.0; +} + +/*! + Returns the current error state. + \since 1.0 +*/ + +QMediaPlayer::Error QMediaPlayer::error() const +{ + return d_func()->error; +} + +QString QMediaPlayer::errorString() const +{ + return d_func()->errorString; +} + +/*! + Returns the current network access point in use. + If a default contructed QNetworkConfiguration is returned + this feature is not available or that none of the + current supplied configurations are in use. + \since 1.2 +*/ +QNetworkConfiguration QMediaPlayer::currentNetworkConfiguration() const +{ + Q_D(const QMediaPlayer); + + if (d->networkAccessControl) + return d_func()->networkAccessControl->currentConfiguration(); + + return QNetworkConfiguration(); +} + +//public Q_SLOTS: +/*! + Start or resume playing the current source. + \since 1.0 +*/ + +void QMediaPlayer::play() +{ + Q_D(QMediaPlayer); + + if (d->control == 0) { + QMetaObject::invokeMethod(this, "_q_error", Qt::QueuedConnection, + Q_ARG(int, QMediaPlayer::ServiceMissingError), + Q_ARG(QString, tr("The QMediaPlayer object does not have a valid service"))); + return; + } + + //if playlist control is available, the service should advance itself + if (d->playlist && d->playlist->currentIndex() == -1 && !d->playlist->isEmpty()) + d->playlist->setCurrentIndex(0); + + // Reset error conditions + d->error = NoError; + d->errorString = QString(); + + d->control->play(); +} + +/*! + Pause playing the current source. + \since 1.0 +*/ + +void QMediaPlayer::pause() +{ + Q_D(QMediaPlayer); + + if (d->control != 0) + d->control->pause(); +} + +/*! + Stop playing, and reset the play position to the beginning. + \since 1.0 +*/ + +void QMediaPlayer::stop() +{ + Q_D(QMediaPlayer); + + if (d->control != 0) + d->control->stop(); +} + +void QMediaPlayer::setPosition(qint64 position) +{ + Q_D(QMediaPlayer); + + if (d->control == 0 || !isSeekable()) + return; + + d->control->setPosition(qBound(qint64(0), position, duration())); +} + +void QMediaPlayer::setVolume(int v) +{ + Q_D(QMediaPlayer); + + if (d->control == 0) + return; + + int clamped = qBound(0, v, 100); + if (clamped == volume()) + return; + + d->control->setVolume(clamped); +} + +void QMediaPlayer::setMuted(bool muted) +{ + Q_D(QMediaPlayer); + + if (d->control == 0 || muted == isMuted()) + return; + + d->control->setMuted(muted); +} + +void QMediaPlayer::setPlaybackRate(qreal rate) +{ + Q_D(QMediaPlayer); + + if (d->control != 0) + d->control->setPlaybackRate(rate); +} + +/*! + Sets the current \a media source. + + If a \a stream is supplied; media data will be read from it instead of resolving the media + source. In this case the media source may still be used to resolve additional information + about the media such as mime type. + + Setting the media to a null QMediaContent will cause the player to discard all + information relating to the current media source and to cease all I/O operations related + to that media. + \since 1.0 +*/ + +void QMediaPlayer::setMedia(const QMediaContent &media, QIODevice *stream) +{ + Q_D(QMediaPlayer); + + if (playlist() && playlist()->currentMedia() != media) + setPlaylist(0); + + if (d->control != 0) + d_func()->control->setMedia(media, stream); +} + +/*! + \internal + \since 1.0 +*/ + +bool QMediaPlayer::bind(QObject *obj) +{ + return QMediaObject::bind(obj); +} + +/*! + \internal + \since 1.0 +*/ + +void QMediaPlayer::unbind(QObject *obj) +{ + QMediaObject::unbind(obj); +} + +/*! + Returns the level of support a media player has for a \a mimeType and a set of \a codecs. + + The \a flags argument allows additional requirements such as performance indicators to be + specified. + \since 1.0 +*/ +QtMultimedia::SupportEstimate QMediaPlayer::hasSupport(const QString &mimeType, + const QStringList& codecs, + Flags flags) +{ + return QMediaServiceProvider::defaultServiceProvider()->hasSupport(QByteArray(Q_MEDIASERVICE_MEDIAPLAYER), + mimeType, + codecs, + flags); +} + +/*! + \deprecated + Returns a list of MIME types supported by the media player. + + The \a flags argument causes the resultant list to be restricted to MIME types which can be supported + given additional requirements, such as performance indicators. + + This function may not return useful results on some platforms, and support for a specific file of a + given mime type is not guaranteed even if the mime type is in general supported. In addition, in some + cases this function will need to load all available media plugins and query them for their support, which + may take some time. + \since 1.0 +*/ +QStringList QMediaPlayer::supportedMimeTypes(Flags flags) +{ + return QMediaServiceProvider::defaultServiceProvider()->supportedMimeTypes(QByteArray(Q_MEDIASERVICE_MEDIAPLAYER), + flags); +} + +/*! + \fn void QMediaPlayer::setVideoOutput(QVideoWidget* output) + + Attach a QVideoWidget video \a output to the media player. + + If the media player has already video output attached, + it will be replaced with a new one. + \since 1.0 +*/ +void QMediaPlayer::setVideoOutput(QVideoWidget *output) +{ + Q_D(QMediaPlayer); + + if (d->videoOutput) + unbind(d->videoOutput); + + // We don't know (in this library) that QVideoWidget inherits QObject + QObject *outputObject = reinterpret_cast(output); + + d->videoOutput = outputObject && bind(outputObject) ? outputObject : 0; +} + +/*! + \fn void QMediaPlayer::setVideoOutput(QGraphicsVideoItem* output) + + Attach a QGraphicsVideoItem video \a output to the media player. + + If the media player has already video output attached, + it will be replaced with a new one. + \since 1.0 +*/ +void QMediaPlayer::setVideoOutput(QGraphicsVideoItem *output) +{ + Q_D(QMediaPlayer); + + if (d->videoOutput) + unbind(d->videoOutput); + + // We don't know (in this library) that QGraphicsVideoItem (multiply) inherits QObject + // but QObject inheritance depends on QObject coming first, so try this out. + QObject *outputObject = reinterpret_cast(output); + + d->videoOutput = outputObject && bind(outputObject) ? outputObject : 0; +} + +/*! + Sets a video \a surface as the video output of a media player. + + If a video output has already been set on the media player the new surface + will replace it. + \since 1.2 +*/ + +void QMediaPlayer::setVideoOutput(QAbstractVideoSurface *surface) +{ + Q_D(QMediaPlayer); + + d->surfaceOutput.setVideoSurface(surface); + + if (d->videoOutput != &d->surfaceOutput) { + if (d->videoOutput) + unbind(d->videoOutput); + + d->videoOutput = bind(&d->surfaceOutput) ? &d->surfaceOutput : 0; + } +} + +// Enums +/*! + \enum QMediaPlayer::State + + Defines the current state of a media player. + + \value PlayingState The media player is currently playing content. + \value PausedState The media player has paused playback, playback of the current track will + resume from the position the player was paused at. + \value StoppedState The media player is not playing content, playback will begin from the start + of the current track. +*/ + +/*! + \enum QMediaPlayer::MediaStatus + + Defines the status of a media player's current media. + + \value UnknownMediaStatus The status of the media cannot be determined. + \value NoMedia The is no current media. The player is in the StoppedState. + \value LoadingMedia The current media is being loaded. The player may be in any state. + \value LoadedMedia The current media has been loaded. The player is in the StoppedState. + \value StalledMedia Playback of the current media has stalled due to insufficient buffering or + some other temporary interruption. The player is in the PlayingState or PausedState. + \value BufferingMedia The player is buffering data but has enough data buffered for playback to + continue for the immediate future. The player is in the PlayingState or PausedState. + \value BufferedMedia The player has fully buffered the current media. The player is in the + PlayingState or PausedState. + \value EndOfMedia Playback has reached the end of the current media. The player is in the + StoppedState. + \value InvalidMedia The current media cannot be played. The player is in the StoppedState. +*/ + +/*! + \enum QMediaPlayer::Error + + Defines a media player error condition. + + \value NoError No error has occurred. + \value ResourceError A media resource couldn't be resolved. + \value FormatError The format of a media resource isn't (fully) supported. Playback may still + be possible, but without an audio or video component. + \value NetworkError A network error occurred. + \value AccessDeniedError There are not the appropriate permissions to play a media resource. + \value ServiceMissingError A valid playback service was not found, playback cannot proceed. +*/ + +// Signals +/*! + \fn QMediaPlayer::error(QMediaPlayer::Error error) + + Signals that an \a error condition has occurred. + + \since 1.0 + \sa errorString() +*/ + +/*! + \fn void QMediaPlayer::stateChanged(State state) + + \since 1.0 + Signal the \a state of the Player object has changed. +*/ + +/*! + \fn QMediaPlayer::mediaStatusChanged(QMediaPlayer::MediaStatus status) + + Signals that the \a status of the current media has changed. + + \since 1.0 + \sa mediaStatus() +*/ + +/*! + \fn void QMediaPlayer::mediaChanged(const QMediaContent &media); + + Signals that the current playing content will be obtained from \a media. + + \since 1.0 + \sa media() +*/ + +/*! + \fn void QMediaPlayer::playbackRateChanged(qreal rate); + + Signals the playbackRate has changed to \a rate. + \since 1.0 +*/ + +/*! + \fn void QMediaPlayer::seekableChanged(bool seekable); + + Signals the \a seekable status of the player object has changed. + \since 1.0 +*/ + +// Properties +/*! + \property QMediaPlayer::state + \brief the media player's playback state. + + By default this property is QMediaPlayer::Stopped + + \since 1.0 + \sa mediaStatus(), play(), pause(), stop() +*/ + +/*! + \property QMediaPlayer::error + \brief a string describing the last error condition. + + \since 1.0 + \sa error() +*/ + +/*! + \property QMediaPlayer::media + \brief the active media source being used by the player object. + + The player object will use the QMediaContent for selection of the content to + be played. + + By default this property has a null QMediaContent. + + Setting this property to a null QMediaContent will cause the player to discard all + information relating to the current media source and to cease all I/O operations related + to that media. + + \since 1.0 + \sa QMediaContent +*/ + +/*! + \property QMediaPlayer::playlist + \brief the media playlist being used by the player object. + + The player object will use the current playlist item for selection of the content to + be played. + + By default this property is set to null. + + If the media playlist is used as a source, QMediaPlayer::media is updated with + a current playlist item. The current source should be selected with + QMediaPlaylist::setCurrentIndex(int) instead of QMediaPlayer::setMedia(), + otherwise the current playlist will be discarded. + + \since 1.0 + \sa QMediaContent +*/ + + +/*! + \property QMediaPlayer::mediaStatus + \brief the status of the current media stream. + + The stream status describes how the playback of the current stream is + progressing. + + By default this property is QMediaPlayer::NoMedia + + \since 1.0 + \sa state +*/ + +/*! + \property QMediaPlayer::duration + \brief the duration of the current media. + + The value is the total playback time in milliseconds of the current media. + The value may change across the life time of the QMediaPlayer object and + may not be available when initial playback begins, connect to the + durationChanged() signal to receive status notifications. + \since 1.0 +*/ + +/*! + \property QMediaPlayer::position + \brief the playback position of the current media. + + The value is the current playback position, expressed in milliseconds since + the beginning of the media. Periodically changes in the position will be + indicated with the signal positionChanged(), the interval between updates + can be set with QMediaObject's method setNotifyInterval(). + \since 1.0 +*/ + +/*! + \property QMediaPlayer::volume + \brief the current playback volume. + + The playback volume is a linear in effect and the value can range from 0 - + 100, values outside this range will be clamped. + \since 1.0 +*/ + +/*! + \property QMediaPlayer::muted + \brief the muted state of the current media. + + The value will be true if the playback volume is muted; otherwise false. + \since 1.0 +*/ + +/*! + \property QMediaPlayer::bufferStatus + \brief the percentage of the temporary buffer filled before playback begins. + + When the player object is buffering; this property holds the percentage of + the temporary buffer that is filled. The buffer will need to reach 100% + filled before playback can resume, at which time the MediaStatus will be + BufferedMedia. + + \since 1.0 + \sa mediaStatus() +*/ + +/*! + \property QMediaPlayer::audioAvailable + \brief the audio availabilty status for the current media. + + As the life time of QMediaPlayer can be longer than the playback of one + QMediaContent, this property may change over time, the + audioAvailableChanged signal can be used to monitor it's status. + \since 1.0 +*/ + +/*! + \property QMediaPlayer::videoAvailable + \brief the video availability status for the current media. + + If available, the QVideoWidget class can be used to view the video. As the + life time of QMediaPlayer can be longer than the playback of one + QMediaContent, this property may change over time, the + videoAvailableChanged signal can be used to monitor it's status. + + \since 1.0 + \sa QVideoWidget, QMediaContent +*/ + +/*! + \property QMediaPlayer::seekable + \brief the seek-able status of the current media + + If seeking is supported this property will be true; false otherwise. The + status of this property may change across the life time of the QMediaPlayer + object, use the seekableChanged signal to monitor changes. + \since 1.0 +*/ + +/*! + \property QMediaPlayer::playbackRate + \brief the playback rate of the current media. + + This value is a multiplier applied to the media's standard play rate. By + default this value is 1.0, indicating that the media is playing at the + standard pace. Values higher than 1.0 will increase the rate of play. + Values less than zero can be set and indicate the media will rewind at the + multiplier of the standard pace. + + Not all playback services support change of the playback rate. It is + framework defined as to the status and quality of audio and video + while fast forwarding or rewinding. + \since 1.0 +*/ + +/*! + \fn void QMediaPlayer::durationChanged(qint64 duration) + + Signal the duration of the content has changed to \a duration, expressed in milliseconds. + \since 1.0 +*/ + +/*! + \fn void QMediaPlayer::positionChanged(qint64 position) + + Signal the position of the content has changed to \a position, expressed in + milliseconds. + \since 1.0 +*/ + +/*! + \fn void QMediaPlayer::volumeChanged(int volume) + + Signal the playback volume has changed to \a volume. + \since 1.0 +*/ + +/*! + \fn void QMediaPlayer::mutedChanged(bool muted) + + Signal the mute state has changed to \a muted. + \since 1.0 +*/ + +/*! + \fn void QMediaPlayer::videoAvailableChanged(bool videoAvailable) + + Signal the availability of visual content has changed to \a videoAvailable. + \since 1.0 +*/ + +/*! + \fn void QMediaPlayer::audioAvailableChanged(bool available) + + Signals the availability of audio content has changed to \a available. + \since 1.0 +*/ + +/*! + \fn void QMediaPlayer::bufferStatusChanged(int percentFilled) + + Signal the amount of the local buffer filled as a percentage by \a percentFilled. + \since 1.0 +*/ + +/*! + \fn void QMediaPlayer::networkConfigurationChanged(const QNetworkConfiguration &configuration) + + Signal that the active in use network access point has been changed to \a configuration and all subsequent network access will use this \a configuration. + \since 1.2 +*/ + +/*! + \enum QMediaPlayer::Flag + + \value LowLatency The player is expected to be used with simple audio formats, + but playback should start without significant delay. + Such playback service can be used for beeps, ringtones, etc. + + \value StreamPlayback The player is expected to play QIODevice based streams. + If passed to QMediaPlayer constructor, the service supporting + streams playback will be chosen. + + \value VideoSurface The player is expected to be able to render to a + QAbstractVideoSurface \l {setVideoOutput()}{output}. +*/ + +#include "moc_qmediaplayer.cpp" +QT_END_NAMESPACE + diff --git a/src/multimedia/qmediaplayer.h b/src/multimedia/qmediaplayer.h new file mode 100644 index 000000000..f53b50ceb --- /dev/null +++ b/src/multimedia/qmediaplayer.h @@ -0,0 +1,227 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QMEDIAPLAYER_H +#define QMEDIAPLAYER_H + + +#include "qmediaserviceprovider.h" +#include "qmediaobject.h" +#include "qmediacontent.h" +#include "qmediaenumdebug.h" + +#include + +QT_BEGIN_HEADER + +QT_BEGIN_NAMESPACE + +QT_MODULE(Multimedia) + + +class QAbstractVideoSurface; +class QMediaPlaylist; +class QVideoWidget; +class QGraphicsVideoItem; + +class QMediaPlayerPrivate; +class Q_MULTIMEDIA_EXPORT QMediaPlayer : public QMediaObject +{ + Q_OBJECT + Q_PROPERTY(QMediaContent media READ media WRITE setMedia NOTIFY mediaChanged) + Q_PROPERTY(QMediaPlaylist * playlist READ playlist WRITE setPlaylist) + Q_PROPERTY(qint64 duration READ duration NOTIFY durationChanged) + Q_PROPERTY(qint64 position READ position WRITE setPosition NOTIFY positionChanged) + Q_PROPERTY(int volume READ volume WRITE setVolume NOTIFY volumeChanged) + Q_PROPERTY(bool muted READ isMuted WRITE setMuted NOTIFY mutedChanged) + Q_PROPERTY(int bufferStatus READ bufferStatus NOTIFY bufferStatusChanged) + Q_PROPERTY(bool audioAvailable READ isAudioAvailable NOTIFY audioAvailableChanged) + Q_PROPERTY(bool videoAvailable READ isVideoAvailable NOTIFY videoAvailableChanged) + Q_PROPERTY(bool seekable READ isSeekable NOTIFY seekableChanged) + Q_PROPERTY(qreal playbackRate READ playbackRate WRITE setPlaybackRate NOTIFY playbackRateChanged) + Q_PROPERTY(State state READ state NOTIFY stateChanged) + Q_PROPERTY(MediaStatus mediaStatus READ mediaStatus NOTIFY mediaStatusChanged) + Q_PROPERTY(QString error READ errorString) + Q_ENUMS(State) + Q_ENUMS(MediaStatus) + Q_ENUMS(Error) + +public: + enum State + { + StoppedState, + PlayingState, + PausedState + }; + + enum MediaStatus + { + UnknownMediaStatus, + NoMedia, + LoadingMedia, + LoadedMedia, + StalledMedia, + BufferingMedia, + BufferedMedia, + EndOfMedia, + InvalidMedia + }; + + enum Flag + { + LowLatency = 0x01, + StreamPlayback = 0x02, + VideoSurface = 0x04 + }; + Q_DECLARE_FLAGS(Flags, Flag) + + enum Error + { + NoError, + ResourceError, + FormatError, + NetworkError, + AccessDeniedError, + ServiceMissingError + }; + + QMediaPlayer(QObject *parent = 0, Flags flags = 0, QMediaServiceProvider *provider = QMediaServiceProvider::defaultServiceProvider()); + ~QMediaPlayer(); + + static QtMultimedia::SupportEstimate hasSupport(const QString &mimeType, + const QStringList& codecs = QStringList(), + Flags flags = 0); + static QStringList supportedMimeTypes(Flags flags = 0); + + void setVideoOutput(QVideoWidget *); + void setVideoOutput(QGraphicsVideoItem *); + void setVideoOutput(QAbstractVideoSurface *surface); + + QMediaContent media() const; + const QIODevice *mediaStream() const; + QMediaPlaylist *playlist() const; + + State state() const; + MediaStatus mediaStatus() const; + + qint64 duration() const; + qint64 position() const; + + int volume() const; + bool isMuted() const; + bool isAudioAvailable() const; + bool isVideoAvailable() const; + + int bufferStatus() const; + + bool isSeekable() const; + qreal playbackRate() const; + + Error error() const; + QString errorString() const; + + QNetworkConfiguration currentNetworkConfiguration() const; + +public Q_SLOTS: + void play(); + void pause(); + void stop(); + + void setPosition(qint64 position); + void setVolume(int volume); + void setMuted(bool muted); + + void setPlaybackRate(qreal rate); + + void setMedia(const QMediaContent &media, QIODevice *stream = 0); + void setPlaylist(QMediaPlaylist *playlist); + + void setNetworkConfigurations(const QList &configurations); + +Q_SIGNALS: + void mediaChanged(const QMediaContent &media); + + void stateChanged(QMediaPlayer::State newState); + void mediaStatusChanged(QMediaPlayer::MediaStatus status); + + void durationChanged(qint64 duration); + void positionChanged(qint64 position); + + void volumeChanged(int volume); + void mutedChanged(bool muted); + void audioAvailableChanged(bool available); + void videoAvailableChanged(bool videoAvailable); + + void bufferStatusChanged(int percentFilled); + + void seekableChanged(bool seekable); + void playbackRateChanged(qreal rate); + + void error(QMediaPlayer::Error error); + + void networkConfigurationChanged(const QNetworkConfiguration &configuration); +public: + virtual bool bind(QObject *); + virtual void unbind(QObject *); + +private: + Q_DISABLE_COPY(QMediaPlayer) + Q_DECLARE_PRIVATE(QMediaPlayer) + Q_PRIVATE_SLOT(d_func(), void _q_stateChanged(QMediaPlayer::State)) + Q_PRIVATE_SLOT(d_func(), void _q_mediaStatusChanged(QMediaPlayer::MediaStatus)) + Q_PRIVATE_SLOT(d_func(), void _q_error(int, const QString &)) + Q_PRIVATE_SLOT(d_func(), void _q_updateMedia(const QMediaContent&)) + Q_PRIVATE_SLOT(d_func(), void _q_playlistDestroyed()) +}; + +QT_END_NAMESPACE + +Q_DECLARE_METATYPE(QMediaPlayer::State) +Q_DECLARE_METATYPE(QMediaPlayer::MediaStatus) +Q_DECLARE_METATYPE(QMediaPlayer::Error) + +Q_MEDIA_ENUM_DEBUG(QMediaPlayer, State) +Q_MEDIA_ENUM_DEBUG(QMediaPlayer, MediaStatus) +Q_MEDIA_ENUM_DEBUG(QMediaPlayer, Error) + +QT_END_HEADER + +#endif // QMEDIAPLAYER_H diff --git a/src/multimedia/qmediaplayercontrol.cpp b/src/multimedia/qmediaplayercontrol.cpp new file mode 100644 index 000000000..2585b044c --- /dev/null +++ b/src/multimedia/qmediaplayercontrol.cpp @@ -0,0 +1,414 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qmediaplayercontrol.h" +#include "qmediacontrol_p.h" +#include "qmediaplayer.h" + +QT_BEGIN_NAMESPACE + + +/*! + \class QMediaPlayerControl + \inmodule QtMultimedia + \ingroup multimedia-serv + \since 1.0 + + + \brief The QMediaPlayerControl class provides access to the media playing + functionality of a QMediaService. + + If a QMediaService can play media is will implement QMediaPlayerControl. + This control provides a means to set the \l {setMedia()}{media} to play, + \l {play()}{start}, \l {pause()} {pause} and \l {stop()}{stop} playback, + \l {setPosition()}{seek}, and control the \l {setVolume()}{volume}. + It also provides feedback on the \l {duration()}{duration} of the media, + the current \l {position()}{position}, and \l {bufferStatus()}{buffering} + progress. + + The functionality provided by this control is exposed to application + code through the QMediaPlayer class. + + The interface name of QMediaPlayerControl is \c com.nokia.Qt.QMediaPlayerControl/1.0 as + defined in QMediaPlayerControl_iid. + + \sa QMediaService::requestControl(), QMediaPlayer +*/ + +/*! + \macro QMediaPlayerControl_iid + + \c com.nokia.Qt.QMediaPlayerControl/1.0 + + Defines the interface name of the QMediaPlayerControl class. + + \relates QMediaPlayerControl +*/ + +/*! + Destroys a media player control. +*/ +QMediaPlayerControl::~QMediaPlayerControl() +{ +} + +/*! + Constructs a new media player control with the given \a parent. +*/ +QMediaPlayerControl::QMediaPlayerControl(QObject *parent): + QMediaControl(*new QMediaControlPrivate, parent) +{ +} + +/*! + \fn QMediaPlayerControl::state() const + + Returns the state of a player control. + \since 1.0 +*/ + +/*! + \fn QMediaPlayerControl::stateChanged(QMediaPlayer::State state) + + Signals that the \a state of a player control has changed. + + \since 1.0 + \sa state() +*/ + +/*! + \fn QMediaPlayerControl::mediaStatus() const + + Returns the status of the current media. + \since 1.0 +*/ + +/*! + \fn QMediaPlayerControl::mediaStatusChanged(QMediaPlayer::MediaStatus status) + + Signals that the \a status of the current media has changed. + + \since 1.0 + \sa mediaStatus() +*/ + + +/*! + \fn QMediaPlayerControl::duration() const + + Returns the duration of the current media in milliseconds. + \since 1.0 +*/ + +/*! + \fn QMediaPlayerControl::durationChanged(qint64 duration) + + Signals that the \a duration of the current media has changed. + + \since 1.0 + \sa duration() +*/ + +/*! + \fn QMediaPlayerControl::position() const + + Returns the current playback position in milliseconds. + \since 1.0 +*/ + +/*! + \fn QMediaPlayerControl::setPosition(qint64 position) + + Sets the playback \a position of the current media. This will initiate a seek and it may take + some time for playback to reach the position set. + \since 1.0 +*/ + +/*! + \fn QMediaPlayerControl::positionChanged(qint64 position) + + Signals the playback \a position has changed. + + This is only emitted in when there has been a discontinous change in the playback postion, such + as a seek or the position being reset. + + \since 1.0 + \sa position() +*/ + +/*! + \fn QMediaPlayerControl::volume() const + + Returns the audio volume of a player control. + \since 1.0 +*/ + +/*! + \fn QMediaPlayerControl::setVolume(int volume) + + Sets the audio \a volume of a player control. + \since 1.0 +*/ + +/*! + \fn QMediaPlayerControl::volumeChanged(int volume) + + Signals the audio \a volume of a player control has changed. + + \since 1.0 + \sa volume() +*/ + +/*! + \fn QMediaPlayerControl::isMuted() const + + Returns the mute state of a player control. + \since 1.0 +*/ + +/*! + \fn QMediaPlayerControl::setMuted(bool mute) + + Sets the \a mute state of a player control. + \since 1.0 +*/ + +/*! + \fn QMediaPlayerControl::mutedChanged(bool mute) + + Signals a change in the \a mute status of a player control. + + \since 1.0 + \sa isMuted() +*/ + +/*! + \fn QMediaPlayerControl::bufferStatus() const + + Returns the buffering progress of the current media. Progress is measured in the percentage + of the buffer filled. + \since 1.0 +*/ + +/*! + \fn QMediaPlayerControl::bufferStatusChanged(int progress) + + Signals that buffering \a progress has changed. + + \since 1.0 + \sa bufferStatus() +*/ + +/*! + \fn QMediaPlayerControl::isAudioAvailable() const + + Identifies if there is audio output available for the current media. + + Returns true if audio output is available and false otherwise. + \since 1.0 +*/ + +/*! + \fn QMediaPlayerControl::audioAvailableChanged(bool audio) + + Signals that there has been a change in the availability of \a audio output. + + \since 1.0 + \sa isAudioAvailable() +*/ + +/*! + \fn QMediaPlayerControl::isVideoAvailable() const + + Identifies if there is video output available for the current media. + + Returns true if video output is available and false otherwise. + \since 1.0 +*/ + +/*! + \fn QMediaPlayerControl::videoAvailableChanged(bool video) + + Signals that there has been a change in the availability of \a video output. + + \since 1.0 + \sa isVideoAvailable() +*/ + +/*! + \fn QMediaPlayerControl::isSeekable() const + + Identifies if the current media is seekable. + + Returns true if it possible to seek within the current media, and false otherwise. + \since 1.0 +*/ + +/*! + \fn QMediaPlayerControl::seekableChanged(bool seekable) + + Signals that the \a seekable state of a player control has changed. + + \since 1.0 + \sa isSeekable() +*/ + +/*! + \fn QMediaPlayerControl::availablePlaybackRanges() const + + Returns a range of times in milliseconds that can be played back. + + Usually for local files this is a continuous interval equal to [0..duration()] + or an empty time range if seeking is not supported, but for network sources + it refers to the buffered parts of the media. + \since 1.0 +*/ + +/*! + \fn QMediaPlayerControl::availablePlaybackRangesChanged(const QMediaTimeRange &ranges) + + Signals that the available media playback \a ranges have changed. + + \since 1.0 + \sa QMediaPlayerControl::availablePlaybackRanges() +*/ + +/*! + \fn qreal QMediaPlayerControl::playbackRate() const + + Returns the rate of playback. + \since 1.0 +*/ + +/*! + \fn QMediaPlayerControl::setPlaybackRate(qreal rate) + + Sets the \a rate of playback. + \since 1.0 +*/ + +/*! + \fn QMediaPlayerControl::media() const + + Returns the current media source. + \since 1.0 +*/ + +/*! + \fn QMediaPlayerControl::mediaStream() const + + Returns the current media stream. This is only a valid if a stream was passed to setMedia(). + + \since 1.0 + \sa setMedia() +*/ + +/*! + \fn QMediaPlayerControl::setMedia(const QMediaContent &media, QIODevice *stream) + + Sets the current \a media source. If a \a stream is supplied; data will be read from that + instead of attempting to resolve the media source. The media source may still be used to + supply media information such as mime type. + + Setting the media to a null QMediaContent will cause the control to discard all + information relating to the current media source and to cease all I/O operations related + to that media. + \since 1.0 +*/ + +/*! + \fn QMediaPlayerControl::mediaChanged(const QMediaContent& content) + + Signals that the current media \a content has changed. + \since 1.0 +*/ + +/*! + \fn QMediaPlayerControl::play() + + Starts playback of the current media. + + If successful the player control will immediately enter the \l {QMediaPlayer::PlayingState} + {playing} state. + + \since 1.0 + \sa state() +*/ + +/*! + \fn QMediaPlayerControl::pause() + + Pauses playback of the current media. + + If sucessful the player control will immediately enter the \l {QMediaPlayer::PausedState} + {paused} state. + + \since 1.0 + \sa state(), play(), stop() +*/ + +/*! + \fn QMediaPlayerControl::stop() + + Stops playback of the current media. + + If successful the player control will immediately enter the \l {QMediaPlayer::StoppedState} + {stopped} state. + \since 1.0 +*/ + +/*! + \fn QMediaPlayerControl::error(int error, const QString &errorString) + + Signals that an \a error has occurred. The \a errorString provides a more detailed explanation. + \since 1.0 +*/ + +/*! + \fn QMediaPlayerControl::playbackRateChanged(qreal rate) + + Signal emitted when playback rate changes to \a rate. + \since 1.0 +*/ + +#include "moc_qmediaplayercontrol.cpp" +QT_END_NAMESPACE + diff --git a/src/multimedia/qmediaplayercontrol.h b/src/multimedia/qmediaplayercontrol.h new file mode 100644 index 000000000..a6e02ee9a --- /dev/null +++ b/src/multimedia/qmediaplayercontrol.h @@ -0,0 +1,131 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QMEDIAPLAYERCONTROL_H +#define QMEDIAPLAYERCONTROL_H + +#include "qmediacontrol.h" +#include "qmediaplayer.h" +#include "qmediatimerange.h" + +#include + +QT_BEGIN_HEADER + +QT_BEGIN_NAMESPACE + +QT_MODULE(Multimedia) + + +class QMediaPlaylist; + +class Q_MULTIMEDIA_EXPORT QMediaPlayerControl : public QMediaControl +{ + Q_OBJECT + +public: + ~QMediaPlayerControl(); + + virtual QMediaPlayer::State state() const = 0; + + virtual QMediaPlayer::MediaStatus mediaStatus() const = 0; + + virtual qint64 duration() const = 0; + + virtual qint64 position() const = 0; + virtual void setPosition(qint64 position) = 0; + + virtual int volume() const = 0; + virtual void setVolume(int volume) = 0; + + virtual bool isMuted() const = 0; + virtual void setMuted(bool muted) = 0; + + virtual int bufferStatus() const = 0; + + virtual bool isAudioAvailable() const = 0; + virtual bool isVideoAvailable() const = 0; + + virtual bool isSeekable() const = 0; + + virtual QMediaTimeRange availablePlaybackRanges() const = 0; + + virtual qreal playbackRate() const = 0; + virtual void setPlaybackRate(qreal rate) = 0; + + virtual QMediaContent media() const = 0; + virtual const QIODevice *mediaStream() const = 0; + virtual void setMedia(const QMediaContent &media, QIODevice *stream) = 0; + + virtual void play() = 0; + virtual void pause() = 0; + virtual void stop() = 0; + +Q_SIGNALS: + void mediaChanged(const QMediaContent& content); + void durationChanged(qint64 duration); + void positionChanged(qint64 position); + void stateChanged(QMediaPlayer::State newState); + void mediaStatusChanged(QMediaPlayer::MediaStatus status); + void volumeChanged(int volume); + void mutedChanged(bool muted); + void audioAvailableChanged(bool audioAvailable); + void videoAvailableChanged(bool videoAvailable); + void bufferStatusChanged(int percentFilled); + void seekableChanged(bool); + void availablePlaybackRangesChanged(const QMediaTimeRange&); + void playbackRateChanged(qreal rate); + void error(int error, const QString &errorString); + +protected: + QMediaPlayerControl(QObject* parent = 0); +}; + +#define QMediaPlayerControl_iid "com.nokia.Qt.QMediaPlayerControl/1.0" +Q_MEDIA_DECLARE_CONTROL(QMediaPlayerControl, QMediaPlayerControl_iid) + +QT_END_NAMESPACE + +QT_END_HEADER + + +#endif // QMEDIAPLAYERCONTROL_H + diff --git a/src/multimedia/qmediaplaylist.cpp b/src/multimedia/qmediaplaylist.cpp new file mode 100644 index 000000000..a5618ad5c --- /dev/null +++ b/src/multimedia/qmediaplaylist.cpp @@ -0,0 +1,756 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qmediaplaylist.h" +#include "qmediaplaylist_p.h" +#include "qmediaplaylistprovider.h" +#include "qlocalmediaplaylistprovider.h" +#include "qmediaplaylistioplugin.h" +#include "qmediaservice.h" +#include "qmediaplaylistcontrol.h" +#include "qmediaplayercontrol.h" + +#include +#include +#include +#include +#include + +#include "qmediapluginloader_p.h" + +QT_BEGIN_NAMESPACE + +Q_GLOBAL_STATIC_WITH_ARGS(QMediaPluginLoader, playlistIOLoader, + (QMediaPlaylistIOInterface_iid, QLatin1String("playlistformats"), Qt::CaseInsensitive)) + + +/*! + \class QMediaPlaylist + \inmodule QtMultimedia + \ingroup multimedia + \since 1.0 + + + \brief The QMediaPlaylist class provides a list of media content to play. + + QMediaPlaylist is intended to be used with other media objects, + like QMediaPlayer or QMediaImageViewer. + + QMediaPlaylist allows to access the service intrinsic playlist functionality + if available, otherwise it provides the the local memory playlist implementation. + + \snippet doc/src/snippets/multimedia-snippets/media.cpp Movie playlist + + Depending on playlist source implementation, most of the playlist mutating + operations can be asynchronous. + + \sa QMediaContent +*/ + + +/*! + \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 for with the given \a parent. +*/ + +QMediaPlaylist::QMediaPlaylist(QObject *parent) + : QObject(parent) + , d_ptr(new QMediaPlaylistPrivate) +{ + Q_D(QMediaPlaylist); + + d->q_ptr = this; + d->localPlaylistControl = new QLocalMediaPlaylistControl(this); + + setMediaObject(0); +} + +/*! + Destroys the playlist. + */ + +QMediaPlaylist::~QMediaPlaylist() +{ + Q_D(QMediaPlaylist); + + if (d->mediaObject) + d->mediaObject->unbind(this); + + delete d_ptr; +} + +/*! + Returns the QMediaObject instance that this QMediaPlaylist is bound too, + or 0 otherwise. + \since 1.0 +*/ +QMediaObject *QMediaPlaylist::mediaObject() const +{ + return d_func()->mediaObject; +} + +/*! + \internal + If \a mediaObject is null or doesn't have an intrinsic playlist, + internal local memory playlist source will be created. + \since 1.0 +*/ +bool QMediaPlaylist::setMediaObject(QMediaObject *mediaObject) +{ + Q_D(QMediaPlaylist); + + if (mediaObject && mediaObject == d->mediaObject) + return true; + + QMediaService *service = mediaObject + ? mediaObject->service() : 0; + + QMediaPlaylistControl *newControl = 0; + + if (service) + newControl = qobject_cast(service->requestControl(QMediaPlaylistControl_iid)); + + if (!newControl) + newControl = d->localPlaylistControl; + + if (d->control != newControl) { + int oldSize = 0; + if (d->control) { + QMediaPlaylistProvider *playlist = d->control->playlistProvider(); + oldSize = playlist->mediaCount(); + disconnect(playlist, SIGNAL(loadFailed(QMediaPlaylist::Error,QString)), + this, SLOT(_q_loadFailed(QMediaPlaylist::Error,QString))); + + disconnect(playlist, SIGNAL(mediaChanged(int,int)), this, SIGNAL(mediaChanged(int,int))); + disconnect(playlist, SIGNAL(mediaAboutToBeInserted(int,int)), this, SIGNAL(mediaAboutToBeInserted(int,int))); + disconnect(playlist, SIGNAL(mediaInserted(int,int)), this, SIGNAL(mediaInserted(int,int))); + disconnect(playlist, SIGNAL(mediaAboutToBeRemoved(int,int)), this, SIGNAL(mediaAboutToBeRemoved(int,int))); + disconnect(playlist, SIGNAL(mediaRemoved(int,int)), this, SIGNAL(mediaRemoved(int,int))); + + disconnect(playlist, SIGNAL(loaded()), this, SIGNAL(loaded())); + + disconnect(d->control, SIGNAL(playbackModeChanged(QMediaPlaylist::PlaybackMode)), + this, SIGNAL(playbackModeChanged(QMediaPlaylist::PlaybackMode))); + disconnect(d->control, SIGNAL(currentIndexChanged(int)), + this, SIGNAL(currentIndexChanged(int))); + disconnect(d->control, SIGNAL(currentMediaChanged(QMediaContent)), + this, SIGNAL(currentMediaChanged(QMediaContent))); + + if (d->mediaObject) + d->mediaObject->service()->releaseControl(d->control); + } + + d->control = newControl; + QMediaPlaylistProvider *playlist = d->control->playlistProvider(); + connect(playlist, SIGNAL(loadFailed(QMediaPlaylist::Error,QString)), + this, SLOT(_q_loadFailed(QMediaPlaylist::Error,QString))); + + connect(playlist, SIGNAL(mediaChanged(int,int)), this, SIGNAL(mediaChanged(int,int))); + connect(playlist, SIGNAL(mediaAboutToBeInserted(int,int)), this, SIGNAL(mediaAboutToBeInserted(int,int))); + connect(playlist, SIGNAL(mediaInserted(int,int)), this, SIGNAL(mediaInserted(int,int))); + connect(playlist, SIGNAL(mediaAboutToBeRemoved(int,int)), this, SIGNAL(mediaAboutToBeRemoved(int,int))); + connect(playlist, SIGNAL(mediaRemoved(int,int)), this, SIGNAL(mediaRemoved(int,int))); + + connect(playlist, SIGNAL(loaded()), this, SIGNAL(loaded())); + + connect(d->control, SIGNAL(playbackModeChanged(QMediaPlaylist::PlaybackMode)), + this, SIGNAL(playbackModeChanged(QMediaPlaylist::PlaybackMode))); + connect(d->control, SIGNAL(currentIndexChanged(int)), + this, SIGNAL(currentIndexChanged(int))); + connect(d->control, SIGNAL(currentMediaChanged(QMediaContent)), + this, SIGNAL(currentMediaChanged(QMediaContent))); + + if (oldSize) + emit mediaRemoved(0, oldSize-1); + + if (playlist->mediaCount()) { + emit mediaAboutToBeInserted(0,playlist->mediaCount()-1); + emit mediaInserted(0,playlist->mediaCount()-1); + } + } + + d->mediaObject = mediaObject; + + return true; +} + +/*! + \property QMediaPlaylist::playbackMode + + This property defines the order, items in playlist are played. + + \since 1.0 + \sa QMediaPlaylist::PlaybackMode +*/ + +QMediaPlaylist::PlaybackMode QMediaPlaylist::playbackMode() const +{ + return d_func()->control->playbackMode(); +} + +void QMediaPlaylist::setPlaybackMode(QMediaPlaylist::PlaybackMode mode) +{ + Q_D(QMediaPlaylist); + d->control->setPlaybackMode(mode); +} + +/*! + Returns position of the current media content in the playlist. + \since 1.0 +*/ +int QMediaPlaylist::currentIndex() const +{ + return d_func()->control->currentIndex(); +} + +/*! + Returns the current media content. + \since 1.0 +*/ + +QMediaContent QMediaPlaylist::currentMedia() const +{ + return d_func()->playlist()->media(currentIndex()); +} + +/*! + 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. + + \since 1.0 + \sa QMediaPlaylist::playbackMode +*/ +int QMediaPlaylist::nextIndex(int steps) const +{ + return d_func()->control->nextIndex(steps); +} + +/*! + Returns the index of the item, which would be current after calling previous() + \a steps times. + + \since 1.0 + \sa QMediaPlaylist::playbackMode +*/ + +int QMediaPlaylist::previousIndex(int steps) const +{ + return d_func()->control->previousIndex(steps); +} + + +/*! + Returns the number of items in the playlist. + + \since 1.0 + \sa isEmpty() + */ +int QMediaPlaylist::mediaCount() const +{ + return d_func()->playlist()->mediaCount(); +} + +/*! + Returns true if the playlist contains no items; otherwise returns false. + + \since 1.0 + \sa mediaCount() + */ +bool QMediaPlaylist::isEmpty() const +{ + return mediaCount() == 0; +} + +/*! + Returns true if the playlist can be modified; otherwise returns false. + + \since 1.0 + \sa mediaCount() + */ +bool QMediaPlaylist::isReadOnly() const +{ + return d_func()->playlist()->isReadOnly(); +} + +/*! + Returns the media content at \a index in the playlist. + \since 1.0 +*/ + +QMediaContent QMediaPlaylist::media(int index) const +{ + return d_func()->playlist()->media(index); +} + +/*! + Append the media \a content to the playlist. + + Returns true if the operation is successful, otherwise return false. + \since 1.0 + */ +bool QMediaPlaylist::addMedia(const QMediaContent &content) +{ + return d_func()->control->playlistProvider()->addMedia(content); +} + +/*! + Append multiple media content \a items to the playlist. + + Returns true if the operation is successful, otherwise return false. + \since 1.0 + */ +bool QMediaPlaylist::addMedia(const QList &items) +{ + return d_func()->control->playlistProvider()->addMedia(items); +} + +/*! + Insert the media \a content to the playlist at position \a pos. + + Returns true if the operation is successful, otherwise false. + \since 1.0 +*/ + +bool QMediaPlaylist::insertMedia(int pos, const QMediaContent &content) +{ + return d_func()->playlist()->insertMedia(pos, content); +} + +/*! + Insert multiple media content \a items to the playlist at position \a pos. + + Returns true if the operation is successful, otherwise false. + \since 1.0 +*/ + +bool QMediaPlaylist::insertMedia(int pos, const QList &items) +{ + return d_func()->playlist()->insertMedia(pos, items); +} + +/*! + Remove the item from the playlist at position \a pos. + + Returns true if the operation is successful, otherwise return false. + \since 1.0 + */ +bool QMediaPlaylist::removeMedia(int pos) +{ + Q_D(QMediaPlaylist); + return d->playlist()->removeMedia(pos); +} + +/*! + Remove items in the playlist from \a start to \a end inclusive. + + Returns true if the operation is successful, otherwise return false. + \since 1.0 + */ +bool QMediaPlaylist::removeMedia(int start, int end) +{ + Q_D(QMediaPlaylist); + return d->playlist()->removeMedia(start, end); +} + +/*! + Remove all the items from the playlist. + + Returns true if the operation is successful, otherwise return false. + \since 1.0 + */ +bool QMediaPlaylist::clear() +{ + Q_D(QMediaPlaylist); + return d->playlist()->clear(); +} + +bool QMediaPlaylistPrivate::readItems(QMediaPlaylistReader *reader) +{ + while (!reader->atEnd()) + playlist()->addMedia(reader->readItem()); + + return true; +} + +bool QMediaPlaylistPrivate::writeItems(QMediaPlaylistWriter *writer) +{ + for (int i=0; imediaCount(); i++) { + if (!writer->writeItem(playlist()->media(i))) + return false; + } + writer->close(); + return true; +} + +/*! + 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(). + \since 1.0 +*/ +void QMediaPlaylist::load(const QUrl &location, const char *format) +{ + Q_D(QMediaPlaylist); + + d->error = NoError; + d->errorString.clear(); + + if (d->playlist()->load(location,format)) + return; + + if (isReadOnly()) { + d->error = AccessDeniedError; + d->errorString = tr("Could not add items to read only playlist."); + emit loadFailed(); + return; + } + + foreach (QString const& key, playlistIOLoader()->keys()) { + QMediaPlaylistIOInterface* plugin = qobject_cast(playlistIOLoader()->instance(key)); + if (plugin && plugin->canRead(location,format)) { + QMediaPlaylistReader *reader = plugin->createReader(location,QByteArray(format)); + if (reader && d->readItems(reader)) { + delete reader; + emit loaded(); + return; + } + delete reader; + } + } + + d->error = FormatNotSupportedError; + d->errorString = tr("Playlist format is not supported"); + emit loadFailed(); + + return; +} + +/*! + 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(). + \since 1.0 +*/ +void QMediaPlaylist::load(QIODevice * device, const char *format) +{ + Q_D(QMediaPlaylist); + + d->error = NoError; + d->errorString.clear(); + + if (d->playlist()->load(device,format)) + return; + + if (isReadOnly()) { + d->error = AccessDeniedError; + d->errorString = tr("Could not add items to read only playlist."); + emit loadFailed(); + return; + } + + foreach (QString const& key, playlistIOLoader()->keys()) { + QMediaPlaylistIOInterface* plugin = qobject_cast(playlistIOLoader()->instance(key)); + if (plugin && plugin->canRead(device,format)) { + QMediaPlaylistReader *reader = plugin->createReader(device,QByteArray(format)); + if (reader && d->readItems(reader)) { + delete reader; + emit loaded(); + return; + } + delete reader; + } + } + + d->error = FormatNotSupportedError; + d->errorString = tr("Playlist format is not supported"); + emit loadFailed(); + + return; +} + +/*! + 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. + \since 1.0 + */ +bool QMediaPlaylist::save(const QUrl &location, const char *format) +{ + Q_D(QMediaPlaylist); + + d->error = NoError; + d->errorString.clear(); + + if (d->playlist()->save(location,format)) + return true; + + 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. + \since 1.0 +*/ +bool QMediaPlaylist::save(QIODevice * device, const char *format) +{ + Q_D(QMediaPlaylist); + + d->error = NoError; + d->errorString.clear(); + + if (d->playlist()->save(device,format)) + return true; + + foreach (QString const& key, playlistIOLoader()->keys()) { + QMediaPlaylistIOInterface* plugin = qobject_cast(playlistIOLoader()->instance(key)); + if (plugin && plugin->canWrite(device,format)) { + QMediaPlaylistWriter *writer = plugin->createWriter(device,QByteArray(format)); + if (writer && d->writeItems(writer)) { + delete writer; + return true; + } + delete writer; + } + } + + d->error = FormatNotSupportedError; + d->errorString = tr("Playlist format is not supported."); + + return false; +} + +/*! + Returns the last error condition. + \since 1.0 +*/ +QMediaPlaylist::Error QMediaPlaylist::error() const +{ + return d_func()->error; +} + +/*! + Returns the string describing the last error condition. + \since 1.0 +*/ +QString QMediaPlaylist::errorString() const +{ + return d_func()->errorString; +} + +/*! + Shuffle items in the playlist. + \since 1.0 +*/ +void QMediaPlaylist::shuffle() +{ + d_func()->playlist()->shuffle(); +} + + +/*! + Advance to the next media content in playlist. + \since 1.0 +*/ +void QMediaPlaylist::next() +{ + d_func()->control->next(); +} + +/*! + Return to the previous media content in playlist. + \since 1.0 +*/ +void QMediaPlaylist::previous() +{ + d_func()->control->previous(); +} + +/*! + Activate media content from playlist at position \a playlistPosition. + \since 1.0 +*/ + +void QMediaPlaylist::setCurrentIndex(int playlistPosition) +{ + d_func()->control->setCurrentIndex(playlistPosition); +} + +/*! + \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. + \since 1.0 + */ + +/*! + \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. + \since 1.0 + */ + +/*! + \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. + \since 1.0 + */ + +/*! + \fn void QMediaPlaylist::currentIndexChanged(int position) + + Signal emitted when playlist position changed to \a position. + \since 1.0 +*/ + +/*! + \fn void QMediaPlaylist::playbackModeChanged(QMediaPlaylist::PlaybackMode mode) + + Signal emitted when playback mode changed to \a mode. + \since 1.0 +*/ + +/*! + \fn void QMediaPlaylist::mediaAboutToBeInserted(int start, int end) + + Signal emitted when items are to be inserted at \a start and ending at \a end. + \since 1.0 +*/ + +/*! + \fn void QMediaPlaylist::mediaAboutToBeRemoved(int start, int end) + + Signal emitted when item are to be deleted at \a start and ending at \a end. + \since 1.0 +*/ + +/*! + \fn void QMediaPlaylist::currentMediaChanged(const QMediaContent &content) + + Signal emitted when current media changes to \a content. + \since 1.0 +*/ + +/*! + \property QMediaPlaylist::currentIndex + \brief Current position. + \since 1.0 +*/ + +/*! + \property QMediaPlaylist::currentMedia + \brief Current media content. + \since 1.0 +*/ + +/*! + \fn QMediaPlaylist::loaded() + + Signal emitted when playlist finished loading. + \since 1.0 +*/ + +/*! + \fn QMediaPlaylist::loadFailed() + + Signal emitted if failed to load playlist. + \since 1.0 +*/ + +/*! + \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. +*/ + +#include "moc_qmediaplaylist.cpp" +#include "moc_qmediaplaylist_p.cpp" +QT_END_NAMESPACE + diff --git a/src/multimedia/qmediaplaylist.h b/src/multimedia/qmediaplaylist.h new file mode 100644 index 000000000..7b4b62260 --- /dev/null +++ b/src/multimedia/qmediaplaylist.h @@ -0,0 +1,154 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QMEDIAPLAYLIST_H +#define QMEDIAPLAYLIST_H + +#include + +#include +#include +#include +#include + + +QT_BEGIN_HEADER + +QT_BEGIN_NAMESPACE + +QT_MODULE(Multimedia) + + +class QMediaPlaylistProvider; + +class QMediaPlaylistPrivate; +class Q_MULTIMEDIA_EXPORT QMediaPlaylist : public QObject, public QMediaBindableInterface +{ + Q_OBJECT + Q_INTERFACES(QMediaBindableInterface) + Q_PROPERTY(QMediaPlaylist::PlaybackMode playbackMode READ playbackMode WRITE setPlaybackMode NOTIFY playbackModeChanged) + Q_PROPERTY(QMediaContent currentMedia READ currentMedia NOTIFY currentMediaChanged) + Q_PROPERTY(int currentIndex READ currentIndex WRITE setCurrentIndex NOTIFY currentIndexChanged) + Q_ENUMS(PlaybackMode Error) + +public: + enum PlaybackMode { CurrentItemOnce, CurrentItemInLoop, Sequential, Loop, Random }; + enum Error { NoError, FormatError, FormatNotSupportedError, NetworkError, AccessDeniedError }; + + QMediaPlaylist(QObject *parent = 0); + virtual ~QMediaPlaylist(); + + QMediaObject *mediaObject() const; + + PlaybackMode playbackMode() const; + void setPlaybackMode(PlaybackMode mode); + + int currentIndex() const; + QMediaContent currentMedia() const; + + int nextIndex(int steps = 1) const; + int previousIndex(int steps = 1) const; + + QMediaContent media(int index) const; + + int mediaCount() const; + bool isEmpty() const; + bool isReadOnly() const; + + bool addMedia(const QMediaContent &content); + bool addMedia(const QList &items); + bool insertMedia(int index, const QMediaContent &content); + bool insertMedia(int index, const QList &items); + bool removeMedia(int pos); + bool removeMedia(int start, int end); + bool clear(); + + void load(const QUrl &location, const char *format = 0); + void load(QIODevice * device, const char *format = 0); + + bool save(const QUrl &location, const char *format = 0); + bool save(QIODevice * device, const char *format); + + Error error() const; + QString errorString() const; + +public Q_SLOTS: + void shuffle(); + + void next(); + void previous(); + + void setCurrentIndex(int index); + +Q_SIGNALS: + void currentIndexChanged(int index); + void playbackModeChanged(QMediaPlaylist::PlaybackMode mode); + void currentMediaChanged(const QMediaContent&); + + 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(); + +protected: + bool setMediaObject(QMediaObject *object); + QMediaPlaylistPrivate *d_ptr; + +private: + Q_DECLARE_PRIVATE(QMediaPlaylist) + Q_PRIVATE_SLOT(d_func(), void _q_loadFailed(QMediaPlaylist::Error, const QString &)) +}; + +QT_END_NAMESPACE + +Q_DECLARE_METATYPE(QMediaPlaylist::PlaybackMode) +Q_DECLARE_METATYPE(QMediaPlaylist::Error) + +Q_MEDIA_ENUM_DEBUG(QMediaPlaylist, PlaybackMode) +Q_MEDIA_ENUM_DEBUG(QMediaPlaylist, Error) + +QT_END_HEADER + +#endif // QMEDIAPLAYLIST_H diff --git a/src/multimedia/qmediaplaylist_p.h b/src/multimedia/qmediaplaylist_p.h new file mode 100644 index 000000000..c04483c02 --- /dev/null +++ b/src/multimedia/qmediaplaylist_p.h @@ -0,0 +1,177 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#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 "qmediaplaylistcontrol.h" +#include "qmediaplayer.h" +#include "qmediaplayercontrol.h" +#include "qlocalmediaplaylistprovider.h" +#include "qmediaobject_p.h" + +#include + +#ifdef Q_MOC_RUN +# pragma Q_MOC_EXPAND_MACROS +#endif + +QT_BEGIN_HEADER + +QT_BEGIN_NAMESPACE + +QT_MODULE(Multimedia) + + +class QMediaPlaylistControl; +class QMediaPlaylistProvider; +class QMediaPlaylistReader; +class QMediaPlaylistWriter; +class QMediaPlayerControl; + +class QMediaPlaylistPrivate +{ + Q_DECLARE_PUBLIC(QMediaPlaylist) +public: + QMediaPlaylistPrivate() + :mediaObject(0), + control(0), + localPlaylistControl(0), + error(QMediaPlaylist::NoError) + { + } + + virtual ~QMediaPlaylistPrivate() {} + + void _q_loadFailed(QMediaPlaylist::Error error, const QString &errorString) + { + this->error = error; + this->errorString = errorString; + + emit q_ptr->loadFailed(); + } + + void _q_mediaObjectDeleted() + { + Q_Q(QMediaPlaylist); + mediaObject = 0; + if (control != localPlaylistControl) + control = 0; + q->setMediaObject(0); + } + + QMediaObject *mediaObject; + + QMediaPlaylistControl *control; + QMediaPlaylistProvider *playlist() const { return control->playlistProvider(); } + + QMediaPlaylistControl *localPlaylistControl; + + bool readItems(QMediaPlaylistReader *reader); + bool writeItems(QMediaPlaylistWriter *writer); + + QMediaPlaylist::Error error; + QString errorString; + + QMediaPlaylist *q_ptr; +}; + + +class QLocalMediaPlaylistControl : public QMediaPlaylistControl +{ + Q_OBJECT +public: + QLocalMediaPlaylistControl(QObject *parent) + :QMediaPlaylistControl(parent) + { + QMediaPlaylistProvider *playlist = new QLocalMediaPlaylistProvider(this); + m_navigator = new QMediaPlaylistNavigator(playlist,this); + m_navigator->setPlaybackMode(QMediaPlaylist::Sequential); + + connect(m_navigator, SIGNAL(currentIndexChanged(int)), SIGNAL(currentIndexChanged(int))); + connect(m_navigator, SIGNAL(activated(QMediaContent)), SIGNAL(currentMediaChanged(QMediaContent))); + connect(m_navigator, SIGNAL(playbackModeChanged(QMediaPlaylist::PlaybackMode)), SIGNAL(playbackModeChanged(QMediaPlaylist::PlaybackMode))); + } + + virtual ~QLocalMediaPlaylistControl() {}; + + QMediaPlaylistProvider* playlistProvider() const { return m_navigator->playlist(); } + bool setPlaylistProvider(QMediaPlaylistProvider *mediaPlaylist) + { + m_navigator->setPlaylist(mediaPlaylist); + emit playlistProviderChanged(); + return true; + } + + int currentIndex() const { return m_navigator->currentIndex(); } + void setCurrentIndex(int position) { m_navigator->jump(position); } + int nextIndex(int steps) const { return m_navigator->nextIndex(steps); } + int previousIndex(int steps) const { return m_navigator->previousIndex(steps); } + + void next() { m_navigator->next(); } + void previous() { m_navigator->previous(); } + + QMediaPlaylist::PlaybackMode playbackMode() const { return m_navigator->playbackMode(); } + void setPlaybackMode(QMediaPlaylist::PlaybackMode mode) { m_navigator->setPlaybackMode(mode); } + +private: + QMediaPlaylistNavigator *m_navigator; +}; + + +QT_END_NAMESPACE + +QT_END_HEADER + + +#endif // QMEDIAPLAYLIST_P_H diff --git a/src/multimedia/qmediaplaylistcontrol.cpp b/src/multimedia/qmediaplaylistcontrol.cpp new file mode 100644 index 000000000..dc2348956 --- /dev/null +++ b/src/multimedia/qmediaplaylistcontrol.cpp @@ -0,0 +1,219 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + + +#include "qmediaplaylistcontrol.h" +#include "qmediacontrol_p.h" + +QT_BEGIN_NAMESPACE + +/*! + \class QMediaPlaylistControl + \inmodule QtMultimedia + \ingroup multimedia-serv + \since 1.0 + + + \brief The QMediaPlaylistControl class provides access to the playlist + functionality of a QMediaService. + + If a QMediaService contains an internal playlist it will implement + QMediaPlaylistControl. This control provides access to the contents of the + \l {playlistProvider()}{playlist}, as well as the \l + {currentIndex()}{position} of the current media, and a means of navigating + to the \l {next()}{next} and \l {previous()}{previous} media. + + The functionality provided by the control is exposed to application code + through the QMediaPlaylist class. + + The interface name of QMediaPlaylistControl is \c com.nokia.Qt.QMediaPlaylistControl/1.0 as + defined in QMediaPlaylistControl_iid. + + \sa QMediaService::requestControl(), QMediaPlayer +*/ + +/*! + \macro QMediaPlaylistControl_iid + + \c com.nokia.Qt.QMediaPlaylistControl/1.0 + + Defines the interface name of the QMediaPlaylistControl class. + + \relates QMediaPlaylistControl +*/ + +/*! + Create a new playlist control object with the given \a parent. +*/ +QMediaPlaylistControl::QMediaPlaylistControl(QObject *parent): + QMediaControl(*new QMediaControlPrivate, parent) +{ +} + +/*! + Destroys the playlist control. +*/ +QMediaPlaylistControl::~QMediaPlaylistControl() +{ +} + + +/*! + \fn QMediaPlaylistControl::playlistProvider() const + + Returns the playlist used by this media player. + \since 1.0 +*/ + +/*! + \fn QMediaPlaylistControl::setPlaylistProvider(QMediaPlaylistProvider *playlist) + + Set the playlist of this media player to \a playlist. + + In many cases it is possible just to use the playlist + constructed by player, but sometimes replacing the whole + playlist allows to avoid copyting of all the items bettween playlists. + + Returns true if player can use this passed playlist; otherwise returns false. + + \since 1.0 +*/ + +/*! + \fn QMediaPlaylistControl::currentIndex() const + + Returns position of the current media source in the playlist. + \since 1.0 +*/ + +/*! + \fn QMediaPlaylistControl::setCurrentIndex(int position) + + Jump to the item at the given \a position. + \since 1.0 +*/ + +/*! + \fn QMediaPlaylistControl::nextIndex(int step) const + + Returns the index of item, which were current after calling next() + \a step times. + + Returned value depends on the size of playlist, current position + and playback mode. + + \since 1.0 + \sa QMediaPlaylist::playbackMode +*/ + +/*! + \fn QMediaPlaylistControl::previousIndex(int step) const + + Returns the index of item, which were current after calling previous() + \a step times. + + \since 1.0 + \sa QMediaPlaylist::playbackMode +*/ + +/*! + \fn QMediaPlaylistControl::next() + + Moves to the next item in playlist. + \since 1.0 +*/ + +/*! + \fn QMediaPlaylistControl::previous() + + Returns to the previous item in playlist. + \since 1.0 +*/ + +/*! + \fn QMediaPlaylistControl::playbackMode() const + + Returns the playlist navigation mode. + + \since 1.0 + \sa QMediaPlaylist::PlaybackMode +*/ + +/*! + \fn QMediaPlaylistControl::setPlaybackMode(QMediaPlaylist::PlaybackMode mode) + + Sets the playback \a mode. + + \since 1.0 + \sa QMediaPlaylist::PlaybackMode +*/ + +/*! + \fn QMediaPlaylistControl::playlistProviderChanged() + + Signal emitted when the playlist provider has changed. + \since 1.0 +*/ + +/*! + \fn QMediaPlaylistControl::currentIndexChanged(int position) + + Signal emitted when the playlist \a position is changed. + \since 1.0 +*/ + +/*! + \fn QMediaPlaylistControl::playbackModeChanged(QMediaPlaylist::PlaybackMode mode) + + Signal emitted when the playback \a mode is changed. + \since 1.0 +*/ + +/*! + \fn QMediaPlaylistControl::currentMediaChanged(const QMediaContent& content) + + Signal emitted when current media changes to \a content. + \since 1.0 +*/ + +#include "moc_qmediaplaylistcontrol.cpp" +QT_END_NAMESPACE + diff --git a/src/multimedia/qmediaplaylistcontrol.h b/src/multimedia/qmediaplaylistcontrol.h new file mode 100644 index 000000000..2cce448fa --- /dev/null +++ b/src/multimedia/qmediaplaylistcontrol.h @@ -0,0 +1,98 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + + +#ifndef QMEDIAPLAYLISTCONTROL_H +#define QMEDIAPLAYLISTCONTROL_H + +#include "qmediacontrol.h" +#include "qmediaplaylistnavigator.h" + + +QT_BEGIN_HEADER + +QT_BEGIN_NAMESPACE + +QT_MODULE(Multimedia) + + +class QMediaPlaylistProvider; + +class Q_MULTIMEDIA_EXPORT QMediaPlaylistControl : public QMediaControl +{ + Q_OBJECT + +public: + virtual ~QMediaPlaylistControl(); + + virtual QMediaPlaylistProvider* playlistProvider() const = 0; + virtual bool setPlaylistProvider(QMediaPlaylistProvider *playlist) = 0; + + virtual int currentIndex() const = 0; + virtual void setCurrentIndex(int position) = 0; + virtual int nextIndex(int steps) const = 0; + virtual int previousIndex(int steps) const = 0; + + virtual void next() = 0; + virtual void previous() = 0; + + virtual QMediaPlaylist::PlaybackMode playbackMode() const = 0; + virtual void setPlaybackMode(QMediaPlaylist::PlaybackMode mode) = 0; + +Q_SIGNALS: + void playlistProviderChanged(); + void currentIndexChanged(int position); + void currentMediaChanged(const QMediaContent&); + void playbackModeChanged(QMediaPlaylist::PlaybackMode mode); + +protected: + QMediaPlaylistControl(QObject* parent = 0); +}; + +#define QMediaPlaylistControl_iid "com.nokia.Qt.QMediaPlaylistControl/1.0" +Q_MEDIA_DECLARE_CONTROL(QMediaPlaylistControl, QMediaPlaylistControl_iid) + +QT_END_NAMESPACE + +QT_END_HEADER + + +#endif // QMEDIAPLAYLISTCONTROL_H diff --git a/src/multimedia/qmediaplaylistioplugin.cpp b/src/multimedia/qmediaplaylistioplugin.cpp new file mode 100644 index 000000000..80fe0ef6b --- /dev/null +++ b/src/multimedia/qmediaplaylistioplugin.cpp @@ -0,0 +1,204 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qmediaplaylistioplugin.h" + +QT_BEGIN_NAMESPACE + +/*! + \class QMediaPlaylistReader + + \brief The QMediaPlaylistReader class provides an interface for reading a playlist file. + \inmodule QtMultimedia + \since 1.0 + + \sa QMediaPlaylistIOPlugin +*/ + +/*! + Destroys a media playlist reader. +*/ +QMediaPlaylistReader::~QMediaPlaylistReader() +{ +} + +/*! + \fn QMediaPlaylistReader::atEnd() const + + Identifies if a playlist reader has reached the end of its input. + + Returns true if the reader has reached the end; and false otherwise. + \since 1.0 +*/ + +/*! + \fn QMediaPlaylistReader::readItem() + + Reads an item of media from a playlist file. + + Returns the read media, or a null QMediaContent if no more media is available. + \since 1.0 +*/ + +/*! + \fn QMediaPlaylistReader::close() + + Closes a playlist reader's input device. + \since 1.0 +*/ + +/*! + \class QMediaPlaylistWriter + + \brief The QMediaPlaylistWriter class provides an interface for writing a playlist file. + + \since 1.0 + \sa QMediaPlaylistIOPlugin +*/ + +/*! + Destroys a media playlist writer. +*/ +QMediaPlaylistWriter::~QMediaPlaylistWriter() +{ +} + +/*! + \fn QMediaPlaylistWriter::writeItem(const QMediaContent &media) + + Writes an item of \a media to a playlist file. + + Returns true if the media was written successfully; and false otherwise. + \since 1.0 +*/ + +/*! + \fn QMediaPlaylistWriter::close() + + Finalizes the writing of a playlist and closes the output device. + \since 1.0 +*/ + +/*! + \class QMediaPlaylistIOPlugin + \brief The QMediaPlaylistIOPlugin class provides an interface for media playlist I/O plug-ins. + \since 1.0 +*/ + +/*! + Constructs a media playlist I/O plug-in with the given \a parent. +*/ +QMediaPlaylistIOPlugin::QMediaPlaylistIOPlugin(QObject *parent) + :QObject(parent) +{ +} + +/*! + Destroys a media playlist I/O plug-in. +*/ +QMediaPlaylistIOPlugin::~QMediaPlaylistIOPlugin() +{ +} + +/*! + \fn QMediaPlaylistIOPlugin::canRead(QIODevice *device, const QByteArray &format) const + + Identifies if plug-in can read \a format data from an I/O \a device. + + Returns true if the data can be read; and false otherwise. + \since 1.0 +*/ + +/*! + \fn QMediaPlaylistIOPlugin::canRead(const QUrl& location, const QByteArray &format) const + + Identifies if a plug-in can read \a format data from a URL \a location. + + Returns true if the data can be read; and false otherwise. + \since 1.0 +*/ + +/*! + \fn QMediaPlaylistIOPlugin::canWrite(QIODevice *device, const QByteArray &format) const + + Identifies if a plug-in can write \a format data to an I/O \a device. + + Returns true if the data can be written; and false otherwise. + \since 1.0 +*/ + +/*! + \fn QMediaPlaylistIOPlugin::keys() const + + Returns a list of format keys supported by a plug-in. + \since 1.0 +*/ + +/*! + \fn QMediaPlaylistIOPlugin::createReader(QIODevice *device, const QByteArray &format) + + Returns a new QMediaPlaylistReader which reads \a format data from an I/O \a device. + + If the device is invalid or the format is unsupported this will return a null pointer. + \since 1.0 +*/ + +/*! + \fn QMediaPlaylistIOPlugin::createReader(const QUrl& location, const QByteArray &format) + + Returns a new QMediaPlaylistReader which reads \a format data from a URL \a location. + + If the location or the format is unsupported this will return a null pointer. + \since 1.0 +*/ + +/*! + \fn QMediaPlaylistIOPlugin::createWriter(QIODevice *device, const QByteArray &format) + + Returns a new QMediaPlaylistWriter which writes \a format data to an I/O \a device. + + If the device is invalid or the format is unsupported this will return a null pointer. + \since 1.0 +*/ + +#include "moc_qmediaplaylistioplugin.cpp" +QT_END_NAMESPACE + diff --git a/src/multimedia/qmediaplaylistioplugin.h b/src/multimedia/qmediaplaylistioplugin.h new file mode 100644 index 000000000..97ded8b43 --- /dev/null +++ b/src/multimedia/qmediaplaylistioplugin.h @@ -0,0 +1,126 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QMEDIAPLAYLISTIOPLUGIN_H +#define QMEDIAPLAYLISTIOPLUGIN_H + +#include +#include +#include + +#include + +#include "qmediacontent.h" + +QT_BEGIN_HEADER + +QT_BEGIN_NAMESPACE + +QT_MODULE(Multimedia) + +class QString; +class QUrl; +class QByteArray; +class QIODevice; +class QStringList; + +class Q_MULTIMEDIA_EXPORT QMediaPlaylistReader +{ +public: + virtual ~QMediaPlaylistReader(); + + virtual bool atEnd() const = 0; + virtual QMediaContent readItem() = 0; + virtual void close() = 0; +}; + +class Q_MULTIMEDIA_EXPORT QMediaPlaylistWriter +{ +public: + virtual ~QMediaPlaylistWriter(); + + virtual bool writeItem(const QMediaContent &content) = 0; + virtual void close() = 0; +}; + +struct Q_MULTIMEDIA_EXPORT QMediaPlaylistIOInterface : public QFactoryInterface +{ + virtual bool canRead(QIODevice *device, const QByteArray &format = QByteArray() ) const = 0; + virtual bool canRead(const QUrl& location, const QByteArray &format = QByteArray()) const = 0; + + virtual bool canWrite(QIODevice *device, const QByteArray &format) const = 0; + + virtual QMediaPlaylistReader *createReader(QIODevice *device, const QByteArray &format = QByteArray()) = 0; + virtual QMediaPlaylistReader *createReader(const QUrl& location, const QByteArray &format = QByteArray()) = 0; + + virtual QMediaPlaylistWriter *createWriter(QIODevice *device, const QByteArray &format) = 0; +}; + +#define QMediaPlaylistIOInterface_iid "com.nokia.Qt.QMediaPlaylistIOInterface" +Q_DECLARE_INTERFACE(QMediaPlaylistIOInterface, QMediaPlaylistIOInterface_iid); + +class Q_MULTIMEDIA_EXPORT QMediaPlaylistIOPlugin : public QObject, public QMediaPlaylistIOInterface +{ +Q_OBJECT +Q_INTERFACES(QMediaPlaylistIOInterface:QFactoryInterface) +public: + explicit QMediaPlaylistIOPlugin(QObject *parent = 0); + virtual ~QMediaPlaylistIOPlugin(); + + virtual bool canRead(QIODevice *device, const QByteArray &format = QByteArray() ) const = 0; + virtual bool canRead(const QUrl& location, const QByteArray &format = QByteArray()) const = 0; + + virtual bool canWrite(QIODevice *device, const QByteArray &format) const = 0; + + virtual QStringList keys() const = 0; + + virtual QMediaPlaylistReader *createReader(QIODevice *device, const QByteArray &format = QByteArray()) = 0; + virtual QMediaPlaylistReader *createReader(const QUrl& location, const QByteArray &format = QByteArray()) = 0; + + virtual QMediaPlaylistWriter *createWriter(QIODevice *device, const QByteArray &format) = 0; +}; + +QT_END_NAMESPACE + +QT_END_HEADER + + +#endif // QMEDIAPLAYLISTIOPLUGIN_H diff --git a/src/multimedia/qmediaplaylistnavigator.cpp b/src/multimedia/qmediaplaylistnavigator.cpp new file mode 100644 index 000000000..d78e6ef42 --- /dev/null +++ b/src/multimedia/qmediaplaylistnavigator.cpp @@ -0,0 +1,568 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qmediaplaylistnavigator.h" +#include "qmediaplaylistprovider.h" +#include "qmediaplaylist.h" +#include "qmediaobject_p.h" + +#include + +QT_BEGIN_NAMESPACE + +class QMediaPlaylistNullProvider : public QMediaPlaylistProvider +{ +public: + QMediaPlaylistNullProvider() :QMediaPlaylistProvider() {} + virtual ~QMediaPlaylistNullProvider() {} + virtual int mediaCount() const {return 0;} + virtual QMediaContent media(int) const { return QMediaContent(); } +}; + +Q_GLOBAL_STATIC(QMediaPlaylistNullProvider, _q_nullMediaPlaylist) + +class QMediaPlaylistNavigatorPrivate +{ + Q_DECLARE_NON_CONST_PUBLIC(QMediaPlaylistNavigator) +public: + QMediaPlaylistNavigatorPrivate() + :playlist(0), + currentPos(-1), + lastValidPos(-1), + playbackMode(QMediaPlaylist::Sequential), + randomPositionsOffset(-1) + { + } + + QMediaPlaylistProvider *playlist; + int currentPos; + int lastValidPos; //to be used with CurrentItemOnce playback mode + QMediaPlaylist::PlaybackMode playbackMode; + QMediaContent currentItem; + + mutable QList randomModePositions; + mutable int randomPositionsOffset; + + int nextItemPos(int steps = 1) const; + int previousItemPos(int steps = 1) const; + + void _q_mediaInserted(int start, int end); + void _q_mediaRemoved(int start, int end); + void _q_mediaChanged(int start, int end); + + QMediaPlaylistNavigator *q_ptr; +}; + + +int QMediaPlaylistNavigatorPrivate::nextItemPos(int steps) const +{ + if (playlist->mediaCount() == 0) + return -1; + + if (steps == 0) + return currentPos; + + switch (playbackMode) { + case QMediaPlaylist::CurrentItemOnce: + return /*currentPos == -1 ? lastValidPos :*/ -1; + case QMediaPlaylist::CurrentItemInLoop: + return currentPos; + case QMediaPlaylist::Sequential: + { + int nextPos = currentPos+steps; + return nextPos < playlist->mediaCount() ? nextPos : -1; + } + case QMediaPlaylist::Loop: + return (currentPos+steps) % playlist->mediaCount(); + case QMediaPlaylist::Random: + { + //TODO: limit the history size + + if (randomPositionsOffset == -1) { + randomModePositions.clear(); + randomModePositions.append(currentPos); + randomPositionsOffset = 0; + } + + while (randomModePositions.size() < randomPositionsOffset+steps+1) + randomModePositions.append(-1); + int res = randomModePositions[randomPositionsOffset+steps]; + if (res<0 || res >= playlist->mediaCount()) { + res = qrand() % playlist->mediaCount(); + randomModePositions[randomPositionsOffset+steps] = res; + } + + return res; + } + } + + return -1; +} + +int QMediaPlaylistNavigatorPrivate::previousItemPos(int steps) const +{ + if (playlist->mediaCount() == 0) + return -1; + + if (steps == 0) + return currentPos; + + switch (playbackMode) { + case QMediaPlaylist::CurrentItemOnce: + return /*currentPos == -1 ? lastValidPos :*/ -1; + case QMediaPlaylist::CurrentItemInLoop: + return currentPos; + case QMediaPlaylist::Sequential: + { + int prevPos = currentPos == -1 ? playlist->mediaCount() - steps : currentPos - steps; + return prevPos>=0 ? prevPos : -1; + } + case QMediaPlaylist::Loop: + { + int prevPos = currentPos - steps; + while (prevPos<0) + prevPos += playlist->mediaCount(); + return prevPos; + } + case QMediaPlaylist::Random: + { + //TODO: limit the history size + + if (randomPositionsOffset == -1) { + randomModePositions.clear(); + randomModePositions.append(currentPos); + randomPositionsOffset = 0; + } + + while (randomPositionsOffset-steps < 0) { + randomModePositions.prepend(-1); + randomPositionsOffset++; + } + + int res = randomModePositions[randomPositionsOffset-steps]; + if (res<0 || res >= playlist->mediaCount()) { + res = qrand() % playlist->mediaCount(); + randomModePositions[randomPositionsOffset-steps] = res; + } + + return res; + } + } + + return -1; +} + +/*! + \class QMediaPlaylistNavigator + + \brief The QMediaPlaylistNavigator class provides navigation for a media playlist. + \inmodule QtMultimedia + \ingroup multimedia + \since 1.0 + + \sa QMediaPlaylist, QMediaPlaylistProvider +*/ + + +/*! + Constructs a media playlist navigator for a \a playlist. + + The \a parent is passed to QObject. + \since 1.0 + */ +QMediaPlaylistNavigator::QMediaPlaylistNavigator(QMediaPlaylistProvider *playlist, QObject *parent) + : QObject(parent) + , d_ptr(new QMediaPlaylistNavigatorPrivate) +{ + d_ptr->q_ptr = this; + + setPlaylist(playlist ? playlist : _q_nullMediaPlaylist()); +} + +/*! + Destroys a media playlist navigator. + */ + +QMediaPlaylistNavigator::~QMediaPlaylistNavigator() +{ + delete d_ptr; +} + + +/*! \property QMediaPlaylistNavigator::playbackMode + Contains the playback mode. + \since 1.0 + */ +QMediaPlaylist::PlaybackMode QMediaPlaylistNavigator::playbackMode() const +{ + return d_func()->playbackMode; +} + +/*! + Sets the playback \a mode. + \since 1.0 + */ +void QMediaPlaylistNavigator::setPlaybackMode(QMediaPlaylist::PlaybackMode mode) +{ + Q_D(QMediaPlaylistNavigator); + if (d->playbackMode == mode) + return; + + if (mode == QMediaPlaylist::Random) { + d->randomPositionsOffset = 0; + d->randomModePositions.append(d->currentPos); + } else if (d->playbackMode == QMediaPlaylist::Random) { + d->randomPositionsOffset = -1; + d->randomModePositions.clear(); + } + + d->playbackMode = mode; + + emit playbackModeChanged(mode); + emit surroundingItemsChanged(); +} + +/*! + Returns the playlist being navigated. + \since 1.0 +*/ + +QMediaPlaylistProvider *QMediaPlaylistNavigator::playlist() const +{ + return d_func()->playlist; +} + +/*! + Sets the \a playlist to navigate. + \since 1.0 +*/ +void QMediaPlaylistNavigator::setPlaylist(QMediaPlaylistProvider *playlist) +{ + Q_D(QMediaPlaylistNavigator); + + if (d->playlist == playlist) + return; + + if (d->playlist) { + d->playlist->disconnect(this); + } + + if (playlist) { + d->playlist = playlist; + } else { + //assign to shared readonly null playlist + d->playlist = _q_nullMediaPlaylist(); + } + + connect(d->playlist, SIGNAL(mediaInserted(int,int)), SLOT(_q_mediaInserted(int,int))); + connect(d->playlist, SIGNAL(mediaRemoved(int,int)), SLOT(_q_mediaRemoved(int,int))); + connect(d->playlist, SIGNAL(mediaChanged(int,int)), SLOT(_q_mediaChanged(int,int))); + + d->randomPositionsOffset = -1; + d->randomModePositions.clear(); + + if (d->currentPos != -1) { + d->currentPos = -1; + emit currentIndexChanged(-1); + } + + if (!d->currentItem.isNull()) { + d->currentItem = QMediaContent(); + emit activated(d->currentItem); //stop playback + } +} + +/*! \property QMediaPlaylistNavigator::currentItem + + Contains the media at the current position in the playlist. + + \since 1.0 + \sa currentIndex() +*/ + +QMediaContent QMediaPlaylistNavigator::currentItem() const +{ + return itemAt(d_func()->currentPos); +} + +/*! \fn QMediaContent QMediaPlaylistNavigator::nextItem(int steps) const + + Returns the media that is \a steps positions ahead of the current + position in the playlist. + + \since 1.0 + \sa nextIndex() +*/ +QMediaContent QMediaPlaylistNavigator::nextItem(int steps) const +{ + return itemAt(nextIndex(steps)); +} + +/*! + Returns the media that is \a steps positions behind the current + position in the playlist. + + \since 1.0 + \sa previousIndex() + */ +QMediaContent QMediaPlaylistNavigator::previousItem(int steps) const +{ + return itemAt(previousIndex(steps)); +} + +/*! + Returns the media at a \a position in the playlist. + \since 1.0 + */ +QMediaContent QMediaPlaylistNavigator::itemAt(int position) const +{ + return d_func()->playlist->media(position); +} + +/*! \property QMediaPlaylistNavigator::currentIndex + + Contains the position of the current media. + + If no media is current, the property contains -1. + + \since 1.0 + \sa nextIndex(), previousIndex() +*/ + +int QMediaPlaylistNavigator::currentIndex() const +{ + return d_func()->currentPos; +} + +/*! + Returns a position \a steps ahead of the current position + accounting for the playbackMode(). + + If the position is beyond the end of the playlist, this value + returned is -1. + + \since 1.0 + \sa currentIndex(), previousIndex(), playbackMode() +*/ + +int QMediaPlaylistNavigator::nextIndex(int steps) const +{ + return d_func()->nextItemPos(steps); +} + +/*! + + Returns a position \a steps behind the current position accounting + for the playbackMode(). + + If the position is prior to the beginning of the playlist this will + return -1. + + \since 1.0 + \sa currentIndex(), nextIndex(), playbackMode() +*/ +int QMediaPlaylistNavigator::previousIndex(int steps) const +{ + return d_func()->previousItemPos(steps); +} + +/*! + Advances to the next item in the playlist. + + \since 1.0 + \sa previous(), jump(), playbackMode() + */ +void QMediaPlaylistNavigator::next() +{ + Q_D(QMediaPlaylistNavigator); + + int nextPos = d->nextItemPos(); + + if ( playbackMode() == QMediaPlaylist::Random ) + d->randomPositionsOffset++; + + jump(nextPos); +} + +/*! + Returns to the previous item in the playlist, + + \since 1.0 + \sa next(), jump(), playbackMode() + */ +void QMediaPlaylistNavigator::previous() +{ + Q_D(QMediaPlaylistNavigator); + + int prevPos = d->previousItemPos(); + if ( playbackMode() == QMediaPlaylist::Random ) + d->randomPositionsOffset--; + + jump(prevPos); +} + +/*! + Jumps to a new \a position in the playlist. + \since 1.0 + */ +void QMediaPlaylistNavigator::jump(int position) +{ + Q_D(QMediaPlaylistNavigator); + + if (position<-1 || position>=d->playlist->mediaCount()) { + qWarning() << "QMediaPlaylistNavigator: Jump outside playlist range"; + position = -1; + } + + if (position != -1) + d->lastValidPos = position; + + if (playbackMode() == QMediaPlaylist::Random) { + if (d->randomModePositions[d->randomPositionsOffset] != position) { + d->randomModePositions.clear(); + d->randomModePositions.append(position); + d->randomPositionsOffset = 0; + } + } + + if (position != -1) + d->currentItem = d->playlist->media(position); + else + d->currentItem = QMediaContent(); + + if (position != d->currentPos) { + d->currentPos = position; + emit currentIndexChanged(d->currentPos); + emit surroundingItemsChanged(); + } + + emit activated(d->currentItem); +} + +/*! + \internal + \since 1.0 +*/ +void QMediaPlaylistNavigatorPrivate::_q_mediaInserted(int start, int end) +{ + Q_Q(QMediaPlaylistNavigator); + + if (currentPos >= start) { + currentPos = end-start+1; + q->jump(currentPos); + } + + //TODO: check if they really changed + emit q->surroundingItemsChanged(); +} + +/*! + \internal + \since 1.0 +*/ +void QMediaPlaylistNavigatorPrivate::_q_mediaRemoved(int start, int end) +{ + Q_Q(QMediaPlaylistNavigator); + + if (currentPos > end) { + currentPos = currentPos - end-start+1; + q->jump(currentPos); + } else if (currentPos >= start) { + //current item was removed + currentPos = qMin(start, playlist->mediaCount()-1); + q->jump(currentPos); + } + + //TODO: check if they really changed + emit q->surroundingItemsChanged(); +} + +/*! + \internal + \since 1.0 +*/ +void QMediaPlaylistNavigatorPrivate::_q_mediaChanged(int start, int end) +{ + Q_Q(QMediaPlaylistNavigator); + + if (currentPos >= start && currentPos<=end) { + QMediaContent src = playlist->media(currentPos); + if (src != currentItem) { + currentItem = src; + emit q->activated(src); + } + } + + //TODO: check if they really changed + emit q->surroundingItemsChanged(); +} + +/*! + \fn QMediaPlaylistNavigator::activated(const QMediaContent &media) + + Signals that the current \a media has changed. + \since 1.0 +*/ + +/*! + \fn QMediaPlaylistNavigator::currentIndexChanged(int position) + + Signals the \a position of the current media has changed. + \since 1.0 +*/ + +/*! + \fn QMediaPlaylistNavigator::playbackModeChanged(QMediaPlaylist::PlaybackMode mode) + + Signals that the playback \a mode has changed. + \since 1.0 +*/ + +/*! + \fn QMediaPlaylistNavigator::surroundingItemsChanged() + + Signals that media immediately surrounding the current position has changed. + \since 1.0 +*/ + +#include "moc_qmediaplaylistnavigator.cpp" +QT_END_NAMESPACE + diff --git a/src/multimedia/qmediaplaylistnavigator.h b/src/multimedia/qmediaplaylistnavigator.h new file mode 100644 index 000000000..72e452072 --- /dev/null +++ b/src/multimedia/qmediaplaylistnavigator.h @@ -0,0 +1,115 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QMEDIAPLAYLISTNAVIGATOR_H +#define QMEDIAPLAYLISTNAVIGATOR_H + +#include "qmediaplaylistprovider.h" +#include "qmediaplaylist.h" +#include + +QT_BEGIN_HEADER + +QT_BEGIN_NAMESPACE + +QT_MODULE(Multimedia) + + +class QMediaPlaylistNavigatorPrivate; +class Q_MULTIMEDIA_EXPORT QMediaPlaylistNavigator : public QObject +{ + Q_OBJECT + Q_PROPERTY(QMediaPlaylist::PlaybackMode playbackMode READ playbackMode WRITE setPlaybackMode NOTIFY playbackModeChanged) + Q_PROPERTY(int currentIndex READ currentIndex WRITE jump NOTIFY currentIndexChanged) + Q_PROPERTY(QMediaContent currentItem READ currentItem) + +public: + QMediaPlaylistNavigator(QMediaPlaylistProvider *playlist, QObject *parent = 0); + virtual ~QMediaPlaylistNavigator(); + + QMediaPlaylistProvider *playlist() const; + void setPlaylist(QMediaPlaylistProvider *playlist); + + QMediaPlaylist::PlaybackMode playbackMode() const; + + QMediaContent currentItem() const; + QMediaContent nextItem(int steps = 1) const; + QMediaContent previousItem(int steps = 1) const; + + QMediaContent itemAt(int position) const; + + int currentIndex() const; + int nextIndex(int steps = 1) const; + int previousIndex(int steps = 1) const; + +public Q_SLOTS: + void next(); + void previous(); + + void jump(int); + + void setPlaybackMode(QMediaPlaylist::PlaybackMode mode); + +Q_SIGNALS: + void activated(const QMediaContent &content); + void currentIndexChanged(int); + void playbackModeChanged(QMediaPlaylist::PlaybackMode mode); + + void surroundingItemsChanged(); + +protected: + QMediaPlaylistNavigatorPrivate *d_ptr; + +private: + Q_DISABLE_COPY(QMediaPlaylistNavigator) + Q_DECLARE_PRIVATE(QMediaPlaylistNavigator) + + Q_PRIVATE_SLOT(d_func(), void _q_mediaInserted(int start, int end)) + Q_PRIVATE_SLOT(d_func(), void _q_mediaRemoved(int start, int end)) + Q_PRIVATE_SLOT(d_func(), void _q_mediaChanged(int start, int end)) +}; + +QT_END_NAMESPACE + +QT_END_HEADER + + +#endif // QMEDIAPLAYLISTNAVIGATOR_H diff --git a/src/multimedia/qmediaplaylistprovider.cpp b/src/multimedia/qmediaplaylistprovider.cpp new file mode 100644 index 000000000..75e927b39 --- /dev/null +++ b/src/multimedia/qmediaplaylistprovider.cpp @@ -0,0 +1,329 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qmediaplaylistprovider.h" +#include "qmediaplaylistprovider_p.h" + +#include + +QT_BEGIN_NAMESPACE + +/*! + \class QMediaPlaylistProvider + + \brief The QMediaPlaylistProvider class provides an abstract list of media. + \inmodule QtMultimedia + \since 1.0 + + \sa QMediaPlaylist +*/ + +/*! + Constructs a playlist provider with the given \a parent. +*/ +QMediaPlaylistProvider::QMediaPlaylistProvider(QObject *parent) + :QObject(parent), d_ptr(new QMediaPlaylistProviderPrivate) +{ +} + +/*! + \internal +*/ +QMediaPlaylistProvider::QMediaPlaylistProvider(QMediaPlaylistProviderPrivate &dd, QObject *parent) + :QObject(parent), d_ptr(&dd) +{ +} + +/*! + Destroys a playlist provider. +*/ +QMediaPlaylistProvider::~QMediaPlaylistProvider() +{ + delete d_ptr; +} + +/*! + \fn QMediaPlaylistProvider::mediaCount() const; + + Returns the size of playlist. + \since 1.0 +*/ + +/*! + \fn QMediaPlaylistProvider::media(int index) const; + + Returns the media at \a index in the playlist. + + If the index is invalid this will return a null media content. + \since 1.0 +*/ + + +/*! + Loads a playlist from from a URL \a location. If no playlist \a format is specified the loader + will inspect the URL or probe the headers to guess the format. + + New items are appended to playlist. + + Returns true if the provider supports the format and loading from the locations URL protocol, + otherwise this will return false. + \since 1.0 +*/ +bool QMediaPlaylistProvider::load(const QUrl &location, const char *format) +{ + Q_UNUSED(location); + Q_UNUSED(format); + return false; +} + +/*! + Loads a playlist from from an I/O \a device. If no playlist \a format is specified the loader + will probe the headers to guess the format. + + New items are appended to playlist. + + Returns true if the provider supports the format and loading from an I/O device, otherwise this + will return false. + \since 1.0 +*/ +bool QMediaPlaylistProvider::load(QIODevice * device, const char *format) +{ + Q_UNUSED(device); + Q_UNUSED(format); + return false; +} + +/*! + Saves the contents of a playlist to a URL \a location. If no playlist \a format is specified + the writer will inspect the URL to guess the format. + + Returns true if the playlist was saved successfully; and false otherwise. + \since 1.0 + */ +bool QMediaPlaylistProvider::save(const QUrl &location, const char *format) +{ + Q_UNUSED(location); + Q_UNUSED(format); + return false; +} + +/*! + Saves the contents of a playlist to an I/O \a device in the specified \a format. + + Returns true if the playlist was saved successfully; and false otherwise. + \since 1.0 +*/ +bool QMediaPlaylistProvider::save(QIODevice * device, const char *format) +{ + Q_UNUSED(device); + Q_UNUSED(format); + return false; +} + +/*! + Returns true if a playlist is read-only; otherwise returns false. + \since 1.0 +*/ +bool QMediaPlaylistProvider::isReadOnly() const +{ + return true; +} + +/*! + Append \a media to a playlist. + + Returns true if the media was appended; and false otherwise. + \since 1.0 +*/ +bool QMediaPlaylistProvider::addMedia(const QMediaContent &media) +{ + Q_UNUSED(media); + return false; +} + +/*! + Append multiple media \a items to a playlist. + + Returns true if the media items were appended; and false otherwise. + \since 1.0 +*/ +bool QMediaPlaylistProvider::addMedia(const QList &items) +{ + foreach(const QMediaContent &item, items) { + if (!addMedia(item)) + return false; + } + + return true; +} + +/*! + Inserts \a media into a playlist at \a position. + + Returns true if the media was inserted; and false otherwise. + \since 1.0 +*/ +bool QMediaPlaylistProvider::insertMedia(int position, const QMediaContent &media) +{ + Q_UNUSED(position); + Q_UNUSED(media); + return false; +} + +/*! + Inserts multiple media \a items into a playlist at \a position. + + Returns true if the media \a items were inserted; and false otherwise. + \since 1.0 +*/ +bool QMediaPlaylistProvider::insertMedia(int position, const QList &items) +{ + for (int i=0; i + +#include "qmediacontent.h" +#include "qmediaplaylist.h" + +QT_BEGIN_HEADER + +QT_BEGIN_NAMESPACE + +QT_MODULE(Multimedia) + +class QString; +QT_END_NAMESPACE + +QT_BEGIN_NAMESPACE + +class QMediaPlaylistProviderPrivate; +class Q_MULTIMEDIA_EXPORT QMediaPlaylistProvider : public QObject +{ +Q_OBJECT +public: + QMediaPlaylistProvider(QObject *parent=0); + virtual ~QMediaPlaylistProvider(); + + virtual bool load(const QUrl &location, const char *format = 0); + virtual bool load(QIODevice * device, const char *format = 0); + virtual bool save(const QUrl &location, const char *format = 0); + virtual bool save(QIODevice * device, const char *format); + + virtual int mediaCount() const = 0; + virtual QMediaContent media(int index) const = 0; + + virtual bool isReadOnly() const; + + virtual bool addMedia(const QMediaContent &content); + virtual bool addMedia(const QList &contentList); + virtual bool insertMedia(int index, const QMediaContent &content); + virtual bool insertMedia(int index, const QList &content); + virtual bool removeMedia(int pos); + virtual bool removeMedia(int start, int end); + virtual bool clear(); + +public Q_SLOTS: + virtual void shuffle(); + +Q_SIGNALS: + 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(QMediaPlaylist::Error, const QString& errorMessage); + +protected: + QMediaPlaylistProviderPrivate *d_ptr; + QMediaPlaylistProvider(QMediaPlaylistProviderPrivate &dd, QObject *parent); + +private: + Q_DECLARE_PRIVATE(QMediaPlaylistProvider) +}; + +QT_END_NAMESPACE + +QT_END_HEADER + + +#endif // QMEDIAPLAYLISTPROVIDER_H diff --git a/src/multimedia/qmediaplaylistprovider_p.h b/src/multimedia/qmediaplaylistprovider_p.h new file mode 100644 index 000000000..71fb86f20 --- /dev/null +++ b/src/multimedia/qmediaplaylistprovider_p.h @@ -0,0 +1,80 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QMEDIAPLAYLISTPROVIDER_P_H +#define QMEDIAPLAYLISTPROVIDER_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" + +QT_BEGIN_HEADER + +QT_BEGIN_NAMESPACE + +QT_MODULE(Multimedia) + + +class QMediaPlaylistProviderPrivate +{ +public: + QMediaPlaylistProviderPrivate() + {} + virtual ~QMediaPlaylistProviderPrivate() + {} +}; + +QT_END_NAMESPACE + +QT_END_HEADER + + + +#endif // QMEDIAPLAYLISTSOURCE_P_H diff --git a/src/multimedia/qmediaplaylistsourcecontrol.cpp b/src/multimedia/qmediaplaylistsourcecontrol.cpp new file mode 100644 index 000000000..ca90feda2 --- /dev/null +++ b/src/multimedia/qmediaplaylistsourcecontrol.cpp @@ -0,0 +1,128 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + + +#include +#include + +QT_BEGIN_NAMESPACE + +/*! + \class QMediaPlaylistSourceControl + \inmodule QtMultimedia + \ingroup multimedia-serv + \since 1.0 + + + \brief The QMediaPlaylistSourceControl class provides access to the playlist playback + functionality of a QMediaService. + + This control allows QMediaPlaylist to be passed directly to the service + instead of playing media sources one by one. This control should be + implemented if backend benefits from knowing the next media source to be + played, for example for preloading, cross fading or gap-less playback. + + If QMediaPlaylistSourceControl is provided, the backend must listen for + current playlist item changes to load corresponding media source and + advance the playlist with QMediaPlaylist::next() when playback of the + current media is finished. + + The interface name of QMediaPlaylistSourceControl is \c com.nokia.Qt.QMediaPlaylistSourceControl/1.0 as + defined in QMediaPlaylistSourceControl_iid. + + \sa QMediaService::requestControl(), QMediaPlayer +*/ + +/*! + \macro QMediaPlaylistSourceControl_iid + + \c com.nokia.Qt.QMediaPlaylistSourceControl/1.0 + + Defines the interface name of the QMediaPlaylistSourceControl class. + + \relates QMediaPlaylistSourceControl +*/ + +/*! + Create a new playlist source control object with the given \a parent. +*/ +QMediaPlaylistSourceControl::QMediaPlaylistSourceControl(QObject *parent): + QMediaControl(*new QMediaControlPrivate, parent) +{ +} + +/*! + Destroys the playlist control. +*/ +QMediaPlaylistSourceControl::~QMediaPlaylistSourceControl() +{ +} + + +/*! + \fn QMediaPlaylistSourceControl::playlist() const + + Returns the current playlist. + Should return a null pointer if no playlist is assigned. + \since 1.0 +*/ + +/*! + \fn QMediaPlaylistSourceControl::setPlaylist(QMediaPlaylist *playlist) + + Set the playlist of this media player to \a playlist. + If a null pointer is passed, the playlist source should be disabled. + + The current media should be replaced with the current item of the media playlist. + \since 1.0 +*/ + + +/*! + \fn QMediaPlaylistSourceControl::playlistChanged(QMediaPlaylist* playlist) + + Signal emitted when the playlist has changed to \a playlist. + \since 1.0 +*/ + +#include "moc_qmediaplaylistsourcecontrol.cpp" +QT_END_NAMESPACE + diff --git a/src/multimedia/qmediaplaylistsourcecontrol.h b/src/multimedia/qmediaplaylistsourcecontrol.h new file mode 100644 index 000000000..040bb6431 --- /dev/null +++ b/src/multimedia/qmediaplaylistsourcecontrol.h @@ -0,0 +1,82 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + + +#ifndef QMEDIAPLAYLISTSOURCECONTROL_H +#define QMEDIAPLAYLISTSOURCECONTROL_H + +#include + +QT_BEGIN_HEADER + +QT_BEGIN_NAMESPACE + +QT_MODULE(Multimedia) + + +class QMediaPlaylist; + +class Q_MULTIMEDIA_EXPORT QMediaPlaylistSourceControl : public QMediaControl +{ + Q_OBJECT + +public: + virtual ~QMediaPlaylistSourceControl(); + + virtual QMediaPlaylist *playlist() const = 0; + virtual void setPlaylist(QMediaPlaylist *) = 0; + +Q_SIGNALS: + void playlistChanged(QMediaPlaylist* playlist); + +protected: + QMediaPlaylistSourceControl(QObject* parent = 0); +}; + +#define QMediaPlaylistSourceControl_iid "com.nokia.Qt.QMediaPlaylistSourceControl/1.0" +Q_MEDIA_DECLARE_CONTROL(QMediaPlaylistSourceControl, QMediaPlaylistSourceControl_iid) + +QT_END_NAMESPACE + +QT_END_HEADER + + +#endif // QMEDIAPLAYLISTCONTROL_H diff --git a/src/multimedia/qmediapluginloader.cpp b/src/multimedia/qmediapluginloader.cpp new file mode 100644 index 000000000..32f336959 --- /dev/null +++ b/src/multimedia/qmediapluginloader.cpp @@ -0,0 +1,213 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qmediapluginloader_p.h" +#include +#include +#include +#include + +#include "qmediaserviceproviderplugin.h" + +#if defined(Q_OS_MAC) +# include +#endif + +QT_BEGIN_NAMESPACE + +typedef QMap ObjectListMap; +Q_GLOBAL_STATIC(ObjectListMap, staticMediaPlugins); + + +QMediaPluginLoader::QMediaPluginLoader(const char *iid, const QString &location, Qt::CaseSensitivity): + m_iid(iid) +{ + m_location = QString::fromLatin1("/%1").arg(location); + load(); +} + +QStringList QMediaPluginLoader::keys() const +{ + return m_instances.keys(); +} + +QObject* QMediaPluginLoader::instance(QString const &key) +{ + return m_instances.value(key).value(0); +} + +QList QMediaPluginLoader::instances(QString const &key) +{ + return m_instances.value(key); +} + +//to be used for testing purposes only +void QMediaPluginLoader::setStaticPlugins(const QString &location, const QObjectList& objects) +{ + staticMediaPlugins()->insert(QString::fromLatin1("/%1").arg(location), objects); +} + +QStringList QMediaPluginLoader::availablePlugins() const +{ + QStringList paths; + QStringList plugins; + +#if defined(Q_OS_MAC) + QString imageSuffix(qgetenv("DYLD_IMAGE_SUFFIX")); + + // Bundle plugin directory + CFBundleRef mainBundle = CFBundleGetMainBundle(); + if (mainBundle != 0) { + CFURLRef baseUrl = CFBundleCopyBundleURL(mainBundle); + CFURLRef pluginUrlPart = CFBundleCopyBuiltInPlugInsURL(mainBundle); + CFStringRef pluginPathPart = CFURLCopyFileSystemPath(pluginUrlPart, kCFURLPOSIXPathStyle); + CFURLRef pluginUrl = CFURLCreateCopyAppendingPathComponent(0, baseUrl, pluginPathPart, true); + CFStringRef pluginPath = CFURLCopyFileSystemPath(pluginUrl, kCFURLPOSIXPathStyle); + + CFIndex length = CFStringGetLength(pluginPath); + UniChar buffer[length]; + CFStringGetCharacters(pluginPath, CFRangeMake(0, length), buffer); + + paths << QString(reinterpret_cast(buffer), length); + + CFRelease(pluginPath); + CFRelease(pluginUrl); + CFRelease(pluginPathPart); + CFRelease(pluginUrlPart); + CFRelease(baseUrl); + } +#endif + + // Qt paths + paths << QCoreApplication::libraryPaths(); + + foreach (const QString &path, paths) { + QDir typeDir(path + m_location); + foreach (const QString &file, typeDir.entryList(QDir::Files)) { +#if defined(Q_OS_MAC) + if (!imageSuffix.isEmpty()) { // Only add appropriate images + if (file.lastIndexOf(imageSuffix, -6) == -1) + continue; + } else { // Ignore any images with common suffixes + if (file.endsWith(QLatin1String("_debug.dylib")) || + file.endsWith(QLatin1String("_profile.dylib"))) + continue; + } +#elif defined(Q_OS_UNIX) + // Ignore separate debug files + if (file.endsWith(QLatin1String(".debug"))) + continue; +#elif defined(Q_OS_WIN) + // Ignore non-dlls + if (!file.endsWith(QLatin1String(".dll"), Qt::CaseInsensitive)) + continue; +#endif + plugins << typeDir.absoluteFilePath(file); + } + } + + return plugins; +} + +void QMediaPluginLoader::load() +{ + if (!m_instances.isEmpty()) + return; + +#if !defined QT_NO_DEBUG + const bool showDebug = qgetenv("QT_DEBUG_PLUGINS").toInt() > 0; +#endif + + if (staticMediaPlugins() && staticMediaPlugins()->contains(m_location)) { + foreach(QObject *o, staticMediaPlugins()->value(m_location)) { + if (o != 0 && o->qt_metacast(m_iid) != 0) { + QFactoryInterface* p = qobject_cast(o); + if (p != 0) { + foreach (QString const &key, p->keys()) + m_instances[key].append(o); + } + } + } + } else { + QSet loadedPlugins; + + foreach (const QString &plugin, availablePlugins()) { + QString fileName = QFileInfo(plugin).fileName(); + //don't try to load plugin with the same name if it's already loaded + if (loadedPlugins.contains(fileName)) { +#if !defined QT_NO_DEBUG + if (showDebug) + qDebug() << "Skip loading plugin" << plugin; +#endif + continue; + } + + QPluginLoader loader(plugin); + + QObject *o = loader.instance(); + if (o != 0 && o->qt_metacast(m_iid) != 0) { + QFactoryInterface* p = qobject_cast(o); + if (p != 0) { + foreach (const QString &key, p->keys()) + m_instances[key].append(o); + + loadedPlugins.insert(fileName); +#if !defined QT_NO_DEBUG + if (showDebug) + qDebug() << "Loaded plugin" << plugin << "services:" << p->keys(); +#endif + } + + continue; + } else { +#if !defined QT_NO_DEBUG + if (showDebug) + qWarning() << "QMediaPluginLoader: Failed to load plugin: " << plugin << loader.errorString(); +#endif + } + + delete o; + } + } +} + +QT_END_NAMESPACE + diff --git a/src/multimedia/qmediapluginloader_p.h b/src/multimedia/qmediapluginloader_p.h new file mode 100644 index 000000000..1800a41e7 --- /dev/null +++ b/src/multimedia/qmediapluginloader_p.h @@ -0,0 +1,99 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QMEDIAPLUGINLOADER_H +#define QMEDIAPLUGINLOADER_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 +#include +#include +#include +#include + + +QT_BEGIN_HEADER + +QT_BEGIN_NAMESPACE + +QT_MODULE(Multimedia) + + +class QMediaServiceProviderPlugin; + +class Q_AUTOTEST_EXPORT QMediaPluginLoader +{ +public: + QMediaPluginLoader(const char *iid, + const QString &suffix = QString(), + Qt::CaseSensitivity = Qt::CaseSensitive); + + QStringList keys() const; + QObject* instance(QString const &key); + QList instances(QString const &key); + + static void setStaticPlugins(const QString &location, const QObjectList& objects); + +private: + void load(); + QStringList availablePlugins() const; + + QByteArray m_iid; + QString m_location; + QMap > m_instances; +}; + +QT_END_NAMESPACE + +QT_END_HEADER + + +#endif // QMEDIAPLUGINLOADER_H diff --git a/src/multimedia/qmediarecorder.cpp b/src/multimedia/qmediarecorder.cpp new file mode 100644 index 000000000..bcbae5708 --- /dev/null +++ b/src/multimedia/qmediarecorder.cpp @@ -0,0 +1,904 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qmediarecorder.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include + +#include + +QT_BEGIN_NAMESPACE + +/*! + \class QMediaRecorder + \inmodule QtMultimedia + \ingroup multimedia + \since 1.0 + + + \brief The QMediaRecorder class is used for the recording of media content. + + The QMediaRecorder class is a high level media recording class. It's not + intended to be used alone but for accessing the media recording functions + of other media objects, like QRadioTuner, or QAudioCaptureSource. + + \snippet doc/src/snippets/multimedia-snippets/media.cpp Media recorder + + \sa QAudioCaptureSource +*/ + +namespace +{ +class MediaRecorderRegisterMetaTypes +{ +public: + MediaRecorderRegisterMetaTypes() + { + qRegisterMetaType("QMediaRecorder::State"); + qRegisterMetaType("QMediaRecorder::Error"); + } +} _registerRecorderMetaTypes; +} + + +class QMediaRecorderPrivate +{ + Q_DECLARE_NON_CONST_PUBLIC(QMediaRecorder) + +public: + QMediaRecorderPrivate(); + + QMediaObject *mediaObject; + + QMediaRecorderControl *control; + QMediaContainerControl *formatControl; + QAudioEncoderControl *audioControl; + QVideoEncoderControl *videoControl; + QMetaDataWriterControl *metaDataControl; + + QTimer* notifyTimer; + + QMediaRecorder::State state; + QMediaRecorder::Error error; + QString errorString; + + void _q_stateChanged(QMediaRecorder::State state); + void _q_error(int error, const QString &errorString); + void _q_serviceDestroyed(); + void _q_notify(); + void _q_updateNotifyInterval(int ms); + + QMediaRecorder *q_ptr; +}; + +QMediaRecorderPrivate::QMediaRecorderPrivate(): + mediaObject(0), + control(0), + formatControl(0), + audioControl(0), + videoControl(0), + metaDataControl(0), + notifyTimer(0), + state(QMediaRecorder::StoppedState), + error(QMediaRecorder::NoError) +{ +} + +#define ENUM_NAME(c,e,v) (c::staticMetaObject.enumerator(c::staticMetaObject.indexOfEnumerator(e)).valueToKey((v))) + +void QMediaRecorderPrivate::_q_stateChanged(QMediaRecorder::State ps) +{ + Q_Q(QMediaRecorder); + + if (ps == QMediaRecorder::RecordingState) + notifyTimer->start(); + else + notifyTimer->stop(); + +// qDebug() << "Recorder state changed:" << ENUM_NAME(QMediaRecorder,"State",ps); + if (state != ps) { + emit q->stateChanged(ps); + } + + state = ps; +} + + +void QMediaRecorderPrivate::_q_error(int error, const QString &errorString) +{ + Q_Q(QMediaRecorder); + + this->error = QMediaRecorder::Error(error); + this->errorString = errorString; + + emit q->error(this->error); +} + +void QMediaRecorderPrivate::_q_serviceDestroyed() +{ + mediaObject = 0; + control = 0; + formatControl = 0; + audioControl = 0; + videoControl = 0; + metaDataControl = 0; +} + +void QMediaRecorderPrivate::_q_notify() +{ + emit q_func()->durationChanged(q_func()->duration()); +} + +void QMediaRecorderPrivate::_q_updateNotifyInterval(int ms) +{ + notifyTimer->setInterval(ms); +} + + +/*! + Constructs a media recorder which records the media produced by \a mediaObject. + + The \a parent is passed to QMediaObject. + \since 1.0 +*/ + +QMediaRecorder::QMediaRecorder(QMediaObject *mediaObject, QObject *parent): + QObject(parent), + d_ptr(new QMediaRecorderPrivate) +{ + Q_D(QMediaRecorder); + d->q_ptr = this; + setMediaObject(mediaObject); + + d->notifyTimer = new QTimer(this); + d->notifyTimer->setInterval(mediaObject->notifyInterval()); + connect(d->notifyTimer, SIGNAL(timeout()), SLOT(_q_notify())); + connect(mediaObject, SIGNAL(notifyIntervalChanged(int)), SLOT(_q_updateNotifyInterval(int))); +} + +/*! + Destroys a media recorder object. +*/ + +QMediaRecorder::~QMediaRecorder() +{ +} + +/*! + Returns the QMediaObject instance that this QMediaRecorder is bound too, + or 0 otherwise. + \since 1.0 +*/ +QMediaObject *QMediaRecorder::mediaObject() const +{ + return d_func()->mediaObject; +} + +/*! + \internal + \since 1.0 +*/ +bool QMediaRecorder::setMediaObject(QMediaObject *object) +{ + Q_D(QMediaRecorder); + + if (object == d->mediaObject) + return true; + + if (d->mediaObject) { + if (d->control) { + disconnect(d->control, SIGNAL(stateChanged(QMediaRecorder::State)), + this, SLOT(_q_stateChanged(QMediaRecorder::State))); + + disconnect(d->control, SIGNAL(mutedChanged(bool)), + this, SIGNAL(mutedChanged(bool))); + + disconnect(d->control, SIGNAL(durationChanged(qint64)), + this, SIGNAL(durationChanged(qint64))); + + disconnect(d->control, SIGNAL(error(int,QString)), + this, SLOT(_q_error(int,QString))); + } + + QMediaService *service = d->mediaObject->service(); + + if (service) { + disconnect(service, SIGNAL(destroyed()), this, SLOT(_q_serviceDestroyed())); + + if (d->control) + service->releaseControl(d->control); + if (d->formatControl) + service->releaseControl(d->formatControl); + if (d->audioControl) + service->releaseControl(d->audioControl); + if (d->videoControl) + service->releaseControl(d->videoControl); + if (d->metaDataControl) { + disconnect(d->metaDataControl, SIGNAL(metaDataChanged()), + this, SIGNAL(metaDataChanged())); + disconnect(d->metaDataControl, SIGNAL(metaDataAvailableChanged(bool)), + this, SIGNAL(metaDataAvailableChanged(bool))); + disconnect(d->metaDataControl, SIGNAL(writableChanged(bool)), + this, SIGNAL(metaDataWritableChanged(bool))); + + service->releaseControl(d->metaDataControl); + } + } + } + + d->control = 0; + d->formatControl = 0; + d->audioControl = 0; + d->videoControl = 0; + d->metaDataControl = 0; + + d->mediaObject = object; + + if (d->mediaObject) { + QMediaService *service = d->mediaObject->service(); + + if (service) { + d->control = qobject_cast(service->requestControl(QMediaRecorderControl_iid)); + + if (d->control) { + d->formatControl = qobject_cast(service->requestControl(QMediaContainerControl_iid)); + d->audioControl = qobject_cast(service->requestControl(QAudioEncoderControl_iid)); + d->videoControl = qobject_cast(service->requestControl(QVideoEncoderControl_iid)); + + QMediaControl *control = service->requestControl(QMetaDataWriterControl_iid); + if (control) { + d->metaDataControl = qobject_cast(control); + if (!d->metaDataControl) { + service->releaseControl(control); + } else { + connect(d->metaDataControl, + SIGNAL(metaDataChanged()), + SIGNAL(metaDataChanged())); + connect(d->metaDataControl, + SIGNAL(metaDataAvailableChanged(bool)), + SIGNAL(metaDataAvailableChanged(bool))); + connect(d->metaDataControl, + SIGNAL(writableChanged(bool)), + SIGNAL(metaDataWritableChanged(bool))); + } + } + + connect(d->control, SIGNAL(stateChanged(QMediaRecorder::State)), + this, SLOT(_q_stateChanged(QMediaRecorder::State))); + + connect(d->control, SIGNAL(mutedChanged(bool)), + this, SIGNAL(mutedChanged(bool))); + + connect(d->control, SIGNAL(durationChanged(qint64)), + this, SIGNAL(durationChanged(qint64))); + + connect(d->control, SIGNAL(error(int,QString)), + this, SLOT(_q_error(int,QString))); + + connect(service, SIGNAL(destroyed()), this, SLOT(_q_serviceDestroyed())); + + + return true; + } + } + + d->mediaObject = 0; + return false; + } + + return true; +} + +/*! + \property QMediaRecorder::outputLocation + \brief the destination location of media content. + + Setting the location can fail, for example when the service supports only + local file system locations but a network URL was passed. If the service + does not support media recording this setting the output location will + always fail. + + The \a location can be relative or empty; + in this case the recorder uses the system specific place and file naming scheme. + After recording has stated, QMediaRecorder::outputLocation() returns the actual output location. + \since 1.0 +*/ + +/*! + Returns true if media recorder service ready to use. + \since 1.0 +*/ +bool QMediaRecorder::isAvailable() const +{ + if (d_func()->control != NULL) + return true; + else + return false; +} + +/*! + Returns the availability error code. + \since 1.0 +*/ +QtMultimedia::AvailabilityError QMediaRecorder::availabilityError() const +{ + if (d_func()->control != NULL) + return QtMultimedia::NoError; + else + return QtMultimedia::ServiceMissingError; +} + +QUrl QMediaRecorder::outputLocation() const +{ + return d_func()->control ? d_func()->control->outputLocation() : QUrl(); +} + +bool QMediaRecorder::setOutputLocation(const QUrl &location) +{ + Q_D(QMediaRecorder); + return d->control ? d->control->setOutputLocation(location) : false; +} + +/*! + Returns the current media recorder state. + + \since 1.0 + \sa QMediaRecorder::State +*/ + +QMediaRecorder::State QMediaRecorder::state() const +{ + return d_func()->control ? QMediaRecorder::State(d_func()->control->state()) : StoppedState; +} + +/*! + Returns the current error state. + + \since 1.0 + \sa errorString() +*/ + +QMediaRecorder::Error QMediaRecorder::error() const +{ + return d_func()->error; +} + +/*! + Returns a string describing the current error state. + + \since 1.0 + \sa error() +*/ + +QString QMediaRecorder::errorString() const +{ + return d_func()->errorString; +} + +/*! + \property QMediaRecorder::duration + + \brief the recorded media duration in milliseconds. + \since 1.0 +*/ + +qint64 QMediaRecorder::duration() const +{ + return d_func()->control ? d_func()->control->duration() : 0; +} + +/*! + \property QMediaRecorder::muted + + \brief whether a recording audio stream is muted. + \since 1.0 +*/ + +bool QMediaRecorder::isMuted() const +{ + return d_func()->control ? d_func()->control->isMuted() : 0; +} + +void QMediaRecorder::setMuted(bool muted) +{ + Q_D(QMediaRecorder); + + if (d->control) + d->control->setMuted(muted); +} + +/*! + Returns a list of MIME types of supported container formats. + \since 1.0 +*/ +QStringList QMediaRecorder::supportedContainers() const +{ + return d_func()->formatControl ? + d_func()->formatControl->supportedContainers() : QStringList(); +} + +/*! + Returns a description of a container format \a mimeType. + \since 1.0 +*/ +QString QMediaRecorder::containerDescription(const QString &mimeType) const +{ + return d_func()->formatControl ? + d_func()->formatControl->containerDescription(mimeType) : QString(); +} + +/*! + Returns the MIME type of the selected container format. + \since 1.0 +*/ + +QString QMediaRecorder::containerMimeType() const +{ + return d_func()->formatControl ? + d_func()->formatControl->containerMimeType() : QString(); +} + +/*! + Returns a list of supported audio codecs. + \since 1.0 +*/ +QStringList QMediaRecorder::supportedAudioCodecs() const +{ + return d_func()->audioControl ? + d_func()->audioControl->supportedAudioCodecs() : QStringList(); +} + +/*! + Returns a description of an audio \a codec. + \since 1.0 +*/ +QString QMediaRecorder::audioCodecDescription(const QString &codec) const +{ + return d_func()->audioControl ? + d_func()->audioControl->codecDescription(codec) : QString(); +} + +/*! + Returns a list of supported audio sample rates. + + If non null audio \a settings parameter is passed, the returned list is + reduced to sample rates supported with partial settings applied. + + This can be used to query the list of sample rates, supported by specific + audio codec. + + If the encoder supports arbitrary sample rates within the supported rates + range, *\a continuous is set to true, otherwise *\a continuous is set to + false. + \since 1.0 +*/ + +QList QMediaRecorder::supportedAudioSampleRates(const QAudioEncoderSettings &settings, bool *continuous) const +{ + if (continuous) + *continuous = false; + + return d_func()->audioControl ? + d_func()->audioControl->supportedSampleRates(settings, continuous) : QList(); +} + +/*! + Returns a list of resolutions video can be encoded at. + + If non null video \a settings parameter is passed, the returned list is + reduced to resolution supported with partial settings like video codec or + framerate applied. + + If the encoder supports arbitrary resolutions within the supported range, + *\a continuous is set to true, otherwise *\a continuous is set to false. + + \since 1.0 + \sa QVideoEncoderSettings::resolution() +*/ +QList QMediaRecorder::supportedResolutions(const QVideoEncoderSettings &settings, bool *continuous) const +{ + if (continuous) + *continuous = false; + + return d_func()->videoControl ? + d_func()->videoControl->supportedResolutions(settings, continuous) : QList(); +} + +/*! + Returns a list of frame rates video can be encoded at. + + If non null video \a settings parameter is passed, the returned list is + reduced to frame rates supported with partial settings like video codec or + resolution applied. + + If the encoder supports arbitrary frame rates within the supported range, + *\a continuous is set to true, otherwise *\a continuous is set to false. + + \since 1.0 + \sa QVideoEncoderSettings::frameRate() +*/ +QList QMediaRecorder::supportedFrameRates(const QVideoEncoderSettings &settings, bool *continuous) const +{ + if (continuous) + *continuous = false; + + return d_func()->videoControl ? + d_func()->videoControl->supportedFrameRates(settings, continuous) : QList(); +} + +/*! + Returns a list of supported video codecs. + \since 1.0 +*/ +QStringList QMediaRecorder::supportedVideoCodecs() const +{ + return d_func()->videoControl ? + d_func()->videoControl->supportedVideoCodecs() : QStringList(); +} + +/*! + Returns a description of a video \a codec. + + \since 1.0 + \sa setEncodingSettings() +*/ +QString QMediaRecorder::videoCodecDescription(const QString &codec) const +{ + return d_func()->videoControl ? + d_func()->videoControl->videoCodecDescription(codec) : QString(); +} + +/*! + Returns the audio encoder settings being used. + + \since 1.0 + \sa setEncodingSettings() +*/ + +QAudioEncoderSettings QMediaRecorder::audioSettings() const +{ + return d_func()->audioControl ? + d_func()->audioControl->audioSettings() : QAudioEncoderSettings(); +} + +/*! + Returns the video encoder settings being used. + + \since 1.0 + \sa setEncodingSettings() +*/ + +QVideoEncoderSettings QMediaRecorder::videoSettings() const +{ + return d_func()->videoControl ? + d_func()->videoControl->videoSettings() : QVideoEncoderSettings(); +} + +/*! + Sets the \a audio and \a video encoder settings and \a container format MIME type. + + If some parameters are not specified, or null settings are passed, the + encoder will choose default encoding parameters, depending on media + source properties. + While setEncodingSettings is optional, the backend can preload + encoding pipeline to improve recording startup time. + + It's only possible to change settings when the encoder is in the + QMediaEncoder::StoppedState state. + + \since 1.0 + \sa audioSettings(), videoSettings(), containerMimeType() +*/ + +void QMediaRecorder::setEncodingSettings(const QAudioEncoderSettings &audio, + const QVideoEncoderSettings &video, + const QString &container) +{ + Q_D(QMediaRecorder); + + QCamera *camera = qobject_cast(d->mediaObject); + if (camera && camera->captureMode() == QCamera::CaptureVideo) { + QMetaObject::invokeMethod(camera, + "_q_preparePropertyChange", + Qt::DirectConnection, + Q_ARG(int, QCameraControl::VideoEncodingSettings)); + } + + if (d->audioControl) + d->audioControl->setAudioSettings(audio); + + if (d->videoControl) + d->videoControl->setVideoSettings(video); + + if (d->formatControl) + d->formatControl->setContainerMimeType(container); + + if (d->control) + d->control->applySettings(); +} + + +/*! + Start recording. + + This is an asynchronous call, with signal + stateCahnged(QMediaRecorder::RecordingState) being emitted when recording + started, otherwise the error() signal is emitted. + \since 1.0 +*/ + +void QMediaRecorder::record() +{ + Q_D(QMediaRecorder); + + // reset error + d->error = NoError; + d->errorString = QString(); + + if (d->control) + d->control->record(); +} + +/*! + Pause recording. + \since 1.0 +*/ + +void QMediaRecorder::pause() +{ + Q_D(QMediaRecorder); + if (d->control) + d->control->pause(); +} + +/*! + Stop recording. + \since 1.0 +*/ + +void QMediaRecorder::stop() +{ + Q_D(QMediaRecorder); + if (d->control) + d->control->stop(); +} + +/*! + \enum QMediaRecorder::State + + \value StoppedState The recorder is not active. + \value RecordingState The recorder is currently active and producing data. + \value PausedState The recorder is paused. +*/ + +/*! + \enum QMediaRecorder::Error + + \value NoError No Errors. + \value ResourceError Device is not ready or not available. + \value FormatError Current format is not supported. +*/ + +/*! + \fn QMediaRecorder::stateChanged(State state) + + Signals that a media recorder's \a state has changed. + \since 1.0 +*/ + +/*! + \fn QMediaRecorder::durationChanged(qint64 duration) + + Signals that the \a duration of the recorded media has changed. + \since 1.0 +*/ + +/*! + \fn QMediaRecorder::error(QMediaRecorder::Error error) + + Signals that an \a error has occurred. + \since 1.0 +*/ + +/*! + \fn QMediaRecorder::mutedChanged(bool muted) + + Signals that the \a muted state has changed. If true the recording is being muted. + \since 1.0 +*/ + +/*! + \property QMediaRecorder::metaDataAvailable + \brief whether access to a media object's meta-data is available. + + If this is true there is meta-data available, otherwise there is no meta-data available. + \since 1.0 +*/ + +bool QMediaRecorder::isMetaDataAvailable() const +{ + Q_D(const QMediaRecorder); + + return d->metaDataControl + ? d->metaDataControl->isMetaDataAvailable() + : false; +} + +/*! + \fn QMediaRecorder::metaDataAvailableChanged(bool available) + + Signals that the \a available state of a media object's meta-data has changed. + \since 1.0 +*/ + +/*! + \property QMediaRecorder::metaDataWritable + \brief whether a media object's meta-data is writable. + + If this is true the meta-data is writable, otherwise the meta-data is read-only. + \since 1.0 +*/ + +bool QMediaRecorder::isMetaDataWritable() const +{ + Q_D(const QMediaRecorder); + + return d->metaDataControl + ? d->metaDataControl->isWritable() + : false; +} + +/*! + \fn QMediaRecorder::metaDataWritableChanged(bool writable) + + Signals that the \a writable state of a media object's meta-data has changed. + \since 1.0 +*/ + +/*! + Returns the value associated with a meta-data \a key. + \since 1.0 +*/ +QVariant QMediaRecorder::metaData(QtMultimedia::MetaData key) const +{ + Q_D(const QMediaRecorder); + + return d->metaDataControl + ? d->metaDataControl->metaData(key) + : QVariant(); +} + +/*! + Sets a \a value for a meta-data \a key. + + \note To ensure that meta data is set corretly, it should be set before starting the recording. + Once the recording is stopped, any meta data set will be attached to the next recording. + \since 1.0 +*/ +void QMediaRecorder::setMetaData(QtMultimedia::MetaData key, const QVariant &value) +{ + Q_D(QMediaRecorder); + + if (d->metaDataControl) + d->metaDataControl->setMetaData(key, value); +} + +/*! + Returns a list of keys there is meta-data available for. + \since 1.0 +*/ +QList QMediaRecorder::availableMetaData() const +{ + Q_D(const QMediaRecorder); + + return d->metaDataControl + ? d->metaDataControl->availableMetaData() + : QList(); +} + +/*! + \fn QMediaRecorder::metaDataChanged() + + Signals that a media object's meta-data has changed. + \since 1.0 +*/ + +/*! + Returns the value associated with a meta-data \a key. + + The naming and type of extended meta-data is not standardized, so the values and meaning + of keys may vary between backends. + \since 1.0 +*/ +QVariant QMediaRecorder::extendedMetaData(const QString &key) const +{ + Q_D(const QMediaRecorder); + + return d->metaDataControl + ? d->metaDataControl->extendedMetaData(key) + : QVariant(); +} + +/*! + Sets a \a value for a meta-data \a key. + + The naming and type of extended meta-data is not standardized, so the values and meaning + of keys may vary between backends. + \since 1.0 +*/ +void QMediaRecorder::setExtendedMetaData(const QString &key, const QVariant &value) +{ + Q_D(QMediaRecorder); + + if (d->metaDataControl) + d->metaDataControl->setExtendedMetaData(key, value); +} + +/*! + Returns a list of keys there is extended meta-data available for. + \since 1.0 +*/ +QStringList QMediaRecorder::availableExtendedMetaData() const +{ + Q_D(const QMediaRecorder); + + return d->metaDataControl + ? d->metaDataControl->availableExtendedMetaData() + : QStringList(); +} + +#include "moc_qmediarecorder.cpp" +QT_END_NAMESPACE + diff --git a/src/multimedia/qmediarecorder.h b/src/multimedia/qmediarecorder.h new file mode 100644 index 000000000..fbd47ddde --- /dev/null +++ b/src/multimedia/qmediarecorder.h @@ -0,0 +1,197 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QMEDIARECORDER_H +#define QMEDIARECORDER_H + +#include +#include +#include +#include +#include + +#include + +QT_BEGIN_HEADER + +QT_BEGIN_NAMESPACE + +QT_MODULE(Multimedia) + +class QUrl; +class QSize; +class QAudioFormat; +QT_END_NAMESPACE + +QT_BEGIN_NAMESPACE + +class QMediaRecorderService; +class QAudioEncoderSettings; +class QVideoEncoderSettings; + +class QMediaRecorderPrivate; +class Q_MULTIMEDIA_EXPORT QMediaRecorder : public QObject, public QMediaBindableInterface +{ + Q_OBJECT + Q_INTERFACES(QMediaBindableInterface) + Q_ENUMS(State) + Q_ENUMS(Error) + Q_PROPERTY(qint64 duration READ duration NOTIFY durationChanged) + Q_PROPERTY(QUrl outputLocation READ outputLocation WRITE setOutputLocation) + Q_PROPERTY(bool muted READ isMuted WRITE setMuted NOTIFY mutedChanged) + Q_PROPERTY(bool metaDataAvailable READ isMetaDataAvailable NOTIFY metaDataAvailableChanged) + Q_PROPERTY(bool metaDataWritable READ isMetaDataWritable NOTIFY metaDataWritableChanged) +public: + + enum State + { + StoppedState, + RecordingState, + PausedState + }; + + enum Error + { + NoError, + ResourceError, + FormatError + }; + + QMediaRecorder(QMediaObject *mediaObject, QObject *parent = 0); + ~QMediaRecorder(); + + QMediaObject *mediaObject() const; + + bool isAvailable() const; + QtMultimedia::AvailabilityError availabilityError() const; + + QUrl outputLocation() const; + bool setOutputLocation(const QUrl &location); + + State state() const; + + Error error() const; + QString errorString() const; + + qint64 duration() const; + + bool isMuted() const; + + QStringList supportedContainers() const; + QString containerDescription(const QString &containerMimeType) const; + + QStringList supportedAudioCodecs() const; + QString audioCodecDescription(const QString &codecName) const; + + QList supportedAudioSampleRates(const QAudioEncoderSettings &settings = QAudioEncoderSettings(), + bool *continuous = 0) const; + + QStringList supportedVideoCodecs() const; + QString videoCodecDescription(const QString &codecName) const; + + QList supportedResolutions(const QVideoEncoderSettings &settings = QVideoEncoderSettings(), + bool *continuous = 0) const; + + QList supportedFrameRates(const QVideoEncoderSettings &settings = QVideoEncoderSettings(), + bool *continuous = 0) const; + + QAudioEncoderSettings audioSettings() const; + QVideoEncoderSettings videoSettings() const; + QString containerMimeType() const; + + void setEncodingSettings(const QAudioEncoderSettings &audioSettings, + const QVideoEncoderSettings &videoSettings = QVideoEncoderSettings(), + const QString &containerMimeType = QString()); + + + bool isMetaDataAvailable() const; + bool isMetaDataWritable() const; + + QVariant metaData(QtMultimedia::MetaData key) const; + void setMetaData(QtMultimedia::MetaData key, const QVariant &value); + QList availableMetaData() const; + + QVariant extendedMetaData(const QString &key) const; + void setExtendedMetaData(const QString &key, const QVariant &value); + QStringList availableExtendedMetaData() const; + +public Q_SLOTS: + void record(); + void pause(); + void stop(); + void setMuted(bool muted); + +Q_SIGNALS: + void stateChanged(QMediaRecorder::State state); + void durationChanged(qint64 duration); + void mutedChanged(bool muted); + + void error(QMediaRecorder::Error error); + + void metaDataAvailableChanged(bool available); + void metaDataWritableChanged(bool writable); + void metaDataChanged(); + +protected: + bool setMediaObject(QMediaObject *object); + +private: + QMediaRecorderPrivate *d_ptr; + Q_DISABLE_COPY(QMediaRecorder) + Q_DECLARE_PRIVATE(QMediaRecorder) + Q_PRIVATE_SLOT(d_func(), void _q_stateChanged(QMediaRecorder::State)) + Q_PRIVATE_SLOT(d_func(), void _q_error(int, const QString &)) + Q_PRIVATE_SLOT(d_func(), void _q_serviceDestroyed()) + Q_PRIVATE_SLOT(d_func(), void _q_notify()) + Q_PRIVATE_SLOT(d_func(), void _q_updateNotifyInterval(int)) +}; + +QT_END_NAMESPACE + +Q_DECLARE_METATYPE(QMediaRecorder::State) +Q_DECLARE_METATYPE(QMediaRecorder::Error) + +Q_MEDIA_ENUM_DEBUG(QMediaRecorder, State) +Q_MEDIA_ENUM_DEBUG(QMediaRecorder, Error) + +QT_END_HEADER + +#endif // QMEDIARECORDER_H diff --git a/src/multimedia/qmediarecordercontrol.cpp b/src/multimedia/qmediarecordercontrol.cpp new file mode 100644 index 000000000..ffc51021b --- /dev/null +++ b/src/multimedia/qmediarecordercontrol.cpp @@ -0,0 +1,209 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qmediarecordercontrol.h" + +QT_BEGIN_NAMESPACE + + +/*! + \class QMediaRecorderControl + \inmodule QtMultimedia + \ingroup multimedia-serv + \since 1.0 + + + \brief The QMediaRecorderControl class provides access to the recording + functionality of a QMediaService. + + If a QMediaService can record media it will implement QMediaRecorderControl. + This control provides a means to set the \l {outputLocation()}{output location}, + and \l {record()}{start}, \l {pause()}{pause} and \l {stop()}{stop} + recording. It also provides feedback on the \l {duration()}{duration} + of the recording. + + The functionality provided by this control is exposed to application + code through the QMediaRecorder class. + + The interface name of QMediaRecorderControl is \c com.nokia.Qt.QMediaRecorderControl/1.0 as + defined in QMediaRecorderControl_iid. + + \sa QMediaService::requestControl(), QMediaRecorder + +*/ + +/*! + \macro QMediaRecorderControl_iid + + \c com.nokia.Qt.QMediaRecorderControl/1.0 + + Defines the interface name of the QMediaRecorderControl class. + + \relates QMediaRecorderControl +*/ + +/*! + Constructs a media recorder control with the given \a parent. +*/ + +QMediaRecorderControl::QMediaRecorderControl(QObject* parent) + : QMediaControl(parent) +{ +} + +/*! + Destroys a media recorder control. +*/ + +QMediaRecorderControl::~QMediaRecorderControl() +{ +} + +/*! + \fn QUrl QMediaRecorderControl::outputLocation() const + + Returns the current output location being used. + \since 1.0 +*/ + +/*! + \fn bool QMediaRecorderControl::setOutputLocation(const QUrl &location) + + Sets the output \a location and returns if this operation is successful. + If file at the output location already exists, it should be overwritten. + + The \a location can be relative or empty; + in this case the service should use the system specific place and file naming scheme. + After recording has stated, QMediaRecorderControl::outputLocation() should return the actual output location. + \since 1.0 +*/ + +/*! + \fn int QMediaRecorderControl::state() const + + Return the current recording state. + \since 1.0 +*/ + +/*! + \fn qint64 QMediaRecorderControl::duration() const + + Return the current duration in milliseconds. + \since 1.0 +*/ + +/*! + \fn void QMediaRecorderControl::record() + + Start recording. + \since 1.0 +*/ + +/*! + \fn void QMediaRecorderControl::pause() + + Pause recording. + \since 1.0 +*/ + +/*! + \fn void QMediaRecorderControl::stop() + + Stop recording. + \since 1.0 +*/ + +/*! + \fn void QMediaRecorderControl::applySettings() + + Commits the encoder settings and performs pre-initialization to reduce delays when recording + is started. + \since 1.0 +*/ + +/*! + \fn bool QMediaRecorderControl::isMuted() const + + Returns true if the recorder is muted, and false if it is not. + \since 1.0 +*/ + +/*! + \fn void QMediaRecorderControl::setMuted(bool muted) + + Sets the \a muted state of a media recorder. + \since 1.0 +*/ + + +/*! + \fn void QMediaRecorderControl::stateChanged(QMediaRecorder::State state) + + Signals that the \a state of a media recorder has changed. + \since 1.0 +*/ + +/*! + \fn void QMediaRecorderControl::durationChanged(qint64 duration) + + Signals that the \a duration of the recorded media has changed. + + This only emitted when there is a discontinuous change in the duration such as being reset to 0. + \since 1.0 +*/ + +/*! + \fn void QMediaRecorderControl::mutedChanged(bool muted) + + Signals that the \a muted state of a media recorder has changed. + \since 1.0 +*/ + +/*! + \fn void QMediaRecorderControl::error(int error, const QString &errorString) + + Signals that an \a error has occurred. The \a errorString describes the error. + \since 1.0 +*/ + +#include "moc_qmediarecordercontrol.cpp" +QT_END_NAMESPACE + diff --git a/src/multimedia/qmediarecordercontrol.h b/src/multimedia/qmediarecordercontrol.h new file mode 100644 index 000000000..26f244c08 --- /dev/null +++ b/src/multimedia/qmediarecordercontrol.h @@ -0,0 +1,101 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QMEDIARECORDERCONTROL_H +#define QMEDIARECORDERCONTROL_H + +#include "qmediacontrol.h" +#include "qmediarecorder.h" + +QT_BEGIN_HEADER + +QT_BEGIN_NAMESPACE + +QT_MODULE(Multimedia) + +class QUrl; +QT_END_NAMESPACE + +QT_BEGIN_NAMESPACE + +class Q_MULTIMEDIA_EXPORT QMediaRecorderControl : public QMediaControl +{ + Q_OBJECT + +public: + virtual ~QMediaRecorderControl(); + + virtual QUrl outputLocation() const = 0; + virtual bool setOutputLocation(const QUrl &location) = 0; + + virtual QMediaRecorder::State state() const = 0; + + virtual qint64 duration() const = 0; + + virtual bool isMuted() const = 0; + + virtual void applySettings() = 0; + +Q_SIGNALS: + void stateChanged(QMediaRecorder::State state); + void durationChanged(qint64 position); + void mutedChanged(bool muted); + void error(int error, const QString &errorString); + +public Q_SLOTS: + virtual void record() = 0; + virtual void pause() = 0; + virtual void stop() = 0; + virtual void setMuted(bool muted) = 0; + +protected: + QMediaRecorderControl(QObject* parent = 0); +}; + +#define QMediaRecorderControl_iid "com.nokia.Qt.QMediaRecorderControl/1.0" +Q_MEDIA_DECLARE_CONTROL(QMediaRecorderControl, QMediaRecorderControl_iid) + +QT_END_NAMESPACE + +QT_END_HEADER + + +#endif diff --git a/src/multimedia/qmediaresource.cpp b/src/multimedia/qmediaresource.cpp new file mode 100644 index 000000000..a80168830 --- /dev/null +++ b/src/multimedia/qmediaresource.cpp @@ -0,0 +1,440 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qmediaresource.h" + +#include +#include +#include + +QT_BEGIN_NAMESPACE + +/*! + \class QMediaResource + + \brief The QMediaResource class provides a description of a media resource. + \inmodule QtMultimedia + \ingroup multimedia + \since 1.0 + + A media resource is composed of a \l {url()}{URL} containing the + location of the resource and a set of properties that describe the + format of the resource. The properties provide a means to assess a + resource without first attempting to load it, and in situations where + media be represented by multiple alternative representations provide a + means to select the appropriate resource. + + Media made available by a remote services can often be available in + multiple encodings or quality levels, this allows a client to select + an appropriate resource based on considerations such as codecs supported, + network bandwidth, and display constraints. QMediaResource includes + information such as the \l {mimeType()}{MIME type}, \l {audioCodec()}{audio} + and \l {videoCodec()}{video} codecs, \l {audioBitRate()}{audio} and + \l {videoBitRate()}{video} bit rates, and \l {resolution()}{resolution} + so these constraints and others can be evaluated. + + The only mandatory property of a QMediaResource is the url(). + + \sa QMediaContent +*/ + +/*! + \typedef QMediaResourceList + + Synonym for \c QList +*/ + +/*! + Constructs a null media resource. +*/ +QMediaResource::QMediaResource() +{ +} + +/*! + Constructs a media resource with the given \a mimeType from a \a url. + \since 1.0 +*/ +QMediaResource::QMediaResource(const QUrl &url, const QString &mimeType) +{ + values.insert(Url, url); + values.insert(MimeType, mimeType); +} + +/*! + Constructs a media resource with the given \a mimeType from a network \a request. + \since 1.0 +*/ +QMediaResource::QMediaResource(const QNetworkRequest &request, const QString &mimeType) +{ + values.insert(Request, QVariant::fromValue(request)); + values.insert(Url, request.url()); + values.insert(MimeType, mimeType); +} + +/*! + Constructs a copy of a media resource \a other. + \since 1.0 +*/ +QMediaResource::QMediaResource(const QMediaResource &other) + : values(other.values) +{ +} + +/*! + Assigns the value of \a other to a media resource. + \since 1.0 +*/ +QMediaResource &QMediaResource::operator =(const QMediaResource &other) +{ + values = other.values; + + return *this; +} + +/*! + Destroys a media resource. +*/ +QMediaResource::~QMediaResource() +{ +} + + +/*! + Compares a media resource to \a other. + + Returns true if the resources are identical, and false otherwise. + \since 1.0 +*/ +bool QMediaResource::operator ==(const QMediaResource &other) const +{ + // Compare requests directly as QNetworkRequests are "custom types". + foreach (int key, values.keys()) { + switch (key) { + case Request: + if (request() != other.request()) + return false; + break; + default: + if (values.value(key) != other.values.value(key)) + return false; + } + } + return true; +} + +/*! + Compares a media resource to \a other. + + Returns true if they are different, and false otherwise. + \since 1.0 +*/ +bool QMediaResource::operator !=(const QMediaResource &other) const +{ + return !(*this == other); +} + +/*! + Identifies if a media resource is null. + + Returns true if the resource is null, and false otherwise. + \since 1.0 +*/ +bool QMediaResource::isNull() const +{ + return values.isEmpty(); +} + +/*! + Returns the URL of a media resource. + \since 1.0 +*/ +QUrl QMediaResource::url() const +{ + return qvariant_cast(values.value(Url)); +} + +/*! + Returns the network request associated with this media resource. + \since 1.0 +*/ +QNetworkRequest QMediaResource::request() const +{ + if(values.contains(Request)) + return qvariant_cast(values.value(Request)); + + return QNetworkRequest(url()); +} + +/*! + Returns the MIME type of a media resource. + + This may be null if the MIME type is unknown. + \since 1.0 +*/ +QString QMediaResource::mimeType() const +{ + return qvariant_cast(values.value(MimeType)); +} + +/*! + Returns the language of a media resource as an ISO 639-2 code. + + This may be null if the language is unknown. + \since 1.0 +*/ +QString QMediaResource::language() const +{ + return qvariant_cast(values.value(Language)); +} + +/*! + Sets the \a language of a media resource. + \since 1.0 +*/ +void QMediaResource::setLanguage(const QString &language) +{ + if (!language.isNull()) + values.insert(Language, language); + else + values.remove(Language); +} + +/*! + Returns the audio codec of a media resource. + + This may be null if the media resource does not contain an audio stream, or the codec is + unknown. + \since 1.0 +*/ +QString QMediaResource::audioCodec() const +{ + return qvariant_cast(values.value(AudioCodec)); +} + +/*! + Sets the audio \a codec of a media resource. + \since 1.0 +*/ +void QMediaResource::setAudioCodec(const QString &codec) +{ + if (!codec.isNull()) + values.insert(AudioCodec, codec); + else + values.remove(AudioCodec); +} + +/*! + Returns the video codec of a media resource. + + This may be null if the media resource does not contain a video stream, or the codec is + unknonwn. + \since 1.0 +*/ +QString QMediaResource::videoCodec() const +{ + return qvariant_cast(values.value(VideoCodec)); +} + +/*! + Sets the video \a codec of media resource. + \since 1.0 +*/ +void QMediaResource::setVideoCodec(const QString &codec) +{ + if (!codec.isNull()) + values.insert(VideoCodec, codec); + else + values.remove(VideoCodec); +} + +/*! + Returns the size in bytes of a media resource. + + This may be zero if the size is unknown. + \since 1.0 +*/ +qint64 QMediaResource::dataSize() const +{ + return qvariant_cast(values.value(DataSize)); +} + +/*! + Sets the \a size in bytes of a media resource. + \since 1.0 +*/ +void QMediaResource::setDataSize(const qint64 size) +{ + if (size != 0) + values.insert(DataSize, size); + else + values.remove(DataSize); +} + +/*! + Returns the bit rate in bits per second of a media resource's audio stream. + + This may be zero if the bit rate is unknown, or the resource contains no audio stream. + \since 1.0 +*/ +int QMediaResource::audioBitRate() const +{ + return values.value(AudioBitRate).toInt(); +} + +/*! + Sets the bit \a rate in bits per second of a media resource's video stream. + \since 1.0 +*/ +void QMediaResource::setAudioBitRate(int rate) +{ + if (rate != 0) + values.insert(AudioBitRate, rate); + else + values.remove(AudioBitRate); +} + +/*! + Returns the audio sample rate of a media resource. + + This may be zero if the sample size is unknown, or the resource contains no audio stream. + \since 1.0 +*/ +int QMediaResource::sampleRate() const +{ + return qvariant_cast(values.value(SampleRate)); +} + +/*! + Sets the audio \a sampleRate of a media resource. + \since 1.0 +*/ +void QMediaResource::setSampleRate(int sampleRate) +{ + if (sampleRate != 0) + values.insert(SampleRate, sampleRate); + else + values.remove(SampleRate); +} + +/*! + Returns the number of audio channels in a media resource. + + This may be zero if the sample size is unknown, or the resource contains no audio stream. + \since 1.0 +*/ +int QMediaResource::channelCount() const +{ + return qvariant_cast(values.value(ChannelCount)); +} + +/*! + Sets the number of audio \a channels in a media resource. + \since 1.0 +*/ +void QMediaResource::setChannelCount(int channels) +{ + if (channels != 0) + values.insert(ChannelCount, channels); + else + values.remove(ChannelCount); +} + +/*! + Returns the bit rate in bits per second of a media resource's video stream. + + This may be zero if the bit rate is unknown, or the resource contains no video stream. + \since 1.0 +*/ +int QMediaResource::videoBitRate() const +{ + return values.value(VideoBitRate).toInt(); +} + +/*! + Sets the bit \a rate in bits per second of a media resource's video stream. + \since 1.0 +*/ +void QMediaResource::setVideoBitRate(int rate) +{ + if (rate != 0) + values.insert(VideoBitRate, rate); + else + values.remove(VideoBitRate); +} + +/*! + Returns the resolution in pixels of a media resource. + + This may be null is the resolution is unknown, or the resource contains no pixel data (i.e. the + resource is an audio stream. + \since 1.0 +*/ +QSize QMediaResource::resolution() const +{ + return qvariant_cast(values.value(Resolution)); +} + +/*! + Sets the \a resolution in pixels of a media resource. + \since 1.0 +*/ +void QMediaResource::setResolution(const QSize &resolution) +{ + if (resolution.width() != -1 || resolution.height() != -1) + values.insert(Resolution, resolution); + else + values.remove(Resolution); +} + +/*! + Sets the \a width and \a height in pixels of a media resource. + \since 1.0 +*/ +void QMediaResource::setResolution(int width, int height) +{ + if (width != -1 || height != -1) + values.insert(Resolution, QSize(width, height)); + else + values.remove(Resolution); +} +QT_END_NAMESPACE + diff --git a/src/multimedia/qmediaresource.h b/src/multimedia/qmediaresource.h new file mode 100644 index 000000000..b06c61dcb --- /dev/null +++ b/src/multimedia/qmediaresource.h @@ -0,0 +1,134 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QMEDIARESOURCE_H +#define QMEDIARESOURCE_H + +#include +#include +#include + +#include + +QT_BEGIN_HEADER + +QT_BEGIN_NAMESPACE + +QT_MODULE(Multimedia) + + +class Q_MULTIMEDIA_EXPORT QMediaResource +{ +public: + QMediaResource(); + QMediaResource(const QUrl &url, const QString &mimeType = QString()); + QMediaResource(const QNetworkRequest &request, const QString &mimeType = QString()); + QMediaResource(const QMediaResource &other); + QMediaResource &operator =(const QMediaResource &other); + ~QMediaResource(); + + bool isNull() const; + + bool operator ==(const QMediaResource &other) const; + bool operator !=(const QMediaResource &other) const; + + QUrl url() const; + QNetworkRequest request() const; + QString mimeType() const; + + QString language() const; + void setLanguage(const QString &language); + + QString audioCodec() const; + void setAudioCodec(const QString &codec); + + QString videoCodec() const; + void setVideoCodec(const QString &codec); + + qint64 dataSize() const; + void setDataSize(const qint64 size); + + int audioBitRate() const; + void setAudioBitRate(int rate); + + int sampleRate() const; + void setSampleRate(int frequency); + + int channelCount() const; + void setChannelCount(int channels); + + int videoBitRate() const; + void setVideoBitRate(int rate); + + QSize resolution() const; + void setResolution(const QSize &resolution); + void setResolution(int width, int height); + + +private: + enum Property + { + Url, + Request, + MimeType, + Language, + AudioCodec, + VideoCodec, + DataSize, + AudioBitRate, + VideoBitRate, + SampleRate, + ChannelCount, + Resolution + }; + QMap values; +}; + +typedef QList QMediaResourceList; + +QT_END_NAMESPACE + +Q_DECLARE_METATYPE(QMediaResource) +Q_DECLARE_METATYPE(QMediaResourceList) + +QT_END_HEADER + +#endif diff --git a/src/multimedia/qmediaservice.cpp b/src/multimedia/qmediaservice.cpp new file mode 100644 index 000000000..d97b3613c --- /dev/null +++ b/src/multimedia/qmediaservice.cpp @@ -0,0 +1,151 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qmediaservice.h" +#include "qmediaservice_p.h" + +#include + + + +QT_BEGIN_NAMESPACE + + +/*! + \class QMediaService + \brief The QMediaService class provides a common base class for media + service implementations. + \inmodule QtMultimedia + \ingroup multimedia-serv + \since 1.0 + + + Media services provide implementations of the functionality promised + by media objects, and allow multiple providers to implement a QMediaObject. + + To provide the functionality of a QMediaObject media services implement + QMediaControl interfaces. Services typically implement one core media + control which provides the core feature of a media object, and some + number of additional controls which provide either optional features of + the media object, or features of a secondary media object or peripheral + object. + + A pointer to media service's QMediaControl implementation can be obtained + by passing the control's interface name to the requestControl() function. + + \snippet doc/src/snippets/multimedia-snippets/media.cpp Request control + + Media objects can use services loaded dynamically from plug-ins or + implemented statically within an applications. Plug-in based services + should also implement the QMediaServiceProviderPlugin interface. Static + services should implement the QMediaServiceProvider interface. + + \sa QMediaObject, QMediaControl, QMediaServiceProvider, QMediaServiceProviderPlugin +*/ + +/*! + Construct a media service with the given \a parent. This class is meant as a + base class for Multimedia services so this constructor is protected. +*/ + +QMediaService::QMediaService(QObject *parent) + : QObject(parent) + , d_ptr(new QMediaServicePrivate) +{ + d_ptr->q_ptr = this; +} + +/*! + \internal +*/ +QMediaService::QMediaService(QMediaServicePrivate &dd, QObject *parent) + : QObject(parent) + , d_ptr(&dd) +{ + d_ptr->q_ptr = this; +} + +/*! + Destroys a media service. +*/ + +QMediaService::~QMediaService() +{ + delete d_ptr; +} + +/*! + \fn QMediaControl* QMediaService::requestControl(const char *interface) + + Returns a pointer to the media control implementing \a interface. + + If the service does not implement the control, or if it is unavailable a + null pointer is returned instead. + + Controls must be returned to the service when no longer needed using the + releaseControl() function. + \since 1.0 +*/ + +/*! + \fn T QMediaService::requestControl() + + Returns a pointer to the media control of type T implemented by a media service. + + If the service does not implement the control, or if it is unavailable a + null pointer is returned instead. + + Controls must be returned to the service when no longer needed using the + releaseControl() function. + \since 1.0 +*/ + +/*! + \fn void QMediaService::releaseControl(QMediaControl *control); + + Releases a \a control back to the service. + \since 1.0 +*/ + +#include "moc_qmediaservice.cpp" + +QT_END_NAMESPACE + diff --git a/src/multimedia/qmediaservice.h b/src/multimedia/qmediaservice.h new file mode 100644 index 000000000..64aa7099f --- /dev/null +++ b/src/multimedia/qmediaservice.h @@ -0,0 +1,97 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QABSTRACTMEDIASERVICE_H +#define QABSTRACTMEDIASERVICE_H + +#include +#include +#include + +#include "qmediacontrol.h" + +QT_BEGIN_HEADER + +QT_BEGIN_NAMESPACE + +QT_MODULE(Multimedia) + + +class QMediaServicePrivate; +class Q_MULTIMEDIA_EXPORT QMediaService : public QObject +{ + Q_OBJECT + +public: + ~QMediaService(); + + virtual QMediaControl* requestControl(const char *name) = 0; + +#ifndef QT_NO_MEMBER_TEMPLATES + template inline T requestControl() { + if (QMediaControl *control = requestControl(qmediacontrol_iid())) { + if (T typedControl = qobject_cast(control)) + return typedControl; + releaseControl(control); + } + return 0; + } +#endif + + virtual void releaseControl(QMediaControl *control) = 0; + +protected: + QMediaService(QObject* parent); + QMediaService(QMediaServicePrivate &dd, QObject *parent); + + QMediaServicePrivate *d_ptr; + +private: + Q_DECLARE_PRIVATE(QMediaService) +}; + +QT_END_NAMESPACE + +QT_END_HEADER + + +#endif // QABSTRACTMEDIASERVICE_H + diff --git a/src/multimedia/qmediaservice_p.h b/src/multimedia/qmediaservice_p.h new file mode 100644 index 000000000..83fd7287f --- /dev/null +++ b/src/multimedia/qmediaservice_p.h @@ -0,0 +1,80 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QABSTRACTMEDIASERVICE_P_H +#define QABSTRACTMEDIASERVICE_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. +// + +QT_BEGIN_HEADER + +QT_BEGIN_NAMESPACE + +QT_MODULE(Multimedia) + + +class QAudioDeviceControl; + +class QMediaServicePrivate +{ +public: + QMediaServicePrivate(): q_ptr(0) {} + virtual ~QMediaServicePrivate() {} + + QMediaService *q_ptr; +}; + +QT_END_NAMESPACE + +QT_END_HEADER + + + +#endif diff --git a/src/multimedia/qmediaserviceprovider.cpp b/src/multimedia/qmediaserviceprovider.cpp new file mode 100644 index 000000000..0017349c4 --- /dev/null +++ b/src/multimedia/qmediaserviceprovider.cpp @@ -0,0 +1,783 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include +#include + +#include "qmediaservice.h" +#include "qmediaserviceprovider.h" +#include "qmediaserviceproviderplugin.h" +#include "qmediapluginloader_p.h" +#include "qmediaplayer.h" + +QT_BEGIN_NAMESPACE + +class QMediaServiceProviderHintPrivate : public QSharedData +{ +public: + QMediaServiceProviderHintPrivate(QMediaServiceProviderHint::Type type) + :type(type), features(0) + { + } + + QMediaServiceProviderHintPrivate(const QMediaServiceProviderHintPrivate &other) + :QSharedData(other), + type(other.type), + device(other.device), + mimeType(other.mimeType), + codecs(other.codecs), + features(other.features) + { + } + + ~QMediaServiceProviderHintPrivate() + { + } + + QMediaServiceProviderHint::Type type; + QByteArray device; + QString mimeType; + QStringList codecs; + QMediaServiceProviderHint::Features features; +}; + +/*! + \class QMediaServiceProviderHint + + \brief The QMediaServiceProviderHint class describes what is required of a QMediaService. + + \inmodule QtMultimedia + \ingroup multimedia-serv + \since 1.0 + + The QMediaServiceProvider class uses hints to select an appropriate media service. +*/ + +/*! + \enum QMediaServiceProviderHint::Feature + + Enumerates features a media service may provide. + + \value LowLatencyPlayback + The service is expected to play simple audio formats, + but playback should start without significant delay. + Such playback service can be used for beeps, ringtones, etc. + + \value RecordingSupport + The service provides audio or video recording functions. + + \value StreamPlayback + The service is capable of playing QIODevice based streams. + + \value VideoSurface + The service is capable of renderering to a QAbstractVideoSurface + output. + + \value BackgroundPlayback + The service is capable of doing playback in the background +*/ + +/*! + \enum QMediaServiceProviderHint::Type + + Enumerates the possible types of media service provider hint. + + \value Null En empty hint, use the default service. + \value ContentType Select media service most suitable for certain content type. + \value Device Select media service which supports certain device. + \value SupportedFeatures Select media service supporting the set of optional features. +*/ + + +/*! + Constructs an empty media service provider hint. +*/ +QMediaServiceProviderHint::QMediaServiceProviderHint() + :d(new QMediaServiceProviderHintPrivate(Null)) +{ +} + +/*! + Constructs a ContentType media service provider hint. + + This type of hint describes a service that is able to play content of a specific MIME \a type + encoded with one or more of the listed \a codecs. + \since 1.0 +*/ +QMediaServiceProviderHint::QMediaServiceProviderHint(const QString &type, const QStringList& codecs) + :d(new QMediaServiceProviderHintPrivate(ContentType)) +{ + d->mimeType = type; + d->codecs = codecs; +} + +/*! + Constructs a Device media service provider hint. + + This type of hint describes a media service that utilizes a specific \a device. + \since 1.0 +*/ +QMediaServiceProviderHint::QMediaServiceProviderHint(const QByteArray &device) + :d(new QMediaServiceProviderHintPrivate(Device)) +{ + d->device = device; +} + +/*! + Constructs a SupportedFeatures media service provider hint. + + This type of hint describes a service which supports a specific set of \a features. + \since 1.0 +*/ +QMediaServiceProviderHint::QMediaServiceProviderHint(QMediaServiceProviderHint::Features features) + :d(new QMediaServiceProviderHintPrivate(SupportedFeatures)) +{ + d->features = features; +} + +/*! + Constructs a copy of the media service provider hint \a other. + \since 1.0 +*/ +QMediaServiceProviderHint::QMediaServiceProviderHint(const QMediaServiceProviderHint &other) + :d(other.d) +{ +} + +/*! + Destroys a media service provider hint. +*/ +QMediaServiceProviderHint::~QMediaServiceProviderHint() +{ +} + +/*! + Assigns the value \a other to a media service provider hint. + \since 1.0 +*/ +QMediaServiceProviderHint& QMediaServiceProviderHint::operator=(const QMediaServiceProviderHint &other) +{ + d = other.d; + return *this; +} + +/*! + Identifies if \a other is of equal value to a media service provider hint. + + Returns true if the hints are equal, and false if they are not. + \since 1.0 +*/ +bool QMediaServiceProviderHint::operator == (const QMediaServiceProviderHint &other) const +{ + return (d == other.d) || + (d->type == other.d->type && + d->device == other.d->device && + d->mimeType == other.d->mimeType && + d->codecs == other.d->codecs && + d->features == other.d->features); +} + +/*! + Identifies if \a other is not of equal value to a media service provider hint. + + Returns true if the hints are not equal, and false if they are. + \since 1.0 +*/ +bool QMediaServiceProviderHint::operator != (const QMediaServiceProviderHint &other) const +{ + return !(*this == other); +} + +/*! + Returns true if a media service provider is null. + \since 1.0 +*/ +bool QMediaServiceProviderHint::isNull() const +{ + return d->type == Null; +} + +/*! + Returns the type of a media service provider hint. + \since 1.0 +*/ +QMediaServiceProviderHint::Type QMediaServiceProviderHint::type() const +{ + return d->type; +} + +/*! + Returns the mime type of the media a service is expected to be able play. + \since 1.0 +*/ +QString QMediaServiceProviderHint::mimeType() const +{ + return d->mimeType; +} + +/*! + Returns a list of codes a media service is expected to be able to decode. + \since 1.0 +*/ +QStringList QMediaServiceProviderHint::codecs() const +{ + return d->codecs; +} + +/*! + Returns the name of a device a media service is expected to utilize. + \since 1.0 +*/ +QByteArray QMediaServiceProviderHint::device() const +{ + return d->device; +} + +/*! + Returns a set of features a media service is expected to provide. + \since 1.0 +*/ +QMediaServiceProviderHint::Features QMediaServiceProviderHint::features() const +{ + return d->features; +} + + +Q_GLOBAL_STATIC_WITH_ARGS(QMediaPluginLoader, loader, + (QMediaServiceProviderFactoryInterface_iid, QLatin1String("mediaservice"), Qt::CaseInsensitive)) + + +class QPluginServiceProvider : public QMediaServiceProvider +{ + QMap pluginMap; + +public: + QMediaService* requestService(const QByteArray &type, const QMediaServiceProviderHint &hint) + { + QString key(QLatin1String(type.constData())); + + QListplugins; + foreach (QObject *obj, loader()->instances(key)) { + QMediaServiceProviderPlugin *plugin = + qobject_cast(obj); + if (plugin) + plugins << plugin; + } + + if (!plugins.isEmpty()) { + QMediaServiceProviderPlugin *plugin = 0; + + switch (hint.type()) { + case QMediaServiceProviderHint::Null: + plugin = plugins[0]; + //special case for media player, if low latency was not asked, + //prefer services not offering it, since they are likely to support + //more formats + if (type == QByteArray(Q_MEDIASERVICE_MEDIAPLAYER)) { + foreach (QMediaServiceProviderPlugin *currentPlugin, plugins) { + QMediaServiceFeaturesInterface *iface = + qobject_cast(currentPlugin); + + if (!iface || !(iface->supportedFeatures(type) & + QMediaServiceProviderHint::LowLatencyPlayback)) { + plugin = currentPlugin; + break; + } + + } + } + break; + case QMediaServiceProviderHint::SupportedFeatures: + plugin = plugins[0]; + foreach (QMediaServiceProviderPlugin *currentPlugin, plugins) { + QMediaServiceFeaturesInterface *iface = + qobject_cast(currentPlugin); + + if (iface) { + if ((iface->supportedFeatures(type) & hint.features()) == hint.features()) { + plugin = currentPlugin; + break; + } + } + } + break; + case QMediaServiceProviderHint::Device: { + foreach (QMediaServiceProviderPlugin *currentPlugin, plugins) { + QMediaServiceSupportedDevicesInterface *iface = + qobject_cast(currentPlugin); + + if (!iface) { + // the plugin may support the device, + // but this choice still can be overridden + plugin = currentPlugin; + } else { + if (iface->devices(type).contains(hint.device())) { + plugin = currentPlugin; + break; + } + } + } + } + break; + case QMediaServiceProviderHint::ContentType: { + QtMultimedia::SupportEstimate estimate = QtMultimedia::NotSupported; + foreach (QMediaServiceProviderPlugin *currentPlugin, plugins) { + QtMultimedia::SupportEstimate currentEstimate = QtMultimedia::MaybeSupported; + QMediaServiceSupportedFormatsInterface *iface = + qobject_cast(currentPlugin); + + if (iface) + currentEstimate = iface->hasSupport(hint.mimeType(), hint.codecs()); + + if (currentEstimate > estimate) { + estimate = currentEstimate; + plugin = currentPlugin; + + if (currentEstimate == QtMultimedia::PreferredService) + break; + } + } + } + break; + } + + if (plugin != 0) { + QMediaService *service = plugin->create(key); + if (service != 0) + pluginMap.insert(service, plugin); + + return service; + } + } + + qWarning() << "defaultServiceProvider::requestService(): no service found for -" << key; + return 0; + } + + void releaseService(QMediaService *service) + { + if (service != 0) { + QMediaServiceProviderPlugin *plugin = pluginMap.take(service); + + if (plugin != 0) + plugin->release(service); + } + } + + QtMultimedia::SupportEstimate hasSupport(const QByteArray &serviceType, + const QString &mimeType, + const QStringList& codecs, + int flags) const + { + QList instances = loader()->instances(QLatin1String(serviceType)); + + if (instances.isEmpty()) + return QtMultimedia::NotSupported; + + bool allServicesProvideInterface = true; + QtMultimedia::SupportEstimate supportEstimate = QtMultimedia::NotSupported; + + foreach(QObject *obj, instances) { + QMediaServiceSupportedFormatsInterface *iface = + qobject_cast(obj); + + + if (flags) { + QMediaServiceFeaturesInterface *iface = + qobject_cast(obj); + + if (iface) { + QMediaServiceProviderHint::Features features = iface->supportedFeatures(serviceType); + + //if low latency playback was asked, skip services known + //not to provide low latency playback + if ((flags & QMediaPlayer::LowLatency) && + !(features & QMediaServiceProviderHint::LowLatencyPlayback)) + continue; + + //the same for QIODevice based streams support + if ((flags & QMediaPlayer::StreamPlayback) && + !(features & QMediaServiceProviderHint::StreamPlayback)) + continue; + } + } + + if (iface) + supportEstimate = qMax(supportEstimate, iface->hasSupport(mimeType, codecs)); + else + allServicesProvideInterface = false; + } + + //don't return PreferredService + supportEstimate = qMin(supportEstimate, QtMultimedia::ProbablySupported); + + //Return NotSupported only if no services are available of serviceType + //or all the services returned NotSupported, otherwise return at least MaybeSupported + if (!allServicesProvideInterface) + supportEstimate = qMax(QtMultimedia::MaybeSupported, supportEstimate); + + return supportEstimate; + } + + QStringList supportedMimeTypes(const QByteArray &serviceType, int flags) const + { + QList instances = loader()->instances(QLatin1String(serviceType)); + + QStringList supportedTypes; + + foreach(QObject *obj, instances) { + QMediaServiceSupportedFormatsInterface *iface = + qobject_cast(obj); + + + if (flags) { + QMediaServiceFeaturesInterface *iface = + qobject_cast(obj); + + if (iface) { + QMediaServiceProviderHint::Features features = iface->supportedFeatures(serviceType); + + // If low latency playback was asked for, skip MIME types from services known + // not to provide low latency playback + if ((flags & QMediaPlayer::LowLatency) && + !(features & QMediaServiceProviderHint::LowLatencyPlayback)) + continue; + + //the same for QIODevice based streams support + if ((flags & QMediaPlayer::StreamPlayback) && + !(features & QMediaServiceProviderHint::StreamPlayback)) + continue; + + //the same for QAbstractVideoSurface support + if ((flags & QMediaPlayer::VideoSurface) && + !(features & QMediaServiceProviderHint::VideoSurface)) + continue; + } + } + + if (iface) { + supportedTypes << iface->supportedMimeTypes(); + } + } + + // Multiple services may support the same MIME type + supportedTypes.removeDuplicates(); + + return supportedTypes; + } + + QList devices(const QByteArray &serviceType) const + { + QList res; + + foreach (QObject *obj, loader()->instances(QLatin1String(serviceType))) { + QMediaServiceSupportedDevicesInterface *iface = + qobject_cast(obj); + + if (iface) { + res.append(iface->devices(serviceType)); + } + } + + return res; + } + + QString deviceDescription(const QByteArray &serviceType, const QByteArray &device) + { + foreach (QObject *obj, loader()->instances(QLatin1String(serviceType))) { + QMediaServiceSupportedDevicesInterface *iface = + qobject_cast(obj); + + if (iface) { + if (iface->devices(serviceType).contains(device)) + return iface->deviceDescription(serviceType, device); + } + } + + return QString(); + } +}; + +Q_GLOBAL_STATIC(QPluginServiceProvider, pluginProvider); + +/*! + \class QMediaServiceProvider + + \brief The QMediaServiceProvider class provides an abstract allocator for media services. + \since 1.0 +*/ + +/*! + \fn QMediaServiceProvider::requestService(const QByteArray &type, const QMediaServiceProviderHint &hint) + + Requests an instance of a \a type service which best matches the given \a + hint. + + Returns a pointer to the requested service, or a null pointer if there is + no suitable service. + + The returned service must be released with releaseService when it is + finished with. + \since 1.0 +*/ + +/*! + \fn QMediaServiceProvider::releaseService(QMediaService *service) + + Releases a media \a service requested with requestService(). + \since 1.0 +*/ + +/*! + \fn QtMultimedia::SupportEstimate QMediaServiceProvider::hasSupport(const QByteArray &serviceType, const QString &mimeType, const QStringList& codecs, int flags) const + + Returns how confident a media service provider is that is can provide a \a + serviceType service that is able to play media of a specific \a mimeType + that is encoded using the listed \a codecs while adhering to constraints + identified in \a flags. + \since 1.0 +*/ +QtMultimedia::SupportEstimate QMediaServiceProvider::hasSupport(const QByteArray &serviceType, + const QString &mimeType, + const QStringList& codecs, + int flags) const +{ + Q_UNUSED(serviceType); + Q_UNUSED(mimeType); + Q_UNUSED(codecs); + Q_UNUSED(flags); + + return QtMultimedia::MaybeSupported; +} + +/*! + \fn QStringList QMediaServiceProvider::supportedMimeTypes(const QByteArray &serviceType, int flags) const + + Returns a list of MIME types supported by the service provider for the + specified \a serviceType. + + The resultant list is restricted to MIME types which can be supported given + the constraints in \a flags. + \since 1.0 +*/ +QStringList QMediaServiceProvider::supportedMimeTypes(const QByteArray &serviceType, int flags) const +{ + Q_UNUSED(serviceType); + Q_UNUSED(flags); + + return QStringList(); +} + +/*! + Returns the list of devices related to \a service type. + \since 1.0 +*/ +QList QMediaServiceProvider::devices(const QByteArray &service) const +{ + Q_UNUSED(service); + return QList(); +} + +/*! + Returns the description of \a device related to \a serviceType, suitable for use by + an application for display. + \since 1.0 +*/ +QString QMediaServiceProvider::deviceDescription(const QByteArray &serviceType, const QByteArray &device) +{ + Q_UNUSED(serviceType); + Q_UNUSED(device); + return QString(); +} + + +#ifdef QT_BUILD_INTERNAL + +static QMediaServiceProvider *qt_defaultMediaServiceProvider = 0; + +/*! + Sets a media service \a provider as the default. + + \internal + \since 1.0 +*/ +void QMediaServiceProvider::setDefaultServiceProvider(QMediaServiceProvider *provider) +{ + qt_defaultMediaServiceProvider = provider; +} + +#endif + +/*! + Returns a default provider of media services. +*/ +QMediaServiceProvider *QMediaServiceProvider::defaultServiceProvider() +{ +#ifdef QT_BUILD_INTERNAL + return qt_defaultMediaServiceProvider != 0 + ? qt_defaultMediaServiceProvider + : static_cast(pluginProvider()); +#else + return pluginProvider(); +#endif +} + +/*! + \class QMediaServiceProviderPlugin + + \brief The QMediaServiceProviderPlugin class interface provides an interface for QMediaService + plug-ins. + \since 1.0 + + A media service provider plug-in may implement one or more of + QMediaServiceSupportedFormatsInterface, + QMediaServiceSupportedDevicesInterface, and QMediaServiceFeaturesInterface + to identify the features it supports. +*/ + +/*! + \fn QMediaServiceProviderPlugin::keys() const + + Returns a list of keys for media services a plug-in can create. + \since 1.0 +*/ + +/*! + \fn QMediaServiceProviderPlugin::create(const QString &key) + + Constructs a new instance of the QMediaService identified by \a key. + + The QMediaService returned must be destroyed with release(). + \since 1.0 +*/ + +/*! + \fn QMediaServiceProviderPlugin::release(QMediaService *service) + + Destroys a media \a service constructed with create(). + \since 1.0 +*/ + + +/*! + \class QMediaServiceSupportedFormatsInterface + \brief The QMediaServiceSupportedFormatsInterface class interface + identifies if a media service plug-in supports a media format. + \since 1.0 + + A QMediaServiceProviderPlugin may implement this interface. +*/ + +/*! + \fn QMediaServiceSupportedFormatsInterface::~QMediaServiceSupportedFormatsInterface() + + Destroys a media service supported formats interface. +*/ + +/*! + \fn QMediaServiceSupportedFormatsInterface::hasSupport(const QString &mimeType, const QStringList& codecs) const + + Returns the level of support a media service plug-in has for a \a mimeType + and set of \a codecs. + \since 1.0 +*/ + +/*! + \fn QMediaServiceSupportedFormatsInterface::supportedMimeTypes() const + + Returns a list of MIME types supported by the media service plug-in. + \since 1.0 +*/ + +/*! + \class QMediaServiceSupportedDevicesInterface + \brief The QMediaServiceSupportedDevicesInterface class interface + identifies the devices supported by a media service plug-in. + \since 1.0 + + A QMediaServiceProviderPlugin may implement this interface. +*/ + +/*! + \fn QMediaServiceSupportedDevicesInterface::~QMediaServiceSupportedDevicesInterface() + + Destroys a media service supported devices interface. +*/ + +/*! + \fn QMediaServiceSupportedDevicesInterface::devices(const QByteArray &service) const + + Returns a list of devices supported by a plug-in \a service. + \since 1.0 +*/ + +/*! + \fn QMediaServiceSupportedDevicesInterface::deviceDescription(const QByteArray &service, const QByteArray &device) + + Returns a description of a \a device supported by a plug-in \a service. + \since 1.0 +*/ + +/*! + \class QMediaServiceFeaturesInterface + \brief The QMediaServiceFeaturesInterface class interface identifies + features supported by a media service plug-in. + \since 1.0 + + A QMediaServiceProviderPlugin may implement this interface. +*/ + +/*! + \fn QMediaServiceFeaturesInterface::~QMediaServiceFeaturesInterface() + + Destroys a media service features interface. +*/ +/*! + \fn QMediaServiceFeaturesInterface::supportedFeatures(const QByteArray &service) const + + Returns a set of features supported by a plug-in \a service. + \since 1.0 +*/ + +#include "moc_qmediaserviceprovider.cpp" +#include "moc_qmediaserviceproviderplugin.cpp" +QT_END_NAMESPACE + diff --git a/src/multimedia/qmediaserviceprovider.h b/src/multimedia/qmediaserviceprovider.h new file mode 100644 index 000000000..8ad2e2f6c --- /dev/null +++ b/src/multimedia/qmediaserviceprovider.h @@ -0,0 +1,186 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QMEDIASERVICEPROVIDER_H +#define QMEDIASERVICEPROVIDER_H + +#include +#include +#include +#include "qtmedianamespace.h" + +QT_BEGIN_HEADER + +QT_BEGIN_NAMESPACE + +QT_MODULE(Multimedia) + + +class QMediaService; + +class QMediaServiceProviderHintPrivate; +class Q_MULTIMEDIA_EXPORT QMediaServiceProviderHint +{ +public: + enum Type { Null, ContentType, Device, SupportedFeatures }; + + enum Feature { + LowLatencyPlayback = 0x01, + RecordingSupport = 0x02, + StreamPlayback = 0x04, + VideoSurface = 0x08, + BackgroundPlayback = 0x10, + }; + Q_DECLARE_FLAGS(Features, Feature) + + QMediaServiceProviderHint(); + QMediaServiceProviderHint(const QString &mimeType, const QStringList& codecs); + QMediaServiceProviderHint(const QByteArray &device); + QMediaServiceProviderHint(Features features); + QMediaServiceProviderHint(const QMediaServiceProviderHint &other); + ~QMediaServiceProviderHint(); + + QMediaServiceProviderHint& operator=(const QMediaServiceProviderHint &other); + + bool operator == (const QMediaServiceProviderHint &other) const; + bool operator != (const QMediaServiceProviderHint &other) const; + + bool isNull() const; + + Type type() const; + + QString mimeType() const; + QStringList codecs() const; + + QByteArray device() const; + + Features features() const; + + //to be extended, if necessary + +private: + QSharedDataPointer d; +}; + +Q_DECLARE_OPERATORS_FOR_FLAGS(QMediaServiceProviderHint::Features) + +class Q_MULTIMEDIA_EXPORT QMediaServiceProvider : public QObject +{ + Q_OBJECT + +public: + virtual QMediaService* requestService(const QByteArray &type, const QMediaServiceProviderHint &hint = QMediaServiceProviderHint()) = 0; + virtual void releaseService(QMediaService *service) = 0; + + virtual QtMultimedia::SupportEstimate hasSupport(const QByteArray &serviceType, + const QString &mimeType, + const QStringList& codecs, + int flags = 0) const; + virtual QStringList supportedMimeTypes(const QByteArray &serviceType, int flags = 0) const; + + virtual QList devices(const QByteArray &serviceType) const; + virtual QString deviceDescription(const QByteArray &serviceType, const QByteArray &device); + + static QMediaServiceProvider* defaultServiceProvider(); + +#ifdef QT_BUILD_INTERNAL + static void setDefaultServiceProvider(QMediaServiceProvider *provider); +#endif +}; + +/*! + Service with support for media playback + Required Controls: QMediaPlayerControl + Optional Controls: QMediaPlaylistControl, QAudioDeviceControl + Video Output Controls (used by QWideoWidget and QGraphicsVideoItem): + Required: QVideoOutputControl + Optional: QVideoWindowControl, QVideoRendererControl, QVideoWidgetControl +*/ +#define Q_MEDIASERVICE_MEDIAPLAYER "com.nokia.qt.mediaplayer" + +/*! + Service with support for background media playback + Required Controls: QMediaPlayerControl, QMediaBackgroundPlaybackControl + Optional Controls: QMediaPlaylistControl, QAudioDeviceControl +*/ +#define Q_MEDIASERVICE_BACKGROUNDMEDIAPLAYER "com.nokia.qt.backgroundmediaplayer" + +/*! + Service with support for recording from audio sources + Required Controls: QAudioDeviceControl + Recording Controls (QMediaRecorder): + Required: QMediaRecorderControl + Recommended: QAudioEncoderControl + Optional: QMediaContainerControl +*/ +#define Q_MEDIASERVICE_AUDIOSOURCE "com.nokia.qt.audiosource" + +/*! + Service with support for camera use. + Required Controls: QCameraControl + Optional Controls: QCameraExposureControl, QCameraFocusControl, QCameraImageProcessingControl + Still Capture Controls: QCameraImageCaptureControl + Video Capture Controls (QMediaRecorder): + Required: QMediaRecorderControl + Recommended: QAudioEncoderControl, QVideoEncoderControl, QMediaContainerControl + Viewfinder Video Output Controls (used by QCameraViewfinder and QGraphicsVideoItem): + Required: QVideoOutputControl + Optional: QVideoWindowControl, QVideoRendererControl, QVideoWidgetControl +*/ +#define Q_MEDIASERVICE_CAMERA "com.nokia.qt.camera" + +/*! + Service with support for radio tuning. + Required Controls: QRadioTunerControl + Recording Controls (Optional, used by QMediaRecorder): + Required: QMediaRecorderControl + Recommended: QAudioEncoderControl + Optional: QMediaContainerControl +*/ +#define Q_MEDIASERVICE_RADIO "com.nokia.qt.radio" + + +QT_END_NAMESPACE + +QT_END_HEADER + + +#endif // QMEDIASERVICEPROVIDER_H diff --git a/src/multimedia/qmediaserviceproviderplugin.h b/src/multimedia/qmediaserviceproviderplugin.h new file mode 100644 index 000000000..669723e2b --- /dev/null +++ b/src/multimedia/qmediaserviceproviderplugin.h @@ -0,0 +1,129 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QMEDIASERVICEPROVIDERPLUGIN_H +#define QMEDIASERVICEPROVIDERPLUGIN_H + +#include +#include +#include +#include +#include "qmediaserviceprovider.h" + +#ifdef Q_MOC_RUN +# pragma Q_MOC_EXPAND_MACROS +#endif + +QT_BEGIN_HEADER + +QT_BEGIN_NAMESPACE + +QT_MODULE(Multimedia) + + +class QMediaService; + +struct Q_MULTIMEDIA_EXPORT QMediaServiceProviderFactoryInterface : public QFactoryInterface +{ + virtual QStringList keys() const = 0; + virtual QMediaService* create(QString const& key) = 0; + virtual void release(QMediaService *service) = 0; +}; + +#define QMediaServiceProviderFactoryInterface_iid \ + "com.nokia.Qt.QMediaServiceProviderFactoryInterface/1.0" +Q_DECLARE_INTERFACE(QMediaServiceProviderFactoryInterface, QMediaServiceProviderFactoryInterface_iid) + + +struct Q_MULTIMEDIA_EXPORT QMediaServiceSupportedFormatsInterface +{ + virtual ~QMediaServiceSupportedFormatsInterface() {} + virtual QtMultimedia::SupportEstimate hasSupport(const QString &mimeType, const QStringList& codecs) const = 0; + virtual QStringList supportedMimeTypes() const = 0; +}; + +#define QMediaServiceSupportedFormatsInterface_iid \ + "com.nokia.Qt.QMediaServiceSupportedFormatsInterface/1.0" +Q_DECLARE_INTERFACE(QMediaServiceSupportedFormatsInterface, QMediaServiceSupportedFormatsInterface_iid) + + +struct Q_MULTIMEDIA_EXPORT QMediaServiceSupportedDevicesInterface +{ + virtual ~QMediaServiceSupportedDevicesInterface() {} + virtual QList devices(const QByteArray &service) const = 0; + virtual QString deviceDescription(const QByteArray &service, const QByteArray &device) = 0; +}; + +#define QMediaServiceSupportedDevicesInterface_iid \ + "com.nokia.Qt.QMediaServiceSupportedDevicesInterface/1.0" +Q_DECLARE_INTERFACE(QMediaServiceSupportedDevicesInterface, QMediaServiceSupportedDevicesInterface_iid) + + + +struct Q_MULTIMEDIA_EXPORT QMediaServiceFeaturesInterface +{ + virtual ~QMediaServiceFeaturesInterface() {} + virtual QMediaServiceProviderHint::Features supportedFeatures(const QByteArray &service) const = 0; +}; + +#define QMediaServiceFeaturesInterface_iid \ + "com.nokia.Qt.QMediaServiceFeaturesInterface/1.0" +Q_DECLARE_INTERFACE(QMediaServiceFeaturesInterface, QMediaServiceFeaturesInterface_iid) + + +class Q_MULTIMEDIA_EXPORT QMediaServiceProviderPlugin : public QObject, public QMediaServiceProviderFactoryInterface +{ + Q_OBJECT + Q_INTERFACES(QMediaServiceProviderFactoryInterface:QFactoryInterface) + +public: + virtual QStringList keys() const = 0; + virtual QMediaService* create(const QString& key) = 0; + virtual void release(QMediaService *service) = 0; +}; + +QT_END_NAMESPACE + +QT_END_HEADER + + + +#endif // QMEDIASERVICEPROVIDERPLUGIN_H diff --git a/src/multimedia/qmediastreamscontrol.cpp b/src/multimedia/qmediastreamscontrol.cpp new file mode 100644 index 000000000..65614b612 --- /dev/null +++ b/src/multimedia/qmediastreamscontrol.cpp @@ -0,0 +1,161 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qmediastreamscontrol.h" +#include "qmediacontrol_p.h" + +QT_BEGIN_NAMESPACE + +/*! + \class QMediaStreamsControl + \preliminary + + \inmodule QtMultimedia + \ingroup multimedia-serv + \brief The QMediaStreamsControl class provides a media stream selection control. + + \since 1.0 + + The QMediaStreamsControl class provides descriptions of the available media streams + and allows individual streams to be activated and deactivated. + + The interface name of QMediaStreamsControl is \c com.nokia.Qt.MediaStreamsControl as + defined in QMediaStreamsControl_iid. + + \sa QMediaService::requestControl() +*/ + +/*! + \macro QMediaStreamsControl_iid + + \c com.nokia.Qt.MediaStreamsControl + + Defines the interface name of the QMediaStreamsControl class. + + \relates QMediaStreamsControl + \since 1.0 +*/ + +/*! + Constructs a new media streams control with the given \a parent. +*/ +QMediaStreamsControl::QMediaStreamsControl(QObject *parent) + :QMediaControl(*new QMediaControlPrivate, parent) +{ +} + +/*! + Destroys a media streams control. +*/ +QMediaStreamsControl::~QMediaStreamsControl() +{ +} + +/*! + \enum QMediaStreamsControl::StreamType + + Media stream type. + + \value AudioStream Audio stream. + \value VideoStream Video stream. + \value SubPictureStream Subpicture or teletext stream. + \value UnknownStream The stream type is unknown. + \value DataStream +*/ + +/*! + \fn QMediaStreamsControl::streamCount() + + Returns the number of media streams. + \since 1.0 +*/ + +/*! + \fn QMediaStreamsControl::streamType(int stream) + + Return the type of a media \a stream. + \since 1.0 +*/ + +/*! + \fn QMediaStreamsControl::metaData(int stream, QtMultimedia::MetaData key) + + Returns the meta-data value of \a key for a given \a stream. + + Useful metadata keya are QtMultimedia::Title, QtMultimedia::Description and QtMultimedia::Language. + \since 1.0 +*/ + +/*! + \fn QMediaStreamsControl::isActive(int stream) + + Returns true if the media \a stream is active. + \since 1.0 +*/ + +/*! + \fn QMediaStreamsControl::setActive(int stream, bool state) + + Sets the active \a state of a media \a stream. + + Setting the active state of a media stream to true will activate it. If any other stream + of the same type was previously active it will be deactivated. Setting the active state fo a + media stream to false will deactivate it. + \since 1.0 +*/ + +/*! + \fn QMediaStreamsControl::streamsChanged() + + The signal is emitted when the available streams list is changed. + \since 1.0 +*/ + +/*! + \fn QMediaStreamsControl::activeStreamsChanged() + + The signal is emitted when the active streams list is changed. + \since 1.0 +*/ + +#include "moc_qmediastreamscontrol.cpp" +QT_END_NAMESPACE + diff --git a/src/multimedia/qmediastreamscontrol.h b/src/multimedia/qmediastreamscontrol.h new file mode 100644 index 000000000..bbd8a2a43 --- /dev/null +++ b/src/multimedia/qmediastreamscontrol.h @@ -0,0 +1,95 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + + +#ifndef QMEDIASTREAMSCONTROL_H +#define QMEDIASTREAMSCONTROL_H + +#include "qmediacontrol.h" +#include "qtmedianamespace.h" +#include "qtmultimediadefs.h" +#include + +QT_BEGIN_HEADER + +QT_BEGIN_NAMESPACE + +QT_MODULE(Multimedia) + + +class Q_MULTIMEDIA_EXPORT QMediaStreamsControl : public QMediaControl +{ + Q_OBJECT + Q_ENUMS(SteamType) +public: + enum StreamType { UnknownStream, VideoStream, AudioStream, SubPictureStream, DataStream }; + + virtual ~QMediaStreamsControl(); + + virtual int streamCount() = 0; + virtual StreamType streamType(int streamNumber) = 0; + + virtual QVariant metaData(int streamNumber, QtMultimedia::MetaData key) = 0; + + virtual bool isActive(int streamNumber) = 0; + virtual void setActive(int streamNumber, bool state) = 0; + +Q_SIGNALS: + void streamsChanged(); + void activeStreamsChanged(); + +protected: + QMediaStreamsControl(QObject *parent = 0); +}; + +#define QMediaStreamsControl_iid "com.nokia.Qt.QMediaStreamsControl/1.0" +Q_MEDIA_DECLARE_CONTROL(QMediaStreamsControl, QMediaStreamsControl_iid) + +QT_END_NAMESPACE + +Q_DECLARE_METATYPE(QMediaStreamsControl::StreamType) + +Q_MEDIA_ENUM_DEBUG(QMediaStreamsControl, StreamType) + +QT_END_HEADER + +#endif // QMEDIASTREAMSCONTROL_H + diff --git a/src/multimedia/qmediatimerange.cpp b/src/multimedia/qmediatimerange.cpp new file mode 100644 index 000000000..34252de37 --- /dev/null +++ b/src/multimedia/qmediatimerange.cpp @@ -0,0 +1,759 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include + +#include "qmediatimerange.h" + +QT_BEGIN_NAMESPACE + +/*! + \class QMediaTimeInterval + \brief The QMediaTimeInterval class represents a time interval with integer precision. + \inmodule QtMultimedia + \ingroup multimedia + \since 1.0 + + An interval is specified by an inclusive start() and end() time. These + must be set in the constructor, as this is an immutable class. The + specific units of time represented by the class have not been defined - it + is suitable for any times which can be represented by a signed 64 bit + integer. + + The isNormal() method determines if a time interval is normal (a normal + time interval has start() <= end()). An abnormal interval can be converted + in to a normal interval by calling the normalized() method. + + The contains() method determines if a specified time lies within the time + interval. + + The translated() method returns a time interval which has been translated + forwards or backwards through time by a specified offset. + + \sa QMediaTimeRange +*/ + +/*! + \fn QMediaTimeInterval::QMediaTimeInterval() + + Constructs an empty interval. +*/ +QMediaTimeInterval::QMediaTimeInterval() + : s(0) + , e(0) +{ + +} + +/*! + \fn QMediaTimeInterval::QMediaTimeInterval(qint64 start, qint64 end) + + Constructs an interval with the specified \a start and \a end times. + \since 1.0 +*/ +QMediaTimeInterval::QMediaTimeInterval(qint64 start, qint64 end) + : s(start) + , e(end) +{ + +} + +/*! + \fn QMediaTimeInterval::QMediaTimeInterval(const QMediaTimeInterval &other) + + Constructs an interval by taking a copy of \a other. + \since 1.0 +*/ +QMediaTimeInterval::QMediaTimeInterval(const QMediaTimeInterval &other) + : s(other.s) + , e(other.e) +{ + +} + +/*! + \fn QMediaTimeInterval::start() const + + Returns the start time of the interval. + + \since 1.0 + \sa end() +*/ +qint64 QMediaTimeInterval::start() const +{ + return s; +} + +/*! + \fn QMediaTimeInterval::end() const + + Returns the end time of the interval. + + \since 1.0 + \sa start() +*/ +qint64 QMediaTimeInterval::end() const +{ + return e; +} + +/*! + \fn QMediaTimeInterval::contains(qint64 time) const + + Returns true if the time interval contains the specified \a time. + That is, start() <= time <= end(). + \since 1.0 +*/ +bool QMediaTimeInterval::contains(qint64 time) const +{ + return isNormal() ? (s <= time && time <= e) + : (e <= time && time <= s); +} + +/*! + \fn QMediaTimeInterval::isNormal() const + + Returns true if this time interval is normal. + A normal time interval has start() <= end(). + + \since 1.0 + \sa normalized() +*/ +bool QMediaTimeInterval::isNormal() const +{ + return s <= e; +} + +/*! + \fn QMediaTimeInterval::normalized() const + + Returns a normalized version of this interval. + + If the start() time of the interval is greater than the end() time, + then the returned interval has the start and end times swapped. + \since 1.0 +*/ +QMediaTimeInterval QMediaTimeInterval::normalized() const +{ + if(s > e) + return QMediaTimeInterval(e, s); + + return *this; +} + +/*! + \fn QMediaTimeInterval::translated(qint64 offset) const + + Returns a copy of this time interval, translated by a value of \a offset. + An interval can be moved forward through time with a positive offset, or backward + through time with a negative offset. + \since 1.0 +*/ +QMediaTimeInterval QMediaTimeInterval::translated(qint64 offset) const +{ + return QMediaTimeInterval(s + offset, e + offset); +} + +/*! + \fn operator==(const QMediaTimeInterval &a, const QMediaTimeInterval &b) + \relates QMediaTimeRange + + Returns true if \a a is exactly equal to \a b. + \since 1.0 +*/ +bool operator==(const QMediaTimeInterval &a, const QMediaTimeInterval &b) +{ + return a.start() == b.start() && a.end() == b.end(); +} + +/*! + \fn operator!=(const QMediaTimeInterval &a, const QMediaTimeInterval &b) + \relates QMediaTimeRange + + Returns true if \a a is not exactly equal to \a b. + \since 1.0 +*/ +bool operator!=(const QMediaTimeInterval &a, const QMediaTimeInterval &b) +{ + return a.start() != b.start() || a.end() != b.end(); +} + +class QMediaTimeRangePrivate : public QSharedData +{ +public: + + QMediaTimeRangePrivate(); + QMediaTimeRangePrivate(const QMediaTimeRangePrivate &other); + QMediaTimeRangePrivate(const QMediaTimeInterval &interval); + + QList intervals; + + void addInterval(const QMediaTimeInterval &interval); + void removeInterval(const QMediaTimeInterval &interval); +}; + +QMediaTimeRangePrivate::QMediaTimeRangePrivate() + : QSharedData() +{ + +} + +QMediaTimeRangePrivate::QMediaTimeRangePrivate(const QMediaTimeRangePrivate &other) + : QSharedData() + , intervals(other.intervals) +{ + +} + +QMediaTimeRangePrivate::QMediaTimeRangePrivate(const QMediaTimeInterval &interval) + : QSharedData() +{ + if(interval.isNormal()) + intervals << interval; +} + +void QMediaTimeRangePrivate::addInterval(const QMediaTimeInterval &interval) +{ + // Handle normalized intervals only + if(!interval.isNormal()) + return; + + // Find a place to insert the interval + int i; + for (i = 0; i < intervals.count(); i++) { + // Insert before this element + if(interval.s < intervals[i].s) { + intervals.insert(i, interval); + break; + } + } + + // Interval needs to be added to the end of the list + if (i == intervals.count()) + intervals.append(interval); + + // Do we need to correct the element before us? + if(i > 0 && intervals[i - 1].e >= interval.s - 1) + i--; + + // Merge trailing ranges + while (i < intervals.count() - 1 + && intervals[i].e >= intervals[i + 1].s - 1) { + intervals[i].e = qMax(intervals[i].e, intervals[i + 1].e); + intervals.removeAt(i + 1); + } +} + +void QMediaTimeRangePrivate::removeInterval(const QMediaTimeInterval &interval) +{ + // Handle normalized intervals only + if(!interval.isNormal()) + return; + + for (int i = 0; i < intervals.count(); i++) { + QMediaTimeInterval r = intervals[i]; + + if (r.e < interval.s) { + // Before the removal interval + continue; + } else if (interval.e < r.s) { + // After the removal interval - stop here + break; + } else if (r.s < interval.s && interval.e < r.e) { + // Split case - a single range has a chunk removed + intervals[i].e = interval.s -1; + addInterval(QMediaTimeInterval(interval.e + 1, r.e)); + break; + } else if (r.s < interval.s) { + // Trimming Tail Case + intervals[i].e = interval.s - 1; + } else if (interval.e < r.e) { + // Trimming Head Case - we can stop after this + intervals[i].s = interval.e + 1; + break; + } else { + // Complete coverage case + intervals.removeAt(i); + --i; + } + } +} + +/*! + \class QMediaTimeRange + \brief The QMediaTimeRange class represents a set of zero or more disjoint + time intervals. + \ingroup multimedia + \since 1.0 + + \reentrant + + The earliestTime(), latestTime(), intervals() and isEmpty() + methods are used to get information about the current time range. + + The addInterval(), removeInterval() and clear() methods are used to modify + the current time range. + + When adding or removing intervals from the time range, existing intervals + within the range may be expanded, trimmed, deleted, merged or split to ensure + that all intervals within the time range remain distinct and disjoint. As a + consequence, all intervals added or removed from a time range must be + \l{QMediaTimeInterval::isNormal()}{normal}. + + \sa QMediaTimeInterval +*/ + +/*! + \fn QMediaTimeRange::QMediaTimeRange() + + Constructs an empty time range. +*/ +QMediaTimeRange::QMediaTimeRange() + : d(new QMediaTimeRangePrivate) +{ + +} + +/*! + \fn QMediaTimeRange::QMediaTimeRange(qint64 start, qint64 end) + + Constructs a time range that contains an initial interval from + \a start to \a end inclusive. + + If the interval is not \l{QMediaTimeInterval::isNormal()}{normal}, + the resulting time range will be empty. + + \since 1.0 + \sa addInterval() +*/ +QMediaTimeRange::QMediaTimeRange(qint64 start, qint64 end) + : d(new QMediaTimeRangePrivate(QMediaTimeInterval(start, end))) +{ + +} + +/*! + \fn QMediaTimeRange::QMediaTimeRange(const QMediaTimeInterval &interval) + + Constructs a time range that contains an intitial interval, \a interval. + + If \a interval is not \l{QMediaTimeInterval::isNormal()}{normal}, + the resulting time range will be empty. + + \since 1.0 + \sa addInterval() +*/ +QMediaTimeRange::QMediaTimeRange(const QMediaTimeInterval &interval) + : d(new QMediaTimeRangePrivate(interval)) +{ + +} + +/*! + \fn QMediaTimeRange::QMediaTimeRange(const QMediaTimeRange &range) + + Constructs a time range by copying another time \a range. + \since 1.0 +*/ +QMediaTimeRange::QMediaTimeRange(const QMediaTimeRange &range) + : d(range.d) +{ + +} + +/*! + \fn QMediaTimeRange::~QMediaTimeRange() + + Destructor. +*/ +QMediaTimeRange::~QMediaTimeRange() +{ + +} + +/*! + \fn QMediaTimeRange::operator=(const QMediaTimeRange &other) + + Takes a copy of the \a other time range and returns itself. + \since 1.0 +*/ +QMediaTimeRange &QMediaTimeRange::operator=(const QMediaTimeRange &other) +{ + d = other.d; + return *this; +} + +/*! + \fn QMediaTimeRange::operator=(const QMediaTimeInterval &interval) + + Sets the time range to a single continuous interval, \a interval. + \since 1.0 +*/ +QMediaTimeRange &QMediaTimeRange::operator=(const QMediaTimeInterval &interval) +{ + d = new QMediaTimeRangePrivate(interval); + return *this; +} + +/*! + \fn QMediaTimeRange::earliestTime() const + + Returns the earliest time within the time range. + + For empty time ranges, this value is equal to zero. + + \since 1.0 + \sa latestTime() +*/ +qint64 QMediaTimeRange::earliestTime() const +{ + if (!d->intervals.isEmpty()) + return d->intervals[0].s; + + return 0; +} + +/*! + \fn QMediaTimeRange::latestTime() const + + Returns the latest time within the time range. + + For empty time ranges, this value is equal to zero. + + \since 1.0 + \sa earliestTime() +*/ +qint64 QMediaTimeRange::latestTime() const +{ + if (!d->intervals.isEmpty()) + return d->intervals[d->intervals.count() - 1].e; + + return 0; +} + +/*! + \fn QMediaTimeRange::addInterval(qint64 start, qint64 end) + \overload + + Adds the interval specified by \a start and \a end + to the time range. + + \since 1.0 + \sa addInterval() +*/ +void QMediaTimeRange::addInterval(qint64 start, qint64 end) +{ + d->addInterval(QMediaTimeInterval(start, end)); +} + +/*! + \fn QMediaTimeRange::addInterval(const QMediaTimeInterval &interval) + + Adds the specified \a interval to the time range. + + Adding intervals which are not \l{QMediaTimeInterval::isNormal()}{normal} + is invalid, and will be ignored. + + If the specified interval is adjacent to, or overlaps existing + intervals within the time range, these intervals will be merged. + + This operation takes \l{linear time} + + \since 1.0 + \sa removeInterval() +*/ +void QMediaTimeRange::addInterval(const QMediaTimeInterval &interval) +{ + d->addInterval(interval); +} + +/*! + \fn QMediaTimeRange::addTimeRange(const QMediaTimeRange &range) + + Adds each of the intervals in \a range to this time range. + + Equivalent to calling addInterval() for each interval in \a range. + \since 1.0 +*/ +void QMediaTimeRange::addTimeRange(const QMediaTimeRange &range) +{ + foreach(const QMediaTimeInterval &i, range.intervals()) { + d->addInterval(i); + } +} + +/*! + \fn QMediaTimeRange::removeInterval(qint64 start, qint64 end) + \overload + + Removes the interval specified by \a start and \a end + from the time range. + + \since 1.0 + \sa removeInterval() +*/ +void QMediaTimeRange::removeInterval(qint64 start, qint64 end) +{ + d->removeInterval(QMediaTimeInterval(start, end)); +} + +/*! + \fn QMediaTimeRange::removeInterval(const QMediaTimeInterval &interval) + + Removes the specified \a interval from the time range. + + Removing intervals which are not \l{QMediaTimeInterval::isNormal()}{normal} + is invalid, and will be ignored. + + Intervals within the time range will be trimmed, split or deleted + such that no intervals within the time range include any part of the + target interval. + + This operation takes \l{linear time} + + \since 1.0 + \sa addInterval() +*/ +void QMediaTimeRange::removeInterval(const QMediaTimeInterval &interval) +{ + d->removeInterval(interval); +} + +/*! + \fn QMediaTimeRange::removeTimeRange(const QMediaTimeRange &range) + + Removes each of the intervals in \a range from this time range. + + Equivalent to calling removeInterval() for each interval in \a range. + \since 1.0 +*/ +void QMediaTimeRange::removeTimeRange(const QMediaTimeRange &range) +{ + foreach(const QMediaTimeInterval &i, range.intervals()) { + d->removeInterval(i); + } +} + +/*! + \fn QMediaTimeRange::operator+=(const QMediaTimeRange &other) + + Adds each interval in \a other to the time range and returns the result. + \since 1.0 +*/ +QMediaTimeRange& QMediaTimeRange::operator+=(const QMediaTimeRange &other) +{ + addTimeRange(other); + return *this; +} + +/*! + \fn QMediaTimeRange::operator+=(const QMediaTimeInterval &interval) + + Adds the specified \a interval to the time range and returns the result. + \since 1.0 +*/ +QMediaTimeRange& QMediaTimeRange::operator+=(const QMediaTimeInterval &interval) +{ + addInterval(interval); + return *this; +} + +/*! + \fn QMediaTimeRange::operator-=(const QMediaTimeRange &other) + + Removes each interval in \a other from the time range and returns the result. + \since 1.0 +*/ +QMediaTimeRange& QMediaTimeRange::operator-=(const QMediaTimeRange &other) +{ + removeTimeRange(other); + return *this; +} + +/*! + \fn QMediaTimeRange::operator-=(const QMediaTimeInterval &interval) + + Removes the specified \a interval from the time range and returns the result. + \since 1.0 +*/ +QMediaTimeRange& QMediaTimeRange::operator-=(const QMediaTimeInterval &interval) +{ + removeInterval(interval); + return *this; +} + +/*! + \fn QMediaTimeRange::clear() + + Removes all intervals from the time range. + + \since 1.0 + \sa removeInterval() +*/ +void QMediaTimeRange::clear() +{ + d->intervals.clear(); +} + +/*! + \fn QMediaTimeRange::intervals() const + + Returns the list of intervals covered by this time range. + \since 1.0 +*/ +QList QMediaTimeRange::intervals() const +{ + return d->intervals; +} + +/*! + \fn QMediaTimeRange::isEmpty() const + + Returns true if there are no intervals within the time range. + + \since 1.0 + \sa intervals() +*/ +bool QMediaTimeRange::isEmpty() const +{ + return d->intervals.isEmpty(); +} + +/*! + \fn QMediaTimeRange::isContinuous() const + + Returns true if the time range consists of a continuous interval. + That is, there is one or fewer disjoint intervals within the time range. + \since 1.0 +*/ +bool QMediaTimeRange::isContinuous() const +{ + return (d->intervals.count() <= 1); +} + +/*! + \fn QMediaTimeRange::contains(qint64 time) const + + Returns true if the specified \a time lies within the time range. + \since 1.0 +*/ +bool QMediaTimeRange::contains(qint64 time) const +{ + for (int i = 0; i < d->intervals.count(); i++) { + if (d->intervals[i].contains(time)) + return true; + + if (time < d->intervals[i].s) + break; + } + + return false; +} + +/*! + \fn operator==(const QMediaTimeRange &a, const QMediaTimeRange &b) + \relates QMediaTimeRange + + Returns true if all intervals in \a a are present in \a b. + \since 1.0 +*/ +bool operator==(const QMediaTimeRange &a, const QMediaTimeRange &b) +{ + if (a.intervals().count() != b.intervals().count()) + return false; + + for (int i = 0; i < a.intervals().count(); i++) + { + if(a.intervals()[i] != b.intervals()[i]) + return false; + } + + return true; +} + +/*! + \fn operator!=(const QMediaTimeRange &a, const QMediaTimeRange &b) + \relates QMediaTimeRange + + Returns true if one or more intervals in \a a are not present in \a b. + \since 1.0 +*/ +bool operator!=(const QMediaTimeRange &a, const QMediaTimeRange &b) +{ + return !(a == b); +} + +/*! + \fn operator+(const QMediaTimeRange &r1, const QMediaTimeRange &r2) + + Returns a time range containing the union between \a r1 and \a r2. + \since 1.0 + */ +QMediaTimeRange operator+(const QMediaTimeRange &r1, const QMediaTimeRange &r2) +{ + return (QMediaTimeRange(r1) += r2); +} + +/*! + \fn operator-(const QMediaTimeRange &r1, const QMediaTimeRange &r2) + + Returns a time range containing \a r2 subtracted from \a r1. + \since 1.0 + */ +QMediaTimeRange operator-(const QMediaTimeRange &r1, const QMediaTimeRange &r2) +{ + return (QMediaTimeRange(r1) -= r2); +} + +#ifndef QT_NO_DEBUG_STREAM +QDebug operator<<(QDebug dbg, const QMediaTimeRange &range) +{ + dbg.nospace() << "QMediaTimeRange( "; + foreach (const QMediaTimeInterval &interval, range.intervals()) { + dbg.nospace() << "(" << interval.start() << ", " << interval.end() << ") "; + } + dbg.space() << ")"; + return dbg; +} +#endif + +QT_END_NAMESPACE + diff --git a/src/multimedia/qmediatimerange.h b/src/multimedia/qmediatimerange.h new file mode 100644 index 000000000..d506bbe52 --- /dev/null +++ b/src/multimedia/qmediatimerange.h @@ -0,0 +1,140 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QMEDIATIMERANGE_H +#define QMEDIATIMERANGE_H + +#include +#include "qtmedianamespace.h" +#include + +QT_BEGIN_HEADER + +QT_BEGIN_NAMESPACE + +QT_MODULE(Multimedia) + + +class QMediaTimeRangePrivate; + +class Q_MULTIMEDIA_EXPORT QMediaTimeInterval +{ +public: + QMediaTimeInterval(); + QMediaTimeInterval(qint64 start, qint64 end); + QMediaTimeInterval(const QMediaTimeInterval&); + + qint64 start() const; + qint64 end() const; + + bool contains(qint64 time) const; + + bool isNormal() const; + QMediaTimeInterval normalized() const; + QMediaTimeInterval translated(qint64 offset) const; + +private: + friend class QMediaTimeRangePrivate; + friend class QMediaTimeRange; + + qint64 s; + qint64 e; +}; + +Q_MULTIMEDIA_EXPORT bool operator==(const QMediaTimeInterval&, const QMediaTimeInterval&); +Q_MULTIMEDIA_EXPORT bool operator!=(const QMediaTimeInterval&, const QMediaTimeInterval&); + +class Q_MULTIMEDIA_EXPORT QMediaTimeRange +{ +public: + + QMediaTimeRange(); + QMediaTimeRange(qint64 start, qint64 end); + QMediaTimeRange(const QMediaTimeInterval&); + QMediaTimeRange(const QMediaTimeRange &range); + ~QMediaTimeRange(); + + QMediaTimeRange &operator=(const QMediaTimeRange&); + QMediaTimeRange &operator=(const QMediaTimeInterval&); + + qint64 earliestTime() const; + qint64 latestTime() const; + + QList intervals() const; + bool isEmpty() const; + bool isContinuous() const; + + bool contains(qint64 time) const; + + void addInterval(qint64 start, qint64 end); + void addInterval(const QMediaTimeInterval &interval); + void addTimeRange(const QMediaTimeRange&); + + void removeInterval(qint64 start, qint64 end); + void removeInterval(const QMediaTimeInterval &interval); + void removeTimeRange(const QMediaTimeRange&); + + QMediaTimeRange& operator+=(const QMediaTimeRange&); + QMediaTimeRange& operator+=(const QMediaTimeInterval&); + QMediaTimeRange& operator-=(const QMediaTimeRange&); + QMediaTimeRange& operator-=(const QMediaTimeInterval&); + + void clear(); + +private: + QSharedDataPointer d; +}; + +Q_MULTIMEDIA_EXPORT bool operator==(const QMediaTimeRange&, const QMediaTimeRange&); +Q_MULTIMEDIA_EXPORT bool operator!=(const QMediaTimeRange&, const QMediaTimeRange&); +Q_MULTIMEDIA_EXPORT QMediaTimeRange operator+(const QMediaTimeRange&, const QMediaTimeRange&); +Q_MULTIMEDIA_EXPORT QMediaTimeRange operator-(const QMediaTimeRange&, const QMediaTimeRange&); + +#ifndef QT_NO_DEBUG_STREAM +Q_MULTIMEDIA_EXPORT QDebug operator<<(QDebug, const QMediaTimeRange &); +#endif + +QT_END_NAMESPACE + +QT_END_HEADER + + +#endif // QMEDIATIMERANGE_H diff --git a/src/multimedia/qmetadatareadercontrol.cpp b/src/multimedia/qmetadatareadercontrol.cpp new file mode 100644 index 000000000..a15cf6d7e --- /dev/null +++ b/src/multimedia/qmetadatareadercontrol.cpp @@ -0,0 +1,163 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include +#include + +QT_BEGIN_NAMESPACE + + +/*! + \class QMetaDataReaderControl + \inmodule QtMultimedia + \ingroup multimedia-serv + \since 1.0 + + + \brief The QMetaDataReaderControl class provides read access to the + meta-data of a QMediaService's media. + + If a QMediaService can provide read or write access to the meta-data of + its current media it will implement QMetaDataReaderControl. This control + provides functions for both retrieving and setting meta-data values. + Meta-data may be addressed by the well defined keys in the + QtMultimedia::MetaData enumeration using the metaData() functions, or by + string keys using the extendedMetaData() functions. + + The functionality provided by this control is exposed to application + code by the meta-data members of QMediaObject, and so meta-data access + is potentially available in any of the media object classes. Any media + service may implement QMetaDataReaderControl. + + The interface name of QMetaDataReaderControl is + \c com.nokia.Qt.QMetaDataReaderControl/1.0 as defined in + QMetaDataReaderControl_iid. + + \sa QMediaService::requestControl(), QMediaObject +*/ + +/*! + \macro QMetaDataReaderControl_iid + + \c com.nokia.Qt.QMetaDataReaderControl/1.0 + + Defines the interface name of the QMetaDataReaderControl class. + + \relates QMetaDataReaderControl +*/ + +/*! + Construct a QMetaDataReaderControl with \a parent. This class is meant as a base class + for service specific meta data providers so this constructor is protected. +*/ + +QMetaDataReaderControl::QMetaDataReaderControl(QObject *parent): + QMediaControl(*new QMediaControlPrivate, parent) +{ +} + +/*! + Destroy the meta-data object. +*/ + +QMetaDataReaderControl::~QMetaDataReaderControl() +{ +} + +/*! + \fn bool QMetaDataReaderControl::isMetaDataAvailable() const + + Identifies if meta-data is available from a media service. + + Returns true if the meta-data is available and false otherwise. + \since 1.0 +*/ + +/*! + \fn QVariant QMetaDataReaderControl::metaData(QtMultimedia::MetaData key) const + + Returns the meta-data for the given \a key. + \since 1.0 +*/ + +/*! + \fn QMetaDataReaderControl::availableMetaData() const + + Returns a list of keys there is meta-data available for. + \since 1.0 +*/ + +/*! + \fn QMetaDataReaderControl::extendedMetaData(const QString &key) const + + Returns the metaData for an abitrary string \a key. + + The valid selection of keys for extended meta-data is determined by the provider and the meaning + and type may differ between providers. + \since 1.0 +*/ + +/*! + \fn QMetaDataReaderControl::availableExtendedMetaData() const + + Returns a list of keys there is extended meta-data available for. + \since 1.0 +*/ + + +/*! + \fn void QMetaDataReaderControl::metaDataChanged() + + Signal the changes of meta-data. + \since 1.0 +*/ + +/*! + \fn void QMetaDataReaderControl::metaDataAvailableChanged(bool available) + + Signal the availability of meta-data has changed, \a available will + be true if the multimedia object has meta-data. + \since 1.0 +*/ + +#include "moc_qmetadatareadercontrol.cpp" +QT_END_NAMESPACE + diff --git a/src/multimedia/qmetadatareadercontrol.h b/src/multimedia/qmetadatareadercontrol.h new file mode 100644 index 000000000..0d370b5c4 --- /dev/null +++ b/src/multimedia/qmetadatareadercontrol.h @@ -0,0 +1,92 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QMETADATAREADERCONTROL_H +#define QMETADATAREADERCONTROL_H + +#include +#include + +#include + +#include +#include "qtmedianamespace.h" + +QT_BEGIN_HEADER + +QT_BEGIN_NAMESPACE + +QT_MODULE(Multimedia) + + + +class Q_MULTIMEDIA_EXPORT QMetaDataReaderControl : public QMediaControl +{ + Q_OBJECT +public: + ~QMetaDataReaderControl(); + + virtual bool isMetaDataAvailable() const = 0; + + virtual QVariant metaData(QtMultimedia::MetaData key) const = 0; + virtual QList availableMetaData() const = 0; + + virtual QVariant extendedMetaData(const QString &key) const = 0; + virtual QStringList availableExtendedMetaData() const = 0; + +Q_SIGNALS: + void metaDataChanged(); + + void metaDataAvailableChanged(bool available); + +protected: + QMetaDataReaderControl(QObject *parent = 0); +}; + +#define QMetaDataReaderControl_iid "com.nokia.Qt.QMetaDataReaderControl/1.0" +Q_MEDIA_DECLARE_CONTROL(QMetaDataReaderControl, QMetaDataReaderControl_iid) + +QT_END_NAMESPACE + +QT_END_HEADER + + +#endif // QMETADATAPROVIDER_H diff --git a/src/multimedia/qmetadatawritercontrol.cpp b/src/multimedia/qmetadatawritercontrol.cpp new file mode 100644 index 000000000..0888bcfae --- /dev/null +++ b/src/multimedia/qmetadatawritercontrol.cpp @@ -0,0 +1,195 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include +#include + +QT_BEGIN_NAMESPACE + + +/*! + \class QMetaDataWriterControl + \inmodule QtMultimedia + \ingroup multimedia-serv + \since 1.0 + + + \brief The QMetaDataWriterControl class provides write access to the + meta-data of a QMediaService's media. + + If a QMediaService can provide write access to the meta-data of its + current media it will implement QMetaDataWriterControl. This control + provides functions for both retrieving and setting meta-data values. + Meta-data may be addressed by the well defined keys in the + QtMultimedia::MetaData enumeration using the metaData() functions, or + by string keys using the extendedMetaData() functions. + + The functionality provided by this control is exposed to application code + by the meta-data members of QMediaObject, and so meta-data access is + potentially available in any of the media object classes. Any media + service may implement QMetaDataControl. + + The interface name of QMetaDataWriterControl is \c com.nokia.Qt.QMetaDataWriterControl/1.0 as + defined in QMetaDataWriterControl_iid. + + \sa QMediaService::requestControl(), QMediaObject +*/ + +/*! + \macro QMetaDataWriterControl_iid + + \c com.nokia.Qt.QMetaDataWriterControl/1.0 + + Defines the interface name of the QMetaDataWriterControl class. + + \relates QMetaDataWriterControl +*/ + +/*! + Construct a QMetaDataWriterControl with \a parent. This class is meant as a base class + for service specific meta data providers so this constructor is protected. +*/ + +QMetaDataWriterControl::QMetaDataWriterControl(QObject *parent): + QMediaControl(*new QMediaControlPrivate, parent) +{ +} + +/*! + Destroy the meta-data writer control. +*/ + +QMetaDataWriterControl::~QMetaDataWriterControl() +{ +} + +/*! + \fn bool QMetaDataWriterControl::isMetaDataAvailable() const + + Identifies if meta-data is available from a media service. + + Returns true if the meta-data is available and false otherwise. + \since 1.0 +*/ + +/*! + \fn bool QMetaDataWriterControl::isWritable() const + + Identifies if a media service's meta-data can be edited. + + Returns true if the meta-data is writable and false otherwise. + \since 1.0 +*/ + +/*! + \fn QVariant QMetaDataWriterControl::metaData(QtMultimedia::MetaData key) const + + Returns the meta-data for the given \a key. + \since 1.0 +*/ + +/*! + \fn void QMetaDataWriterControl::setMetaData(QtMultimedia::MetaData key, const QVariant &value) + + Sets the \a value of the meta-data element with the given \a key. + \since 1.0 +*/ + +/*! + \fn QMetaDataWriterControl::availableMetaData() const + + Returns a list of keys there is meta-data available for. +*/ + +/*! + \fn QMetaDataWriterControl::extendedMetaData(const QString &key) const + + Returns the meta-data for an abitrary string \a key. + + The valid selection of keys for extended meta-data is determined by the provider and the meaning + and type may differ between providers. + \since 1.0 +*/ + +/*! + \fn QMetaDataWriterControl::setExtendedMetaData(const QString &key, const QVariant &value) + + Change the value of the meta-data element with an abitrary string \a key to \a value. + + The valid selection of keys for extended meta-data is determined by the provider and the meaning + and type may differ between providers. + \since 1.0 +*/ + +/*! + \fn QMetaDataWriterControl::availableExtendedMetaData() const + + Returns a list of keys there is extended meta-data available for. + \since 1.0 +*/ + + +/*! + \fn void QMetaDataWriterControl::metaDataChanged() + + Signal the changes of meta-data. + \since 1.0 +*/ + +/*! + \fn void QMetaDataWriterControl::metaDataAvailableChanged(bool available) + + Signal the availability of meta-data has changed, \a available will + be true if the multimedia object has meta-data. + \since 1.0 +*/ + +/*! + \fn void QMetaDataWriterControl::writableChanged(bool writable) + + Signal a change in the writable status of meta-data, \a writable will be + true if meta-data elements can be added or adjusted. + \since 1.0 +*/ + +#include "moc_qmetadatawritercontrol.cpp" +QT_END_NAMESPACE + diff --git a/src/multimedia/qmetadatawritercontrol.h b/src/multimedia/qmetadatawritercontrol.h new file mode 100644 index 000000000..3f8b8c3f4 --- /dev/null +++ b/src/multimedia/qmetadatawritercontrol.h @@ -0,0 +1,97 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QMETADATAWRITERCONTROL_H +#define QMETADATAWRITERCONTROL_H + +#include "qmediacontrol.h" +#include "qmediaobject.h" + +#include "qmediaresource.h" + +#include +#include "qtmedianamespace.h" + +QT_BEGIN_HEADER + +QT_BEGIN_NAMESPACE + +QT_MODULE(Multimedia) + + + +class Q_MULTIMEDIA_EXPORT QMetaDataWriterControl : public QMediaControl +{ + Q_OBJECT +public: + ~QMetaDataWriterControl(); + + virtual bool isWritable() const = 0; + virtual bool isMetaDataAvailable() const = 0; + + virtual QVariant metaData(QtMultimedia::MetaData key) const = 0; + virtual void setMetaData(QtMultimedia::MetaData key, const QVariant &value) = 0; + virtual QList availableMetaData() const = 0; + + virtual QVariant extendedMetaData(const QString &key) const = 0; + virtual void setExtendedMetaData(const QString &key, const QVariant &value) = 0; + virtual QStringList availableExtendedMetaData() const = 0; + + +Q_SIGNALS: + void metaDataChanged(); + + void writableChanged(bool writable); + void metaDataAvailableChanged(bool available); + +protected: + QMetaDataWriterControl(QObject *parent = 0); +}; + +#define QMetaDataWriterControl_iid "com.nokia.Qt.QMetaDataWriterControl/1.0" +Q_MEDIA_DECLARE_CONTROL(QMetaDataWriterControl, QMetaDataWriterControl_iid) + +QT_END_NAMESPACE + +QT_END_HEADER + + +#endif diff --git a/src/multimedia/qradiotuner.cpp b/src/multimedia/qradiotuner.cpp new file mode 100644 index 000000000..25f76b83a --- /dev/null +++ b/src/multimedia/qradiotuner.cpp @@ -0,0 +1,614 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qradiotuner.h" +#include "qmediaservice.h" +#include "qmediaobject_p.h" +#include "qradiotunercontrol.h" + +#include + + +QT_BEGIN_NAMESPACE + +/*! + \class QRadioTuner + \brief The QRadioTuner class provides an interface to the systems analog radio device. + + \inmodule QtMultimedia + \ingroup multimedia + \since 1.0 + + You can control the systems analog radio device using this interface, for example: + + \snippet doc/src/snippets/multimedia-snippets/media.cpp Radio tuner + + The radio object will emit signals for any changes in state such as: + bandChanged(), frequencyChanged(), stereoStatusChanged(), searchingChanged(), + signalStrengthChanged(), volumeChanged(), mutedChanged(). + + You can change between the frequency bands using setBand() however it is recommended + that you check to make sure the band is available first using isBandSupported(). + +*/ + + +class QRadioTunerPrivate : public QMediaObjectPrivate +{ +public: + QRadioTunerPrivate():provider(0), control(0) {} + QMediaServiceProvider *provider; + QRadioTunerControl* control; +}; + + + +/*! + Constructs a radio tuner based on a media service allocated by a media service \a provider. + + The \a parent is passed to QMediaObject. + \since 1.0 +*/ + +QRadioTuner::QRadioTuner(QObject *parent, QMediaServiceProvider* provider): + QMediaObject(*new QRadioTunerPrivate, parent, provider->requestService(Q_MEDIASERVICE_RADIO)) +{ + Q_D(QRadioTuner); + + d->provider = provider; + + if (d->service != 0) { + d->control = qobject_cast(d->service->requestControl(QRadioTunerControl_iid)); + if (d->control != 0) { + connect(d->control, SIGNAL(stateChanged(QRadioTuner::State)), SIGNAL(stateChanged(QRadioTuner::State))); + connect(d->control, SIGNAL(bandChanged(QRadioTuner::Band)), SIGNAL(bandChanged(QRadioTuner::Band))); + connect(d->control, SIGNAL(frequencyChanged(int)), SIGNAL(frequencyChanged(int))); + connect(d->control, SIGNAL(stereoStatusChanged(bool)), SIGNAL(stereoStatusChanged(bool))); + connect(d->control, SIGNAL(searchingChanged(bool)), SIGNAL(searchingChanged(bool))); + connect(d->control, SIGNAL(signalStrengthChanged(int)), SIGNAL(signalStrengthChanged(int))); + connect(d->control, SIGNAL(volumeChanged(int)), SIGNAL(volumeChanged(int))); + connect(d->control, SIGNAL(mutedChanged(bool)), SIGNAL(mutedChanged(bool))); + connect(d->control, SIGNAL(error(QRadioTuner::Error)), SIGNAL(error(QRadioTuner::Error))); + } + } +} + +/*! + Destroys a radio tuner. +*/ + +QRadioTuner::~QRadioTuner() +{ + Q_D(QRadioTuner); + + if (d->service && d->control) + d->service->releaseControl(d->control); + + d->provider->releaseService(d->service); +} + +/*! + Returns true if the radio tuner service is ready to use. + \since 1.0 +*/ +bool QRadioTuner::isAvailable() const +{ + if (d_func()->control != NULL) + return d_func()->control->isAvailable(); + else + return false; +} + +/*! + Returns the availability error state. + \since 1.0 +*/ +QtMultimedia::AvailabilityError QRadioTuner::availabilityError() const +{ + if (d_func()->control != NULL) + return d_func()->control->availabilityError(); + else + return QtMultimedia::ServiceMissingError; +} + +/*! + \property QRadioTuner::state + Return the current radio tuner state. + + \since 1.0 + \sa QRadioTuner::State +*/ + +QRadioTuner::State QRadioTuner::state() const +{ + return d_func()->control ? + d_func()->control->state() : QRadioTuner::StoppedState; +} + +/*! + \property QRadioTuner::band + \brief the frequency band a radio tuner is tuned to. + + \since 1.0 + \sa QRadioTuner::Band +*/ + +QRadioTuner::Band QRadioTuner::band() const +{ + Q_D(const QRadioTuner); + + if (d->control != 0) + return d->control->band(); + + return QRadioTuner::FM; +} + +/*! + \property QRadioTuner::frequency + \brief the frequency in Hertz a radio tuner is tuned to. + \since 1.0 +*/ + +int QRadioTuner::frequency() const +{ + Q_D(const QRadioTuner); + + if (d->control != 0) + return d->control->frequency(); + + return 0; +} + +/*! + Returns the number of Hertz to increment the frequency by when stepping through frequencies + within a given \a band. + \since 1.0 +*/ + +int QRadioTuner::frequencyStep(QRadioTuner::Band band) const +{ + Q_D(const QRadioTuner); + + if(d->control != 0) + return d->control->frequencyStep(band); + + return 0; +} + +/*! + Returns a frequency \a band's minimum and maximum frequency. + \since 1.0 +*/ + +QPair QRadioTuner::frequencyRange(QRadioTuner::Band band) const +{ + Q_D(const QRadioTuner); + + if(d->control != 0) + return d->control->frequencyRange(band); + + return qMakePair(0,0); +} + +/*! + \property QRadioTuner::stereo + \brief whether a radio tuner is receiving a stereo signal. + \since 1.0 +*/ + +bool QRadioTuner::isStereo() const +{ + Q_D(const QRadioTuner); + + if (d->control != 0) + return d->control->isStereo(); + + return false; +} + + +/*! + \property QRadioTuner::stereoMode + \brief the stereo mode of a radio tuner. + \since 1.0 +*/ + +QRadioTuner::StereoMode QRadioTuner::stereoMode() const +{ + Q_D(const QRadioTuner); + + if (d->control != 0) + return d->control->stereoMode(); + + return QRadioTuner::Auto; +} + +void QRadioTuner::setStereoMode(QRadioTuner::StereoMode mode) +{ + Q_D(QRadioTuner); + + if (d->control != 0) + return d->control->setStereoMode(mode); +} + +/*! + Identifies if a frequency \a band is supported by a radio tuner. + + Returns true if the band is supported, and false if it is not. + \since 1.0 +*/ + +bool QRadioTuner::isBandSupported(QRadioTuner::Band band) const +{ + Q_D(const QRadioTuner); + + if (d->control != 0) + return d->control->isBandSupported(band); + + return false; +} + +/*! + Activate the radio device. + \since 1.0 +*/ + +void QRadioTuner::start() +{ + Q_D(const QRadioTuner); + + if (d->control != 0) + d->control->start(); +} + +/*! + Deactivate the radio device. + \since 1.0 +*/ + +void QRadioTuner::stop() +{ + Q_D(const QRadioTuner); + + if (d->control != 0) + d->control->stop(); +} + +/*! + \property QRadioTuner::signalStrength + \brief the strength of the current radio signal as a percentage. + \since 1.0 +*/ + +int QRadioTuner::signalStrength() const +{ + Q_D(const QRadioTuner); + + if (d->control != 0) + return d->control->signalStrength(); + + return 0; +} + +/*! + \property QRadioTuner::volume + \brief the volume of a radio tuner's audio output as a percentage. + \since 1.0 +*/ + + +int QRadioTuner::volume() const +{ + Q_D(const QRadioTuner); + + if (d->control != 0) + return d->control->volume(); + + return 0; +} + +/*! + \property QRadioTuner::muted + \brief whether a radio tuner's audio output is muted. + \since 1.0 +*/ + +bool QRadioTuner::isMuted() const +{ + Q_D(const QRadioTuner); + + if (d->control != 0) + return d->control->isMuted(); + + return false; +} + +/*! + Sets a radio tuner's frequency \a band. + + Changing the band will reset the \l frequency to the new band's minimum frequency. + \since 1.0 +*/ + +void QRadioTuner::setBand(QRadioTuner::Band band) +{ + Q_D(QRadioTuner); + + if (d->control != 0) + d->control->setBand(band); +} + +/*! + Sets a radio tuner's \a frequency. + + If the tuner is set to a frequency outside the current \l band, the band will be changed to + one occupied by the new frequency. + \since 1.0 +*/ + +void QRadioTuner::setFrequency(int frequency) +{ + Q_D(QRadioTuner); + + if (d->control != 0) + d->control->setFrequency(frequency); +} + +void QRadioTuner::setVolume(int volume) +{ + Q_D(QRadioTuner); + + if (d->control != 0) + d->control->setVolume(volume); +} + +void QRadioTuner::setMuted(bool muted) +{ + Q_D(QRadioTuner); + + if (d->control != 0) + d->control->setMuted(muted); +} + +/*! + \property QRadioTuner::searching + \brief whether a radio tuner is currently scanning for a signal. + + \sa searchForward(), searchBackward(), cancelSearch() + \since 1.0 +*/ + +bool QRadioTuner::isSearching() const +{ + Q_D(const QRadioTuner); + + if (d->control != 0) + return d->control->isSearching(); + + return false; +} + +/*! + Starts a forward scan for a signal, starting from the current \l frequency. + + \since 1.0 + \sa searchBackward(), cancelSearch(), searching +*/ + +void QRadioTuner::searchForward() +{ + Q_D(QRadioTuner); + + if (d->control != 0) + d->control->searchForward(); +} + +/*! + Starts a backwards scan for a signal, starting from the current \l frequency. + + \since 1.0 + \sa searchForward(), cancelSearch(), searching +*/ + +void QRadioTuner::searchBackward() +{ + Q_D(QRadioTuner); + + if (d->control != 0) + d->control->searchBackward(); +} + +/*! + Stops scanning for a signal. + + \since 1.0 + \sa searchForward(), searchBackward(), searching +*/ + +void QRadioTuner::cancelSearch() +{ + Q_D(QRadioTuner); + + if (d->control != 0) + d->control->cancelSearch(); +} + +/*! + Returns the error state of a radio tuner. + + \since 1.0 + \sa errorString() +*/ + +QRadioTuner::Error QRadioTuner::error() const +{ + Q_D(const QRadioTuner); + + if (d->control != 0) + return d->control->error(); + + return QRadioTuner::ResourceError; +} + +/*! + Returns a description of a radio tuner's error state. + + \since 1.0 + \sa error() +*/ + +QString QRadioTuner::errorString() const +{ + Q_D(const QRadioTuner); + + if (d->control != 0) + return d->control->errorString(); + + return QString(); +} + +/*! + \fn void QRadioTuner::bandChanged(QRadioTuner::Band band) + + Signals a radio tuner's \a band has changed. + \since 1.0 +*/ + +/*! + \fn void QRadioTuner::frequencyChanged(int frequency) + + Signals that the \a frequency a radio tuner is tuned to has changed. + \since 1.0 +*/ + +/*! + \fn void QRadioTuner::mutedChanged(bool muted) + + Signals that the \a muted state of a radio tuner's audio output has changed. + \since 1.0 +*/ + +/*! + \fn void QRadioTuner::volumeChanged(int volume) + + Signals that the \a volume of a radio tuner's audio output has changed. + \since 1.0 +*/ + +/*! + \fn void QRadioTuner::searchingChanged(bool searching) + + Signals that the \a searching state of a radio tuner has changed. + \since 1.0 +*/ + +/*! + \fn void QRadioTuner::stereoStatusChanged(bool stereo) + + Signals that the \a stereo state of a radio tuner has changed. + \since 1.0 +*/ + +/*! + \fn void QRadioTuner::signalStrengthChanged(int strength) + + Signals that the \a strength of the signal received by a radio tuner has changed. + \since 1.0 +*/ + +/*! + \fn void QRadioTuner::error(QRadioTuner::Error error) + + Signals that an \a error occurred. + \since 1.0 +*/ + +/*! + \enum QRadioTuner::State + + Enumerates radio tuner states. + + \value ActiveState The tuner is started and active. + \value StoppedState The tuner device is stopped. +*/ + + +/*! + \enum QRadioTuner::Band + + Enumerates radio frequency bands. + + \value AM 520 to 1610 kHz, 9 or 10kHz channel spacing, extended 1610 to 1710 kHz + \value FM 87.5 to 108.0 MHz, except Japan 76-90 MHz + \value SW 1.711 to 30.0 MHz, divided into 15 bands. 5kHz channel spacing + \value LW 148.5 to 283.5 kHz, 9kHz channel spacing (Europe, Africa, Asia) + \value FM2 range not defined, used when area supports more than one FM range. +*/ + +/*! + \enum QRadioTuner::Error + + Enumerates radio tuner error conditions. + + \value NoError No errors have occurred. + \value ResourceError There is no radio service available. + \value OpenError Unable to open radio device. + \value OutOfRangeError An attempt to set a frequency or band that is not supported by radio device. +*/ + +/*! + \enum QRadioTuner::StereoMode + + Enumerates radio tuner policy for receiving stereo signals. + + \value Auto Uses the stereo mode matching the station. + \value ForceStereo Provide stereo mode, converting if required. + \value ForceMono Provide mono mode, converting if required. +*/ + +/*! \fn void QRadioTuner::stateChanged(QRadioTuner::State state) + This signal is emitted when the state changes to \a state. + \since 1.0 + */ + +#include "moc_qradiotuner.cpp" +QT_END_NAMESPACE + diff --git a/src/multimedia/qradiotuner.h b/src/multimedia/qradiotuner.h new file mode 100644 index 000000000..78852638c --- /dev/null +++ b/src/multimedia/qradiotuner.h @@ -0,0 +1,158 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QRADIOTUNER_H +#define QRADIOTUNER_H + +#include + +#include "qmediaobject.h" +#include "qmediaserviceprovider.h" +#include + +#include + +QT_BEGIN_HEADER + +QT_BEGIN_NAMESPACE + +QT_MODULE(Multimedia) + + +class QRadioTunerPrivate; +class Q_MULTIMEDIA_EXPORT QRadioTuner : public QMediaObject +{ + Q_OBJECT + Q_PROPERTY(State state READ state NOTIFY stateChanged) + Q_PROPERTY(Band band READ band WRITE setBand NOTIFY bandChanged) + Q_PROPERTY(int frequency READ frequency WRITE setFrequency NOTIFY frequencyChanged) + Q_PROPERTY(bool stereo READ isStereo NOTIFY stereoStatusChanged) + Q_PROPERTY(StereoMode stereoMode READ stereoMode WRITE setStereoMode) + Q_PROPERTY(int signalStrength READ signalStrength NOTIFY signalStrengthChanged) + Q_PROPERTY(int volume READ volume WRITE setVolume NOTIFY volumeChanged) + Q_PROPERTY(bool muted READ isMuted WRITE setMuted NOTIFY mutedChanged) + Q_PROPERTY(bool searching READ isSearching NOTIFY searchingChanged) + Q_ENUMS(State) + Q_ENUMS(Band) + Q_ENUMS(Error) + Q_ENUMS(StereoMode) + +public: + enum State { ActiveState, StoppedState }; + enum Band { AM, FM, SW, LW, FM2 }; + enum Error { NoError, ResourceError, OpenError, OutOfRangeError }; + enum StereoMode { ForceStereo, ForceMono, Auto }; + + QRadioTuner(QObject *parent = 0, QMediaServiceProvider *provider = QMediaServiceProvider::defaultServiceProvider()); + ~QRadioTuner(); + + bool isAvailable() const; + QtMultimedia::AvailabilityError availabilityError() const; + + State state() const; + + Band band() const; + + bool isBandSupported(Band b) const; + + int frequency() const; + int frequencyStep(Band band) const; + QPair frequencyRange(Band band) const; + + bool isStereo() const; + void setStereoMode(QRadioTuner::StereoMode mode); + StereoMode stereoMode() const; + + int signalStrength() const; + + int volume() const; + bool isMuted() const; + + bool isSearching() const; + + Error error() const; + QString errorString() const; + +public Q_SLOTS: + void searchForward(); + void searchBackward(); + void cancelSearch(); + + void setBand(Band band); + void setFrequency(int frequency); + + void setVolume(int volume); + void setMuted(bool muted); + + void start(); + void stop(); + +Q_SIGNALS: + void stateChanged(QRadioTuner::State state); + void bandChanged(QRadioTuner::Band band); + void frequencyChanged(int frequency); + void stereoStatusChanged(bool stereo); + void searchingChanged(bool searching); + void signalStrengthChanged(int signalStrength); + void volumeChanged(int volume); + void mutedChanged(bool muted); + void error(QRadioTuner::Error error); + +private: + Q_DISABLE_COPY(QRadioTuner) + Q_DECLARE_PRIVATE(QRadioTuner) +}; + +QT_END_NAMESPACE + +Q_DECLARE_METATYPE(QRadioTuner::State) +Q_DECLARE_METATYPE(QRadioTuner::Band) +Q_DECLARE_METATYPE(QRadioTuner::Error) +Q_DECLARE_METATYPE(QRadioTuner::StereoMode) + +Q_MEDIA_ENUM_DEBUG(QRadioTuner, State) +Q_MEDIA_ENUM_DEBUG(QRadioTuner, Band) +Q_MEDIA_ENUM_DEBUG(QRadioTuner, Error) +Q_MEDIA_ENUM_DEBUG(QRadioTuner, StereoMode) + +QT_END_HEADER + +#endif // QRADIOPLAYER_H diff --git a/src/multimedia/qradiotunercontrol.cpp b/src/multimedia/qradiotunercontrol.cpp new file mode 100644 index 000000000..97ffd2396 --- /dev/null +++ b/src/multimedia/qradiotunercontrol.cpp @@ -0,0 +1,364 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include +#include "qradiotunercontrol.h" +#include "qmediacontrol_p.h" + +QT_BEGIN_NAMESPACE + + +/*! + \class QRadioTunerControl + \inmodule QtMultimedia + \ingroup multimedia-serv + \since 1.0 + + + \brief The QRadioTunerControl class provides access to the radio tuning + functionality of a QMediaService. + + If a QMediaService can tune an analog radio device it will implement + QRadioTunerControl. This control provides a means to tune a radio device + to a specific \l {setFrequency()}{frequency} as well as search \l + {searchForward()}{forwards} and \l {searchBackward()}{backwards} for a + signal. + + The functionality provided by this control is exposed to application code + through the QRadioTuner class. + + The interface name of QRadioTunerControl is \c com.nokia.Qt.QRadioTunerControl/1.0 as + defined in QRadioTunerControl_iid. + + \sa QMediaService::requestControl(), QRadioTuner +*/ + +/*! + \macro QRadioTunerControl_iid + + \c com.nokia.Qt.QRadioTunerControl/1.0 + + Defines the interface name of the QRadioTunerControl class. + + \relates QRadioTunerControl +*/ + +/*! + Constructs a radio tuner control with the given \a parent. +*/ + +QRadioTunerControl::QRadioTunerControl(QObject *parent): + QMediaControl(*new QMediaControlPrivate, parent) +{ +} + +/*! + Destroys a radio tuner control. +*/ + +QRadioTunerControl::~QRadioTunerControl() +{ +} + +/*! + \fn bool QRadioTunerControl::isAvailable() const + + Returns true if the radio service is ready to use. + \since 1.0 +*/ + +/*! + \fn QtMultimedia::AvailabilityError QRadioTunerControl::availabilityError() const + + Returns the error state of the radio service. + \since 1.0 +*/ + +/*! + \fn QRadioTuner::State QRadioTunerControl::state() const + + Returns the current radio tuner state. + \since 1.0 +*/ + +/*! + \fn QRadioTuner::Band QRadioTunerControl::band() const + + Returns the frequency band a radio tuner is tuned to. + \since 1.0 +*/ + +/*! + \fn void QRadioTunerControl::bandChanged(QRadioTuner::Band band) + + Signals that the frequency \a band a radio tuner is tuned to has changed. + \since 1.0 +*/ + +/*! + \fn void QRadioTunerControl::setBand(QRadioTuner::Band band) + + Sets the frequecy \a band a radio tuner is tuned to. + + Changing the frequency band will reset the frequency to the minimum frequency of the new band. + \since 1.0 +*/ + +/*! + \fn bool QRadioTunerControl::isBandSupported(QRadioTuner::Band band) const + + Identifies if a frequency \a band is supported. + + Returns true if the band is supported, and false if it is not. + \since 1.0 +*/ + +/*! + \fn int QRadioTunerControl::frequency() const + + Returns the frequency a radio tuner is tuned to. + \since 1.0 +*/ + +/*! + \fn int QRadioTunerControl::frequencyStep(QRadioTuner::Band band) const + + Returns the number of Hertz to increment the frequency by when stepping through frequencies + within a given \a band. + \since 1.0 +*/ + +/*! + \fn QPair QRadioTunerControl::frequencyRange(QRadioTuner::Band band) const + + Returns a frequency \a band's minimum and maximum frequency. + \since 1.0 +*/ + +/*! + \fn void QRadioTunerControl::setFrequency(int frequency) + + Sets the \a frequency a radio tuner is tuned to. + \since 1.0 +*/ + +/*! + \fn bool QRadioTunerControl::isStereo() const + + Identifies if a radio tuner is receiving a stereo signal. + + Returns true if the tuner is receiving a stereo signal, and false if it is not. + \since 1.0 +*/ + +/*! + \fn QRadioTuner::StereoMode QRadioTunerControl::stereoMode() const + + Returns a radio tuner's stereo mode. + + \since 1.0 + \sa QRadioTuner::StereoMode +*/ + +/*! + \fn void QRadioTunerControl::setStereoMode(QRadioTuner::StereoMode mode) + + Sets a radio tuner's stereo \a mode. + + \since 1.0 + \sa QRadioTuner::StereoMode +*/ + +/*! + \fn int QRadioTunerControl::signalStrength() const + + Return a radio tuner's current signal strength as a percentage. + \since 1.0 +*/ + +/*! + \fn int QRadioTunerControl::volume() const + + Returns the volume of a radio tuner's audio output as a percentage. + \since 1.0 +*/ + +/*! + \fn void QRadioTunerControl::setVolume(int volume) + + Sets the percentage \a volume of a radio tuner's audio output. + \since 1.0 +*/ + +/*! + \fn bool QRadioTunerControl::isMuted() const + + Identifies if a radio tuner's audio output is muted. + + Returns true if the audio is muted, and false if it is not. + \since 1.0 +*/ + +/*! + \fn void QRadioTunerControl::setMuted(bool muted) + + Sets the \a muted state of a radio tuner's audio output. + \since 1.0 +*/ + +/*! + \fn bool QRadioTunerControl::isSearching() const + + Identifies if a radio tuner is currently scanning for signal. + + Returns true if the tuner is scanning, and false if it is not. + \since 1.0 +*/ + +/*! + \fn void QRadioTunerControl::searchForward() + + Starts a forward scan for a signal, starting from the current \l frequency(). + \since 1.0 +*/ + +/*! + \fn void QRadioTunerControl::searchBackward() + + Starts a backwards scan for a signal, starting from the current \l frequency(). + \since 1.0 +*/ + +/*! + \fn void QRadioTunerControl::cancelSearch() + + Stops scanning for a signal. + \since 1.0 +*/ + +/*! + \fn void QRadioTunerControl::start() + + Activate the radio device. + \since 1.0 +*/ + +/*! + \fn QRadioTunerControl::stop() + + Deactivate the radio device. + \since 1.0 +*/ + +/*! + \fn QRadioTuner::Error QRadioTunerControl::error() const + + Returns the error state of a radio tuner. + \since 1.0 +*/ + +/*! + \fn QString QRadioTunerControl::errorString() const + + Returns a string describing a radio tuner's error state. + \since 1.0 +*/ + +/*! + \fn void QRadioTunerControl::stateChanged(QRadioTuner::State state) + + Signals that the \a state of a radio tuner has changed. + \since 1.0 +*/ + + +/*! + \fn void QRadioTunerControl::frequencyChanged(int frequency) + + Signals that the \a frequency a radio tuner is tuned to has changed. + \since 1.0 +*/ + +/*! + \fn void QRadioTunerControl::stereoStatusChanged(bool stereo) + + Signals that the \a stereo state of a radio tuner has changed. + \since 1.0 +*/ + +/*! + \fn void QRadioTunerControl::searchingChanged(bool searching) + + Signals that the \a searching state of a radio tuner has changed. + \since 1.0 +*/ + +/*! + \fn void QRadioTunerControl::signalStrengthChanged(int strength) + + Signals that the percentage \a strength of the signal received by a radio tuner has changed. + \since 1.0 +*/ + +/*! + \fn void QRadioTunerControl::volumeChanged(int volume) + + Signals that the percentage \a volume of radio tuner's audio output has changed. + \since 1.0 +*/ + +/*! + \fn void QRadioTunerControl::mutedChanged(bool muted) + + Signals that the \a muted state of a radio tuner's audio output has changed. + \since 1.0 +*/ + +/*! + \fn void QRadioTunerControl::error(QRadioTuner::Error error) + + Signals that an \a error has occurred. + \since 1.0 +*/ + +#include "moc_qradiotunercontrol.cpp" +QT_END_NAMESPACE + diff --git a/src/multimedia/qradiotunercontrol.h b/src/multimedia/qradiotunercontrol.h new file mode 100644 index 000000000..04812be48 --- /dev/null +++ b/src/multimedia/qradiotunercontrol.h @@ -0,0 +1,123 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QRADIOTUNERCONTROL_H +#define QRADIOTUNERCONTROL_H + +#include "qmediacontrol.h" +#include "qradiotuner.h" + +QT_BEGIN_HEADER + +QT_BEGIN_NAMESPACE + +QT_MODULE(Multimedia) + + +class Q_MULTIMEDIA_EXPORT QRadioTunerControl : public QMediaControl +{ + Q_OBJECT + +public: + ~QRadioTunerControl(); + + virtual bool isAvailable() const = 0; + virtual QtMultimedia::AvailabilityError availabilityError() const = 0; + + virtual QRadioTuner::State state() const = 0; + + virtual QRadioTuner::Band band() const = 0; + virtual void setBand(QRadioTuner::Band b) = 0; + virtual bool isBandSupported(QRadioTuner::Band b) const = 0; + + virtual int frequency() const = 0; + virtual int frequencyStep(QRadioTuner::Band b) const = 0; + virtual QPair frequencyRange(QRadioTuner::Band b) const = 0; + virtual void setFrequency(int frequency) = 0; + + virtual bool isStereo() const = 0; + virtual QRadioTuner::StereoMode stereoMode() const = 0; + virtual void setStereoMode(QRadioTuner::StereoMode mode) = 0; + + virtual int signalStrength() const = 0; + + virtual int volume() const = 0; + virtual void setVolume(int volume) = 0; + + virtual bool isMuted() const = 0; + virtual void setMuted(bool muted) = 0; + + virtual bool isSearching() const = 0; + + virtual void searchForward() = 0; + virtual void searchBackward() = 0; + virtual void cancelSearch() = 0; + + virtual void start() = 0; + virtual void stop() = 0; + + virtual QRadioTuner::Error error() const = 0; + virtual QString errorString() const = 0; + +Q_SIGNALS: + void stateChanged(QRadioTuner::State state); + void bandChanged(QRadioTuner::Band band); + void frequencyChanged(int frequency); + void stereoStatusChanged(bool stereo); + void searchingChanged(bool searching); + void signalStrengthChanged(int signalStrength); + void volumeChanged(int volume); + void mutedChanged(bool muted); + void error(QRadioTuner::Error err); + +protected: + QRadioTunerControl(QObject *parent = 0); +}; + +#define QRadioTunerControl_iid "com.nokia.Qt.QRadioTunerControl/1.0" +Q_MEDIA_DECLARE_CONTROL(QRadioTunerControl, QRadioTunerControl_iid) + +QT_END_NAMESPACE + +QT_END_HEADER + + +#endif // QRADIOTUNERCONTROL_H diff --git a/src/multimedia/qtmedianamespace.h b/src/multimedia/qtmedianamespace.h new file mode 100644 index 000000000..4296b188d --- /dev/null +++ b/src/multimedia/qtmedianamespace.h @@ -0,0 +1,339 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QTMEDIANAMESPACE_H +#define QTMEDIANAMESPACE_H + +#include +#include + +#include + +QT_BEGIN_HEADER + +QT_BEGIN_NAMESPACE + +QT_MODULE(Multimedia) + +// For now, for backwards source compatibility +// we have a copy of these enums +// But if you add a new enum value, you won't need +// to copy it to the QtMMK enums since it can't have +// been used before. +namespace QtMultimedia +{ + enum MetaData + { + // Common + Title, + SubTitle, + Author, + Comment, + Description, + Category, + Genre, + Year, + Date, + UserRating, + Keywords, + Language, + Publisher, + Copyright, + ParentalRating, + RatingOrganisation, + + // Media + Size, + MediaType, + Duration, + + // Audio + AudioBitRate, + AudioCodec, + AverageLevel, + ChannelCount, + PeakValue, + SampleRate, + + // Music + AlbumTitle, + AlbumArtist, + ContributingArtist, + Composer, + Conductor, + Lyrics, + Mood, + TrackNumber, + TrackCount, + + CoverArtUrlSmall, + CoverArtUrlLarge, + + // Image/Video + Resolution, + PixelAspectRatio, + + // Video + VideoFrameRate, + VideoBitRate, + VideoCodec, + + PosterUrl, + + // Movie + ChapterNumber, + Director, + LeadPerformer, + Writer, + + // Photos + CameraManufacturer, + CameraModel, + Event, + Subject, + Orientation, + ExposureTime, + FNumber, + ExposureProgram, + ISOSpeedRatings, + ExposureBiasValue, + DateTimeOriginal, + DateTimeDigitized, + SubjectDistance, + MeteringMode, + LightSource, + Flash, + FocalLength, + ExposureMode, + WhiteBalance, + DigitalZoomRatio, + FocalLengthIn35mmFilm, + SceneCaptureType, + GainControl, + Contrast, + Saturation, + Sharpness, + DeviceSettingDescription, + + PosterImage, + CoverArtImage, + ThumbnailImage + + }; + + enum SupportEstimate + { + NotSupported, + MaybeSupported, + ProbablySupported, + PreferredService + }; + + enum EncodingQuality + { + VeryLowQuality, + LowQuality, + NormalQuality, + HighQuality, + VeryHighQuality + }; + + enum EncodingMode + { + ConstantQualityEncoding, + ConstantBitRateEncoding, + AverageBitRateEncoding, + TwoPassEncoding + }; + + enum AvailabilityError + { + NoError, + ServiceMissingError, + BusyError, + ResourceError + }; + +} + +// For legacy support +namespace QtMultimediaKit +{ + enum MetaData + { + // Common + Title = QtMultimedia::Title, + SubTitle, + Author, + Comment, + Description, + Category, + Genre, + Year, + Date, + UserRating, + Keywords, + Language, + Publisher, + Copyright, + ParentalRating, + RatingOrganisation, + + // Media + Size, + MediaType, + Duration, + + // Audio + AudioBitRate, + AudioCodec, + AverageLevel, + ChannelCount, + PeakValue, + SampleRate, + + // Music + AlbumTitle, + AlbumArtist, + ContributingArtist, + Composer, + Conductor, + Lyrics, + Mood, + TrackNumber, + TrackCount, + + CoverArtUrlSmall, + CoverArtUrlLarge, + + // Image/Video + Resolution, + PixelAspectRatio, + + // Video + VideoFrameRate, + VideoBitRate, + VideoCodec, + + PosterUrl, + + // Movie + ChapterNumber, + Director, + LeadPerformer, + Writer, + + // Photos + CameraManufacturer, + CameraModel, + Event, + Subject, + Orientation, + ExposureTime, + FNumber, + ExposureProgram, + ISOSpeedRatings, + ExposureBiasValue, + DateTimeOriginal, + DateTimeDigitized, + SubjectDistance, + MeteringMode, + LightSource, + Flash, + FocalLength, + ExposureMode, + WhiteBalance, + DigitalZoomRatio, + FocalLengthIn35mmFilm, + SceneCaptureType, + GainControl, + Contrast, + Saturation, + Sharpness, + DeviceSettingDescription, + + PosterImage, + CoverArtImage, + ThumbnailImage + + }; + + enum SupportEstimate + { + NotSupported = QtMultimedia::NotSupported, + MaybeSupported, + ProbablySupported, + PreferredService + }; + + enum EncodingQuality + { + VeryLowQuality = QtMultimedia::VeryLowQuality, + LowQuality, + NormalQuality, + HighQuality, + VeryHighQuality + }; + + enum EncodingMode + { + ConstantQualityEncoding = QtMultimedia::ConstantQualityEncoding, + ConstantBitRateEncoding, + AverageBitRateEncoding, + TwoPassEncoding + }; + + enum AvailabilityError + { + NoError = QtMultimedia::NoError, + ServiceMissingError, + BusyError, + ResourceError + }; + +} + +QT_END_NAMESPACE + +QT_END_HEADER + + +#endif diff --git a/src/multimedia/qtmedianamespace.qdoc b/src/multimedia/qtmedianamespace.qdoc new file mode 100644 index 000000000..bc998e930 --- /dev/null +++ b/src/multimedia/qtmedianamespace.qdoc @@ -0,0 +1,208 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:FDL$ +** GNU Free Documentation License +** Alternatively, this file may be used under the terms of the GNU Free +** Documentation License version 1.3 as published by the Free Software +** Foundation and appearing in the file included in the packaging of +** this file. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms +** and conditions contained in a signed written agreement between you +** and Nokia. +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +/*! + \namespace QtMultimedia + \ingroup multimedia + \inmodule QtMultimedia + + \brief The QtMultimedia namespace contains miscellaneous identifiers used throughout the Qt Media services library. + + QtMultimedia is a module containing the low level, low latency, + Multimedia APIs which were introduced in Qt 4.6 and also includes the + high level QtMultimedia APIs which were introduced in QtMobility 1.0. + +*/ + +/*! + \enum QtMultimedia::MetaData + + This enum provides identifiers for meta-data attributes. + + \note Not all identifiers are supported on all platforms. Please consult vendor documentation for specific support + on different platforms. + + Common attributes + \value Title The title of the media. QString. + \value SubTitle The sub-title of the media. QString. + \value Author The authors of the media. QStringList. + \value Comment A user comment about the media. QString. + \value Description A description of the media. QString + \value Category The category of the media. QStringList. + \value Genre The genre of the media. QStringList. + \value Year The year of release of the media. int. + \value Date The date of the media. QDate. + \value UserRating A user rating of the media. int [0..100]. + \value Keywords A list of keywords describing the media. QStringList. + \value Language The language of media, as an ISO 639-2 code. + + \value Publisher The publisher of the media. QString. + \value Copyright The media's copyright notice. QString. + \value ParentalRating The parental rating of the media. QString. + \value RatingOrganisation The organisation responsible for the parental rating of the media. + QString. + + Media attributes + \value Size The size in bytes of the media. qint64 + \value MediaType The type of the media (audio, video, etc). QString. + \value Duration The duration in millseconds of the media. qint64. + + Audio attributes + \value AudioBitRate The bit rate of the media's audio stream in bits per second. int. + \value AudioCodec The codec of the media's audio stream. QString. + \value AverageLevel The average volume level of the media. int. + \value ChannelCount The number of channels in the media's audio stream. int. + \value PeakValue The peak volume of the media's audio stream. int + \value SampleRate The sample rate of the media's audio stream in hertz. int + + Music attributes + \value AlbumTitle The title of the album the media belongs to. QString. + \value AlbumArtist The principal artist of the album the media belongs to. QString. + \value ContributingArtist The artists contributing to the media. QStringList. + \value Composer The composer of the media. QStringList. + \value Conductor The conductor of the media. QString. + \value Lyrics The lyrics to the media. QString. + \value Mood The mood of the media. QString. + \value TrackNumber The track number of the media. int. + \value TrackCount The number of tracks on the album containing the media. int. + + \value CoverArtUrlSmall The URL of a small cover art image. QUrl. + \value CoverArtUrlLarge The URL of a large cover art image. QUrl. + \value CoverArtImage An embedded cover art image. QImage. + + Image and video attributes + \value Resolution The dimensions of an image or video. QSize. + \value PixelAspectRatio The pixel aspect ratio of an image or video. QSize. + + Video attributes + \value VideoFrameRate The frame rate of the media's video stream. qreal. + \value VideoBitRate The bit rate of the media's video stream in bits per second. int. + \value VideoCodec The codec of the media's video stream. QString. + + \value PosterUrl The URL of a poster image. QUrl. + \value PosterImage An embedded poster image. QImage. + + Movie attributes + \value ChapterNumber The chapter number of the media. int. + \value Director The director of the media. QString. + \value LeadPerformer The lead performer in the media. QStringList. + \value Writer The writer of the media. QStringList. + + Photo attributes. + \value CameraManufacturer The manufacturer of the camera used to capture the media. QString. + \value CameraModel The model of the camera used to capture the media. QString. + \value Event The event during which the media was captured. QString. + \value Subject The subject of the media. QString. + \value Orientation Orientation of image. + \value ExposureTime Exposure time, given in seconds. + \value FNumber The F Number. + \value ExposureProgram + The class of the program used by the camera to set exposure when the picture is taken. + \value ISOSpeedRatings + Indicates the ISO Speed and ISO Latitude of the camera or input device as specified in ISO 12232. + \value ExposureBiasValue + The exposure bias. + The unit is the APEX (Additive System of Photographic Exposure) setting. + \value DateTimeOriginal The date and time when the original image data was generated. + \value DateTimeDigitized The date and time when the image was stored as digital data. + \value SubjectDistance The distance to the subject, given in meters. + \value MeteringMode The metering mode. + \value LightSource + The kind of light source. + \value Flash + Status of flash when the image was shot. + \value FocalLength + The actual focal length of the lens, in mm. + \value ExposureMode + Indicates the exposure mode set when the image was shot. + \value WhiteBalance + Indicates the white balance mode set when the image was shot. + \value DigitalZoomRatio + Indicates the digital zoom ratio when the image was shot. + \value FocalLengthIn35mmFilm + Indicates the equivalent focal length assuming a 35mm film camera, in mm. + \value SceneCaptureType + Indicates the type of scene that was shot. + It can also be used to record the mode in which the image was shot. + \value GainControl + Indicates the degree of overall image gain adjustment. + \value Contrast + Indicates the direction of contrast processing applied by the camera when the image was shot. + \value Saturation + Indicates the direction of saturation processing applied by the camera when the image was shot. + \value Sharpness + Indicates the direction of sharpness processing applied by the camera when the image was shot. + \value DeviceSettingDescription + Exif tag, indicates information on the picture-taking conditions of a particular camera model. QString + + \value ThumbnailImage An embedded thumbnail image. QImage. +*/ + +/*! + \enum QtMultimedia::SupportEstimate + + Enumerates the levels of support a media service provider may have for a feature. + + \value NotSupported The feature is not supported. + \value MaybeSupported The feature may be supported. + \value ProbablySupported The feature is probably supported. + \value PreferredService The service is the preferred provider of a service. +*/ + +/*! + \enum QtMultimedia::EncodingQuality + + Enumerates quality encoding levels. + + \value VeryLowQuality + \value LowQuality + \value NormalQuality + \value HighQuality + \value VeryHighQuality +*/ + +/*! + \enum QtMultimedia::EncodingMode + + Enumerates encoding modes. + + \value ConstantQualityEncoding + \value ConstantBitRateEncoding + \value AverageBitRateEncoding + \value TwoPassEncoding +*/ + +/*! + \enum QtMultimedia::AvailabilityError + + Enumerates Service status errors. + + \value NoError The service is operating correctly. + \value ServiceMissingError There is no service available to provide the requested functionality. + \value ResourceError The service could not allocate resources required to function correctly. + \value BusyError The service must wait for access to necessary resources. +*/ diff --git a/src/multimedia/qtmultimediadefs.h b/src/multimedia/qtmultimediadefs.h new file mode 100644 index 000000000..313503929 --- /dev/null +++ b/src/multimedia/qtmultimediadefs.h @@ -0,0 +1,90 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +// +// 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. +// + +#ifndef QTMULTIMEDIA_P_H +#define QTMULTIMEDIA_P_H + +#include + +QT_BEGIN_HEADER + +#if defined(Q_OS_WIN) +# if defined(QT_NODLL) +# undef QT_MAKEDLL +# undef QT_DLL +# elif defined(QT_MAKEDLL) +# if defined(QT_DLL) +# undef QT_DLL +# endif +# if defined(QT_BUILD_MULTIMEDIA_LIB) +# define Q_MULTIMEDIA_EXPORT Q_DECL_EXPORT +# else +# define Q_MULTIMEDIA_EXPORT Q_DECL_IMPORT +# endif +# elif defined(QT_DLL) /* use a Qt DLL library */ +# define Q_MULTIMEDIA_EXPORT Q_DECL_IMPORT +# endif +#endif + +#if !defined(Q_MULTIMEDIA_EXPORT) +# if defined(QT_SHARED) +# define Q_MULTIMEDIA_EXPORT Q_DECL_EXPORT +# else +# define Q_MULTIMEDIA_EXPORT +# endif +#endif + +QT_END_HEADER + + +#endif // QMULTIMEDIA_P_H + diff --git a/src/multimedia/qvideodevicecontrol.cpp b/src/multimedia/qvideodevicecontrol.cpp new file mode 100644 index 000000000..a864fd580 --- /dev/null +++ b/src/multimedia/qvideodevicecontrol.cpp @@ -0,0 +1,159 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qvideodevicecontrol.h" + +QT_BEGIN_NAMESPACE + +/*! + \class QVideoDeviceControl + + \brief The QVideoDeviceControl class provides an video device selector media control. + \inmodule QtMultimedia + \ingroup multimedia-serv + \since 1.0 + + The QVideoDeviceControl class provides descriptions of the video devices + available on a system and allows one to be selected as the endpoint of a + media service. + + The interface name of QVideoDeviceControl is \c com.nokia.Qt.VideoDeviceControl as + defined in QVideoDeviceControl_iid. +*/ + +/*! + \macro QVideoDeviceControl_iid + + \c com.nokia.Qt.VideoDeviceControl + + Defines the interface name of the QVideoDeviceControl class. + + \relates QVideoDeviceControl +*/ + +/*! + Constructs a video device control with the given \a parent. +*/ +QVideoDeviceControl::QVideoDeviceControl(QObject *parent) + :QMediaControl(parent) +{ +} + +/*! + Destroys a video device control. +*/ +QVideoDeviceControl::~QVideoDeviceControl() +{ +} + +/*! + \fn QVideoDeviceControl::deviceCount() const + + Returns the number of available video devices; + \since 1.0 +*/ + +/*! + \fn QVideoDeviceControl::deviceName(int index) const + + Returns the name of the video device at \a index. + \since 1.0 +*/ + +/*! + \fn QVideoDeviceControl::deviceDescription(int index) const + + Returns a description of the video device at \a index. + \since 1.0 +*/ + +/*! + \fn QVideoDeviceControl::deviceIcon(int index) const + + Returns an icon for the video device at \a index. + \since 1.0 +*/ + +/*! + \fn QVideoDeviceControl::defaultDevice() const + + Returns the index of the default video device. + \since 1.0 +*/ + +/*! + \fn QVideoDeviceControl::selectedDevice() const + + Returns the index of the selected video device. + \since 1.0 +*/ + +/*! + \fn QVideoDeviceControl::setSelectedDevice(int index) + + Sets the selected video device \a index. + \since 1.0 +*/ + +/*! + \fn QVideoDeviceControl::devicesChanged() + + Signals that the list of available video devices has changed. + \since 1.0 +*/ + +/*! + \fn QVideoDeviceControl::selectedDeviceChanged(int index) + + Signals that the selected video device \a index has changed. + \since 1.0 +*/ + +/*! + \fn QVideoDeviceControl::selectedDeviceChanged(const QString &name) + + Signals that the selected video device \a name has changed. + \since 1.0 +*/ + +#include "moc_qvideodevicecontrol.cpp" +QT_END_NAMESPACE + diff --git a/src/multimedia/qvideodevicecontrol.h b/src/multimedia/qvideodevicecontrol.h new file mode 100644 index 000000000..6f44c4671 --- /dev/null +++ b/src/multimedia/qvideodevicecontrol.h @@ -0,0 +1,88 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QVIDEODEVICECONTROL_H +#define QVIDEODEVICECONTROL_H + +#include "qmediacontrol.h" + +QT_BEGIN_HEADER + +QT_BEGIN_NAMESPACE + +QT_MODULE(Multimedia) + +class Q_MULTIMEDIA_EXPORT QVideoDeviceControl : public QMediaControl +{ + Q_OBJECT + +public: + virtual ~QVideoDeviceControl(); + + virtual int deviceCount() const = 0; + + virtual QString deviceName(int index) const = 0; + virtual QString deviceDescription(int index) const = 0; + virtual QIcon deviceIcon(int index) const = 0; + + virtual int defaultDevice() const = 0; + virtual int selectedDevice() const = 0; + +public Q_SLOTS: + virtual void setSelectedDevice(int index) = 0; + +Q_SIGNALS: + void selectedDeviceChanged(int index); + void selectedDeviceChanged(const QString &deviceName); + void devicesChanged(); + +protected: + QVideoDeviceControl(QObject *parent = 0); +}; + +#define QVideoDeviceControl_iid "com.nokia.Qt.QVideoDeviceControl/1.0" +Q_MEDIA_DECLARE_CONTROL(QVideoDeviceControl, QVideoDeviceControl_iid) + +QT_END_NAMESPACE + +QT_END_HEADER + +#endif // QVIDEODEVICECONTROL_H diff --git a/src/multimedia/qvideoencodercontrol.cpp b/src/multimedia/qvideoencodercontrol.cpp new file mode 100644 index 000000000..1551f2cf7 --- /dev/null +++ b/src/multimedia/qvideoencodercontrol.cpp @@ -0,0 +1,190 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qvideoencodercontrol.h" +#include +#include + +QT_BEGIN_NAMESPACE + +/*! + \class QVideoEncoderControl + + \inmodule QtMultimedia + \ingroup multimedia-serv + \since 1.0 + + \brief The QVideoEncoderControl class provides access to the settings + of a media service that performs video encoding. + + If a QMediaService supports encoding video data it will implement + QVideoEncoderControl. This control provides information about the limits + of restricted video encoder options and allows the selection of a set of + video encoder settings as specified in a QVideoEncoderSettings object. + + The functionality provided by this control is exposed to application code + through the QMediaRecorder class. + + The interface name of QVideoEncoderControl is \c com.nokia.Qt.QVideoEncoderControl/1.0 as + defined in QVideoEncoderControl_iid. + + \sa QMediaRecorder, QVideoEncoderSettings, QMediaService::requestControl() +*/ + +/*! + \macro QVideoEncoderControl_iid + + \c com.nokia.Qt.QVideoEncoderControl/1.0 + + Defines the interface name of the QVideoEncoderControl class. + + \relates QVideoEncoderControl +*/ + +/*! + Create a new video encoder control object with the given \a parent. +*/ +QVideoEncoderControl::QVideoEncoderControl(QObject *parent) + :QMediaControl(parent) +{ +} + +/*! + Destroys a video encoder control. +*/ +QVideoEncoderControl::~QVideoEncoderControl() +{ +} + +/*! + \fn QVideoEncoderControl::supportedVideoCodecs() const + + Returns the list of supported video codecs. + \since 1.0 +*/ + +/*! + \fn QVideoEncoderControl::videoCodecDescription(const QString &codec) const + + Returns a description of a video \a codec. + \since 1.0 +*/ + +/*! + \fn QVideoEncoderControl::supportedEncodingOptions(const QString &codec) const + + Returns a list of supported encoding options for a video \a codec. + + The names and types of the options in the list is system dependent. + \since 1.0 +*/ + +/*! + \fn QVideoEncoderControl::encodingOption(const QString &codec, const QString &option) const + + Returns the value of a video \a codec \a option. + \since 1.0 +*/ + +/*! + \fn QVideoEncoderControl::setEncodingOption(const QString &codec, const QString &option, const QVariant &value) + + Sets the \a value of a \a codec specific \a option. + \since 1.0 +*/ + +/*! + \fn QVideoEncoderControl::supportedResolutions(const QVideoEncoderSettings &settings = QVideoEncoderSettings(), + bool *continuous = 0) const + + Returns a list of supported resolutions. + + If non null video \a settings parameter is passed, + the returned list is reduced to resolution supported with partial settings like + \l {QVideoEncoderSettings::setCodec()}{video codec} or + \l {QVideoEncoderSettings::setFrameRate()}{frame rate} applied. + + If the encoder supports arbitrary resolutions within the supported resolutions range, + *\a continuous is set to true, otherwise *\a continuous is set to false. + + \since 1.0 + \sa QVideoEncoderSettings::resolution() +*/ + +/*! + \fn QVideoEncoderControl::supportedFrameRates(const QVideoEncoderSettings &settings = QVideoEncoderSettings(), + bool *continuous = 0) const + + Returns a list of supported frame rates. + + If non null video \a settings parameter is passed, + the returned list is reduced to frame rates supported with partial settings like + \l {QVideoEncoderSettings::setCodec()}{video codec} or + \l {QVideoEncoderSettings::setResolution()}{video resolution} applied. + + If the encoder supports arbitrary frame rates within the supported range, + *\a continuous is set to true, otherwise *\a continuous is set to false. + + \since 1.0 + \sa QVideoEncoderSettings::frameRate() +*/ + +/*! + \fn QVideoEncoderControl::videoSettings() const + + Returns the video encoder settings. + + The returned value may be different tha passed to QVideoEncoderControl::setVideoSettings() + if the settings contains the default or undefined parameters. + In this case if the undefined parameters are already resolved, they should be returned. + \since 1.0 +*/ + +/*! + \fn QVideoEncoderControl::setVideoSettings(const QVideoEncoderSettings &settings) + + Sets the selected video encoder \a settings. + \since 1.0 +*/ + +#include "moc_qvideoencodercontrol.cpp" +QT_END_NAMESPACE + diff --git a/src/multimedia/qvideoencodercontrol.h b/src/multimedia/qvideoencodercontrol.h new file mode 100644 index 000000000..343af8039 --- /dev/null +++ b/src/multimedia/qvideoencodercontrol.h @@ -0,0 +1,98 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QVIDEOENCODERCONTROL_H +#define QVIDEOENCODERCONTROL_H + +#include "qmediacontrol.h" +#include "qmediarecorder.h" + +#include +#include + +QT_BEGIN_HEADER + +QT_BEGIN_NAMESPACE + +QT_MODULE(Multimedia) + +class QByteArray; +class QStringList; +QT_END_NAMESPACE + +QT_BEGIN_NAMESPACE + +class Q_MULTIMEDIA_EXPORT QVideoEncoderControl : public QMediaControl +{ + Q_OBJECT + +public: + virtual ~QVideoEncoderControl(); + + virtual QList supportedResolutions(const QVideoEncoderSettings &settings, + bool *continuous = 0) const = 0; + + virtual QList supportedFrameRates(const QVideoEncoderSettings &settings, + bool *continuous = 0) const = 0; + + virtual QStringList supportedVideoCodecs() const = 0; + virtual QString videoCodecDescription(const QString &codecName) const = 0; + + virtual QVideoEncoderSettings videoSettings() const = 0; + virtual void setVideoSettings(const QVideoEncoderSettings &settings) = 0; + + virtual QStringList supportedEncodingOptions(const QString &codec) const = 0; + virtual QVariant encodingOption(const QString &codec, const QString &name) const = 0; + virtual void setEncodingOption(const QString &codec, const QString &name, const QVariant &value) = 0; + +protected: + QVideoEncoderControl(QObject *parent = 0); +}; + +#define QVideoEncoderControl_iid "com.nokia.Qt.QVideoEncoderControl/1.0" +Q_MEDIA_DECLARE_CONTROL(QVideoEncoderControl, QVideoEncoderControl_iid) + +QT_END_NAMESPACE + +QT_END_HEADER + + +#endif diff --git a/src/multimedia/qvideorenderercontrol.cpp b/src/multimedia/qvideorenderercontrol.cpp new file mode 100644 index 000000000..99142261a --- /dev/null +++ b/src/multimedia/qvideorenderercontrol.cpp @@ -0,0 +1,114 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qvideorenderercontrol.h" + +#include "qmediacontrol_p.h" + +QT_BEGIN_NAMESPACE + +/*! + \class QVideoRendererControl + + + \brief The QVideoRendererControl class provides a control for rendering + to a video surface. + + \inmodule QtMultimedia + \ingroup multimedia-serv + \since 1.0 + + Using the surface() property of QVideoRendererControl a + QAbstractVideoSurface may be set as the video render target of a + QMediaService. + + \snippet doc/src/snippets/multimedia-snippets/video.cpp Video renderer control + + QVideoRendererControl is one of a number of possible video output controls. + + The interface name of QVideoRendererControl is \c com.nokia.Qt.QVideoRendererControl/1.0 as + defined in QVideoRendererControl_iid. + + \sa QMediaService::requestControl(), QVideoWidget +*/ + +/*! + \macro QVideoRendererControl_iid + + \c com.nokia.Qt.QVideoRendererControl/1.0 + + Defines the interface name of the QVideoRendererControl class. + + \relates QVideoRendererControl +*/ + +/*! + Constructs a new video renderer media end point with the given \a parent. +*/ +QVideoRendererControl::QVideoRendererControl(QObject *parent) + : QMediaControl(parent) +{ +} + +/*! + Destroys a video renderer media end point. +*/ +QVideoRendererControl::~QVideoRendererControl() +{ +} + +/*! + \fn QVideoRendererControl::surface() const + + Returns the surface a video producer renders to. + \since 1.0 +*/ + +/*! + \fn QVideoRendererControl::setSurface(QAbstractVideoSurface *surface) + + Sets the \a surface a video producer renders to. + \since 1.0 +*/ + +#include "moc_qvideorenderercontrol.cpp" +QT_END_NAMESPACE + diff --git a/src/multimedia/qvideorenderercontrol.h b/src/multimedia/qvideorenderercontrol.h new file mode 100644 index 000000000..b3a70837c --- /dev/null +++ b/src/multimedia/qvideorenderercontrol.h @@ -0,0 +1,81 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QVIDEORENDERERCONTROL_H +#define QVIDEORENDERERCONTROL_H + +#include "qmediacontrol.h" + +QT_BEGIN_HEADER + +QT_BEGIN_NAMESPACE + +QT_MODULE(Multimedia) + +class QAbstractVideoSurface; +QT_END_NAMESPACE + +QT_BEGIN_NAMESPACE + + +class Q_MULTIMEDIA_EXPORT QVideoRendererControl : public QMediaControl +{ + Q_OBJECT + +public: + ~QVideoRendererControl(); + + virtual QAbstractVideoSurface *surface() const = 0; + virtual void setSurface(QAbstractVideoSurface *surface) = 0; + +protected: + QVideoRendererControl(QObject *parent = 0); +}; + +#define QVideoRendererControl_iid "com.nokia.Qt.QVideoRendererControl/1.0" +Q_MEDIA_DECLARE_CONTROL(QVideoRendererControl, QVideoRendererControl_iid) + +QT_END_NAMESPACE + +QT_END_HEADER + + +#endif // QVIDEORENDERERCONTROL_H diff --git a/src/multimedia/qvideosurfaceoutput.cpp b/src/multimedia/qvideosurfaceoutput.cpp new file mode 100644 index 000000000..cdbec5596 --- /dev/null +++ b/src/multimedia/qvideosurfaceoutput.cpp @@ -0,0 +1,100 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qvideosurfaceoutput_p.h" + +#include +#include +#include + + +QVideoSurfaceOutput::QVideoSurfaceOutput(QObject*parent) + : QObject(parent) +{ +} + +QVideoSurfaceOutput::~QVideoSurfaceOutput() +{ + if (m_control) { + m_control.data()->setSurface(0); + m_service.data()->releaseControl(m_control.data()); + } +} + +QMediaObject *QVideoSurfaceOutput::mediaObject() const +{ + return m_object.data(); +} + +void QVideoSurfaceOutput::setVideoSurface(QAbstractVideoSurface *surface) +{ + m_surface = surface; + + if (m_control) + m_control.data()->setSurface(surface); +} + +bool QVideoSurfaceOutput::setMediaObject(QMediaObject *object) +{ + if (m_control) { + m_control.data()->setSurface(0); + m_service.data()->releaseControl(m_control.data()); + } + m_control.clear(); + m_service.clear(); + m_object.clear(); + + if (object) { + if (QMediaService *service = object->service()) { + if (QMediaControl *control = service->requestControl(QVideoRendererControl_iid)) { + if ((m_control = qobject_cast(control))) { + m_service = service; + m_object = object; + m_control.data()->setSurface(m_surface.data()); + + return true; + } + service->releaseControl(control); + } + } + } + return false; +} diff --git a/src/multimedia/qvideosurfaceoutput_p.h b/src/multimedia/qvideosurfaceoutput_p.h new file mode 100644 index 000000000..76ec5e84d --- /dev/null +++ b/src/multimedia/qvideosurfaceoutput_p.h @@ -0,0 +1,86 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QVIDEOSURFACEOUTPUT_P_H +#define QVIDEOSURFACEOUTPUT_P_H + +#include + +#include + +QT_BEGIN_HEADER + +QT_BEGIN_NAMESPACE + +QT_MODULE(Multimedia) + + +class QAbstractVideoSurface; +class QVideoRendererControl; + +class QVideoSurfaceOutput : public QObject, public QMediaBindableInterface +{ + Q_OBJECT + Q_INTERFACES(QMediaBindableInterface) +public: + QVideoSurfaceOutput(QObject*parent = 0); + ~QVideoSurfaceOutput(); + + QMediaObject *mediaObject() const; + + void setVideoSurface(QAbstractVideoSurface *surface); + +protected: + bool setMediaObject(QMediaObject *object); + +private: + QWeakPointer m_surface; + QWeakPointer m_control; + QWeakPointer m_service; + QWeakPointer m_object; +}; + +QT_END_NAMESPACE + +QT_END_HEADER + + +#endif diff --git a/src/multimedia/video/qabstractvideobuffer.cpp b/src/multimedia/video/qabstractvideobuffer.cpp new file mode 100644 index 000000000..6480bc850 --- /dev/null +++ b/src/multimedia/video/qabstractvideobuffer.cpp @@ -0,0 +1,202 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qabstractvideobuffer_p.h" + +#include + +QT_BEGIN_NAMESPACE + +/*! + \class QAbstractVideoBuffer + \brief The QAbstractVideoBuffer class is an abstraction for video data. + \since 1.0 + \inmodule QtMultimedia + + The QVideoFrame class makes use of a QAbstractVideoBuffer internally to reference a buffer of + video data. Creating a subclass of QAbstractVideoBuffer will allow you to construct video + frames from preallocated or static buffers. + + The contents of a buffer can be accessed by mapping the buffer to memory using the map() + function which returns a pointer to memory containing the contents of the the video buffer. + The memory returned by map() is released by calling the unmap() function. + + The handle() of a buffer may also be used to manipulate its contents using type specific APIs. + The type of a buffer's handle is given by the handleType() function. + + \sa QVideoFrame +*/ + +/*! + \enum QAbstractVideoBuffer::HandleType + + Identifies the type of a video buffers handle. + + \value NoHandle The buffer has no handle, its data can only be accessed by mapping the buffer. + \value GLTextureHandle The handle of the buffer is an OpenGL texture ID. + \value XvShmImageHandle The handle contains pointer to shared memory XVideo image. + \value CoreImageHandle The handle contains pointer to Mac OS X CIImage. + \value QPixmapHandle The handle of the buffer is a QPixmap. + \value UserHandle Start value for user defined handle types. + + \sa handleType() +*/ + +/*! + \enum QAbstractVideoBuffer::MapMode + + Enumerates how a video buffer's data is mapped to memory. + + \value NotMapped The video buffer has is not mapped to memory. + \value ReadOnly The mapped memory is populated with data from the video buffer when mapped, but + the content of the mapped memory may be discarded when unmapped. + \value WriteOnly The mapped memory is uninitialized when mapped, and the content will be used to + populate the video buffer when unmapped. + \value ReadWrite The mapped memory is populated with data from the video buffer, and the + video buffer is repopulated with the content of the mapped memory. + + \sa mapMode(), map() +*/ + +/*! + Constructs an abstract video buffer of the given \a type. +*/ +QAbstractVideoBuffer::QAbstractVideoBuffer(HandleType type) + : d_ptr(new QAbstractVideoBufferPrivate) +{ + Q_D(QAbstractVideoBuffer); + + d->handleType = type; +} + +/*! + \internal +*/ +QAbstractVideoBuffer::QAbstractVideoBuffer(QAbstractVideoBufferPrivate &dd, HandleType type) + : d_ptr(&dd) +{ + Q_D(QAbstractVideoBuffer); + + d->handleType = type; +} + +/*! + Destroys an abstract video buffer. +*/ +QAbstractVideoBuffer::~QAbstractVideoBuffer() +{ + delete d_ptr; +} + +/*! + Returns the type of a video buffer's handle. + + \since 1.0 + \sa handle() +*/ +QAbstractVideoBuffer::HandleType QAbstractVideoBuffer::handleType() const +{ + return d_func()->handleType; +} + +/*! + \fn QAbstractVideoBuffer::mapMode() const + + Returns the mode a video buffer is mapped in. + + \since 1.0 + \sa map() +*/ + +/*! + \fn QAbstractVideoBuffer::map(MapMode mode, int *numBytes, int *bytesPerLine) + + Maps the contents of a video buffer to memory. + + The map \a mode indicates whether the contents of the mapped memory should be read from and/or + written to the buffer. If the map mode includes the QAbstractVideoBuffer::ReadOnly flag the + mapped memory will be populated with the content of the video buffer when mapped. If the map + mode includes the QAbstractVideoBuffer::WriteOnly flag the content of the mapped memory will be + persisted in the buffer when unmapped. + + When access to the data is no longer needed be sure to call the unmap() function to release the + mapped memory. + + Returns a pointer to the mapped memory region, or a null pointer if the mapping failed. The + size in bytes of the mapped memory region is returned in \a numBytes, and the line stride in \a + bytesPerLine. + + When access to the data is no longer needed be sure to unmap() the buffer. + + \note Writing to memory that is mapped as read-only is undefined, and may result in changes + to shared data. + + \since 1.0 + \sa unmap(), mapMode() +*/ + +/*! + \fn QAbstractVideoBuffer::unmap() + + Releases the memory mapped by the map() function + + If the \l {QAbstractVideoBuffer::MapMode}{MapMode} included the QAbstractVideoBuffer::WriteOnly + flag this will persist the current content of the mapped memory to the video frame. + + \since 1.0 + \sa map() +*/ + +/*! + Returns a type specific handle to the data buffer. + + The type of the handle is given by handleType() function. + + \since 1.0 + \sa handleType() +*/ +QVariant QAbstractVideoBuffer::handle() const +{ + return QVariant(); +} + + +QT_END_NAMESPACE diff --git a/src/multimedia/video/qabstractvideobuffer.h b/src/multimedia/video/qabstractvideobuffer.h new file mode 100644 index 000000000..2c66dfd65 --- /dev/null +++ b/src/multimedia/video/qabstractvideobuffer.h @@ -0,0 +1,112 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QABSTRACTVIDEOBUFFER_H +#define QABSTRACTVIDEOBUFFER_H + +#include +#include + + +#include + +QT_BEGIN_HEADER + +QT_BEGIN_NAMESPACE + +QT_MODULE(Multimedia) + + +class QVariant; + +class QAbstractVideoBufferPrivate; + +class Q_MULTIMEDIA_EXPORT QAbstractVideoBuffer +{ +public: + enum HandleType + { + NoHandle, + GLTextureHandle, + XvShmImageHandle, + CoreImageHandle, + QPixmapHandle, + UserHandle = 1000 + }; + + enum MapMode + { + NotMapped = 0x00, + ReadOnly = 0x01, + WriteOnly = 0x02, + ReadWrite = ReadOnly | WriteOnly + }; + + QAbstractVideoBuffer(HandleType type); + virtual ~QAbstractVideoBuffer(); + + HandleType handleType() const; + + virtual MapMode mapMode() const = 0; + + virtual uchar *map(MapMode mode, int *numBytes, int *bytesPerLine) = 0; + virtual void unmap() = 0; + + virtual QVariant handle() const; + +protected: + QAbstractVideoBuffer(QAbstractVideoBufferPrivate &dd, HandleType type); + + QAbstractVideoBufferPrivate *d_ptr; + +private: + Q_DECLARE_PRIVATE(QAbstractVideoBuffer) + Q_DISABLE_COPY(QAbstractVideoBuffer) +}; + +QT_END_NAMESPACE + +Q_DECLARE_METATYPE(QAbstractVideoBuffer::HandleType) +Q_DECLARE_METATYPE(QAbstractVideoBuffer::MapMode) + +QT_END_HEADER + +#endif diff --git a/src/multimedia/video/qabstractvideobuffer_p.h b/src/multimedia/video/qabstractvideobuffer_p.h new file mode 100644 index 000000000..b808e5d91 --- /dev/null +++ b/src/multimedia/video/qabstractvideobuffer_p.h @@ -0,0 +1,88 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QABSTRACTVIDEOBUFFER_P_H +#define QABSTRACTVIDEOBUFFER_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 +#include "qabstractvideobuffer.h" + +#include +#include + + +QT_BEGIN_HEADER + +QT_BEGIN_NAMESPACE + +QT_MODULE(Multimedia) + + +class QAbstractVideoBufferPrivate +{ +public: + QAbstractVideoBufferPrivate() + : handleType(QAbstractVideoBuffer::NoHandle) + {} + + virtual ~QAbstractVideoBufferPrivate() + {} + + QAbstractVideoBuffer::HandleType handleType; +}; + +QT_END_NAMESPACE + +QT_END_HEADER + + +#endif diff --git a/src/multimedia/video/qabstractvideosurface.cpp b/src/multimedia/video/qabstractvideosurface.cpp new file mode 100644 index 000000000..4d65d7eaa --- /dev/null +++ b/src/multimedia/video/qabstractvideosurface.cpp @@ -0,0 +1,340 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +//TESTED_COMPONENT=src/multimedia + +#include "qabstractvideosurface.h" + +#include "qvideosurfaceformat.h" + +#include + +QT_BEGIN_NAMESPACE + +Q_DECLARE_METATYPE(QVideoSurfaceFormat) +Q_DECLARE_METATYPE(QAbstractVideoSurface::Error) + +/*! + \class QAbstractVideoSurface + \brief The QAbstractVideoSurface class is a base class for video presentation surfaces. + \since 1.0 + \inmodule QtMultimedia + + A video surface presents a continuous stream of identically formatted frames, where the format + of each frame is compatible with a stream format supplied when starting a presentation. + + The QAbstractVideoSurface class defines the standard interface that video producers use to + inter-operate with video presentation surfaces. It is not supposed to be instantiated directly. + Instead, you should subclass it to create new video surfaces. + + A list of pixel formats a surface can present is given by the supportedPixelFormats() function, + and the isFormatSupported() function will test if a video surface format is supported. If a + format is not supported the nearestFormat() function may be able to suggest a similar format. + For example, if a surface supports fixed set of resolutions it may suggest the smallest + supported resolution that contains the proposed resolution. + + The start() function takes a supported format and enables a video surface. Once started a + surface will begin displaying the frames it receives in the present() function. Surfaces may + hold a reference to the buffer of a presented video frame until a new frame is presented or + streaming is stopped. The stop() function will disable a surface and a release any video + buffers it holds references to. +*/ + +/*! + \enum QAbstractVideoSurface::Error + This enum describes the errors that may be returned by the error() function. + + \value NoError No error occurred. + \value UnsupportedFormatError A video format was not supported. + \value IncorrectFormatError A video frame was not compatible with the format of the surface. + \value StoppedError The surface has not been started. + \value ResourceError The surface could not allocate some resource. +*/ + +/*! + Constructs a video surface with the given \a parent. +*/ +QAbstractVideoSurface::QAbstractVideoSurface(QObject *parent) + : QObject(parent) +{ + setProperty("_q_surfaceFormat", QVariant::fromValue(QVideoSurfaceFormat())); + setProperty("_q_active", false); + setProperty("_q_error", QVariant::fromValue(QAbstractVideoSurface::NoError)); + setProperty("_q_nativeResolution", QSize()); +} + +// XXX Qt5 +/*! + \internal + + This is deprecated. + + Since we need to build without access to Qt's private headers we can't reliably inherit + from QObjectPrivate. Binary compatibility means we can't remove this constructor or + add a d pointer to QAbstractVideoSurface. +*/ +QAbstractVideoSurface::QAbstractVideoSurface(QAbstractVideoSurfacePrivate &, QObject *parent) + : QObject(parent) +{ +} + +/*! + Destroys a video surface. +*/ +QAbstractVideoSurface::~QAbstractVideoSurface() +{ +} + +/*! + \fn QAbstractVideoSurface::supportedPixelFormats(QAbstractVideoBuffer::HandleType type) const + + Returns a list of pixel formats a video surface can present for a given handle \a type. + + The pixel formats returned for the QAbstractVideoBuffer::NoHandle type are valid for any buffer + that can be mapped in read-only mode. + + Types that are first in the list can be assumed to be faster to render. + \since 1.0 +*/ + +/*! + Tests a video surface \a format to determine if a surface can accept it. + + Returns true if the format is supported by the surface, and false otherwise. + \since 1.0 +*/ +bool QAbstractVideoSurface::isFormatSupported(const QVideoSurfaceFormat &format) const +{ + return supportedPixelFormats(format.handleType()).contains(format.pixelFormat()); +} + +/*! + Returns a supported video surface format that is similar to \a format. + + A similar surface format is one that has the same \l {QVideoSurfaceFormat::pixelFormat()}{pixel + format} and \l {QVideoSurfaceFormat::handleType()}{handle type} but may differ in some of the other + properties. For example, if there are restrictions on the \l {QVideoSurfaceFormat::frameSize()} + {frame sizes} a video surface can accept it may suggest a format with a larger frame size and + a \l {QVideoSurfaceFormat::viewport()}{viewport} the size of the original frame size. + + If the format is already supported it will be returned unchanged, or if there is no similar + supported format an invalid format will be returned. + \since 1.0 +*/ +QVideoSurfaceFormat QAbstractVideoSurface::nearestFormat(const QVideoSurfaceFormat &format) const +{ + return isFormatSupported(format) + ? format + : QVideoSurfaceFormat(); +} + +/*! + \fn QAbstractVideoSurface::supportedFormatsChanged() + + Signals that the set of formats supported by a video surface has changed. + + \since 1.0 + \sa supportedPixelFormats(), isFormatSupported() +*/ + +/*! + Returns the format of a video surface. + \since 1.0 +*/ +QVideoSurfaceFormat QAbstractVideoSurface::surfaceFormat() const +{ + return property("_q_format").value(); +} + +/*! + \fn QAbstractVideoSurface::surfaceFormatChanged(const QVideoSurfaceFormat &format) + + Signals that the configured \a format of a video surface has changed. + + \since 1.0 + \sa surfaceFormat(), start() +*/ + +/*! + Starts a video surface presenting \a format frames. + + Returns true if the surface was started, and false if an error occurred. + + \since 1.0 + \sa isActive(), stop() +*/ +bool QAbstractVideoSurface::start(const QVideoSurfaceFormat &format) +{ + bool wasActive = property("_q_active").toBool(); + + setProperty("_q_active", true); + setProperty("_q_format", QVariant::fromValue(format)); + setProperty("_q_error", QVariant::fromValue(NoError)); + + emit surfaceFormatChanged(format); + + if (!wasActive) + emit activeChanged(true); + + return true; +} + +/*! + Stops a video surface presenting frames and releases any resources acquired in start(). + + \since 1.0 + \sa isActive(), start() +*/ +void QAbstractVideoSurface::stop() +{ + if (property("_q_active").toBool()) { + setProperty("_q_format", QVariant::fromValue(QVideoSurfaceFormat())); + setProperty("_q_active", false); + + emit activeChanged(false); + emit surfaceFormatChanged(surfaceFormat()); + } +} + +/*! + Indicates whether a video surface has been started. + + Returns true if the surface has been started, and false otherwise. + \since 1.0 +*/ +bool QAbstractVideoSurface::isActive() const +{ + return property("_q_active").toBool(); +} + +/*! + \fn QAbstractVideoSurface::activeChanged(bool active) + + Signals that the \a active state of a video surface has changed. + + \since 1.0 + \sa isActive(), start(), stop() +*/ + +/*! + \fn QAbstractVideoSurface::present(const QVideoFrame &frame) + + Presents a video \a frame. + + Returns true if the frame was presented, and false if an error occurred. + + Not all surfaces will block until the presentation of a frame has completed. Calling present() + on a non-blocking surface may fail if called before the presentation of a previous frame has + completed. In such cases the surface may not return to a ready state until it has had an + opportunity to process events. + + If present() fails for any other reason the surface will immediately enter the stopped state + and an error() value will be set. + + A video surface must be in the started state for present() to succeed, and the format of the + video frame must be compatible with the current video surface format. + + \since 1.0 + \sa error() +*/ + +/*! + Returns the last error that occurred. + + If a surface fails to start(), or stops unexpectedly this function can be called to discover + what error occurred. + \since 1.0 +*/ + +QAbstractVideoSurface::Error QAbstractVideoSurface::error() const +{ + return property("_q_error").value(); +} + +/*! + Sets the value of error() to \a error. + \since 1.0 +*/ +void QAbstractVideoSurface::setError(Error error) +{ + setProperty("_q_error", QVariant::fromValue(error)); +} + +/*! + \property QAbstractVideoSurface::nativeResolution + + The native resolution of video surface. + This is the resolution of video frames the surface + can render with optimal quality and/or performance. + + The native resolution is not always known and can be changed during playback. + \since 1.1 + */ +QSize QAbstractVideoSurface::nativeResolution() const +{ + return property("_q_nativeResolution").toSize(); +} + +/*! + Set the video surface native \a resolution. + \since 1.1 + */ +void QAbstractVideoSurface::setNativeResolution(const QSize &resolution) +{ + const QSize nativeResolution = property("_q_nativeResolution").toSize(); + + if (nativeResolution != resolution) { + setProperty("_q_nativeResolution", resolution); + + emit nativeResolutionChanged(resolution); + } +} +/*! + \fn QAbstractVideoSurface::nativeResolutionChanged(const QSize &resolution); + + Signals the native \a resolution of video surface has changed. + \since 1.1 +*/ + +QT_END_NAMESPACE + +#include "moc_qabstractvideosurface.cpp" + diff --git a/src/multimedia/video/qabstractvideosurface.h b/src/multimedia/video/qabstractvideosurface.h new file mode 100644 index 000000000..37c4d385f --- /dev/null +++ b/src/multimedia/video/qabstractvideosurface.h @@ -0,0 +1,115 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QABSTRACTVIDEOSURFACE_H +#define QABSTRACTVIDEOSURFACE_H + +#include +#include + +QT_BEGIN_HEADER + +QT_BEGIN_NAMESPACE + +QT_MODULE(Multimedia) + + +class QRectF; +class QVideoSurfaceFormat; + +class QAbstractVideoSurfacePrivate; + +class Q_MULTIMEDIA_EXPORT QAbstractVideoSurface : public QObject +{ + Q_OBJECT + Q_PROPERTY(QSize nativeResolution READ nativeResolution NOTIFY nativeResolutionChanged) +public: + enum Error + { + NoError, + UnsupportedFormatError, + IncorrectFormatError, + StoppedError, + ResourceError + }; + + explicit QAbstractVideoSurface(QObject *parent = 0); + ~QAbstractVideoSurface(); + + virtual QList supportedPixelFormats( + QAbstractVideoBuffer::HandleType handleType = QAbstractVideoBuffer::NoHandle) const = 0; + virtual bool isFormatSupported(const QVideoSurfaceFormat &format) const; + virtual QVideoSurfaceFormat nearestFormat(const QVideoSurfaceFormat &format) const; + + QVideoSurfaceFormat surfaceFormat() const; + + QSize nativeResolution() const; + + virtual bool start(const QVideoSurfaceFormat &format); + virtual void stop(); + + bool isActive() const; + + virtual bool present(const QVideoFrame &frame) = 0; + + Error error() const; + +Q_SIGNALS: + void activeChanged(bool active); + void surfaceFormatChanged(const QVideoSurfaceFormat &format); + void supportedFormatsChanged(); + void nativeResolutionChanged(const QSize &); + +protected: + QAbstractVideoSurface(QAbstractVideoSurfacePrivate &dd, QObject *parent); + + void setError(Error error); + void setNativeResolution(const QSize &resolution); + +private: + Q_DECLARE_PRIVATE(QAbstractVideoSurface) +}; + +QT_END_NAMESPACE + +QT_END_HEADER + +#endif diff --git a/src/multimedia/video/qimagevideobuffer.cpp b/src/multimedia/video/qimagevideobuffer.cpp new file mode 100644 index 000000000..e16abc30b --- /dev/null +++ b/src/multimedia/video/qimagevideobuffer.cpp @@ -0,0 +1,106 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qimagevideobuffer_p.h" + +#include "qabstractvideobuffer_p.h" + +#include +#include + +QT_BEGIN_NAMESPACE + +class QImageVideoBufferPrivate : public QAbstractVideoBufferPrivate +{ +public: + QImageVideoBufferPrivate() + : mapMode(QAbstractVideoBuffer::NotMapped) + { + } + + QAbstractVideoBuffer::MapMode mapMode; + QImage image; +}; + +QImageVideoBuffer::QImageVideoBuffer(const QImage &image) + : QAbstractVideoBuffer(*new QImageVideoBufferPrivate, NoHandle) +{ + Q_D(QImageVideoBuffer); + + d->image = image; +} + +QImageVideoBuffer::~QImageVideoBuffer() +{ +} + +QAbstractVideoBuffer::MapMode QImageVideoBuffer::mapMode() const +{ + return d_func()->mapMode; +} + +uchar *QImageVideoBuffer::map(MapMode mode, int *numBytes, int *bytesPerLine) +{ + Q_D(QImageVideoBuffer); + + if (d->mapMode == NotMapped && d->image.bits() && mode != NotMapped) { + d->mapMode = mode; + + if (numBytes) + *numBytes = d->image.byteCount(); + + if (bytesPerLine) + *bytesPerLine = d->image.bytesPerLine(); + + return d->image.bits(); + } else { + return 0; + } +} + +void QImageVideoBuffer::unmap() +{ + Q_D(QImageVideoBuffer); + + d->mapMode = NotMapped; +} + +QT_END_NAMESPACE diff --git a/src/multimedia/video/qimagevideobuffer_p.h b/src/multimedia/video/qimagevideobuffer_p.h new file mode 100644 index 000000000..dae952ed4 --- /dev/null +++ b/src/multimedia/video/qimagevideobuffer_p.h @@ -0,0 +1,87 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QIMAGEVIDEOBUFFER_P_H +#define QIMAGEVIDEOBUFFER_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 + +QT_BEGIN_HEADER + +QT_BEGIN_NAMESPACE + +QT_MODULE(Multimedia) + + +class QImage; + +class QImageVideoBufferPrivate; + +class Q_MULTIMEDIA_EXPORT QImageVideoBuffer : public QAbstractVideoBuffer +{ + Q_DECLARE_PRIVATE(QImageVideoBuffer) +public: + QImageVideoBuffer(const QImage &image); + ~QImageVideoBuffer(); + + MapMode mapMode() const; + + uchar *map(MapMode mode, int *numBytes, int *bytesPerLine); + void unmap(); +}; + +QT_END_NAMESPACE + +QT_END_HEADER + + +#endif diff --git a/src/multimedia/video/qmemoryvideobuffer.cpp b/src/multimedia/video/qmemoryvideobuffer.cpp new file mode 100644 index 000000000..d3516182a --- /dev/null +++ b/src/multimedia/video/qmemoryvideobuffer.cpp @@ -0,0 +1,132 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qmemoryvideobuffer_p.h" + +#include "qabstractvideobuffer_p.h" +#include + +QT_BEGIN_NAMESPACE + +class QMemoryVideoBufferPrivate : public QAbstractVideoBufferPrivate +{ +public: + QMemoryVideoBufferPrivate() + : bytesPerLine(0) + , mapMode(QAbstractVideoBuffer::NotMapped) + { + } + + int bytesPerLine; + QAbstractVideoBuffer::MapMode mapMode; + QByteArray data; +}; + +/*! + \class QMemoryVideoBuffer + \brief The QMemoryVideoBuffer class provides a system memory allocated video data buffer. + \internal + + QMemoryVideoBuffer is the default video buffer for allocating system memory. It may be used to + allocate memory for a QVideoFrame without implementing your own QAbstractVideoBuffer. +*/ + +/*! + Constructs a video buffer with an image stride of \a bytesPerLine from a byte \a array. +*/ +QMemoryVideoBuffer::QMemoryVideoBuffer(const QByteArray &array, int bytesPerLine) + : QAbstractVideoBuffer(*new QMemoryVideoBufferPrivate, NoHandle) +{ + Q_D(QMemoryVideoBuffer); + + d->data = array; + d->bytesPerLine = bytesPerLine; +} + +/*! + Destroys a system memory allocated video buffer. +*/ +QMemoryVideoBuffer::~QMemoryVideoBuffer() +{ +} + +/*! + \reimp + \since 1.1 +*/ +QAbstractVideoBuffer::MapMode QMemoryVideoBuffer::mapMode() const +{ + return d_func()->mapMode; +} + +/*! + \reimp + \since 1.1 +*/ +uchar *QMemoryVideoBuffer::map(MapMode mode, int *numBytes, int *bytesPerLine) +{ + Q_D(QMemoryVideoBuffer); + + if (d->mapMode == NotMapped && d->data.data() && mode != NotMapped) { + d->mapMode = mode; + + if (numBytes) + *numBytes = d->data.size(); + + if (bytesPerLine) + *bytesPerLine = d->bytesPerLine; + + return reinterpret_cast(d->data.data()); + } else { + return 0; + } +} + +/*! + \reimp + \since 1.1 +*/ +void QMemoryVideoBuffer::unmap() +{ + d_func()->mapMode = NotMapped; +} + +QT_END_NAMESPACE diff --git a/src/multimedia/video/qmemoryvideobuffer_p.h b/src/multimedia/video/qmemoryvideobuffer_p.h new file mode 100644 index 000000000..d5bc4e3c8 --- /dev/null +++ b/src/multimedia/video/qmemoryvideobuffer_p.h @@ -0,0 +1,89 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QMEMORYVIDEOBUFFER_P_H +#define QMEMORYVIDEOBUFFER_P_H + +#include + +// +// 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. +// + +QT_BEGIN_HEADER + +QT_BEGIN_HEADER + +QT_BEGIN_NAMESPACE + +QT_MODULE(Multimedia) + + +class QMemoryVideoBufferPrivate; + +class Q_MULTIMEDIA_EXPORT QMemoryVideoBuffer : public QAbstractVideoBuffer +{ + Q_DECLARE_PRIVATE(QMemoryVideoBuffer) +public: + QMemoryVideoBuffer(const QByteArray &data, int bytesPerLine); + ~QMemoryVideoBuffer(); + + MapMode mapMode() const; + + uchar *map(MapMode mode, int *numBytes, int *bytesPerLine); + void unmap(); +}; + +QT_END_NAMESPACE + +QT_END_HEADER + + +QT_END_HEADER + +#endif diff --git a/src/multimedia/video/qvideoframe.cpp b/src/multimedia/video/qvideoframe.cpp new file mode 100644 index 000000000..eaef644e9 --- /dev/null +++ b/src/multimedia/video/qvideoframe.cpp @@ -0,0 +1,776 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qvideoframe.h" + +#include "qimagevideobuffer_p.h" +#include "qmemoryvideobuffer_p.h" + +#include +#include +#include +#include +#include + +QT_BEGIN_NAMESPACE + +namespace +{ +class QVideoFramePrivateRegisterMetaTypes +{ +public: + QVideoFramePrivateRegisterMetaTypes() + { + qRegisterMetaType("QVideoFrame::PixelFormat"); + } +} _registerMetaTypes; +} + + +class QVideoFramePrivate : public QSharedData +{ +public: + QVideoFramePrivate() + : startTime(-1) + , endTime(-1) + , data(0) + , mappedBytes(0) + , bytesPerLine(0) + , pixelFormat(QVideoFrame::Format_Invalid) + , fieldType(QVideoFrame::ProgressiveFrame) + , buffer(0) + { + } + + QVideoFramePrivate(const QSize &size, QVideoFrame::PixelFormat format) + : size(size) + , startTime(-1) + , endTime(-1) + , data(0) + , mappedBytes(0) + , bytesPerLine(0) + , pixelFormat(format) + , fieldType(QVideoFrame::ProgressiveFrame) + , buffer(0) + { + } + + ~QVideoFramePrivate() + { + delete buffer; + } + + QSize size; + qint64 startTime; + qint64 endTime; + uchar *data; + int mappedBytes; + int bytesPerLine; + QVideoFrame::PixelFormat pixelFormat; + QVideoFrame::FieldType fieldType; + QAbstractVideoBuffer *buffer; + +private: + Q_DISABLE_COPY(QVideoFramePrivate) +}; + +/*! + \class QVideoFrame + \brief The QVideoFrame class provides a representation of a frame of video data. + \since 1.0 + \inmodule QtMultimedia + + A QVideoFrame encapsulates the data of a video frame, and information about the frame. + + The contents of a video frame can be mapped to memory using the map() function. While + mapped, the video data can accessed using the bits() function, which returns a pointer to a + buffer. The total size of this buffer is given by the mappedBytes() function, and the size of each line is given + by bytesPerLine(). The return value of the handle() function may be used to access frame data + using the internal buffer's native APIs. + + The video data in a QVideoFrame is encapsulated in a QAbstractVideoBuffer. A QVideoFrame + may be constructed from any buffer type by subclassing the QAbstractVideoBuffer class. + + \note QVideoFrame is explicitly shared, any change made to video frame will also apply to any + copies. +*/ + +/*! + \enum QVideoFrame::PixelFormat + + Enumerates video data types. + + \value Format_Invalid + The frame is invalid. + + \value Format_ARGB32 + The frame is stored using a 32-bit ARGB format (0xAARRGGBB). This is equivalent to + QImage::Format_ARGB32. + + \value Format_ARGB32_Premultiplied + The frame stored using a premultiplied 32-bit ARGB format (0xAARRGGBB). This is equivalent + to QImage::Format_ARGB32_Premultiplied. + + \value Format_RGB32 + The frame stored using a 32-bit RGB format (0xffRRGGBB). This is equivalent to + QImage::Format_RGB32 + + \value Format_RGB24 + The frame is stored using a 24-bit RGB format (8-8-8). This is equivalent to + QImage::Format_RGB888 + + \value Format_RGB565 + The frame is stored using a 16-bit RGB format (5-6-5). This is equivalent to + QImage::Format_RGB16. + + \value Format_RGB555 + The frame is stored using a 16-bit RGB format (5-5-5). This is equivalent to + QImage::Format_RGB555. + + \value Format_ARGB8565_Premultiplied + The frame is stored using a 24-bit premultiplied ARGB format (8-6-6-5). + + \value Format_BGRA32 + The frame is stored using a 32-bit ARGB format (0xBBGGRRAA). + + \value Format_BGRA32_Premultiplied + The frame is stored using a premultiplied 32bit BGRA format. + + \value Format_BGR32 + The frame is stored using a 32-bit BGR format (0xBBGGRRff). + + \value Format_BGR24 + The frame is stored using a 24-bit BGR format (0xBBGGRR). + + \value Format_BGR565 + The frame is stored using a 16-bit BGR format (5-6-5). + + \value Format_BGR555 + The frame is stored using a 16-bit BGR format (5-5-5). + + \value Format_BGRA5658_Premultiplied + The frame is stored using a 24-bit premultiplied BGRA format (5-6-5-8). + + \value Format_AYUV444 + The frame is stored using a packed 32-bit AYUV format (0xAAYYUUVV). + + \value Format_AYUV444_Premultiplied + The frame is stored using a packed premultiplied 32-bit AYUV format (0xAAYYUUVV). + + \value Format_YUV444 + The frame is stored using a 24-bit packed YUV format (8-8-8). + + \value Format_YUV420P + The frame is stored using an 8-bit per component planar YUV format with the U and V planes + horizontally and vertically sub-sampled, i.e. the height and width of the U and V planes are + half that of the Y plane. + + \value Format_YV12 + The frame is stored using an 8-bit per component planar YVU format with the V and U planes + horizontally and vertically sub-sampled, i.e. the height and width of the V and U planes are + half that of the Y plane. + + \value Format_UYVY + The frame is stored using an 8-bit per component packed YUV format with the U and V planes + horizontally sub-sampled (U-Y-V-Y), i.e. two horizontally adjacent pixels are stored as a 32-bit + macropixel which has a Y value for each pixel and common U and V values. + + \value Format_YUYV + The frame is stored using an 8-bit per component packed YUV format with the U and V planes + horizontally sub-sampled (Y-U-Y-V), i.e. two horizontally adjacent pixels are stored as a 32-bit + macropixel which has a Y value for each pixel and common U and V values. + + \value Format_NV12 + The frame is stored using an 8-bit per component semi-planar YUV format with a Y plane (Y) + followed by a horizontally and vertically sub-sampled, packed UV plane (U-V). + + \value Format_NV21 + The frame is stored using an 8-bit per component semi-planar YUV format with a Y plane (Y) + followed by a horizontally and vertically sub-sampled, packed VU plane (V-U). + + \value Format_IMC1 + The frame is stored using an 8-bit per component planar YUV format with the U and V planes + horizontally and vertically sub-sampled. This is similar to the Format_YUV420P type, except + that the bytes per line of the U and V planes are padded out to the same stride as the Y plane. + + \value Format_IMC2 + The frame is stored using an 8-bit per component planar YUV format with the U and V planes + horizontally and vertically sub-sampled. This is similar to the Format_YUV420P type, except + that the lines of the U and V planes are interleaved, i.e. each line of U data is followed by a + line of V data creating a single line of the same stride as the Y data. + + \value Format_IMC3 + The frame is stored using an 8-bit per component planar YVU format with the V and U planes + horizontally and vertically sub-sampled. This is similar to the Format_YV12 type, except that + the bytes per line of the V and U planes are padded out to the same stride as the Y plane. + + \value Format_IMC4 + The frame is stored using an 8-bit per component planar YVU format with the V and U planes + horizontally and vertically sub-sampled. This is similar to the Format_YV12 type, except that + the lines of the V and U planes are interleaved, i.e. each line of V data is followed by a line + of U data creating a single line of the same stride as the Y data. + + \value Format_Y8 + The frame is stored using an 8-bit greyscale format. + + \value Format_Y16 + The frame is stored using a 16-bit linear greyscale format. Little endian. + + \value Format_Jpeg + The frame is stored in compressed Jpeg format. + + \value Format_CameraRaw + The frame is stored using a device specific camera raw format. + + \value Format_AdobeDng + The frame is stored using raw Adobe Digital Negative (DNG) format. + + \value Format_User + Start value for user defined pixel formats. +*/ + +/*! + \enum QVideoFrame::FieldType + + Specifies the field an interlaced video frame belongs to. + + \value ProgressiveFrame The frame is not interlaced. + \value TopField The frame contains a top field. + \value BottomField The frame contains a bottom field. + \value InterlacedFrame The frame contains a merged top and bottom field. +*/ + +/*! + Constructs a null video frame. +*/ +QVideoFrame::QVideoFrame() + : d(new QVideoFramePrivate) +{ +} + +/*! + Constructs a video frame from a \a buffer with the given pixel \a format and \a size in pixels. + + \note This doesn't increment the reference count of the video buffer. + \since 1.0 +*/ +QVideoFrame::QVideoFrame( + QAbstractVideoBuffer *buffer, const QSize &size, PixelFormat format) + : d(new QVideoFramePrivate(size, format)) +{ + d->buffer = buffer; +} + +/*! + Constructs a video frame of the given pixel \a format and \a size in pixels. + + The \a bytesPerLine (stride) is the length of each scan line in bytes, and \a bytes is the total + number of bytes that must be allocated for the frame. + \since 1.0 +*/ +QVideoFrame::QVideoFrame(int bytes, const QSize &size, int bytesPerLine, PixelFormat format) + : d(new QVideoFramePrivate(size, format)) +{ + if (bytes > 0) { + QByteArray data; + data.resize(bytes); + + // Check the memory was successfully allocated. + if (!data.isEmpty()) + d->buffer = new QMemoryVideoBuffer(data, bytesPerLine); + } +} + +/*! + Constructs a video frame from an \a image. + + \note This will construct an invalid video frame if there is no frame type equivalent to the + image format. + + \since 1.0 + \sa pixelFormatFromImageFormat() +*/ +QVideoFrame::QVideoFrame(const QImage &image) + : d(new QVideoFramePrivate( + image.size(), pixelFormatFromImageFormat(image.format()))) +{ + if (d->pixelFormat != Format_Invalid) + d->buffer = new QImageVideoBuffer(image); +} + +/*! + Constructs a copy of \a other. + + \since 1.0 +*/ +QVideoFrame::QVideoFrame(const QVideoFrame &other) + : d(other.d) +{ +} + +/*! + Assigns the contents of \a other to a video frame. + \since 1.0 +*/ +QVideoFrame &QVideoFrame::operator =(const QVideoFrame &other) +{ + d = other.d; + + return *this; +} + +/*! + Destroys a video frame. +*/ +QVideoFrame::~QVideoFrame() +{ +} + +/*! + Identifies whether a video frame is valid. + + An invalid frame has no video buffer associated with it. + + Returns true if the frame is valid, and false if it is not. + \since 1.0 +*/ +bool QVideoFrame::isValid() const +{ + return d->buffer != 0; +} + +/*! + Returns the color format of a video frame. + \since 1.0 +*/ +QVideoFrame::PixelFormat QVideoFrame::pixelFormat() const +{ + return d->pixelFormat; +} + +/*! + Returns the type of a video frame's handle. + + \since 1.0 +*/ +QAbstractVideoBuffer::HandleType QVideoFrame::handleType() const +{ + return d->buffer ? d->buffer->handleType() : QAbstractVideoBuffer::NoHandle; +} + +/*! + Returns the dimensions of a video frame. + \since 1.0 +*/ +QSize QVideoFrame::size() const +{ + return d->size; +} + +/*! + Returns the width of a video frame. + \since 1.0 +*/ +int QVideoFrame::width() const +{ + return d->size.width(); +} + +/*! + Returns the height of a video frame. + \since 1.0 +*/ +int QVideoFrame::height() const +{ + return d->size.height(); +} + +/*! + Returns the field an interlaced video frame belongs to. + + If the video is not interlaced this will return WholeFrame. + \since 1.0 +*/ +QVideoFrame::FieldType QVideoFrame::fieldType() const +{ + return d->fieldType; +} + +/*! + Sets the \a field an interlaced video frame belongs to. + \since 1.0 +*/ +void QVideoFrame::setFieldType(QVideoFrame::FieldType field) +{ + d->fieldType = field; +} + +/*! + Identifies if a video frame's contents are currently mapped to system memory. + + This is a convenience function which checks that the \l {QAbstractVideoBuffer::MapMode}{MapMode} + of the frame is not equal to QAbstractVideoBuffer::NotMapped. + + Returns true if the contents of the video frame are mapped to system memory, and false + otherwise. + + \since 1.0 + \sa mapMode(), QAbstractVideoBuffer::MapMode +*/ + +bool QVideoFrame::isMapped() const +{ + return d->buffer != 0 && d->buffer->mapMode() != QAbstractVideoBuffer::NotMapped; +} + +/*! + Identifies if the mapped contents of a video frame will be persisted when the frame is unmapped. + + This is a convenience function which checks if the \l {QAbstractVideoBuffer::MapMode}{MapMode} + contains the QAbstractVideoBuffer::WriteOnly flag. + + Returns true if the video frame will be updated when unmapped, and false otherwise. + + \note The result of altering the data of a frame that is mapped in read-only mode is undefined. + Depending on the buffer implementation the changes may be persisted, or worse alter a shared + buffer. + + \since 1.0 + \sa mapMode(), QAbstractVideoBuffer::MapMode +*/ +bool QVideoFrame::isWritable() const +{ + return d->buffer != 0 && (d->buffer->mapMode() & QAbstractVideoBuffer::WriteOnly); +} + +/*! + Identifies if the mapped contents of a video frame were read from the frame when it was mapped. + + This is a convenience function which checks if the \l {QAbstractVideoBuffer::MapMode}{MapMode} + contains the QAbstractVideoBuffer::WriteOnly flag. + + Returns true if the contents of the mapped memory were read from the video frame, and false + otherwise. + + \since 1.0 + \sa mapMode(), QAbstractVideoBuffer::MapMode +*/ +bool QVideoFrame::isReadable() const +{ + return d->buffer != 0 && (d->buffer->mapMode() & QAbstractVideoBuffer::ReadOnly); +} + +/*! + Returns the mode a video frame was mapped to system memory in. + + \since 1.0 + \sa map(), QAbstractVideoBuffer::MapMode +*/ +QAbstractVideoBuffer::MapMode QVideoFrame::mapMode() const +{ + return d->buffer != 0 ? d->buffer->mapMode() : QAbstractVideoBuffer::NotMapped; +} + +/*! + Maps the contents of a video frame to memory. + + The map \a mode indicates whether the contents of the mapped memory should be read from and/or + written to the frame. If the map mode includes the QAbstractVideoBuffer::ReadOnly flag the + mapped memory will be populated with the content of the video frame when mapped. If the map + mode inclues the QAbstractVideoBuffer::WriteOnly flag the content of the mapped memory will be + persisted in the frame when unmapped. + + While mapped the contents of a video frame can be accessed directly through the pointer returned + by the bits() function. + + When access to the data is no longer needed be sure to call the unmap() function to release the + mapped memory and possibly update the video frame contents. + + Returns true if the buffer was mapped to memory in the given \a mode and false otherwise. + + \since 1.0 + \sa unmap(), mapMode(), bits() +*/ +bool QVideoFrame::map(QAbstractVideoBuffer::MapMode mode) +{ + if (d->buffer != 0 && d->data == 0) { + Q_ASSERT(d->bytesPerLine == 0); + Q_ASSERT(d->mappedBytes == 0); + + d->data = d->buffer->map(mode, &d->mappedBytes, &d->bytesPerLine); + + return d->data != 0; + } + + return false; +} + +/*! + Releases the memory mapped by the map() function. + + If the \l {QAbstractVideoBuffer::MapMode}{MapMode} included the QAbstractVideoBuffer::WriteOnly + flag this will persist the current content of the mapped memory to the video frame. + + \since 1.0 + \sa map() +*/ +void QVideoFrame::unmap() +{ + if (d->data != 0) { + d->mappedBytes = 0; + d->bytesPerLine = 0; + d->data = 0; + + d->buffer->unmap(); + } +} + +/*! + Returns the number of bytes in a scan line. + + \note This is the bytes per line of the first plane only. The bytes per line of subsequent + planes should be calculated as per the frame type. + + This value is only valid while the frame data is \l {map()}{mapped}. + + \since 1.0 + \sa bits(), map(), mappedBytes() +*/ +int QVideoFrame::bytesPerLine() const +{ + return d->bytesPerLine; +} + +/*! + Returns a pointer to the start of the frame data buffer. + + This value is only valid while the frame data is \l {map()}{mapped}. + + Changes made to data accessed via this pointer (when mapped with write access) + are only guaranteed to have been persisted when unmap() is called. + + \since 1.0 + \sa map(), mappedBytes(), bytesPerLine() +*/ +uchar *QVideoFrame::bits() +{ + return d->data; +} + +/*! + Returns a pointer to the start of the frame data buffer. + + This value is only valid while the frame data is \l {map()}{mapped}. + + If the buffer was not mapped with read access, the contents of this + buffer will initially be uninitialized. + + \since 1.0 + \sa map(), mappedBytes(), bytesPerLine() +*/ +const uchar *QVideoFrame::bits() const +{ + return d->data; +} + +/*! + Returns the number of bytes occupied by the mapped frame data. + + This value is only valid while the frame data is \l {map()}{mapped}. + + \since 1.0 + \sa map() +*/ +int QVideoFrame::mappedBytes() const +{ + return d->mappedBytes; +} + +/*! + Returns a type specific handle to a video frame's buffer. + + For an OpenGL texture this would be the texture ID. + + \since 1.0 + \sa QAbstractVideoBuffer::handle() +*/ +QVariant QVideoFrame::handle() const +{ + return d->buffer != 0 ? d->buffer->handle() : QVariant(); +} + +/*! + Returns the presentation time when the frame should be displayed. + \since 1.0 +*/ +qint64 QVideoFrame::startTime() const +{ + return d->startTime; +} + +/*! + Sets the presentation \a time when the frame should be displayed. + \since 1.0 +*/ +void QVideoFrame::setStartTime(qint64 time) +{ + d->startTime = time; +} + +/*! + Returns the presentation time when a frame should stop being displayed. + + \since 1.0 +*/ +qint64 QVideoFrame::endTime() const +{ + return d->endTime; +} + +/*! + Sets the presentation \a time when a frame should stop being displayed. + \since 1.0 +*/ +void QVideoFrame::setEndTime(qint64 time) +{ + d->endTime = time; +} + +/*! + Returns a video pixel format equivalent to an image \a format. If there is no equivalent + format QVideoFrame::InvalidType is returned instead. + \since 1.0 +*/ +QVideoFrame::PixelFormat QVideoFrame::pixelFormatFromImageFormat(QImage::Format format) +{ + switch (format) { + case QImage::Format_Invalid: + case QImage::Format_Mono: + case QImage::Format_MonoLSB: + case QImage::Format_Indexed8: + return Format_Invalid; + case QImage::Format_RGB32: + return Format_RGB32; + case QImage::Format_ARGB32: + return Format_ARGB32; + case QImage::Format_ARGB32_Premultiplied: + return Format_ARGB32_Premultiplied; + case QImage::Format_RGB16: + return Format_RGB565; + case QImage::Format_ARGB8565_Premultiplied: + return Format_ARGB8565_Premultiplied; + case QImage::Format_RGB666: + case QImage::Format_ARGB6666_Premultiplied: + return Format_Invalid; + case QImage::Format_RGB555: + return Format_RGB555; + case QImage::Format_ARGB8555_Premultiplied: + return Format_Invalid; + case QImage::Format_RGB888: + return Format_RGB24; + case QImage::Format_RGB444: + case QImage::Format_ARGB4444_Premultiplied: + return Format_Invalid; + case QImage::NImageFormats: + return Format_Invalid; + } + return Format_Invalid; +} + +/*! + Returns an image format equivalent to a video frame pixel \a format. If there is no equivalent + format QImage::Format_Invalid is returned instead. + \since 1.0 +*/ +QImage::Format QVideoFrame::imageFormatFromPixelFormat(PixelFormat format) +{ + switch (format) { + case Format_Invalid: + return QImage::Format_Invalid; + case Format_ARGB32: + return QImage::Format_ARGB32; + case Format_ARGB32_Premultiplied: + return QImage::Format_ARGB32_Premultiplied; + case Format_RGB32: + return QImage::Format_RGB32; + case Format_RGB24: + return QImage::Format_RGB888; + case Format_RGB565: + return QImage::Format_RGB16; + case Format_RGB555: + return QImage::Format_RGB555; + case Format_ARGB8565_Premultiplied: + return QImage::Format_ARGB8565_Premultiplied; + case Format_BGRA32: + case Format_BGRA32_Premultiplied: + case Format_BGR32: + case Format_BGR24: + return QImage::Format_Invalid; + case Format_BGR565: + case Format_BGR555: + case Format_BGRA5658_Premultiplied: + case Format_AYUV444: + case Format_AYUV444_Premultiplied: + case Format_YUV444: + case Format_YUV420P: + case Format_YV12: + case Format_UYVY: + case Format_YUYV: + case Format_NV12: + case Format_NV21: + case Format_IMC1: + case Format_IMC2: + case Format_IMC3: + case Format_IMC4: + case Format_Y8: + case Format_Y16: + case Format_Jpeg: + case Format_CameraRaw: + case Format_AdobeDng: + return QImage::Format_Invalid; + case Format_User: + return QImage::Format_Invalid; + } + return QImage::Format_Invalid; +} + +QT_END_NAMESPACE + diff --git a/src/multimedia/video/qvideoframe.h b/src/multimedia/video/qvideoframe.h new file mode 100644 index 000000000..6dffaf59d --- /dev/null +++ b/src/multimedia/video/qvideoframe.h @@ -0,0 +1,174 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QVIDEOFRAME_H +#define QVIDEOFRAME_H + +#include +#include +#include +#include + +QT_BEGIN_HEADER + +QT_BEGIN_NAMESPACE + +QT_MODULE(Multimedia) + +class QSize; +class QVariant; + +class QVideoFramePrivate; + +class Q_MULTIMEDIA_EXPORT QVideoFrame +{ +public: + enum FieldType + { + ProgressiveFrame, + TopField, + BottomField, + InterlacedFrame + }; + + enum PixelFormat + { + Format_Invalid, + Format_ARGB32, + Format_ARGB32_Premultiplied, + Format_RGB32, + Format_RGB24, + Format_RGB565, + Format_RGB555, + Format_ARGB8565_Premultiplied, + Format_BGRA32, + Format_BGRA32_Premultiplied, + Format_BGR32, + Format_BGR24, + Format_BGR565, + Format_BGR555, + Format_BGRA5658_Premultiplied, + + Format_AYUV444, + Format_AYUV444_Premultiplied, + Format_YUV444, + Format_YUV420P, + Format_YV12, + Format_UYVY, + Format_YUYV, + Format_NV12, + Format_NV21, + Format_IMC1, + Format_IMC2, + Format_IMC3, + Format_IMC4, + Format_Y8, + Format_Y16, + + Format_Jpeg, + + Format_CameraRaw, + Format_AdobeDng, + + Format_User = 1000 + }; + + QVideoFrame(); + QVideoFrame(QAbstractVideoBuffer *buffer, const QSize &size, PixelFormat format); + QVideoFrame(int bytes, const QSize &size, int bytesPerLine, PixelFormat format); + QVideoFrame(const QImage &image); + QVideoFrame(const QVideoFrame &other); + ~QVideoFrame(); + + QVideoFrame &operator =(const QVideoFrame &other); + + bool isValid() const; + + PixelFormat pixelFormat() const; + + QAbstractVideoBuffer::HandleType handleType() const; + + QSize size() const; + int width() const; + int height() const; + + FieldType fieldType() const; + void setFieldType(FieldType); + + bool isMapped() const; + bool isReadable() const; + bool isWritable() const; + + QAbstractVideoBuffer::MapMode mapMode() const; + + bool map(QAbstractVideoBuffer::MapMode mode); + void unmap(); + + int bytesPerLine() const; + + uchar *bits(); + const uchar *bits() const; + int mappedBytes() const; + + QVariant handle() const; + + qint64 startTime() const; + void setStartTime(qint64 time); + + qint64 endTime() const; + void setEndTime(qint64 time); + + static PixelFormat pixelFormatFromImageFormat(QImage::Format format); + static QImage::Format imageFormatFromPixelFormat(PixelFormat format); + +private: + QExplicitlySharedDataPointer d; +}; + +QT_END_NAMESPACE + +Q_DECLARE_METATYPE(QVideoFrame::FieldType) +Q_DECLARE_METATYPE(QVideoFrame::PixelFormat) + +QT_END_HEADER + +#endif + diff --git a/src/multimedia/video/qvideosurfaceformat.cpp b/src/multimedia/video/qvideosurfaceformat.cpp new file mode 100644 index 000000000..8286d18e1 --- /dev/null +++ b/src/multimedia/video/qvideosurfaceformat.cpp @@ -0,0 +1,707 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qvideosurfaceformat.h" + +#include +#include +#include +#include +#include + +QT_BEGIN_NAMESPACE + +class QVideoSurfaceFormatPrivate : public QSharedData +{ +public: + QVideoSurfaceFormatPrivate() + : pixelFormat(QVideoFrame::Format_Invalid) + , handleType(QAbstractVideoBuffer::NoHandle) + , scanLineDirection(QVideoSurfaceFormat::TopToBottom) + , pixelAspectRatio(1, 1) + , ycbcrColorSpace(QVideoSurfaceFormat::YCbCr_Undefined) + , frameRate(0.0) + { + } + + QVideoSurfaceFormatPrivate( + const QSize &size, + QVideoFrame::PixelFormat format, + QAbstractVideoBuffer::HandleType type) + : pixelFormat(format) + , handleType(type) + , scanLineDirection(QVideoSurfaceFormat::TopToBottom) + , frameSize(size) + , pixelAspectRatio(1, 1) + , ycbcrColorSpace(QVideoSurfaceFormat::YCbCr_Undefined) + , viewport(QPoint(0, 0), size) + , frameRate(0.0) + { + } + + QVideoSurfaceFormatPrivate(const QVideoSurfaceFormatPrivate &other) + : QSharedData(other) + , pixelFormat(other.pixelFormat) + , handleType(other.handleType) + , scanLineDirection(other.scanLineDirection) + , frameSize(other.frameSize) + , pixelAspectRatio(other.pixelAspectRatio) + , ycbcrColorSpace(other.ycbcrColorSpace) + , viewport(other.viewport) + , frameRate(other.frameRate) + , propertyNames(other.propertyNames) + , propertyValues(other.propertyValues) + { + } + + bool operator ==(const QVideoSurfaceFormatPrivate &other) const + { + if (pixelFormat == other.pixelFormat + && handleType == other.handleType + && scanLineDirection == other.scanLineDirection + && frameSize == other.frameSize + && pixelAspectRatio == other.pixelAspectRatio + && viewport == other.viewport + && frameRatesEqual(frameRate, other.frameRate) + && ycbcrColorSpace == other.ycbcrColorSpace + && propertyNames.count() == other.propertyNames.count()) { + for (int i = 0; i < propertyNames.count(); ++i) { + int j = other.propertyNames.indexOf(propertyNames.at(i)); + + if (j == -1 || propertyValues.at(i) != other.propertyValues.at(j)) + return false; + } + return true; + } else { + return false; + } + } + + inline static bool frameRatesEqual(qreal r1, qreal r2) + { + return qAbs(r1 - r2) <= 0.00001 * qMin(qAbs(r1), qAbs(r2)); + } + + QVideoFrame::PixelFormat pixelFormat; + QAbstractVideoBuffer::HandleType handleType; + QVideoSurfaceFormat::Direction scanLineDirection; + QSize frameSize; + QSize pixelAspectRatio; + QVideoSurfaceFormat::YCbCrColorSpace ycbcrColorSpace; + QRect viewport; + qreal frameRate; + QList propertyNames; + QList propertyValues; +}; + +/*! + \class QVideoSurfaceFormat + \brief The QVideoSurfaceFormat class specifies the stream format of a video presentation + surface. + \since 1.0 + \inmodule QtMultimedia + + A video surface presents a stream of video frames. The surface's format describes the type of + the frames and determines how they should be presented. + + The core properties of a video stream required to setup a video surface are the pixel format + given by pixelFormat(), and the frame dimensions given by frameSize(). + + If the surface is to present frames using a frame's handle a surface format will also include + a handle type which is given by the handleType() function. + + The region of a frame that is actually displayed on a video surface is given by the viewport(). + A stream may have a viewport less than the entire region of a frame to allow for videos smaller + than the nearest optimal size of a video frame. For example the width of a frame may be + extended so that the start of each scan line is eight byte aligned. + + Other common properties are the pixelAspectRatio(), scanLineDirection(), and frameRate(). + Additionally a stream may have some additional type specific properties which are listed by the + dynamicPropertyNames() function and can be accessed using the property(), and setProperty() + functions. +*/ + +/*! + \enum QVideoSurfaceFormat::Direction + + Enumerates the layout direction of video scan lines. + + \value TopToBottom Scan lines are arranged from the top of the frame to the bottom. + \value BottomToTop Scan lines are arranged from the bottom of the frame to the top. +*/ + +/*! + \enum QVideoSurfaceFormat::YCbCrColorSpace + + Enumerates the Y'CbCr color space of video frames. + + \value YCbCr_Undefined + No color space is specified. + + \value YCbCr_BT601 + A Y'CbCr color space defined by ITU-R recommendation BT.601 + with Y value range from 16 to 235, and Cb/Cr range from 16 to 240. + Used in standard definition video. + + \value YCbCr_BT709 + A Y'CbCr color space defined by ITU-R BT.709 with the same values range as YCbCr_BT601. Used + for HDTV. + + \value YCbCr_xvYCC601 + The BT.601 color space with the value range extended to 0 to 255. + It is backward compatibile with BT.601 and uses values outside BT.601 range to represent a + wider range of colors. + + \value YCbCr_xvYCC709 + The BT.709 color space with the value range extended to 0 to 255. + + \value YCbCr_JPEG + The full range Y'CbCr color space used in JPEG files. +*/ + +/*! + Constructs a null video stream format. +*/ +QVideoSurfaceFormat::QVideoSurfaceFormat() + : d(new QVideoSurfaceFormatPrivate) +{ +} + +/*! + Contructs a description of stream which receives stream of \a type buffers with given frame + \a size and pixel \a format. + \since 1.0 +*/ +QVideoSurfaceFormat::QVideoSurfaceFormat( + const QSize& size, QVideoFrame::PixelFormat format, QAbstractVideoBuffer::HandleType type) + : d(new QVideoSurfaceFormatPrivate(size, format, type)) +{ +} + +/*! + Constructs a copy of \a other. + \since 1.0 +*/ +QVideoSurfaceFormat::QVideoSurfaceFormat(const QVideoSurfaceFormat &other) + : d(other.d) +{ +} + +/*! + Assigns the values of \a other to this object. + \since 1.0 +*/ +QVideoSurfaceFormat &QVideoSurfaceFormat::operator =(const QVideoSurfaceFormat &other) +{ + d = other.d; + + return *this; +} + +/*! + Destroys a video stream description. +*/ +QVideoSurfaceFormat::~QVideoSurfaceFormat() +{ +} + +/*! + Identifies if a video surface format has a valid pixel format and frame size. + + Returns true if the format is valid, and false otherwise. + \since 1.0 +*/ +bool QVideoSurfaceFormat::isValid() const +{ + return d->pixelFormat != QVideoFrame::Format_Invalid && d->frameSize.isValid(); +} + +/*! + Returns true if \a other is the same as this video format, and false if they are different. + \since 1.0 +*/ +bool QVideoSurfaceFormat::operator ==(const QVideoSurfaceFormat &other) const +{ + return d == other.d || *d == *other.d; +} + +/*! + Returns true if \a other is different to a video format, and false if they are the same. + \since 1.0 +*/ +bool QVideoSurfaceFormat::operator !=(const QVideoSurfaceFormat &other) const +{ + return d != other.d && !(*d == *other.d); +} + +/*! + Returns the pixel format of frames in a video stream. + \since 1.0 +*/ +QVideoFrame::PixelFormat QVideoSurfaceFormat::pixelFormat() const +{ + return d->pixelFormat; +} + +/*! + Returns the type of handle the surface uses to present the frame data. + + If the handle type is QAbstractVideoBuffer::NoHandle buffers with any handle type are valid + provided they can be \l {QAbstractVideoBuffer::map()}{mapped} with the + QAbstractVideoBuffer::ReadOnly flag. If the handleType() is not QAbstractVideoBuffer::NoHandle + then the handle type of the buffer must be the same as that of the surface format. + \since 1.0 +*/ +QAbstractVideoBuffer::HandleType QVideoSurfaceFormat::handleType() const +{ + return d->handleType; +} + +/*! + Returns the dimensions of frames in a video stream. + + \sa frameWidth(), frameHeight() + \since 1.0 +*/ +QSize QVideoSurfaceFormat::frameSize() const +{ + return d->frameSize; +} + +/*! + Returns the width of frames in a video stream. + + \sa frameSize(), frameHeight() + \since 1.0 +*/ +int QVideoSurfaceFormat::frameWidth() const +{ + return d->frameSize.width(); +} + +/*! + Returns the height of frame in a video stream. + \since 1.0 +*/ +int QVideoSurfaceFormat::frameHeight() const +{ + return d->frameSize.height(); +} + +/*! + Sets the size of frames in a video stream to \a size. + + This will reset the viewport() to fill the entire frame. + \since 1.0 +*/ +void QVideoSurfaceFormat::setFrameSize(const QSize &size) +{ + d->frameSize = size; + d->viewport = QRect(QPoint(0, 0), size); +} + +/*! + \overload + + Sets the \a width and \a height of frames in a video stream. + + This will reset the viewport() to fill the entire frame. + \since 1.0 +*/ +void QVideoSurfaceFormat::setFrameSize(int width, int height) +{ + d->frameSize = QSize(width, height); + d->viewport = QRect(0, 0, width, height); +} + +/*! + Returns the viewport of a video stream. + + The viewport is the region of a video frame that is actually displayed. + + By default the viewport covers an entire frame. + \since 1.0 +*/ +QRect QVideoSurfaceFormat::viewport() const +{ + return d->viewport; +} + +/*! + Sets the viewport of a video stream to \a viewport. + \since 1.0 +*/ +void QVideoSurfaceFormat::setViewport(const QRect &viewport) +{ + d->viewport = viewport; +} + +/*! + Returns the direction of scan lines. + \since 1.0 +*/ +QVideoSurfaceFormat::Direction QVideoSurfaceFormat::scanLineDirection() const +{ + return d->scanLineDirection; +} + +/*! + Sets the \a direction of scan lines. + \since 1.0 +*/ +void QVideoSurfaceFormat::setScanLineDirection(Direction direction) +{ + d->scanLineDirection = direction; +} + +/*! + Returns the frame rate of a video stream in frames per second. + \since 1.0 +*/ +qreal QVideoSurfaceFormat::frameRate() const +{ + return d->frameRate; +} + +/*! + Sets the frame \a rate of a video stream in frames per second. + \since 1.0 +*/ +void QVideoSurfaceFormat::setFrameRate(qreal rate) +{ + d->frameRate = rate; +} + +/*! + Returns a video stream's pixel aspect ratio. + \since 1.0 +*/ +QSize QVideoSurfaceFormat::pixelAspectRatio() const +{ + return d->pixelAspectRatio; +} + +/*! + Sets a video stream's pixel aspect \a ratio. + \since 1.0 +*/ +void QVideoSurfaceFormat::setPixelAspectRatio(const QSize &ratio) +{ + d->pixelAspectRatio = ratio; +} + +/*! + \overload + + Sets the \a horizontal and \a vertical elements of a video stream's pixel aspect ratio. + \since 1.0 +*/ +void QVideoSurfaceFormat::setPixelAspectRatio(int horizontal, int vertical) +{ + d->pixelAspectRatio = QSize(horizontal, vertical); +} + +/*! + Returns the Y'CbCr color space of a video stream. + \since 1.0 +*/ +QVideoSurfaceFormat::YCbCrColorSpace QVideoSurfaceFormat::yCbCrColorSpace() const +{ + return d->ycbcrColorSpace; +} + +/*! + Sets the Y'CbCr color \a space of a video stream. + It is only used with raw YUV frame types. + \since 1.0 +*/ +void QVideoSurfaceFormat::setYCbCrColorSpace(QVideoSurfaceFormat::YCbCrColorSpace space) +{ + d->ycbcrColorSpace = space; +} + +/*! + Returns a suggested size in pixels for the video stream. + + This is the size of the viewport scaled according to the pixel aspect ratio. + \since 1.0 +*/ +QSize QVideoSurfaceFormat::sizeHint() const +{ + QSize size = d->viewport.size(); + + if (d->pixelAspectRatio.height() != 0) + size.setWidth(size.width() * d->pixelAspectRatio.width() / d->pixelAspectRatio.height()); + + return size; +} + +/*! + Returns a list of video format dynamic property names. + \since 1.0 +*/ +QList QVideoSurfaceFormat::propertyNames() const +{ + return (QList() + << "handleType" + << "pixelFormat" + << "frameSize" + << "frameWidth" + << "viewport" + << "scanLineDirection" + << "frameRate" + << "pixelAspectRatio" + << "sizeHint" + << "yCbCrColorSpace") + + d->propertyNames; +} + +/*! + Returns the value of the video format's \a name property. + \since 1.0 +*/ +QVariant QVideoSurfaceFormat::property(const char *name) const +{ + if (qstrcmp(name, "handleType") == 0) { + return qVariantFromValue(d->handleType); + } else if (qstrcmp(name, "pixelFormat") == 0) { + return qVariantFromValue(d->pixelFormat); + } else if (qstrcmp(name, "handleType") == 0) { + return qVariantFromValue(d->handleType); + } else if (qstrcmp(name, "frameSize") == 0) { + return d->frameSize; + } else if (qstrcmp(name, "frameWidth") == 0) { + return d->frameSize.width(); + } else if (qstrcmp(name, "frameHeight") == 0) { + return d->frameSize.height(); + } else if (qstrcmp(name, "viewport") == 0) { + return d->viewport; + } else if (qstrcmp(name, "scanLineDirection") == 0) { + return qVariantFromValue(d->scanLineDirection); + } else if (qstrcmp(name, "frameRate") == 0) { + return qVariantFromValue(d->frameRate); + } else if (qstrcmp(name, "pixelAspectRatio") == 0) { + return qVariantFromValue(d->pixelAspectRatio); + } else if (qstrcmp(name, "sizeHint") == 0) { + return sizeHint(); + } else if (qstrcmp(name, "yCbCrColorSpace") == 0) { + return qVariantFromValue(d->ycbcrColorSpace); + } else { + int id = 0; + for (; id < d->propertyNames.count() && d->propertyNames.at(id) != name; ++id) {} + + return id < d->propertyValues.count() + ? d->propertyValues.at(id) + : QVariant(); + } +} + +/*! + Sets the video format's \a name property to \a value. + + Trying to set a read only property will be ignored. + + \since 1.0 +*/ +void QVideoSurfaceFormat::setProperty(const char *name, const QVariant &value) +{ + if (qstrcmp(name, "handleType") == 0) { + // read only. + } else if (qstrcmp(name, "pixelFormat") == 0) { + // read only. + } else if (qstrcmp(name, "frameSize") == 0) { + if (qVariantCanConvert(value)) { + d->frameSize = qvariant_cast(value); + d->viewport = QRect(QPoint(0, 0), d->frameSize); + } + } else if (qstrcmp(name, "frameWidth") == 0) { + // read only. + } else if (qstrcmp(name, "frameHeight") == 0) { + // read only. + } else if (qstrcmp(name, "viewport") == 0) { + if (qVariantCanConvert(value)) + d->viewport = qvariant_cast(value); + } else if (qstrcmp(name, "scanLineDirection") == 0) { + if (qVariantCanConvert(value)) + d->scanLineDirection = qvariant_cast(value); + } else if (qstrcmp(name, "frameRate") == 0) { + if (qVariantCanConvert(value)) + d->frameRate = qvariant_cast(value); + } else if (qstrcmp(name, "pixelAspectRatio") == 0) { + if (qVariantCanConvert(value)) + d->pixelAspectRatio = qvariant_cast(value); + } else if (qstrcmp(name, "sizeHint") == 0) { + // read only. + } else if (qstrcmp(name, "yCbCrColorSpace") == 0) { + if (qVariantCanConvert(value)) + d->ycbcrColorSpace = qvariant_cast(value); + } else { + int id = 0; + for (; id < d->propertyNames.count() && d->propertyNames.at(id) != name; ++id) {} + + if (id < d->propertyValues.count()) { + if (value.isNull()) { + d->propertyNames.removeAt(id); + d->propertyValues.removeAt(id); + } else { + d->propertyValues[id] = value; + } + } else if (!value.isNull()) { + d->propertyNames.append(QByteArray(name)); + d->propertyValues.append(value); + } + } +} + + +#ifndef QT_NO_DEBUG_STREAM +QDebug operator<<(QDebug dbg, const QVideoSurfaceFormat &f) +{ + QString typeName; + switch (f.pixelFormat()) { + case QVideoFrame::Format_Invalid: + typeName = QLatin1String("Format_Invalid"); + break; + case QVideoFrame::Format_ARGB32: + typeName = QLatin1String("Format_ARGB32"); + break; + case QVideoFrame::Format_ARGB32_Premultiplied: + typeName = QLatin1String("Format_ARGB32_Premultiplied"); + break; + case QVideoFrame::Format_RGB32: + typeName = QLatin1String("Format_RGB32"); + break; + case QVideoFrame::Format_RGB24: + typeName = QLatin1String("Format_RGB24"); + break; + case QVideoFrame::Format_RGB565: + typeName = QLatin1String("Format_RGB565"); + break; + case QVideoFrame::Format_RGB555: + typeName = QLatin1String("Format_RGB555"); + break; + case QVideoFrame::Format_ARGB8565_Premultiplied: + typeName = QLatin1String("Format_ARGB8565_Premultiplied"); + break; + case QVideoFrame::Format_BGRA32: + typeName = QLatin1String("Format_BGRA32"); + break; + case QVideoFrame::Format_BGRA32_Premultiplied: + typeName = QLatin1String("Format_BGRA32_Premultiplied"); + break; + case QVideoFrame::Format_BGR32: + typeName = QLatin1String("Format_BGR32"); + break; + case QVideoFrame::Format_BGR24: + typeName = QLatin1String("Format_BGR24"); + break; + case QVideoFrame::Format_BGR565: + typeName = QLatin1String("Format_BGR565"); + break; + case QVideoFrame::Format_BGR555: + typeName = QLatin1String("Format_BGR555"); + break; + case QVideoFrame::Format_BGRA5658_Premultiplied: + typeName = QLatin1String("Format_BGRA5658_Premultiplied"); + break; + case QVideoFrame::Format_AYUV444: + typeName = QLatin1String("Format_AYUV444"); + break; + case QVideoFrame::Format_AYUV444_Premultiplied: + typeName = QLatin1String("Format_AYUV444_Premultiplied"); + break; + case QVideoFrame::Format_YUV444: + typeName = QLatin1String("Format_YUV444"); + break; + case QVideoFrame::Format_YUV420P: + typeName = QLatin1String("Format_YUV420P"); + break; + case QVideoFrame::Format_YV12: + typeName = QLatin1String("Format_YV12"); + break; + case QVideoFrame::Format_UYVY: + typeName = QLatin1String("Format_UYVY"); + break; + case QVideoFrame::Format_YUYV: + typeName = QLatin1String("Format_YUYV"); + break; + case QVideoFrame::Format_NV12: + typeName = QLatin1String("Format_NV12"); + break; + case QVideoFrame::Format_NV21: + typeName = QLatin1String("Format_NV21"); + break; + case QVideoFrame::Format_IMC1: + typeName = QLatin1String("Format_IMC1"); + break; + case QVideoFrame::Format_IMC2: + typeName = QLatin1String("Format_IMC2"); + break; + case QVideoFrame::Format_IMC3: + typeName = QLatin1String("Format_IMC3"); + break; + case QVideoFrame::Format_IMC4: + typeName = QLatin1String("Format_IMC4"); + break; + case QVideoFrame::Format_Y8: + typeName = QLatin1String("Format_Y8"); + break; + case QVideoFrame::Format_Y16: + typeName = QLatin1String("Format_Y16"); + break; + default: + typeName = QString(QLatin1String("UserType(%1)" )).arg(int(f.pixelFormat())); + } + + dbg.nospace() << "QVideoSurfaceFormat(" << typeName; + dbg.nospace() << ", " << f.frameSize(); + dbg.nospace() << ", viewport=" << f.viewport(); + dbg.nospace() << ", pixelAspectRatio=" << f.pixelAspectRatio(); + dbg.nospace() << ")"; + + foreach(const QByteArray& propertyName, f.propertyNames()) + dbg << "\n " << propertyName.data() << " = " << f.property(propertyName.data()); + + return dbg.space(); +} +#endif + +QT_END_NAMESPACE diff --git a/src/multimedia/video/qvideosurfaceformat.h b/src/multimedia/video/qvideosurfaceformat.h new file mode 100644 index 000000000..f830b80a6 --- /dev/null +++ b/src/multimedia/video/qvideosurfaceformat.h @@ -0,0 +1,148 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QVIDEOSURFACEFORMAT_H +#define QVIDEOSURFACEFORMAT_H + +#include +#include +#include +#include +#include +#include + +QT_BEGIN_HEADER + +QT_BEGIN_NAMESPACE + +QT_MODULE(Multimedia) + + +class QDebug; + +class QVideoSurfaceFormatPrivate; + +class Q_MULTIMEDIA_EXPORT QVideoSurfaceFormat +{ +public: + enum Direction + { + TopToBottom, + BottomToTop + }; + + enum YCbCrColorSpace + { + YCbCr_Undefined, + YCbCr_BT601, + YCbCr_BT709, + YCbCr_xvYCC601, + YCbCr_xvYCC709, + YCbCr_JPEG, +#ifndef qdoc + YCbCr_CustomMatrix +#endif + }; + + QVideoSurfaceFormat(); + QVideoSurfaceFormat( + const QSize &size, + QVideoFrame::PixelFormat pixelFormat, + QAbstractVideoBuffer::HandleType handleType = QAbstractVideoBuffer::NoHandle); + QVideoSurfaceFormat(const QVideoSurfaceFormat &format); + ~QVideoSurfaceFormat(); + + QVideoSurfaceFormat &operator =(const QVideoSurfaceFormat &format); + + bool operator ==(const QVideoSurfaceFormat &format) const; + bool operator !=(const QVideoSurfaceFormat &format) const; + + bool isValid() const; + + QVideoFrame::PixelFormat pixelFormat() const; + QAbstractVideoBuffer::HandleType handleType() const; + + QSize frameSize() const; + void setFrameSize(const QSize &size); + void setFrameSize(int width, int height); + + int frameWidth() const; + int frameHeight() const; + + QRect viewport() const; + void setViewport(const QRect &viewport); + + Direction scanLineDirection() const; + void setScanLineDirection(Direction direction); + + qreal frameRate() const; + void setFrameRate(qreal rate); + + QSize pixelAspectRatio() const; + void setPixelAspectRatio(const QSize &ratio); + void setPixelAspectRatio(int width, int height); + + YCbCrColorSpace yCbCrColorSpace() const; + void setYCbCrColorSpace(YCbCrColorSpace colorSpace); + + QSize sizeHint() const; + + QList propertyNames() const; + QVariant property(const char *name) const; + void setProperty(const char *name, const QVariant &value); + +private: + QSharedDataPointer d; +}; + +#ifndef QT_NO_DEBUG_STREAM +Q_MULTIMEDIA_EXPORT QDebug operator<<(QDebug, const QVideoSurfaceFormat &); +#endif + +QT_END_NAMESPACE + +Q_DECLARE_METATYPE(QVideoSurfaceFormat::Direction) +Q_DECLARE_METATYPE(QVideoSurfaceFormat::YCbCrColorSpace) + +QT_END_HEADER + +#endif + diff --git a/src/multimedia/video/video.pri b/src/multimedia/video/video.pri new file mode 100644 index 000000000..accaa3371 --- /dev/null +++ b/src/multimedia/video/video.pri @@ -0,0 +1,22 @@ + +INCLUDEPATH += video + +PUBLIC_HEADERS += \ + video/qabstractvideobuffer.h \ + video/qabstractvideosurface.h \ + video/qvideoframe.h \ + video/qvideosurfaceformat.h + +PRIVATE_HEADERS += \ + video/qabstractvideobuffer_p.h \ + video/qimagevideobuffer_p.h \ + video/qmemoryvideobuffer_p.h + +SOURCES += \ + video/qabstractvideobuffer.cpp \ + video/qabstractvideosurface.cpp \ + video/qimagevideobuffer.cpp \ + video/qmemoryvideobuffer.cpp \ + video/qvideoframe.cpp \ + video/qvideosurfaceformat.cpp + diff --git a/src/multimediakit/audio/audio.pri b/src/multimediakit/audio/audio.pri deleted file mode 100644 index 4bedbd4d5..000000000 --- a/src/multimediakit/audio/audio.pri +++ /dev/null @@ -1,60 +0,0 @@ -INCLUDEPATH += audio - -PUBLIC_HEADERS += audio/qaudio.h \ - audio/qaudioformat.h \ - audio/qaudioinput.h \ - audio/qaudiooutput.h \ - audio/qaudiodeviceinfo.h \ - audio/qaudiosystemplugin.h \ - audio/qaudiosystem.h - -PRIVATE_HEADERS += audio/qaudiodevicefactory_p.h audio/qaudiopluginloader_p.h - - -SOURCES += audio/qaudio.cpp \ - audio/qaudioformat.cpp \ - audio/qaudiodeviceinfo.cpp \ - audio/qaudiooutput.cpp \ - audio/qaudioinput.cpp \ - audio/qaudiosystemplugin.cpp \ - audio/qaudiosystem.cpp \ - audio/qaudiodevicefactory.cpp \ - audio/qaudiopluginloader.cpp - -mac { - PRIVATE_HEADERS += audio/qaudioinput_mac_p.h \ - audio/qaudiooutput_mac_p.h \ - audio/qaudiodeviceinfo_mac_p.h \ - audio/qaudio_mac_p.h - - SOURCES += audio/qaudiodeviceinfo_mac_p.cpp \ - audio/qaudiooutput_mac_p.cpp \ - audio/qaudioinput_mac_p.cpp \ - audio/qaudio_mac.cpp - - LIBS += -framework ApplicationServices -framework CoreAudio -framework AudioUnit -framework AudioToolbox -} - -win32 { - PRIVATE_HEADERS += audio/qaudioinput_win32_p.h audio/qaudiooutput_win32_p.h audio/qaudiodeviceinfo_win32_p.h - SOURCES += audio/qaudiodeviceinfo_win32_p.cpp \ - audio/qaudiooutput_win32_p.cpp \ - audio/qaudioinput_win32_p.cpp - LIBS += -lwinmm -lstrmiids -lole32 -loleaut32 -} - -unix:!mac { - contains(config_test_pulseaudio, yes) { - DEFINES += QT_NO_AUDIO_BACKEND - } - else:contains(QT_CONFIG, alsa) { - linux-*|freebsd-*|openbsd-* { - DEFINES += HAS_ALSA - PRIVATE_HEADERS += audio/qaudiooutput_alsa_p.h audio/qaudioinput_alsa_p.h audio/qaudiodeviceinfo_alsa_p.h - SOURCES += audio/qaudiodeviceinfo_alsa_p.cpp \ - audio/qaudiooutput_alsa_p.cpp \ - audio/qaudioinput_alsa_p.cpp - LIBS_PRIVATE += -lasound - } - } -} diff --git a/src/multimediakit/audio/qaudio.cpp b/src/multimediakit/audio/qaudio.cpp deleted file mode 100644 index cc422cedd..000000000 --- a/src/multimediakit/audio/qaudio.cpp +++ /dev/null @@ -1,103 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - - -#include - - -QT_BEGIN_NAMESPACE - -namespace QAudio -{ - -class RegisterMetaTypes -{ -public: - RegisterMetaTypes() - { - qRegisterMetaType(); - qRegisterMetaType(); - qRegisterMetaType(); - } - -} _register; - -} - -/* - \namespace QAudio - \brief The QAudio namespace contains enums used by the audio classes. - \inmodule QtMultimediaKit - \ingroup multimedia -*/ - -/* - \enum QAudio::Error - - \value NoError No errors have occurred - \value OpenError An error occurred opening the audio device - \value IOError An error occurred during read/write of audio device - \value UnderrunError Audio data is not being fed to the audio device at a fast enough rate - \value FatalError A non-recoverable error has occurred, the audio device is not usable at this time. -*/ - -/* - \enum QAudio::State - - \value ActiveState Audio data is being processed, this state is set after start() is called - and while audio data is available to be processed. - \value SuspendedState The audio device is in a suspended state, this state will only be entered - after suspend() is called. - \value StoppedState The audio device is closed, and is not processing any audio data - \value IdleState The QIODevice passed in has no data and audio system's buffer is empty, this state - is set after start() is called and while no audio data is available to be processed. -*/ - -/* - \enum QAudio::Mode - - \value AudioOutput audio output device - \value AudioInput audio input device -*/ - - -QT_END_NAMESPACE - diff --git a/src/multimediakit/audio/qaudio.h b/src/multimediakit/audio/qaudio.h deleted file mode 100644 index 16accfef9..000000000 --- a/src/multimediakit/audio/qaudio.h +++ /dev/null @@ -1,74 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - - -#ifndef QAUDIO_H -#define QAUDIO_H - -#include -#include - -#include - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -QT_MODULE(Multimedia) - -//QTM_SYNC_HEADER_EXPORT QAudio - -namespace QAudio -{ - enum Error { NoError, OpenError, IOError, UnderrunError, FatalError }; - enum State { ActiveState, SuspendedState, StoppedState, IdleState }; - enum Mode { AudioInput, AudioOutput }; -} - -QT_END_NAMESPACE - -QT_END_HEADER - -Q_DECLARE_METATYPE(QAudio::Error) -Q_DECLARE_METATYPE(QAudio::State) -Q_DECLARE_METATYPE(QAudio::Mode) - -#endif // QAUDIO_H diff --git a/src/multimediakit/audio/qaudio_mac.cpp b/src/multimediakit/audio/qaudio_mac.cpp deleted file mode 100644 index 461508304..000000000 --- a/src/multimediakit/audio/qaudio_mac.cpp +++ /dev/null @@ -1,145 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - - -#include "qaudio_mac_p.h" - -QT_BEGIN_NAMESPACE - -// Debugging -QDebug operator<<(QDebug dbg, const QAudioFormat& audioFormat) -{ - dbg.nospace() << "QAudioFormat(" << - audioFormat.frequency() << "," << - audioFormat.channels() << "," << - audioFormat.sampleSize()<< "," << - audioFormat.codec() << "," << - audioFormat.byteOrder() << "," << - audioFormat.sampleType() << ")"; - - return dbg.space(); -} - - -// Conversion -QAudioFormat toQAudioFormat(AudioStreamBasicDescription const& sf) -{ - QAudioFormat audioFormat; - - audioFormat.setFrequency(sf.mSampleRate); - audioFormat.setChannels(sf.mChannelsPerFrame); - audioFormat.setSampleSize(sf.mBitsPerChannel); - audioFormat.setCodec(QString::fromLatin1("audio/pcm")); - audioFormat.setByteOrder((sf.mFormatFlags & kAudioFormatFlagIsBigEndian) != 0 ? QAudioFormat::BigEndian : QAudioFormat::LittleEndian); - QAudioFormat::SampleType type = QAudioFormat::UnSignedInt; - if ((sf.mFormatFlags & kAudioFormatFlagIsSignedInteger) != 0) - type = QAudioFormat::SignedInt; - else if ((sf.mFormatFlags & kAudioFormatFlagIsFloat) != 0) - type = QAudioFormat::Float; - audioFormat.setSampleType(type); - - return audioFormat; -} - -AudioStreamBasicDescription toAudioStreamBasicDescription(QAudioFormat const& audioFormat) -{ - AudioStreamBasicDescription sf; - - sf.mFormatFlags = kAudioFormatFlagIsPacked; - sf.mSampleRate = audioFormat.frequency(); - sf.mFramesPerPacket = 1; - sf.mChannelsPerFrame = audioFormat.channels(); - sf.mBitsPerChannel = audioFormat.sampleSize(); - sf.mBytesPerFrame = sf.mChannelsPerFrame * (sf.mBitsPerChannel / 8); - sf.mBytesPerPacket = sf.mFramesPerPacket * sf.mBytesPerFrame; - sf.mFormatID = kAudioFormatLinearPCM; - - switch (audioFormat.sampleType()) { - case QAudioFormat::SignedInt: sf.mFormatFlags |= kAudioFormatFlagIsSignedInteger; break; - case QAudioFormat::UnSignedInt: /* default */ break; - case QAudioFormat::Float: sf.mFormatFlags |= kAudioFormatFlagIsFloat; break; - case QAudioFormat::Unknown: default: break; - } - - if (audioFormat.byteOrder() == QAudioFormat::BigEndian) - sf.mFormatFlags |= kAudioFormatFlagIsBigEndian; - - return sf; -} - -// QAudioRingBuffer -QAudioRingBuffer::QAudioRingBuffer(int bufferSize): - m_bufferSize(bufferSize) -{ - m_buffer = new char[m_bufferSize]; - reset(); -} - -QAudioRingBuffer::~QAudioRingBuffer() -{ - delete m_buffer; -} - -int QAudioRingBuffer::used() const -{ - return m_bufferUsed; -} - -int QAudioRingBuffer::free() const -{ - return m_bufferSize - m_bufferUsed; -} - -int QAudioRingBuffer::size() const -{ - return m_bufferSize; -} - -void QAudioRingBuffer::reset() -{ - m_readPos = 0; - m_writePos = 0; - m_bufferUsed = 0; -} - -QT_END_NAMESPACE - - diff --git a/src/multimediakit/audio/qaudio_mac_p.h b/src/multimediakit/audio/qaudio_mac_p.h deleted file mode 100644 index 06ce43010..000000000 --- a/src/multimediakit/audio/qaudio_mac_p.h +++ /dev/null @@ -1,145 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -// -// W A R N I N G -// ------------- -// -// This file is not part of the Qt API. It exists for the convenience -// of other Qt classes. This header file may change from version to -// version without notice, or even be removed. -// -// We mean it. -// - - -#ifndef QAUDIO_MAC_P_H -#define QAUDIO_MAC_P_H - -#include - -#include -#include - -#include - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -QT_MODULE(Multimedia) - - - -extern QDebug operator<<(QDebug dbg, const QAudioFormat& audioFormat); - -extern QAudioFormat toQAudioFormat(const AudioStreamBasicDescription& streamFormat); -extern AudioStreamBasicDescription toAudioStreamBasicDescription(QAudioFormat const& audioFormat); - -class QAudioRingBuffer -{ -public: - typedef QPair Region; - - QAudioRingBuffer(int bufferSize); - ~QAudioRingBuffer(); - - Region acquireReadRegion(int size) - { - const int used = m_bufferUsed.fetchAndAddAcquire(0); - - if (used > 0) { - const int readSize = qMin(size, qMin(m_bufferSize - m_readPos, used)); - - return readSize > 0 ? Region(m_buffer + m_readPos, readSize) : Region(0, 0); - } - - return Region(0, 0); - } - - void releaseReadRegion(Region const& region) - { - m_readPos = (m_readPos + region.second) % m_bufferSize; - - m_bufferUsed.fetchAndAddRelease(-region.second); - } - - Region acquireWriteRegion(int size) - { - const int free = m_bufferSize - m_bufferUsed.fetchAndAddAcquire(0); - - if (free > 0) { - const int writeSize = qMin(size, qMin(m_bufferSize - m_writePos, free)); - - return writeSize > 0 ? Region(m_buffer + m_writePos, writeSize) : Region(0, 0); - } - - return Region(0, 0); - } - - void releaseWriteRegion(Region const& region) - { - m_writePos = (m_writePos + region.second) % m_bufferSize; - - m_bufferUsed.fetchAndAddRelease(region.second); - } - - int used() const; - int free() const; - int size() const; - - void reset(); - -private: - int m_bufferSize; - int m_readPos; - int m_writePos; - char* m_buffer; - QAtomicInt m_bufferUsed; -}; - -QT_END_NAMESPACE - -QT_END_HEADER - -#endif // QAUDIO_MAC_P_H - - diff --git a/src/multimediakit/audio/qaudiodevicefactory.cpp b/src/multimediakit/audio/qaudiodevicefactory.cpp deleted file mode 100644 index 19071e78f..000000000 --- a/src/multimediakit/audio/qaudiodevicefactory.cpp +++ /dev/null @@ -1,288 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include - -#include "qaudiosystem.h" -#include "qaudiosystemplugin.h" - -#include "qaudiopluginloader_p.h" -#include "qaudiodevicefactory_p.h" - -#ifndef QT_NO_AUDIO_BACKEND -#if defined(Q_OS_WIN) -#include "qaudiodeviceinfo_win32_p.h" -#include "qaudiooutput_win32_p.h" -#include "qaudioinput_win32_p.h" -#elif defined(Q_OS_MAC) -#include "qaudiodeviceinfo_mac_p.h" -#include "qaudiooutput_mac_p.h" -#include "qaudioinput_mac_p.h" -#elif defined(HAS_ALSA) -#include "qaudiodeviceinfo_alsa_p.h" -#include "qaudiooutput_alsa_p.h" -#include "qaudioinput_alsa_p.h" -#endif -#endif - -QT_BEGIN_NAMESPACE - -#if !defined (QT_NO_LIBRARY) && !defined(QT_NO_SETTINGS) -Q_GLOBAL_STATIC_WITH_ARGS(QAudioPluginLoader, audioLoader, - (QAudioSystemFactoryInterface_iid, QLatin1String("/audio"), Qt::CaseInsensitive)) -#endif - -class QNullDeviceInfo : public QAbstractAudioDeviceInfo -{ -public: - QAudioFormat preferredFormat() const { qWarning()<<"using null deviceinfo, none available"; return QAudioFormat(); } - bool isFormatSupported(const QAudioFormat& ) const { return false; } - QAudioFormat nearestFormat(const QAudioFormat& ) const { return QAudioFormat(); } - QString deviceName() const { return QString(); } - QStringList supportedCodecs() { return QStringList(); } - QList supportedSampleRates() { return QList(); } - QList supportedChannelCounts() { return QList(); } - QList supportedSampleSizes() { return QList(); } - QList supportedByteOrders() { return QList(); } - QList supportedSampleTypes() { return QList(); } -}; - -class QNullInputDevice : public QAbstractAudioInput -{ -public: - void start(QIODevice*) { qWarning()<<"using null input device, none available";} - QIODevice* start() { qWarning()<<"using null input device, none available"; return 0; } - void stop() {} - void reset() {} - void suspend() {} - void resume() {} - int bytesReady() const { return 0; } - int periodSize() const { return 0; } - void setBufferSize(int ) {} - int bufferSize() const { return 0; } - void setNotifyInterval(int ) {} - int notifyInterval() const { return 0; } - qint64 processedUSecs() const { return 0; } - qint64 elapsedUSecs() const { return 0; } - QAudio::Error error() const { return QAudio::OpenError; } - QAudio::State state() const { return QAudio::StoppedState; } - void setFormat(const QAudioFormat&) {} - QAudioFormat format() const { return QAudioFormat(); } -}; - -class QNullOutputDevice : public QAbstractAudioOutput -{ -public: - void start(QIODevice*) {qWarning()<<"using null output device, none available";} - QIODevice* start() { qWarning()<<"using null output device, none available"; return 0; } - void stop() {} - void reset() {} - void suspend() {} - void resume() {} - int bytesFree() const { return 0; } - int periodSize() const { return 0; } - void setBufferSize(int ) {} - int bufferSize() const { return 0; } - void setNotifyInterval(int ) {} - int notifyInterval() const { return 0; } - qint64 processedUSecs() const { return 0; } - qint64 elapsedUSecs() const { return 0; } - QAudio::Error error() const { return QAudio::OpenError; } - QAudio::State state() const { return QAudio::StoppedState; } - void setFormat(const QAudioFormat&) {} - QAudioFormat format() const { return QAudioFormat(); } -}; - -QList QAudioDeviceFactory::availableDevices(QAudio::Mode mode) -{ - QList devices; -#ifndef QT_NO_AUDIO_BACKEND -#if (defined(Q_OS_WIN) || defined(Q_OS_MAC) || defined(HAS_ALSA)) - foreach (const QByteArray &handle, QAudioDeviceInfoInternal::availableDevices(mode)) - devices << QAudioDeviceInfo(QLatin1String("builtin"), handle, mode); -#endif -#endif - -#if !defined (QT_NO_LIBRARY) && !defined(QT_NO_SETTINGS) - QAudioPluginLoader* l = audioLoader(); - foreach (const QString& key, l->keys()) { - QAudioSystemFactoryInterface* plugin = qobject_cast(l->instance(key)); - if (plugin) { - foreach (QByteArray const& handle, plugin->availableDevices(mode)) - devices << QAudioDeviceInfo(key, handle, mode); - } - - delete plugin; - } -#endif - - return devices; -} - -QAudioDeviceInfo QAudioDeviceFactory::defaultInputDevice() -{ -#if !defined (QT_NO_LIBRARY) && !defined(QT_NO_SETTINGS) - QAudioSystemFactoryInterface* plugin = qobject_cast(audioLoader()->instance(QLatin1String("default"))); - - if (plugin) { - QList list = plugin->availableDevices(QAudio::AudioInput); - if (list.size() > 0) - return QAudioDeviceInfo(QLatin1String("default"), list.at(0), QAudio::AudioInput); - } -#endif - -#ifndef QT_NO_AUDIO_BACKEND -#if (defined(Q_OS_WIN) || defined(Q_OS_MAC) || defined(HAS_ALSA)) - return QAudioDeviceInfo(QLatin1String("builtin"), QAudioDeviceInfoInternal::defaultInputDevice(), QAudio::AudioInput); -#endif -#endif - return QAudioDeviceInfo(); -} - -QAudioDeviceInfo QAudioDeviceFactory::defaultOutputDevice() -{ -#if !defined (QT_NO_LIBRARY) && !defined(QT_NO_SETTINGS) - QAudioSystemFactoryInterface* plugin = qobject_cast(audioLoader()->instance(QLatin1String("default"))); - - if (plugin) { - QList list = plugin->availableDevices(QAudio::AudioOutput); - if (list.size() > 0) - return QAudioDeviceInfo(QLatin1String("default"), list.at(0), QAudio::AudioOutput); - } -#endif - -#ifndef QT_NO_AUDIO_BACKEND -#if (defined(Q_OS_WIN) || defined(Q_OS_MAC) || defined(HAS_ALSA)) - return QAudioDeviceInfo(QLatin1String("builtin"), QAudioDeviceInfoInternal::defaultOutputDevice(), QAudio::AudioOutput); -#endif -#endif - return QAudioDeviceInfo(); -} - -QAbstractAudioDeviceInfo* QAudioDeviceFactory::audioDeviceInfo(const QString &realm, const QByteArray &handle, QAudio::Mode mode) -{ - QAbstractAudioDeviceInfo *rc = 0; - -#ifndef QT_NO_AUDIO_BACKEND -#if (defined(Q_OS_WIN) || defined(Q_OS_MAC) || defined(HAS_ALSA)) - if (realm == QLatin1String("builtin")) - return new QAudioDeviceInfoInternal(handle, mode); -#endif -#endif - -#if !defined (QT_NO_LIBRARY) && !defined(QT_NO_SETTINGS) - QAudioSystemFactoryInterface* plugin = - qobject_cast(audioLoader()->instance(realm)); - - if (plugin) - rc = plugin->createDeviceInfo(handle, mode); -#endif - - return rc == 0 ? new QNullDeviceInfo() : rc; -} - -QAbstractAudioInput* QAudioDeviceFactory::createDefaultInputDevice(QAudioFormat const &format) -{ - return createInputDevice(defaultInputDevice(), format); -} - -QAbstractAudioOutput* QAudioDeviceFactory::createDefaultOutputDevice(QAudioFormat const &format) -{ - return createOutputDevice(defaultOutputDevice(), format); -} - -QAbstractAudioInput* QAudioDeviceFactory::createInputDevice(QAudioDeviceInfo const& deviceInfo, QAudioFormat const &format) -{ - if (deviceInfo.isNull()) - return new QNullInputDevice(); -#ifndef QT_NO_AUDIO_BACKEND -#if (defined(Q_OS_WIN) || defined(Q_OS_MAC) || defined(HAS_ALSA)) - if (deviceInfo.realm() == QLatin1String("builtin")) { - QAbstractAudioInput* p = new QAudioInputPrivate(deviceInfo.handle()); - if (p) p->setFormat(format); - return p; - } -#endif -#endif -#if !defined (QT_NO_LIBRARY) && !defined(QT_NO_SETTINGS) - QAudioSystemFactoryInterface* plugin = - qobject_cast(audioLoader()->instance(deviceInfo.realm())); - - if (plugin) { - QAbstractAudioInput* p = plugin->createInput(deviceInfo.handle()); - if (p) p->setFormat(format); - return p; - } -#endif - - return new QNullInputDevice(); -} - -QAbstractAudioOutput* QAudioDeviceFactory::createOutputDevice(QAudioDeviceInfo const& deviceInfo, QAudioFormat const &format) -{ - if (deviceInfo.isNull()) - return new QNullOutputDevice(); -#ifndef QT_NO_AUDIO_BACKEND -#if (defined(Q_OS_WIN) || defined(Q_OS_MAC) || defined(HAS_ALSA)) - if (deviceInfo.realm() == QLatin1String("builtin")) { - QAbstractAudioOutput* p = new QAudioOutputPrivate(deviceInfo.handle()); - if (p) p->setFormat(format); - return p; - } -#endif -#endif - -#if !defined (QT_NO_LIBRARY) && !defined(QT_NO_SETTINGS) - QAudioSystemFactoryInterface* plugin = - qobject_cast(audioLoader()->instance(deviceInfo.realm())); - - if (plugin) { - QAbstractAudioOutput* p = plugin->createOutput(deviceInfo.handle()); - if (p) p->setFormat(format); - return p; - } -#endif - - return new QNullOutputDevice(); -} - -QT_END_NAMESPACE - diff --git a/src/multimediakit/audio/qaudiodevicefactory_p.h b/src/multimediakit/audio/qaudiodevicefactory_p.h deleted file mode 100644 index 16ddb573a..000000000 --- a/src/multimediakit/audio/qaudiodevicefactory_p.h +++ /dev/null @@ -1,100 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -// -// W A R N I N G -// ------------- -// -// This file is not part of the Qt API. It exists for the convenience -// of other Qt classes. This header file may change from version to -// version without notice, or even be removed. -// -// We mean it. -// - -#ifndef QAUDIODEVICEFACTORY_P_H -#define QAUDIODEVICEFACTORY_P_H - -#include -#include - -#include -#include - -#include "qaudiodeviceinfo.h" - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -QT_MODULE(Multimedia) - - -class QAbstractAudioInput; -class QAbstractAudioOutput; -class QAbstractAudioDeviceInfo; - -class QAudioDeviceFactory -{ -public: - static QList availableDevices(QAudio::Mode mode); - - static QAudioDeviceInfo defaultInputDevice(); - static QAudioDeviceInfo defaultOutputDevice(); - - static QAbstractAudioDeviceInfo* audioDeviceInfo(const QString &realm, const QByteArray &handle, QAudio::Mode mode); - - static QAbstractAudioInput* createDefaultInputDevice(QAudioFormat const &format); - static QAbstractAudioOutput* createDefaultOutputDevice(QAudioFormat const &format); - - static QAbstractAudioInput* createInputDevice(QAudioDeviceInfo const &device, QAudioFormat const &format); - static QAbstractAudioOutput* createOutputDevice(QAudioDeviceInfo const &device, QAudioFormat const &format); - - static QAbstractAudioInput* createNullInput(); - static QAbstractAudioOutput* createNullOutput(); -}; - -QT_END_NAMESPACE - -QT_END_HEADER - -#endif // QAUDIODEVICEFACTORY_P_H - diff --git a/src/multimediakit/audio/qaudiodeviceinfo.cpp b/src/multimediakit/audio/qaudiodeviceinfo.cpp deleted file mode 100644 index 6b6f7951e..000000000 --- a/src/multimediakit/audio/qaudiodeviceinfo.cpp +++ /dev/null @@ -1,483 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qaudiodevicefactory_p.h" -#include "qaudiosystem.h" -#include "qaudiodeviceinfo.h" - -#include - -QT_BEGIN_NAMESPACE - -class QAudioDeviceInfoPrivate : public QSharedData -{ -public: - QAudioDeviceInfoPrivate():info(0) {} - QAudioDeviceInfoPrivate(const QString &r, const QByteArray &h, QAudio::Mode m): - realm(r), handle(h), mode(m) - { - if (!handle.isEmpty()) - info = QAudioDeviceFactory::audioDeviceInfo(realm, handle, mode); - else - info = NULL; - } - - QAudioDeviceInfoPrivate(const QAudioDeviceInfoPrivate &other): - QSharedData(other), - realm(other.realm), handle(other.handle), mode(other.mode) - { - info = QAudioDeviceFactory::audioDeviceInfo(realm, handle, mode); - } - - QAudioDeviceInfoPrivate& operator=(const QAudioDeviceInfoPrivate &other) - { - delete info; - - realm = other.realm; - handle = other.handle; - mode = other.mode; - info = QAudioDeviceFactory::audioDeviceInfo(realm, handle, mode); - return *this; - } - - ~QAudioDeviceInfoPrivate() - { - delete info; - } - - QString realm; - QByteArray handle; - QAudio::Mode mode; - QAbstractAudioDeviceInfo* info; -}; - - -/*! - \class QAudioDeviceInfo - \brief The QAudioDeviceInfo class provides an interface to query audio devices and their functionality. - \inmodule QtMultimediaKit - \ingroup multimedia - - QAudioDeviceInfo lets you query for audio devices--such as sound - cards and USB headsets--that are currently available on the system. - The audio devices available are dependent on the platform or audio plugins installed. - - A QAudioDeviceInfo is used by Qt to construct - classes that communicate with the device--such as - QAudioInput, and QAudioOutput. - - You can also query each device for the formats it supports. A - format in this context is a set consisting of a specific byte - order, channel, codec, frequency, sample rate, and sample type. A - format is represented by the QAudioFormat class. - - The values supported by the the device for each of these - parameters can be fetched with - supportedByteOrders(), supportedChannelCounts(), supportedCodecs(), - supportedSampleRates(), supportedSampleSizes(), and - supportedSampleTypes(). The combinations supported are dependent on the platform, - audio plugins installed and the audio device capabilities. If you need a - specific format, you can check if - the device supports it with isFormatSupported(), or fetch a - supported format that is as close as possible to the format with - nearestFormat(). For instance: - - \snippet doc/src/snippets/multimedia-snippets/audio.cpp Setting audio format - - The static - functions defaultInputDevice(), defaultOutputDevice(), and - availableDevices() let you get a list of all available - devices. Devices are fetched according to the value of mode - this is specified by the \l {QAudio}::Mode enum. - The QAudioDeviceInfo returned are only valid for the \l {QAudio}::Mode. - - For instance: - - \snippet doc/src/snippets/multimedia-snippets/audio.cpp Dumping audio formats - - In this code sample, we loop through all devices that are able to output - sound, i.e., play an audio stream in a supported format. For each device we - find, we simply print the deviceName(). - - \sa QAudioOutput, QAudioInput -*/ - -/*! - Constructs an empty QAudioDeviceInfo object. -*/ -QAudioDeviceInfo::QAudioDeviceInfo(): - d(new QAudioDeviceInfoPrivate) -{ -} - -/*! - Constructs a copy of \a other. - \since 1.0 -*/ -QAudioDeviceInfo::QAudioDeviceInfo(const QAudioDeviceInfo& other): - d(other.d) -{ -} - -/*! - Destroy this audio device info. -*/ -QAudioDeviceInfo::~QAudioDeviceInfo() -{ -} - -/*! - Sets the QAudioDeviceInfo object to be equal to \a other. - \since 1.0 -*/ -QAudioDeviceInfo& QAudioDeviceInfo::operator=(const QAudioDeviceInfo &other) -{ - d = other.d; - return *this; -} - -/*! - Returns whether this QAudioDeviceInfo object holds a device definition. - \since 1.0 -*/ -bool QAudioDeviceInfo::isNull() const -{ - return d->info == 0; -} - -/*! - Returns the human readable name of the audio device. - - Device names vary depending on the platform/audio plugin being used. - - They are a unique string identifier for the audio device. - - eg. default, Intel, U0x46d0x9a4 - \since 1.0 -*/ -QString QAudioDeviceInfo::deviceName() const -{ - return isNull() ? QString() : d->info->deviceName(); -} - -/*! - Returns true if the supplied \a settings are supported by the audio - device described by this QAudioDeviceInfo. - \since 1.0 -*/ -bool QAudioDeviceInfo::isFormatSupported(const QAudioFormat &settings) const -{ - return isNull() ? false : d->info->isFormatSupported(settings); -} - -/*! - Returns the default audio format settings for this device. - - These settings are provided by the platform/audio plugin being used. - - They are also dependent on the \l {QAudio}::Mode being used. - - A typical audio system would provide something like: - \list - \o Input settings: 8000Hz mono 8 bit. - \o Output settings: 44100Hz stereo 16 bit little endian. - \endlist - \since 1.0 -*/ -QAudioFormat QAudioDeviceInfo::preferredFormat() const -{ - return isNull() ? QAudioFormat() : d->info->preferredFormat(); -} - -/*! - Returns the closest QAudioFormat to the supplied \a settings that the system supports. - - These settings are provided by the platform/audio plugin being used. - - They are also dependent on the \l {QAudio}::Mode being used. - \since 1.0 -*/ -QAudioFormat QAudioDeviceInfo::nearestFormat(const QAudioFormat &settings) const -{ - if (isFormatSupported(settings)) - return settings; - - QAudioFormat nearest = settings; - - QList testCodecs = supportedCodecs(); - QList testChannels = supportedChannels(); - QList testByteOrders = supportedByteOrders(); - QList testSampleTypes; - QList sampleTypesAvailable = supportedSampleTypes(); - QMap testFrequencies; - QList frequenciesAvailable = supportedFrequencies(); - QMap testSampleSizes; - QList sampleSizesAvailable = supportedSampleSizes(); - - // Get sorted lists for checking - if (testCodecs.contains(settings.codec())) { - testCodecs.removeAll(settings.codec()); - testCodecs.insert(0, settings.codec()); - } - testChannels.removeAll(settings.channels()); - testChannels.insert(0, settings.channels()); - testByteOrders.removeAll(settings.byteOrder()); - testByteOrders.insert(0, settings.byteOrder()); - - if (sampleTypesAvailable.contains(settings.sampleType())) - testSampleTypes.append(settings.sampleType()); - if (sampleTypesAvailable.contains(QAudioFormat::SignedInt)) - testSampleTypes.append(QAudioFormat::SignedInt); - if (sampleTypesAvailable.contains(QAudioFormat::UnSignedInt)) - testSampleTypes.append(QAudioFormat::UnSignedInt); - if (sampleTypesAvailable.contains(QAudioFormat::Float)) - testSampleTypes.append(QAudioFormat::Float); - - if (sampleSizesAvailable.contains(settings.sampleSize())) - testSampleSizes.insert(0,settings.sampleSize()); - sampleSizesAvailable.removeAll(settings.sampleSize()); - foreach (int size, sampleSizesAvailable) { - int larger = (size > settings.sampleSize()) ? size : settings.sampleSize(); - int smaller = (size > settings.sampleSize()) ? settings.sampleSize() : size; - bool isMultiple = ( 0 == (larger % smaller)); - int diff = larger - smaller; - testSampleSizes.insert((isMultiple ? diff : diff+100000), size); - } - if (frequenciesAvailable.contains(settings.frequency())) - testFrequencies.insert(0,settings.frequency()); - frequenciesAvailable.removeAll(settings.frequency()); - foreach (int frequency, frequenciesAvailable) { - int larger = (frequency > settings.frequency()) ? frequency : settings.frequency(); - int smaller = (frequency > settings.frequency()) ? settings.frequency() : frequency; - bool isMultiple = ( 0 == (larger % smaller)); - int diff = larger - smaller; - testFrequencies.insert((isMultiple ? diff : diff+100000), frequency); - } - - // Try to find nearest - foreach (QString codec, testCodecs) { - nearest.setCodec(codec); - foreach (QAudioFormat::Endian order, testByteOrders) { - nearest.setByteOrder(order); - foreach (QAudioFormat::SampleType sample, testSampleTypes) { - nearest.setSampleType(sample); - QMapIterator sz(testSampleSizes); - while (sz.hasNext()) { - sz.next(); - nearest.setSampleSize(sz.value()); - foreach (int channel, testChannels) { - nearest.setChannels(channel); - QMapIterator i(testFrequencies); - while (i.hasNext()) { - i.next(); - nearest.setFrequency(i.value()); - if (isFormatSupported(nearest)) - return nearest; - } - } - } - } - } - } - //Fallback - return preferredFormat(); -} - -/*! - Returns a list of supported codecs. - - All platform and plugin implementations should provide support for: - - "audio/pcm" - Linear PCM - - For writing plugins to support additional codecs refer to: - - http://www.iana.org/assignments/media-types/audio/ - \since 1.0 -*/ -QStringList QAudioDeviceInfo::supportedCodecs() const -{ - return isNull() ? QStringList() : d->info->supportedCodecs(); -} - -/*! - Returns a list of supported sample rates (in Hertz). - - \since 1.0 -*/ -QList QAudioDeviceInfo::supportedSampleRates() const -{ - return supportedFrequencies(); -} - -/*! - \obsolete - - Use supportedSampleRates() instead. - \since 1.0 -*/ -QList QAudioDeviceInfo::supportedFrequencies() const -{ - return isNull() ? QList() : d->info->supportedSampleRates(); -} - -/*! - Returns a list of supported channel counts. - - This is typically 1 for mono sound, or 2 for stereo sound. - - \since 1.0 -*/ -QList QAudioDeviceInfo::supportedChannelCounts() const -{ - return supportedChannels(); -} - -/*! - \obsolete - - Use supportedChannelCount() instead. - \since 1.0 -*/ -QList QAudioDeviceInfo::supportedChannels() const -{ - return isNull() ? QList() : d->info->supportedChannelCounts(); -} - -/*! - Returns a list of supported sample sizes (in bits). - - Typically this will include 8 and 16 bit sample sizes. - - \since 1.0 -*/ -QList QAudioDeviceInfo::supportedSampleSizes() const -{ - return isNull() ? QList() : d->info->supportedSampleSizes(); -} - -/*! - Returns a list of supported byte orders. - \since 1.0 -*/ -QList QAudioDeviceInfo::supportedByteOrders() const -{ - return isNull() ? QList() : d->info->supportedByteOrders(); -} - -/*! - Returns a list of supported sample types. - \since 1.0 -*/ -QList QAudioDeviceInfo::supportedSampleTypes() const -{ - return isNull() ? QList() : d->info->supportedSampleTypes(); -} - -/*! - Returns the information for the default input audio device. - All platform and audio plugin implementations provide a default audio device to use. - \since 1.0 -*/ -QAudioDeviceInfo QAudioDeviceInfo::defaultInputDevice() -{ - return QAudioDeviceFactory::defaultInputDevice(); -} - -/*! - Returns the information for the default output audio device. - All platform and audio plugin implementations provide a default audio device to use. - \since 1.0 -*/ -QAudioDeviceInfo QAudioDeviceInfo::defaultOutputDevice() -{ - return QAudioDeviceFactory::defaultOutputDevice(); -} - -/*! - Returns a list of audio devices that support \a mode. - \since 1.0 -*/ -QList QAudioDeviceInfo::availableDevices(QAudio::Mode mode) -{ - return QAudioDeviceFactory::availableDevices(mode); -} - - -/*! - \internal - \since 1.0 -*/ -QAudioDeviceInfo::QAudioDeviceInfo(const QString &realm, const QByteArray &handle, QAudio::Mode mode): - d(new QAudioDeviceInfoPrivate(realm, handle, mode)) -{ -} - -/*! - \internal - \since 1.0 -*/ -QString QAudioDeviceInfo::realm() const -{ - return d->realm; -} - -/*! - \internal - \since 1.0 -*/ -QByteArray QAudioDeviceInfo::handle() const -{ - return d->handle; -} - - -/*! - \internal - \since 1.0 -*/ -QAudio::Mode QAudioDeviceInfo::mode() const -{ - return d->mode; -} - -QT_END_NAMESPACE - diff --git a/src/multimediakit/audio/qaudiodeviceinfo.h b/src/multimediakit/audio/qaudiodeviceinfo.h deleted file mode 100644 index e8616ce35..000000000 --- a/src/multimediakit/audio/qaudiodeviceinfo.h +++ /dev/null @@ -1,116 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - - -#ifndef QAUDIODEVICEINFO_H -#define QAUDIODEVICEINFO_H - -#include -#include -#include -#include -#include - -#include -#include - -#include -#include - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -QT_MODULE(Multimedia) - - -class QAudioDeviceFactory; - -class QAudioDeviceInfoPrivate; -class Q_MULTIMEDIA_EXPORT QAudioDeviceInfo -{ - friend class QAudioDeviceFactory; - -public: - QAudioDeviceInfo(); - QAudioDeviceInfo(const QAudioDeviceInfo& other); - ~QAudioDeviceInfo(); - - QAudioDeviceInfo& operator=(const QAudioDeviceInfo& other); - - bool isNull() const; - - QString deviceName() const; - - bool isFormatSupported(const QAudioFormat &format) const; - QAudioFormat preferredFormat() const; - QAudioFormat nearestFormat(const QAudioFormat &format) const; - - QStringList supportedCodecs() const; - QList supportedFrequencies() const; - QList supportedSampleRates() const; - QList supportedChannels() const; - QList supportedChannelCounts() const; - QList supportedSampleSizes() const; - QList supportedByteOrders() const; - QList supportedSampleTypes() const; - - static QAudioDeviceInfo defaultInputDevice(); - static QAudioDeviceInfo defaultOutputDevice(); - - static QList availableDevices(QAudio::Mode mode); - -private: - QAudioDeviceInfo(const QString &realm, const QByteArray &handle, QAudio::Mode mode); - QString realm() const; - QByteArray handle() const; - QAudio::Mode mode() const; - - QSharedDataPointer d; -}; - -QT_END_NAMESPACE - -QT_END_HEADER - -Q_DECLARE_METATYPE(QAudioDeviceInfo) - -#endif // QAUDIODEVICEINFO_H diff --git a/src/multimediakit/audio/qaudiodeviceinfo_alsa_p.cpp b/src/multimediakit/audio/qaudiodeviceinfo_alsa_p.cpp deleted file mode 100644 index 113b330d4..000000000 --- a/src/multimediakit/audio/qaudiodeviceinfo_alsa_p.cpp +++ /dev/null @@ -1,535 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -// -// W A R N I N G -// ------------- -// -// This file is not part of the Qt API. It exists for the convenience -// of other Qt classes. This header file may change from version to -// version without notice, or even be removed. -// -// INTERNAL USE ONLY: Do NOT use for any other purpose. -// - -#include "qaudiodeviceinfo_alsa_p.h" - -#include - -QT_BEGIN_NAMESPACE - -QAudioDeviceInfoInternal::QAudioDeviceInfoInternal(QByteArray dev, QAudio::Mode mode) -{ - handle = 0; - - device = QLatin1String(dev); - this->mode = mode; - - checkSurround(); -} - -QAudioDeviceInfoInternal::~QAudioDeviceInfoInternal() -{ - close(); -} - -bool QAudioDeviceInfoInternal::isFormatSupported(const QAudioFormat& format) const -{ - return testSettings(format); -} - -QAudioFormat QAudioDeviceInfoInternal::preferredFormat() const -{ - QAudioFormat nearest; - if(mode == QAudio::AudioOutput) { - nearest.setFrequency(44100); - nearest.setChannels(2); - nearest.setByteOrder(QAudioFormat::LittleEndian); - nearest.setSampleType(QAudioFormat::SignedInt); - nearest.setSampleSize(16); - nearest.setCodec(QLatin1String("audio/pcm")); - } else { - nearest.setFrequency(8000); - nearest.setChannels(1); - nearest.setSampleType(QAudioFormat::UnSignedInt); - nearest.setSampleSize(8); - nearest.setCodec(QLatin1String("audio/pcm")); - if(!testSettings(nearest)) { - nearest.setChannels(2); - nearest.setSampleSize(16); - nearest.setSampleType(QAudioFormat::SignedInt); - } - } - return nearest; -} - -QString QAudioDeviceInfoInternal::deviceName() const -{ - return device; -} - -QStringList QAudioDeviceInfoInternal::supportedCodecs() -{ - updateLists(); - return codecz; -} - -QList QAudioDeviceInfoInternal::supportedSampleRates() -{ - updateLists(); - return freqz; -} - -QList QAudioDeviceInfoInternal::supportedChannelCounts() -{ - updateLists(); - return channelz; -} - -QList QAudioDeviceInfoInternal::supportedSampleSizes() -{ - updateLists(); - return sizez; -} - -QList QAudioDeviceInfoInternal::supportedByteOrders() -{ - updateLists(); - return byteOrderz; -} - -QList QAudioDeviceInfoInternal::supportedSampleTypes() -{ - updateLists(); - return typez; -} - -bool QAudioDeviceInfoInternal::open() -{ - int err = 0; - QString dev = device; - QList devices = availableDevices(mode); - - if(dev.compare(QLatin1String("default")) == 0) { -#if(SND_LIB_MAJOR == 1 && SND_LIB_MINOR == 0 && SND_LIB_SUBMINOR >= 14) - if (devices.size() > 0) - dev = QLatin1String(devices.first().constData()); - else - return false; -#else - dev = QLatin1String("hw:0,0"); -#endif - } else { -#if(SND_LIB_MAJOR == 1 && SND_LIB_MINOR == 0 && SND_LIB_SUBMINOR >= 14) - dev = device; -#else - int idx = 0; - char *name; - - QString shortName = device.mid(device.indexOf(QLatin1String("="),0)+1); - - while(snd_card_get_name(idx,&name) == 0) { - if(dev.contains(QLatin1String(name))) - break; - idx++; - } - dev = QString(QLatin1String("hw:%1,0")).arg(idx); -#endif - } - if(mode == QAudio::AudioOutput) { - err=snd_pcm_open( &handle,dev.toLocal8Bit().constData(),SND_PCM_STREAM_PLAYBACK,0); - } else { - err=snd_pcm_open( &handle,dev.toLocal8Bit().constData(),SND_PCM_STREAM_CAPTURE,0); - } - if(err < 0) { - handle = 0; - return false; - } - return true; -} - -void QAudioDeviceInfoInternal::close() -{ - if(handle) - snd_pcm_close(handle); - handle = 0; -} - -bool QAudioDeviceInfoInternal::testSettings(const QAudioFormat& format) const -{ - // Set nearest to closest settings that do work. - // See if what is in settings will work (return value). - int err = 0; - snd_pcm_t* handle; - snd_pcm_hw_params_t *params; - QString dev = device; - - QList devices = QAudioDeviceInfoInternal::availableDevices(QAudio::AudioOutput); - - if(dev.compare(QLatin1String("default")) == 0) { -#if(SND_LIB_MAJOR == 1 && SND_LIB_MINOR == 0 && SND_LIB_SUBMINOR >= 14) - dev = QLatin1String(devices.first().constData()); -#else - dev = QLatin1String("hw:0,0"); -#endif - } else { -#if(SND_LIB_MAJOR == 1 && SND_LIB_MINOR == 0 && SND_LIB_SUBMINOR >= 14) - dev = device; -#else - int idx = 0; - char *name; - - QString shortName = device.mid(device.indexOf(QLatin1String("="),0)+1); - - while(snd_card_get_name(idx,&name) == 0) { - if(shortName.compare(QLatin1String(name)) == 0) - break; - idx++; - } - dev = QString(QLatin1String("hw:%1,0")).arg(idx); -#endif - } - if(mode == QAudio::AudioOutput) { - err=snd_pcm_open( &handle,dev.toLocal8Bit().constData(),SND_PCM_STREAM_PLAYBACK,0); - } else { - err=snd_pcm_open( &handle,dev.toLocal8Bit().constData(),SND_PCM_STREAM_CAPTURE,0); - } - if(err < 0) { - handle = 0; - return false; - } - - bool testChannel = false; - bool testCodec = false; - bool testFreq = false; - bool testType = false; - bool testSize = false; - - int dir = 0; - - snd_pcm_nonblock( handle, 0 ); - snd_pcm_hw_params_alloca( ¶ms ); - snd_pcm_hw_params_any( handle, params ); - - // set the values! - snd_pcm_hw_params_set_channels(handle,params,format.channels()); - snd_pcm_hw_params_set_rate(handle,params,format.frequency(),dir); - - err = -1; - - switch(format.sampleSize()) { - case 8: - if(format.sampleType() == QAudioFormat::SignedInt) - err = snd_pcm_hw_params_set_format(handle,params,SND_PCM_FORMAT_S8); - else if(format.sampleType() == QAudioFormat::UnSignedInt) - err = snd_pcm_hw_params_set_format(handle,params,SND_PCM_FORMAT_U8); - break; - case 16: - if(format.sampleType() == QAudioFormat::SignedInt) { - if(format.byteOrder() == QAudioFormat::LittleEndian) - err = snd_pcm_hw_params_set_format(handle,params,SND_PCM_FORMAT_S16_LE); - else if(format.byteOrder() == QAudioFormat::BigEndian) - err = snd_pcm_hw_params_set_format(handle,params,SND_PCM_FORMAT_S16_BE); - } else if(format.sampleType() == QAudioFormat::UnSignedInt) { - if(format.byteOrder() == QAudioFormat::LittleEndian) - err = snd_pcm_hw_params_set_format(handle,params,SND_PCM_FORMAT_U16_LE); - else if(format.byteOrder() == QAudioFormat::BigEndian) - err = snd_pcm_hw_params_set_format(handle,params,SND_PCM_FORMAT_U16_BE); - } - break; - case 32: - if(format.sampleType() == QAudioFormat::SignedInt) { - if(format.byteOrder() == QAudioFormat::LittleEndian) - err = snd_pcm_hw_params_set_format(handle,params,SND_PCM_FORMAT_S32_LE); - else if(format.byteOrder() == QAudioFormat::BigEndian) - err = snd_pcm_hw_params_set_format(handle,params,SND_PCM_FORMAT_S32_BE); - } else if(format.sampleType() == QAudioFormat::UnSignedInt) { - if(format.byteOrder() == QAudioFormat::LittleEndian) - err = snd_pcm_hw_params_set_format(handle,params,SND_PCM_FORMAT_U32_LE); - else if(format.byteOrder() == QAudioFormat::BigEndian) - err = snd_pcm_hw_params_set_format(handle,params,SND_PCM_FORMAT_U32_BE); - } - } - - // For now, just accept only audio/pcm codec - if(!format.codec().startsWith(QLatin1String("audio/pcm"))) { - err=-1; - } else - testCodec = true; - - if(err>=0 && format.channels() != -1) { - err = snd_pcm_hw_params_test_channels(handle,params,format.channels()); - if(err>=0) - err = snd_pcm_hw_params_set_channels(handle,params,format.channels()); - if(err>=0) - testChannel = true; - } - - if(err>=0 && format.frequency() != -1) { - err = snd_pcm_hw_params_test_rate(handle,params,format.frequency(),0); - if(err>=0) - err = snd_pcm_hw_params_set_rate(handle,params,format.frequency(),dir); - if(err>=0) - testFreq = true; - } - - if((err>=0 && format.sampleSize() != -1) && - (format.sampleType() != QAudioFormat::Unknown)) { - switch(format.sampleSize()) { - case 8: - if(format.sampleType() == QAudioFormat::SignedInt) - err = snd_pcm_hw_params_set_format(handle,params,SND_PCM_FORMAT_S8); - else if(format.sampleType() == QAudioFormat::UnSignedInt) - err = snd_pcm_hw_params_set_format(handle,params,SND_PCM_FORMAT_U8); - break; - case 16: - if(format.sampleType() == QAudioFormat::SignedInt) { - if(format.byteOrder() == QAudioFormat::LittleEndian) - err = snd_pcm_hw_params_set_format(handle,params,SND_PCM_FORMAT_S16_LE); - else if(format.byteOrder() == QAudioFormat::BigEndian) - err = snd_pcm_hw_params_set_format(handle,params,SND_PCM_FORMAT_S16_BE); - } else if(format.sampleType() == QAudioFormat::UnSignedInt) { - if(format.byteOrder() == QAudioFormat::LittleEndian) - err = snd_pcm_hw_params_set_format(handle,params,SND_PCM_FORMAT_U16_LE); - else if(format.byteOrder() == QAudioFormat::BigEndian) - err = snd_pcm_hw_params_set_format(handle,params,SND_PCM_FORMAT_U16_BE); - } - break; - case 32: - if(format.sampleType() == QAudioFormat::SignedInt) { - if(format.byteOrder() == QAudioFormat::LittleEndian) - err = snd_pcm_hw_params_set_format(handle,params,SND_PCM_FORMAT_S32_LE); - else if(format.byteOrder() == QAudioFormat::BigEndian) - err = snd_pcm_hw_params_set_format(handle,params,SND_PCM_FORMAT_S32_BE); - } else if(format.sampleType() == QAudioFormat::UnSignedInt) { - if(format.byteOrder() == QAudioFormat::LittleEndian) - err = snd_pcm_hw_params_set_format(handle,params,SND_PCM_FORMAT_U32_LE); - else if(format.byteOrder() == QAudioFormat::BigEndian) - err = snd_pcm_hw_params_set_format(handle,params,SND_PCM_FORMAT_U32_BE); - } - } - if(err>=0) { - testSize = true; - testType = true; - } - } - if(err>=0) - err = snd_pcm_hw_params(handle, params); - - if(err == 0) { - // settings work - // close() - if(handle) - snd_pcm_close(handle); - return true; - } - if(handle) - snd_pcm_close(handle); - - return false; -} - -void QAudioDeviceInfoInternal::updateLists() -{ - // redo all lists based on current settings - freqz.clear(); - channelz.clear(); - sizez.clear(); - byteOrderz.clear(); - typez.clear(); - codecz.clear(); - - if(!handle) - open(); - - if(!handle) - return; - - for(int i=0; i<(int)MAX_SAMPLE_RATES; i++) { - //if(snd_pcm_hw_params_test_rate(handle, params, SAMPLE_RATES[i], dir) == 0) - freqz.append(SAMPLE_RATES[i]); - } - channelz.append(1); - channelz.append(2); - if (surround40) channelz.append(4); - if (surround51) channelz.append(6); - if (surround71) channelz.append(8); - sizez.append(8); - sizez.append(16); - sizez.append(32); - byteOrderz.append(QAudioFormat::LittleEndian); - byteOrderz.append(QAudioFormat::BigEndian); - typez.append(QAudioFormat::SignedInt); - typez.append(QAudioFormat::UnSignedInt); - typez.append(QAudioFormat::Float); - codecz.append(QLatin1String("audio/pcm")); - close(); -} - -QList QAudioDeviceInfoInternal::availableDevices(QAudio::Mode mode) -{ - QList allDevices; - QList devices; - QByteArray filter; - -#if(SND_LIB_MAJOR == 1 && SND_LIB_MINOR == 0 && SND_LIB_SUBMINOR >= 14) - // Create a list of all current audio devices that support mode - void **hints, **n; - char *name, *descr, *io; - - if(snd_device_name_hint(-1, "pcm", &hints) < 0) { - qWarning() << "no alsa devices available"; - return devices; - } - n = hints; - - if(mode == QAudio::AudioInput) { - filter = "Input"; - } else { - filter = "Output"; - } - - while (*n != NULL) { - name = snd_device_name_get_hint(*n, "NAME"); - if (name != 0 && qstrcmp(name, "null") != 0) { - descr = snd_device_name_get_hint(*n, "DESC"); - io = snd_device_name_get_hint(*n, "IOID"); - - if ((descr != NULL) && ((io == NULL) || (io == filter))) { - QString deviceName = QLatin1String(name); - QString deviceDescription = QLatin1String(descr); - allDevices.append(deviceName.toLocal8Bit().constData()); - if (deviceDescription.contains(QLatin1String("Default Audio Device"))) - devices.append(deviceName.toLocal8Bit().constData()); - } - - free(name); - if (descr != NULL) - free(descr); - if (io != NULL) - free(io); - } - ++n; - } - snd_device_name_free_hint(hints); - - if(devices.size() > 0) { - devices.append("default"); - } -#else - int idx = 0; - char* name; - - while(snd_card_get_name(idx,&name) == 0) { - devices.append(name); - idx++; - } - if (idx > 0) - devices.append("default"); -#endif -#if !defined(Q_WS_MAEMO_6) - if (devices.size() == 0 && allDevices.size() > 0) - return allDevices; -#endif - - return devices; -} - -QByteArray QAudioDeviceInfoInternal::defaultInputDevice() -{ - QList devices = availableDevices(QAudio::AudioInput); - if(devices.size() == 0) - return QByteArray(); - - return devices.first(); -} - -QByteArray QAudioDeviceInfoInternal::defaultOutputDevice() -{ - QList devices = availableDevices(QAudio::AudioOutput); - if(devices.size() == 0) - return QByteArray(); - - return devices.first(); -} - -void QAudioDeviceInfoInternal::checkSurround() -{ - QList devices; - surround40 = false; - surround51 = false; - surround71 = false; - - void **hints, **n; - char *name, *descr, *io; - - if(snd_device_name_hint(-1, "pcm", &hints) < 0) - return; - - n = hints; - - while (*n != NULL) { - name = snd_device_name_get_hint(*n, "NAME"); - descr = snd_device_name_get_hint(*n, "DESC"); - io = snd_device_name_get_hint(*n, "IOID"); - if((name != NULL) && (descr != NULL)) { - QString deviceName = QLatin1String(name); - if (mode == QAudio::AudioOutput) { - if(deviceName.contains(QLatin1String("surround40"))) - surround40 = true; - if(deviceName.contains(QLatin1String("surround51"))) - surround51 = true; - if(deviceName.contains(QLatin1String("surround71"))) - surround71 = true; - } - } - if(name != NULL) - free(name); - if(descr != NULL) - free(descr); - if(io != NULL) - free(io); - ++n; - } - snd_device_name_free_hint(hints); -} - -QT_END_NAMESPACE diff --git a/src/multimediakit/audio/qaudiodeviceinfo_alsa_p.h b/src/multimediakit/audio/qaudiodeviceinfo_alsa_p.h deleted file mode 100644 index cf19d2554..000000000 --- a/src/multimediakit/audio/qaudiodeviceinfo_alsa_p.h +++ /dev/null @@ -1,129 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -// -// W A R N I N G -// ------------- -// -// This file is not part of the Qt API. It exists for the convenience -// of other Qt classes. This header file may change from version to -// version without notice, or even be removed. -// -// We mean it. -// - - -#ifndef QAUDIODEVICEINFOALSA_H -#define QAUDIODEVICEINFOALSA_H - -#include - -#include -#include -#include -#include - -#include "qaudio.h" -#include "qaudiodeviceinfo.h" -#include "qaudiosystem.h" - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -QT_MODULE(Multimedia) - - -const unsigned int MAX_SAMPLE_RATES = 5; -const unsigned int SAMPLE_RATES[] = - { 8000, 11025, 22050, 44100, 48000 }; - -class QAudioDeviceInfoInternal : public QAbstractAudioDeviceInfo -{ - Q_OBJECT -public: - QAudioDeviceInfoInternal(QByteArray dev,QAudio::Mode mode); - ~QAudioDeviceInfoInternal(); - - bool testSettings(const QAudioFormat& format) const; - void updateLists(); - QAudioFormat preferredFormat() const; - bool isFormatSupported(const QAudioFormat& format) const; - QString deviceName() const; - QStringList supportedCodecs(); - QList supportedSampleRates(); - QList supportedChannelCounts(); - QList supportedSampleSizes(); - QList supportedByteOrders(); - QList supportedSampleTypes(); - static QByteArray defaultInputDevice(); - static QByteArray defaultOutputDevice(); - static QList availableDevices(QAudio::Mode); - -private: - bool open(); - void close(); - - void checkSurround(); - bool surround40; - bool surround51; - bool surround71; - - QString device; - QAudio::Mode mode; - QAudioFormat nearest; - QList freqz; - QList channelz; - QList sizez; - QList byteOrderz; - QStringList codecz; - QList typez; - snd_pcm_t* handle; - snd_pcm_hw_params_t *params; -}; - -QT_END_NAMESPACE - -QT_END_HEADER - - -#endif - diff --git a/src/multimediakit/audio/qaudiodeviceinfo_mac_p.cpp b/src/multimediakit/audio/qaudiodeviceinfo_mac_p.cpp deleted file mode 100644 index 4c7779f91..000000000 --- a/src/multimediakit/audio/qaudiodeviceinfo_mac_p.cpp +++ /dev/null @@ -1,351 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -// -// W A R N I N G -// ------------- -// -// This file is not part of the Qt API. It exists for the convenience -// of other Qt classes. This header file may change from version to -// version without notice, or even be removed. -// -// INTERNAL USE ONLY: Do NOT use for any other purpose. -// - -#include -#include -#include -#include -#include - -#include -#include "qaudio_mac_p.h" -#include "qaudiodeviceinfo_mac_p.h" - - - -QT_BEGIN_NAMESPACE - -// XXX: remove at some future date -static inline QString cfStringToQString(CFStringRef str) -{ - CFIndex length = CFStringGetLength(str); - const UniChar *chars = CFStringGetCharactersPtr(str); - if (chars) - return QString(reinterpret_cast(chars), length); - - UniChar buffer[length]; - CFStringGetCharacters(str, CFRangeMake(0, length), buffer); - return QString(reinterpret_cast(buffer), length); -} - -QAudioDeviceInfoInternal::QAudioDeviceInfoInternal(QByteArray const& handle, QAudio::Mode) -{ - QDataStream ds(handle); - quint32 did, tm; - - ds >> did >> tm >> name; - deviceId = AudioDeviceID(did); - mode = QAudio::Mode(tm); -} - -bool QAudioDeviceInfoInternal::isFormatSupported(const QAudioFormat& format) const -{ - QAudioDeviceInfoInternal *self = const_cast(this); - - return format.isValid() - && format.codec() == QString::fromLatin1("audio/pcm") - && self->supportedSampleRates().contains(format.sampleRate()) - && self->supportedChannelCounts().contains(format.channelCount()) - && self->supportedSampleSizes().contains(format.sampleSize()); -} - -QAudioFormat QAudioDeviceInfoInternal::preferredFormat() const -{ - QAudioFormat rc; - - UInt32 propSize = 0; - - if (AudioDeviceGetPropertyInfo(deviceId, - 0, - mode == QAudio::AudioInput, - kAudioDevicePropertyStreams, - &propSize, - 0) == noErr) { - - const int sc = propSize / sizeof(AudioStreamID); - - if (sc > 0) { - AudioStreamID* streams = new AudioStreamID[sc]; - - if (AudioDeviceGetProperty(deviceId, - 0, - mode == QAudio::AudioInput, - kAudioDevicePropertyStreams, - &propSize, - streams) == noErr) { - - for (int i = 0; i < sc; ++i) { - if (AudioStreamGetPropertyInfo(streams[i], - 0, - kAudioStreamPropertyPhysicalFormat, - &propSize, - 0) == noErr) { - - AudioStreamBasicDescription sf; - - if (AudioStreamGetProperty(streams[i], - 0, - kAudioStreamPropertyPhysicalFormat, - &propSize, - &sf) == noErr) { - rc = toQAudioFormat(sf); - break; - } - } - } - } - - delete streams; - } - } - - return rc; -} - -QString QAudioDeviceInfoInternal::deviceName() const -{ - return name; -} - -QStringList QAudioDeviceInfoInternal::supportedCodecs() -{ - return QStringList() << QString::fromLatin1("audio/pcm"); -} - -QList QAudioDeviceInfoInternal::supportedSampleRates() -{ - QSet rc; - - // Add some common frequencies - rc << 8000 << 11025 << 22050 << 44100; - - // - UInt32 propSize = 0; - - if (AudioDeviceGetPropertyInfo(deviceId, - 0, - mode == QAudio::AudioInput, - kAudioDevicePropertyAvailableNominalSampleRates, - &propSize, - 0) == noErr) { - - const int pc = propSize / sizeof(AudioValueRange); - - if (pc > 0) { - AudioValueRange* vr = new AudioValueRange[pc]; - - if (AudioDeviceGetProperty(deviceId, - 0, - mode == QAudio::AudioInput, - kAudioDevicePropertyAvailableNominalSampleRates, - &propSize, - vr) == noErr) { - - for (int i = 0; i < pc; ++i) - rc << vr[i].mMaximum; - } - - delete vr; - } - } - - return rc.toList(); -} - -QList QAudioDeviceInfoInternal::supportedChannelCounts() -{ - QList rc; - - // Can mix down to 1 channel - rc << 1; - - UInt32 propSize = 0; - int channels = 0; - - if (AudioDeviceGetPropertyInfo(deviceId, - 0, - mode == QAudio::AudioInput, - kAudioDevicePropertyStreamConfiguration, - &propSize, - 0) == noErr) { - - AudioBufferList* audioBufferList = static_cast(qMalloc(propSize)); - - if (audioBufferList != 0) { - if (AudioDeviceGetProperty(deviceId, - 0, - mode == QAudio::AudioInput, - kAudioDevicePropertyStreamConfiguration, - &propSize, - audioBufferList) == noErr) { - - for (int i = 0; i < int(audioBufferList->mNumberBuffers); ++i) { - channels += audioBufferList->mBuffers[i].mNumberChannels; - rc << channels; - } - } - - qFree(audioBufferList); - } - } - - return rc; -} - -QList QAudioDeviceInfoInternal::supportedSampleSizes() -{ - return QList() << 8 << 16 << 24 << 32 << 64; -} - -QList QAudioDeviceInfoInternal::supportedByteOrders() -{ - return QList() << QAudioFormat::LittleEndian << QAudioFormat::BigEndian; -} - -QList QAudioDeviceInfoInternal::supportedSampleTypes() -{ - return QList() << QAudioFormat::SignedInt << QAudioFormat::UnSignedInt << QAudioFormat::Float; -} - -static QByteArray get_device_info(AudioDeviceID audioDevice, QAudio::Mode mode) -{ - UInt32 size; - QByteArray device; - QDataStream ds(&device, QIODevice::WriteOnly); - AudioStreamBasicDescription sf; - CFStringRef name; - Boolean isInput = mode == QAudio::AudioInput; - - // Id - ds << quint32(audioDevice); - - // Mode - size = sizeof(AudioStreamBasicDescription); - if (AudioDeviceGetProperty(audioDevice, 0, isInput, kAudioDevicePropertyStreamFormat, - &size, &sf) != noErr) { - return QByteArray(); - } - ds << quint32(mode); - - // Name - size = sizeof(CFStringRef); - if (AudioDeviceGetProperty(audioDevice, 0, isInput, kAudioObjectPropertyName, - &size, &name) != noErr) { - qWarning() << "QAudioDeviceInfo: Unable to find device name"; - return QByteArray(); - } - ds << cfStringToQString(name); - - CFRelease(name); - - return device; -} - -QByteArray QAudioDeviceInfoInternal::defaultInputDevice() -{ - AudioDeviceID audioDevice; - UInt32 size = sizeof(audioDevice); - - if (AudioHardwareGetProperty(kAudioHardwarePropertyDefaultInputDevice, &size, - &audioDevice) != noErr) { - qWarning() << "QAudioDeviceInfo: Unable to find default input device"; - return QByteArray(); - } - - return get_device_info(audioDevice, QAudio::AudioInput); -} - -QByteArray QAudioDeviceInfoInternal::defaultOutputDevice() -{ - AudioDeviceID audioDevice; - UInt32 size = sizeof(audioDevice); - - if (AudioHardwareGetProperty(kAudioHardwarePropertyDefaultOutputDevice, &size, - &audioDevice) != noErr) { - qWarning() << "QAudioDeviceInfo: Unable to find default output device"; - return QByteArray(); - } - - return get_device_info(audioDevice, QAudio::AudioOutput); -} - -QList QAudioDeviceInfoInternal::availableDevices(QAudio::Mode mode) -{ - QList devices; - - UInt32 propSize = 0; - - if (AudioHardwareGetPropertyInfo(kAudioHardwarePropertyDevices, &propSize, 0) == noErr) { - - const int dc = propSize / sizeof(AudioDeviceID); - - if (dc > 0) { - AudioDeviceID* audioDevices = new AudioDeviceID[dc]; - - if (AudioHardwareGetProperty(kAudioHardwarePropertyDevices, &propSize, audioDevices) == noErr) { - for (int i = 0; i < dc; ++i) { - QByteArray info = get_device_info(audioDevices[i], mode); - if (!info.isNull()) - devices << info; - } - } - - delete audioDevices; - } - } - - return devices; -} - - -QT_END_NAMESPACE - diff --git a/src/multimediakit/audio/qaudiodeviceinfo_mac_p.h b/src/multimediakit/audio/qaudiodeviceinfo_mac_p.h deleted file mode 100644 index 3b9ca4676..000000000 --- a/src/multimediakit/audio/qaudiodeviceinfo_mac_p.h +++ /dev/null @@ -1,99 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -// -// W A R N I N G -// ------------- -// -// This file is not part of the Qt API. It exists for the convenience -// of other Qt classes. This header file may change from version to -// version without notice, or even be removed. -// -// We mean it. -// - - -#ifndef QDEVICEINFO_MAC_P_H -#define QDEVICEINFO_MAC_P_H - -#include - -#include - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -QT_MODULE(Multimedia) - - -class QAudioDeviceInfoInternal : public QAbstractAudioDeviceInfo -{ -public: - AudioDeviceID deviceId; - QString name; - QAudio::Mode mode; - - QAudioDeviceInfoInternal(QByteArray const& handle, QAudio::Mode mode); - - bool isFormatSupported(const QAudioFormat& format) const; - QAudioFormat preferredFormat() const; - - QString deviceName() const; - - QStringList supportedCodecs(); - QList supportedSampleRates(); - QList supportedChannelCounts(); - QList supportedSampleSizes(); - QList supportedByteOrders(); - QList supportedSampleTypes(); - - static QByteArray defaultInputDevice(); - static QByteArray defaultOutputDevice(); - - static QList availableDevices(QAudio::Mode mode); -}; - -QT_END_NAMESPACE - -QT_END_HEADER - -#endif // QDEVICEINFO_MAC_P_H diff --git a/src/multimediakit/audio/qaudiodeviceinfo_win32_p.cpp b/src/multimediakit/audio/qaudiodeviceinfo_win32_p.cpp deleted file mode 100644 index 10b9b777d..000000000 --- a/src/multimediakit/audio/qaudiodeviceinfo_win32_p.cpp +++ /dev/null @@ -1,465 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -// -// W A R N I N G -// ------------- -// -// This file is not part of the Qt API. It exists for the convenience -// of other Qt classes. This header file may change from version to -// version without notice, or even be removed. -// -// INTERNAL USE ONLY: Do NOT use for any other purpose. -// - - -#include -#include -#include "qaudiodeviceinfo_win32_p.h" -#include - -#if defined(Q_CC_MINGW) - -extern GUID CLSID_AudioInputDeviceCategory; - -#ifndef __IErrorLog_INTERFACE_DEFINED__ -#define __IErrorLog_INTERFACE_DEFINED__ - -DECLARE_INTERFACE_(IErrorLog, IUnknown) -{ - STDMETHOD(AddError)(THIS_ LPCOLESTR, EXCEPINFO *) PURE; -}; - -#endif /* __IErrorLog_INTERFACE_DEFINED__ */ - -#ifndef __IPropertyBag_INTERFACE_DEFINED__ -#define __IPropertyBag_INTERFACE_DEFINED__ - -const GUID IID_IPropertyBag = {0x55272A00, 0x42CB, 0x11CE, {0x81, 0x35, 0x00, 0xAA, 0x00, 0x4B, 0xB8, 0x51}}; - -DECLARE_INTERFACE_(IPropertyBag, IUnknown) -{ - STDMETHOD(Read)(THIS_ LPCOLESTR, VARIANT *, IErrorLog *) PURE; - STDMETHOD(Write)(THIS_ LPCOLESTR, VARIANT *) PURE; -}; - -#endif /* __IPropertyBag_INTERFACE_DEFINED__ */ - -#endif//Q_CC_MINGW - -QT_BEGIN_NAMESPACE - -// For mingw toolchain mmsystem.h only defines half the defines, so add if needed. -#ifndef WAVE_FORMAT_44M08 -#define WAVE_FORMAT_44M08 0x00000100 -#define WAVE_FORMAT_44S08 0x00000200 -#define WAVE_FORMAT_44M16 0x00000400 -#define WAVE_FORMAT_44S16 0x00000800 -#define WAVE_FORMAT_48M08 0x00001000 -#define WAVE_FORMAT_48S08 0x00002000 -#define WAVE_FORMAT_48M16 0x00004000 -#define WAVE_FORMAT_48S16 0x00008000 -#define WAVE_FORMAT_96M08 0x00010000 -#define WAVE_FORMAT_96S08 0x00020000 -#define WAVE_FORMAT_96M16 0x00040000 -#define WAVE_FORMAT_96S16 0x00080000 -#endif - - -QAudioDeviceInfoInternal::QAudioDeviceInfoInternal(QByteArray dev, QAudio::Mode mode) -{ - QDataStream ds(&dev, QIODevice::ReadOnly); - ds >> devId >> device; - this->mode = mode; - - updateLists(); -} - -QAudioDeviceInfoInternal::~QAudioDeviceInfoInternal() -{ - close(); -} - -bool QAudioDeviceInfoInternal::isFormatSupported(const QAudioFormat& format) const -{ - return testSettings(format); -} - -QAudioFormat QAudioDeviceInfoInternal::preferredFormat() const -{ - QAudioFormat nearest; - if(mode == QAudio::AudioOutput) { - nearest.setFrequency(44100); - nearest.setChannelCount(2); - nearest.setByteOrder(QAudioFormat::LittleEndian); - nearest.setSampleType(QAudioFormat::SignedInt); - nearest.setSampleSize(16); - nearest.setCodec(QLatin1String("audio/pcm")); - } else { - nearest.setFrequency(11025); - nearest.setChannelCount(1); - nearest.setByteOrder(QAudioFormat::LittleEndian); - nearest.setSampleType(QAudioFormat::SignedInt); - nearest.setSampleSize(8); - nearest.setCodec(QLatin1String("audio/pcm")); - } - return nearest; -} - -QString QAudioDeviceInfoInternal::deviceName() const -{ - return device; -} - -QStringList QAudioDeviceInfoInternal::supportedCodecs() -{ - updateLists(); - return codecz; -} - -QList QAudioDeviceInfoInternal::supportedSampleRates() -{ - updateLists(); - return freqz; -} - -QList QAudioDeviceInfoInternal::supportedChannelCounts() -{ - updateLists(); - return channelz; -} - -QList QAudioDeviceInfoInternal::supportedSampleSizes() -{ - updateLists(); - return sizez; -} - -QList QAudioDeviceInfoInternal::supportedByteOrders() -{ - updateLists(); - return byteOrderz; -} - -QList QAudioDeviceInfoInternal::supportedSampleTypes() -{ - updateLists(); - return typez; -} - - -bool QAudioDeviceInfoInternal::open() -{ - return true; -} - -void QAudioDeviceInfoInternal::close() -{ -} - -bool QAudioDeviceInfoInternal::testSettings(const QAudioFormat& format) const -{ - // Set nearest to closest settings that do work. - // See if what is in settings will work (return value). - - bool failed = false; - bool match = false; - - // check codec - for( int i = 0; i < codecz.count(); i++) { - if (format.codec() == codecz.at(i)) - match = true; - } - if (!match) failed = true; - - // check channel - match = false; - if (!failed) { - for( int i = 0; i < channelz.count(); i++) { - if (format.channels() == channelz.at(i)) { - match = true; - break; - } - } - if (!match) - failed = true; - } - - // check frequency - match = false; - if (!failed) { - for( int i = 0; i < freqz.count(); i++) { - if (format.frequency() == freqz.at(i)) { - match = true; - break; - } - } - if (!match) - failed = true; - } - - // check sample size - match = false; - if (!failed) { - for( int i = 0; i < sizez.count(); i++) { - if (format.sampleSize() == sizez.at(i)) { - match = true; - break; - } - } - if (!match) - failed = true; - } - - // check byte order - match = false; - if (!failed) { - for( int i = 0; i < byteOrderz.count(); i++) { - if (format.byteOrder() == byteOrderz.at(i)) { - match = true; - break; - } - } - if (!match) - failed = true; - } - - // check sample type - match = false; - if (!failed) { - for( int i = 0; i < typez.count(); i++) { - if (format.sampleType() == typez.at(i)) { - match = true; - break; - } - } - if (!match) - failed = true; - } - - if(!failed) { - // settings work - return true; - } - return false; -} - -void QAudioDeviceInfoInternal::updateLists() -{ - // redo all lists based on current settings - bool match = false; - DWORD fmt = NULL; - - if(mode == QAudio::AudioOutput) { - WAVEOUTCAPS woc; - if (waveOutGetDevCaps(devId, &woc, sizeof(WAVEOUTCAPS)) == MMSYSERR_NOERROR) { - match = true; - fmt = woc.dwFormats; - } - } else { - WAVEINCAPS woc; - if (waveInGetDevCaps(devId, &woc, sizeof(WAVEINCAPS)) == MMSYSERR_NOERROR) { - match = true; - fmt = woc.dwFormats; - } - } - sizez.clear(); - freqz.clear(); - channelz.clear(); - byteOrderz.clear(); - typez.clear(); - codecz.clear(); - - if(match) { - if((fmt && WAVE_FORMAT_1M08) - || (fmt && WAVE_FORMAT_1S08) - || (fmt && WAVE_FORMAT_2M08) - || (fmt && WAVE_FORMAT_2S08) - || (fmt && WAVE_FORMAT_4M08) - || (fmt && WAVE_FORMAT_4S08) - || (fmt && WAVE_FORMAT_48M08) - || (fmt && WAVE_FORMAT_48S08) - || (fmt && WAVE_FORMAT_96M08) - || (fmt && WAVE_FORMAT_96S08) - ) { - sizez.append(8); - } - if((fmt && WAVE_FORMAT_1M16) - || (fmt && WAVE_FORMAT_1S16) - || (fmt && WAVE_FORMAT_2M16) - || (fmt && WAVE_FORMAT_2S16) - || (fmt && WAVE_FORMAT_4M16) - || (fmt && WAVE_FORMAT_4S16) - || (fmt && WAVE_FORMAT_48M16) - || (fmt && WAVE_FORMAT_48S16) - || (fmt && WAVE_FORMAT_96M16) - || (fmt && WAVE_FORMAT_96S16) - ) { - sizez.append(16); - } - if((fmt && WAVE_FORMAT_1M08) - || (fmt && WAVE_FORMAT_1S08) - || (fmt && WAVE_FORMAT_1M16) - || (fmt && WAVE_FORMAT_1S16)) { - freqz.append(11025); - } - if((fmt && WAVE_FORMAT_2M08) - || (fmt && WAVE_FORMAT_2S08) - || (fmt && WAVE_FORMAT_2M16) - || (fmt && WAVE_FORMAT_2S16)) { - freqz.append(22050); - } - if((fmt && WAVE_FORMAT_4M08) - || (fmt && WAVE_FORMAT_4S08) - || (fmt && WAVE_FORMAT_4M16) - || (fmt && WAVE_FORMAT_4S16)) { - freqz.append(44100); - } - if((fmt && WAVE_FORMAT_48M08) - || (fmt && WAVE_FORMAT_48S08) - || (fmt && WAVE_FORMAT_48M16) - || (fmt && WAVE_FORMAT_48S16)) { - freqz.append(48000); - } - if((fmt && WAVE_FORMAT_96M08) - || (fmt && WAVE_FORMAT_96S08) - || (fmt && WAVE_FORMAT_96M16) - || (fmt && WAVE_FORMAT_96S16)) { - freqz.append(96000); - } - channelz.append(1); - channelz.append(2); - if (mode == QAudio::AudioOutput) { - channelz.append(4); - channelz.append(6); - channelz.append(8); - } - - byteOrderz.append(QAudioFormat::LittleEndian); - - typez.append(QAudioFormat::SignedInt); - typez.append(QAudioFormat::UnSignedInt); - - codecz.append(QLatin1String("audio/pcm")); - } - if (freqz.count() > 0) - freqz.prepend(8000); -} - -QList QAudioDeviceInfoInternal::availableDevices(QAudio::Mode mode) -{ - Q_UNUSED(mode) - - QList devices; - //enumerate device fullnames through directshow api - CoInitialize(NULL); - ICreateDevEnum *pDevEnum = NULL; - IEnumMoniker *pEnum = NULL; - // Create the System device enumerator - HRESULT hr = CoCreateInstance(CLSID_SystemDeviceEnum, NULL, - CLSCTX_INPROC_SERVER, IID_ICreateDevEnum, - reinterpret_cast(&pDevEnum)); - - unsigned long iNumDevs = mode == QAudio::AudioOutput ? waveOutGetNumDevs() : waveInGetNumDevs(); - if (SUCCEEDED(hr)) { - // Create the enumerator for the audio input/output category - if (pDevEnum->CreateClassEnumerator( - mode == QAudio::AudioOutput ? CLSID_AudioRendererCategory : CLSID_AudioInputDeviceCategory, - &pEnum, 0) == S_OK) { - pEnum->Reset(); - // go through and find all audio devices - IMoniker *pMoniker = NULL; - while (pEnum->Next(1, &pMoniker, NULL) == S_OK) { - IPropertyBag *pPropBag; - hr = pMoniker->BindToStorage(0,0,IID_IPropertyBag, - reinterpret_cast(&pPropBag)); - if (FAILED(hr)) { - pMoniker->Release(); - continue; // skip this one - } - // Find if it is a wave device - VARIANT var; - VariantInit(&var); - hr = pPropBag->Read(mode == QAudio::AudioOutput ? L"WaveOutID" : L"WaveInID", &var, 0); - if (SUCCEEDED(hr)) { - LONG waveID = var.lVal; - if (waveID >= 0 && waveID < LONG(iNumDevs)) { - VariantClear(&var); - // Find the description - hr = pPropBag->Read(L"FriendlyName", &var, 0); - if (SUCCEEDED(hr)) { - QByteArray device; - QDataStream ds(&device, QIODevice::WriteOnly); - ds << quint32(waveID) << QString::fromWCharArray(var.bstrVal); - devices.append(device); - } - } - } - - pPropBag->Release(); - pMoniker->Release(); - } - } - } - CoUninitialize(); - - return devices; -} - -QByteArray QAudioDeviceInfoInternal::defaultOutputDevice() -{ - QList list = availableDevices(QAudio::AudioOutput); - if (list.size() > 0) - return list.at(0); - else - return QByteArray(); -} - -QByteArray QAudioDeviceInfoInternal::defaultInputDevice() -{ - QList list = availableDevices(QAudio::AudioInput); - if (list.size() > 0) - return list.at(0); - else - return QByteArray(); -} - -QT_END_NAMESPACE diff --git a/src/multimediakit/audio/qaudiodeviceinfo_win32_p.h b/src/multimediakit/audio/qaudiodeviceinfo_win32_p.h deleted file mode 100644 index 2d4e27106..000000000 --- a/src/multimediakit/audio/qaudiodeviceinfo_win32_p.h +++ /dev/null @@ -1,120 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -// -// W A R N I N G -// ------------- -// -// This file is not part of the Qt API. It exists for the convenience -// of other Qt classes. This header file may change from version to -// version without notice, or even be removed. -// -// We mean it. -// - - -#ifndef QAUDIODEVICEINFOWIN_H -#define QAUDIODEVICEINFOWIN_H - -#include -#include -#include -#include - -#include -#include - - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -QT_MODULE(Multimedia) - - -const unsigned int MAX_SAMPLE_RATES = 5; -const unsigned int SAMPLE_RATES[] = { 8000, 11025, 22050, 44100, 48000 }; - -class QAudioDeviceInfoInternal : public QAbstractAudioDeviceInfo -{ - Q_OBJECT - -public: - QAudioDeviceInfoInternal(QByteArray dev,QAudio::Mode mode); - ~QAudioDeviceInfoInternal(); - - bool open(); - void close(); - - bool testSettings(const QAudioFormat& format) const; - void updateLists(); - QAudioFormat preferredFormat() const; - bool isFormatSupported(const QAudioFormat& format) const; - QString deviceName() const; - QStringList supportedCodecs(); - QList supportedSampleRates(); - QList supportedChannelCounts(); - QList supportedSampleSizes(); - QList supportedByteOrders(); - QList supportedSampleTypes(); - static QByteArray defaultInputDevice(); - static QByteArray defaultOutputDevice(); - static QList availableDevices(QAudio::Mode); - -private: - QAudio::Mode mode; - QString device; - quint32 devId; - QAudioFormat nearest; - QList freqz; - QList channelz; - QList sizez; - QList byteOrderz; - QStringList codecz; - QList typez; -}; - -QT_END_NAMESPACE - -QT_END_HEADER - - -#endif diff --git a/src/multimediakit/audio/qaudioformat.cpp b/src/multimediakit/audio/qaudioformat.cpp deleted file mode 100644 index 833928f8c..000000000 --- a/src/multimediakit/audio/qaudioformat.cpp +++ /dev/null @@ -1,407 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#include -#include - - -QT_BEGIN_NAMESPACE - - -class QAudioFormatPrivate : public QSharedData -{ -public: - QAudioFormatPrivate() - { - frequency = -1; - channels = -1; - sampleSize = -1; - byteOrder = QAudioFormat::Endian(QSysInfo::ByteOrder); - sampleType = QAudioFormat::Unknown; - } - - QAudioFormatPrivate(const QAudioFormatPrivate &other): - QSharedData(other), - codec(other.codec), - byteOrder(other.byteOrder), - sampleType(other.sampleType), - frequency(other.frequency), - channels(other.channels), - sampleSize(other.sampleSize) - { - } - - QAudioFormatPrivate& operator=(const QAudioFormatPrivate &other) - { - codec = other.codec; - byteOrder = other.byteOrder; - sampleType = other.sampleType; - frequency = other.frequency; - channels = other.channels; - sampleSize = other.sampleSize; - - return *this; - } - - QString codec; - QAudioFormat::Endian byteOrder; - QAudioFormat::SampleType sampleType; - int frequency; - int channels; - int sampleSize; -}; - -/*! - \class QAudioFormat - \brief The QAudioFormat class stores audio stream parameter information. - - \inmodule QtMultimediaKit - \ingroup multimedia - \since 1.0 - - An audio format specifies how data in an audio stream is arranged, - i.e, how the stream is to be interpreted. The encoding itself is - specified by the codec() used for the stream. - - In addition to the encoding, QAudioFormat contains other - parameters that further specify how the audio sample data is arranged. - These are the frequency, the number of channels, the sample size, - the sample type, and the byte order. The following table describes - these in more detail. - - \table - \header - \o Parameter - \o Description - \row - \o Sample Rate - \o Samples per second of audio data in Hertz. - \row - \o Number of channels - \o The number of audio channels (typically one for mono - or two for stereo) - \row - \o Sample size - \o How much data is stored in each sample (typically 8 - or 16 bits) - \row - \o Sample type - \o Numerical representation of sample (typically signed integer, - unsigned integer or float) - \row - \o Byte order - \o Byte ordering of sample (typically little endian, big endian) - \endtable - - This class is typically used in conjunction with QAudioInput or - QAudioOutput to allow you to specify the parameters of the audio - stream being read or written. - - You can obtain audio formats compatible with the audio device used - through functions in QAudioDeviceInfo. This class also lets you - query available parameter values for a device, so that you can set - the parameters yourself. See the \l QAudioDeviceInfo class - description for details. You need to know the format of the audio - streams you wish to play or record. -*/ - -/*! - Construct a new audio format. - - Values are initialized as follows: - \list - \o sampleRate() = -1 - \o channelCount() = -1 - \o sampleSize() = -1 - \o byteOrder() = QAudioFormat::Endian(QSysInfo::ByteOrder) - \o sampleType() = QAudioFormat::Unknown - \c codec() = "" - \endlist -*/ -QAudioFormat::QAudioFormat(): - d(new QAudioFormatPrivate) -{ -} - -/*! - Construct a new audio format using \a other. - \since 1.0 -*/ -QAudioFormat::QAudioFormat(const QAudioFormat &other): - d(other.d) -{ -} - -/*! - Destroy this audio format. -*/ -QAudioFormat::~QAudioFormat() -{ -} - -/*! - Assigns \a other to this QAudioFormat implementation. - \since 1.0 -*/ -QAudioFormat& QAudioFormat::operator=(const QAudioFormat &other) -{ - d = other.d; - return *this; -} - -/*! - Returns true if this QAudioFormat is equal to the \a other - QAudioFormat; otherwise returns false. - - All elements of QAudioFormat are used for the comparison. - \since 1.0 -*/ -bool QAudioFormat::operator==(const QAudioFormat &other) const -{ - return d->frequency == other.d->frequency && - d->channels == other.d->channels && - d->sampleSize == other.d->sampleSize && - d->byteOrder == other.d->byteOrder && - d->codec == other.d->codec && - d->sampleType == other.d->sampleType; -} - -/*! - Returns true if this QAudioFormat is not equal to the \a other - QAudioFormat; otherwise returns false. - - All elements of QAudioFormat are used for the comparison. - \since 1.0 -*/ -bool QAudioFormat::operator!=(const QAudioFormat& other) const -{ - return !(*this == other); -} - -/*! - Returns true if all of the parameters are valid. - \since 1.0 -*/ -bool QAudioFormat::isValid() const -{ - return d->frequency != -1 && d->channels != -1 && d->sampleSize != -1 && - d->sampleType != QAudioFormat::Unknown && !d->codec.isEmpty(); -} - -/*! - Sets the sample rate to \a samplerate Hertz. - - \since 1.0 -*/ -void QAudioFormat::setSampleRate(int samplerate) -{ - d->frequency = samplerate; -} - -/*! - \obsolete - - Use setSampleRate() instead. -*/ -void QAudioFormat::setFrequency(int frequency) -{ - d->frequency = frequency; -} - -/*! - Returns the current sample rate in Hertz. - - \since 1.0 -*/ -int QAudioFormat::sampleRate() const -{ - return d->frequency; -} - -/*! - \obsolete - - Use sampleRate() instead. -*/ -int QAudioFormat::frequency() const -{ - return d->frequency; -} - -/*! - Sets the channel count to \a channels. - - \since 1.0 -*/ -void QAudioFormat::setChannelCount(int channels) -{ - d->channels = channels; -} - -/*! - \obsolete - - Use setChannelCount() instead. -*/ -void QAudioFormat::setChannels(int channels) -{ - d->channels = channels; -} - -/*! - Returns the current channel count value. - - \since 1.0 -*/ -int QAudioFormat::channelCount() const -{ - return d->channels; -} - -/*! - \obsolete - - Use channelCount() instead. -*/ -int QAudioFormat::channels() const -{ - return d->channels; -} - -/*! - Sets the sample size to the \a sampleSize specified, in bits. - - This is typically 8 or 16, but some systems may support higher sample sizes. - \since 1.0 -*/ -void QAudioFormat::setSampleSize(int sampleSize) -{ - d->sampleSize = sampleSize; -} - -/*! - Returns the current sample size value, in bits. - \since 1.0 -*/ -int QAudioFormat::sampleSize() const -{ - return d->sampleSize; -} - -/*! - Sets the codec to \a codec. - - The parameter to this function should be one of the types - reported by the QAudioDeviceInfo::supportedCodecs() function - for the audio device you are working with. - - \since 1.0 - \sa QAudioDeviceInfo::supportedCodecs() -*/ -void QAudioFormat::setCodec(const QString &codec) -{ - d->codec = codec; -} - -/*! - Returns the current codec identifier. - - \since 1.0 - \sa QAudioDeviceInfo::supportedCodecs() -*/ -QString QAudioFormat::codec() const -{ - return d->codec; -} - -/*! - Sets the byteOrder to \a byteOrder. - \since 1.0 -*/ -void QAudioFormat::setByteOrder(QAudioFormat::Endian byteOrder) -{ - d->byteOrder = byteOrder; -} - -/*! - Returns the current byteOrder value. - \since 1.0 -*/ -QAudioFormat::Endian QAudioFormat::byteOrder() const -{ - return d->byteOrder; -} - -/*! - Sets the sampleType to \a sampleType. - \since 1.0 -*/ -void QAudioFormat::setSampleType(QAudioFormat::SampleType sampleType) -{ - d->sampleType = sampleType; -} - -/*! - Returns the current SampleType value. - \since 1.0 -*/ -QAudioFormat::SampleType QAudioFormat::sampleType() const -{ - return d->sampleType; -} - -/*! - \enum QAudioFormat::SampleType - - \value Unknown Not Set - \value SignedInt Samples are signed integers - \value UnSignedInt Samples are unsigned intergers - \value Float Samples are floats -*/ - -/*! - \enum QAudioFormat::Endian - - \value BigEndian Samples are big endian byte order - \value LittleEndian Samples are little endian byte order -*/ - -QT_END_NAMESPACE - diff --git a/src/multimediakit/audio/qaudioformat.h b/src/multimediakit/audio/qaudioformat.h deleted file mode 100644 index c6600cdcf..000000000 --- a/src/multimediakit/audio/qaudioformat.h +++ /dev/null @@ -1,109 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - - -#ifndef QAUDIOFORMAT_H -#define QAUDIOFORMAT_H - -#include -#include - -#include -#include - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -QT_MODULE(Multimedia) - - - -class QAudioFormatPrivate; - -class Q_MULTIMEDIA_EXPORT QAudioFormat -{ -public: - enum SampleType { Unknown, SignedInt, UnSignedInt, Float }; - enum Endian { BigEndian = QSysInfo::BigEndian, LittleEndian = QSysInfo::LittleEndian }; - - QAudioFormat(); - QAudioFormat(const QAudioFormat &other); - ~QAudioFormat(); - - QAudioFormat& operator=(const QAudioFormat &other); - bool operator==(const QAudioFormat &other) const; - bool operator!=(const QAudioFormat &other) const; - - bool isValid() const; - - void setFrequency(int frequency); - int frequency() const; - void setSampleRate(int sampleRate); - int sampleRate() const; - - void setChannels(int channels); - int channels() const; - void setChannelCount(int channelCount); - int channelCount() const; - - void setSampleSize(int sampleSize); - int sampleSize() const; - - void setCodec(const QString &codec); - QString codec() const; - - void setByteOrder(QAudioFormat::Endian byteOrder); - QAudioFormat::Endian byteOrder() const; - - void setSampleType(QAudioFormat::SampleType sampleType); - QAudioFormat::SampleType sampleType() const; - -private: - QSharedDataPointer d; -}; - - -QT_END_NAMESPACE - -QT_END_HEADER - -#endif // QAUDIOFORMAT_H diff --git a/src/multimediakit/audio/qaudioinput.cpp b/src/multimediakit/audio/qaudioinput.cpp deleted file mode 100644 index 4a6bfaefd..000000000 --- a/src/multimediakit/audio/qaudioinput.cpp +++ /dev/null @@ -1,402 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - - -#include "qaudio.h" -#include "qaudiodeviceinfo.h" -#include "qaudiosystem.h" -#include "qaudioinput.h" - -#include "qaudiodevicefactory_p.h" - -QT_BEGIN_NAMESPACE - -/*! - \class QAudioInput - \brief The QAudioInput class provides an interface for receiving audio data from an audio input device. - - \inmodule QtMultimediaKit - \ingroup multimedia - \since 1.0 - - You can construct an audio input with the system's - \l{QAudioDeviceInfo::defaultInputDevice()}{default audio input - device}. It is also possible to create QAudioInput with a - specific QAudioDeviceInfo. When you create the audio input, you - should also send in the QAudioFormat to be used for the recording - (see the QAudioFormat class description for details). - - To record to a file: - - QAudioInput lets you record audio with an audio input device. The - default constructor of this class will use the systems default - audio device, but you can also specify a QAudioDeviceInfo for a - specific device. You also need to pass in the QAudioFormat in - which you wish to record. - - Starting up the QAudioInput is simply a matter of calling start() - with a QIODevice opened for writing. For instance, to record to a - file, you can: - - \snippet doc/src/snippets/multimedia-snippets/audio.cpp Audio input class members - - \snippet doc/src/snippets/multimedia-snippets/audio.cpp Audio input setup - - This will start recording if the format specified is supported by - the input device (you can check this with - QAudioDeviceInfo::isFormatSupported(). In case there are any - snags, use the error() function to check what went wrong. We stop - recording in the \c stopRecording() slot. - - \snippet doc/src/snippets/multimedia-snippets/audio.cpp Audio input stop recording - - At any point in time, QAudioInput will be in one of four states: - active, suspended, stopped, or idle. These states are specified by - the QAudio::State enum. You can request a state change directly through - suspend(), resume(), stop(), reset(), and start(). The current - state is reported by state(). QAudioOutput will also signal you - when the state changes (stateChanged()). - - QAudioInput provides several ways of measuring the time that has - passed since the start() of the recording. The \c processedUSecs() - function returns the length of the stream in microseconds written, - i.e., it leaves out the times the audio input was suspended or idle. - The elapsedUSecs() function returns the time elapsed since start() was called regardless of - which states the QAudioInput has been in. - - If an error should occur, you can fetch its reason with error(). - The possible error reasons are described by the QAudio::Error - enum. The QAudioInput will enter the \l{QAudio::}{StoppedState} when - an error is encountered. Connect to the stateChanged() signal to - handle the error: - - \snippet doc/src/snippets/multimedia-snippets/audio.cpp Audio input state changed - - \sa QAudioOutput, QAudioDeviceInfo -*/ - -/*! - Construct a new audio input and attach it to \a parent. - The default audio input device is used with the output - \a format parameters. - \since 1.0 -*/ - -QAudioInput::QAudioInput(const QAudioFormat &format, QObject *parent): - QObject(parent) -{ - d = QAudioDeviceFactory::createDefaultInputDevice(format); - connect(d, SIGNAL(notify()), SIGNAL(notify())); - connect(d, SIGNAL(stateChanged(QAudio::State)), SIGNAL(stateChanged(QAudio::State))); -} - -/*! - Construct a new audio input and attach it to \a parent. - The device referenced by \a audioDevice is used with the input - \a format parameters. - \since 1.0 -*/ - -QAudioInput::QAudioInput(const QAudioDeviceInfo &audioDevice, const QAudioFormat &format, QObject *parent): - QObject(parent) -{ - d = QAudioDeviceFactory::createInputDevice(audioDevice, format); - connect(d, SIGNAL(notify()), SIGNAL(notify())); - connect(d, SIGNAL(stateChanged(QAudio::State)), SIGNAL(stateChanged(QAudio::State))); -} - -/*! - Destroy this audio input. -*/ - -QAudioInput::~QAudioInput() -{ - delete d; -} - -/*! - Uses the \a device as the QIODevice to transfer data. - Passing a QIODevice allows the data to be transferred without any extra code. - All that is required is to open the QIODevice. - - If able to successfully get audio data from the systems audio device the - state() is set to either QAudio::ActiveState or QAudio::IdleState, - error() is set to QAudio::NoError and the stateChanged() signal is emitted. - - If a problem occurs during this process the error() is set to QAudio::OpenError, - state() is set to QAudio::StoppedState and stateChanged() signal is emitted. - - \since 1.0 - \sa QIODevice -*/ - -void QAudioInput::start(QIODevice* device) -{ - d->start(device); -} - -/*! - Returns a pointer to the QIODevice being used to handle the data - transfer. This QIODevice can be used to read() audio data - directly. - - If able to access the systems audio device the state() is set to - QAudio::IdleState, error() is set to QAudio::NoError - and the stateChanged() signal is emitted. - - If a problem occurs during this process the error() is set to QAudio::OpenError, - state() is set to QAudio::StoppedState and stateChanged() signal is emitted. - - \since 1.0 - \sa QIODevice -*/ - -QIODevice* QAudioInput::start() -{ - return d->start(); -} - -/*! - Returns the QAudioFormat being used. - \since 1.0 -*/ - -QAudioFormat QAudioInput::format() const -{ - return d->format(); -} - -/*! - Stops the audio input, detaching from the system resource. - - Sets error() to QAudio::NoError, state() to QAudio::StoppedState and - emit stateChanged() signal. - \since 1.0 -*/ - -void QAudioInput::stop() -{ - d->stop(); -} - -/*! - Drops all audio data in the buffers, resets buffers to zero. - \since 1.0 -*/ - -void QAudioInput::reset() -{ - d->reset(); -} - -/*! - Stops processing audio data, preserving buffered audio data. - - Sets error() to QAudio::NoError, state() to QAudio::SuspendedState and - emit stateChanged() signal. - \since 1.0 -*/ - -void QAudioInput::suspend() -{ - d->suspend(); -} - -/*! - Resumes processing audio data after a suspend(). - - Sets error() to QAudio::NoError. - Sets state() to QAudio::ActiveState if you previously called start(QIODevice*). - Sets state() to QAudio::IdleState if you previously called start(). - emits stateChanged() signal. - \since 1.0 -*/ - -void QAudioInput::resume() -{ - d->resume(); -} - -/*! - Sets the audio buffer size to \a value milliseconds. - - Note: This function can be called anytime before start(), calls to this - are ignored after start(). It should not be assumed that the buffer size - set is the actual buffer size used, calling bufferSize() anytime after start() - will return the actual buffer size being used. - - \since 1.0 -*/ - -void QAudioInput::setBufferSize(int value) -{ - d->setBufferSize(value); -} - -/*! - Returns the audio buffer size in milliseconds. - - If called before start(), returns platform default value. - If called before start() but setBufferSize() was called prior, returns value set by setBufferSize(). - If called after start(), returns the actual buffer size being used. This may not be what was set previously - by setBufferSize(). - - \since 1.0 -*/ - -int QAudioInput::bufferSize() const -{ - return d->bufferSize(); -} - -/*! - Returns the amount of audio data available to read in bytes. - - NOTE: returned value is only valid while in QAudio::ActiveState or QAudio::IdleState - state, otherwise returns zero. - \since 1.0 -*/ - -int QAudioInput::bytesReady() const -{ - /* - -If not ActiveState|IdleState, return 0 - -return amount of audio data available to read - */ - return d->bytesReady(); -} - -/*! - Returns the period size in bytes. - - Note: This is the recommended read size in bytes. - \since 1.0 -*/ - -int QAudioInput::periodSize() const -{ - return d->periodSize(); -} - -/*! - Sets the interval for notify() signal to be emitted. - This is based on the \a ms of audio data processed - not on actual real-time. - The minimum resolution of the timer is platform specific and values - should be checked with notifyInterval() to confirm actual value - being used. - \since 1.0 -*/ - -void QAudioInput::setNotifyInterval(int ms) -{ - d->setNotifyInterval(ms); -} - -/*! - Returns the notify interval in milliseconds. - \since 1.0 -*/ - -int QAudioInput::notifyInterval() const -{ - return d->notifyInterval(); -} - -/*! - Returns the amount of audio data processed since start() - was called in microseconds. - \since 1.0 -*/ - -qint64 QAudioInput::processedUSecs() const -{ - return d->processedUSecs(); -} - -/*! - Returns the microseconds since start() was called, including time in Idle and - Suspend states. - \since 1.0 -*/ - -qint64 QAudioInput::elapsedUSecs() const -{ - return d->elapsedUSecs(); -} - -/*! - Returns the error state. - \since 1.0 -*/ - -QAudio::Error QAudioInput::error() const -{ - return d->error(); -} - -/*! - Returns the state of audio processing. - \since 1.0 -*/ - -QAudio::State QAudioInput::state() const -{ - return d->state(); -} - -/*! - \fn QAudioInput::stateChanged(QAudio::State state) - This signal is emitted when the device \a state has changed. - \since 1.0 -*/ - -/*! - \fn QAudioInput::notify() - This signal is emitted when x ms of audio data has been processed - the interval set by setNotifyInterval(x). - \since 1.0 -*/ - -QT_END_NAMESPACE - -#include "moc_qaudioinput.cpp" - diff --git a/src/multimediakit/audio/qaudioinput.h b/src/multimediakit/audio/qaudioinput.h deleted file mode 100644 index 8684a10fe..000000000 --- a/src/multimediakit/audio/qaudioinput.h +++ /dev/null @@ -1,114 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - - -#ifndef QAUDIOINPUT_H -#define QAUDIOINPUT_H - -#include - -#include -#include - -#include -#include -#include - - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -QT_MODULE(Multimedia) - - - -class QAbstractAudioInput; - -class Q_MULTIMEDIA_EXPORT QAudioInput : public QObject -{ - Q_OBJECT - -public: - explicit QAudioInput(const QAudioFormat &format = QAudioFormat(), QObject *parent = 0); - explicit QAudioInput(const QAudioDeviceInfo &audioDeviceInfo, const QAudioFormat &format = QAudioFormat(), QObject *parent = 0); - ~QAudioInput(); - - QAudioFormat format() const; - - void start(QIODevice *device); - QIODevice* start(); - - void stop(); - void reset(); - void suspend(); - void resume(); - - void setBufferSize(int bytes); - int bufferSize() const; - - int bytesReady() const; - int periodSize() const; - - void setNotifyInterval(int milliSeconds); - int notifyInterval() const; - - qint64 processedUSecs() const; - qint64 elapsedUSecs() const; - - QAudio::Error error() const; - QAudio::State state() const; - -Q_SIGNALS: - void stateChanged(QAudio::State); - void notify(); - -private: - Q_DISABLE_COPY(QAudioInput) - - QAbstractAudioInput* d; -}; - -QT_END_NAMESPACE - -QT_END_HEADER - -#endif // QAUDIOINPUT_H diff --git a/src/multimediakit/audio/qaudioinput_alsa_p.cpp b/src/multimediakit/audio/qaudioinput_alsa_p.cpp deleted file mode 100644 index 044458cd0..000000000 --- a/src/multimediakit/audio/qaudioinput_alsa_p.cpp +++ /dev/null @@ -1,867 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -// -// W A R N I N G -// ------------- -// -// This file is not part of the Qt API. It exists for the convenience -// of other Qt classes. This header file may change from version to -// version without notice, or even be removed. -// -// INTERNAL USE ONLY: Do NOT use for any other purpose. -// - -#include -#include "qaudioinput_alsa_p.h" -#include "qaudiodeviceinfo_alsa_p.h" - -QT_BEGIN_NAMESPACE - -//#define DEBUG_AUDIO 1 - -QAudioInputPrivate::QAudioInputPrivate(const QByteArray &device) -{ - bytesAvailable = 0; - handle = 0; - ahandler = 0; - access = SND_PCM_ACCESS_RW_INTERLEAVED; - pcmformat = SND_PCM_FORMAT_S16; - buffer_size = 0; - period_size = 0; - buffer_time = 100000; - period_time = 20000; - totalTimeValue = 0; - intervalTime = 1000; - errorState = QAudio::NoError; - deviceState = QAudio::StoppedState; - audioSource = 0; - pullMode = true; - resuming = false; - - m_device = device; - - timer = new QTimer(this); - connect(timer,SIGNAL(timeout()),SLOT(userFeed())); -} - -QAudioInputPrivate::~QAudioInputPrivate() -{ - close(); - disconnect(timer, SIGNAL(timeout())); - QCoreApplication::processEvents(); - delete timer; -} - -QAudio::Error QAudioInputPrivate::error() const -{ - return errorState; -} - -QAudio::State QAudioInputPrivate::state() const -{ - return deviceState; -} - -void QAudioInputPrivate::setFormat(const QAudioFormat& fmt) -{ - if (deviceState == QAudio::StoppedState) - settings = fmt; -} - -QAudioFormat QAudioInputPrivate::format() const -{ - return settings; -} - -int QAudioInputPrivate::xrun_recovery(int err) -{ - int count = 0; - bool reset = false; - - if(err == -EPIPE) { - errorState = QAudio::UnderrunError; - err = snd_pcm_prepare(handle); - if(err < 0) - reset = true; - else { - bytesAvailable = checkBytesReady(); - if (bytesAvailable <= 0) - reset = true; - } - - } else if((err == -ESTRPIPE)||(err == -EIO)) { - errorState = QAudio::IOError; - while((err = snd_pcm_resume(handle)) == -EAGAIN){ - usleep(100); - count++; - if(count > 5) { - reset = true; - break; - } - } - if(err < 0) { - err = snd_pcm_prepare(handle); - if(err < 0) - reset = true; - } - } - if(reset) { - close(); - open(); - snd_pcm_prepare(handle); - return 0; - } - return err; -} - -int QAudioInputPrivate::setFormat() -{ - snd_pcm_format_t format = SND_PCM_FORMAT_UNKNOWN; - - if(settings.sampleSize() == 8) { - format = SND_PCM_FORMAT_U8; - } else if(settings.sampleSize() == 16) { - if(settings.sampleType() == QAudioFormat::SignedInt) { - if(settings.byteOrder() == QAudioFormat::LittleEndian) - format = SND_PCM_FORMAT_S16_LE; - else - format = SND_PCM_FORMAT_S16_BE; - } else if(settings.sampleType() == QAudioFormat::UnSignedInt) { - if(settings.byteOrder() == QAudioFormat::LittleEndian) - format = SND_PCM_FORMAT_U16_LE; - else - format = SND_PCM_FORMAT_U16_BE; - } - } else if(settings.sampleSize() == 24) { - if(settings.sampleType() == QAudioFormat::SignedInt) { - if(settings.byteOrder() == QAudioFormat::LittleEndian) - format = SND_PCM_FORMAT_S24_LE; - else - format = SND_PCM_FORMAT_S24_BE; - } else if(settings.sampleType() == QAudioFormat::UnSignedInt) { - if(settings.byteOrder() == QAudioFormat::LittleEndian) - format = SND_PCM_FORMAT_U24_LE; - else - format = SND_PCM_FORMAT_U24_BE; - } - } else if(settings.sampleSize() == 32) { - if(settings.sampleType() == QAudioFormat::SignedInt) { - if(settings.byteOrder() == QAudioFormat::LittleEndian) - format = SND_PCM_FORMAT_S32_LE; - else - format = SND_PCM_FORMAT_S32_BE; - } else if(settings.sampleType() == QAudioFormat::UnSignedInt) { - if(settings.byteOrder() == QAudioFormat::LittleEndian) - format = SND_PCM_FORMAT_U32_LE; - else - format = SND_PCM_FORMAT_U32_BE; - } else if(settings.sampleType() == QAudioFormat::Float) { - if(settings.byteOrder() == QAudioFormat::LittleEndian) - format = SND_PCM_FORMAT_FLOAT_LE; - else - format = SND_PCM_FORMAT_FLOAT_BE; - } - } else if(settings.sampleSize() == 64) { - if(settings.byteOrder() == QAudioFormat::LittleEndian) - format = SND_PCM_FORMAT_FLOAT64_LE; - else - format = SND_PCM_FORMAT_FLOAT64_BE; - } - - return format != SND_PCM_FORMAT_UNKNOWN - ? snd_pcm_hw_params_set_format( handle, hwparams, format) - : -1; -} - -void QAudioInputPrivate::start(QIODevice* device) -{ - if(deviceState != QAudio::StoppedState) - close(); - - if(!pullMode && audioSource) - delete audioSource; - - pullMode = true; - audioSource = device; - - deviceState = QAudio::ActiveState; - - if( !open() ) - return; - - emit stateChanged(deviceState); -} - -QIODevice* QAudioInputPrivate::start() -{ - if(deviceState != QAudio::StoppedState) - close(); - - if(!pullMode && audioSource) - delete audioSource; - - pullMode = false; - audioSource = new InputPrivate(this); - audioSource->open(QIODevice::ReadOnly | QIODevice::Unbuffered); - - deviceState = QAudio::IdleState; - - if( !open() ) - return 0; - - emit stateChanged(deviceState); - - return audioSource; -} - -void QAudioInputPrivate::stop() -{ - if(deviceState == QAudio::StoppedState) - return; - - deviceState = QAudio::StoppedState; - - close(); - emit stateChanged(deviceState); -} - -bool QAudioInputPrivate::open() -{ -#ifdef DEBUG_AUDIO - QTime now(QTime::currentTime()); - qDebug()< devices = QAudioDeviceInfoInternal::availableDevices(QAudio::AudioInput); - if(dev.compare(QLatin1String("default")) == 0) { -#if(SND_LIB_MAJOR == 1 && SND_LIB_MINOR == 0 && SND_LIB_SUBMINOR >= 14) - if (devices.size() > 0) - dev = QLatin1String(devices.first()); - else - return false; -#else - dev = QLatin1String("hw:0,0"); -#endif - } else { -#if(SND_LIB_MAJOR == 1 && SND_LIB_MINOR == 0 && SND_LIB_SUBMINOR >= 14) - dev = QLatin1String(m_device); -#else - int idx = 0; - char *name; - - QString shortName = QLatin1String(m_device.mid(m_device.indexOf('=',0)+1).constData()); - - while(snd_card_get_name(idx,&name) == 0) { - if(qstrncmp(shortName.toLocal8Bit().constData(),name,shortName.length()) == 0) - break; - idx++; - } - dev = QString(QLatin1String("hw:%1,0")).arg(idx); -#endif - } - - // Step 1: try and open the device - while((count < 5) && (err < 0)) { - err=snd_pcm_open(&handle,dev.toLocal8Bit().constData(),SND_PCM_STREAM_CAPTURE,0); - if(err < 0) - count++; - } - if (( err < 0)||(handle == 0)) { - errorState = QAudio::OpenError; - deviceState = QAudio::StoppedState; - emit stateChanged(deviceState); - return false; - } - snd_pcm_nonblock( handle, 0 ); - - // Step 2: Set the desired HW parameters. - snd_pcm_hw_params_alloca( &hwparams ); - - bool fatal = false; - QString errMessage; - unsigned int chunks = 8; - - err = snd_pcm_hw_params_any( handle, hwparams ); - if ( err < 0 ) { - fatal = true; - errMessage = QString::fromLatin1("QAudioInput: snd_pcm_hw_params_any: err = %1").arg(err); - } - if ( !fatal ) { - err = snd_pcm_hw_params_set_rate_resample( handle, hwparams, 1 ); - if ( err < 0 ) { - fatal = true; - errMessage = QString::fromLatin1("QAudioInput: snd_pcm_hw_params_set_rate_resample: err = %1").arg(err); - } - } - if ( !fatal ) { - err = snd_pcm_hw_params_set_access( handle, hwparams, access ); - if ( err < 0 ) { - fatal = true; - errMessage = QString::fromLatin1("QAudioInput: snd_pcm_hw_params_set_access: err = %1").arg(err); - } - } - if ( !fatal ) { - err = setFormat(); - if ( err < 0 ) { - fatal = true; - errMessage = QString::fromLatin1("QAudioInput: snd_pcm_hw_params_set_format: err = %1").arg(err); - } - } - if ( !fatal ) { - err = snd_pcm_hw_params_set_channels( handle, hwparams, (unsigned int)settings.channels() ); - if ( err < 0 ) { - fatal = true; - errMessage = QString::fromLatin1("QAudioInput: snd_pcm_hw_params_set_channels: err = %1").arg(err); - } - } - if ( !fatal ) { - err = snd_pcm_hw_params_set_rate_near( handle, hwparams, &freakuency, 0 ); - if ( err < 0 ) { - fatal = true; - errMessage = QString::fromLatin1("QAudioInput: snd_pcm_hw_params_set_rate_near: err = %1").arg(err); - } - } - if ( !fatal ) { - err = snd_pcm_hw_params_set_buffer_time_near(handle, hwparams, &buffer_time, &dir); - if ( err < 0 ) { - fatal = true; - errMessage = QString::fromLatin1("QAudioInput: snd_pcm_hw_params_set_buffer_time_near: err = %1").arg(err); - } - } - if ( !fatal ) { - err = snd_pcm_hw_params_set_period_time_near(handle, hwparams, &period_time, &dir); - if ( err < 0 ) { - fatal = true; - errMessage = QString::fromLatin1("QAudioInput: snd_pcm_hw_params_set_period_time_near: err = %1").arg(err); - } - } - if ( !fatal ) { - err = snd_pcm_hw_params_set_periods_near(handle, hwparams, &chunks, &dir); - if ( err < 0 ) { - fatal = true; - errMessage = QString::fromLatin1("QAudioInput: snd_pcm_hw_params_set_periods_near: err = %1").arg(err); - } - } - if ( !fatal ) { - err = snd_pcm_hw_params(handle, hwparams); - if ( err < 0 ) { - fatal = true; - errMessage = QString::fromLatin1("QAudioInput: snd_pcm_hw_params: err = %1").arg(err); - } - } - if( err < 0) { - qWarning()<start(period_time*chunks/2000); - - errorState = QAudio::NoError; - - totalTimeValue = 0; - - return true; -} - -void QAudioInputPrivate::close() -{ - timer->stop(); - - if ( handle ) { - snd_pcm_drop( handle ); - snd_pcm_close( handle ); - handle = 0; - } -} - -int QAudioInputPrivate::checkBytesReady() -{ - if(resuming) - bytesAvailable = period_size; - else if(deviceState != QAudio::ActiveState - && deviceState != QAudio::IdleState) - bytesAvailable = 0; - else { - int frames = snd_pcm_avail_update(handle); - if (frames < 0) { - bytesAvailable = frames; - } else { - if((int)frames > (int)buffer_frames) - frames = buffer_frames; - bytesAvailable = snd_pcm_frames_to_bytes(handle, frames); - } - } - return bytesAvailable; -} - -int QAudioInputPrivate::bytesReady() const -{ - return qMax(bytesAvailable, 0); -} - -qint64 QAudioInputPrivate::read(char* data, qint64 len) -{ - // Read in some audio data and write it to QIODevice, pull mode - if ( !handle ) - return 0; - - int bytesRead = 0; - int bytesInRingbufferBeforeRead = ringBuffer.bytesOfDataInBuffer(); - - if (ringBuffer.bytesOfDataInBuffer() < len) { - - // bytesAvaiable is saved as a side effect of checkBytesReady(). - int bytesToRead = checkBytesReady(); - - if (bytesToRead < 0) { - // bytesAvailable as negative is error code, try to recover from it. - xrun_recovery(bytesToRead); - bytesToRead = checkBytesReady(); - if (bytesToRead < 0) { - // recovery failed must stop and set error. - close(); - errorState = QAudio::IOError; - deviceState = QAudio::StoppedState; - emit stateChanged(deviceState); - return 0; - } - } - - bytesToRead = qMin(len, bytesToRead); - bytesToRead = qMin(ringBuffer.freeBytes(), bytesToRead); - bytesToRead -= bytesToRead % period_size; - - int count=0; - int err = 0; - while(count < 5 && bytesToRead > 0) { - char buffer[bytesToRead]; - int chunks = bytesToRead / period_size; - int frames = chunks * period_frames; - if (frames > (int)buffer_frames) - frames = buffer_frames; - - int readFrames = snd_pcm_readi(handle, buffer, frames); - - if (readFrames >= 0) { - bytesRead = snd_pcm_frames_to_bytes(handle, readFrames); - ringBuffer.write(buffer, bytesRead); -#ifdef DEBUG_AUDIO - qDebug() << QString::fromLatin1("read in bytes = %1 (frames=%2)").arg(bytesRead).arg(readFrames).toLatin1().constData(); -#endif - break; - } else if((readFrames == -EAGAIN) || (readFrames == -EINTR)) { - errorState = QAudio::IOError; - err = 0; - break; - } else { - if(readFrames == -EPIPE) { - errorState = QAudio::UnderrunError; - err = snd_pcm_prepare(handle); - } else if(readFrames == -ESTRPIPE) { - err = snd_pcm_prepare(handle); - } - if(err != 0) break; - } - count++; - } - - } - - bytesRead += bytesInRingbufferBeforeRead; - - if (bytesRead > 0) { - // got some send it onward -#ifdef DEBUG_AUDIO - qDebug() << "frames to write to QIODevice = " << - snd_pcm_bytes_to_frames( handle, (int)bytesRead ) << " (" << bytesRead << ") bytes"; -#endif - if (deviceState != QAudio::ActiveState && deviceState != QAudio::IdleState) - return 0; - - if (pullMode) { - qint64 l = 0; - qint64 bytesWritten = 0; - while (ringBuffer.bytesOfDataInBuffer() > 0) { - l = audioSource->write(ringBuffer.availableData(), ringBuffer.availableDataBlockSize()); - if (l > 0) { - ringBuffer.readBytes(l); - bytesWritten += l; - } else { - break; - } - } - - if (l < 0) { - close(); - errorState = QAudio::IOError; - deviceState = QAudio::StoppedState; - emit stateChanged(deviceState); - } else if (l == 0 && bytesWritten == 0) { - if (deviceState != QAudio::IdleState) { - errorState = QAudio::NoError; - deviceState = QAudio::IdleState; - emit stateChanged(deviceState); - } - } else { - bytesAvailable -= bytesWritten; - totalTimeValue += bytesWritten; - resuming = false; - if (deviceState != QAudio::ActiveState) { - errorState = QAudio::NoError; - deviceState = QAudio::ActiveState; - emit stateChanged(deviceState); - } - } - - return bytesWritten; - } else { - while (ringBuffer.bytesOfDataInBuffer() > 0) { - int size = ringBuffer.availableDataBlockSize(); - memcpy(data, ringBuffer.availableData(), size); - data += size; - ringBuffer.readBytes(size); - } - - bytesAvailable -= bytesRead; - totalTimeValue += bytesRead; - resuming = false; - if (deviceState != QAudio::ActiveState) { - errorState = QAudio::NoError; - deviceState = QAudio::ActiveState; - emit stateChanged(deviceState); - } - - return bytesRead; - } - } - - return 0; -} - -void QAudioInputPrivate::resume() -{ - if(deviceState == QAudio::SuspendedState) { - int err = 0; - - if(handle) { - err = snd_pcm_prepare( handle ); - if(err < 0) - xrun_recovery(err); - - err = snd_pcm_start(handle); - if(err < 0) - xrun_recovery(err); - - bytesAvailable = buffer_size; - } - resuming = true; - deviceState = QAudio::ActiveState; - int chunks = buffer_size/period_size; - timer->start(period_time*chunks/2000); - emit stateChanged(deviceState); - } -} - -void QAudioInputPrivate::setBufferSize(int value) -{ - buffer_size = value; -} - -int QAudioInputPrivate::bufferSize() const -{ - return buffer_size; -} - -int QAudioInputPrivate::periodSize() const -{ - return period_size; -} - -void QAudioInputPrivate::setNotifyInterval(int ms) -{ - intervalTime = qMax(0, ms); -} - -int QAudioInputPrivate::notifyInterval() const -{ - return intervalTime; -} - -qint64 QAudioInputPrivate::processedUSecs() const -{ - qint64 result = qint64(1000000) * totalTimeValue / - (settings.channels()*(settings.sampleSize()/8)) / - settings.frequency(); - - return result; -} - -void QAudioInputPrivate::suspend() -{ - if(deviceState == QAudio::ActiveState||resuming) { - timer->stop(); - deviceState = QAudio::SuspendedState; - emit stateChanged(deviceState); - } -} - -void QAudioInputPrivate::userFeed() -{ - if(deviceState == QAudio::StoppedState || deviceState == QAudio::SuspendedState) - return; -#ifdef DEBUG_AUDIO - QTime now(QTime::currentTime()); - qDebug()<(audioSource); - a->trigger(); - } - bytesAvailable = checkBytesReady(); - - if(deviceState != QAudio::ActiveState) - return true; - - if (bytesAvailable < 0) { - // bytesAvailable as negative is error code, try to recover from it. - xrun_recovery(bytesAvailable); - bytesAvailable = checkBytesReady(); - if (bytesAvailable < 0) { - // recovery failed must stop and set error. - close(); - errorState = QAudio::IOError; - deviceState = QAudio::StoppedState; - emit stateChanged(deviceState); - return 0; - } - } - - if(intervalTime && (timeStamp.elapsed() + elapsedTimeOffset) > intervalTime) { - emit notify(); - elapsedTimeOffset = timeStamp.elapsed() + elapsedTimeOffset - intervalTime; - timeStamp.restart(); - } - return true; -} - -qint64 QAudioInputPrivate::elapsedUSecs() const -{ - if (deviceState == QAudio::StoppedState) - return 0; - - return clockStamp.elapsed()*1000; -} - -void QAudioInputPrivate::reset() -{ - if(handle) - snd_pcm_reset(handle); - stop(); - bytesAvailable = 0; -} - -void QAudioInputPrivate::drain() -{ - if(handle) - snd_pcm_drain(handle); -} - -InputPrivate::InputPrivate(QAudioInputPrivate* audio) -{ - audioDevice = qobject_cast(audio); -} - -InputPrivate::~InputPrivate() -{ -} - -qint64 InputPrivate::readData( char* data, qint64 len) -{ - return audioDevice->read(data,len); -} - -qint64 InputPrivate::writeData(const char* data, qint64 len) -{ - Q_UNUSED(data) - Q_UNUSED(len) - return 0; -} - -void InputPrivate::trigger() -{ - emit readyRead(); -} - -RingBuffer::RingBuffer() : - m_head(0), - m_tail(0) -{ -} - -void RingBuffer::resize(int size) -{ - m_data.resize(size); -} - -int RingBuffer::bytesOfDataInBuffer() const -{ - if (m_head < m_tail) - return m_tail - m_head; - else if (m_tail < m_head) - return m_data.size() + m_tail - m_head; - else - return 0; -} - -int RingBuffer::freeBytes() const -{ - if (m_head > m_tail) - return m_head - m_tail - 1; - else if (m_tail > m_head) - return m_data.size() - m_tail + m_head - 1; - else - return m_data.size() - 1; -} - -const char *RingBuffer::availableData() const -{ - return (m_data.constData() + m_head); -} - -int RingBuffer::availableDataBlockSize() const -{ - if (m_head > m_tail) - return m_data.size() - m_head; - else if (m_tail > m_head) - return m_tail - m_head; - else - return 0; -} - -void RingBuffer::readBytes(int bytes) -{ - m_head = (m_head + bytes) % m_data.size(); -} - -void RingBuffer::write(char *data, int len) -{ - if (m_tail + len < m_data.size()) { - memcpy(m_data.data() + m_tail, data, len); - m_tail += len; - } else { - int bytesUntilEnd = m_data.size() - m_tail; - memcpy(m_data.data() + m_tail, data, bytesUntilEnd); - if (len - bytesUntilEnd > 0) - memcpy(m_data.data(), data + bytesUntilEnd, len - bytesUntilEnd); - m_tail = len - bytesUntilEnd; - } -} - -QT_END_NAMESPACE - -#include "moc_qaudioinput_alsa_p.cpp" diff --git a/src/multimediakit/audio/qaudioinput_alsa_p.h b/src/multimediakit/audio/qaudioinput_alsa_p.h deleted file mode 100644 index a05f6954d..000000000 --- a/src/multimediakit/audio/qaudioinput_alsa_p.h +++ /dev/null @@ -1,191 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -// -// W A R N I N G -// ------------- -// -// This file is not part of the Qt API. It exists for the convenience -// of other Qt classes. This header file may change from version to -// version without notice, or even be removed. -// -// We mean it. -// - - -#ifndef QAUDIOINPUTALSA_H -#define QAUDIOINPUTALSA_H - -#include - -#include -#include -#include -#include -#include -#include - -#include "qaudio.h" -#include "qaudiodeviceinfo.h" -#include "qaudiosystem.h" - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -QT_MODULE(Multimedia) - - -class InputPrivate; - -class RingBuffer -{ -public: - RingBuffer(); - - void resize(int size); - - int bytesOfDataInBuffer() const; - int freeBytes() const; - - const char *availableData() const; - int availableDataBlockSize() const; - void readBytes(int bytes); - - void write(char *data, int len); - -private: - int m_head; - int m_tail; - - QByteArray m_data; -}; - -class QAudioInputPrivate : public QAbstractAudioInput -{ - Q_OBJECT -public: - QAudioInputPrivate(const QByteArray &device); - ~QAudioInputPrivate(); - - qint64 read(char* data, qint64 len); - - void start(QIODevice* device); - QIODevice* start(); - void stop(); - void reset(); - void suspend(); - void resume(); - int bytesReady() const; - int periodSize() const; - void setBufferSize(int value); - int bufferSize() const; - void setNotifyInterval(int milliSeconds); - int notifyInterval() const; - qint64 processedUSecs() const; - qint64 elapsedUSecs() const; - QAudio::Error error() const; - QAudio::State state() const; - void setFormat(const QAudioFormat& fmt); - QAudioFormat format() const; - bool resuming; - snd_pcm_t* handle; - qint64 totalTimeValue; - QIODevice* audioSource; - QAudioFormat settings; - QAudio::Error errorState; - QAudio::State deviceState; - -private slots: - void userFeed(); - bool deviceReady(); - -private: - int checkBytesReady(); - int xrun_recovery(int err); - int setFormat(); - bool open(); - void close(); - void drain(); - - QTimer* timer; - QTime timeStamp; - QTime clockStamp; - qint64 elapsedTimeOffset; - int intervalTime; - RingBuffer ringBuffer; - int bytesAvailable; - QByteArray m_device; - bool pullMode; - int buffer_size; - int period_size; - unsigned int buffer_time; - unsigned int period_time; - snd_pcm_uframes_t buffer_frames; - snd_pcm_uframes_t period_frames; - snd_async_handler_t* ahandler; - snd_pcm_access_t access; - snd_pcm_format_t pcmformat; - snd_timestamp_t* timestamp; - snd_pcm_hw_params_t *hwparams; -}; - -class InputPrivate : public QIODevice -{ - Q_OBJECT -public: - InputPrivate(QAudioInputPrivate* audio); - ~InputPrivate(); - - qint64 readData( char* data, qint64 len); - qint64 writeData(const char* data, qint64 len); - - void trigger(); -private: - QAudioInputPrivate *audioDevice; -}; - -QT_END_NAMESPACE - -QT_END_HEADER - - -#endif diff --git a/src/multimediakit/audio/qaudioinput_mac_p.cpp b/src/multimediakit/audio/qaudioinput_mac_p.cpp deleted file mode 100644 index 5a4053220..000000000 --- a/src/multimediakit/audio/qaudioinput_mac_p.cpp +++ /dev/null @@ -1,989 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -// -// W A R N I N G -// ------------- -// -// This file is not part of the Qt API. It exists for the convenience -// of other Qt classes. This header file may change from version to -// version without notice, or even be removed. -// -// INTERNAL USE ONLY: Do NOT use for any other purpose. -// - -#include -#include -#include - -#include - -#include "qaudio_mac_p.h" -#include "qaudioinput_mac_p.h" -#include "qaudiodeviceinfo_mac_p.h" - -QT_BEGIN_NAMESPACE - - -namespace QtMultimediaKitInternal -{ - -static const int default_buffer_size = 4 * 1024; - -class QAudioBufferList -{ -public: - QAudioBufferList(AudioStreamBasicDescription const& streamFormat): - owner(false), - sf(streamFormat) - { - const bool isInterleaved = (sf.mFormatFlags & kAudioFormatFlagIsNonInterleaved) == 0; - const int numberOfBuffers = isInterleaved ? 1 : sf.mChannelsPerFrame; - - dataSize = 0; - - bfs = reinterpret_cast(qMalloc(sizeof(AudioBufferList) + - (sizeof(AudioBuffer) * numberOfBuffers))); - - bfs->mNumberBuffers = numberOfBuffers; - for (int i = 0; i < numberOfBuffers; ++i) { - bfs->mBuffers[i].mNumberChannels = isInterleaved ? numberOfBuffers : 1; - bfs->mBuffers[i].mDataByteSize = 0; - bfs->mBuffers[i].mData = 0; - } - } - - QAudioBufferList(AudioStreamBasicDescription const& streamFormat, char* buffer, int bufferSize): - owner(false), - sf(streamFormat), - bfs(0) - { - dataSize = bufferSize; - - bfs = reinterpret_cast(qMalloc(sizeof(AudioBufferList) + sizeof(AudioBuffer))); - - bfs->mNumberBuffers = 1; - bfs->mBuffers[0].mNumberChannels = 1; - bfs->mBuffers[0].mDataByteSize = dataSize; - bfs->mBuffers[0].mData = buffer; - } - - QAudioBufferList(AudioStreamBasicDescription const& streamFormat, int framesToBuffer): - owner(true), - sf(streamFormat), - bfs(0) - { - const bool isInterleaved = (sf.mFormatFlags & kAudioFormatFlagIsNonInterleaved) == 0; - const int numberOfBuffers = isInterleaved ? 1 : sf.mChannelsPerFrame; - - dataSize = framesToBuffer * sf.mBytesPerFrame; - - bfs = reinterpret_cast(qMalloc(sizeof(AudioBufferList) + - (sizeof(AudioBuffer) * numberOfBuffers))); - bfs->mNumberBuffers = numberOfBuffers; - for (int i = 0; i < numberOfBuffers; ++i) { - bfs->mBuffers[i].mNumberChannels = isInterleaved ? numberOfBuffers : 1; - bfs->mBuffers[i].mDataByteSize = dataSize; - bfs->mBuffers[i].mData = qMalloc(dataSize); - } - } - - ~QAudioBufferList() - { - if (owner) { - for (UInt32 i = 0; i < bfs->mNumberBuffers; ++i) - qFree(bfs->mBuffers[i].mData); - } - - qFree(bfs); - } - - AudioBufferList* audioBufferList() const - { - return bfs; - } - - char* data(int buffer = 0) const - { - return static_cast(bfs->mBuffers[buffer].mData); - } - - qint64 bufferSize(int buffer = 0) const - { - return bfs->mBuffers[buffer].mDataByteSize; - } - - int frameCount(int buffer = 0) const - { - return bfs->mBuffers[buffer].mDataByteSize / sf.mBytesPerFrame; - } - - int packetCount(int buffer = 0) const - { - return bfs->mBuffers[buffer].mDataByteSize / sf.mBytesPerPacket; - } - - int packetSize() const - { - return sf.mBytesPerPacket; - } - - void reset() - { - for (UInt32 i = 0; i < bfs->mNumberBuffers; ++i) { - bfs->mBuffers[i].mDataByteSize = dataSize; - bfs->mBuffers[i].mData = 0; - } - } - -private: - bool owner; - int dataSize; - AudioStreamBasicDescription sf; - AudioBufferList* bfs; -}; - -class QAudioPacketFeeder -{ -public: - QAudioPacketFeeder(QAudioBufferList* abl): - audioBufferList(abl) - { - totalPackets = audioBufferList->packetCount(); - position = 0; - } - - bool feed(AudioBufferList& dst, UInt32& packetCount) - { - if (position == totalPackets) { - dst.mBuffers[0].mDataByteSize = 0; - packetCount = 0; - return false; - } - - if (totalPackets - position < packetCount) - packetCount = totalPackets - position; - - dst.mBuffers[0].mDataByteSize = packetCount * audioBufferList->packetSize(); - dst.mBuffers[0].mData = audioBufferList->data() + (position * audioBufferList->packetSize()); - - position += packetCount; - - return true; - } - - bool empty() const - { - return position == totalPackets; - } - -private: - UInt32 totalPackets; - UInt32 position; - QAudioBufferList* audioBufferList; -}; - -class QAudioInputBuffer : public QObject -{ - Q_OBJECT - -public: - QAudioInputBuffer(int bufferSize, - int maxPeriodSize, - AudioStreamBasicDescription const& inputFormat, - AudioStreamBasicDescription const& outputFormat, - QObject* parent): - QObject(parent), - m_deviceError(false), - m_audioConverter(0), - m_inputFormat(inputFormat), - m_outputFormat(outputFormat) - { - m_maxPeriodSize = maxPeriodSize; - m_periodTime = m_maxPeriodSize / m_outputFormat.mBytesPerFrame * 1000 / m_outputFormat.mSampleRate; - m_buffer = new QAudioRingBuffer(bufferSize + (bufferSize % maxPeriodSize == 0 ? 0 : maxPeriodSize - (bufferSize % maxPeriodSize))); - m_inputBufferList = new QAudioBufferList(m_inputFormat); - - m_flushTimer = new QTimer(this); - connect(m_flushTimer, SIGNAL(timeout()), SLOT(flushBuffer())); - - if (toQAudioFormat(inputFormat) != toQAudioFormat(outputFormat)) { - if (AudioConverterNew(&m_inputFormat, &m_outputFormat, &m_audioConverter) != noErr) { - qWarning() << "QAudioInput: Unable to create an Audio Converter"; - m_audioConverter = 0; - } - } - } - - ~QAudioInputBuffer() - { - delete m_buffer; - } - - qint64 renderFromDevice(AudioUnit audioUnit, - AudioUnitRenderActionFlags* ioActionFlags, - const AudioTimeStamp* inTimeStamp, - UInt32 inBusNumber, - UInt32 inNumberFrames) - { - const bool pullMode = m_device == 0; - - OSStatus err; - qint64 framesRendered = 0; - - m_inputBufferList->reset(); - err = AudioUnitRender(audioUnit, - ioActionFlags, - inTimeStamp, - inBusNumber, - inNumberFrames, - m_inputBufferList->audioBufferList()); - - if (m_audioConverter != 0) { - QAudioPacketFeeder feeder(m_inputBufferList); - - int copied = 0; - const int available = m_buffer->free(); - - while (err == noErr && !feeder.empty()) { - QAudioRingBuffer::Region region = m_buffer->acquireWriteRegion(available); - - if (region.second == 0) - break; - - AudioBufferList output; - output.mNumberBuffers = 1; - output.mBuffers[0].mNumberChannels = 1; - output.mBuffers[0].mDataByteSize = region.second; - output.mBuffers[0].mData = region.first; - - UInt32 packetSize = region.second / m_outputFormat.mBytesPerPacket; - err = AudioConverterFillComplexBuffer(m_audioConverter, - converterCallback, - &feeder, - &packetSize, - &output, - 0); - region.second = output.mBuffers[0].mDataByteSize; - copied += region.second; - - m_buffer->releaseWriteRegion(region); - } - - framesRendered += copied / m_outputFormat.mBytesPerFrame; - } - else { - const int available = m_inputBufferList->bufferSize(); - bool wecan = true; - int copied = 0; - - while (wecan && copied < available) { - QAudioRingBuffer::Region region = m_buffer->acquireWriteRegion(available - copied); - - if (region.second > 0) { - memcpy(region.first, m_inputBufferList->data() + copied, region.second); - copied += region.second; - } - else - wecan = false; - - m_buffer->releaseWriteRegion(region); - } - - framesRendered = copied / m_outputFormat.mBytesPerFrame; - } - - if (pullMode && framesRendered > 0) - emit readyRead(); - - return framesRendered; - } - - qint64 readBytes(char* data, qint64 len) - { - bool wecan = true; - qint64 bytesCopied = 0; - - len -= len % m_maxPeriodSize; - while (wecan && bytesCopied < len) { - QAudioRingBuffer::Region region = m_buffer->acquireReadRegion(len - bytesCopied); - - if (region.second > 0) { - memcpy(data + bytesCopied, region.first, region.second); - bytesCopied += region.second; - } - else - wecan = false; - - m_buffer->releaseReadRegion(region); - } - - return bytesCopied; - } - - void setFlushDevice(QIODevice* device) - { - if (m_device != device) - m_device = device; - } - - void startFlushTimer() - { - if (m_device != 0) { - m_flushTimer->start((m_buffer->size() - (m_maxPeriodSize * 2)) / m_maxPeriodSize * m_periodTime); - } - } - - void stopFlushTimer() - { - m_flushTimer->stop(); - } - - void flush(bool all = false) - { - if (m_device == 0) - return; - - const int used = m_buffer->used(); - const int readSize = all ? used : used - (used % m_maxPeriodSize); - - if (readSize > 0) { - bool wecan = true; - int flushed = 0; - - while (!m_deviceError && wecan && flushed < readSize) { - QAudioRingBuffer::Region region = m_buffer->acquireReadRegion(readSize - flushed); - - if (region.second > 0) { - int bytesWritten = m_device->write(region.first, region.second); - if (bytesWritten < 0) { - stopFlushTimer(); - m_deviceError = true; - } - else { - region.second = bytesWritten; - flushed += bytesWritten; - wecan = bytesWritten != 0; - } - } - else - wecan = false; - - m_buffer->releaseReadRegion(region); - } - } - } - - void reset() - { - m_buffer->reset(); - m_deviceError = false; - } - - int available() const - { - return m_buffer->free(); - } - - int used() const - { - return m_buffer->used(); - } - -signals: - void readyRead(); - -private slots: - void flushBuffer() - { - flush(); - } - -private: - bool m_deviceError; - int m_maxPeriodSize; - int m_periodTime; - QIODevice* m_device; - QTimer* m_flushTimer; - QAudioRingBuffer* m_buffer; - QAudioBufferList* m_inputBufferList; - AudioConverterRef m_audioConverter; - AudioStreamBasicDescription m_inputFormat; - AudioStreamBasicDescription m_outputFormat; - - const static OSStatus as_empty = 'qtem'; - - // Converter callback - static OSStatus converterCallback(AudioConverterRef inAudioConverter, - UInt32* ioNumberDataPackets, - AudioBufferList* ioData, - AudioStreamPacketDescription** outDataPacketDescription, - void* inUserData) - { - Q_UNUSED(inAudioConverter); - Q_UNUSED(outDataPacketDescription); - - QAudioPacketFeeder* feeder = static_cast(inUserData); - - if (!feeder->feed(*ioData, *ioNumberDataPackets)) - return as_empty; - - return noErr; - } -}; - - -class MacInputDevice : public QIODevice -{ - Q_OBJECT - -public: - MacInputDevice(QAudioInputBuffer* audioBuffer, QObject* parent): - QIODevice(parent), - m_audioBuffer(audioBuffer) - { - open(QIODevice::ReadOnly | QIODevice::Unbuffered); - connect(m_audioBuffer, SIGNAL(readyRead()), SIGNAL(readyRead())); - } - - qint64 readData(char* data, qint64 len) - { - return m_audioBuffer->readBytes(data, len); - } - - qint64 writeData(const char* data, qint64 len) - { - Q_UNUSED(data); - Q_UNUSED(len); - - return 0; - } - - bool isSequential() const - { - return true; - } - -private: - QAudioInputBuffer* m_audioBuffer; -}; - -} - - -QAudioInputPrivate::QAudioInputPrivate(const QByteArray& device) -{ - QDataStream ds(device); - quint32 did, mode; - - ds >> did >> mode; - - if (QAudio::Mode(mode) == QAudio::AudioOutput) - errorCode = QAudio::OpenError; - else { - audioDeviceInfo = new QAudioDeviceInfoInternal(device, QAudio::AudioInput); - isOpen = false; - audioDeviceId = AudioDeviceID(did); - audioUnit = 0; - startTime = 0; - totalFrames = 0; - audioBuffer = 0; - internalBufferSize = QtMultimediaKitInternal::default_buffer_size; - clockFrequency = AudioGetHostClockFrequency() / 1000; - errorCode = QAudio::NoError; - stateCode = QAudio::StoppedState; - - intervalTimer = new QTimer(this); - intervalTimer->setInterval(1000); - connect(intervalTimer, SIGNAL(timeout()), SIGNAL(notify())); - } -} - -QAudioInputPrivate::~QAudioInputPrivate() -{ - close(); - delete audioDeviceInfo; -} - -bool QAudioInputPrivate::open() -{ - UInt32 size = 0; - - if (isOpen) - return true; - - ComponentDescription cd; - cd.componentType = kAudioUnitType_Output; - cd.componentSubType = kAudioUnitSubType_HALOutput; - cd.componentManufacturer = kAudioUnitManufacturer_Apple; - cd.componentFlags = 0; - cd.componentFlagsMask = 0; - - // Open - Component cp = FindNextComponent(NULL, &cd); - if (cp == 0) { - qWarning() << "QAudioInput: Failed to find HAL Output component"; - return false; - } - - if (OpenAComponent(cp, &audioUnit) != noErr) { - qWarning() << "QAudioInput: Unable to Open Output Component"; - return false; - } - - // Set mode - // switch to input mode - UInt32 enable = 1; - if (AudioUnitSetProperty(audioUnit, - kAudioOutputUnitProperty_EnableIO, - kAudioUnitScope_Input, - 1, - &enable, - sizeof(enable)) != noErr) { - qWarning() << "QAudioInput: Unable to switch to input mode (Enable Input)"; - return false; - } - - enable = 0; - if (AudioUnitSetProperty(audioUnit, - kAudioOutputUnitProperty_EnableIO, - kAudioUnitScope_Output, - 0, - &enable, - sizeof(enable)) != noErr) { - qWarning() << "QAudioInput: Unable to switch to input mode (Disable output)"; - return false; - } - - // register callback - AURenderCallbackStruct cb; - cb.inputProc = inputCallback; - cb.inputProcRefCon = this; - - if (AudioUnitSetProperty(audioUnit, - kAudioOutputUnitProperty_SetInputCallback, - kAudioUnitScope_Global, - 0, - &cb, - sizeof(cb)) != noErr) { - qWarning() << "QAudioInput: Failed to set AudioUnit callback"; - return false; - } - - // Set Audio Device - if (AudioUnitSetProperty(audioUnit, - kAudioOutputUnitProperty_CurrentDevice, - kAudioUnitScope_Global, - 0, - &audioDeviceId, - sizeof(audioDeviceId)) != noErr) { - qWarning() << "QAudioInput: Unable to use configured device"; - return false; - } - - // Set format - // Wanted - streamFormat = toAudioStreamBasicDescription(audioFormat); - - // Required on unit - if (audioFormat == audioDeviceInfo->preferredFormat()) { - deviceFormat = streamFormat; - AudioUnitSetProperty(audioUnit, - kAudioUnitProperty_StreamFormat, - kAudioUnitScope_Output, - 1, - &deviceFormat, - sizeof(deviceFormat)); - } - else { - size = sizeof(deviceFormat); - if (AudioUnitGetProperty(audioUnit, - kAudioUnitProperty_StreamFormat, - kAudioUnitScope_Input, - 1, - &deviceFormat, - &size) != noErr) { - qWarning() << "QAudioInput: Unable to retrieve device format"; - return false; - } - - if (AudioUnitSetProperty(audioUnit, - kAudioUnitProperty_StreamFormat, - kAudioUnitScope_Output, - 1, - &deviceFormat, - sizeof(deviceFormat)) != noErr) { - qWarning() << "QAudioInput: Unable to set device format"; - return false; - } - } - - // Setup buffers - UInt32 numberOfFrames; - size = sizeof(UInt32); - if (AudioUnitGetProperty(audioUnit, - kAudioDevicePropertyBufferFrameSize, - kAudioUnitScope_Global, - 0, - &numberOfFrames, - &size) != noErr) { - qWarning() << "QAudioInput: Failed to get audio period size"; - return false; - } - - // Allocate buffer - periodSizeBytes = numberOfFrames * streamFormat.mBytesPerFrame; - - if (internalBufferSize < periodSizeBytes * 2) - internalBufferSize = periodSizeBytes * 2; - else - internalBufferSize -= internalBufferSize % streamFormat.mBytesPerFrame; - - audioBuffer = new QtMultimediaKitInternal::QAudioInputBuffer(internalBufferSize, - periodSizeBytes, - deviceFormat, - streamFormat, - this); - - audioIO = new QtMultimediaKitInternal::MacInputDevice(audioBuffer, this); - - // Init - if (AudioUnitInitialize(audioUnit) != noErr) { - qWarning() << "QAudioInput: Failed to initialize AudioUnit"; - return false; - } - - isOpen = true; - - return isOpen; -} - -void QAudioInputPrivate::close() -{ - if (audioUnit != 0) { - AudioOutputUnitStop(audioUnit); - AudioUnitUninitialize(audioUnit); - CloseComponent(audioUnit); - } - - delete audioBuffer; -} - -QAudioFormat QAudioInputPrivate::format() const -{ - return audioFormat; -} - -void QAudioInputPrivate::setFormat(const QAudioFormat& fmt) -{ - if (stateCode == QAudio::StoppedState) - audioFormat = fmt; -} - -void QAudioInputPrivate::start(QIODevice* device) -{ - QIODevice* op = device; - - if (!audioDeviceInfo->isFormatSupported(audioFormat) || !open()) { - stateCode = QAudio::StoppedState; - errorCode = QAudio::OpenError; - return; - } - - reset(); - audioBuffer->reset(); - audioBuffer->setFlushDevice(op); - - if (op == 0) - op = audioIO; - - // Start - startTime = AudioGetCurrentHostTime(); - totalFrames = 0; - - audioThreadStart(); - - stateCode = QAudio::ActiveState; - errorCode = QAudio::NoError; - emit stateChanged(stateCode); -} - -QIODevice* QAudioInputPrivate::start() -{ - QIODevice* op = 0; - - if (!audioDeviceInfo->isFormatSupported(audioFormat) || !open()) { - stateCode = QAudio::StoppedState; - errorCode = QAudio::OpenError; - return audioIO; - } - - reset(); - audioBuffer->reset(); - audioBuffer->setFlushDevice(op); - - if (op == 0) - op = audioIO; - - // Start - startTime = AudioGetCurrentHostTime(); - totalFrames = 0; - - audioThreadStart(); - - stateCode = QAudio::ActiveState; - errorCode = QAudio::NoError; - emit stateChanged(stateCode); - - return op; -} - -void QAudioInputPrivate::stop() -{ - QMutexLocker lock(&mutex); - if (stateCode != QAudio::StoppedState) { - audioThreadStop(); - audioBuffer->flush(true); - - errorCode = QAudio::NoError; - stateCode = QAudio::StoppedState; - QMetaObject::invokeMethod(this, "stateChanged", Qt::QueuedConnection, Q_ARG(QAudio::State, stateCode)); - } -} - -void QAudioInputPrivate::reset() -{ - QMutexLocker lock(&mutex); - if (stateCode != QAudio::StoppedState) { - audioThreadStop(); - - errorCode = QAudio::NoError; - stateCode = QAudio::StoppedState; - QMetaObject::invokeMethod(this, "stateChanged", Qt::QueuedConnection, Q_ARG(QAudio::State, stateCode)); - } -} - -void QAudioInputPrivate::suspend() -{ - QMutexLocker lock(&mutex); - if (stateCode == QAudio::ActiveState || stateCode == QAudio::IdleState) { - audioThreadStop(); - - errorCode = QAudio::NoError; - stateCode = QAudio::SuspendedState; - QMetaObject::invokeMethod(this, "stateChanged", Qt::QueuedConnection, Q_ARG(QAudio::State, stateCode)); - } -} - -void QAudioInputPrivate::resume() -{ - QMutexLocker lock(&mutex); - if (stateCode == QAudio::SuspendedState) { - audioThreadStart(); - - errorCode = QAudio::NoError; - stateCode = QAudio::ActiveState; - QMetaObject::invokeMethod(this, "stateChanged", Qt::QueuedConnection, Q_ARG(QAudio::State, stateCode)); - } -} - -int QAudioInputPrivate::bytesReady() const -{ - return audioBuffer->used(); -} - -int QAudioInputPrivate::periodSize() const -{ - return periodSizeBytes; -} - -void QAudioInputPrivate::setBufferSize(int bs) -{ - internalBufferSize = bs; -} - -int QAudioInputPrivate::bufferSize() const -{ - return internalBufferSize; -} - -void QAudioInputPrivate::setNotifyInterval(int milliSeconds) -{ - if (intervalTimer->interval() == milliSeconds) - return; - - if (milliSeconds <= 0) - milliSeconds = 0; - - intervalTimer->setInterval(milliSeconds); -} - -int QAudioInputPrivate::notifyInterval() const -{ - return intervalTimer->interval(); -} - -qint64 QAudioInputPrivate::processedUSecs() const -{ - return totalFrames * 1000000 / audioFormat.frequency(); -} - -qint64 QAudioInputPrivate::elapsedUSecs() const -{ - if (stateCode == QAudio::StoppedState) - return 0; - - return (AudioGetCurrentHostTime() - startTime) / (clockFrequency / 1000); -} - -QAudio::Error QAudioInputPrivate::error() const -{ - return errorCode; -} - -QAudio::State QAudioInputPrivate::state() const -{ - return stateCode; -} - -void QAudioInputPrivate::audioThreadStop() -{ - stopTimers(); - if (audioThreadState.testAndSetAcquire(Running, Stopped)) - threadFinished.wait(&mutex); -} - -void QAudioInputPrivate::audioThreadStart() -{ - startTimers(); - audioThreadState = Running; - AudioOutputUnitStart(audioUnit); -} - -void QAudioInputPrivate::audioDeviceStop() -{ - AudioOutputUnitStop(audioUnit); - audioThreadState = Stopped; - threadFinished.wakeOne(); -} - -void QAudioInputPrivate::audioDeviceFull() -{ - QMutexLocker lock(&mutex); - if (stateCode == QAudio::ActiveState) { - audioDeviceStop(); - - errorCode = QAudio::UnderrunError; - stateCode = QAudio::IdleState; - QMetaObject::invokeMethod(this, "deviceStopped", Qt::QueuedConnection); - } -} - -void QAudioInputPrivate::audioDeviceError() -{ - QMutexLocker lock(&mutex); - if (stateCode == QAudio::ActiveState) { - audioDeviceStop(); - - errorCode = QAudio::IOError; - stateCode = QAudio::StoppedState; - QMetaObject::invokeMethod(this, "deviceStopped", Qt::QueuedConnection); - } -} - -void QAudioInputPrivate::startTimers() -{ - audioBuffer->startFlushTimer(); - if (intervalTimer->interval() > 0) - intervalTimer->start(); -} - -void QAudioInputPrivate::stopTimers() -{ - audioBuffer->stopFlushTimer(); - intervalTimer->stop(); -} - -void QAudioInputPrivate::deviceStopped() -{ - stopTimers(); - emit stateChanged(stateCode); -} - -// Input callback -OSStatus QAudioInputPrivate::inputCallback(void* inRefCon, - AudioUnitRenderActionFlags* ioActionFlags, - const AudioTimeStamp* inTimeStamp, - UInt32 inBusNumber, - UInt32 inNumberFrames, - AudioBufferList* ioData) -{ - Q_UNUSED(ioData); - - QAudioInputPrivate* d = static_cast(inRefCon); - - const int threadState = d->audioThreadState.fetchAndAddAcquire(0); - if (threadState == Stopped) - d->audioDeviceStop(); - else { - qint64 framesWritten; - - framesWritten = d->audioBuffer->renderFromDevice(d->audioUnit, - ioActionFlags, - inTimeStamp, - inBusNumber, - inNumberFrames); - - if (framesWritten > 0) - d->totalFrames += framesWritten; - else if (framesWritten == 0) - d->audioDeviceFull(); - else if (framesWritten < 0) - d->audioDeviceError(); - } - - return noErr; -} - - -QT_END_NAMESPACE - -#include "qaudioinput_mac_p.moc" diff --git a/src/multimediakit/audio/qaudioinput_mac_p.h b/src/multimediakit/audio/qaudioinput_mac_p.h deleted file mode 100644 index 99e8ad061..000000000 --- a/src/multimediakit/audio/qaudioinput_mac_p.h +++ /dev/null @@ -1,174 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -// -// W A R N I N G -// ------------- -// -// This file is not part of the Qt API. It exists for the convenience -// of other Qt classes. This header file may change from version to -// version without notice, or even be removed. -// -// We mean it. -// - - -#ifndef QAUDIOINPUT_MAC_P_H -#define QAUDIOINPUT_MAC_P_H - -#include -#include -#include -#include - -#include -#include -#include -#include - -#include -#include -#include - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -QT_MODULE(Multimedia) - - -class QTimer; -class QIODevice; -class QAbstractAudioDeviceInfo; - -namespace QtMultimediaKitInternal -{ -class QAudioInputBuffer; -} - -class QAudioInputPrivate : public QAbstractAudioInput -{ - Q_OBJECT - -public: - bool isOpen; - int periodSizeBytes; - int internalBufferSize; - qint64 totalFrames; - QAudioFormat audioFormat; - QIODevice* audioIO; - AudioUnit audioUnit; - AudioDeviceID audioDeviceId; - Float64 clockFrequency; - UInt64 startTime; - QAudio::Error errorCode; - QAudio::State stateCode; - QtMultimediaKitInternal::QAudioInputBuffer* audioBuffer; - QMutex mutex; - QWaitCondition threadFinished; - QAtomicInt audioThreadState; - QTimer* intervalTimer; - AudioStreamBasicDescription streamFormat; - AudioStreamBasicDescription deviceFormat; - QAbstractAudioDeviceInfo *audioDeviceInfo; - - QAudioInputPrivate(const QByteArray& device); - ~QAudioInputPrivate(); - - bool open(); - void close(); - - QAudioFormat format() const; - void setFormat(const QAudioFormat& fmt); - - QIODevice* start(); - void start(QIODevice* device); - void stop(); - void reset(); - void suspend(); - void resume(); - void idle(); - - int bytesReady() const; - int periodSize() const; - - void setBufferSize(int value); - int bufferSize() const; - - void setNotifyInterval(int milliSeconds); - int notifyInterval() const; - - qint64 processedUSecs() const; - qint64 elapsedUSecs() const; - - QAudio::Error error() const; - QAudio::State state() const; - - void audioThreadStart(); - void audioThreadStop(); - - void audioDeviceStop(); - void audioDeviceFull(); - void audioDeviceError(); - - void startTimers(); - void stopTimers(); - -private slots: - void deviceStopped(); - -private: - enum { Running, Stopped }; - - // Input callback - static OSStatus inputCallback(void* inRefCon, - AudioUnitRenderActionFlags* ioActionFlags, - const AudioTimeStamp* inTimeStamp, - UInt32 inBusNumber, - UInt32 inNumberFrames, - AudioBufferList* ioData); -}; - -QT_END_NAMESPACE - -QT_END_HEADER - -#endif // QAUDIOINPUT_MAC_P_H diff --git a/src/multimediakit/audio/qaudioinput_win32_p.cpp b/src/multimediakit/audio/qaudioinput_win32_p.cpp deleted file mode 100644 index 718656ba3..000000000 --- a/src/multimediakit/audio/qaudioinput_win32_p.cpp +++ /dev/null @@ -1,642 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -// -// W A R N I N G -// ------------- -// -// This file is not part of the Qt API. It exists for the convenience -// of other Qt classes. This header file may change from version to -// version without notice, or even be removed. -// -// INTERNAL USE ONLY: Do NOT use for any other purpose. -// - - -#include "qaudioinput_win32_p.h" - -QT_BEGIN_NAMESPACE - -//#define DEBUG_AUDIO 1 - -QAudioInputPrivate::QAudioInputPrivate(const QByteArray &device) -{ - bytesAvailable = 0; - buffer_size = 0; - period_size = 0; - m_device = device; - totalTimeValue = 0; - intervalTime = 1000; - errorState = QAudio::NoError; - deviceState = QAudio::StoppedState; - audioSource = 0; - pullMode = true; - resuming = false; - finished = false; - waveBlockOffset = 0; -} - -QAudioInputPrivate::~QAudioInputPrivate() -{ - stop(); -} - -void QT_WIN_CALLBACK QAudioInputPrivate::waveInProc( HWAVEIN hWaveIn, UINT uMsg, - DWORD dwInstance, DWORD dwParam1, DWORD dwParam2 ) -{ - Q_UNUSED(dwParam1) - Q_UNUSED(dwParam2) - Q_UNUSED(hWaveIn) - - QAudioInputPrivate* qAudio; - qAudio = (QAudioInputPrivate*)(dwInstance); - if(!qAudio) - return; - - QMutexLocker(&qAudio->mutex); - - switch(uMsg) { - case WIM_OPEN: - break; - case WIM_DATA: - if(qAudio->waveFreeBlockCount > 0) - qAudio->waveFreeBlockCount--; - qAudio->feedback(); - break; - case WIM_CLOSE: - qAudio->finished = true; - break; - default: - return; - } -} - -WAVEHDR* QAudioInputPrivate::allocateBlocks(int size, int count) -{ - int i; - unsigned char* buffer; - WAVEHDR* blocks; - DWORD totalBufferSize = (size + sizeof(WAVEHDR))*count; - - if((buffer=(unsigned char*)HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY, - totalBufferSize)) == 0) { - qWarning("QAudioInput: Memory allocation error"); - return 0; - } - blocks = (WAVEHDR*)buffer; - buffer += sizeof(WAVEHDR)*count; - for(i = 0; i < count; i++) { - blocks[i].dwBufferLength = size; - blocks[i].lpData = (LPSTR)buffer; - blocks[i].dwBytesRecorded=0; - blocks[i].dwUser = 0L; - blocks[i].dwFlags = 0L; - blocks[i].dwLoops = 0L; - result = waveInPrepareHeader(hWaveIn,&blocks[i], sizeof(WAVEHDR)); - if(result != MMSYSERR_NOERROR) { - qWarning("QAudioInput: Can't prepare block %d",i); - return 0; - } - buffer += size; - } - return blocks; -} - -void QAudioInputPrivate::freeBlocks(WAVEHDR* blockArray) -{ - WAVEHDR* blocks = blockArray; - - int count = buffer_size/period_size; - - for(int i = 0; i < count; i++) { - waveInUnprepareHeader(hWaveIn,blocks, sizeof(WAVEHDR)); - blocks++; - } - HeapFree(GetProcessHeap(), 0, blockArray); -} - -QAudio::Error QAudioInputPrivate::error() const -{ - return errorState; -} - -QAudio::State QAudioInputPrivate::state() const -{ - return deviceState; -} - -void QAudioInputPrivate::setFormat(const QAudioFormat& fmt) -{ - if (deviceState == QAudio::StoppedState) - settings = fmt; -} - -QAudioFormat QAudioInputPrivate::format() const -{ - return settings; -} - -void QAudioInputPrivate::start(QIODevice* device) -{ - if(deviceState != QAudio::StoppedState) - close(); - - if(!pullMode && audioSource) - delete audioSource; - - pullMode = true; - audioSource = device; - - deviceState = QAudio::ActiveState; - - if(!open()) - return; - - emit stateChanged(deviceState); -} - -QIODevice* QAudioInputPrivate::start() -{ - if(deviceState != QAudio::StoppedState) - close(); - - if(!pullMode && audioSource) - delete audioSource; - - pullMode = false; - audioSource = new InputPrivate(this); - audioSource->open(QIODevice::ReadOnly | QIODevice::Unbuffered); - - deviceState = QAudio::IdleState; - - if(!open()) - return 0; - - emit stateChanged(deviceState); - - return audioSource; -} - -void QAudioInputPrivate::stop() -{ - if(deviceState == QAudio::StoppedState) - return; - - close(); - emit stateChanged(deviceState); -} - -bool QAudioInputPrivate::open() -{ -#ifdef DEBUG_AUDIO - QTime now(QTime::currentTime()); - qDebug()< 48000) { - qWarning("QAudioInput: open error, frequency out of range (%d).", settings.frequency()); - } else if (buffer_size == 0) { - - buffer_size - = (settings.frequency() - * settings.channelCount() - * settings.sampleSize() - + 39) / 40; - period_size = buffer_size / 5; - } else { - period_size = buffer_size / 5; - } - - if (period_size == 0) { - errorState = QAudio::OpenError; - deviceState = QAudio::StoppedState; - emit stateChanged(deviceState); - return false; - } - - timeStamp.restart(); - elapsedTimeOffset = 0; - wfx.nSamplesPerSec = settings.frequency(); - wfx.wBitsPerSample = settings.sampleSize(); - wfx.nChannels = settings.channels(); - wfx.cbSize = 0; - - wfx.wFormatTag = WAVE_FORMAT_PCM; - wfx.nBlockAlign = (wfx.wBitsPerSample >> 3) * wfx.nChannels; - wfx.nAvgBytesPerSec = wfx.nBlockAlign * wfx.nSamplesPerSec; - - QDataStream ds(&m_device, QIODevice::ReadOnly); - quint32 deviceId; - ds >> deviceId; - - if (waveInOpen(&hWaveIn, UINT_PTR(deviceId), &wfx, - (DWORD_PTR)&waveInProc, - (DWORD_PTR) this, - CALLBACK_FUNCTION) != MMSYSERR_NOERROR) { - errorState = QAudio::OpenError; - deviceState = QAudio::StoppedState; - emit stateChanged(deviceState); - qWarning("QAudioInput: failed to open audio device"); - return false; - } - waveBlocks = allocateBlocks(period_size, buffer_size/period_size); - waveBlockOffset = 0; - - if(waveBlocks == 0) { - errorState = QAudio::OpenError; - deviceState = QAudio::StoppedState; - emit stateChanged(deviceState); - qWarning("QAudioInput: failed to allocate blocks. open failed"); - return false; - } - - mutex.lock(); - waveFreeBlockCount = buffer_size/period_size; - mutex.unlock(); - - for(int i=0; i 0 && waveBlocks[header].dwFlags & WHDR_DONE) { - if(pullMode) { - l = audioSource->write(waveBlocks[header].lpData + waveBlockOffset, - waveBlocks[header].dwBytesRecorded - waveBlockOffset); -#ifdef DEBUG_AUDIO - qDebug()<<"IN: "<(len, waveBlocks[header].dwBytesRecorded - waveBlockOffset); - // push mode - memcpy(p, waveBlocks[header].lpData + waveBlockOffset, l); - - len -= l; - -#ifdef DEBUG_AUDIO - qDebug()<<"IN: "<= buffer_size/period_size) - header = 0; - p+=l; - - mutex.lock(); - if(!pullMode) { - if(len < period_size || waveFreeBlockCount == buffer_size/period_size) - done = true; - } else { - if(waveFreeBlockCount == buffer_size/period_size) - done = true; - } - mutex.unlock(); - } - - written+=l; - } -#ifdef DEBUG_AUDIO - qDebug()<<"read in len="<(audioSource); - a->trigger(); - } - - if(intervalTime && (timeStamp.elapsed() + elapsedTimeOffset) > intervalTime) { - emit notify(); - elapsedTimeOffset = timeStamp.elapsed() + elapsedTimeOffset - intervalTime; - timeStamp.restart(); - } - return true; -} - -qint64 QAudioInputPrivate::elapsedUSecs() const -{ - if (deviceState == QAudio::StoppedState) - return 0; - - return timeStampOpened.elapsed()*1000; -} - -void QAudioInputPrivate::reset() -{ - stop(); - if (period_size > 0) - waveFreeBlockCount = buffer_size / period_size; -} - -InputPrivate::InputPrivate(QAudioInputPrivate* audio) -{ - audioDevice = qobject_cast(audio); -} - -InputPrivate::~InputPrivate() {} - -qint64 InputPrivate::readData( char* data, qint64 len) -{ - // push mode, user read() called - if(audioDevice->deviceState != QAudio::ActiveState && - audioDevice->deviceState != QAudio::IdleState) - return 0; - // Read in some audio data - return audioDevice->read(data,len); -} - -qint64 InputPrivate::writeData(const char* data, qint64 len) -{ - Q_UNUSED(data) - Q_UNUSED(len) - - emit readyRead(); - return 0; -} - -void InputPrivate::trigger() -{ - emit readyRead(); -} - -QT_END_NAMESPACE - -#include "moc_qaudioinput_win32_p.cpp" - diff --git a/src/multimediakit/audio/qaudioinput_win32_p.h b/src/multimediakit/audio/qaudioinput_win32_p.h deleted file mode 100644 index 10d41a552..000000000 --- a/src/multimediakit/audio/qaudioinput_win32_p.h +++ /dev/null @@ -1,179 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -// -// W A R N I N G -// ------------- -// -// This file is not part of the Qt API. It exists for the convenience -// of other Qt classes. This header file may change from version to -// version without notice, or even be removed. -// -// We mean it. -// - -#ifndef QAUDIOINPUTWIN_H -#define QAUDIOINPUTWIN_H - -#include -#include - -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include - - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -QT_MODULE(Multimedia) - - -// For compat with 4.6 -#if !defined(QT_WIN_CALLBACK) -# if defined(Q_CC_MINGW) -# define QT_WIN_CALLBACK CALLBACK __attribute__ ((force_align_arg_pointer)) -# else -# define QT_WIN_CALLBACK CALLBACK -# endif -#endif - -class QAudioInputPrivate : public QAbstractAudioInput -{ - Q_OBJECT -public: - QAudioInputPrivate(const QByteArray &device); - ~QAudioInputPrivate(); - - qint64 read(char* data, qint64 len); - - void setFormat(const QAudioFormat& fmt); - QAudioFormat format() const; - QIODevice* start(); - void start(QIODevice* device); - void stop(); - void reset(); - void suspend(); - void resume(); - int bytesReady() const; - int periodSize() const; - void setBufferSize(int value); - int bufferSize() const; - void setNotifyInterval(int milliSeconds); - int notifyInterval() const; - qint64 processedUSecs() const; - qint64 elapsedUSecs() const; - QAudio::Error error() const; - QAudio::State state() const; - - QIODevice* audioSource; - QAudioFormat settings; - QAudio::Error errorState; - QAudio::State deviceState; - -private: - qint32 buffer_size; - qint32 period_size; - qint32 header; - QByteArray m_device; - int bytesAvailable; - int intervalTime; - QTime timeStamp; - qint64 elapsedTimeOffset; - QTime timeStampOpened; - qint64 totalTimeValue; - bool pullMode; - bool resuming; - WAVEFORMATEX wfx; - HWAVEIN hWaveIn; - MMRESULT result; - WAVEHDR* waveBlocks; - volatile bool finished; - volatile int waveFreeBlockCount; - int waveBlockOffset; - - QMutex mutex; - static void QT_WIN_CALLBACK waveInProc( HWAVEIN hWaveIn, UINT uMsg, - DWORD dwInstance, DWORD dwParam1, DWORD dwParam2 ); - - WAVEHDR* allocateBlocks(int size, int count); - void freeBlocks(WAVEHDR* blockArray); - bool open(); - void close(); - -private slots: - void feedback(); - bool deviceReady(); - -signals: - void processMore(); -}; - -class InputPrivate : public QIODevice -{ - Q_OBJECT -public: - InputPrivate(QAudioInputPrivate* audio); - ~InputPrivate(); - - qint64 readData( char* data, qint64 len); - qint64 writeData(const char* data, qint64 len); - - void trigger(); -private: - QAudioInputPrivate *audioDevice; -}; - -QT_END_NAMESPACE - -QT_END_HEADER - - -#endif diff --git a/src/multimediakit/audio/qaudiooutput.cpp b/src/multimediakit/audio/qaudiooutput.cpp deleted file mode 100644 index d4a2d7fed..000000000 --- a/src/multimediakit/audio/qaudiooutput.cpp +++ /dev/null @@ -1,404 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - - -#include "qaudio.h" -#include "qaudiodeviceinfo.h" -#include "qaudiosystem.h" -#include "qaudiooutput.h" - -#include "qaudiodevicefactory_p.h" - - -QT_BEGIN_NAMESPACE - -/*! - \class QAudioOutput - \brief The QAudioOutput class provides an interface for sending audio data to an audio output device. - - \inmodule QtMultimediaKit - \ingroup multimedia - \since 1.0 - - You can construct an audio output with the system's - \l{QAudioDeviceInfo::defaultOutputDevice()}{default audio output - device}. It is also possible to create QAudioOutput with a - specific QAudioDeviceInfo. When you create the audio output, you - should also send in the QAudioFormat to be used for the playback - (see the QAudioFormat class description for details). - - To play a file: - - Starting to play an audio stream is simply a matter of calling - start() with a QIODevice. QAudioOutput will then fetch the data it - needs from the io device. So playing back an audio file is as - simple as: - - \snippet doc/src/snippets/multimedia-snippets/audio.cpp Audio output class members - - \snippet doc/src/snippets/multimedia-snippets/audio.cpp Audio output setup - - The file will start playing assuming that the audio system and - output device support it. If you run out of luck, check what's - up with the error() function. - - After the file has finished playing, we need to stop the device: - - \snippet doc/src/snippets/multimedia-snippets/audio.cpp Audio output state changed - - At any given time, the QAudioOutput will be in one of four states: - active, suspended, stopped, or idle. These states are described - by the QAudio::State enum. - State changes are reported through the stateChanged() signal. You - can use this signal to, for instance, update the GUI of the - application; the mundane example here being changing the state of - a \c { play/pause } button. You request a state change directly - with suspend(), stop(), reset(), resume(), and start(). - - While the stream is playing, you can set a notify interval in - milliseconds with setNotifyInterval(). This interval specifies the - time between two emissions of the notify() signal. This is - relative to the position in the stream, i.e., if the QAudioOutput - is in the SuspendedState or the IdleState, the notify() signal is - not emitted. A typical use-case would be to update a - \l{QSlider}{slider} that allows seeking in the stream. - If you want the time since playback started regardless of which - states the audio output has been in, elapsedUSecs() is the function for you. - - If an error occurs, you can fetch the \l{QAudio::Error}{error - type} with the error() function. Please see the QAudio::Error enum - for a description of the possible errors that are reported. When - an error is encountered, the state changes to QAudio::StoppedState. - You can check for errors by connecting to the stateChanged() - signal: - - \snippet doc/src/snippets/multimedia-snippets/audio.cpp Audio output state changed - - \sa QAudioInput, QAudioDeviceInfo -*/ - -/*! - Construct a new audio output and attach it to \a parent. - The default audio output device is used with the output - \a format parameters. - \since 1.0 -*/ -QAudioOutput::QAudioOutput(const QAudioFormat &format, QObject *parent): - QObject(parent) -{ - d = QAudioDeviceFactory::createDefaultOutputDevice(format); - connect(d, SIGNAL(notify()), SIGNAL(notify())); - connect(d, SIGNAL(stateChanged(QAudio::State)), SIGNAL(stateChanged(QAudio::State))); -} - -/*! - Construct a new audio output and attach it to \a parent. - The device referenced by \a audioDevice is used with the output - \a format parameters. - \since 1.0 -*/ -QAudioOutput::QAudioOutput(const QAudioDeviceInfo &audioDevice, const QAudioFormat &format, QObject *parent): - QObject(parent) -{ - d = QAudioDeviceFactory::createOutputDevice(audioDevice, format); - connect(d, SIGNAL(notify()), SIGNAL(notify())); - connect(d, SIGNAL(stateChanged(QAudio::State)), SIGNAL(stateChanged(QAudio::State))); -} - -/*! - Destroys this audio output. - - This will release any system resources used and free any buffers. -*/ -QAudioOutput::~QAudioOutput() -{ - delete d; -} - -/*! - Returns the QAudioFormat being used. - - \since 1.0 -*/ -QAudioFormat QAudioOutput::format() const -{ - return d->format(); -} - -/*! - Uses the \a device as the QIODevice to transfer data. - Passing a QIODevice allows the data to be transferred without any extra code. - All that is required is to open the QIODevice. - - If able to successfully output audio data to the systems audio device the - state() is set to QAudio::ActiveState, error() is set to QAudio::NoError - and the stateChanged() signal is emitted. - - If a problem occurs during this process the error() is set to QAudio::OpenError, - state() is set to QAudio::StoppedState and stateChanged() signal is emitted. - - \since 1.0 - \sa QIODevice -*/ -void QAudioOutput::start(QIODevice* device) -{ - d->start(device); -} - -/*! - Returns a pointer to the QIODevice being used to handle the data - transfer. This QIODevice can be used to write() audio data directly. - - If able to access the systems audio device the state() is set to - QAudio::IdleState, error() is set to QAudio::NoError - and the stateChanged() signal is emitted. - - If a problem occurs during this process the error() is set to QAudio::OpenError, - state() is set to QAudio::StoppedState and stateChanged() signal is emitted. - - \since 1.0 - \sa QIODevice -*/ -QIODevice* QAudioOutput::start() -{ - return d->start(); -} - -/*! - Stops the audio output, detaching from the system resource. - - Sets error() to QAudio::NoError, state() to QAudio::StoppedState and - emit stateChanged() signal. - \since 1.0 -*/ -void QAudioOutput::stop() -{ - d->stop(); -} - -/*! - Drops all audio data in the buffers, resets buffers to zero. - - \since 1.0 -*/ -void QAudioOutput::reset() -{ - d->reset(); -} - -/*! - Stops processing audio data, preserving buffered audio data. - - Sets error() to QAudio::NoError, state() to QAudio::SuspendedState and - emits stateChanged() signal. - \since 1.0 -*/ -void QAudioOutput::suspend() -{ - d->suspend(); -} - -/*! - Resumes processing audio data after a suspend(). - - Sets error() to QAudio::NoError. - Sets state() to QAudio::ActiveState if you previously called start(QIODevice*). - Sets state() to QAudio::IdleState if you previously called start(). - emits stateChanged() signal. - \since 1.0 -*/ -void QAudioOutput::resume() -{ - d->resume(); -} - -/*! - Returns the number of free bytes available in the audio buffer. - - \note The returned value is only valid while in QAudio::ActiveState or QAudio::IdleState - state, otherwise returns zero. - \since 1.0 -*/ -int QAudioOutput::bytesFree() const -{ - return d->bytesFree(); -} - -/*! - Returns the period size in bytes. This is the amount of data required each period - to prevent buffer underrun, and to ensure uninterrupted playback. - - \note It is recommended to provide at least enough data for a full period with each - write operation. - \since 1.0 -*/ -int QAudioOutput::periodSize() const -{ - return d->periodSize(); -} - -/*! - Sets the audio buffer size to \a value in bytes. - - \note This function can be called anytime before start(). Calls to this - are ignored after start(). It should not be assumed that the buffer size - set is the actual buffer size used - call bufferSize() anytime after start() - to return the actual buffer size being used. - \since 1.0 -*/ -void QAudioOutput::setBufferSize(int value) -{ - d->setBufferSize(value); -} - -/*! - Returns the audio buffer size in bytes. - - If called before start(), returns platform default value. - If called before start() but setBufferSize() was called prior, returns value set by setBufferSize(). - If called after start(), returns the actual buffer size being used. This may not be what was set previously - by setBufferSize(). - - \since 1.0 -*/ -int QAudioOutput::bufferSize() const -{ - return d->bufferSize(); -} - -/*! - Sets the interval for notify() signal to be emitted. - This is based on the \a ms of audio data processed, - not on wall clock time. - The minimum resolution of the timer is platform specific and values - should be checked with notifyInterval() to confirm the actual value - being used. - \since 1.0 -*/ -void QAudioOutput::setNotifyInterval(int ms) -{ - d->setNotifyInterval(ms); -} - -/*! - Returns the notify interval in milliseconds. - \since 1.0 -*/ -int QAudioOutput::notifyInterval() const -{ - return d->notifyInterval(); -} - -/*! - Returns the amount of audio data processed since start() - was called (in microseconds). - \since 1.0 -*/ -qint64 QAudioOutput::processedUSecs() const -{ - return d->processedUSecs(); -} - -/*! - Returns the microseconds since start() was called, including time in Idle and - Suspend states. - \since 1.0 -*/ -qint64 QAudioOutput::elapsedUSecs() const -{ - return d->elapsedUSecs(); -} - -/*! - Returns the error state. - \since 1.0 -*/ -QAudio::Error QAudioOutput::error() const -{ - return d->error(); -} - -/*! - Returns the state of audio processing. - \since 1.0 -*/ -QAudio::State QAudioOutput::state() const -{ - return d->state(); -} - -/*! - Sets the volume. - Where \a volume is between 0.0 and 1.0 inclusive. - \since 5.0 -*/ -void QAudioOutput::setVolume(qreal volume) -{ - d->setVolume(volume); -} - -/*! - Returns the volume between 0.0 and 1.0 inclusive. - \since 5.0 -*/ -qreal QAudioOutput::volume() const -{ - return d->volume(); -} - -/*! - \fn QAudioOutput::stateChanged(QAudio::State state) - This signal is emitted when the device \a state has changed. - This is the current state of the audio output. - \since 1.0 -*/ - -/*! - \fn QAudioOutput::notify() - This signal is emitted when a certain interval of milliseconds - of audio data has been processed. The interval is set by - setNotifyInterval(). - \since 1.0 -*/ - -QT_END_NAMESPACE - -#include "moc_qaudiooutput.cpp" diff --git a/src/multimediakit/audio/qaudiooutput.h b/src/multimediakit/audio/qaudiooutput.h deleted file mode 100644 index f146c800a..000000000 --- a/src/multimediakit/audio/qaudiooutput.h +++ /dev/null @@ -1,117 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - - -#ifndef QAUDIOOUTPUT_H -#define QAUDIOOUTPUT_H - -#include - -#include -#include - -#include -#include -#include - - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -QT_MODULE(Multimedia) - - - -class QAbstractAudioOutput; - -class Q_MULTIMEDIA_EXPORT QAudioOutput : public QObject -{ - Q_OBJECT - -public: - explicit QAudioOutput(const QAudioFormat &format = QAudioFormat(), QObject *parent = 0); - explicit QAudioOutput(const QAudioDeviceInfo &audioDeviceInfo, const QAudioFormat &format = QAudioFormat(), QObject *parent = 0); - ~QAudioOutput(); - - QAudioFormat format() const; - - void start(QIODevice *device); - QIODevice* start(); - - void stop(); - void reset(); - void suspend(); - void resume(); - - void setBufferSize(int bytes); - int bufferSize() const; - - int bytesFree() const; - int periodSize() const; - - void setNotifyInterval(int milliSeconds); - int notifyInterval() const; - - qint64 processedUSecs() const; - qint64 elapsedUSecs() const; - - QAudio::Error error() const; - QAudio::State state() const; - - void setVolume(qreal); - qreal volume() const; - -Q_SIGNALS: - void stateChanged(QAudio::State); - void notify(); - -private: - Q_DISABLE_COPY(QAudioOutput) - - QAbstractAudioOutput* d; -}; - -QT_END_NAMESPACE - -QT_END_HEADER - -#endif // QAUDIOOUTPUT_H diff --git a/src/multimediakit/audio/qaudiooutput_alsa_p.cpp b/src/multimediakit/audio/qaudiooutput_alsa_p.cpp deleted file mode 100644 index 8ef4e2819..000000000 --- a/src/multimediakit/audio/qaudiooutput_alsa_p.cpp +++ /dev/null @@ -1,834 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -// -// W A R N I N G -// ------------- -// -// This file is not part of the Qt API. It exists for the convenience -// of other Qt classes. This header file may change from version to -// version without notice, or even be removed. -// -// INTERNAL USE ONLY: Do NOT use for any other purpose. -// - -#include -#include "qaudiooutput_alsa_p.h" -#include "qaudiodeviceinfo_alsa_p.h" - -QT_BEGIN_NAMESPACE - -//#define DEBUG_AUDIO 1 - -QAudioOutputPrivate::QAudioOutputPrivate(const QByteArray &device) -{ - bytesAvailable = 0; - handle = 0; - ahandler = 0; - access = SND_PCM_ACCESS_RW_INTERLEAVED; - pcmformat = SND_PCM_FORMAT_S16; - buffer_frames = 0; - period_frames = 0; - buffer_size = 0; - period_size = 0; - buffer_time = 100000; - period_time = 20000; - totalTimeValue = 0; - intervalTime = 1000; - audioBuffer = 0; - errorState = QAudio::NoError; - deviceState = QAudio::StoppedState; - audioSource = 0; - pullMode = true; - resuming = false; - opened = false; - - m_device = device; - - timer = new QTimer(this); - connect(timer,SIGNAL(timeout()),SLOT(userFeed())); -} - -QAudioOutputPrivate::~QAudioOutputPrivate() -{ - close(); - disconnect(timer, SIGNAL(timeout())); - QCoreApplication::processEvents(); - delete timer; -} - -QAudio::Error QAudioOutputPrivate::error() const -{ - return errorState; -} - -QAudio::State QAudioOutputPrivate::state() const -{ - return deviceState; -} - -void QAudioOutputPrivate::async_callback(snd_async_handler_t *ahandler) -{ - QAudioOutputPrivate* audioOut; - - audioOut = static_cast - (snd_async_handler_get_callback_private(ahandler)); - - if((audioOut->deviceState==QAudio::ActiveState)||(audioOut->resuming)) - audioOut->feedback(); -} - -int QAudioOutputPrivate::xrun_recovery(int err) -{ - int count = 0; - bool reset = false; - - if(err == -EPIPE) { - errorState = QAudio::UnderrunError; - emit errorChanged(errorState); - err = snd_pcm_prepare(handle); - if(err < 0) - reset = true; - - } else if((err == -ESTRPIPE)||(err == -EIO)) { - errorState = QAudio::IOError; - emit errorChanged(errorState); - while((err = snd_pcm_resume(handle)) == -EAGAIN){ - usleep(100); - count++; - if(count > 5) { - reset = true; - break; - } - } - if(err < 0) { - err = snd_pcm_prepare(handle); - if(err < 0) - reset = true; - } - } - if(reset) { - close(); - open(); - snd_pcm_prepare(handle); - return 0; - } - return err; -} - -int QAudioOutputPrivate::setFormat() -{ - snd_pcm_format_t pcmformat = SND_PCM_FORMAT_UNKNOWN; - - if(settings.sampleSize() == 8) { - pcmformat = SND_PCM_FORMAT_U8; - - } else if(settings.sampleSize() == 16) { - if(settings.sampleType() == QAudioFormat::SignedInt) { - if(settings.byteOrder() == QAudioFormat::LittleEndian) - pcmformat = SND_PCM_FORMAT_S16_LE; - else - pcmformat = SND_PCM_FORMAT_S16_BE; - } else if(settings.sampleType() == QAudioFormat::UnSignedInt) { - if(settings.byteOrder() == QAudioFormat::LittleEndian) - pcmformat = SND_PCM_FORMAT_U16_LE; - else - pcmformat = SND_PCM_FORMAT_U16_BE; - } - } else if(settings.sampleSize() == 24) { - if(settings.sampleType() == QAudioFormat::SignedInt) { - if(settings.byteOrder() == QAudioFormat::LittleEndian) - pcmformat = SND_PCM_FORMAT_S24_LE; - else - pcmformat = SND_PCM_FORMAT_S24_BE; - } else if(settings.sampleType() == QAudioFormat::UnSignedInt) { - if(settings.byteOrder() == QAudioFormat::LittleEndian) - pcmformat = SND_PCM_FORMAT_U24_LE; - else - pcmformat = SND_PCM_FORMAT_U24_BE; - } - } else if(settings.sampleSize() == 32) { - if(settings.sampleType() == QAudioFormat::SignedInt) { - if(settings.byteOrder() == QAudioFormat::LittleEndian) - pcmformat = SND_PCM_FORMAT_S32_LE; - else - pcmformat = SND_PCM_FORMAT_S32_BE; - } else if(settings.sampleType() == QAudioFormat::UnSignedInt) { - if(settings.byteOrder() == QAudioFormat::LittleEndian) - pcmformat = SND_PCM_FORMAT_U32_LE; - else - pcmformat = SND_PCM_FORMAT_U32_BE; - } else if(settings.sampleType() == QAudioFormat::Float) { - if(settings.byteOrder() == QAudioFormat::LittleEndian) - pcmformat = SND_PCM_FORMAT_FLOAT_LE; - else - pcmformat = SND_PCM_FORMAT_FLOAT_BE; - } - } else if(settings.sampleSize() == 64) { - if(settings.byteOrder() == QAudioFormat::LittleEndian) - pcmformat = SND_PCM_FORMAT_FLOAT64_LE; - else - pcmformat = SND_PCM_FORMAT_FLOAT64_BE; - } - - return pcmformat != SND_PCM_FORMAT_UNKNOWN - ? snd_pcm_hw_params_set_format( handle, hwparams, pcmformat) - : -1; -} - -void QAudioOutputPrivate::start(QIODevice* device) -{ - if(deviceState != QAudio::StoppedState) - deviceState = QAudio::StoppedState; - - errorState = QAudio::NoError; - - // Handle change of mode - if(audioSource && !pullMode) { - delete audioSource; - audioSource = 0; - } - - close(); - - pullMode = true; - audioSource = device; - - deviceState = QAudio::ActiveState; - - open(); - - emit stateChanged(deviceState); -} - -QIODevice* QAudioOutputPrivate::start() -{ - if(deviceState != QAudio::StoppedState) - deviceState = QAudio::StoppedState; - - errorState = QAudio::NoError; - - // Handle change of mode - if(audioSource && !pullMode) { - delete audioSource; - audioSource = 0; - } - - close(); - - audioSource = new OutputPrivate(this); - audioSource->open(QIODevice::WriteOnly|QIODevice::Unbuffered); - pullMode = false; - - deviceState = QAudio::IdleState; - - open(); - - emit stateChanged(deviceState); - - return audioSource; -} - -void QAudioOutputPrivate::stop() -{ - if(deviceState == QAudio::StoppedState) - return; - errorState = QAudio::NoError; - deviceState = QAudio::StoppedState; - close(); - emit stateChanged(deviceState); -} - -bool QAudioOutputPrivate::open() -{ - if(opened) - return true; - -#ifdef DEBUG_AUDIO - QTime now(QTime::currentTime()); - qDebug()< devices = QAudioDeviceInfoInternal::availableDevices(QAudio::AudioOutput); - if(dev.compare(QLatin1String("default")) == 0) { -#if(SND_LIB_MAJOR == 1 && SND_LIB_MINOR == 0 && SND_LIB_SUBMINOR >= 14) - if (devices.size() > 0) - dev = QLatin1String(devices.first()); - else - return false; -#else - dev = QLatin1String("hw:0,0"); -#endif - } else { -#if(SND_LIB_MAJOR == 1 && SND_LIB_MINOR == 0 && SND_LIB_SUBMINOR >= 14) - dev = QLatin1String(m_device); -#else - int idx = 0; - char *name; - - QString shortName = QLatin1String(m_device.mid(m_device.indexOf('=',0)+1).constData()); - - while(snd_card_get_name(idx,&name) == 0) { - if(qstrncmp(shortName.toLocal8Bit().constData(),name,shortName.length()) == 0) - break; - idx++; - } - dev = QString(QLatin1String("hw:%1,0")).arg(idx); -#endif - } - - // Step 1: try and open the device - while((count < 5) && (err < 0)) { - err=snd_pcm_open(&handle,dev.toLocal8Bit().constData(),SND_PCM_STREAM_PLAYBACK,0); - if(err < 0) - count++; - } - if (( err < 0)||(handle == 0)) { - errorState = QAudio::OpenError; - emit errorChanged(errorState); - deviceState = QAudio::StoppedState; - return false; - } - snd_pcm_nonblock( handle, 0 ); - - // Step 2: Set the desired HW parameters. - snd_pcm_hw_params_alloca( &hwparams ); - - bool fatal = false; - QString errMessage; - unsigned int chunks = 8; - - err = snd_pcm_hw_params_any( handle, hwparams ); - if ( err < 0 ) { - fatal = true; - errMessage = QString::fromLatin1("QAudioOutput: snd_pcm_hw_params_any: err = %1").arg(err); - } - if ( !fatal ) { - err = snd_pcm_hw_params_set_rate_resample( handle, hwparams, 1 ); - if ( err < 0 ) { - fatal = true; - errMessage = QString::fromLatin1("QAudioOutput: snd_pcm_hw_params_set_rate_resample: err = %1").arg(err); - } - } - if ( !fatal ) { - err = snd_pcm_hw_params_set_access( handle, hwparams, access ); - if ( err < 0 ) { - fatal = true; - errMessage = QString::fromLatin1("QAudioOutput: snd_pcm_hw_params_set_access: err = %1").arg(err); - } - } - if ( !fatal ) { - err = setFormat(); - if ( err < 0 ) { - fatal = true; - errMessage = QString::fromLatin1("QAudioOutput: snd_pcm_hw_params_set_format: err = %1").arg(err); - } - } - if ( !fatal ) { - err = snd_pcm_hw_params_set_channels( handle, hwparams, (unsigned int)settings.channels() ); - if ( err < 0 ) { - fatal = true; - errMessage = QString::fromLatin1("QAudioOutput: snd_pcm_hw_params_set_channels: err = %1").arg(err); - } - } - if ( !fatal ) { - err = snd_pcm_hw_params_set_rate_near( handle, hwparams, &freakuency, 0 ); - if ( err < 0 ) { - fatal = true; - errMessage = QString::fromLatin1("QAudioOutput: snd_pcm_hw_params_set_rate_near: err = %1").arg(err); - } - } - if ( !fatal ) { - unsigned int maxBufferTime = 0; - unsigned int minBufferTime = 0; - unsigned int maxPeriodTime = 0; - unsigned int minPeriodTime = 0; - - err = snd_pcm_hw_params_get_buffer_time_max(hwparams, &maxBufferTime, &dir); - if ( err >= 0) - err = snd_pcm_hw_params_get_buffer_time_min(hwparams, &minBufferTime, &dir); - if ( err >= 0) - err = snd_pcm_hw_params_get_period_time_max(hwparams, &maxPeriodTime, &dir); - if ( err >= 0) - err = snd_pcm_hw_params_get_period_time_min(hwparams, &minPeriodTime, &dir); - - if ( err < 0 ) { - fatal = true; - errMessage = QString::fromLatin1("QAudioOutput: buffer/period min and max: err = %1").arg(err); - } else { - if (maxBufferTime < buffer_time || buffer_time < minBufferTime || maxPeriodTime < period_time || minPeriodTime > period_time) { -#ifdef DEBUG_AUDIO - qDebug()<<"defaults out of range"; - qDebug()<<"pmin="<start(period_time/1000); - - clockStamp.restart(); - timeStamp.restart(); - elapsedTimeOffset = 0; - errorState = QAudio::NoError; - totalTimeValue = 0; - opened = true; - - return true; -} - -void QAudioOutputPrivate::close() -{ - timer->stop(); - - if ( handle ) { - snd_pcm_drain( handle ); - snd_pcm_close( handle ); - handle = 0; - delete [] audioBuffer; - audioBuffer=0; - } - if(!pullMode && audioSource) { - delete audioSource; - audioSource = 0; - } - opened = false; -} - -int QAudioOutputPrivate::bytesFree() const -{ - if(resuming) - return period_size; - - if(deviceState != QAudio::ActiveState && deviceState != QAudio::IdleState) - return 0; - - int frames = snd_pcm_avail_update(handle); - if (frames == -EPIPE) { - // Try and handle buffer underrun - int err = snd_pcm_recover(handle, frames, 0); - if (err < 0) - return 0; - else - frames = snd_pcm_avail_update(handle); - } else if (frames < 0) { - return 0; - } - - if ((int)frames > (int)buffer_frames) - frames = buffer_frames; - - return snd_pcm_frames_to_bytes(handle, frames); -} - -qint64 QAudioOutputPrivate::write( const char *data, qint64 len ) -{ - // Write out some audio data - if ( !handle ) - return 0; -#ifdef DEBUG_AUDIO - qDebug()<<"frames to write out = "<< - snd_pcm_bytes_to_frames( handle, (int)len )<<" ("< 0) { - totalTimeValue += err; - resuming = false; - errorState = QAudio::NoError; - if (deviceState != QAudio::ActiveState) { - deviceState = QAudio::ActiveState; - emit stateChanged(deviceState); - } - return snd_pcm_frames_to_bytes( handle, err ); - } else - err = xrun_recovery(err); - - if(err < 0) { - close(); - errorState = QAudio::FatalError; - emit errorChanged(errorState); - deviceState = QAudio::StoppedState; - emit stateChanged(deviceState); - } - return 0; -} - -int QAudioOutputPrivate::periodSize() const -{ - return period_size; -} - -void QAudioOutputPrivate::setBufferSize(int value) -{ - if(deviceState == QAudio::StoppedState) - buffer_size = value; -} - -int QAudioOutputPrivate::bufferSize() const -{ - return buffer_size; -} - -void QAudioOutputPrivate::setNotifyInterval(int ms) -{ - intervalTime = qMax(0, ms); -} - -int QAudioOutputPrivate::notifyInterval() const -{ - return intervalTime; -} - -qint64 QAudioOutputPrivate::processedUSecs() const -{ - return qint64(1000000) * totalTimeValue / settings.frequency(); -} - -void QAudioOutputPrivate::resume() -{ - if(deviceState == QAudio::SuspendedState) { - int err = 0; - - if(handle) { - err = snd_pcm_prepare( handle ); - if(err < 0) - xrun_recovery(err); - - err = snd_pcm_start(handle); - if(err < 0) - xrun_recovery(err); - - bytesAvailable = (int)snd_pcm_frames_to_bytes(handle, buffer_frames); - } - resuming = true; - - deviceState = QAudio::ActiveState; - - errorState = QAudio::NoError; - timer->start(period_time/1000); - emit stateChanged(deviceState); - } -} - -void QAudioOutputPrivate::setFormat(const QAudioFormat& fmt) -{ - if (deviceState == QAudio::StoppedState) - settings = fmt; -} - -QAudioFormat QAudioOutputPrivate::format() const -{ - return settings; -} - -void QAudioOutputPrivate::suspend() -{ - if(deviceState == QAudio::ActiveState || deviceState == QAudio::IdleState || resuming) { - timer->stop(); - deviceState = QAudio::SuspendedState; - errorState = QAudio::NoError; - emit stateChanged(deviceState); - } -} - -void QAudioOutputPrivate::userFeed() -{ - if(deviceState == QAudio::StoppedState || deviceState == QAudio::SuspendedState) - return; -#ifdef DEBUG_AUDIO - QTime now(QTime::currentTime()); - qDebug()< - -#include -#include -#include -#include -#include -#include - -#include "qaudio.h" -#include "qaudiodeviceinfo.h" -#include "qaudiosystem.h" - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -QT_MODULE(Multimedia) - - -class OutputPrivate; - -class QAudioOutputPrivate : public QAbstractAudioOutput -{ - friend class OutputPrivate; - Q_OBJECT -public: - QAudioOutputPrivate(const QByteArray &device); - ~QAudioOutputPrivate(); - - qint64 write( const char *data, qint64 len ); - - void start(QIODevice* device); - QIODevice* start(); - void stop(); - void reset(); - void suspend(); - void resume(); - int bytesFree() const; - int periodSize() const; - void setBufferSize(int value); - int bufferSize() const; - void setNotifyInterval(int milliSeconds); - int notifyInterval() const; - qint64 processedUSecs() const; - qint64 elapsedUSecs() const; - QAudio::Error error() const; - QAudio::State state() const; - void setFormat(const QAudioFormat& fmt); - QAudioFormat format() const; - - QIODevice* audioSource; - QAudioFormat settings; - QAudio::Error errorState; - QAudio::State deviceState; - -private slots: - void userFeed(); - void feedback(); - void updateAvailable(); - bool deviceReady(); - -signals: - void processMore(); - -private: - bool opened; - bool pullMode; - bool resuming; - int buffer_size; - int period_size; - int intervalTime; - qint64 totalTimeValue; - unsigned int buffer_time; - unsigned int period_time; - snd_pcm_uframes_t buffer_frames; - snd_pcm_uframes_t period_frames; - static void async_callback(snd_async_handler_t *ahandler); - int xrun_recovery(int err); - - int setFormat(); - bool open(); - void close(); - - QTimer* timer; - QByteArray m_device; - int bytesAvailable; - QTime timeStamp; - QTime clockStamp; - qint64 elapsedTimeOffset; - char* audioBuffer; - snd_pcm_t* handle; - snd_async_handler_t* ahandler; - snd_pcm_access_t access; - snd_pcm_format_t pcmformat; - snd_timestamp_t* timestamp; - snd_pcm_hw_params_t *hwparams; -}; - -class OutputPrivate : public QIODevice -{ - friend class QAudioOutputPrivate; - Q_OBJECT -public: - OutputPrivate(QAudioOutputPrivate* audio); - ~OutputPrivate(); - - qint64 readData( char* data, qint64 len); - qint64 writeData(const char* data, qint64 len); - -private: - QAudioOutputPrivate *audioDevice; -}; - -QT_END_NAMESPACE - -QT_END_HEADER - - -#endif diff --git a/src/multimediakit/audio/qaudiooutput_mac_p.cpp b/src/multimediakit/audio/qaudiooutput_mac_p.cpp deleted file mode 100644 index cace401d6..000000000 --- a/src/multimediakit/audio/qaudiooutput_mac_p.cpp +++ /dev/null @@ -1,734 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -// -// W A R N I N G -// ------------- -// -// This file is not part of the Qt API. It exists for the convenience -// of other Qt classes. This header file may change from version to -// version without notice, or even be removed. -// -// INTERNAL USE ONLY: Do NOT use for any other purpose. -// - -#include -#include -#include -#include - -#include -#include -#include -#include - -#include - -#include "qaudio_mac_p.h" -#include "qaudiooutput_mac_p.h" -#include "qaudiodeviceinfo_mac_p.h" - - -QT_BEGIN_NAMESPACE - - -namespace QtMultimediaKitInternal -{ - -static const int default_buffer_size = 8 * 1024; - - -class QAudioOutputBuffer : public QObject -{ - Q_OBJECT - -public: - QAudioOutputBuffer(int bufferSize, int maxPeriodSize, QAudioFormat const& audioFormat): - m_deviceError(false), - m_maxPeriodSize(maxPeriodSize), - m_device(0) - { - m_buffer = new QAudioRingBuffer(bufferSize + (bufferSize % maxPeriodSize == 0 ? 0 : maxPeriodSize - (bufferSize % maxPeriodSize))); - m_bytesPerFrame = (audioFormat.sampleSize() / 8) * audioFormat.channels(); - m_periodTime = m_maxPeriodSize / m_bytesPerFrame * 1000 / audioFormat.frequency(); - - m_fillTimer = new QTimer(this); - connect(m_fillTimer, SIGNAL(timeout()), SLOT(fillBuffer())); - } - - ~QAudioOutputBuffer() - { - delete m_buffer; - } - - qint64 readFrames(char* data, qint64 maxFrames) - { - bool wecan = true; - qint64 framesRead = 0; - - while (wecan && framesRead < maxFrames) { - QAudioRingBuffer::Region region = m_buffer->acquireReadRegion((maxFrames - framesRead) * m_bytesPerFrame); - - if (region.second > 0) { - // Ensure that we only read whole frames. - region.second -= region.second % m_bytesPerFrame; - - if (region.second > 0) { - memcpy(data + (framesRead * m_bytesPerFrame), region.first, region.second); - framesRead += region.second / m_bytesPerFrame; - } else - wecan = false; // If there is only a partial frame left we should exit. - } - else - wecan = false; - - m_buffer->releaseReadRegion(region); - } - - if (framesRead == 0 && m_deviceError) - framesRead = -1; - - return framesRead; - } - - qint64 writeBytes(const char* data, qint64 maxSize) - { - bool wecan = true; - qint64 bytesWritten = 0; - - maxSize -= maxSize % m_bytesPerFrame; - while (wecan && bytesWritten < maxSize) { - QAudioRingBuffer::Region region = m_buffer->acquireWriteRegion(maxSize - bytesWritten); - - if (region.second > 0) { - memcpy(region.first, data + bytesWritten, region.second); - bytesWritten += region.second; - } - else - wecan = false; - - m_buffer->releaseWriteRegion(region); - } - - if (bytesWritten > 0) - emit readyRead(); - - return bytesWritten; - } - - int available() const - { - return m_buffer->free(); - } - - void reset() - { - m_buffer->reset(); - m_device = 0; - m_deviceError = false; - } - - void setPrefetchDevice(QIODevice* device) - { - if (m_device != device) { - m_device = device; - if (m_device != 0) - fillBuffer(); - } - } - - void startFillTimer() - { - if (m_device != 0) - m_fillTimer->start(m_buffer->size() / 2 / m_maxPeriodSize * m_periodTime); - } - - void stopFillTimer() - { - m_fillTimer->stop(); - } - -signals: - void readyRead(); - -private slots: - void fillBuffer() - { - const int free = m_buffer->free(); - const int writeSize = free - (free % m_maxPeriodSize); - - if (writeSize > 0) { - bool wecan = true; - int filled = 0; - - while (!m_deviceError && wecan && filled < writeSize) { - QAudioRingBuffer::Region region = m_buffer->acquireWriteRegion(writeSize - filled); - - if (region.second > 0) { - region.second = m_device->read(region.first, region.second); - if (region.second > 0) - filled += region.second; - else if (region.second == 0) - wecan = false; - else if (region.second < 0) { - m_fillTimer->stop(); - region.second = 0; - m_deviceError = true; - } - } - else - wecan = false; - - m_buffer->releaseWriteRegion(region); - } - - if (filled > 0) - emit readyRead(); - } - } - -private: - bool m_deviceError; - int m_maxPeriodSize; - int m_bytesPerFrame; - int m_periodTime; - QIODevice* m_device; - QTimer* m_fillTimer; - QAudioRingBuffer* m_buffer; -}; - - -} - -class MacOutputDevice : public QIODevice -{ - Q_OBJECT - -public: - MacOutputDevice(QtMultimediaKitInternal::QAudioOutputBuffer* audioBuffer, QObject* parent): - QIODevice(parent), - m_audioBuffer(audioBuffer) - { - open(QIODevice::WriteOnly | QIODevice::Unbuffered); - } - - qint64 readData(char* data, qint64 len) - { - Q_UNUSED(data); - Q_UNUSED(len); - - return 0; - } - - qint64 writeData(const char* data, qint64 len) - { - return m_audioBuffer->writeBytes(data, len); - } - - bool isSequential() const - { - return true; - } - -private: - QtMultimediaKitInternal::QAudioOutputBuffer* m_audioBuffer; -}; - - -QAudioOutputPrivate::QAudioOutputPrivate(const QByteArray& device) -{ - QDataStream ds(device); - quint32 did, mode; - - ds >> did >> mode; - - if (QAudio::Mode(mode) == QAudio::AudioInput) - errorCode = QAudio::OpenError; - else { - audioDeviceInfo = new QAudioDeviceInfoInternal(device, QAudio::AudioOutput); - isOpen = false; - audioDeviceId = AudioDeviceID(did); - audioUnit = 0; - audioIO = 0; - startTime = 0; - totalFrames = 0; - audioBuffer = 0; - internalBufferSize = QtMultimediaKitInternal::default_buffer_size; - clockFrequency = AudioGetHostClockFrequency() / 1000; - errorCode = QAudio::NoError; - stateCode = QAudio::StoppedState; - audioThreadState = Stopped; - - intervalTimer = new QTimer(this); - intervalTimer->setInterval(1000); - connect(intervalTimer, SIGNAL(timeout()), SIGNAL(notify())); - } -} - -QAudioOutputPrivate::~QAudioOutputPrivate() -{ - delete audioDeviceInfo; - close(); -} - -bool QAudioOutputPrivate::open() -{ - if (errorCode != QAudio::NoError) - return false; - - if (isOpen) - return true; - - ComponentDescription cd; - cd.componentType = kAudioUnitType_Output; - cd.componentSubType = kAudioUnitSubType_HALOutput; - cd.componentManufacturer = kAudioUnitManufacturer_Apple; - cd.componentFlags = 0; - cd.componentFlagsMask = 0; - - // Open - Component cp = FindNextComponent(NULL, &cd); - if (cp == 0) { - qWarning() << "QAudioOutput: Failed to find HAL Output component"; - return false; - } - - if (OpenAComponent(cp, &audioUnit) != noErr) { - qWarning() << "QAudioOutput: Unable to Open Output Component"; - return false; - } - - // register callback - AURenderCallbackStruct cb; - cb.inputProc = renderCallback; - cb.inputProcRefCon = this; - - if (AudioUnitSetProperty(audioUnit, - kAudioUnitProperty_SetRenderCallback, - kAudioUnitScope_Global, - 0, - &cb, - sizeof(cb)) != noErr) { - qWarning() << "QAudioOutput: Failed to set AudioUnit callback"; - return false; - } - - // Set Audio Device - if (AudioUnitSetProperty(audioUnit, - kAudioOutputUnitProperty_CurrentDevice, - kAudioUnitScope_Global, - 0, - &audioDeviceId, - sizeof(audioDeviceId)) != noErr) { - qWarning() << "QAudioOutput: Unable to use configured device"; - return false; - } - - // Set stream format - streamFormat = toAudioStreamBasicDescription(audioFormat); - - UInt32 size = sizeof(streamFormat); - if (AudioUnitSetProperty(audioUnit, - kAudioUnitProperty_StreamFormat, - kAudioUnitScope_Input, - 0, - &streamFormat, - sizeof(streamFormat)) != noErr) { - qWarning() << "QAudioOutput: Unable to Set Stream information"; - return false; - } - - // Allocate buffer - UInt32 numberOfFrames = 0; - size = sizeof(UInt32); - if (AudioUnitGetProperty(audioUnit, - kAudioDevicePropertyBufferFrameSize, - kAudioUnitScope_Global, - 0, - &numberOfFrames, - &size) != noErr) { - qWarning() << "QAudioInput: Failed to get audio period size"; - return false; - } - - periodSizeBytes = numberOfFrames * streamFormat.mBytesPerFrame; - if (internalBufferSize < periodSizeBytes * 2) - internalBufferSize = periodSizeBytes * 2; - else - internalBufferSize -= internalBufferSize % streamFormat.mBytesPerFrame; - - audioBuffer = new QtMultimediaKitInternal::QAudioOutputBuffer(internalBufferSize, periodSizeBytes, audioFormat); - connect(audioBuffer, SIGNAL(readyRead()), SLOT(inputReady())); // Pull - - audioIO = new MacOutputDevice(audioBuffer, this); - - // Init - if (AudioUnitInitialize(audioUnit)) { - qWarning() << "QAudioOutput: Failed to initialize AudioUnit"; - return false; - } - - isOpen = true; - - return true; -} - -void QAudioOutputPrivate::close() -{ - if (audioUnit != 0) { - AudioOutputUnitStop(audioUnit); - AudioUnitUninitialize(audioUnit); - CloseComponent(audioUnit); - } - - delete audioBuffer; -} - -QAudioFormat QAudioOutputPrivate::format() const -{ - return audioFormat; -} - -void QAudioOutputPrivate::setFormat(const QAudioFormat& fmt) -{ - if (stateCode == QAudio::StoppedState) - audioFormat = fmt; -} - -void QAudioOutputPrivate::start(QIODevice* device) -{ - QIODevice* op = device; - - if (!audioDeviceInfo->isFormatSupported(audioFormat) || !open()) { - stateCode = QAudio::StoppedState; - errorCode = QAudio::OpenError; - } - - reset(); - audioBuffer->reset(); - audioBuffer->setPrefetchDevice(op); - - if (op == 0) { - op = audioIO; - stateCode = QAudio::IdleState; - } - else - stateCode = QAudio::ActiveState; - - // Start - errorCode = QAudio::NoError; - totalFrames = 0; - startTime = AudioGetCurrentHostTime(); - - if (stateCode == QAudio::ActiveState) - audioThreadStart(); - - emit stateChanged(stateCode); -} - -QIODevice* QAudioOutputPrivate::start() -{ - if (!audioDeviceInfo->isFormatSupported(audioFormat) || !open()) { - stateCode = QAudio::StoppedState; - errorCode = QAudio::OpenError; - return audioIO; - } - - reset(); - audioBuffer->reset(); - audioBuffer->setPrefetchDevice(0); - - stateCode = QAudio::IdleState; - - // Start - errorCode = QAudio::NoError; - totalFrames = 0; - startTime = AudioGetCurrentHostTime(); - - emit stateChanged(stateCode); - - return audioIO; -} - -void QAudioOutputPrivate::stop() -{ - QMutexLocker lock(&mutex); - if (stateCode != QAudio::StoppedState) { - audioThreadDrain(); - - stateCode = QAudio::StoppedState; - errorCode = QAudio::NoError; - QMetaObject::invokeMethod(this, "stateChanged", Qt::QueuedConnection, Q_ARG(QAudio::State, stateCode)); - } -} - -void QAudioOutputPrivate::reset() -{ - QMutexLocker lock(&mutex); - if (stateCode != QAudio::StoppedState) { - audioThreadStop(); - - stateCode = QAudio::StoppedState; - errorCode = QAudio::NoError; - QMetaObject::invokeMethod(this, "stateChanged", Qt::QueuedConnection, Q_ARG(QAudio::State, stateCode)); - } -} - -void QAudioOutputPrivate::suspend() -{ - QMutexLocker lock(&mutex); - if (stateCode == QAudio::ActiveState || stateCode == QAudio::IdleState) { - audioThreadStop(); - - stateCode = QAudio::SuspendedState; - errorCode = QAudio::NoError; - QMetaObject::invokeMethod(this, "stateChanged", Qt::QueuedConnection, Q_ARG(QAudio::State, stateCode)); - } -} - -void QAudioOutputPrivate::resume() -{ - QMutexLocker lock(&mutex); - if (stateCode == QAudio::SuspendedState) { - audioThreadStart(); - - stateCode = QAudio::ActiveState; - errorCode = QAudio::NoError; - QMetaObject::invokeMethod(this, "stateChanged", Qt::QueuedConnection, Q_ARG(QAudio::State, stateCode)); - } -} - -int QAudioOutputPrivate::bytesFree() const -{ - return audioBuffer->available(); -} - -int QAudioOutputPrivate::periodSize() const -{ - return periodSizeBytes; -} - -void QAudioOutputPrivate::setBufferSize(int bs) -{ - if (stateCode == QAudio::StoppedState) - internalBufferSize = bs; -} - -int QAudioOutputPrivate::bufferSize() const -{ - return internalBufferSize; -} - -void QAudioOutputPrivate::setNotifyInterval(int milliSeconds) -{ - if (intervalTimer->interval() == milliSeconds) - return; - - if (milliSeconds <= 0) - milliSeconds = 0; - - intervalTimer->setInterval(milliSeconds); -} - -int QAudioOutputPrivate::notifyInterval() const -{ - return intervalTimer->interval(); -} - -qint64 QAudioOutputPrivate::processedUSecs() const -{ - return totalFrames * 1000000 / audioFormat.frequency(); -} - -qint64 QAudioOutputPrivate::elapsedUSecs() const -{ - if (stateCode == QAudio::StoppedState) - return 0; - - return (AudioGetCurrentHostTime() - startTime) / (clockFrequency / 1000); -} - -QAudio::Error QAudioOutputPrivate::error() const -{ - return errorCode; -} - -QAudio::State QAudioOutputPrivate::state() const -{ - return stateCode; -} - -void QAudioOutputPrivate::audioThreadStart() -{ - startTimers(); - audioThreadState = Running; - AudioOutputUnitStart(audioUnit); -} - -void QAudioOutputPrivate::audioThreadStop() -{ - stopTimers(); - if (audioThreadState.testAndSetAcquire(Running, Stopped)) - threadFinished.wait(&mutex); -} - -void QAudioOutputPrivate::audioThreadDrain() -{ - stopTimers(); - if (audioThreadState.testAndSetAcquire(Running, Draining)) - threadFinished.wait(&mutex); -} - -void QAudioOutputPrivate::audioDeviceStop() -{ - AudioOutputUnitStop(audioUnit); - audioThreadState = Stopped; - threadFinished.wakeOne(); -} - -void QAudioOutputPrivate::audioDeviceIdle() -{ - QMutexLocker lock(&mutex); - if (stateCode == QAudio::ActiveState) { - audioDeviceStop(); - - errorCode = QAudio::UnderrunError; - stateCode = QAudio::IdleState; - QMetaObject::invokeMethod(this, "deviceStopped", Qt::QueuedConnection); - } -} - -void QAudioOutputPrivate::audioDeviceError() -{ - QMutexLocker lock(&mutex); - if (stateCode == QAudio::ActiveState) { - audioDeviceStop(); - - errorCode = QAudio::IOError; - stateCode = QAudio::StoppedState; - QMetaObject::invokeMethod(this, "deviceStopped", Qt::QueuedConnection); - } -} - -void QAudioOutputPrivate::startTimers() -{ - audioBuffer->startFillTimer(); - if (intervalTimer->interval() > 0) - intervalTimer->start(); -} - -void QAudioOutputPrivate::stopTimers() -{ - audioBuffer->stopFillTimer(); - intervalTimer->stop(); -} - - -void QAudioOutputPrivate::deviceStopped() -{ - intervalTimer->stop(); - emit stateChanged(stateCode); -} - -void QAudioOutputPrivate::inputReady() -{ - QMutexLocker lock(&mutex); - if (stateCode == QAudio::IdleState) { - audioThreadStart(); - - stateCode = QAudio::ActiveState; - errorCode = QAudio::NoError; - - QMetaObject::invokeMethod(this, "stateChanged", Qt::QueuedConnection, Q_ARG(QAudio::State, stateCode)); - } -} - - -OSStatus QAudioOutputPrivate::renderCallback(void* inRefCon, - AudioUnitRenderActionFlags* ioActionFlags, - const AudioTimeStamp* inTimeStamp, - UInt32 inBusNumber, - UInt32 inNumberFrames, - AudioBufferList* ioData) -{ - Q_UNUSED(ioActionFlags) - Q_UNUSED(inTimeStamp) - Q_UNUSED(inBusNumber) - Q_UNUSED(inNumberFrames) - - QAudioOutputPrivate* d = static_cast(inRefCon); - - const int threadState = d->audioThreadState.fetchAndAddAcquire(0); - if (threadState == Stopped) { - ioData->mBuffers[0].mDataByteSize = 0; - d->audioDeviceStop(); - } - else { - const UInt32 bytesPerFrame = d->streamFormat.mBytesPerFrame; - qint64 framesRead; - - framesRead = d->audioBuffer->readFrames((char*)ioData->mBuffers[0].mData, - ioData->mBuffers[0].mDataByteSize / bytesPerFrame); - - if (framesRead > 0) { - ioData->mBuffers[0].mDataByteSize = framesRead * bytesPerFrame; - d->totalFrames += framesRead; - } - else { - ioData->mBuffers[0].mDataByteSize = 0; - if (framesRead == 0) { - if (threadState == Draining) - d->audioDeviceStop(); - else - d->audioDeviceIdle(); - } - else - d->audioDeviceError(); - } - } - - return noErr; -} - - -QT_END_NAMESPACE - -#include "qaudiooutput_mac_p.moc" diff --git a/src/multimediakit/audio/qaudiooutput_mac_p.h b/src/multimediakit/audio/qaudiooutput_mac_p.h deleted file mode 100644 index d1cf680b1..000000000 --- a/src/multimediakit/audio/qaudiooutput_mac_p.h +++ /dev/null @@ -1,174 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -// -// W A R N I N G -// ------------- -// -// This file is not part of the Qt API. It exists for the convenience -// of other Qt classes. This header file may change from version to -// version without notice, or even be removed. -// -// We mean it. -// - -#ifndef QAUDIOOUTPUT_MAC_P_H -#define QAUDIOOUTPUT_MAC_P_H - -#include -#include -#include -#include - -#include -#include -#include -#include -#include - -#include -#include -#include - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -QT_MODULE(Multimedia) - - -class QIODevice; -class QAbstractAudioDeviceInfo; - -namespace QtMultimediaKitInternal -{ -class QAudioOutputBuffer; -} - -class QAudioOutputPrivate : public QAbstractAudioOutput -{ - Q_OBJECT - -public: - bool isOpen; - int internalBufferSize; - int periodSizeBytes; - qint64 totalFrames; - QAudioFormat audioFormat; - QIODevice* audioIO; - AudioDeviceID audioDeviceId; - AudioUnit audioUnit; - Float64 clockFrequency; - UInt64 startTime; - AudioStreamBasicDescription deviceFormat; - AudioStreamBasicDescription streamFormat; - QtMultimediaKitInternal::QAudioOutputBuffer* audioBuffer; - QAtomicInt audioThreadState; - QWaitCondition threadFinished; - QMutex mutex; - QTimer* intervalTimer; - QAbstractAudioDeviceInfo *audioDeviceInfo; - - QAudio::Error errorCode; - QAudio::State stateCode; - - QAudioOutputPrivate(const QByteArray& device); - ~QAudioOutputPrivate(); - - bool open(); - void close(); - - QAudioFormat format() const; - void setFormat(const QAudioFormat& fmt); - - QIODevice* start(); - void start(QIODevice* device); - void stop(); - void reset(); - void suspend(); - void resume(); - - int bytesFree() const; - int periodSize() const; - - void setBufferSize(int value); - int bufferSize() const; - - void setNotifyInterval(int milliSeconds); - int notifyInterval() const; - - qint64 processedUSecs() const; - qint64 elapsedUSecs() const; - - QAudio::Error error() const; - QAudio::State state() const; - - void audioThreadStart(); - void audioThreadStop(); - void audioThreadDrain(); - - void audioDeviceStop(); - void audioDeviceIdle(); - void audioDeviceError(); - - void startTimers(); - void stopTimers(); - -private slots: - void deviceStopped(); - void inputReady(); - -private: - enum { Running, Draining, Stopped }; - - static OSStatus renderCallback(void* inRefCon, - AudioUnitRenderActionFlags* ioActionFlags, - const AudioTimeStamp* inTimeStamp, - UInt32 inBusNumber, - UInt32 inNumberFrames, - AudioBufferList* ioData); -}; - -QT_END_NAMESPACE - -QT_END_HEADER - -#endif diff --git a/src/multimediakit/audio/qaudiooutput_win32_p.cpp b/src/multimediakit/audio/qaudiooutput_win32_p.cpp deleted file mode 100644 index d5b31a30f..000000000 --- a/src/multimediakit/audio/qaudiooutput_win32_p.cpp +++ /dev/null @@ -1,715 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -// -// W A R N I N G -// ------------- -// -// This file is not part of the Qt API. It exists for the convenience -// of other Qt classes. This header file may change from version to -// version without notice, or even be removed. -// -// INTERNAL USE ONLY: Do NOT use for any other purpose. -// - -#include "qaudiooutput_win32_p.h" - -#ifndef SPEAKER_FRONT_LEFT - #define SPEAKER_FRONT_LEFT 0x00000001 - #define SPEAKER_FRONT_RIGHT 0x00000002 - #define SPEAKER_FRONT_CENTER 0x00000004 - #define SPEAKER_LOW_FREQUENCY 0x00000008 - #define SPEAKER_BACK_LEFT 0x00000010 - #define SPEAKER_BACK_RIGHT 0x00000020 - #define SPEAKER_FRONT_LEFT_OF_CENTER 0x00000040 - #define SPEAKER_FRONT_RIGHT_OF_CENTER 0x00000080 - #define SPEAKER_BACK_CENTER 0x00000100 - #define SPEAKER_SIDE_LEFT 0x00000200 - #define SPEAKER_SIDE_RIGHT 0x00000400 - #define SPEAKER_TOP_CENTER 0x00000800 - #define SPEAKER_TOP_FRONT_LEFT 0x00001000 - #define SPEAKER_TOP_FRONT_CENTER 0x00002000 - #define SPEAKER_TOP_FRONT_RIGHT 0x00004000 - #define SPEAKER_TOP_BACK_LEFT 0x00008000 - #define SPEAKER_TOP_BACK_CENTER 0x00010000 - #define SPEAKER_TOP_BACK_RIGHT 0x00020000 - #define SPEAKER_RESERVED 0x7FFC0000 - #define SPEAKER_ALL 0x80000000 -#endif - -#ifndef _WAVEFORMATEXTENSIBLE_ - - #define _WAVEFORMATEXTENSIBLE_ - typedef struct - { - WAVEFORMATEX Format; // Base WAVEFORMATEX data - union - { - WORD wValidBitsPerSample; // Valid bits in each sample container - WORD wSamplesPerBlock; // Samples per block of audio data; valid - // if wBitsPerSample=0 (but rarely used). - WORD wReserved; // Zero if neither case above applies. - } Samples; - DWORD dwChannelMask; // Positions of the audio channels - GUID SubFormat; // Format identifier GUID - } WAVEFORMATEXTENSIBLE, *PWAVEFORMATEXTENSIBLE, *LPPWAVEFORMATEXTENSIBLE; - typedef const WAVEFORMATEXTENSIBLE* LPCWAVEFORMATEXTENSIBLE; - -#endif - -#if !defined(WAVE_FORMAT_EXTENSIBLE) -#define WAVE_FORMAT_EXTENSIBLE 0xFFFE -#endif - -//#define DEBUG_AUDIO 1 - -QT_BEGIN_NAMESPACE - -QAudioOutputPrivate::QAudioOutputPrivate(const QByteArray &device) -{ - bytesAvailable = 0; - buffer_size = 0; - period_size = 0; - m_device = device; - totalTimeValue = 0; - intervalTime = 1000; - audioBuffer = 0; - errorState = QAudio::NoError; - deviceState = QAudio::StoppedState; - audioSource = 0; - pullMode = true; - finished = false; -} - -QAudioOutputPrivate::~QAudioOutputPrivate() -{ - mutex.lock(); - finished = true; - mutex.unlock(); - - close(); -} - -void CALLBACK QAudioOutputPrivate::waveOutProc( HWAVEOUT hWaveOut, UINT uMsg, - DWORD dwInstance, DWORD dwParam1, DWORD dwParam2 ) -{ - Q_UNUSED(dwParam1) - Q_UNUSED(dwParam2) - Q_UNUSED(hWaveOut) - - QAudioOutputPrivate* qAudio; - qAudio = (QAudioOutputPrivate*)(dwInstance); - if(!qAudio) - return; - - QMutexLocker(&qAudio->mutex); - - switch(uMsg) { - case WOM_OPEN: - qAudio->feedback(); - break; - case WOM_CLOSE: - return; - case WOM_DONE: - if(qAudio->finished || qAudio->buffer_size == 0 || qAudio->period_size == 0) { - return; - } - qAudio->waveFreeBlockCount++; - if(qAudio->waveFreeBlockCount >= qAudio->buffer_size/qAudio->period_size) - qAudio->waveFreeBlockCount = qAudio->buffer_size/qAudio->period_size; - qAudio->feedback(); - break; - default: - return; - } -} - -WAVEHDR* QAudioOutputPrivate::allocateBlocks(int size, int count) -{ - int i; - unsigned char* buffer; - WAVEHDR* blocks; - DWORD totalBufferSize = (size + sizeof(WAVEHDR))*count; - - if((buffer=(unsigned char*)HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY, - totalBufferSize)) == 0) { - qWarning("QAudioOutput: Memory allocation error"); - return 0; - } - blocks = (WAVEHDR*)buffer; - buffer += sizeof(WAVEHDR)*count; - for(i = 0; i < count; i++) { - blocks[i].dwBufferLength = size; - blocks[i].lpData = (LPSTR)buffer; - buffer += size; - } - return blocks; -} - -void QAudioOutputPrivate::freeBlocks(WAVEHDR* blockArray) -{ - WAVEHDR* blocks = blockArray; - - int count = buffer_size/period_size; - - for(int i = 0; i < count; i++) { - waveOutUnprepareHeader(hWaveOut,blocks, sizeof(WAVEHDR)); - blocks++; - } - HeapFree(GetProcessHeap(), 0, blockArray); -} - -QAudioFormat QAudioOutputPrivate::format() const -{ - return settings; -} - -void QAudioOutputPrivate::setFormat(const QAudioFormat& fmt) -{ - if (deviceState == QAudio::StoppedState) - settings = fmt; -} - -void QAudioOutputPrivate::start(QIODevice* device) -{ - if(deviceState != QAudio::StoppedState) - close(); - - if(!pullMode && audioSource) - delete audioSource; - - pullMode = true; - audioSource = device; - - deviceState = QAudio::ActiveState; - - if(!open()) - return; - - emit stateChanged(deviceState); -} - -QIODevice* QAudioOutputPrivate::start() -{ - if(deviceState != QAudio::StoppedState) - close(); - - if(!pullMode && audioSource) - delete audioSource; - - pullMode = false; - audioSource = new OutputPrivate(this); - audioSource->open(QIODevice::WriteOnly|QIODevice::Unbuffered); - - deviceState = QAudio::IdleState; - - if(!open()) - return 0; - - emit stateChanged(deviceState); - - return audioSource; -} - -void QAudioOutputPrivate::stop() -{ - if(deviceState == QAudio::StoppedState) - return; - close(); - if(!pullMode && audioSource) { - delete audioSource; - audioSource = 0; - } - emit stateChanged(deviceState); -} - -bool QAudioOutputPrivate::open() -{ -#ifdef DEBUG_AUDIO - QTime now(QTime::currentTime()); - qDebug()< 96000) { - qWarning("QAudioOutput: open error, frequency out of range (%d).", settings.frequency()); - } else if (buffer_size == 0) { - // Default buffer size, 200ms, default period size is 40ms - buffer_size - = (settings.frequency() - * settings.channelCount() - * settings.sampleSize() - + 39) / 40; - period_size = buffer_size / 5; - } else { - period_size = buffer_size / 5; - } - - if (period_size == 0) { - errorState = QAudio::OpenError; - deviceState = QAudio::StoppedState; - emit stateChanged(deviceState); - return false; - } - - waveBlocks = allocateBlocks(period_size, buffer_size/period_size); - - mutex.lock(); - waveFreeBlockCount = buffer_size/period_size; - mutex.unlock(); - - waveCurrentBlock = 0; - - if(audioBuffer == 0) - audioBuffer = new char[buffer_size]; - - timeStamp.restart(); - elapsedTimeOffset = 0; - - wfx.nSamplesPerSec = settings.frequency(); - wfx.wBitsPerSample = settings.sampleSize(); - wfx.nChannels = settings.channels(); - wfx.cbSize = 0; - - bool surround = false; - - if (settings.channels() > 2) - surround = true; - - wfx.wFormatTag = WAVE_FORMAT_PCM; - wfx.nBlockAlign = (wfx.wBitsPerSample >> 3) * wfx.nChannels; - wfx.nAvgBytesPerSec = wfx.nBlockAlign * wfx.nSamplesPerSec; - - QDataStream ds(&m_device, QIODevice::ReadOnly); - quint32 deviceId; - ds >> deviceId; - - if (!surround) { - if (waveOutOpen(&hWaveOut, UINT_PTR(deviceId), &wfx, - (DWORD_PTR)&waveOutProc, - (DWORD_PTR) this, - CALLBACK_FUNCTION) != MMSYSERR_NOERROR) { - errorState = QAudio::OpenError; - deviceState = QAudio::StoppedState; - emit stateChanged(deviceState); - qWarning("QAudioOutput: open error"); - return false; - } - } else { - WAVEFORMATEXTENSIBLE wfex; - wfex.Format.wFormatTag = WAVE_FORMAT_EXTENSIBLE; - wfex.Format.nChannels = settings.channels(); - wfex.Format.wBitsPerSample = settings.sampleSize(); - wfex.Format.nSamplesPerSec = settings.frequency(); - wfex.Format.nBlockAlign = wfex.Format.nChannels*wfex.Format.wBitsPerSample/8; - wfex.Format.nAvgBytesPerSec=wfex.Format.nSamplesPerSec*wfex.Format.nBlockAlign; - wfex.Samples.wValidBitsPerSample=wfex.Format.wBitsPerSample; - static const GUID _KSDATAFORMAT_SUBTYPE_PCM = { - 0x00000001, 0x0000, 0x0010, {0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}}; - wfex.SubFormat=_KSDATAFORMAT_SUBTYPE_PCM; - wfex.Format.cbSize=22; - - wfex.dwChannelMask = SPEAKER_FRONT_LEFT | SPEAKER_FRONT_RIGHT; - if (settings.channels() >= 4) - wfex.dwChannelMask |= SPEAKER_BACK_LEFT | SPEAKER_BACK_RIGHT; - if (settings.channels() >= 6) - wfex.dwChannelMask |= SPEAKER_FRONT_CENTER | SPEAKER_LOW_FREQUENCY; - if (settings.channels() == 8) - wfex.dwChannelMask |= SPEAKER_SIDE_LEFT | SPEAKER_SIDE_RIGHT; - - if (waveOutOpen(&hWaveOut, UINT_PTR(deviceId), &wfex.Format, - (DWORD_PTR)&waveOutProc, - (DWORD_PTR) this, - CALLBACK_FUNCTION) != MMSYSERR_NOERROR) { - errorState = QAudio::OpenError; - deviceState = QAudio::StoppedState; - emit stateChanged(deviceState); - qWarning("QAudioOutput: open error"); - return false; - } - } - - totalTimeValue = 0; - timeStampOpened.restart(); - elapsedTimeOffset = 0; - - errorState = QAudio::NoError; - if(pullMode) { - deviceState = QAudio::ActiveState; - QTimer::singleShot(10, this, SLOT(feedback())); - } else - deviceState = QAudio::IdleState; - - return true; -} - -void QAudioOutputPrivate::close() -{ - if(deviceState == QAudio::StoppedState) - return; - - deviceState = QAudio::StoppedState; - errorState = QAudio::NoError; - int delay = (buffer_size-bytesFree())*1000/(settings.frequency() - *settings.channels()*(settings.sampleSize()/8)); - waveOutReset(hWaveOut); - Sleep(delay+10); - - freeBlocks(waveBlocks); - waveOutClose(hWaveOut); - delete [] audioBuffer; - audioBuffer = 0; - buffer_size = 0; -} - -int QAudioOutputPrivate::bytesFree() const -{ - int buf; - buf = waveFreeBlockCount*period_size; - - return buf; -} - -int QAudioOutputPrivate::periodSize() const -{ - return period_size; -} - -void QAudioOutputPrivate::setBufferSize(int value) -{ - if(deviceState == QAudio::StoppedState) - buffer_size = value; -} - -int QAudioOutputPrivate::bufferSize() const -{ - return buffer_size; -} - -void QAudioOutputPrivate::setNotifyInterval(int ms) -{ - intervalTime = qMax(0, ms); -} - -int QAudioOutputPrivate::notifyInterval() const -{ - return intervalTime; -} - -qint64 QAudioOutputPrivate::processedUSecs() const -{ - if (deviceState == QAudio::StoppedState) - return 0; - qint64 result = qint64(1000000) * totalTimeValue / - (settings.channels()*(settings.sampleSize()/8)) / - settings.frequency(); - - return result; -} - -qint64 QAudioOutputPrivate::write( const char *data, qint64 len ) -{ - // Write out some audio data - if (deviceState != QAudio::ActiveState && deviceState != QAudio::IdleState) - return 0; - - char* p = (char*)data; - int l = (int)len; - - WAVEHDR* current; - int remain; - current = &waveBlocks[waveCurrentBlock]; - while(l > 0) { - mutex.lock(); - if(waveFreeBlockCount==0) { - mutex.unlock(); - break; - } - mutex.unlock(); - - if(current->dwFlags & WHDR_PREPARED) - waveOutUnprepareHeader(hWaveOut, current, sizeof(WAVEHDR)); - - if(l < period_size) - remain = l; - else - remain = period_size; - memcpy(current->lpData, p, remain); - - l -= remain; - p += remain; - current->dwBufferLength = remain; - waveOutPrepareHeader(hWaveOut, current, sizeof(WAVEHDR)); - waveOutWrite(hWaveOut, current, sizeof(WAVEHDR)); - - mutex.lock(); - waveFreeBlockCount--; -#ifdef DEBUG_AUDIO - qDebug("write out l=%d, waveFreeBlockCount=%d", - current->dwBufferLength,waveFreeBlockCount); -#endif - mutex.unlock(); - - totalTimeValue += current->dwBufferLength; - waveCurrentBlock++; - waveCurrentBlock %= buffer_size/period_size; - current = &waveBlocks[waveCurrentBlock]; - current->dwUser = 0; - errorState = QAudio::NoError; - if (deviceState != QAudio::ActiveState) { - deviceState = QAudio::ActiveState; - emit stateChanged(deviceState); - } - } - return (len-l); -} - -void QAudioOutputPrivate::resume() -{ - if(deviceState == QAudio::SuspendedState) { - deviceState = QAudio::ActiveState; - errorState = QAudio::NoError; - waveOutRestart(hWaveOut); - QTimer::singleShot(10, this, SLOT(feedback())); - emit stateChanged(deviceState); - } -} - -void QAudioOutputPrivate::suspend() -{ - if(deviceState == QAudio::ActiveState || deviceState == QAudio::IdleState) { - int delay = (buffer_size-bytesFree())*1000/(settings.frequency() - *settings.channels()*(settings.sampleSize()/8)); - waveOutPause(hWaveOut); - Sleep(delay+10); - deviceState = QAudio::SuspendedState; - errorState = QAudio::NoError; - emit stateChanged(deviceState); - } -} - -void QAudioOutputPrivate::feedback() -{ -#ifdef DEBUG_AUDIO - QTime now(QTime::currentTime()); - qDebug()<= period_size) - QMetaObject::invokeMethod(this, "deviceReady", Qt::QueuedConnection); - } -} - -bool QAudioOutputPrivate::deviceReady() -{ - if(deviceState == QAudio::StoppedState || deviceState == QAudio::SuspendedState) - return false; - - if(pullMode) { - int chunks = bytesAvailable/period_size; -#ifdef DEBUG_AUDIO - qDebug()<<"deviceReady() avail="< intervalTime ) { - emit notify(); - elapsedTimeOffset = timeStamp.elapsed() + elapsedTimeOffset - intervalTime; - timeStamp.restart(); - } - return true; - } - - if(startup) - waveOutPause(hWaveOut); - int input = period_size*chunks; - int l = audioSource->read(audioBuffer,input); - if(l > 0) { - int out= write(audioBuffer,l); - if(out > 0) { - if (deviceState != QAudio::ActiveState) { - deviceState = QAudio::ActiveState; - emit stateChanged(deviceState); - } - } - if ( out < l) { - // Didn't write all data - audioSource->seek(audioSource->pos()-(l-out)); - } - if(startup) - waveOutRestart(hWaveOut); - } else if(l == 0) { - bytesAvailable = bytesFree(); - - int check = 0; - - mutex.lock(); - check = waveFreeBlockCount; - mutex.unlock(); - - if(check == buffer_size/period_size) { - if (deviceState != QAudio::IdleState) { - errorState = QAudio::UnderrunError; - deviceState = QAudio::IdleState; - emit stateChanged(deviceState); - } - } - - } else if(l < 0) { - bytesAvailable = bytesFree(); - if (errorState != QAudio::IOError) - errorState = QAudio::IOError; - } - } else { - int buffered; - - mutex.lock(); - buffered = waveFreeBlockCount; - mutex.unlock(); - - if (buffered >= buffer_size/period_size && deviceState == QAudio::ActiveState) { - if (deviceState != QAudio::IdleState) { - errorState = QAudio::UnderrunError; - deviceState = QAudio::IdleState; - emit stateChanged(deviceState); - } - } - } - if(deviceState != QAudio::ActiveState && deviceState != QAudio::IdleState) - return true; - - if(intervalTime && (timeStamp.elapsed() + elapsedTimeOffset) > intervalTime) { - emit notify(); - elapsedTimeOffset = timeStamp.elapsed() + elapsedTimeOffset - intervalTime; - timeStamp.restart(); - } - - return true; -} - -qint64 QAudioOutputPrivate::elapsedUSecs() const -{ - if (deviceState == QAudio::StoppedState) - return 0; - - return timeStampOpened.elapsed()*1000; -} - -QAudio::Error QAudioOutputPrivate::error() const -{ - return errorState; -} - -QAudio::State QAudioOutputPrivate::state() const -{ - return deviceState; -} - -void QAudioOutputPrivate::reset() -{ - close(); -} - -OutputPrivate::OutputPrivate(QAudioOutputPrivate* audio) -{ - audioDevice = qobject_cast(audio); -} - -OutputPrivate::~OutputPrivate() {} - -qint64 OutputPrivate::readData( char* data, qint64 len) -{ - Q_UNUSED(data) - Q_UNUSED(len) - - return 0; -} - -qint64 OutputPrivate::writeData(const char* data, qint64 len) -{ - int retry = 0; - qint64 written = 0; - - if((audioDevice->deviceState == QAudio::ActiveState) - ||(audioDevice->deviceState == QAudio::IdleState)) { - qint64 l = len; - while(written < l) { - int chunk = audioDevice->write(data+written,(l-written)); - if(chunk <= 0) - retry++; - else - written+=chunk; - - if(retry > 10) - return written; - } - audioDevice->deviceState = QAudio::ActiveState; - } - return written; -} - -QT_END_NAMESPACE - -#include "moc_qaudiooutput_win32_p.cpp" diff --git a/src/multimediakit/audio/qaudiooutput_win32_p.h b/src/multimediakit/audio/qaudiooutput_win32_p.h deleted file mode 100644 index aa86d4e9b..000000000 --- a/src/multimediakit/audio/qaudiooutput_win32_p.h +++ /dev/null @@ -1,175 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -// -// W A R N I N G -// ------------- -// -// This file is not part of the Qt API. It exists for the convenience -// of other Qt classes. This header file may change from version to -// version without notice, or even be removed. -// -// We mean it. -// - -#ifndef QAUDIOOUTPUTWIN_H -#define QAUDIOOUTPUTWIN_H - -#include -#include - -#include -#include -#include -#include -#include -#include - -#include -#include -#include - -// For compat with 4.6 -#if !defined(QT_WIN_CALLBACK) -# if defined(Q_CC_MINGW) -# define QT_WIN_CALLBACK CALLBACK __attribute__ ((force_align_arg_pointer)) -# else -# define QT_WIN_CALLBACK CALLBACK -# endif -#endif - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -QT_MODULE(Multimedia) - - -class QAudioOutputPrivate : public QAbstractAudioOutput -{ - Q_OBJECT -public: - QAudioOutputPrivate(const QByteArray &device); - ~QAudioOutputPrivate(); - - qint64 write( const char *data, qint64 len ); - - void setFormat(const QAudioFormat& fmt); - QAudioFormat format() const; - QIODevice* start(); - void start(QIODevice* device); - void stop(); - void reset(); - void suspend(); - void resume(); - int bytesFree() const; - int periodSize() const; - void setBufferSize(int value); - int bufferSize() const; - void setNotifyInterval(int milliSeconds); - int notifyInterval() const; - qint64 processedUSecs() const; - qint64 elapsedUSecs() const; - QAudio::Error error() const; - QAudio::State state() const; - - QIODevice* audioSource; - QAudioFormat settings; - QAudio::Error errorState; - QAudio::State deviceState; - -private slots: - void feedback(); - bool deviceReady(); - -private: - QByteArray m_device; - bool resuming; - int bytesAvailable; - QTime timeStamp; - qint64 elapsedTimeOffset; - QTime timeStampOpened; - qint32 buffer_size; - qint32 period_size; - qint64 totalTimeValue; - bool pullMode; - int intervalTime; - static void QT_WIN_CALLBACK waveOutProc( HWAVEOUT hWaveOut, UINT uMsg, - DWORD dwInstance, DWORD dwParam1, DWORD dwParam2 ); - - QMutex mutex; - - WAVEHDR* allocateBlocks(int size, int count); - void freeBlocks(WAVEHDR* blockArray); - bool open(); - void close(); - - WAVEFORMATEX wfx; - HWAVEOUT hWaveOut; - MMRESULT result; - WAVEHDR header; - WAVEHDR* waveBlocks; - volatile bool finished; - volatile int waveFreeBlockCount; - int waveCurrentBlock; - char* audioBuffer; -}; - -class OutputPrivate : public QIODevice -{ - Q_OBJECT -public: - OutputPrivate(QAudioOutputPrivate* audio); - ~OutputPrivate(); - - qint64 readData( char* data, qint64 len); - qint64 writeData(const char* data, qint64 len); - -private: - QAudioOutputPrivate *audioDevice; -}; - -QT_END_NAMESPACE - -QT_END_HEADER - - -#endif diff --git a/src/multimediakit/audio/qaudiopluginloader.cpp b/src/multimediakit/audio/qaudiopluginloader.cpp deleted file mode 100644 index 58006356a..000000000 --- a/src/multimediakit/audio/qaudiopluginloader.cpp +++ /dev/null @@ -1,176 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qaudiosystemplugin.h" -#include "qaudiopluginloader_p.h" - -#include -#include -#include -#include -#include - -QT_BEGIN_NAMESPACE - -QAudioPluginLoader::QAudioPluginLoader(const char *iid, const QString &location, Qt::CaseSensitivity): - m_iid(iid) -{ - m_location = location + QLatin1Char('/'); - load(); -} - -QAudioPluginLoader::~QAudioPluginLoader() -{ - for (int i = 0; i < m_plugins.count(); i++ ) { - delete m_plugins.at(i); - } -} - -QStringList QAudioPluginLoader::pluginList() const -{ -#if !defined QT_NO_DEBUG - const bool showDebug = qgetenv("QT_DEBUG_PLUGINS").toInt() > 0; -#endif - - QStringList paths = QCoreApplication::libraryPaths(); -#ifdef QTM_PLUGIN_PATH - paths << QLatin1String(QTM_PLUGIN_PATH); -#endif -#if !defined QT_NO_DEBUG - if (showDebug) - qDebug() << "Plugin paths:" << paths; -#endif - - //temp variable to avoid multiple identic path - QSet processed; - - /* Discover a bunch o plugins */ - QStringList plugins; - - /* Enumerate our plugin paths */ - for (int i=0; i < paths.count(); i++) { - if (processed.contains(paths.at(i))) - continue; - processed.insert(paths.at(i)); - QDir pluginsDir(paths.at(i)+m_location); - if (!pluginsDir.exists()) - continue; - - QStringList files = pluginsDir.entryList(QDir::Files); -#if !defined QT_NO_DEBUG - if (showDebug) - qDebug()<<"Looking for plugins in "<(&m_mutex)); - - QStringList list; - for (int i = 0; i < m_plugins.count(); i++) { - QAudioSystemPlugin* p = qobject_cast(m_plugins.at(i)->instance()); - if (p) list << p->keys(); - } - - return list; -} - -QObject* QAudioPluginLoader::instance(QString const &key) -{ - QMutexLocker locker(&m_mutex); - - for (int i = 0; i < m_plugins.count(); i++) { - QAudioSystemPlugin* p = qobject_cast(m_plugins.at(i)->instance()); - if (p && p->keys().contains(key)) - return m_plugins.at(i)->instance(); - } - return 0; -} - -QList QAudioPluginLoader::instances(QString const &key) -{ - QMutexLocker locker(&m_mutex); - - QList list; - for (int i = 0; i < m_plugins.count(); i++) { - QAudioSystemPlugin* p = qobject_cast(m_plugins.at(i)->instance()); - if (p && p->keys().contains(key)) - list << m_plugins.at(i)->instance(); - } - return list; -} - -void QAudioPluginLoader::load() -{ - if (!m_plugins.isEmpty()) - return; - -#if !defined QT_NO_DEBUG - const bool showDebug = qgetenv("QT_DEBUG_PLUGINS").toInt() > 0; -#endif - - QStringList plugins = pluginList(); - for (int i=0; i < plugins.count(); i++) { - QPluginLoader* loader = new QPluginLoader(plugins.at(i)); - QObject *o = loader->instance(); - if (o != 0 && o->qt_metacast(m_iid) != 0) { - m_plugins.append(loader); - } else { -#if !defined QT_NO_DEBUG - if (showDebug) - qWarning() << "QAudioPluginLoader: Failed to load plugin: " - << plugins.at(i) << loader->errorString(); -#endif - delete o; - //we are not calling loader->unload here for it may cause problem on some device - delete loader; - } - } -} -QT_END_NAMESPACE - diff --git a/src/multimediakit/audio/qaudiopluginloader_p.h b/src/multimediakit/audio/qaudiopluginloader_p.h deleted file mode 100644 index a0f130fd1..000000000 --- a/src/multimediakit/audio/qaudiopluginloader_p.h +++ /dev/null @@ -1,100 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QAUDIOPLUGINLOADER_H -#define QAUDIOPLUGINLOADER_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 -#include -#include -#include -#include -#include - - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -QT_MODULE(Multimedia) - - -class QAudioPluginLoader -{ -public: - QAudioPluginLoader(const char *iid, - const QString &suffix = QString(), - Qt::CaseSensitivity = Qt::CaseSensitive); - - ~QAudioPluginLoader(); - - QStringList keys() const; - QObject* instance(QString const &key); - QList instances(QString const &key); - -private: - QStringList pluginList() const; - void load(); - - QMutex m_mutex; - - QByteArray m_iid; - QString m_location; - QList m_plugins; -}; - -QT_END_NAMESPACE - -QT_END_HEADER - - -#endif // QAUDIOPLUGINLOADER_H diff --git a/src/multimediakit/audio/qaudiosystem.cpp b/src/multimediakit/audio/qaudiosystem.cpp deleted file mode 100644 index 0c0475e1c..000000000 --- a/src/multimediakit/audio/qaudiosystem.cpp +++ /dev/null @@ -1,436 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qaudiosystem.h" - -QT_BEGIN_NAMESPACE - -/*! - \class QAbstractAudioDeviceInfo - \brief The QAbstractAudioDeviceInfo class is a base class for audio backends. - - \ingroup multimedia - \inmodule QtMultimediaKit - \internal - \since 1.0 - - This class implements the audio functionality for - QAudioDeviceInfo, i.e., QAudioDeviceInfo keeps a - QAbstractAudioDeviceInfo and routes function calls to it. For a - description of the functionality that QAbstractAudioDeviceInfo - implements, you can read the class and functions documentation of - QAudioDeviceInfo. - - \sa QAudioDeviceInfo - \sa QAbstractAudioOutput, QAbstractAudioInput -*/ - -/*! - \fn virtual QAudioFormat QAbstractAudioDeviceInfo::preferredFormat() const - Returns the recommended settings to use. - \since 1.0 -*/ - -/*! - \fn virtual bool QAbstractAudioDeviceInfo::isFormatSupported(const QAudioFormat& format) const - Returns true if \a format is available from audio device. - \since 1.0 -*/ - -/*! - \fn virtual QString QAbstractAudioDeviceInfo::deviceName() const - Returns the audio device name. - \since 1.0 -*/ - -/*! - \fn virtual QStringList QAbstractAudioDeviceInfo::supportedCodecs() - Returns the list of currently available codecs. - \since 1.0 -*/ - -/*! - \fn virtual QList QAbstractAudioDeviceInfo::supportedSampleRates() - Returns the list of currently available sample rates. - \since 1.0 -*/ - -/*! - \fn virtual QList QAbstractAudioDeviceInfo::supportedChannelCounts() - Returns the list of currently available channels. - \since 1.0 -*/ - -/*! - \fn virtual QList QAbstractAudioDeviceInfo::supportedSampleSizes() - Returns the list of currently available sample sizes. - \since 1.0 -*/ - -/*! - \fn virtual QList QAbstractAudioDeviceInfo::supportedByteOrders() - Returns the list of currently available byte orders. - \since 1.0 -*/ - -/*! - \fn virtual QList QAbstractAudioDeviceInfo::supportedSampleTypes() - Returns the list of currently available sample types. - \since 1.0 -*/ - -/*! - \class QAbstractAudioOutput - \brief The QAbstractAudioOutput class is a base class for audio backends. - \since 1.0 - - \ingroup multimedia - \inmodule QtMultimediaKit - \internal - - QAbstractAudioOutput implements audio functionality for - QAudioOutput, i.e., QAudioOutput routes function calls to - QAbstractAudioOutput. For a description of the functionality that - is implemented, see the QAudioOutput class and function - descriptions. - - \sa QAudioOutput -*/ - -/*! - \fn virtual void QAbstractAudioOutput::start(QIODevice* device) - Uses the \a device as the QIODevice to transfer data. - \since 1.0 -*/ - -/*! - \fn virtual QIODevice* QAbstractAudioOutput::start() - Returns a pointer to the QIODevice being used to handle - the data transfer. This QIODevice can be used to write() audio data directly. - \since 1.0 -*/ - -/*! - \fn virtual void QAbstractAudioOutput::stop() - Stops the audio output. - \since 1.0 -*/ - -/*! - \fn virtual void QAbstractAudioOutput::reset() - Drops all audio data in the buffers, resets buffers to zero. - \since 1.0 -*/ - -/*! - \fn virtual void QAbstractAudioOutput::suspend() - Stops processing audio data, preserving buffered audio data. - \since 1.0 -*/ - -/*! - \fn virtual void QAbstractAudioOutput::resume() - Resumes processing audio data after a suspend() - \since 1.0 -*/ - -/*! - \fn virtual int QAbstractAudioOutput::bytesFree() const - Returns the free space available in bytes in the audio buffer. - \since 1.0 -*/ - -/*! - \fn virtual int QAbstractAudioOutput::periodSize() const - Returns the period size in bytes. - \since 1.0 -*/ - -/*! - \fn virtual void QAbstractAudioOutput::setBufferSize(int value) - Sets the audio buffer size to \a value in bytes. - \since 1.0 -*/ - -/*! - \fn virtual int QAbstractAudioOutput::bufferSize() const - Returns the audio buffer size in bytes. - \since 1.0 -*/ - -/*! - \fn virtual void QAbstractAudioOutput::setNotifyInterval(int ms) - Sets the interval for notify() signal to be emitted. This is based on the \a ms - of audio data processed not on actual real-time. The resolution of the timer - is platform specific. - \since 1.0 -*/ - -/*! - \fn virtual int QAbstractAudioOutput::notifyInterval() const - Returns the notify interval in milliseconds. - \since 1.0 -*/ - -/*! - \fn virtual qint64 QAbstractAudioOutput::processedUSecs() const - Returns the amount of audio data processed since start() was called in milliseconds. - \since 1.0 -*/ - -/*! - \fn virtual qint64 QAbstractAudioOutput::elapsedUSecs() const - Returns the milliseconds since start() was called, including time in Idle and suspend states. - \since 1.0 -*/ - -/*! - \fn virtual QAudio::Error QAbstractAudioOutput::error() const - Returns the error state. - \since 1.0 -*/ - -/*! - \fn virtual QAudio::State QAbstractAudioOutput::state() const - Returns the state of audio processing. - \since 1.0 -*/ - -/*! - \fn virtual void QAbstractAudioOutput::setFormat(const QAudioFormat& fmt) - Set the QAudioFormat to use to \a fmt. - Setting the format is only allowable while in QAudio::StoppedState. - \since 1.0 -*/ - -/*! - \fn virtual QAudioFormat QAbstractAudioOutput::format() const - Returns the QAudioFormat being used. - \since 1.0 -*/ - -/*! - \fn virtual void QAbstractAudioOutput::setVolume(qreal volume) - Sets the volume. - Where \a volume is between 0.0 and 1.0. - \since 5.0 -*/ - -/*! - \fn virtual qreal QAbstractAudioOutput::volume() const - Returns the volume in the range 0.0 and 1.0. - \since 5.0 -*/ - -/*! - \fn QAbstractAudioOutput::errorChanged(QAudio::Error error) - This signal is emitted when the \a error state has changed. - \since 1.0 -*/ - -/*! - \fn QAbstractAudioOutput::stateChanged(QAudio::State state) - This signal is emitted when the device \a state has changed. - \since 1.0 -*/ - -/*! - \fn QAbstractAudioOutput::notify() - This signal is emitted when x ms of audio data has been processed - the interval set by setNotifyInterval(x). - \since 1.0 -*/ - - -/*! - \class QAbstractAudioInput - \brief The QAbstractAudioInput class provides access for QAudioInput to access the audio - device provided by the plugin. - \since 1.0 - - \ingroup multimedia - \inmodule QtMultimediaKit - \internal - - QAudioDeviceInput keeps an instance of QAbstractAudioInput and - routes calls to functions of the same name to QAbstractAudioInput. - This means that it is QAbstractAudioInput that implements the - audio functionality. For a description of the functionality, see - the QAudioInput class description. - - \sa QAudioInput -*/ - -/*! - \fn virtual void QAbstractAudioInput::start(QIODevice* device) - Uses the \a device as the QIODevice to transfer data. - \since 1.0 -*/ - -/*! - \fn virtual QIODevice* QAbstractAudioInput::start() - Returns a pointer to the QIODevice being used to handle - the data transfer. This QIODevice can be used to read() audio data directly. - \since 1.0 -*/ - -/*! - \fn virtual void QAbstractAudioInput::stop() - Stops the audio input. - \since 1.0 -*/ - -/*! - \fn virtual void QAbstractAudioInput::reset() - Drops all audio data in the buffers, resets buffers to zero. - \since 1.0 -*/ - -/*! - \fn virtual void QAbstractAudioInput::suspend() - Stops processing audio data, preserving buffered audio data. - \since 1.0 -*/ - -/*! - \fn virtual void QAbstractAudioInput::resume() - Resumes processing audio data after a suspend(). - \since 1.0 -*/ - -/*! - \fn virtual int QAbstractAudioInput::bytesReady() const - Returns the amount of audio data available to read in bytes. - \since 1.0 -*/ - -/*! - \fn virtual int QAbstractAudioInput::periodSize() const - Returns the period size in bytes. - \since 1.0 -*/ - -/*! - \fn virtual void QAbstractAudioInput::setBufferSize(int value) - Sets the audio buffer size to \a value in milliseconds. - \since 1.0 -*/ - -/*! - \fn virtual int QAbstractAudioInput::bufferSize() const - Returns the audio buffer size in milliseconds. - \since 1.0 -*/ - -/*! - \fn virtual void QAbstractAudioInput::setNotifyInterval(int ms) - Sets the interval for notify() signal to be emitted. This is based - on the \a ms of audio data processed not on actual real-time. - The resolution of the timer is platform specific. - \since 1.0 -*/ - -/*! - \fn virtual int QAbstractAudioInput::notifyInterval() const - Returns the notify interval in milliseconds. - \since 1.0 -*/ - -/*! - \fn virtual qint64 QAbstractAudioInput::processedUSecs() const - Returns the amount of audio data processed since start() was called in milliseconds. - \since 1.0 -*/ - -/*! - \fn virtual qint64 QAbstractAudioInput::elapsedUSecs() const - Returns the milliseconds since start() was called, including time in Idle and suspend states. - \since 1.0 -*/ - -/*! - \fn virtual QAudio::Error QAbstractAudioInput::error() const - Returns the error state. - \since 1.0 -*/ - -/*! - \fn virtual QAudio::State QAbstractAudioInput::state() const - Returns the state of audio processing. - \since 1.0 -*/ - -/*! - \fn virtual void QAbstractAudioInput::setFormat(const QAudioFormat& fmt) - Set the QAudioFormat to use to \a fmt. - Setting the format is only allowable while in QAudio::StoppedState. - \since 1.0 -*/ - -/*! - \fn virtual QAudioFormat QAbstractAudioInput::format() const - Returns the QAudioFormat being used - \since 1.0 -*/ - -/*! - \fn QAbstractAudioInput::errorChanged(QAudio::Error error) - This signal is emitted when the \a error state has changed. - \since 1.0 -*/ - -/*! - \fn QAbstractAudioInput::stateChanged(QAudio::State state) - This signal is emitted when the device \a state has changed. - \since 1.0 -*/ - -/*! - \fn QAbstractAudioInput::notify() - This signal is emitted when x ms of audio data has been processed - the interval set by setNotifyInterval(x). - \since 1.0 -*/ - - -QT_END_NAMESPACE - -#include "moc_qaudiosystem.cpp" diff --git a/src/multimediakit/audio/qaudiosystem.h b/src/multimediakit/audio/qaudiosystem.h deleted file mode 100644 index 72dbffa47..000000000 --- a/src/multimediakit/audio/qaudiosystem.h +++ /dev/null @@ -1,141 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QAUDIOSYSTEM_H -#define QAUDIOSYSTEM_H - -#include -#include - -#include "qaudio.h" -#include "qaudioformat.h" -#include "qaudiodeviceinfo.h" - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -QT_MODULE(Multimedia) - - -class Q_MULTIMEDIA_EXPORT QAbstractAudioDeviceInfo : public QObject -{ - Q_OBJECT - -public: - virtual QAudioFormat preferredFormat() const = 0; - virtual bool isFormatSupported(const QAudioFormat &format) const = 0; - virtual QString deviceName() const = 0; - virtual QStringList supportedCodecs() = 0; - virtual QList supportedSampleRates() = 0; - virtual QList supportedChannelCounts() = 0; - virtual QList supportedSampleSizes() = 0; - virtual QList supportedByteOrders() = 0; - virtual QList supportedSampleTypes() = 0; -}; - -class Q_MULTIMEDIA_EXPORT QAbstractAudioOutput : public QObject -{ - Q_OBJECT - -public: - virtual void start(QIODevice *device) = 0; - virtual QIODevice* start() = 0; - virtual void stop() = 0; - virtual void reset() = 0; - virtual void suspend() = 0; - virtual void resume() = 0; - virtual int bytesFree() const = 0; - virtual int periodSize() const = 0; - virtual void setBufferSize(int value) = 0; - virtual int bufferSize() const = 0; - virtual void setNotifyInterval(int milliSeconds) = 0; - virtual int notifyInterval() const = 0; - virtual qint64 processedUSecs() const = 0; - virtual qint64 elapsedUSecs() const = 0; - virtual QAudio::Error error() const = 0; - virtual QAudio::State state() const = 0; - virtual void setFormat(const QAudioFormat& fmt) = 0; - virtual QAudioFormat format() const = 0; - virtual void setVolume(qreal) {} - virtual qreal volume() const { return 1.0; } - -Q_SIGNALS: - void errorChanged(QAudio::Error); - void stateChanged(QAudio::State); - void notify(); -}; - -class Q_MULTIMEDIA_EXPORT QAbstractAudioInput : public QObject -{ - Q_OBJECT - -public: - virtual void start(QIODevice *device) = 0; - virtual QIODevice* start() = 0; - virtual void stop() = 0; - virtual void reset() = 0; - virtual void suspend() = 0; - virtual void resume() = 0; - virtual int bytesReady() const = 0; - virtual int periodSize() const = 0; - virtual void setBufferSize(int value) = 0; - virtual int bufferSize() const = 0; - virtual void setNotifyInterval(int milliSeconds) = 0; - virtual int notifyInterval() const = 0; - virtual qint64 processedUSecs() const = 0; - virtual qint64 elapsedUSecs() const = 0; - virtual QAudio::Error error() const = 0; - virtual QAudio::State state() const = 0; - virtual void setFormat(const QAudioFormat& fmt) = 0; - virtual QAudioFormat format() const = 0; - -Q_SIGNALS: - void errorChanged(QAudio::Error); - void stateChanged(QAudio::State); - void notify(); -}; - -QT_END_NAMESPACE - -QT_END_HEADER - -#endif // QAUDIOSYSTEM_H diff --git a/src/multimediakit/audio/qaudiosystemplugin.cpp b/src/multimediakit/audio/qaudiosystemplugin.cpp deleted file mode 100644 index 3347a6d44..000000000 --- a/src/multimediakit/audio/qaudiosystemplugin.cpp +++ /dev/null @@ -1,143 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - - -#include "qaudiosystemplugin.h" - -QT_BEGIN_NAMESPACE - -/*! - \class QAudioSystemPlugin - \brief The QAudioSystemPlugin class provides an abstract base for audio plugins. - \since 1.0 - - \ingroup multimedia - \inmodule QtMultimediaKit - \internal - - Writing a audio plugin is achieved by subclassing this base class, - reimplementing the pure virtual functions keys(), availableDevices(), - createInput(), createOutput() and createDeviceInfo() then exporting - the class with the Q_EXPORT_PLUGIN2() macro. - - Unit tests are available to help in debugging new plugins. - - \sa QAbstractAudioDeviceInfo, QAbstractAudioOutput, QAbstractAudioInput - - Qt supports win32, linux(alsa) and Mac OS X standard (builtin to the - QtMultimediaKit library at compile time). - - You can support other backends other than these predefined ones by - creating a plugin subclassing QAudioSystemPlugin, QAbstractAudioDeviceInfo, - QAbstractAudioOutput and QAbstractAudioInput. - - Add "default" to your list of keys() available to override the default - audio device to be provided by your plugin. - - -audio-backend configure option will force compiling in of the builtin backend - into the QtMultimediaKit library at compile time. This is automatic by default - and will only be compiled into the library if the dependencies are installed. - eg. alsa-devel package installed for linux. - - If the builtin backend is not compiled into the QtMultimediaKit library and - no audio plugins are available a fallback dummy backend will be used. - This should print out warnings if this is the case when you try and use QAudioInput or QAudioOutput. To fix this problem - reconfigure Qt using -audio-backend or create your own plugin with a default - key to always override the dummy fallback. The easiest way to determine - if you have only a dummy backend is to get a list of available audio devices. - - QAudioDeviceInfo::availableDevices(QAudio::AudioOutput).size() = 0 (dummy backend) -*/ - -/*! - Construct a new audio plugin with \a parent. - This is invoked automatically by the Q_EXPORT_PLUGIN2() macro. -*/ - -QAudioSystemPlugin::QAudioSystemPlugin(QObject* parent) : - QObject(parent) -{} - -/*! - Destroy the audio plugin - - You never have to call this explicitly. Qt destroys a plugin automatically when it is no longer used. -*/ - -QAudioSystemPlugin::~QAudioSystemPlugin() -{} - -/*! - \fn QStringList QAudioSystemPlugin::keys() const - Returns the list of device identifiers this plugin supports. - \since 1.0 -*/ - -/*! - \fn QList QAudioSystemPlugin::availableDevices(QAudio::Mode mode) const - Returns a list of available audio devices for \a mode - \since 1.0 -*/ - -/*! - \fn QAbstractAudioInput* QAudioSystemPlugin::createInput(const QByteArray& device) - Returns a pointer to a QAbstractAudioInput created using \a device identifier - \since 1.0 -*/ - -/*! - \fn QAbstractAudioOutput* QAudioSystemPlugin::createOutput(const QByteArray& device) - Returns a pointer to a QAbstractAudioOutput created using \a device identifier - - \since 1.0 -*/ - -/*! - \fn QAbstractAudioDeviceInfo* QAudioSystemPlugin::createDeviceInfo(const QByteArray& device, QAudio::Mode mode) - Returns a pointer to a QAbstractAudioDeviceInfo created using \a device and \a mode - - \since 1.0 -*/ - - -QT_END_NAMESPACE - -#include "moc_qaudiosystemplugin.cpp" diff --git a/src/multimediakit/audio/qaudiosystemplugin.h b/src/multimediakit/audio/qaudiosystemplugin.h deleted file mode 100644 index 5a876dedb..000000000 --- a/src/multimediakit/audio/qaudiosystemplugin.h +++ /dev/null @@ -1,96 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - - -#ifndef QAUDIOSYSTEMPLUGIN_H -#define QAUDIOSYSTEMPLUGIN_H - -#include -#include -#include - -#include -#include - -#include "qaudioformat.h" -#include "qaudiodeviceinfo.h" -#include "qaudiosystem.h" - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -QT_MODULE(Multimedia) - - -struct Q_MULTIMEDIA_EXPORT QAudioSystemFactoryInterface : public QFactoryInterface -{ - virtual QList availableDevices(QAudio::Mode) const = 0; - virtual QAbstractAudioInput* createInput(const QByteArray& device) = 0; - virtual QAbstractAudioOutput* createOutput(const QByteArray& device) = 0; - virtual QAbstractAudioDeviceInfo* createDeviceInfo(const QByteArray& device, QAudio::Mode mode) = 0; -}; - -#define QAudioSystemFactoryInterface_iid \ - "com.nokia.qt.QAudioSystemFactoryInterface" -Q_DECLARE_INTERFACE(QAudioSystemFactoryInterface, QAudioSystemFactoryInterface_iid) - -class Q_MULTIMEDIA_EXPORT QAudioSystemPlugin : public QObject, public QAudioSystemFactoryInterface -{ - Q_OBJECT - Q_INTERFACES(QAudioSystemFactoryInterface:QFactoryInterface) - -public: - QAudioSystemPlugin(QObject *parent = 0); - ~QAudioSystemPlugin(); - - virtual QStringList keys() const = 0; - virtual QList availableDevices(QAudio::Mode) const = 0; - virtual QAbstractAudioInput* createInput(const QByteArray& device) = 0; - virtual QAbstractAudioOutput* createOutput(const QByteArray& device) = 0; - virtual QAbstractAudioDeviceInfo* createDeviceInfo(const QByteArray& device, QAudio::Mode mode) = 0; -}; - -QT_END_NAMESPACE - -QT_END_HEADER - -#endif // QAUDIOSYSTEMPLUGIN_H diff --git a/src/multimediakit/effects/effects.pri b/src/multimediakit/effects/effects.pri deleted file mode 100644 index 48c9906b6..000000000 --- a/src/multimediakit/effects/effects.pri +++ /dev/null @@ -1,36 +0,0 @@ -INCLUDEPATH += effects - -unix:!mac { - contains(config_test_pulseaudio, yes) { - CONFIG += link_pkgconfig - PKGCONFIG += libpulse - - DEFINES += QT_MULTIMEDIA_PULSEAUDIO - PRIVATE_HEADERS += effects/qsoundeffect_pulse_p.h - SOURCES += effects/qsoundeffect_pulse_p.cpp - !maemo*:DEFINES += QTM_PULSEAUDIO_DEFAULTBUFFER - } else { - DEFINES += QT_MULTIMEDIA_QMEDIAPLAYER - PRIVATE_HEADERS += effects/qsoundeffect_qmedia_p.h - SOURCES += effects/qsoundeffect_qmedia_p.cpp - } -} else:!qpa { - PRIVATE_HEADERS += effects/qsoundeffect_qsound_p.h - SOURCES += effects/qsoundeffect_qsound_p.cpp -} else { - DEFINES += QT_MULTIMEDIA_QMEDIAPLAYER - PRIVATE_HEADERS += effects/qsoundeffect_qmedia_p.h - SOURCES += effects/qsoundeffect_qmedia_p.cpp -} - -PRIVATE_HEADERS += \ - effects/qsoundeffect_p.h \ - effects/qwavedecoder_p.h \ - effects/qsamplecache_p.h - -SOURCES += \ - effects/qsoundeffect.cpp \ - effects/qwavedecoder_p.cpp \ - effects/qsamplecache_p.cpp - -HEADERS += diff --git a/src/multimediakit/effects/qsamplecache_p.cpp b/src/multimediakit/effects/qsamplecache_p.cpp deleted file mode 100644 index 1610a4382..000000000 --- a/src/multimediakit/effects/qsamplecache_p.cpp +++ /dev/null @@ -1,398 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qsamplecache_p.h" -#include "qwavedecoder_p.h" -#include - -//#define QT_SAMPLECACHE_DEBUG - -QT_BEGIN_NAMESPACE - - -/*! - \class QSampleCache - \internal - - When you want to get a sound sample data, you need to request the QSample reference from QSampleCache. - - \since 1.1 - - \code - QSample *m_sample; // class member. - - private Q_SLOTS: - void decoderError(); - void sampleReady(); - \endcode - - \code - Q_GLOBAL_STATIC(QSampleCache, sampleCache) //declare a singleton manager - \endcode - - \code - m_sample = sampleCache()->requestSample(url); - switch(m_sample->state()) { - case QSample::Ready: - sampleReady(); - break; - case QSample::Error: - decoderError(); - break; - default: - connect(m_sample, SIGNAL(error()), this, SLOT(decoderError())); - connect(m_sample, SIGNAL(ready()), this, SLOT(sampleReady())); - break; - } - \endcode - - When you no longer need the sound sample data, you need to release it: - - \code - if (m_sample) { - m_sample->release(); - m_sample = 0; - } - \endcode -*/ - -QSampleCache::QSampleCache() - : m_networkAccessManager(0) - , m_mutex(QMutex::Recursive) - , m_capacity(0) - , m_usage(0) -{ - m_loadingThread.setObjectName(QLatin1String("QSampleCache::LoadingThread")); -} - -QNetworkAccessManager& QSampleCache::networkAccessManager() -{ - if (!m_networkAccessManager) - m_networkAccessManager = new QNetworkAccessManager(); - return *m_networkAccessManager; -} - -QSampleCache::~QSampleCache() -{ - QMutexLocker m(&m_mutex); - - m_loadingThread.quit(); - m_loadingThread.wait(); - - // Killing the loading thread means that no samples can be - // deleted using deleteLater. And some samples that had deleteLater - // already called won't have been processed (m_staleSamples) - foreach (QSample* sample, m_samples) - delete sample; - - foreach (QSample* sample, m_staleSamples) - delete sample; // deleting a sample does affect the m_staleSamples list, but foreach copies it - - delete m_networkAccessManager; -} - -QSample* QSampleCache::requestSample(const QUrl& url) -{ - if (!m_loadingThread.isRunning()) - m_loadingThread.start(); -#ifdef QT_SAMPLECACHE_DEBUG - qDebug() << "QSampleCache: request sample [" << url << "]"; -#endif - QMutexLocker locker(&m_mutex); - QMap::iterator it = m_samples.find(url); - QSample* sample; - if (it == m_samples.end()) { - sample = new QSample(url, this); - m_samples.insert(url, sample); - sample->moveToThread(&m_loadingThread); - } else { - sample = *it; - } - - sample->addRef(); - locker.unlock(); - - sample->loadIfNecessary(); - return sample; -} - -void QSampleCache::setCapacity(qint64 capacity) -{ - QMutexLocker locker(&m_mutex); - if (m_capacity == capacity) - return; -#ifdef QT_SAMPLECACHE_DEBUG - qDebug() << "QSampleCache: capacity changes from " << m_capacity << "to " << capacity; -#endif - if (m_capacity > 0 && capacity <= 0) { //memory management strategy changed - for (QMap::iterator it = m_samples.begin(); it != m_samples.end();) { - QSample* sample = *it; - if (sample->m_ref == 0) { - unloadSample(sample); - it = m_samples.erase(it); - } else - it++; - } - } - - m_capacity = capacity; - refresh(0); -} - -// Called locked -void QSampleCache::unloadSample(QSample *sample) -{ - m_usage -= sample->m_soundData.size(); - m_staleSamples.insert(sample); - sample->deleteLater(); -} - -// Called in both threads -void QSampleCache::refresh(qint64 usageChange) -{ - QMutexLocker locker(&m_mutex); - m_usage += usageChange; - if (m_capacity <= 0 || m_usage <= m_capacity) - return; - -#ifdef QT_SAMPLECACHE_DEBUG - qint64 recoveredSize = 0; -#endif - - //free unused samples to keep usage under capacity limit. - for (QMap::iterator it = m_samples.begin(); it != m_samples.end();) { - QSample* sample = *it; - if (sample->m_ref > 0) { - ++it; - continue; - } -#ifdef QT_SAMPLECACHE_DEBUG - recoveredSize += sample->m_soundData.size(); -#endif - unloadSample(sample); - it = m_samples.erase(it); - if (m_usage <= m_capacity) - return; - } - -#ifdef QT_SAMPLECACHE_DEBUG - qDebug() << "QSampleCache: refresh(" << usageChange - << ") recovered size =" << recoveredSize - << "new usage =" << m_usage; -#endif - - if (m_usage > m_capacity) - qWarning() << "QSampleCache: usage[" << m_usage << " out of limit[" << m_capacity << "]"; -} - -// Called in both threads -void QSampleCache::removeUnreferencedSample(QSample *sample) -{ - QMutexLocker m(&m_mutex); - m_staleSamples.remove(sample); -} - -// Called in loader thread (since this lives in that thread) -// Also called from application thread after loader thread dies. -QSample::~QSample() -{ - // Remove ourselves from our parent - m_parent->removeUnreferencedSample(this); - - QMutexLocker locker(&m_mutex); -#ifdef QT_SAMPLECACHE_DEBUG - qDebug() << "~QSample" << this << ": deleted [" << m_url << "]" << QThread::currentThread(); -#endif - cleanup(); -} - -// Called in application thread -void QSample::loadIfNecessary() -{ - QMutexLocker locker(&m_mutex); - if (m_state == QSample::Error || m_state == QSample::Creating) { - m_state = QSample::Loading; - QMetaObject::invokeMethod(this, "load", Qt::QueuedConnection); - } -} - -// Called in both threads -bool QSampleCache::notifyUnreferencedSample(QSample* sample) -{ - QMutexLocker locker(&m_mutex); - if (m_capacity > 0) - return false; - m_samples.remove(sample->m_url); - m_staleSamples.insert(sample); - sample->deleteLater(); - return true; -} - -// Called in application threadd -void QSample::release() -{ - QMutexLocker locker(&m_mutex); -#ifdef QT_SAMPLECACHE_DEBUG - qDebug() << "Sample:: release" << this << QThread::currentThread() << m_ref; -#endif - m_ref--; - if (m_ref == 0) - m_parent->notifyUnreferencedSample(this); -} - -// Called in dtor and when stream is loaded -// must be called locked. -void QSample::cleanup() -{ - delete m_waveDecoder; - delete m_stream; - m_waveDecoder = 0; - m_stream = 0; -} - -// Called in application thread -void QSample::addRef() -{ - m_ref++; -} - -// Called in loading thread -void QSample::readSample() -{ - Q_ASSERT(QThread::currentThread()->objectName() == QLatin1String("QSampleCache::LoadingThread")); - QMutexLocker m(&m_mutex); -#ifdef QT_SAMPLECACHE_DEBUG - qDebug() << "QSample: readSample"; -#endif - qint64 read = m_waveDecoder->read(m_soundData.data() + m_sampleReadLength, - qMin(m_waveDecoder->bytesAvailable(), - qint64(m_waveDecoder->size() - m_sampleReadLength))); - if (read > 0) - m_sampleReadLength += read; - if (m_sampleReadLength < m_waveDecoder->size()) - return; - Q_ASSERT(m_sampleReadLength == qint64(m_soundData.size())); - onReady(); -} - -// Called in loading thread -void QSample::decoderReady() -{ - Q_ASSERT(QThread::currentThread()->objectName() == QLatin1String("QSampleCache::LoadingThread")); - QMutexLocker m(&m_mutex); -#ifdef QT_SAMPLECACHE_DEBUG - qDebug() << "QSample: decoder ready"; -#endif - m_parent->refresh(m_waveDecoder->size()); - - m_soundData.resize(m_waveDecoder->size()); - m_sampleReadLength = 0; - qint64 read = m_waveDecoder->read(m_soundData.data(), m_waveDecoder->size()); - if (read > 0) - m_sampleReadLength += read; - if (m_sampleReadLength >= m_waveDecoder->size()) - onReady(); -} - -// Called in all threads -QSample::State QSample::state() const -{ - QMutexLocker m(&m_mutex); - return m_state; -} - -// Called in loading thread -// Essentially a second ctor, doesn't need locks (?) -void QSample::load() -{ - Q_ASSERT(QThread::currentThread()->objectName() == QLatin1String("QSampleCache::LoadingThread")); -#ifdef QT_SAMPLECACHE_DEBUG - qDebug() << "QSample: load [" << m_url << "]"; -#endif - m_stream = m_parent->networkAccessManager().get(QNetworkRequest(m_url)); - connect(m_stream, SIGNAL(error(QNetworkReply::NetworkError)), SLOT(decoderError())); - m_waveDecoder = new QWaveDecoder(m_stream); - connect(m_waveDecoder, SIGNAL(formatKnown()), SLOT(decoderReady())); - connect(m_waveDecoder, SIGNAL(invalidFormat()), SLOT(decoderError())); - connect(m_waveDecoder, SIGNAL(readyRead()), SLOT(readSample())); -} - -// Called in loading thread -void QSample::decoderError() -{ - Q_ASSERT(QThread::currentThread()->objectName() == QLatin1String("QSampleCache::LoadingThread")); - QMutexLocker m(&m_mutex); -#ifdef QT_SAMPLECACHE_DEBUG - qDebug() << "QSample: decoder error"; -#endif - cleanup(); - m_state = QSample::Error; - emit error(); -} - -// Called in loading thread from decoder when sample is done. Locked already. -void QSample::onReady() -{ - Q_ASSERT(QThread::currentThread()->objectName() == QLatin1String("QSampleCache::LoadingThread")); -#ifdef QT_SAMPLECACHE_DEBUG - qDebug() << "QSample: load ready"; -#endif - m_audioFormat = m_waveDecoder->audioFormat(); - cleanup(); - m_state = QSample::Ready; - emit ready(); -} - -// Called in application thread, then moved to loader thread -QSample::QSample(const QUrl& url, QSampleCache *parent) - : m_parent(parent) - , m_stream(0) - , m_waveDecoder(0) - , m_url(url) - , m_sampleReadLength(0) - , m_state(Creating) - , m_ref(0) -{ -} - -QT_END_NAMESPACE - -#include "moc_qsamplecache_p.cpp" diff --git a/src/multimediakit/effects/qsamplecache_p.h b/src/multimediakit/effects/qsamplecache_p.h deleted file mode 100644 index 91ca457e6..000000000 --- a/src/multimediakit/effects/qsamplecache_p.h +++ /dev/null @@ -1,161 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QSAMPLECACHE_P_H -#define QSAMPLECACHE_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 -#include -#include -#include -#include -#include -#include - - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -QT_MODULE(Multimedia) - - -class QNetworkAccessManager; -class QSampleCache; -class QWaveDecoder; - -// Lives in application thread -class QSample : public QObject -{ - Q_OBJECT -public: - friend class QSampleCache; - enum State - { - Creating, - Loading, - Error, - Ready, - }; - - State state() const; - // These are not (currently) locked because they are only meant to be called after these - // variables are updated to their final states - const QByteArray& data() const { Q_ASSERT(state() == Ready); return m_soundData; } - const QAudioFormat& format() const { Q_ASSERT(state() == Ready); return m_audioFormat; } - void release(); - -Q_SIGNALS: - void error(); - void ready(); - -protected: - QSample(const QUrl& url, QSampleCache *parent); - -private Q_SLOTS: - void load(); - void decoderError(); - void readSample(); - void decoderReady(); - -private: - void onReady(); - void cleanup(); - void addRef(); - void loadIfNecessary(); - QSample(); - ~QSample(); - - mutable QMutex m_mutex; - QSampleCache *m_parent; - QByteArray m_soundData; - QAudioFormat m_audioFormat; - QIODevice *m_stream; - QWaveDecoder *m_waveDecoder; - QUrl m_url; - qint64 m_sampleReadLength; - State m_state; - int m_ref; -}; - -class QSampleCache -{ -public: - friend class QSample; - - QSampleCache(); - ~QSampleCache(); - - QSample* requestSample(const QUrl& url); - void setCapacity(qint64 capacity); - -private: - QMap m_samples; - QSet m_staleSamples; - QNetworkAccessManager *m_networkAccessManager; - QMutex m_mutex; - qint64 m_capacity; - qint64 m_usage; - QThread m_loadingThread; - - QNetworkAccessManager& networkAccessManager(); - void refresh(qint64 usageChange); - bool notifyUnreferencedSample(QSample* sample); - void removeUnreferencedSample(QSample* sample); - void unloadSample(QSample* sample); -}; - -QT_END_NAMESPACE - -QT_END_HEADER - -#endif // QSAMPLECACHE_P_H diff --git a/src/multimediakit/effects/qsoundeffect.cpp b/src/multimediakit/effects/qsoundeffect.cpp deleted file mode 100644 index b3c7706a6..000000000 --- a/src/multimediakit/effects/qsoundeffect.cpp +++ /dev/null @@ -1,301 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qsoundeffect_p.h" - -#if defined(QT_MULTIMEDIA_PULSEAUDIO) -#include "qsoundeffect_pulse_p.h" -#elif(QT_MULTIMEDIA_QMEDIAPLAYER) -#include "qsoundeffect_qmedia_p.h" -#else -#include "qsoundeffect_qsound_p.h" -#endif - -QT_BEGIN_NAMESPACE - -/*! - \qmlclass SoundEffect QSoundEffect - \brief The SoundEffect element provides a way to play sound effects in QML. - \since 1.0 - - \inmodule QtMultimediaKit - - This element is part of the \bold{QtMultimediaKit 1.1} module. - - The following example plays a WAV file on mouse click. - - \snippet doc/src/snippets/multimedia-snippets/soundeffect.qml complete snippet -*/ - -/*! - \qmlproperty url SoundEffect::source - \since 1.0 - - This property provides a way to control the sound to play. -*/ - -/*! - \qmlproperty int SoundEffect::loops - \since 1.0 - - This property provides a way to control the number of times to repeat the sound on each play(). - - Set to -1 (infinite) to enable infinite loop. -*/ - -/*! - \qmlproperty qreal SoundEffect::volume - \since 1.0 - - This property holds the volume of the playback, from 0.0 (silent) to 1.0 (maximum volume). - Note: Currently this has no effect on Mac OS X. -*/ - -/*! - \qmlproperty bool SoundEffect::muted - \since 1.0 - - This property provides a way to control muting. -*/ - -/*! - \qmlproperty bool SoundEffect::playing - \since 1.1 - - This property indicates if the soundeffect is playing or not. -*/ - -/*! - \qmlproperty int SoundEffect::status - \since 1.0 - - This property indicates the following status of the soundeffect. - - Null: no source has been set or is null. - Loading: the soundeffect is trying to load the source. - Ready: the source is loaded and ready for play. - Error: some error happened during operation, such as failure of loading the source. -*/ - -/*! - \qmlsignal SoundEffect::sourceChanged() - \since 1.0 - - This handler is called when the source has changed. -*/ - -/*! - \qmlsignal SoundEffect::loopsChanged() - \since 1.0 - - This handler is called when the number of loops has changed. -*/ - -/*! - \qmlsignal SoundEffect::volumeChanged() - \since 1.0 - - This handler is called when the volume has changed. -*/ - -/*! - \qmlsignal SoundEffect::mutedChanged() - \since 1.0 - - This handler is called when the mute state has changed. -*/ - -/*! - \qmlsignal SoundEffect::playingChanged() - \since 1.0 - - This handler is called when the playing property has changed. -*/ - -/*! - \qmlsignal SoundEffect::statusChanged() - - This handler is called when the status property has changed. - \since 1.0 -*/ - - -/*! - \internal - \since 1.0 -*/ - -QSoundEffect::QSoundEffect(QObject *parent) : - QObject(parent) -{ - d = new QSoundEffectPrivate(this); - connect(d, SIGNAL(volumeChanged()), SIGNAL(volumeChanged())); - connect(d, SIGNAL(mutedChanged()), SIGNAL(mutedChanged())); - connect(d, SIGNAL(loadedChanged()), SIGNAL(loadedChanged())); - connect(d, SIGNAL(playingChanged()), SIGNAL(playingChanged())); - connect(d, SIGNAL(statusChanged()), SIGNAL(statusChanged())); -} - -QSoundEffect::~QSoundEffect() -{ - d->deleteLater(); -} - -QStringList QSoundEffect::supportedMimeTypes() -{ - return QSoundEffectPrivate::supportedMimeTypes(); -} - -QUrl QSoundEffect::source() const -{ - return d->source(); -} - -void QSoundEffect::setSource(const QUrl &url) -{ - if (d->source() == url) - return; - - d->setSource(url); - - emit sourceChanged(); -} - -int QSoundEffect::loopCount() const -{ - return d->loopCount(); -} - -void QSoundEffect::setLoopCount(int loopCount) -{ - if (loopCount < 0 && loopCount != Infinite) { - qWarning("SoundEffect: loops should be SoundEffect.Infinite, 0 or positive integer"); - return; - } - if (loopCount == 0) - loopCount = 1; - if (d->loopCount() == loopCount) - return; - - d->setLoopCount(loopCount); - emit loopCountChanged(); -} - -qreal QSoundEffect::volume() const -{ - return qreal(d->volume()) / 100; -} - -void QSoundEffect::setVolume(qreal volume) -{ - if (volume < 0 || volume > 1) { - qWarning("SoundEffect: volume should be between 0.0 and 1.0"); - return; - } - int iVolume = qRound(volume * 100); - if (d->volume() == iVolume) - return; - - d->setVolume(iVolume); -} - -bool QSoundEffect::isMuted() const -{ - return d->isMuted(); -} - -void QSoundEffect::setMuted(bool muted) -{ - if (d->isMuted() == muted) - return; - - d->setMuted(muted); -} - -bool QSoundEffect::isLoaded() const -{ - return d->isLoaded(); -} - -/*! - \qmlmethod SoundEffect::play() - - Start playback of the sound effect, looping the effect for the number of - times as specificed in the loops property. - - This is the default method for SoundEffect. - - \snippet doc/src/snippets/multimedia-snippets/soundeffect.qml play sound on click - \since 1.0 -*/ -void QSoundEffect::play() -{ - d->play(); -} - -bool QSoundEffect::isPlaying() const -{ - return d->isPlaying(); -} - -QSoundEffect::Status QSoundEffect::status() const -{ - return d->status(); -} - - -/*! - \qmlmethod SoundEffect::stop() - - Stop current playback. - Note that if the backend is PulseAudio, due to the limitation of the underlying API, - tis stop will only prevent next looping but will not be able to stop current playback immediately. - - \since 1.0 - */ -void QSoundEffect::stop() -{ - d->stop(); -} - -QT_END_NAMESPACE - -#include "moc_qsoundeffect_p.cpp" diff --git a/src/multimediakit/effects/qsoundeffect_p.h b/src/multimediakit/effects/qsoundeffect_p.h deleted file mode 100644 index 4d6764742..000000000 --- a/src/multimediakit/effects/qsoundeffect_p.h +++ /dev/null @@ -1,143 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QSOUNDEFFECT_P_H -#define QSOUNDEFFECT_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 -#include -#include -#include - - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -QT_MODULE(Multimedia) - - -class QSoundEffectPrivate; - -class Q_MULTIMEDIA_EXPORT QSoundEffect : public QObject -{ - Q_OBJECT - Q_CLASSINFO("DefaultMethod", "play()") - Q_PROPERTY(QUrl source READ source WRITE setSource NOTIFY sourceChanged) - Q_PROPERTY(int loops READ loopCount WRITE setLoopCount NOTIFY loopCountChanged) - Q_PROPERTY(qreal volume READ volume WRITE setVolume NOTIFY volumeChanged) - Q_PROPERTY(bool muted READ isMuted WRITE setMuted NOTIFY mutedChanged) - Q_PROPERTY(bool playing READ isPlaying NOTIFY playingChanged) - Q_PROPERTY(Status status READ status NOTIFY statusChanged) - Q_ENUMS(Loop) - Q_ENUMS(Status) - -public: - enum Loop - { - Infinite = -2, - }; - - enum Status - { - Null, - Loading, - Ready, - Error - }; - - explicit QSoundEffect(QObject *parent = 0); - ~QSoundEffect(); - - static QStringList supportedMimeTypes(); - - QUrl source() const; - void setSource(const QUrl &url); - - int loopCount() const; - void setLoopCount(int loopCount); - - qreal volume() const; - void setVolume(qreal volume); - - bool isMuted() const; - void setMuted(bool muted); - - bool isLoaded() const; - - bool isPlaying() const; - Status status() const; - -Q_SIGNALS: - void sourceChanged(); - void loopCountChanged(); - void volumeChanged(); - void mutedChanged(); - void loadedChanged(); - void playingChanged(); - void statusChanged(); - -public Q_SLOTS: - void play(); - void stop(); - -private: - Q_DISABLE_COPY(QSoundEffect) - QSoundEffectPrivate* d; -}; - -QT_END_NAMESPACE - -QT_END_HEADER - - -#endif // QSOUNDEFFECT_H diff --git a/src/multimediakit/effects/qsoundeffect_pulse_p.cpp b/src/multimediakit/effects/qsoundeffect_pulse_p.cpp deleted file mode 100644 index 4570f8fd5..000000000 --- a/src/multimediakit/effects/qsoundeffect_pulse_p.cpp +++ /dev/null @@ -1,957 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -// -// 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. -// -// INTERNAL USE ONLY: Do NOT use for any other purpose. -// - -#include -#include -#include -#include - -#include "qsoundeffect_pulse_p.h" - -#if defined(Q_WS_MAEMO_6) -#include -#endif - -#include - -//#define QT_PA_DEBUG -#ifndef QTM_PULSEAUDIO_DEFAULTBUFFER -#define QT_PA_STREAM_BUFFER_SIZE_MAX (1024 * 64) //64KB is a trade-off for balancing control latency and uploading overhead -#endif - -QT_BEGIN_NAMESPACE - -namespace -{ -inline pa_sample_spec audioFormatToSampleSpec(const QAudioFormat &format) -{ - pa_sample_spec spec; - - spec.rate = format.frequency(); - spec.channels = format.channels(); - - if (format.sampleSize() == 8) - spec.format = PA_SAMPLE_U8; - else if (format.sampleSize() == 16) { - switch (format.byteOrder()) { - case QAudioFormat::BigEndian: spec.format = PA_SAMPLE_S16BE; break; - case QAudioFormat::LittleEndian: spec.format = PA_SAMPLE_S16LE; break; - } - } - else if (format.sampleSize() == 32) { - switch (format.byteOrder()) { - case QAudioFormat::BigEndian: spec.format = PA_SAMPLE_S32BE; break; - case QAudioFormat::LittleEndian: spec.format = PA_SAMPLE_S32LE; break; - } - } - - return spec; -} - -class PulseDaemon : public QObject -{ - Q_OBJECT -public: - PulseDaemon(): m_prepared(false) - { - prepare(); - } - - ~PulseDaemon() - { - if (m_prepared) - release(); - } - - inline void lock() - { - pa_threaded_mainloop_lock(m_mainLoop); - } - - inline void unlock() - { - pa_threaded_mainloop_unlock(m_mainLoop); - } - - inline pa_context *context() const - { - return m_context; - } - - inline pa_cvolume * calcVolume(pa_cvolume *dest, int soundEffectVolume) - { - dest->channels = 2; - dest->values[0] = dest->values[1] = m_vol * soundEffectVolume / 100; - return dest; - } - - void updateStatus(const pa_cvolume& volume) - { - if (m_vol != pa_cvolume_max(&volume)) { - m_vol = pa_cvolume_max(&volume); - emit volumeChanged(); - } - } - -Q_SIGNALS: - void contextReady(); - void volumeChanged(); - -private: - void prepare() - { - m_vol = PA_VOLUME_NORM; - - m_mainLoop = pa_threaded_mainloop_new(); - if (m_mainLoop == 0) { - qWarning("PulseAudioService: unable to create pulseaudio mainloop"); - return; - } - - if (pa_threaded_mainloop_start(m_mainLoop) != 0) { - qWarning("PulseAudioService: unable to start pulseaudio mainloop"); - pa_threaded_mainloop_free(m_mainLoop); - return; - } - - m_mainLoopApi = pa_threaded_mainloop_get_api(m_mainLoop); - - lock(); - m_context = pa_context_new(m_mainLoopApi, QString(QLatin1String("QtPulseAudio:%1")).arg(::getpid()).toAscii().constData()); - - pa_context_set_state_callback(m_context, context_state_callback, this); - - if (m_context == 0) { - qWarning("PulseAudioService: Unable to create new pulseaudio context"); - pa_threaded_mainloop_free(m_mainLoop); - return; - } - - if (pa_context_connect(m_context, 0, (pa_context_flags_t)0, 0) < 0) { - qWarning("PulseAudioService: pa_context_connect() failed"); - pa_context_unref(m_context); - pa_threaded_mainloop_free(m_mainLoop); - return; - } - unlock(); - - m_prepared = true; - } - - void release() - { - if (!m_prepared) return; - pa_threaded_mainloop_stop(m_mainLoop); - pa_threaded_mainloop_free(m_mainLoop); - m_prepared = false; - } - - static void context_state_callback(pa_context *c, void *userdata) - { - PulseDaemon *self = reinterpret_cast(userdata); - switch (pa_context_get_state(c)) { - case PA_CONTEXT_CONNECTING: - case PA_CONTEXT_AUTHORIZING: - case PA_CONTEXT_SETTING_NAME: - break; - case PA_CONTEXT_READY: - #if defined(Q_WS_MAEMO_6) - pa_ext_stream_restore_read(c, &stream_restore_info_callback, self); - pa_ext_stream_restore_set_subscribe_cb(c, &stream_restore_monitor_callback, self); - pa_ext_stream_restore_subscribe(c, 1, 0, self); - #endif - QMetaObject::invokeMethod(self, "contextReady", Qt::QueuedConnection); - break; - default: - break; - } - } - -#if defined(Q_WS_MAEMO_6) - - static void stream_restore_monitor_callback(pa_context *c, void *userdata) - { - PulseDaemon *self = reinterpret_cast(userdata); - pa_ext_stream_restore_read(c, &stream_restore_info_callback, self); - } - - static void stream_restore_info_callback(pa_context *c, - const pa_ext_stream_restore_info *info, - int eol, void *userdata) - { - Q_UNUSED(c) - - PulseDaemon *self = reinterpret_cast(userdata); - - if (!eol) { - if (QString(info->name).startsWith(QLatin1String("sink-input-by-media-role:x-maemo"))) { -#ifdef QT_PA_DEBUG - qDebug() << "x-maemo volume =(" << info->volume.values[0] * 100 / PA_VOLUME_NORM << "," - << info->volume.values[1] * 100 / PA_VOLUME_NORM << "), " - << "mute = " << info->mute; -#endif - self->updateStatus(info->volume); - } - } - } -#endif - - pa_volume_t m_vol; - - bool m_prepared; - pa_context *m_context; - pa_threaded_mainloop *m_mainLoop; - pa_mainloop_api *m_mainLoopApi; -}; - -} - -Q_GLOBAL_STATIC(PulseDaemon, daemon) -Q_GLOBAL_STATIC(QSampleCache, sampleCache) - -namespace -{ -class PulseDaemonLocker -{ -public: - PulseDaemonLocker() - { - daemon()->lock(); - } - - ~PulseDaemonLocker() - { - daemon()->unlock(); - } -}; -} - -QSoundEffectPrivate::QSoundEffectPrivate(QObject* parent): - QObject(parent), - m_pulseStream(0), - m_sinkInputId(-1), - m_emptying(false), - m_sampleReady(false), - m_playing(false), - m_status(QSoundEffect::Null), - m_muted(false), - m_playQueued(false), - m_stopping(false), - m_volume(100), - m_loopCount(1), - m_runningCount(0), - m_sample(0) , - m_position(0) -{ - pa_sample_spec_init(&m_pulseSpec); -} - -QSoundEffectPrivate::~QSoundEffectPrivate() -{ - unloadPulseStream(); - - if (m_sample) - m_sample->release(); -} - -QStringList QSoundEffectPrivate::supportedMimeTypes() -{ - QStringList supportedTypes; - supportedTypes << QLatin1String("audio/x-wav") << QLatin1String("audio/vnd.wave") ; - return supportedTypes; -} - -QUrl QSoundEffectPrivate::source() const -{ - return m_source; -} - -void QSoundEffectPrivate::setSource(const QUrl &url) -{ - Q_ASSERT(m_source != url); -#ifdef QT_PA_DEBUG - qDebug() << this << "setSource =" << url; -#endif - stop(); - if (m_sample) { - if (!m_sampleReady) { - disconnect(m_sample, SIGNAL(error()), this, SLOT(decoderError())); - disconnect(m_sample, SIGNAL(ready()), this, SLOT(sampleReady())); - } - m_sample->release(); - m_sample = 0; - } - - m_source = url; - m_sampleReady = false; - - PulseDaemonLocker locker; - m_runningCount = 0; - if (m_pulseStream && !pa_stream_is_corked(m_pulseStream)) { - pa_stream_set_write_callback(m_pulseStream, 0, 0); - pa_stream_set_underflow_callback(m_pulseStream, 0, 0); - pa_operation_unref(pa_stream_cork(m_pulseStream, 1, 0, 0)); - } - setPlaying(false); - - if (url.isEmpty()) { - setStatus(QSoundEffect::Null); - return; - } - - setStatus(QSoundEffect::Loading); - m_sample = sampleCache()->requestSample(url); - connect(m_sample, SIGNAL(error()), this, SLOT(decoderError())); - connect(m_sample, SIGNAL(ready()), this, SLOT(sampleReady())); - switch(m_sample->state()) { - case QSample::Ready: - sampleReady(); - break; - case QSample::Error: - decoderError(); - break; - default: - break; - } -} - -int QSoundEffectPrivate::loopCount() const -{ - return m_loopCount; -} - -void QSoundEffectPrivate::setLoopCount(int loopCount) -{ - if (loopCount == 0) - loopCount = 1; - m_loopCount = loopCount; -} - -int QSoundEffectPrivate::volume() const -{ - return m_volume; -} - -void QSoundEffectPrivate::setVolume(int volume) -{ - m_volume = volume; - emit volumeChanged(); - updateVolume(); -} - -void QSoundEffectPrivate::updateVolume() -{ - if (m_sinkInputId < 0) - return; - PulseDaemonLocker locker; - pa_cvolume volume; - pa_operation_unref(pa_context_set_sink_input_volume(daemon()->context(), m_sinkInputId, daemon()->calcVolume(&volume, m_volume), setvolume_callback, this)); - Q_ASSERT(pa_cvolume_valid(&volume)); -#ifdef QT_PA_DEBUG - qDebug() << this << "updateVolume =" << pa_cvolume_max(&volume); -#endif -} - -bool QSoundEffectPrivate::isMuted() const -{ - return m_muted; -} - -void QSoundEffectPrivate::setMuted(bool muted) -{ - m_muted = muted; - emit mutedChanged(); - updateMuted(); -} - -void QSoundEffectPrivate::updateMuted() -{ - if (m_sinkInputId < 0) - return; - PulseDaemonLocker locker; - pa_operation_unref(pa_context_set_sink_input_mute(daemon()->context(), m_sinkInputId, m_muted, setmuted_callback, this)); -#ifdef QT_PA_DEBUG - qDebug() << this << "updateMuted = " << daemon()->calcMuted(m_muted); -#endif -} - -bool QSoundEffectPrivate::isLoaded() const -{ - return m_status == QSoundEffect::Ready; -} - -bool QSoundEffectPrivate::isPlaying() const -{ - return m_playing; -} - -QSoundEffect::Status QSoundEffectPrivate::status() const -{ - return m_status; -} - -void QSoundEffectPrivate::setPlaying(bool playing) -{ -#ifdef QT_PA_DEBUG - qDebug() << this << "setPlaying(" << playing << ")"; -#endif - if (m_playing == playing) - return; - if (!playing) - m_playQueued = false; - m_playing = playing; - emit playingChanged(); -} - -void QSoundEffectPrivate::setStatus(QSoundEffect::Status status) -{ -#ifdef QT_PA_DEBUG - qDebug() << this << "setStatus" << status; -#endif - if (m_status == status) - return; - bool oldLoaded = isLoaded(); - m_status = status; - emit statusChanged(); - if (oldLoaded != isLoaded()) - emit loadedChanged(); -} - -void QSoundEffectPrivate::play() -{ -#ifdef QT_PA_DEBUG - qDebug() << this << "play"; -#endif - if (m_status == QSoundEffect::Null || m_status == QSoundEffect::Error || m_playQueued) - return; - - PulseDaemonLocker locker; - if (!m_sampleReady || m_stopping || m_emptying) { -#ifdef QT_PA_DEBUG - qDebug() << this << "play deferred"; -#endif - m_playQueued = true; - } else { - if (m_playing) { //restart playing from the beginning -#ifdef QT_PA_DEBUG - qDebug() << this << "restart playing"; -#endif - m_runningCount = 0; - m_playQueued = true; - Q_ASSERT(m_pulseStream); - emptyStream(); - return; - } - m_runningCount = m_loopCount; - playSample(); - } - - setPlaying(true); -} - -void QSoundEffectPrivate::emptyStream() -{ - m_emptying = true; - pa_stream_set_write_callback(m_pulseStream, 0, this); - pa_stream_set_underflow_callback(m_pulseStream, 0, this); - pa_operation_unref(pa_stream_flush(m_pulseStream, stream_flush_callback, this)); -} - -void QSoundEffectPrivate::emptyComplete() -{ - PulseDaemonLocker locker; - m_emptying = false; - pa_operation_unref(pa_stream_cork(m_pulseStream, 1, stream_cork_callback, this)); -} - -void QSoundEffectPrivate::sampleReady() -{ -#ifdef QT_PA_DEBUG - qDebug() << this << "sampleReady"; -#endif - disconnect(m_sample, SIGNAL(error()), this, SLOT(decoderError())); - disconnect(m_sample, SIGNAL(ready()), this, SLOT(sampleReady())); - pa_sample_spec newFormatSpec = audioFormatToSampleSpec(m_sample->format()); - - if (m_pulseStream && (memcmp(&m_pulseSpec, &newFormatSpec, sizeof(m_pulseSpec)) != 0)) { - unloadPulseStream(); - } - m_pulseSpec = newFormatSpec; - - m_sampleReady = true; - m_position = 0; - - if (m_name.isNull()) - m_name = QString(QLatin1String("QtPulseSample-%1-%2")).arg(::getpid()).arg(quintptr(this)).toUtf8(); - - PulseDaemonLocker locker; - if (m_pulseStream) { -#ifdef QT_PA_DEBUG - qDebug() << this << "reuse existing pulsestream"; -#endif -#ifdef QTM_PULSEAUDIO_DEFAULTBUFFER - const pa_buffer_attr *bufferAttr = pa_stream_get_buffer_attr(m_pulseStream); - if (bufferAttr->prebuf > uint32_t(m_sample->data().size())) { - pa_buffer_attr newBufferAttr; - newBufferAttr = *bufferAttr; - newBufferAttr.prebuf = m_sample->data().size(); - pa_stream_set_buffer_attr(m_pulseStream, &newBufferAttr, stream_adjust_prebuffer_callback, this); - } else { - streamReady(); - } -#else - const pa_buffer_attr *bufferAttr = pa_stream_get_buffer_attr(m_pulseStream); - if (bufferAttr->tlength < m_sample->data().size() && bufferAttr->tlength < QT_PA_STREAM_BUFFER_SIZE_MAX) { - pa_buffer_attr newBufferAttr; - newBufferAttr.maxlength = -1; - newBufferAttr.tlength = qMin(m_sample->data().size(), QT_PA_STREAM_BUFFER_SIZE_MAX); - newBufferAttr.minreq = bufferAttr->tlength / 2; - newBufferAttr.prebuf = -1; - newBufferAttr.fragsize = -1; - pa_stream_set_buffer_attr(m_pulseStream, &newBufferAttr, stream_reset_buffer_callback, this); - } else if (bufferAttr->prebuf > uint32_t(m_sample->data().size())) { - pa_buffer_attr newBufferAttr; - newBufferAttr = *bufferAttr; - newBufferAttr.prebuf = m_sample->data().size(); - pa_stream_set_buffer_attr(m_pulseStream, &newBufferAttr, stream_adjust_prebuffer_callback, this); - } else { - streamReady(); - } -#endif - } else { - if (pa_context_get_state(daemon()->context()) != PA_CONTEXT_READY) { - connect(daemon(), SIGNAL(contextReady()), SLOT(contextReady())); - return; - } - createPulseStream(); - } -} - -void QSoundEffectPrivate::decoderError() -{ - qWarning("QSoundEffect(pulseaudio): Error decoding source"); - disconnect(m_sample, SIGNAL(error()), this, SLOT(decoderError())); - bool playingDirty = false; - if (m_playing) { - m_playing = false; - playingDirty = true; - } - setStatus(QSoundEffect::Error); - if (playingDirty) - emit playingChanged(); -} - -void QSoundEffectPrivate::unloadPulseStream() -{ -#ifdef QT_PA_DEBUG - qDebug() << this << "unloadPulseStream"; -#endif - m_sinkInputId = -1; - PulseDaemonLocker locker; - if (m_pulseStream) { - pa_stream_set_state_callback(m_pulseStream, 0, 0); - pa_stream_set_write_callback(m_pulseStream, 0, 0); - pa_stream_set_underflow_callback(m_pulseStream, 0, 0); - pa_stream_disconnect(m_pulseStream); - pa_stream_unref(m_pulseStream); - disconnect(daemon(), SIGNAL(volumeChanged()), this, SLOT(updateVolume())); - m_pulseStream = 0; - } -} - -void QSoundEffectPrivate::prepare() -{ - if (!m_pulseStream || !m_sampleReady) - return; - PulseDaemonLocker locker; - pa_stream_set_write_callback(m_pulseStream, stream_write_callback, this); - pa_stream_set_underflow_callback(m_pulseStream, stream_underrun_callback, this); - m_stopping = false; - size_t writeBytes = size_t(qMin(m_pulseBufferSize, m_sample->data().size())); -#ifdef QT_PA_DEBUG - qDebug() << this << "prepare(): writable size =" << pa_stream_writable_size(m_pulseStream) - << "actual writeBytes =" << writeBytes - << "m_playQueued =" << m_playQueued; -#endif - m_position = int(writeBytes); - if (pa_stream_write(m_pulseStream, reinterpret_cast(const_cast(m_sample->data().data())), writeBytes, - stream_write_done_callback, 0, PA_SEEK_RELATIVE) != 0) { - qWarning("QSoundEffect(pulseaudio): pa_stream_write, error = %s", pa_strerror(pa_context_errno(daemon()->context()))); - } - if (m_playQueued) { - m_playQueued = false; - m_runningCount = m_loopCount; - playSample(); - } -} - -void QSoundEffectPrivate::uploadSample() -{ - if (m_runningCount == 0) { -#ifdef QT_PA_DEBUG - qDebug() << this << "uploadSample: return due to 0 m_runningCount"; -#endif - return; - } -#ifdef QT_PA_DEBUG - qDebug() << this << "uploadSample: m_runningCount =" << m_runningCount; -#endif - if (m_position == m_sample->data().size()) { - m_position = 0; - if (m_runningCount > 0) - m_runningCount--; - if (m_runningCount == 0) { - return; - } - } - - int writtenBytes = 0; - int writableSize = int(pa_stream_writable_size(m_pulseStream)); - int firstPartLength = qMin(m_sample->data().size() - m_position, writableSize); - if (pa_stream_write(m_pulseStream, reinterpret_cast(const_cast(m_sample->data().data()) + m_position), - firstPartLength, stream_write_done_callback, 0, PA_SEEK_RELATIVE) != 0) { - qWarning("QSoundEffect(pulseaudio): pa_stream_write, error = %s", pa_strerror(pa_context_errno(daemon()->context()))); - } - writtenBytes = firstPartLength; - m_position += firstPartLength; - if (m_position == m_sample->data().size()) { - m_position = 0; - if (m_runningCount > 0) - m_runningCount--; - if (m_runningCount != 0 && firstPartLength < writableSize) - { - while (writtenBytes < writableSize) { - int writeSize = qMin(writableSize - writtenBytes, m_sample->data().size()); - if (pa_stream_write(m_pulseStream, reinterpret_cast(const_cast(m_sample->data().data())), - writeSize, stream_write_done_callback, 0, PA_SEEK_RELATIVE) != 0) { - qWarning("QSoundEffect(pulseaudio): pa_stream_write, error = %s", pa_strerror(pa_context_errno(daemon()->context()))); - } - writtenBytes += writeSize; - if (writeSize < m_sample->data().size()) { - m_position = writeSize; - break; - } - if (m_runningCount > 0) - m_runningCount--; - if (m_runningCount == 0) - break; - } - } - } -#ifdef QT_PA_DEBUG - qDebug() << this << "uploadSample: use direct write, writeable size =" << writableSize - << "actual writtenBytes =" << writtenBytes; -#endif -} - -void QSoundEffectPrivate::playSample() -{ -#ifdef QT_PA_DEBUG - qDebug() << this << "playSample"; -#endif - Q_ASSERT(m_pulseStream); - pa_operation_unref(pa_stream_cork(m_pulseStream, 0, 0, 0)); -} - -void QSoundEffectPrivate::stop() -{ -#ifdef QT_PA_DEBUG - qDebug() << this << "stop"; -#endif - if (!m_playing) - return; - setPlaying(false); - PulseDaemonLocker locker; - m_stopping = true; - if (m_pulseStream) - emptyStream(); - m_runningCount = 0; - m_position = 0; - m_playQueued = false; -} - -void QSoundEffectPrivate::underRun() -{ - stop(); -} - -void QSoundEffectPrivate::streamReady() -{ -#ifdef QT_PA_DEBUG - qDebug() << this << "streamReady"; -#endif - PulseDaemonLocker locker; - m_sinkInputId = pa_stream_get_index(m_pulseStream); - updateMuted(); - updateVolume(); -#ifdef QT_PA_DEBUG - const pa_buffer_attr *realBufAttr = pa_stream_get_buffer_attr(m_pulseStream); - qDebug() << this << "m_sinkInputId =" << m_sinkInputId - << "tlength =" << realBufAttr->tlength << "maxlength =" << realBufAttr->maxlength - << "minreq = " << realBufAttr->minreq << "prebuf =" << realBufAttr->prebuf; -#endif - prepare(); - setStatus(QSoundEffect::Ready); -} - -void QSoundEffectPrivate::createPulseStream() -{ -#ifdef QT_PA_DEBUG - qDebug() << this << "createPulseStream"; -#endif - - pa_proplist *propList = pa_proplist_new(); - pa_proplist_sets(propList, PA_PROP_MEDIA_ROLE, "soundeffect"); - pa_stream *stream = pa_stream_new_with_proplist(daemon()->context(), m_name.constData(), &m_pulseSpec, 0, propList); - pa_proplist_free(propList); - - connect(daemon(), SIGNAL(volumeChanged()), this, SLOT(updateVolume())); - - if (stream == 0) { - qWarning("QSoundEffect(pulseaudio): Failed to create stream"); - m_pulseStream = 0; - setStatus(QSoundEffect::Error); - setPlaying(false); - return; - } - else { - pa_stream_set_state_callback(stream, stream_state_callback, this); - pa_stream_set_write_callback(stream, stream_write_callback, this); - pa_stream_set_underflow_callback(stream, stream_underrun_callback, this); - } - m_pulseStream = stream; - -#ifndef QTM_PULSEAUDIO_DEFAULTBUFFER - pa_buffer_attr bufferAttr; - bufferAttr.tlength = qMin(m_sample->data().size(), QT_PA_STREAM_BUFFER_SIZE_MAX); - bufferAttr.maxlength = -1; - bufferAttr.minreq = bufferAttr.tlength / 2; - bufferAttr.prebuf = -1; - bufferAttr.fragsize = -1; - if (pa_stream_connect_playback(m_pulseStream, 0, &bufferAttr, -#else - if (pa_stream_connect_playback(m_pulseStream, 0, 0, -#endif - m_muted ? pa_stream_flags_t(PA_STREAM_START_MUTED | PA_STREAM_START_CORKED) - : pa_stream_flags_t(PA_STREAM_START_UNMUTED | PA_STREAM_START_CORKED), - 0, 0) < 0) { - qWarning("QSoundEffect(pulseaudio): Failed to connect stream, error = %s", - pa_strerror(pa_context_errno(daemon()->context()))); - } -} - -void QSoundEffectPrivate::contextReady() -{ - disconnect(daemon(), SIGNAL(contextReady()), this, SLOT(contextReady())); - PulseDaemonLocker locker; - createPulseStream(); -} - -void QSoundEffectPrivate::stream_write_callback(pa_stream *s, size_t length, void *userdata) -{ - Q_UNUSED(length); - Q_UNUSED(s) - - QSoundEffectPrivate *self = reinterpret_cast(userdata); -#ifdef QT_PA_DEBUG - qDebug() << self << "stream_write_callback"; -#endif - self->uploadSample(); -} - -void QSoundEffectPrivate::stream_state_callback(pa_stream *s, void *userdata) -{ - QSoundEffectPrivate *self = reinterpret_cast(userdata); - switch (pa_stream_get_state(s)) { - case PA_STREAM_READY: - { -#ifdef QT_PA_DEBUG - qDebug() << self << "pulse stream ready"; -#endif - const pa_buffer_attr *bufferAttr = pa_stream_get_buffer_attr(self->m_pulseStream); - self->m_pulseBufferSize = bufferAttr->tlength; - if (bufferAttr->prebuf > uint32_t(self->m_sample->data().size())) { - pa_buffer_attr newBufferAttr; - newBufferAttr = *bufferAttr; - newBufferAttr.prebuf = self->m_sample->data().size(); - pa_stream_set_buffer_attr(self->m_pulseStream, &newBufferAttr, stream_adjust_prebuffer_callback, userdata); - } else { - QMetaObject::invokeMethod(self, "streamReady", Qt::QueuedConnection); - } - break; - } - case PA_STREAM_CREATING: -#ifdef QT_PA_DEBUG - qDebug() << self << "pulse stream creating"; -#endif - break; - case PA_STREAM_TERMINATED: -#ifdef QT_PA_DEBUG - qDebug() << self << "pulse stream terminated"; -#endif - break; - - case PA_STREAM_FAILED: - default: - qWarning("QSoundEffect(pulseaudio): Error in pulse audio stream"); - break; - } -} - -void QSoundEffectPrivate::stream_reset_buffer_callback(pa_stream *s, int success, void *userdata) -{ - Q_UNUSED(s); - if (!success) - qWarning("QSoundEffect(pulseaudio): faild to reset buffer attribute"); - QSoundEffectPrivate *self = reinterpret_cast(userdata); -#ifdef QT_PA_DEBUG - qDebug() << self << "stream_reset_buffer_callback"; -#endif - const pa_buffer_attr *bufferAttr = pa_stream_get_buffer_attr(self->m_pulseStream); - self->m_pulseBufferSize = bufferAttr->tlength; - if (bufferAttr->prebuf > uint32_t(self->m_sample->data().size())) { - pa_buffer_attr newBufferAttr; - newBufferAttr = *bufferAttr; - newBufferAttr.prebuf = self->m_sample->data().size(); - pa_stream_set_buffer_attr(self->m_pulseStream, &newBufferAttr, stream_adjust_prebuffer_callback, userdata); - } else { - QMetaObject::invokeMethod(self, "streamReady", Qt::QueuedConnection); - } -} - -void QSoundEffectPrivate::stream_adjust_prebuffer_callback(pa_stream *s, int success, void *userdata) -{ - Q_UNUSED(s); - if (!success) - qWarning("QSoundEffect(pulseaudio): faild to adjust pre-buffer attribute"); - QSoundEffectPrivate *self = reinterpret_cast(userdata); -#ifdef QT_PA_DEBUG - qDebug() << self << "stream_adjust_prebuffer_callback"; -#endif - QMetaObject::invokeMethod(self, "streamReady", Qt::QueuedConnection); -} - -void QSoundEffectPrivate::setvolume_callback(pa_context *c, int success, void *userdata) -{ - Q_UNUSED(c); - Q_UNUSED(userdata); -#ifdef QT_PA_DEBUG - qDebug() << reinterpret_cast(userdata) << "setvolume_callback"; -#endif - if (!success) { - qWarning("QSoundEffect(pulseaudio): faild to set volume"); - } -} - -void QSoundEffectPrivate::setmuted_callback(pa_context *c, int success, void *userdata) -{ - Q_UNUSED(c); - Q_UNUSED(userdata); -#ifdef QT_PA_DEBUG - qDebug() << reinterpret_cast(userdata) << "setmuted_callback"; -#endif - if (!success) { - qWarning("QSoundEffect(pulseaudio): faild to set muted"); - } -} - -void QSoundEffectPrivate::stream_underrun_callback(pa_stream *s, void *userdata) -{ - Q_UNUSED(s); - QSoundEffectPrivate *self = reinterpret_cast(userdata); -#ifdef QT_PA_DEBUG - qDebug() << self << "stream_underrun_callback"; -#endif - if (self->m_runningCount == 0 && !self->m_playQueued) - QMetaObject::invokeMethod(self, "underRun", Qt::QueuedConnection); -#ifdef QT_PA_DEBUG - else - qDebug() << "underun corked =" << pa_stream_is_corked(s); -#endif -} - -void QSoundEffectPrivate::stream_cork_callback(pa_stream *s, int success, void *userdata) -{ - Q_UNUSED(s); - if (!success) - qWarning("QSoundEffect(pulseaudio): faild to stop"); - QSoundEffectPrivate *self = reinterpret_cast(userdata); -#ifdef QT_PA_DEBUG - qDebug() << self << "stream_cork_callback"; -#endif - QMetaObject::invokeMethod(self, "prepare", Qt::QueuedConnection); -} - -void QSoundEffectPrivate::stream_flush_callback(pa_stream *s, int success, void *userdata) -{ - Q_UNUSED(s); - if (!success) - qWarning("QSoundEffect(pulseaudio): faild to drain"); - QSoundEffectPrivate *self = reinterpret_cast(userdata); -#ifdef QT_PA_DEBUG - qDebug() << self << "stream_flush_callback"; -#endif - QMetaObject::invokeMethod(self, "emptyComplete", Qt::QueuedConnection); -} - -void QSoundEffectPrivate::stream_write_done_callback(void *p) -{ - Q_UNUSED(p); -#ifdef QT_PA_DEBUG - qDebug() << "stream_write_done_callback"; -#endif -} - -QT_END_NAMESPACE - -#include "moc_qsoundeffect_pulse_p.cpp" -#include "qsoundeffect_pulse_p.moc" diff --git a/src/multimediakit/effects/qsoundeffect_pulse_p.h b/src/multimediakit/effects/qsoundeffect_pulse_p.h deleted file mode 100644 index c78bcdec5..000000000 --- a/src/multimediakit/effects/qsoundeffect_pulse_p.h +++ /dev/null @@ -1,163 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QSOUNDEFFECT_PULSE_H -#define QSOUNDEFFECT_PULSE_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 "qsoundeffect_p.h" - -#include -#include -#include -#include -#include "qsamplecache_p.h" - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -QT_MODULE(Multimedia) - - -class QSoundEffectPrivate : public QObject -{ - Q_OBJECT -public: - explicit QSoundEffectPrivate(QObject* parent); - ~QSoundEffectPrivate(); - - static QStringList supportedMimeTypes(); - - QUrl source() const; - void setSource(const QUrl &url); - int loopCount() const; - void setLoopCount(int loopCount); - int volume() const; - void setVolume(int volume); - bool isMuted() const; - void setMuted(bool muted); - bool isLoaded() const; - bool isPlaying() const; - QSoundEffect::Status status() const; - -public Q_SLOTS: - void play(); - void stop(); - -Q_SIGNALS: - void volumeChanged(); - void mutedChanged(); - void loadedChanged(); - void playingChanged(); - void statusChanged(); - -private Q_SLOTS: - void decoderError(); - void sampleReady(); - void uploadSample(); - void contextReady(); - void underRun(); - void prepare(); - void streamReady(); - void emptyComplete(); - void updateVolume(); - void updateMuted(); - -private: - void playSample(); - - void emptyStream(); - void createPulseStream(); - void unloadPulseStream(); - - void setPlaying(bool playing); - void setStatus(QSoundEffect::Status status); - - static void stream_write_callback(pa_stream *s, size_t length, void *userdata); - static void stream_state_callback(pa_stream *s, void *userdata); - static void stream_underrun_callback(pa_stream *s, void *userdata); - static void stream_cork_callback(pa_stream *s, int success, void *userdata); - static void stream_flush_callback(pa_stream *s, int success, void *userdata); - static void stream_write_done_callback(void *p); - static void stream_adjust_prebuffer_callback(pa_stream *s, int success, void *userdata); - static void stream_reset_buffer_callback(pa_stream *s, int success, void *userdata); - static void setvolume_callback(pa_context *c, int success, void *userdata); - static void setmuted_callback(pa_context *c, int success, void *userdata); - - pa_stream *m_pulseStream; - int m_sinkInputId; - pa_sample_spec m_pulseSpec; - int m_pulseBufferSize; - - bool m_emptying; - bool m_sampleReady; - bool m_playing; - QSoundEffect::Status m_status; - bool m_muted; - bool m_playQueued; - bool m_stopping; - int m_volume; - int m_loopCount; - int m_runningCount; - QUrl m_source; - QByteArray m_name; - - QSample *m_sample; - int m_position; -}; - -QT_END_NAMESPACE - -QT_END_HEADER - -#endif // QSOUNDEFFECT_PULSE_H diff --git a/src/multimediakit/effects/qsoundeffect_qmedia_p.cpp b/src/multimediakit/effects/qsoundeffect_qmedia_p.cpp deleted file mode 100644 index dfd56b09c..000000000 --- a/src/multimediakit/effects/qsoundeffect_qmedia_p.cpp +++ /dev/null @@ -1,233 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -// -// 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. -// -// INTERNAL USE ONLY: Do NOT use for any other purpose. -// - -#include "qsoundeffect_qmedia_p.h" - -#include - -#include "qmediacontent.h" -#include "qmediaplayer.h" - - -QT_BEGIN_NAMESPACE - -QSoundEffectPrivate::QSoundEffectPrivate(QObject* parent): - QObject(parent), - m_loopCount(1), - m_runningCount(0), - m_player(0), - m_status(QSoundEffect::Null), - m_playing(false) -{ - m_player = new QMediaPlayer(this, QMediaPlayer::LowLatency); - connect(m_player, SIGNAL(stateChanged(QMediaPlayer::State)), SLOT(stateChanged(QMediaPlayer::State))); - connect(m_player, SIGNAL(mediaStatusChanged(QMediaPlayer::MediaStatus)), SLOT(mediaStatusChanged(QMediaPlayer::MediaStatus))); - connect(m_player, SIGNAL(error(QMediaPlayer::Error)), SLOT(error(QMediaPlayer::Error))); - connect(m_player, SIGNAL(mutedChanged(bool)), SIGNAL(mutedChanged())); - connect(m_player, SIGNAL(volumeChanged(int)), SIGNAL(volumeChanged())); -} - -QSoundEffectPrivate::~QSoundEffectPrivate() -{ -} - -QStringList QSoundEffectPrivate::supportedMimeTypes() -{ - return QMediaPlayer::supportedMimeTypes(); -} - -QUrl QSoundEffectPrivate::source() const -{ - return m_player->media().canonicalUrl(); -} - -void QSoundEffectPrivate::setSource(const QUrl &url) -{ - m_player->setMedia(url); -} - -int QSoundEffectPrivate::loopCount() const -{ - return m_loopCount; -} - -void QSoundEffectPrivate::setLoopCount(int loopCount) -{ - m_loopCount = loopCount; -} - -int QSoundEffectPrivate::volume() const -{ - return m_player->volume(); -} - -void QSoundEffectPrivate::setVolume(int volume) -{ - m_player->setVolume(volume); -} - -bool QSoundEffectPrivate::isMuted() const -{ - return m_player->isMuted(); -} - -void QSoundEffectPrivate::setMuted(bool muted) -{ - m_player->setMuted(muted); -} - -bool QSoundEffectPrivate::isLoaded() const -{ - return m_status == QSoundEffect::Ready; -} - -bool QSoundEffectPrivate::isPlaying() const -{ - return m_playing; -} - -QSoundEffect::Status QSoundEffectPrivate::status() const -{ - return m_status; -} - -void QSoundEffectPrivate::play() -{ - if (m_status == QSoundEffect::Null || m_status == QSoundEffect::Error) - return; - if (m_loopCount < 0) { - m_runningCount = -1; - } - else { - if (m_runningCount < 0) - m_runningCount = 0; - m_runningCount += m_loopCount; - } - m_player->play(); -} - -void QSoundEffectPrivate::stop() -{ - m_runningCount = 0; - m_player->stop(); -} - -void QSoundEffectPrivate::stateChanged(QMediaPlayer::State state) -{ - if (state == QMediaPlayer::StoppedState) { - if (m_runningCount < 0) { - m_player->play(); - } else if (m_runningCount == 0) { - setPlaying(false); - return; - } else if (--m_runningCount > 0) { - m_player->play(); - } else { - setPlaying(false); - } - } else { - setPlaying(true); - } -} - -void QSoundEffectPrivate::mediaStatusChanged(QMediaPlayer::MediaStatus status) -{ - switch(status) { - case QMediaPlayer::LoadingMedia: - setStatus(QSoundEffect::Loading); - break; - case QMediaPlayer::NoMedia: - setStatus(QSoundEffect::Null); - break; - case QMediaPlayer::InvalidMedia: - setStatus(QSoundEffect::Error); - break; - default: - setStatus(QSoundEffect::Ready); - break; - } -} - -void QSoundEffectPrivate::error(QMediaPlayer::Error err) -{ - bool playingDirty = false; - if (m_playing) { - m_playing = false; - playingDirty = true; - } - setStatus(QSoundEffect::Error); - if (playingDirty) - emit playingChanged(); -} - -void QSoundEffectPrivate::setStatus(QSoundEffect::Status status) -{ - if (m_status == status) - return; - bool oldLoaded = isLoaded(); - m_status = status; - emit statusChanged(); - if (oldLoaded != isLoaded()) - emit loadedChanged(); -} - -void QSoundEffectPrivate::setPlaying(bool playing) -{ - if (m_playing == playing) - return; - m_playing = playing; - emit playingChanged(); -} - -QT_END_NAMESPACE - -#include "moc_qsoundeffect_qmedia_p.cpp" diff --git a/src/multimediakit/effects/qsoundeffect_qmedia_p.h b/src/multimediakit/effects/qsoundeffect_qmedia_p.h deleted file mode 100644 index adafa04a2..000000000 --- a/src/multimediakit/effects/qsoundeffect_qmedia_p.h +++ /dev/null @@ -1,122 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QSOUNDEFFECT_QMEDIA_H -#define QSOUNDEFFECT_QMEDIA_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 -#include -#include "qmediaplayer.h" -#include "qsoundeffect_p.h" - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -QT_MODULE(Multimedia) - - - -class QSoundEffectPrivate : public QObject -{ - Q_OBJECT -public: - - explicit QSoundEffectPrivate(QObject* parent); - ~QSoundEffectPrivate(); - - static QStringList supportedMimeTypes(); - - QUrl source() const; - void setSource(const QUrl &url); - int loopCount() const; - void setLoopCount(int loopCount); - int volume() const; - void setVolume(int volume); - bool isMuted() const; - void setMuted(bool muted); - bool isLoaded() const; - bool isPlaying() const; - QSoundEffect::Status status() const; - -public Q_SLOTS: - void play(); - void stop(); - -Q_SIGNALS: - void volumeChanged(); - void mutedChanged(); - void loadedChanged(); - void playingChanged(); - void statusChanged(); - -private Q_SLOTS: - void stateChanged(QMediaPlayer::State); - void mediaStatusChanged(QMediaPlayer::MediaStatus); - void error(QMediaPlayer::Error); - -private: - void setStatus(QSoundEffect::Status status); - void setPlaying(bool playing); - - int m_loopCount; - int m_runningCount; - bool m_playing; - QSoundEffect::Status m_status; - QMediaPlayer *m_player; -}; - -QT_END_NAMESPACE - -QT_END_HEADER - -#endif // QSOUNDEFFECT_QMEDIA_H diff --git a/src/multimediakit/effects/qsoundeffect_qsound_p.cpp b/src/multimediakit/effects/qsoundeffect_qsound_p.cpp deleted file mode 100644 index 0b9082eb5..000000000 --- a/src/multimediakit/effects/qsoundeffect_qsound_p.cpp +++ /dev/null @@ -1,222 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -// -// 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. -// -// INTERNAL USE ONLY: Do NOT use for any other purpose. -// - -#include "qsoundeffect_qsound_p.h" - -#include -#include -#include - - -QT_BEGIN_NAMESPACE - -QSoundEffectPrivate::QSoundEffectPrivate(QObject* parent): - QObject(parent), - m_playing(false), - m_timerID(0), - m_muted(false), - m_loopCount(1), - m_volume(100), - m_status(QSoundEffect::Null), - m_sound(0) -{ - if (!QSound::isAvailable()) - qWarning("SoundEffect(qsound) : not available"); -} - -QSoundEffectPrivate::~QSoundEffectPrivate() -{ -} - -QStringList QSoundEffectPrivate::supportedMimeTypes() -{ - QStringList supportedTypes; - supportedTypes << QLatin1String("audio/x-wav") << QLatin1String("audio/vnd.wave") ; - return supportedTypes; -} - -QUrl QSoundEffectPrivate::source() const -{ - return m_source; -} - -void QSoundEffectPrivate::setSource(const QUrl &url) -{ - if (url.isEmpty()) { - m_source = QUrl(); - setStatus(QSoundEffect::Null); - return; - } - - if (url.scheme() != QLatin1String("file")) { - m_source = url; - setStatus(QSoundEffect::Error); - return; - } - - if (m_sound != 0) - delete m_sound; - - m_source = url; - m_sound = new QSound(m_source.toLocalFile(), this); - m_sound->setLoops(m_loopCount); - m_status = QSoundEffect::Ready; - emit statusChanged(); - emit loadedChanged(); -} - -int QSoundEffectPrivate::loopCount() const -{ - return m_loopCount; -} - -void QSoundEffectPrivate::setLoopCount(int lc) -{ - m_loopCount = lc; - if (m_sound) - m_sound->setLoops(lc); -} - -int QSoundEffectPrivate::volume() const -{ - return m_volume; -} - -void QSoundEffectPrivate::setVolume(int v) -{ - m_volume = v; -} - -bool QSoundEffectPrivate::isMuted() const -{ - return m_muted; -} - -void QSoundEffectPrivate::setMuted(bool muted) -{ - m_muted = muted; -} - -bool QSoundEffectPrivate::isLoaded() const -{ - return m_status == QSoundEffect::Ready; -} - -void QSoundEffectPrivate::play() -{ - if (m_status == QSoundEffect::Null || m_status == QSoundEffect::Error) - return; - if (m_timerID != 0) - killTimer(m_timerID); - m_timerID = startTimer(500); - m_sound->play(); - setPlaying(true); -} - - -void QSoundEffectPrivate::stop() -{ - if (m_timerID != 0) - killTimer(m_timerID); - m_timerID = 0; - m_sound->stop(); - setPlaying(false); -} - -bool QSoundEffectPrivate::isPlaying() -{ - if (m_playing && m_sound && m_sound->isFinished()) { - if (m_timerID != 0) - killTimer(m_timerID); - m_timerID = 0; - setPlaying(false); - } - return m_playing; -} - -QSoundEffect::Status QSoundEffectPrivate::status() const -{ - return m_status; -} - -void QSoundEffectPrivate::timerEvent(QTimerEvent *event) -{ - Q_UNUSED(event); - setPlaying(!m_sound->isFinished()); - if (isPlaying()) - return; - killTimer(m_timerID); - m_timerID = 0; -} - -void QSoundEffectPrivate::setStatus(QSoundEffect::Status status) -{ - if (m_status == status) - return; - bool oldLoaded = isLoaded(); - m_status = status; - emit statusChanged(); - if (oldLoaded != isLoaded()) - emit loadedChanged(); -} - -void QSoundEffectPrivate::setPlaying(bool playing) -{ - if (m_playing == playing) - return; - m_playing = playing; - emit playingChanged(); -} - -QT_END_NAMESPACE - -#include "moc_qsoundeffect_qsound_p.cpp" diff --git a/src/multimediakit/effects/qsoundeffect_qsound_p.h b/src/multimediakit/effects/qsoundeffect_qsound_p.h deleted file mode 100644 index c98ad79ce..000000000 --- a/src/multimediakit/effects/qsoundeffect_qsound_p.h +++ /dev/null @@ -1,121 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QSOUNDEFFECT_QSOUND_H -#define QSOUNDEFFECT_QSOUND_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 -#include -#include "qsoundeffect_p.h" - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -QT_MODULE(Multimedia) - - -class QSound; - -class QSoundEffectPrivate : public QObject -{ - Q_OBJECT -public: - explicit QSoundEffectPrivate(QObject* parent); - ~QSoundEffectPrivate(); - - static QStringList supportedMimeTypes(); - - QUrl source() const; - void setSource(const QUrl &url); - int loopCount() const; - void setLoopCount(int loopCount); - int volume() const; - void setVolume(int volume); - bool isMuted() const; - void setMuted(bool muted); - bool isLoaded() const; - bool isPlaying(); - QSoundEffect::Status status() const; - -public Q_SLOTS: - void play(); - void stop(); - -Q_SIGNALS: - void volumeChanged(); - void mutedChanged(); - void loadedChanged(); - void playingChanged(); - void statusChanged(); - -private: - void setStatus(QSoundEffect::Status status); - void setPlaying(bool playing); - void timerEvent(QTimerEvent *event); - - bool m_playing; - int m_timerID; - bool m_muted; - int m_loopCount; - int m_volume; - QSoundEffect::Status m_status; - QSound *m_sound; - QUrl m_source; -}; - -QT_END_NAMESPACE - -QT_END_HEADER - -#endif // QSOUNDEFFECT_QSOUND_H diff --git a/src/multimediakit/effects/qwavedecoder_p.cpp b/src/multimediakit/effects/qwavedecoder_p.cpp deleted file mode 100644 index 19b262adc..000000000 --- a/src/multimediakit/effects/qwavedecoder_p.cpp +++ /dev/null @@ -1,232 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qwavedecoder_p.h" - -#include -#include - -QT_BEGIN_NAMESPACE - -QWaveDecoder::QWaveDecoder(QIODevice *s, QObject *parent): - QIODevice(parent), - haveFormat(false), - dataSize(0), - remaining(0), - source(s), - state(QWaveDecoder::InitialState) -{ - open(QIODevice::ReadOnly | QIODevice::Unbuffered); - - if (enoughDataAvailable()) - QTimer::singleShot(0, this, SLOT(handleData())); - else - connect(source, SIGNAL(readyRead()), SLOT(handleData())); -} - -QWaveDecoder::~QWaveDecoder() -{ -} - -QAudioFormat QWaveDecoder::audioFormat() const -{ - return format; -} - -int QWaveDecoder::duration() const -{ - return size() * 1000 / (format.sampleSize() / 8) / format.channels() / format.frequency(); -} - -qint64 QWaveDecoder::size() const -{ - return haveFormat ? dataSize : 0; -} - -bool QWaveDecoder::isSequential() const -{ - return source->isSequential(); -} - -qint64 QWaveDecoder::bytesAvailable() const -{ - return haveFormat ? source->bytesAvailable() : 0; -} - -qint64 QWaveDecoder::readData(char *data, qint64 maxlen) -{ - return haveFormat ? source->read(data, maxlen) : 0; -} - -qint64 QWaveDecoder::writeData(const char *data, qint64 len) -{ - Q_UNUSED(data); - Q_UNUSED(len); - - return -1; -} - -void QWaveDecoder::handleData() -{ - if (state == QWaveDecoder::InitialState) { - if (source->bytesAvailable() < qint64(sizeof(RIFFHeader))) - return; - - RIFFHeader riff; - source->read(reinterpret_cast(&riff), sizeof(RIFFHeader)); - - if (qstrncmp(riff.descriptor.id, "RIFF", 4) != 0 || - qstrncmp(riff.type, "WAVE", 4) != 0) { - source->disconnect(SIGNAL(readyRead()), this, SLOT(handleData())); - emit invalidFormat(); - - return; - } else { - state = QWaveDecoder::WaitingForFormatState; - } - } - - if (state == QWaveDecoder::WaitingForFormatState) { - if (findChunk("fmt ")) { - chunk descriptor; - source->peek(reinterpret_cast(&descriptor), sizeof(chunk)); - - if (source->bytesAvailable() < qint64(descriptor.size + sizeof(chunk))) - return; - - WAVEHeader wave; - source->read(reinterpret_cast(&wave), sizeof(WAVEHeader)); - if (descriptor.size > sizeof(WAVEHeader)) - discardBytes(descriptor.size - sizeof(WAVEHeader)); - - if (wave.audioFormat != 0 && wave.audioFormat != 1) { - source->disconnect(SIGNAL(readyRead()), this, SLOT(handleData())); - emit invalidFormat(); - - return; - } else { - int bps = qFromLittleEndian(wave.bitsPerSample); - - format.setCodec(QLatin1String("audio/pcm")); - format.setSampleType(bps == 8 ? QAudioFormat::UnSignedInt : QAudioFormat::SignedInt); - format.setByteOrder(QAudioFormat::LittleEndian); - format.setFrequency(qFromLittleEndian(wave.sampleRate)); - format.setSampleSize(bps); - format.setChannels(qFromLittleEndian(wave.numChannels)); - - state = QWaveDecoder::WaitingForDataState; - } - } - } - - if (state == QWaveDecoder::WaitingForDataState) { - if (findChunk("data")) { - source->disconnect(SIGNAL(readyRead()), this, SLOT(handleData())); - - chunk descriptor; - source->read(reinterpret_cast(&descriptor), sizeof(chunk)); - dataSize = descriptor.size; - - haveFormat = true; - connect(source, SIGNAL(readyRead()), SIGNAL(readyRead())); - emit formatKnown(); - - return; - } - } - - if (source->atEnd()) { - source->disconnect(SIGNAL(readyRead()), this, SLOT(handleData())); - emit invalidFormat(); - - return; - } - -} - -bool QWaveDecoder::enoughDataAvailable() -{ - if (source->bytesAvailable() < qint64(sizeof(chunk))) - return false; - - chunk descriptor; - source->peek(reinterpret_cast(&descriptor), sizeof(chunk)); - - if (source->bytesAvailable() < qint64(sizeof(chunk) + descriptor.size)) - return false; - - return true; -} - -bool QWaveDecoder::findChunk(const char *chunkId) -{ - if (source->bytesAvailable() < qint64(sizeof(chunk))) - return false; - - chunk descriptor; - source->peek(reinterpret_cast(&descriptor), sizeof(chunk)); - - if (qstrncmp(descriptor.id, chunkId, 4) == 0) - return true; - - while (source->bytesAvailable() >= qint64(sizeof(chunk) + descriptor.size)) { - discardBytes(sizeof(chunk) + descriptor.size); - - source->peek(reinterpret_cast(&descriptor), sizeof(chunk)); - - if (qstrncmp(descriptor.id, chunkId, 4) == 0) - return true; - } - - return false; -} - -void QWaveDecoder::discardBytes(qint64 numBytes) -{ - if (source->isSequential()) - source->read(numBytes); - else - source->seek(source->pos() + numBytes); -} - -QT_END_NAMESPACE - -#include "moc_qwavedecoder_p.cpp" diff --git a/src/multimediakit/effects/qwavedecoder_p.h b/src/multimediakit/effects/qwavedecoder_p.h deleted file mode 100644 index 6c4c00c25..000000000 --- a/src/multimediakit/effects/qwavedecoder_p.h +++ /dev/null @@ -1,137 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef WAVEDECODER_H -#define WAVEDECODER_H - -// -// W A R N I N G -// ------------- -// -// This file is not part of the Qt API. It exists for the convenience -// of other Qt classes. This header file may change from version to -// version without notice, or even be removed. -// -// We mean it. -// - -#include -#include - - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -QT_MODULE(Multimedia) - - - -class QWaveDecoder : public QIODevice -{ - Q_OBJECT - -public: - explicit QWaveDecoder(QIODevice *source, QObject *parent = 0); - ~QWaveDecoder(); - - QAudioFormat audioFormat() const; - int duration() const; - - qint64 size() const; - bool isSequential() const; - qint64 bytesAvailable() const; - -Q_SIGNALS: - void formatKnown(); - void invalidFormat(); - -private Q_SLOTS: - void handleData(); - -private: - qint64 readData(char *data, qint64 maxlen); - qint64 writeData(const char *data, qint64 len); - - bool enoughDataAvailable(); - bool findChunk(const char *chunkId); - void discardBytes(qint64 numBytes); - - enum State { - InitialState, - WaitingForFormatState, - WaitingForDataState - }; - - struct chunk - { - char id[4]; - quint32 size; - }; - struct RIFFHeader - { - chunk descriptor; - char type[4]; - }; - struct WAVEHeader - { - chunk descriptor; - quint16 audioFormat; - quint16 numChannels; - quint32 sampleRate; - quint32 byteRate; - quint16 blockAlign; - quint16 bitsPerSample; - }; - - bool haveFormat; - qint64 dataSize; - qint64 remaining; - QAudioFormat format; - QIODevice *source; - State state; -}; - -QT_END_NAMESPACE - -QT_END_HEADER - -#endif // WAVEDECODER_H diff --git a/src/multimediakit/multimediakit.pro b/src/multimediakit/multimediakit.pro deleted file mode 100644 index 968832651..000000000 --- a/src/multimediakit/multimediakit.pro +++ /dev/null @@ -1,157 +0,0 @@ -load(qt_module) - -# distinct from QtMultimedia -TARGET = QtMultimediaKit -QPRO_PWD = $$PWD -QT = core network gui - -CONFIG += module -MODULE_PRI += ../../modules/qt_multimediakit.pri - -contains(QT_CONFIG, opengl) | contains(QT_CONFIG, opengles2) { -} else { - DEFINES += QT_NO_OPENGL -} - -!static:DEFINES += QT_MAKEDLL -DEFINES += QT_BUILD_MULTIMEDIA_LIB - -load(qt_module_config) - -HEADERS += qtmultimediakitversion.h - - -PRIVATE_HEADERS += \ - qmediacontrol_p.h \ - qmediaobject_p.h \ - qmediaservice_p.h \ - qmediaplaylist_p.h \ - qmediaplaylistprovider_p.h \ - qmediaimageviewerservice_p.h \ - qmediapluginloader_p.h \ - qvideosurfaceoutput_p.h - -PUBLIC_HEADERS += \ - qmediacontrol.h \ - qmediaobject.h \ - qmediaservice.h \ - qmediabindableinterface.h \ - qlocalmediaplaylistprovider.h \ - qmediaimageviewer.h \ - qmediaplayer.h \ - qmediaplayercontrol.h \ - qmediaplaylist.h \ - qmediaplaylistnavigator.h \ - qmediaplaylistprovider.h \ - qmediaplaylistioplugin.h \ - qmediabackgroundplaybackcontrol.h \ - qmediacontent.h \ - qmediaresource.h \ - qmediarecorder.h \ - qmediaencodersettings.h \ - qmediarecordercontrol.h \ - qmediaserviceprovider.h \ - qmediaserviceproviderplugin.h \ - qmetadatareadercontrol.h \ - qmetadatawritercontrol.h \ - qmediastreamscontrol.h \ - qradiotuner.h \ - qradiotunercontrol.h \ - qtmedianamespace.h \ - qaudioencodercontrol.h \ - qvideoencodercontrol.h \ - qimageencodercontrol.h \ - qaudiocapturesource.h \ - qmediacontainercontrol.h \ - qmediaplaylistcontrol.h \ - qmediaplaylistsourcecontrol.h \ - qaudioendpointselector.h \ - qvideodevicecontrol.h \ - qvideorenderercontrol.h \ - qmediatimerange.h \ - qmedianetworkaccesscontrol.h \ - qmediaenumdebug.h \ - qtmultimediakitdefs.h - -SOURCES += qmediacontrol.cpp \ - qmediaobject.cpp \ - qmediaservice.cpp \ - qmediabindableinterface.cpp \ - qlocalmediaplaylistprovider.cpp \ - qmediaimageviewer.cpp \ - qmediaimageviewerservice.cpp \ - qmediaplayer.cpp \ - qmediaplayercontrol.cpp \ - qmediaplaylist.cpp \ - qmediaplaylistioplugin.cpp \ - qmediaplaylistnavigator.cpp \ - qmediaplaylistprovider.cpp \ - qmediarecorder.cpp \ - qmediaencodersettings.cpp \ - qmediarecordercontrol.cpp \ - qmediacontent.cpp \ - qmediaresource.cpp \ - qmediaserviceprovider.cpp \ - qmetadatareadercontrol.cpp \ - qmetadatawritercontrol.cpp \ - qmediastreamscontrol.cpp \ - qradiotuner.cpp \ - qradiotunercontrol.cpp \ - qaudioencodercontrol.cpp \ - qvideoencodercontrol.cpp \ - qimageencodercontrol.cpp \ - qaudiocapturesource.cpp \ - qmediacontainercontrol.cpp \ - qmediaplaylistcontrol.cpp \ - qmediaplaylistsourcecontrol.cpp \ - qaudioendpointselector.cpp \ - qvideodevicecontrol.cpp \ - qmediapluginloader.cpp \ - qvideorenderercontrol.cpp \ - qmediatimerange.cpp \ - qmedianetworkaccesscontrol.cpp \ - qvideosurfaceoutput.cpp \ - qmediabackgroundplaybackcontrol.cpp - -#Camera -PUBLIC_HEADERS += \ - qcamera.h \ - qcameraimagecapture.h \ - qcameraimagecapturecontrol.h \ - qcameraexposure.h \ - qcamerafocus.h \ - qcameraimageprocessing.h \ - qcameracontrol.h \ - qcameralockscontrol.h \ - qcameraexposurecontrol.h \ - qcamerafocuscontrol.h \ - qcameraflashcontrol.h \ - qcameraimageprocessingcontrol.h \ - qcameracapturedestinationcontrol.h \ - qcameracapturebufferformatcontrol.h - -SOURCES += \ - qcamera.cpp \ - qcameraexposure.cpp \ - qcamerafocus.cpp \ - qcameraimageprocessing.cpp \ - qcameraimagecapture.cpp \ - qcameraimagecapturecontrol.cpp \ - qcameracontrol.cpp \ - qcameralockscontrol.cpp \ - qcameraexposurecontrol.cpp \ - qcamerafocuscontrol.cpp \ - qcameraflashcontrol.cpp \ - qcameraimageprocessingcontrol.cpp \ - qcameracapturedestinationcontrol.cpp \ - qcameracapturebufferformatcontrol.cpp - -include(audio/audio.pri) -include(video/video.pri) -include(effects/effects.pri) - -mac:!qpa { - LIBS += -framework AppKit -framework QuartzCore -framework QTKit -} - -HEADERS += $$PUBLIC_HEADERS $$PRIVATE_HEADERS diff --git a/src/multimediakit/qaudiocapturesource.cpp b/src/multimediakit/qaudiocapturesource.cpp deleted file mode 100644 index efd6a6245..000000000 --- a/src/multimediakit/qaudiocapturesource.cpp +++ /dev/null @@ -1,275 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qmediaobject_p.h" -#include -#include "qaudioendpointselector.h" - -QT_BEGIN_NAMESPACE - -/*! - \class QAudioCaptureSource - \brief The QAudioCaptureSource class provides an interface to query and select an audio input endpoint. - \inmodule QtMultimediaKit - \ingroup multimedia - \since 1.0 - - QAudioCaptureSource provides access to the audio inputs available on your system. - - You can query these inputs and select one to use. - - A typical implementation example: - \snippet doc/src/snippets/multimedia-snippets/media.cpp Audio capture source - - The audiocapturesource interface is then used to: - - - Get and Set the audio input to use. - - The capture interface is then used to: - - - Set the destination using setOutputLocation() - - - Set the format parameters using setAudioCodec(), - - - Control the recording using record(),stop() - - \sa QMediaRecorder -*/ - -class QAudioCaptureSourcePrivate : public QMediaObjectPrivate -{ -public: - Q_DECLARE_PUBLIC(QAudioCaptureSource) - - void initControls() - { - Q_Q(QAudioCaptureSource); - - if (service != 0) - audioEndpointSelector = qobject_cast(service->requestControl(QAudioEndpointSelector_iid)); - - if (audioEndpointSelector) { - q->connect(audioEndpointSelector, SIGNAL(activeEndpointChanged(const QString&)), - SIGNAL(activeAudioInputChanged(const QString&))); - q->connect(audioEndpointSelector, SIGNAL(availableEndpointsChanged()), - SIGNAL(availableAudioInputsChanged())); - q->connect(audioEndpointSelector, SIGNAL(availableEndpointsChanged()), - SLOT(statusChanged())); - errorState = QtMultimediaKit::NoError; - } - } - - QAudioCaptureSourcePrivate():provider(0), audioEndpointSelector(0), errorState(QtMultimediaKit::ServiceMissingError) {} - QMediaServiceProvider *provider; - QAudioEndpointSelector *audioEndpointSelector; - QtMultimediaKit::AvailabilityError errorState; -}; - -/*! - Construct a QAudioCaptureSource using the QMediaService from \a provider, with \a parent. - \since 1.0 -*/ - -QAudioCaptureSource::QAudioCaptureSource(QObject *parent, QMediaServiceProvider *provider): - QMediaObject(*new QAudioCaptureSourcePrivate, parent, provider->requestService(Q_MEDIASERVICE_AUDIOSOURCE)) -{ - Q_D(QAudioCaptureSource); - - d->provider = provider; - d->initControls(); -} - -/*! - Destroys the audiocapturesource object. -*/ - -QAudioCaptureSource::~QAudioCaptureSource() -{ - Q_D(QAudioCaptureSource); - - if (d->service && d->audioEndpointSelector) - d->service->releaseControl(d->audioEndpointSelector); - - if (d->provider) - d->provider->releaseService(d->service); -} - -/*! - Returns the error state of the audio capture service. - \since 1.0 -*/ - -QtMultimediaKit::AvailabilityError QAudioCaptureSource::availabilityError() const -{ - Q_D(const QAudioCaptureSource); - - return d->errorState; -} - -/*! - Returns true if the audio capture service is available, otherwise returns false. - \since 1.0 -*/ -bool QAudioCaptureSource::isAvailable() const -{ - Q_D(const QAudioCaptureSource); - - if (d->service != NULL) { - if (d->audioEndpointSelector && d->audioEndpointSelector->availableEndpoints().size() > 0) - return true; - } - return false; -} - - -/*! - Returns a list of available audio inputs - \since 1.0 -*/ - -QList QAudioCaptureSource::audioInputs() const -{ - Q_D(const QAudioCaptureSource); - - QList list; - if (d && d->audioEndpointSelector) - list <audioEndpointSelector->availableEndpoints(); - - return list; -} - -/*! - Returns the description of the audio input device with \a name. - \since 1.0 -*/ - -QString QAudioCaptureSource::audioDescription(const QString& name) const -{ - Q_D(const QAudioCaptureSource); - - if(d->audioEndpointSelector) - return d->audioEndpointSelector->endpointDescription(name); - else - return QString(); -} - -/*! - Returns the default audio input name. - \since 1.0 -*/ - -QString QAudioCaptureSource::defaultAudioInput() const -{ - Q_D(const QAudioCaptureSource); - - if(d->audioEndpointSelector) - return d->audioEndpointSelector->defaultEndpoint(); - else - return QString(); -} - -/*! - Returns the active audio input name. - \since 1.0 -*/ - -QString QAudioCaptureSource::activeAudioInput() const -{ - Q_D(const QAudioCaptureSource); - - if(d->audioEndpointSelector) - return d->audioEndpointSelector->activeEndpoint(); - else - return QString(); -} - -/*! - Set the active audio input to \a name. - \since 1.0 -*/ - -void QAudioCaptureSource::setAudioInput(const QString& name) -{ - Q_D(const QAudioCaptureSource); - - if(d->audioEndpointSelector) - return d->audioEndpointSelector->setActiveEndpoint(name); -} - -/*! - \fn QAudioCaptureSource::activeAudioInputChanged(const QString& name) - - Signal emitted when active audio input changes to \a name. - \since 1.0 -*/ - -/*! - \fn QAudioCaptureSource::availableAudioInputsChanged() - - Signal is emitted when the available audio inputs change. - \since 1.0 -*/ - -/*! - \internal - \since 1.0 -*/ -void QAudioCaptureSource::statusChanged() -{ - Q_D(QAudioCaptureSource); - - if (d->audioEndpointSelector) { - if (d->audioEndpointSelector->availableEndpoints().size() > 0) { - d->errorState = QtMultimediaKit::NoError; - emit availabilityChanged(true); - } else { - d->errorState = QtMultimediaKit::BusyError; - emit availabilityChanged(false); - } - } else { - d->errorState = QtMultimediaKit::ServiceMissingError; - emit availabilityChanged(false); - } -} - -#include "moc_qaudiocapturesource.cpp" -QT_END_NAMESPACE - diff --git a/src/multimediakit/qaudiocapturesource.h b/src/multimediakit/qaudiocapturesource.h deleted file mode 100644 index e27450514..000000000 --- a/src/multimediakit/qaudiocapturesource.h +++ /dev/null @@ -1,103 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QAUDIOCAPTURESOURCE_H -#define QAUDIOCAPTURESOURCE_H - -#include -#include -#include - -#include - -#include "qmediarecorder.h" -#include "qmediacontrol.h" -#include "qmediaobject.h" -#include "qmediaservice.h" - -#include "qmediaserviceprovider.h" - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -QT_MODULE(Multimedia) - - -class QAudioCaptureSourcePrivate; - -class Q_MULTIMEDIA_EXPORT QAudioCaptureSource : public QMediaObject -{ - Q_OBJECT - -public: - QAudioCaptureSource(QObject *parent = 0, QMediaServiceProvider *service = QMediaServiceProvider::defaultServiceProvider()); - ~QAudioCaptureSource(); - - bool isAvailable() const; - QtMultimediaKit::AvailabilityError availabilityError() const; - - QList audioInputs() const; - - QString audioDescription(const QString& name) const; - QString defaultAudioInput() const; - QString activeAudioInput() const; - -public Q_SLOTS: - void setAudioInput(const QString& name); - -Q_SIGNALS: - void activeAudioInputChanged(const QString& name); - void availableAudioInputsChanged(); - -private Q_SLOTS: - void statusChanged(); - -private: - Q_DECLARE_PRIVATE(QAudioCaptureSource) -}; - -QT_END_NAMESPACE - -QT_END_HEADER - - -#endif // QAUDIOCAPTURESOURCE_H diff --git a/src/multimediakit/qaudioencodercontrol.cpp b/src/multimediakit/qaudioencodercontrol.cpp deleted file mode 100644 index 3308ac639..000000000 --- a/src/multimediakit/qaudioencodercontrol.cpp +++ /dev/null @@ -1,167 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qaudioencodercontrol.h" -#include - -QT_BEGIN_NAMESPACE - - -/*! - \class QAudioEncoderControl - \inmodule QtMultimediaKit - \ingroup multimedia-serv - \since 1.0 - - \brief The QAudioEncoderControl class provides access to the settings of a - media service that performs audio encoding. - - If a QMediaService supports encoding audio data it will implement - QAudioEncoderControl. This control provides information about the limits - of restricted audio encoder options and allows the selection of a set of - audio encoder settings as specified in a QAudioEncoderSettings object. - - The functionality provided by this control is exposed to application code through the - QMediaRecorder class. - - The interface name of QAudioEncoderControl is \c com.nokia.Qt.QAudioEncoderControl/1.0 as - defined in QAudioEncoderControl_iid. - - \sa QMediaService::requestControl(), QMediaRecorder -*/ - -/*! - \macro QAudioEncoderControl_iid - - \c com.nokia.Qt.AudioEncoderControl/1.0 - - Defines the interface name of the QAudioEncoderControl class. - - \relates QAudioEncoderControl -*/ - -/*! - Create a new audio encode control object with the given \a parent. -*/ -QAudioEncoderControl::QAudioEncoderControl(QObject *parent) - :QMediaControl(parent) -{ -} - -/*! - Destroys the audio encode control. -*/ -QAudioEncoderControl::~QAudioEncoderControl() -{ -} - -/*! - \fn QAudioEncoderControl::supportedAudioCodecs() const - - Returns the list of supported audio codec names. - \since 1.0 -*/ - -/*! - \fn QAudioEncoderControl::codecDescription(const QString &codec) const - - Returns description of audio \a codec. - \since 1.0 -*/ - -/*! - \fn QAudioEncoderControl::supportedSampleRates(const QAudioEncoderSettings &settings = QAudioEncoderSettings(), - bool *continuous) const - - Returns the list of supported audio sample rates, if known. - - If non null audio \a settings parameter is passed, - the returned list is reduced to sample rates supported with partial settings applied. - - It can be used for example to query the list of sample rates, supported by specific audio codec. - - If the encoder supports arbitrary sample rates within the supported rates range, - *\a continuous is set to true, otherwise *\a continuous is set to false. - \since 1.0 -*/ - -/*! - \fn QAudioEncoderControl::supportedEncodingOptions(const QString &codec) const - - Returns the list of \a codec specific audio encoding options. - \since 1.0 -*/ - -/*! - \fn QAudioEncoderControl::encodingOption(const QString &codec, const QString &option) const - - Returns the value of audio encoding \a option for \a codec. - \since 1.0 -*/ - -/*! - \fn QAudioEncoderControl::setEncodingOption(const QString &codec, const QString &option, const QVariant &value) - - Set the \a codec specific \a option to \a value. - \since 1.0 -*/ - -/*! - \fn QAudioEncoderControl::audioSettings() const - - Returns the audio encoder settings. - - The returned value may be different tha passed to QAudioEncoderControl::setAudioSettings() - if the settings contains the default or undefined parameters. - In this case if the undefined parameters are already resolved, they should be returned. - \since 1.0 -*/ - -/*! - \fn QAudioEncoderControl::setAudioSettings(const QAudioEncoderSettings &settings) - - Sets the selected audio \a settings. - \since 1.0 -*/ - -#include "moc_qaudioencodercontrol.cpp" -QT_END_NAMESPACE - diff --git a/src/multimediakit/qaudioencodercontrol.h b/src/multimediakit/qaudioencodercontrol.h deleted file mode 100644 index 2e3a4bf87..000000000 --- a/src/multimediakit/qaudioencodercontrol.h +++ /dev/null @@ -1,95 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QAUDIOENCODERCONTROL_H -#define QAUDIOENCODERCONTROL_H - -#include "qmediacontrol.h" -#include "qmediarecorder.h" -#include -#include - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -QT_MODULE(Multimedia) - -class QStringList; -class QAudioFormat; -QT_END_NAMESPACE - -QT_BEGIN_NAMESPACE - -class Q_MULTIMEDIA_EXPORT QAudioEncoderControl : public QMediaControl -{ - Q_OBJECT - -public: - virtual ~QAudioEncoderControl(); - - virtual QStringList supportedAudioCodecs() const = 0; - virtual QString codecDescription(const QString &codecName) const = 0; - - virtual QList supportedSampleRates(const QAudioEncoderSettings &settings, - bool *continuous = 0) const = 0; - - virtual QAudioEncoderSettings audioSettings() const = 0; - virtual void setAudioSettings(const QAudioEncoderSettings&) = 0; - - virtual QStringList supportedEncodingOptions(const QString &codec) const = 0; - virtual QVariant encodingOption(const QString &codec, const QString &name) const = 0; - virtual void setEncodingOption( - const QString &codec, const QString &name, const QVariant &value) = 0; - -protected: - QAudioEncoderControl(QObject *parent = 0); -}; - -#define QAudioEncoderControl_iid "com.nokia.Qt.QAudioEncoderControl/1.0" -Q_MEDIA_DECLARE_CONTROL(QAudioEncoderControl, QAudioEncoderControl_iid) - -QT_END_NAMESPACE - -QT_END_HEADER - - -#endif // QAUDIOCAPTUREPROPERTIESCONTROL_H diff --git a/src/multimediakit/qaudioendpointselector.cpp b/src/multimediakit/qaudioendpointselector.cpp deleted file mode 100644 index 8f2f28f56..000000000 --- a/src/multimediakit/qaudioendpointselector.cpp +++ /dev/null @@ -1,140 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qaudioendpointselector.h" - -QT_BEGIN_NAMESPACE - -/*! - \class QAudioEndpointSelector - - \brief The QAudioEndpointSelector class provides an audio endpoint selector media control. - \inmodule QtMultimediaKit - \ingroup multimedia - \since 1.0 - - The QAudioEndpointSelector class provides descriptions of the audio - endpoints available on a system and allows one to be selected as the audio - of a media service. - - The interface name of QAudioEndpointSelector is \c com.nokia.Qt.QAudioEndpointSelector/1.0 as - defined in QAudioEndpointSelector_iid. - - \sa QMediaService::requestControl() -*/ - -/*! - \macro QAudioEndpointSelector_iid - - \c com.nokia.Qt.QAudioEndpointSelector/1.0 - - Defines the interface name of the QAudioEndpointSelector class. - - \relates QAudioEndpointSelector -*/ - -/*! - Constructs a new audio endpoint selector with the given \a parent. -*/ -QAudioEndpointSelector::QAudioEndpointSelector(QObject *parent) - :QMediaControl(parent) -{ -} - -/*! - Destroys an audio endpoint selector. -*/ -QAudioEndpointSelector::~QAudioEndpointSelector() -{ -} - -/*! - \fn QList QAudioEndpointSelector::availableEndpoints() const - - Returns a list of the names of the available audio endpoints. - \since 1.0 -*/ - -/*! - \fn QString QAudioEndpointSelector::endpointDescription(const QString& name) const - - Returns the description of the endpoint \a name. - \since 1.0 -*/ - -/*! - \fn QString QAudioEndpointSelector::defaultEndpoint() const - - Returns the name of the default audio endpoint. - \since 1.0 -*/ - -/*! - \fn QString QAudioEndpointSelector::activeEndpoint() const - - Returns the name of the currently selected audio endpoint. - \since 1.0 -*/ - -/*! - \fn QAudioEndpointSelector::setActiveEndpoint(const QString& name) - - Set the active audio endpoint to \a name. - \since 1.0 -*/ - -/*! - \fn QAudioEndpointSelector::activeEndpointChanged(const QString& name) - - Signals that the audio endpoint has changed to \a name. - \since 1.0 -*/ - -/*! - \fn QAudioEndpointSelector::availableEndpointsChanged() - - Signals that list of available endpoints has changed. - \since 1.0 -*/ - -#include "moc_qaudioendpointselector.cpp" -QT_END_NAMESPACE - diff --git a/src/multimediakit/qaudioendpointselector.h b/src/multimediakit/qaudioendpointselector.h deleted file mode 100644 index 00250bc54..000000000 --- a/src/multimediakit/qaudioendpointselector.h +++ /dev/null @@ -1,86 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QAUDIOENDPOINTSELECTOR_H -#define QAUDIOENDPOINTSELECTOR_H - -#include -#include - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -QT_MODULE(Multimedia) - - -class Q_MULTIMEDIA_EXPORT QAudioEndpointSelector : public QMediaControl -{ - Q_OBJECT - -public: - virtual ~QAudioEndpointSelector(); - - virtual QList availableEndpoints() const = 0; - virtual QString endpointDescription(const QString& name) const = 0; - virtual QString defaultEndpoint() const = 0; - virtual QString activeEndpoint() const = 0; - -public Q_SLOTS: - virtual void setActiveEndpoint(const QString& name) = 0; - -Q_SIGNALS: - void activeEndpointChanged(const QString& name); - void availableEndpointsChanged(); - -protected: - QAudioEndpointSelector(QObject *parent = 0); -}; - -#define QAudioEndpointSelector_iid "com.nokia.Qt.QAudioEndpointSelector/1.0" -Q_MEDIA_DECLARE_CONTROL(QAudioEndpointSelector, QAudioEndpointSelector_iid) - -QT_END_NAMESPACE - -QT_END_HEADER - - -#endif // QAUDIOENDPOINTSELECTOR_H diff --git a/src/multimediakit/qaudionamespace.qdoc b/src/multimediakit/qaudionamespace.qdoc deleted file mode 100644 index a369e970c..000000000 --- a/src/multimediakit/qaudionamespace.qdoc +++ /dev/null @@ -1,70 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:FDL$ -** GNU Free Documentation License -** Alternatively, this file may be used under the terms of the GNU Free -** Documentation License version 1.3 as published by the Free Software -** Foundation and appearing in the file included in the packaging of -** this file. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms -** and conditions contained in a signed written agreement between you -** and Nokia. -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - - - -/*! - \namespace QAudio - \brief The QAudio namespace contains enums used by the audio classes. - \inmodule QtMultimediaKit - \ingroup multimedia -*/ - -/* - \enum QAudio::Error - - Error states - - \value NoError No errors have occurred - \value OpenError An error opening the audio device - \value IOError An error occurred during read/write of audio device - \value UnderrunError Audio data is not being fed to the audio device at a fast enough rate - \value FatalError A non-recoverable error has occurred, the audio device is not usable at this time. -*/ - -/* - \enum QAudio::State - - Audio processing states - - \value ActiveState Audio data is being processed, this state is set after start() is called - and while audio data is available to be processed. - \value SuspendedState The audio device is in a suspended state, this state will only be entered - after suspend() is called. - \value StoppedState The audio device is closed, not processing any audio data - \value IdleState The QIODevice passed in has no data and audio system's buffer is empty, this state - is set after start() is called and while no audio data is available to be processed. -*/ - -/* - \enum QAudio::Mode - - Audio I/O modes - - \value AudioOutput audio output device - \value AudioInput audio input device -*/ diff --git a/src/multimediakit/qcamera.cpp b/src/multimediakit/qcamera.cpp deleted file mode 100644 index 7870c2494..000000000 --- a/src/multimediakit/qcamera.cpp +++ /dev/null @@ -1,1035 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include - -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -QT_USE_NAMESPACE - -namespace -{ -class CameraRegisterMetaTypes -{ -public: - CameraRegisterMetaTypes() - { - qRegisterMetaType("QCamera::Error"); - qRegisterMetaType("QCamera::State"); - qRegisterMetaType("QCamera::Status"); - qRegisterMetaType("QCamera::CaptureMode"); - qRegisterMetaType("QCamera::LockType"); - qRegisterMetaType("QCamera::LockStatus"); - qRegisterMetaType("QCamera::LockChangeReason"); - } -} _registerCameraMetaTypes; -} - - -/*! - \class QCamera - - - \brief The QCamera class provides interface for system camera devices. - - \inmodule QtMultimediaKit - \ingroup camera - \since 1.1 - - QCamera can be used with QVideoWidget for viewfinder display, - QMediaRecorder for video recording and QCameraImageCapture for image taking. - - \snippet doc/src/snippets/multimedia-snippets/media.cpp Request control - -*/ - - -class QCameraPrivate : public QMediaObjectPrivate -{ - Q_DECLARE_NON_CONST_PUBLIC(QCamera) -public: - QCameraPrivate(): - QMediaObjectPrivate(), - provider(0), - control(0), - deviceControl(0), - viewfinder(0), - capture(0), - state(QCamera::UnloadedState), - error(QCamera::NoError), - supportedLocks(QCamera::NoLock), - requestedLocks(QCamera::NoLock), - lockStatus(QCamera::Unlocked), - lockChangeReason(QCamera::UserRequest), - supressLockChangedSignal(false), - restartPending(false) - { - } - - void initControls(); - - QMediaServiceProvider *provider; - - QCameraControl *control; - QVideoDeviceControl *deviceControl; - QCameraLocksControl *locksControl; - - QCameraExposure *cameraExposure; - QCameraFocus *cameraFocus; - QCameraImageProcessing *imageProcessing; - - QObject *viewfinder; - QObject *capture; - - QCamera::State state; - - QCamera::Error error; - QString errorString; - - QCamera::LockTypes supportedLocks; - QCamera::LockTypes requestedLocks; - - QCamera::LockStatus lockStatus; - QCamera::LockChangeReason lockChangeReason; - bool supressLockChangedSignal; - - bool restartPending; - - QVideoSurfaceOutput surfaceViewfinder; - - void _q_error(int error, const QString &errorString); - void unsetError() { error = QCamera::NoError; errorString.clear(); } - - void setState(QCamera::State); - - void _q_updateLockStatus(QCamera::LockType, QCamera::LockStatus, QCamera::LockChangeReason); - void _q_updateState(QCamera::State newState); - void _q_preparePropertyChange(int changeType); - void _q_restartCamera(); - void updateLockStatus(); -}; - - -void QCameraPrivate::_q_error(int error, const QString &errorString) -{ - Q_Q(QCamera); - - this->error = QCamera::Error(error); - this->errorString = errorString; - - qWarning() << "Camera error:" << errorString; - - emit q->error(this->error); -} - -void QCameraPrivate::setState(QCamera::State newState) -{ - Q_Q(QCamera); - - unsetError(); - - if (!control) { - _q_error(QCamera::ServiceMissingError, q_ptr->tr("The camera service is missing")); - return; - } - - if (state == newState) - return; - - restartPending = false; - state = newState; - control->setState(state); - emit q->stateChanged(state); -} - -void QCameraPrivate::_q_updateState(QCamera::State newState) -{ - Q_Q(QCamera); - - //omit changins state to Loaded when the camera is temporarily - //stopped to apply shanges - if (restartPending) - return; - - if (newState != state) { - qDebug() << "Camera state changed:" << newState; - state = newState; - emit q->stateChanged(state); - } -} - -void QCameraPrivate::_q_preparePropertyChange(int changeType) -{ - if (!control) - return; - - QCamera::Status status = control->status(); - - //all the changes are allowed until the camera is starting - if (control->state() != QCamera::ActiveState) - return; - - if (control->canChangeProperty(QCameraControl::PropertyChangeType(changeType), status)) - return; - - restartPending = true; - control->setState(QCamera::LoadedState); - QMetaObject::invokeMethod(q_ptr, "_q_restartCamera", Qt::QueuedConnection); -} - -void QCameraPrivate::_q_restartCamera() -{ - if (restartPending) { - restartPending = false; - control->setState(QCamera::ActiveState); - } -} - -void QCameraPrivate::initControls() -{ - Q_Q(QCamera); - - supportedLocks = 0; - - if (service) { - control = qobject_cast(service->requestControl(QCameraControl_iid)); - locksControl = qobject_cast(service->requestControl(QCameraLocksControl_iid)); - deviceControl = qobject_cast(service->requestControl(QVideoDeviceControl_iid)); - - if (control) { - q->connect(control, SIGNAL(stateChanged(QCamera::State)), q, SLOT(_q_updateState(QCamera::State))); - q->connect(control, SIGNAL(statusChanged(QCamera::Status)), q, SIGNAL(statusChanged(QCamera::Status))); - q->connect(control, SIGNAL(captureModeChanged(QCamera::CaptureMode)), - q, SIGNAL(captureModeChanged(QCamera::CaptureMode))); - q->connect(control, SIGNAL(error(int,QString)), q, SLOT(_q_error(int,QString))); - - } - - if (locksControl) { - q->connect(locksControl, SIGNAL(lockStatusChanged(QCamera::LockType,QCamera::LockStatus,QCamera::LockChangeReason)), - q, SLOT(_q_updateLockStatus(QCamera::LockType,QCamera::LockStatus,QCamera::LockChangeReason))); - supportedLocks = locksControl->supportedLocks(); - } - - error = QCamera::NoError; - } else { - control = 0; - locksControl = 0; - deviceControl = 0; - - error = QCamera::ServiceMissingError; - errorString = QCamera::tr("The camera service is missing"); - } -} - -void QCameraPrivate::updateLockStatus() -{ - Q_Q(QCamera); - - QCamera::LockStatus oldStatus = lockStatus; - - QMap lockStatusPriority; - lockStatusPriority.insert(QCamera::Locked, 1); - lockStatusPriority.insert(QCamera::Searching, 2); - lockStatusPriority.insert(QCamera::Unlocked, 3); - - lockStatus = requestedLocks ? QCamera::Locked : QCamera::Unlocked; - int priority = 0; - - QList lockStatuses; - - if (requestedLocks & QCamera::LockFocus) - lockStatuses << q->lockStatus(QCamera::LockFocus); - - if (requestedLocks & QCamera::LockExposure) - lockStatuses << q->lockStatus(QCamera::LockExposure); - - if (requestedLocks & QCamera::LockWhiteBalance) - lockStatuses << q->lockStatus(QCamera::LockWhiteBalance); - - - foreach (QCamera::LockStatus currentStatus, lockStatuses) { - int currentPriority = lockStatusPriority.value(currentStatus, -1); - if (currentPriority > priority) { - priority = currentPriority; - lockStatus = currentStatus; - } - } - - if (!supressLockChangedSignal && oldStatus != lockStatus) { - emit q->lockStatusChanged(lockStatus, lockChangeReason); - - if (lockStatus == QCamera::Locked) - emit q->locked(); - else if (lockStatus == QCamera::Unlocked && lockChangeReason == QCamera::LockFailed) - emit q->lockFailed(); - } -/* - qDebug() << "Requested locks:" << (requestedLocks & QCamera::LockExposure ? 'e' : ' ') - << (requestedLocks & QCamera::LockFocus ? 'f' : ' ') - << (requestedLocks & QCamera::LockWhiteBalance ? 'w' : ' '); - qDebug() << "Lock status: f:" << q->lockStatus(QCamera::LockFocus) - << " e:" << q->lockStatus(QCamera::LockExposure) - << " w:" << q->lockStatus(QCamera::LockWhiteBalance) - << " composite:" << lockStatus; -*/ -} - -void QCameraPrivate::_q_updateLockStatus(QCamera::LockType type, QCamera::LockStatus status, QCamera::LockChangeReason reason) -{ - Q_Q(QCamera); - lockChangeReason = reason; - updateLockStatus(); - emit q->lockStatusChanged(type, status, reason); -} - - -/*! - Construct a QCamera from service \a provider and \a parent. -*/ - -QCamera::QCamera(QObject *parent, QMediaServiceProvider *provider): - QMediaObject(*new QCameraPrivate, parent, provider->requestService(Q_MEDIASERVICE_CAMERA)) -{ - Q_D(QCamera); - d->provider = provider; - d->initControls(); - d->cameraExposure = new QCameraExposure(this); - d->cameraFocus = new QCameraFocus(this); - d->imageProcessing = new QCameraImageProcessing(this); -} - -/*! - Construct a QCamera from device name \a device and \a parent. -*/ - -QCamera::QCamera(const QByteArray& device, QObject *parent): - QMediaObject(*new QCameraPrivate, parent, - QMediaServiceProvider::defaultServiceProvider()->requestService(Q_MEDIASERVICE_CAMERA, QMediaServiceProviderHint(device))) -{ - Q_D(QCamera); - d->provider = QMediaServiceProvider::defaultServiceProvider(); - d->initControls(); - - if (d->service != 0) { - //pass device name to service - if (d->deviceControl) { - QString deviceName = QString::fromLatin1(device); - - for (int i=0; ideviceControl->deviceCount(); i++) { - if (d->deviceControl->deviceName(i) == deviceName) { - d->deviceControl->setSelectedDevice(i); - break; - } - } - } - } - - d->cameraExposure = new QCameraExposure(this); - d->cameraFocus = new QCameraFocus(this); - d->imageProcessing = new QCameraImageProcessing(this); -} - -/*! - Destroys the camera object. -*/ - -QCamera::~QCamera() -{ - Q_D(QCamera); - delete d->cameraExposure; - d->cameraExposure = 0; - delete d->cameraFocus; - d->cameraFocus = 0; - delete d->imageProcessing; - d->imageProcessing = 0; - - if (d->service) { - if (d->control) - d->service->releaseControl(d->control); - if (d->locksControl) - d->service->releaseControl(d->locksControl); - if (d->deviceControl) - d->service->releaseControl(d->deviceControl); - - d->provider->releaseService(d->service); - } -} - - -/*! - Return true if the camera service is ready to use. - \since 1.1 -*/ -bool QCamera::isAvailable() const -{ - return availabilityError() == QtMultimediaKit::NoError; -} - -/*! - Returns the error state of the camera service. - \since 1.1 -*/ - -QtMultimediaKit::AvailabilityError QCamera::availabilityError() const -{ - Q_D(const QCamera); - if (d->control == NULL) - return QtMultimediaKit::ServiceMissingError; - - if (d->deviceControl && d->deviceControl->deviceCount() == 0) - return QtMultimediaKit::ResourceError; - - if (d->error != QCamera::NoError) - return QtMultimediaKit::ResourceError; - - return QtMultimediaKit::NoError; -} - - -/*! - Returns the camera exposure control object. - \since 1.1 -*/ -QCameraExposure *QCamera::exposure() const -{ - return d_func()->cameraExposure; -} - -/*! - Returns the camera focus control object. - \since 1.1 -*/ -QCameraFocus *QCamera::focus() const -{ - return d_func()->cameraFocus; -} - -/*! - Returns the camera image processing control object. - \since 1.1 -*/ -QCameraImageProcessing *QCamera::imageProcessing() const -{ - return d_func()->imageProcessing; -} - -/*! - Sets the QVideoWidget based camera \a viewfinder. - The previously set viewfinder is detached. - \since 1.1 -*/ - -// QVideoWidget is forward declared -void QCamera::setViewfinder(QVideoWidget *viewfinder) -{ - Q_D(QCamera); - d->_q_preparePropertyChange(QCameraControl::Viewfinder); - - if (d->viewfinder) - unbind(d->viewfinder); - - // We don't know (in this library) that QVideoWidget inherits QObject - QObject *viewFinderObject = reinterpret_cast(viewfinder); - - d->viewfinder = viewFinderObject && bind(viewFinderObject) ? viewFinderObject : 0; -} - -/*! - Sets the QGraphicsVideoItem based camera \a viewfinder. - The previously set viewfinder is detached. - \since 1.1 -*/ -// QGraphicsVideoItem is forward declared -void QCamera::setViewfinder(QGraphicsVideoItem *viewfinder) -{ - Q_D(QCamera); - d->_q_preparePropertyChange(QCameraControl::Viewfinder); - - if (d->viewfinder) - unbind(d->viewfinder); - - // We don't know (in this library) that QGraphicsVideoItem (multiply) inherits QObject - // but QObject inheritance depends on QObject coming first, so try this out. - QObject *viewFinderObject = reinterpret_cast(viewfinder); - - d->viewfinder = viewFinderObject && bind(viewFinderObject) ? viewFinderObject : 0; -} - -/*! - Sets a video \a surface as the viewfinder of a camera. - - If a viewfinder has already been set on the camera the new surface - will replace it. - \since 1.2 -*/ - -void QCamera::setViewfinder(QAbstractVideoSurface *surface) -{ - Q_D(QCamera); - - d->surfaceViewfinder.setVideoSurface(surface); - - if (d->viewfinder != &d->surfaceViewfinder) { - if (d->viewfinder) - unbind(d->viewfinder); - - d->viewfinder = bind(&d->surfaceViewfinder) ? &d->surfaceViewfinder : 0; - } -} - -/*! - Returns the error state of the object. - \since 1.1 -*/ - -QCamera::Error QCamera::error() const -{ - return d_func()->error; -} - -/*! - Returns a string describing a camera's error state. - \since 1.1 -*/ -QString QCamera::errorString() const -{ - return d_func()->errorString; -} - - -/*! - Returns true if the capture \a mode is suported. - \since 1.1 -*/ -bool QCamera::isCaptureModeSupported(QCamera::CaptureMode mode) const -{ - return d_func()->control ? d_func()->control->isCaptureModeSupported(mode) : false; -} - -/*! - \property QCamera::captureMode - - The type of media (video or still images), - the camera is configured to capture. - - It's allowed to change capture mode in any camera state, - but if the camera is currently active, - chaging capture mode is likely to lead to camera status - chaged to QCamera::LoadedStatus, QCamera::LoadingStatus, - and when the camera is ready to QCamera::ActiveStatus. - \since 1.1 -*/ - -QCamera::CaptureMode QCamera::captureMode() const -{ - return d_func()->control ? d_func()->control->captureMode() : QCamera::CaptureStillImage; -} - -void QCamera::setCaptureMode(QCamera::CaptureMode mode) -{ - Q_D(QCamera); - - if (mode != captureMode()) { - if (d->control) { - d->_q_preparePropertyChange(QCameraControl::CaptureMode); - d->control->setCaptureMode(mode); - } - } -} - - -/*! - Starts the camera. - - State is changed to QCamera::ActiveState if camera is started - successfully, otherwise error() signal is emitted. - - While the camera state is changed to QCamera::ActiveState, - starting the camera service can be asynchronous with the actual - status reported with QCamera::status property. - \since 1.1 -*/ -void QCamera::start() -{ - Q_D(QCamera); - d->setState(QCamera::ActiveState); -} - -/*! - Stops the camera. - The camera state is changed from QCamera::ActiveState to QCamera::LoadedState. - \since 1.1 -*/ -void QCamera::stop() -{ - Q_D(QCamera); - d->setState(QCamera::LoadedState); -} - -/*! - Open the camera device. - The camera state is changed to QCamera::LoadedStatus. - - It's not necessary to explcitly load the camera, - unless unless the application have to read the supported camera - settings and change the default depending on the camera capabilities. - - In all the other cases it's possible to start the camera directly - from unloaded state. - \since 1.1 -*/ -void QCamera::load() -{ - Q_D(QCamera); - d->setState(QCamera::LoadedState); -} - -/*! - Close the camera device and deallocate the related resources. - The camera state is changed to QCamera::UnloadedStatus. - \since 1.1 -*/ -void QCamera::unload() -{ - Q_D(QCamera); - d->setState(QCamera::UnloadedState); -} - - -/*! - Returns a list of camera device's available from the default service provider. - \since 1.1 -*/ - -QList QCamera::availableDevices() -{ - return QMediaServiceProvider::defaultServiceProvider()->devices(QByteArray(Q_MEDIASERVICE_CAMERA)); -} - -/*! - Returns the description of the \a device. - \since 1.1 -*/ - -QString QCamera::deviceDescription(const QByteArray &device) -{ - return QMediaServiceProvider::defaultServiceProvider()->deviceDescription(QByteArray(Q_MEDIASERVICE_CAMERA), device); -} - -QCamera::State QCamera::state() const -{ - return d_func()->state; -} - -QCamera::Status QCamera::status() const -{ - if(d_func()->control) - return (QCamera::Status)d_func()->control->status(); - - return QCamera::UnavailableStatus; -} - - -/*! - Returns the lock types, camera supports. - \since 1.1 -*/ -QCamera::LockTypes QCamera::supportedLocks() const -{ - return d_func()->supportedLocks; -} - -/*! - Returns the requested lock types. - \since 1.1 -*/ -QCamera::LockTypes QCamera::requestedLocks() const -{ - return d_func()->requestedLocks; -} - -/*! - Returns the status of requested camera settings locks. - \since 1.1 -*/ -QCamera::LockStatus QCamera::lockStatus() const -{ - return d_func()->lockStatus; -} - -/*! - Returns the status of camera settings \a lock. - \since 1.1 -*/ -QCamera::LockStatus QCamera::lockStatus(QCamera::LockType lockType) const -{ - const QCameraPrivate *d = d_func(); - - if (!(lockType & d->supportedLocks)) - return lockType & d->requestedLocks ? QCamera::Locked : QCamera::Unlocked; - - if (!(lockType & d->requestedLocks)) - return QCamera::Unlocked; - - if (d->locksControl) - return d->locksControl->lockStatus(lockType); - - return QCamera::Unlocked; -} - -/*! - \fn void QCamera::searchAndLock(QCamera::LockTypes locks) - - Locks the camera settings with the requested \a locks, including focusing in the single autofocus mode, - exposure and white balance if the exposure and white balance modes are not manual. - - The camera settings are usually locked before taking one or multiple still images, - in responce to the shutter button being half pressed. - - The QCamera::locked() signal is emitted when camera settings are successfully locked, - otherwise QCamera::lockFailed() is emitted. - - QCamera also emits lockStatusChanged(QCamera::LockType, QCamera::LockStatus) - on individual lock status changes and lockStatusChanged(QCamera::LockStatus) signal on composite status changes. - - Locking serves two roles: it initializes calculation of automatic parameter - (focusing, calculating the correct exposure and white balance) and allows - to keep some or all of those parameters during number of shots. - - If the camera doesn't support keeping one of parameters between shots, the related - lock state changes to QCamera::Unlocked. - - It's also acceptable to relock already locked settings, - depending on the lock parameter this initiates new focusing, exposure or white balance calculation. - \since 1.1 - */ -void QCamera::searchAndLock(QCamera::LockTypes locks) -{ - Q_D(QCamera); - - QCamera::LockStatus oldStatus = d->lockStatus; - d->supressLockChangedSignal = true; - - d->requestedLocks |= locks; - - locks &= d->supportedLocks; - - if (d->locksControl) - d->locksControl->searchAndLock(locks); - - d->supressLockChangedSignal = false; - - d->lockStatus = oldStatus; - d->updateLockStatus(); -} - -/*! - Lock all the supported camera settings. - \since 1.1 - */ -void QCamera::searchAndLock() -{ - searchAndLock(LockExposure | LockWhiteBalance | LockFocus); -} - -/*! - Unlocks the camera settings specified with \a locks or cancel the current locking if one is active. - \since 1.1 - */ -void QCamera::unlock(QCamera::LockTypes locks) -{ - Q_D(QCamera); - - QCamera::LockStatus oldStatus = d->lockStatus; - d->supressLockChangedSignal = true; - - d->requestedLocks &= ~locks; - - locks &= d->supportedLocks; - - if (d->locksControl) - d->locksControl->unlock(locks); - - d->supressLockChangedSignal = false; - - d->lockStatus = oldStatus; - d->updateLockStatus(); -} - -/*! - Unlock all the requested camera locks. - \since 1.1 - */ -void QCamera::unlock() -{ - unlock(d_func()->requestedLocks); -} - - -/*! - \enum QCamera::State - \value UnloadedState - The initial camera state, with camera not loaded, - the camera capabilities except of supported capture modes - are unknown. - - While the supported settings are unknown in this state, - it's allowed to set the camera capture settings like codec, - resolution, or frame rate. - - \value LoadedState - The camera is loaded and ready to be configured. - - In the Idle state it's allowed to query camera capabilities, - set capture resolution, codecs, etc. - - The viewfinder is not active in the loaded state. - - \value ActiveState - In the active state as soon as camera is started - the viewfinder displays video frames and the - camera is ready for capture. -*/ - - -/*! - \property QCamera::state - \brief The current state of the camera object. - \since 1.1 -*/ - -/*! - \enum QCamera::Status - \value ActiveStatus - The camera has been started and can produce data. - The viewfinder displays video frames in active state. - - Depending on backend, changing some camera settings like - capture mode, codecs or resolution in ActiveState may lead - to changing the camera status to LoadedStatus and StartingStatus while - the settings are applied and back to ActiveStatus when the camera is ready. - - \value StartingStatus - The camera is starting in result of state transition to QCamera::ActiveState. - The camera service is not ready to capture yet. - - \value StandbyStatus - The camera is in the power saving standby mode. - The camera may come to the standby mode after some time of inactivity - in the QCamera::LoadedState state. - - \value LoadedStatus - The camera is loaded and ready to be configured. - This status indicates the camera device is opened and - it's possible to query for supported image and video capture settings, - like resolution, framerate and codecs. - - \value LoadingStatus - The camera device loading in result of state transition from - QCamera::UnloadedState to QCamera::LoadedState or QCamera::ActiveState. - - \value UnloadedStatus - The initial camera status, with camera not loaded. - The camera capabilities including supported capture settings may be unknown. - - \value UnavailableStatus - The camera or camera backend is not available. -*/ - - -/*! - \property QCamera::status - \brief The current status of the camera object. - \since 1.1 -*/ - - -/*! - \enum QCamera::CaptureMode - \value CaptureStillImage Camera is configured for still frames capture. - \value CaptureVideo Camera is configured for video capture. - \since 1.1 -*/ - -/*! - \enum QCamera::LockType - - \value NoLock - \value LockExposure - Lock camera exposure. - \value LockWhiteBalance - Lock the white balance. - \value LockFocus - Lock camera focus. -*/ - - -/*! - \property QCamera::lockStatus - \brief The overall status for all the requested camera locks. - \since 1.1 -*/ - -/*! - \fn void QCamera::locked() - - Signals all the requested camera settings are locked. - \since 1.1 -*/ - -/*! - \fn void QCamera::lockFailed() - - Signals locking of at least one requested camera settings failed. - \since 1.1 -*/ - -/*! - \fn QCamera::lockStatusChanged(QCamera::LockStatus status, QCamera::LockChangeReason reason) - - Signals the overall \a status for all the requested camera locks was changed with specified \a reason. - \since 1.1 -*/ - -/*! - \fn QCamera::lockStatusChanged(QCamera::LockType lock, QCamera::LockStatus status, QCamera::LockChangeReason reason) - Signals the \a lock \a status was changed with specified \a reason. - \since 1.1 -*/ - -/*! - \enum QCamera::LockStatus - \value Unlocked - The application is not interested in camera settings value. - The camera may keep this parameter without changes, this is common with camera focus, - or adjust exposure and white balance constantly to keep the viewfinder image nice. - - \value Searching - The application has requested the camera focus, exposure or white balance lock with - QCamera::searchAndLock(). This state indicates the camera is focusing or calculating exposure and white balance. - - \value Locked - The camera focus, exposure or white balance is locked. - The camera is ready to capture, application may check the exposure parameters. - - The locked state usually means the requested parameter stays the same, - except of the cases when the parameter is requested to be constantly updated. - For example in continuous focusing mode, the focus is considered locked as long - and the object is in focus, even while the actual focusing distance may be constantly changing. -*/ - -/*! - \enum QCamera::LockChangeReason - - \value UserRequest - The lock status changed in result of user request, usually to unlock camera settings. - \value LockAcquired - The lock status successfuly changed to QCamera::Locked. - \value LockFailed - The camera failed to acquire the requested lock in result of - autofocus failure, exposure out of supported range, etc. - \value LockLost - The camera is not able to maintain the requested lock any more. - Lock status is changed to QCamera::Unlocked. - \value LockTemporaryLost - The lock is lost, but the camera is working hard to reacquire it. - This value may be used in continuous focusing mode, - when the camera loses the focus, the focus lock state is changed to Qcamera::Searching - with LockTemporaryLost reason. -*/ - -/*! - \enum QCamera::Error - - \value NoError No errors have occurred. - \value CameraError An error has occurred. - \value InvalidRequestError System resource doesn't support requested functionality. - \value ServiceMissingError No camera service available. - \value NotSupportedFeatureError The feature is not supported. -*/ - -/*! - \fn void QCamera::error(QCamera::Error value) - - Signal emitted when error state changes to \a value. - \since 1.1 -*/ - -/*! - \fn void QCamera::captureModeChanged(QCamera::CaptureMode mode) - - Signals the capture \a mode has changed. - \since 1.1 -*/ - -/*! - \fn QCamera::stateChanged(QCamera::State state) - - Signals the camera \a state has changed. - - Usually the state changes is caused by calling - load(), unload(), start() and stop(), - but the state can also be changed change as a result of camera error. - \since 1.1 -*/ - -/*! - \fn QCamera::statusChanged(QCamera::Status status) - - Signals the camera \a status has changed. - - \since 1.1 -*/ - - -#include "moc_qcamera.cpp" diff --git a/src/multimediakit/qcamera.h b/src/multimediakit/qcamera.h deleted file mode 100644 index 5091759ab..000000000 --- a/src/multimediakit/qcamera.h +++ /dev/null @@ -1,238 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QCAMERA_H -#define QCAMERA_H - -#include -#include -#include -#include -#include - -#include -#include -#include - -#include -#include -#include - -#include -#include - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -QT_MODULE(Multimedia) - - -class QAbstractVideoSurface; -class QVideoWidget; -class QGraphicsVideoItem; - -class QCameraPrivate; -class Q_MULTIMEDIA_EXPORT QCamera : public QMediaObject -{ - Q_OBJECT - Q_PROPERTY(QCamera::State state READ state NOTIFY stateChanged) - Q_PROPERTY(QCamera::Status status READ status NOTIFY statusChanged) - Q_PROPERTY(QCamera::CaptureMode captureMode READ captureMode WRITE setCaptureMode NOTIFY captureModeChanged) - Q_PROPERTY(QCamera::LockStatus lockStatus READ lockStatus NOTIFY lockStatusChanged) - - Q_ENUMS(Status) - Q_ENUMS(State) - Q_ENUMS(CaptureMode) - Q_ENUMS(Error) - Q_ENUMS(LockStatus) - Q_ENUMS(LockChangeReason) - Q_ENUMS(LockType) -public: - enum Status { - UnavailableStatus, - UnloadedStatus, - LoadingStatus, - LoadedStatus, - StandbyStatus, - StartingStatus, - ActiveStatus - }; - - enum State { - UnloadedState, - LoadedState, - ActiveState - }; - - enum CaptureMode - { - CaptureStillImage, - CaptureVideo - }; - - enum Error - { - NoError, - CameraError, - InvalidRequestError, - ServiceMissingError, - NotSupportedFeatureError - }; - - enum LockStatus - { - Unlocked, - Searching, - Locked - }; - - enum LockChangeReason { - UserRequest, - LockAcquired, - LockFailed, - LockLost, - LockTemporaryLost - }; - - enum LockType - { - NoLock = 0, - LockExposure = 0x01, - LockWhiteBalance = 0x02, - LockFocus = 0x04 - }; - Q_DECLARE_FLAGS(LockTypes, LockType) - - QCamera(QObject *parent = 0, QMediaServiceProvider *provider = QMediaServiceProvider::defaultServiceProvider()); - QCamera(const QByteArray& device, QObject *parent = 0); - ~QCamera(); - - static QList availableDevices(); - static QString deviceDescription(const QByteArray &device); - - bool isAvailable() const; - QtMultimediaKit::AvailabilityError availabilityError() const; - - State state() const; - Status status() const; - - CaptureMode captureMode() const; - bool isCaptureModeSupported(CaptureMode mode) const; - - QCameraExposure *exposure() const; - QCameraFocus *focus() const; - QCameraImageProcessing *imageProcessing() const; - - void setViewfinder(QVideoWidget *viewfinder); - void setViewfinder(QGraphicsVideoItem *viewfinder); - void setViewfinder(QAbstractVideoSurface *surface); - - Error error() const; - QString errorString() const; - - QCamera::LockTypes supportedLocks() const; - QCamera::LockTypes requestedLocks() const; - - QCamera::LockStatus lockStatus() const; - QCamera::LockStatus lockStatus(QCamera::LockType lock) const; - -public Q_SLOTS: - void setCaptureMode(QCamera::CaptureMode mode); - - void load(); - void unload(); - - void start(); - void stop(); - - void searchAndLock(); - void unlock(); - - void searchAndLock(QCamera::LockTypes locks); - void unlock(QCamera::LockTypes locks); - -Q_SIGNALS: - void stateChanged(QCamera::State); - void captureModeChanged(QCamera::CaptureMode); - void statusChanged(QCamera::Status); - - void locked(); - void lockFailed(); - - void lockStatusChanged(QCamera::LockStatus, QCamera::LockChangeReason); - void lockStatusChanged(QCamera::LockType, QCamera::LockStatus, QCamera::LockChangeReason); - - void error(QCamera::Error); - -private: - Q_DISABLE_COPY(QCamera) - Q_DECLARE_PRIVATE(QCamera) - Q_PRIVATE_SLOT(d_func(), void _q_preparePropertyChange(int)) - Q_PRIVATE_SLOT(d_func(), void _q_restartCamera()) - Q_PRIVATE_SLOT(d_func(), void _q_error(int, const QString &)) - Q_PRIVATE_SLOT(d_func(), void _q_updateLockStatus(QCamera::LockType, QCamera::LockStatus, QCamera::LockChangeReason)) - Q_PRIVATE_SLOT(d_func(), void _q_updateState(QCamera::State)) -}; - -Q_DECLARE_OPERATORS_FOR_FLAGS(QCamera::LockTypes) - -QT_END_NAMESPACE - -Q_DECLARE_METATYPE(QCamera::State) -Q_DECLARE_METATYPE(QCamera::Status) -Q_DECLARE_METATYPE(QCamera::Error) -Q_DECLARE_METATYPE(QCamera::CaptureMode) -Q_DECLARE_METATYPE(QCamera::LockType) -Q_DECLARE_METATYPE(QCamera::LockStatus) -Q_DECLARE_METATYPE(QCamera::LockChangeReason) - -Q_MEDIA_ENUM_DEBUG(QCamera, State) -Q_MEDIA_ENUM_DEBUG(QCamera, Status) -Q_MEDIA_ENUM_DEBUG(QCamera, Error) -Q_MEDIA_ENUM_DEBUG(QCamera, CaptureMode) -Q_MEDIA_ENUM_DEBUG(QCamera, LockType) -Q_MEDIA_ENUM_DEBUG(QCamera, LockStatus) -Q_MEDIA_ENUM_DEBUG(QCamera, LockChangeReason) - -QT_END_HEADER - -#endif // QCAMERA_H diff --git a/src/multimediakit/qcameracapturebufferformatcontrol.cpp b/src/multimediakit/qcameracapturebufferformatcontrol.cpp deleted file mode 100644 index 2a1ca909b..000000000 --- a/src/multimediakit/qcameracapturebufferformatcontrol.cpp +++ /dev/null @@ -1,117 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include - -QT_BEGIN_NAMESPACE - -/*! - \class QCameraCaptureBufferFormatControl - - \brief The QCameraCaptureBufferFormatControl class provides a control for setting the capture buffer format. - - The format is of type QVideoFrame::PixelFormat. - - \inmodule QtMultimediaKit - \ingroup multimedia-serv - - The interface name of QCameraCaptureBufferFormatControl is \c com.nokia.Qt.QCameraCaptureBufferFormatControl/1.0 as - defined in QCameraCaptureBufferFormatControl_iid. - - \sa QMediaService::requestControl() -*/ - -/*! - \macro QCameraCaptureBufferFormatControl_iid - - \c com.nokia.Qt.QCameraCaptureBufferFormatControl/1.0 - - Defines the interface name of the QCameraCaptureBufferFormatControl class. - - \relates QCameraCaptureBufferFormatControl -*/ - -/*! - Constructs a new image buffer capture format control object with the given \a parent -*/ -QCameraCaptureBufferFormatControl::QCameraCaptureBufferFormatControl(QObject *parent) - :QMediaControl(parent) -{ -} - -/*! - Destroys an image buffer capture format control. -*/ -QCameraCaptureBufferFormatControl::~QCameraCaptureBufferFormatControl() -{ -} - -/*! - \fn QCameraCaptureBufferFormatControl::supportedBufferFormats() const - - Returns the list of the supported buffer capture formats. - \since 1.2 -*/ - -/*! - \fn QCameraCaptureBufferFormatControl::bufferFormat() const - - Returns the current buffer capture format. - \since 1.2 -*/ - -/*! - \fn QCameraCaptureBufferFormatControl::setBufferFormat(QVideoFrame::PixelFormat format) - - Sets the buffer capture \a format. - \since 1.2 -*/ - -/*! - \fn QCameraCaptureBufferFormatControl::bufferFormatChanged(QVideoFrame::PixelFormat format) - - Signals the buffer image capture format changed to \a format. - \since 1.2 -*/ - -#include "moc_qcameracapturebufferformatcontrol.cpp" -QT_END_NAMESPACE - diff --git a/src/multimediakit/qcameracapturebufferformatcontrol.h b/src/multimediakit/qcameracapturebufferformatcontrol.h deleted file mode 100644 index 81079a77d..000000000 --- a/src/multimediakit/qcameracapturebufferformatcontrol.h +++ /dev/null @@ -1,81 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QCAMERACAPTUREBUFFERFORMATCONTROL_H -#define QCAMERACAPTUREBUFFERFORMATCONTROL_H - -#include -#include - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -QT_MODULE(Multimedia) - - -class Q_MULTIMEDIA_EXPORT QCameraCaptureBufferFormatControl : public QMediaControl -{ - Q_OBJECT -public: - ~QCameraCaptureBufferFormatControl(); - - virtual QList supportedBufferFormats() const = 0; - virtual QVideoFrame::PixelFormat bufferFormat() const = 0; - virtual void setBufferFormat(QVideoFrame::PixelFormat format) = 0; - -Q_SIGNALS: - void bufferFormatChanged(QVideoFrame::PixelFormat); - -protected: - QCameraCaptureBufferFormatControl(QObject* parent = 0); -}; - -#define QCameraCaptureBufferFormatControl_iid "com.nokia.Qt.QCameraCaptureBufferFormatControl/1.0" -Q_MEDIA_DECLARE_CONTROL(QCameraCaptureBufferFormatControl, QCameraCaptureBufferFormatControl_iid) - -QT_END_NAMESPACE - -QT_END_HEADER - - -#endif - diff --git a/src/multimediakit/qcameracapturedestinationcontrol.cpp b/src/multimediakit/qcameracapturedestinationcontrol.cpp deleted file mode 100644 index 0c2055ddd..000000000 --- a/src/multimediakit/qcameracapturedestinationcontrol.cpp +++ /dev/null @@ -1,121 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include -#include - -QT_BEGIN_NAMESPACE - -/*! - \class QCameraCaptureDestinationControl - - \brief The QCameraCaptureDestinationControl class provides a control for setting capture destination. - - Depending on backend capabilities capture to file, buffer or both can be supported. - - \inmodule QtMultimediaKit - \ingroup multimedia-serv - - - - The interface name of QCameraCaptureDestinationControl is \c com.nokia.Qt.QCameraCaptureDestinationControl/1.0 as - defined in QCameraCaptureDestinationControl_iid. - - - \sa QMediaService::requestControl() -*/ - -/*! - \macro QCameraCaptureDestinationControl_iid - - \c com.nokia.Qt.QCameraCaptureDestinationControl/1.0 - - Defines the interface name of the QCameraCaptureDestinationControl class. - - \relates QCameraCaptureDestinationControl -*/ - -/*! - Constructs a new image capture destination control object with the given \a parent -*/ -QCameraCaptureDestinationControl::QCameraCaptureDestinationControl(QObject *parent) - :QMediaControl(parent) -{ -} - -/*! - Destroys an image capture destination control. -*/ -QCameraCaptureDestinationControl::~QCameraCaptureDestinationControl() -{ -} - -/*! - \fn QCameraCaptureDestinationControl::isCaptureDestinationSupported(QCameraImageCapture::CaptureDestinations destination) const - - Returns true if the capture \a destination is supported; and false if it is not. - \since 1.2 -*/ - -/*! - \fn QCameraCaptureDestinationControl::captureDestination() const - - Returns the current capture \a destination. The default destination is QCameraImageCapture::CaptureToFile. - \since 1.2 -*/ - -/*! - \fn QCameraCaptureDestinationControl::setCaptureDestination(QCameraImageCapture::CaptureDestinations destination) - - Sets the capture \a destination. - \since 1.2 -*/ - -/*! - \fn QCameraCaptureDestinationControl::captureDestinationChanged(QCameraImageCapture::CaptureDestinations destination) - - Signals the image capture \a destination changed. - \since 1.2 -*/ - -#include "moc_qcameracapturedestinationcontrol.cpp" -QT_END_NAMESPACE - diff --git a/src/multimediakit/qcameracapturedestinationcontrol.h b/src/multimediakit/qcameracapturedestinationcontrol.h deleted file mode 100644 index cdd769a4d..000000000 --- a/src/multimediakit/qcameracapturedestinationcontrol.h +++ /dev/null @@ -1,81 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QCAMERACAPTUREDESTINATIONCONTROL_H -#define QCAMERACAPTUREDESTINATIONCONTROL_H - -#include -#include - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -QT_MODULE(Multimedia) - - -class Q_MULTIMEDIA_EXPORT QCameraCaptureDestinationControl : public QMediaControl -{ - Q_OBJECT -public: - ~QCameraCaptureDestinationControl(); - - virtual bool isCaptureDestinationSupported(QCameraImageCapture::CaptureDestinations destination) const = 0; - virtual QCameraImageCapture::CaptureDestinations captureDestination() const = 0; - virtual void setCaptureDestination(QCameraImageCapture::CaptureDestinations destination) = 0; - -Q_SIGNALS: - void captureDestinationChanged(QCameraImageCapture::CaptureDestinations); - -protected: - QCameraCaptureDestinationControl(QObject* parent = 0); -}; - -#define QCameraCaptureDestinationControl_iid "com.nokia.Qt.QCameraCaptureDestinationControl/1.0" -Q_MEDIA_DECLARE_CONTROL(QCameraCaptureDestinationControl, QCameraCaptureDestinationControl_iid) - -QT_END_NAMESPACE - -QT_END_HEADER - - -#endif - diff --git a/src/multimediakit/qcameracontrol.cpp b/src/multimediakit/qcameracontrol.cpp deleted file mode 100644 index d091da711..000000000 --- a/src/multimediakit/qcameracontrol.cpp +++ /dev/null @@ -1,215 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include -#include "qmediacontrol_p.h" - -QT_BEGIN_NAMESPACE - -/*! - \class QCameraControl - - - - \brief The QCameraControl class is an abstract base class for - classes that control still cameras or video cameras. - - \inmodule QtMultimediaKit - \ingroup multimedia-serv - \since 1.1 - - This service is provided by a QMediaService object via - QMediaService::control(). It is used by QCamera. - - The interface name of QCameraControl is \c com.nokia.Qt.QCameraControl/1.0 as - defined in QCameraControl_iid. - - - - \sa QMediaService::requestControl(), QCamera -*/ - -/*! - \macro QCameraControl_iid - - \c com.nokia.Qt.QCameraControl/1.0 - - Defines the interface name of the QCameraControl class. - - \relates QCameraControl -*/ - -/*! - Constructs a camera control object with \a parent. -*/ - -QCameraControl::QCameraControl(QObject *parent): - QMediaControl(*new QMediaControlPrivate, parent) -{ -} - -/*! - Destruct the camera control object. -*/ - -QCameraControl::~QCameraControl() -{ -} - -/*! - \fn QCameraControl::state() const - - Returns the state of the camera service. - - \since 1.1 - \sa QCamera::state -*/ - -/*! - \fn QCameraControl::setState(QCamera::State state) - - Sets the camera \a state. - - State changes are synchronous and indicate user intention, - while camera status is used as a feedback mechanism to inform application about backend status. - Status changes are reported asynchronously with QCameraControl::statusChanged() signal. - - \since 1.1 - \sa QCamera::State -*/ - -/*! - \fn void QCameraControl::stateChanged(QCamera::State state) - - Signal emitted when the camera \a state changes. - - In most cases the state chage is caused by QCameraControl::setState(), - but if critical error has occurred the state changes to QCamera::UnloadedState. - \since 1.1 -*/ - -/*! - \fn QCameraControl::status() const - - Returns the status of the camera service. - - \since 1.1 - \sa QCamera::state -*/ - -/*! - \fn void QCameraControl::statusChanged(QCamera::Status status) - - Signal emitted when the camera \a status changes. - \since 1.1 -*/ - - -/*! - \fn void QCameraControl::error(int error, const QString &errorString) - - Signal emitted when an error occurs with error code \a error and - a description of the error \a errorString. - \since 1.1 -*/ - -/*! - \fn Camera::CaptureMode QCameraControl::captureMode() const = 0 - - Returns the current capture mode. - \since 1.1 -*/ - -/*! - \fn void QCameraControl::setCaptureMode(QCamera::CaptureMode mode) = 0; - - Sets the current capture \a mode. - - The capture mode changes are synchronous and allowed in any camera state. - - If the capture mode is changed while camera is active, - it's recommended to change status to QCamera::LoadedStatus - and start activating the camera in the next event loop - with the status changed to QCamera::StartingStatus. - This allows the capture settings to be applied before camera is started. - Than change the status to QCamera::StartedStatus when the capture mode change is done. - \since 1.1 -*/ - -/*! - \fn bool QCameraControl::isCaptureModeSupported(QCamera::CaptureMode mode) const = 0; - - Returns true if the capture \a mode is suported. - \since 1.1 -*/ - -/*! - \fn QCameraControl::captureModeChanged(QCamera::CaptureMode mode) - - Signal emitted when the camera capture \a mode changes. - \since 1.1 - */ - -/*! - \fn bool QCameraControl::canChangeProperty(PropertyChangeType changeType, QCamera::Status status) const - - Returns true if backend can effectively apply changing camera properties of \a changeType type - while the camera state is QCamera::Active and camera status matches \a status parameter. - - If backend doesn't support applying this change in the active state, it will be stopped - before the settings are changed and restarted after. - Otherwise the backend should apply the change in the current state, - with the camera status indicating the progress, if necessary. - \since 1.1 -*/ - -/*! - \enum QCameraControl::PropertyChangeType - - \value CaptureMode Indicates the capture mode is changed. - \value ImageEncodingSettings Image encoder settings are changed, including resolution. - \value VideoEncodingSettings - Video encoder settings are changed, including audio, video and container settings. - \value Viewfinder Viewfinder is changed. -*/ - -#include "moc_qcameracontrol.cpp" -QT_END_NAMESPACE diff --git a/src/multimediakit/qcameracontrol.h b/src/multimediakit/qcameracontrol.h deleted file mode 100644 index dfc2b3743..000000000 --- a/src/multimediakit/qcameracontrol.h +++ /dev/null @@ -1,101 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QCAMERACONTROL_H -#define QCAMERACONTROL_H - -#include -#include - -#include - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -QT_MODULE(Multimedia) - - -class Q_MULTIMEDIA_EXPORT QCameraControl : public QMediaControl -{ - Q_OBJECT - -public: - enum PropertyChangeType { - CaptureMode = 1, - ImageEncodingSettings = 2, - VideoEncodingSettings = 3, - Viewfinder = 4 - }; - - ~QCameraControl(); - - virtual QCamera::State state() const = 0; - virtual void setState(QCamera::State state) = 0; - - virtual QCamera::Status status() const = 0; - - virtual QCamera::CaptureMode captureMode() const = 0; - virtual void setCaptureMode(QCamera::CaptureMode) = 0; - virtual bool isCaptureModeSupported(QCamera::CaptureMode mode) const = 0; - - virtual bool canChangeProperty(PropertyChangeType changeType, QCamera::Status status) const = 0; - -Q_SIGNALS: - void stateChanged(QCamera::State); - void statusChanged(QCamera::Status); - void error(int error, const QString &errorString); - void captureModeChanged(QCamera::CaptureMode); - -protected: - QCameraControl(QObject* parent = 0); -}; - -#define QCameraControl_iid "com.nokia.Qt.QCameraControl/1.0" -Q_MEDIA_DECLARE_CONTROL(QCameraControl, QCameraControl_iid) - -QT_END_NAMESPACE - -QT_END_HEADER - - -#endif // QCAMERACONTROL_H - diff --git a/src/multimediakit/qcameraexposure.cpp b/src/multimediakit/qcameraexposure.cpp deleted file mode 100644 index e748560aa..000000000 --- a/src/multimediakit/qcameraexposure.cpp +++ /dev/null @@ -1,646 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include - -#include -#include - -#include -#include -#include -#include - -QT_BEGIN_NAMESPACE - -/*! - \class QCameraExposure - - - \brief The QCameraExposure class provides interface for exposure related camera settings. - - \inmodule QtMultimediaKit - \ingroup camera - \since 1.1 - -*/ - -//#define DEBUG_EXPOSURE_CHANGES 1 - -#ifdef DEBUG_EXPOSURE_CHANGES -#define ENUM_NAME(c,e,v) (c::staticMetaObject.enumerator(c::staticMetaObject.indexOfEnumerator(e)).valueToKey((v))) -#endif - -namespace -{ -class CameraExposureRegisterMetaTypes -{ -public: - CameraExposureRegisterMetaTypes() - { - qRegisterMetaType("QCameraExposure::ExposureMode"); - qRegisterMetaType("QCameraExposure::FlashModes"); - qRegisterMetaType("QCameraExposure::MeteringMode"); - } -} _registerCameraExposureMetaTypes; -} - - - -class QCameraExposurePrivate -{ - Q_DECLARE_NON_CONST_PUBLIC(QCameraExposure) -public: - void initControls(); - QCameraExposure *q_ptr; - - QCamera *camera; - QCameraExposureControl *exposureControl; - QCameraFlashControl *flashControl; - - void _q_exposureParameterChanged(int parameter); - void _q_exposureParameterRangeChanged(int parameter); -}; - -void QCameraExposurePrivate::initControls() -{ - Q_Q(QCameraExposure); - - QMediaService *service = camera->service(); - exposureControl = 0; - flashControl = 0; - if (service) { - exposureControl = qobject_cast(service->requestControl(QCameraExposureControl_iid)); - flashControl = qobject_cast(service->requestControl(QCameraFlashControl_iid)); - } - if (exposureControl) { - q->connect(exposureControl, SIGNAL(exposureParameterChanged(int)), - q, SLOT(_q_exposureParameterChanged(int))); - q->connect(exposureControl, SIGNAL(exposureParameterRangeChanged(int)), - q, SLOT(_q_exposureParameterRangeChanged(int))); - } - - if (flashControl) - q->connect(flashControl, SIGNAL(flashReady(bool)), q, SIGNAL(flashReady(bool))); -} - -void QCameraExposurePrivate::_q_exposureParameterChanged(int parameter) -{ - Q_Q(QCameraExposure); - -#if DEBUG_EXPOSURE_CHANGES - qDebug() << "Exposure parameter changed:" - << ENUM_NAME(QCameraExposureControl, "ExposureParameter", parameter) - << exposureControl->exposureParameter(QCameraExposureControl::ExposureParameter(parameter)); -#endif - - switch (parameter) { - case QCameraExposureControl::ISO: - emit q->isoSensitivityChanged(q->isoSensitivity()); - break; - case QCameraExposureControl::Aperture: - emit q->apertureChanged(q->aperture()); - break; - case QCameraExposureControl::ShutterSpeed: - emit q->shutterSpeedChanged(q->shutterSpeed()); - break; - case QCameraExposureControl::ExposureCompensation: - emit q->exposureCompensationChanged(q->exposureCompensation()); - break; - } -} - -void QCameraExposurePrivate::_q_exposureParameterRangeChanged(int parameter) -{ - Q_Q(QCameraExposure); - - switch (parameter) { - case QCameraExposureControl::Aperture: - emit q->apertureRangeChanged(); - break; - case QCameraExposureControl::ShutterSpeed: - emit q->shutterSpeedRangeChanged(); - break; - } -} - -/*! - Construct a QCameraExposure from service \a provider and \a parent. -*/ - -QCameraExposure::QCameraExposure(QCamera *parent): - QObject(parent), d_ptr(new QCameraExposurePrivate) -{ - Q_D(QCameraExposure); - d->camera = parent; - d->q_ptr = this; - d->initControls(); -} - - -/*! - Destroys the camera exposure object. -*/ - -QCameraExposure::~QCameraExposure() -{ - Q_D(QCameraExposure); - if (d->exposureControl) - d->camera->service()->releaseControl(d->exposureControl); -} - -/*! - Returns true if exposure settings are supported by this camera. - \since 1.1 -*/ -bool QCameraExposure::isAvailable() const -{ - return d_func()->exposureControl != 0; -} - - -/*! - \property QCameraExposure::flashMode - \brief The flash mode being used. - - Usually the single QCameraExposure::FlashMode flag is used, - but some non conflicting flags combination are also allowed, - like QCameraExposure::FlashManual | QCameraExposure::FlashSlowSyncRearCurtain. - - \since 1.1 - \sa QCameraExposure::isFlashModeSupported(), QCameraExposure::isFlashReady() -*/ - -QCameraExposure::FlashModes QCameraExposure::flashMode() const -{ - return d_func()->flashControl ? d_func()->flashControl->flashMode() : QCameraExposure::FlashOff; -} - -void QCameraExposure::setFlashMode(QCameraExposure::FlashModes mode) -{ - if (d_func()->flashControl) - d_func()->flashControl->setFlashMode(mode); -} - -/*! - Returns true if the flash \a mode is supported. - \since 1.1 -*/ - -bool QCameraExposure::isFlashModeSupported(QCameraExposure::FlashModes mode) const -{ - return d_func()->flashControl ? d_func()->flashControl->isFlashModeSupported(mode) : false; -} - -/*! - Returns true if flash is charged. -*/ - -bool QCameraExposure::isFlashReady() const -{ - return d_func()->flashControl ? d_func()->flashControl->isFlashReady() : false; -} - - -/*! - \property QCameraExposure::exposureMode - \brief The exposure mode being used. - - \since 1.1 - \sa QCameraExposure::isExposureModeSupported() -*/ - -QCameraExposure::ExposureMode QCameraExposure::exposureMode() const -{ - return d_func()->exposureControl ? d_func()->exposureControl->exposureMode() : QCameraExposure::ExposureAuto; -} - -void QCameraExposure::setExposureMode(QCameraExposure::ExposureMode mode) -{ - if (d_func()->exposureControl) - d_func()->exposureControl->setExposureMode(mode); -} - -/*! - Returns true if the exposure \a mode is supported. - \since 1.1 -*/ - -bool QCameraExposure::isExposureModeSupported(QCameraExposure::ExposureMode mode) const -{ - return d_func()->exposureControl ? - d_func()->exposureControl->isExposureModeSupported(mode) : false; -} - -/*! - \property QCameraExposure::exposureCompensation - \brief Exposure compensation in EV units. - - Exposure compensation property allows to adjust the automatically calculated exposure. - \since 1.1 -*/ - -qreal QCameraExposure::exposureCompensation() const -{ - if (d_func()->exposureControl) - return d_func()->exposureControl->exposureParameter(QCameraExposureControl::ExposureCompensation).toReal(); - else - return 0; -} - -void QCameraExposure::setExposureCompensation(qreal ev) -{ - if (d_func()->exposureControl) - d_func()->exposureControl->setExposureParameter(QCameraExposureControl::ExposureCompensation, QVariant(ev)); -} - -/*! - \property QCameraExposure::meteringMode - \brief The metering mode being used. - - \since 1.1 - \sa QCameraExposure::isMeteringModeSupported() -*/ - -QCameraExposure::MeteringMode QCameraExposure::meteringMode() const -{ - return d_func()->exposureControl ? d_func()->exposureControl->meteringMode() : QCameraExposure::MeteringMatrix; -} - -void QCameraExposure::setMeteringMode(QCameraExposure::MeteringMode mode) -{ - if (d_func()->exposureControl) - d_func()->exposureControl->setMeteringMode(mode); -} - -/*! - Returns true if the metering \a mode is supported. - \since 1.1 -*/ -bool QCameraExposure::isMeteringModeSupported(QCameraExposure::MeteringMode mode) const -{ - return d_func()->exposureControl ? d_func()->exposureControl->isMeteringModeSupported(mode) : false; -} - -int QCameraExposure::isoSensitivity() const -{ - if (d_func()->exposureControl) - return d_func()->exposureControl->exposureParameter(QCameraExposureControl::ISO).toInt(); - - return -1; -} - -/*! - Returns the list of ISO senitivities camera supports. - - If the camera supports arbitrary ISO sensitivities within the supported range, - *\a continuous is set to true, otherwise *\a continuous is set to false. - \since 1.1 -*/ -QList QCameraExposure::supportedIsoSensitivities(bool *continuous) const -{ - QList res; - QCameraExposureControl *control = d_func()->exposureControl; - - if (!control) - return res; - - foreach (const QVariant &value, - control->supportedParameterRange(QCameraExposureControl::ISO)) { - bool ok = false; - int intValue = value.toInt(&ok); - if (ok) - res.append(intValue); - else - qWarning() << "Incompatible ISO value type, int is expected"; - } - - if (continuous) - *continuous = control->exposureParameterFlags(QCameraExposureControl::ISO) & - QCameraExposureControl::ContinuousRange; - - return res; -} - -/*! - \fn QCameraExposure::setManualIsoSensitivity(int iso) - Sets the manual sensitivity to \a iso - \since 1.1 -*/ - -void QCameraExposure::setManualIsoSensitivity(int iso) -{ - if (d_func()->exposureControl) - d_func()->exposureControl->setExposureParameter(QCameraExposureControl::ISO, QVariant(iso)); -} - -/*! - \fn QCameraExposure::setAutoIsoSensitivity() - Turn on auto sensitivity - \since 1.1 -*/ - -void QCameraExposure::setAutoIsoSensitivity() -{ - if (d_func()->exposureControl) - d_func()->exposureControl->setExposureParameter(QCameraExposureControl::ISO, QVariant()); -} - -/*! - \property QCameraExposure::shutterSpeed - \brief Camera's shutter speed in seconds. - - \since 1.1 - \sa supportedShutterSpeeds(), setAutoShutterSpeed(), setManualShutterSpeed() -*/ - -/*! - \fn QCameraExposure::shutterSpeedChanged(qreal speed) - - Signals that a camera's shutter \a speed has changed. - \since 1.1 -*/ - -/*! - \property QCameraExposure::isoSensitivity - \brief The sensor ISO sensitivity. - - \sa supportedIsoSensitivities(), setAutoIsoSensitivity(), setManualIsoSensitivity() - \since 1.1 -*/ - -/*! - \property QCameraExposure::aperture - \brief Lens aperture is specified as an F number, the ratio of the focal length to effective aperture diameter. - - \since 1.1 - \sa supportedApertures(), setAutoAperture(), setManualAperture() -*/ - - -qreal QCameraExposure::aperture() const -{ - if (d_func()->exposureControl) - return d_func()->exposureControl->exposureParameter(QCameraExposureControl::Aperture).toReal(); - - return -1.0; -} - -/*! - Returns the list of aperture values camera supports. - The apertures list can change depending on the focal length, - in such a case the apertureRangeChanged() signal is emitted. - - If the camera supports arbitrary aperture values within the supported range, - *\a continuous is set to true, otherwise *\a continuous is set to false. - \since 1.1 -*/ -QList QCameraExposure::supportedApertures(bool * continuous) const -{ - QList res; - QCameraExposureControl *control = d_func()->exposureControl; - - if (!control) - return res; - - foreach (const QVariant &value, - control->supportedParameterRange(QCameraExposureControl::Aperture)) { - bool ok = false; - qreal realValue = value.toReal(&ok); - if (ok) - res.append(realValue); - else - qWarning() << "Incompatible aperture value type, qreal is expected"; - } - - if (continuous) - *continuous = control->exposureParameterFlags(QCameraExposureControl::Aperture) & - QCameraExposureControl::ContinuousRange; - - return res; -} - -/*! - \fn QCameraExposure::setManualAperture(qreal aperture) - Sets the manual camera \a aperture value. - \since 1.1 -*/ - -void QCameraExposure::setManualAperture(qreal aperture) -{ - if (d_func()->exposureControl) - d_func()->exposureControl->setExposureParameter(QCameraExposureControl::Aperture, QVariant(aperture)); -} - -/*! - \fn QCameraExposure::setAutoAperture() - Turn on auto aperture - \since 1.1 -*/ - -void QCameraExposure::setAutoAperture() -{ - if (d_func()->exposureControl) - d_func()->exposureControl->setExposureParameter(QCameraExposureControl::Aperture, QVariant()); -} - -/*! - Returns the current shutter speed in seconds. - \since 1.1 -*/ - -qreal QCameraExposure::shutterSpeed() const -{ - if (d_func()->exposureControl) - return d_func()->exposureControl->exposureParameter(QCameraExposureControl::ShutterSpeed).toReal(); - - return -1.0; -} - -/*! - Returns the list of shutter speed values in seconds camera supports. - - If the camera supports arbitrary shutter speed values within the supported range, - *\a continuous is set to true, otherwise *\a continuous is set to false. - \since 1.1 -*/ -QList QCameraExposure::supportedShutterSpeeds(bool *continuous) const -{ - QList res; - - QCameraExposureControl *control = d_func()->exposureControl; - if (!control) - return res; - - foreach (const QVariant &value, - control->supportedParameterRange(QCameraExposureControl::ShutterSpeed)) { - bool ok = false; - qreal realValue = value.toReal(&ok); - if (ok) - res.append(realValue); - else - qWarning() << "Incompatible shutter speed value type, qreal is expected"; - } - - if (continuous) - *continuous = control->exposureParameterFlags(QCameraExposureControl::ShutterSpeed) & - QCameraExposureControl::ContinuousRange; - - return res; -} - -/*! - Set the manual shutter speed to \a seconds - \since 1.1 -*/ - -void QCameraExposure::setManualShutterSpeed(qreal seconds) -{ - if (d_func()->exposureControl) - d_func()->exposureControl->setExposureParameter(QCameraExposureControl::ShutterSpeed, QVariant(seconds)); -} - -/*! - Turn on auto shutter speed - \since 1.1 -*/ - -void QCameraExposure::setAutoShutterSpeed() -{ - if (d_func()->exposureControl) - d_func()->exposureControl->setExposureParameter(QCameraExposureControl::ShutterSpeed, QVariant()); -} - - -/*! - \enum QCameraExposure::FlashMode - - \value FlashOff Flash is Off. - \value FlashOn Flash is On. - \value FlashAuto Automatic flash. - \value FlashRedEyeReduction Red eye reduction flash. - \value FlashFill Use flash to fillin shadows. - \value FlashTorch Constant light source, useful for focusing and video capture. - \value FlashSlowSyncFrontCurtain - Use the flash in conjunction with a slow shutter speed. - This mode allows better exposure of distant objects and/or motion blur effect. - \value FlashSlowSyncRearCurtain - The similar mode to FlashSlowSyncFrontCurtain but flash is fired at the end of exposure. - \value FlashManual Flash power is manualy set. -*/ - -/*! - \enum QCameraExposure::ExposureMode - - \value ExposureManual Manual mode. - \value ExposureAuto Automatic mode. - \value ExposureNight Night mode. - \value ExposureBacklight Backlight exposure mode. - \value ExposureSpotlight Spotlight exposure mode. - \value ExposureSports Spots exposure mode. - \value ExposureSnow Snow exposure mode. - \value ExposureBeach Beach exposure mode. - \value ExposureLargeAperture Use larger aperture with small depth of field. - \value ExposureSmallAperture Use smaller aperture. - \value ExposurePortrait Portrait exposure mode. - \value ExposureModeVendor The base value for device specific exposure modes. -*/ - -/*! - \enum QCameraExposure::MeteringMode - - \value MeteringAverage Center weighted average metering mode. - \value MeteringSpot Spot metering mode. - \value MeteringMatrix Matrix metering mode. -*/ - -/*! - \property QCameraExposure::flashReady - \brief Indicates if the flash is charged and ready to use. - \since 1.1 -*/ - -/*! - \fn void QCameraExposure::flashReady(bool ready) - - Signal the flash \a ready status has changed. - \since 1.1 -*/ - -/*! - \fn void QCameraExposure::apertureChanged(qreal value) - - Signal emitted when aperature changes to \a value. - \since 1.1 -*/ - -/*! - \fn void QCameraExposure::apertureRangeChanged() - - Signal emitted when aperature range has changed. - \since 1.1 -*/ - - -/*! - \fn void QCameraExposure::shutterSpeedRangeChanged() - - Signal emitted when the shutter speed range has changed. - \since 1.1 -*/ - - -/*! - \fn void QCameraExposure::isoSensitivityChanged(int value) - - Signal emitted when sensitivity changes to \a value. - \since 1.1 -*/ - -/*! - \fn void QCameraExposure::exposureCompensationChanged(qreal value) - - Signal emitted when the exposure compensation changes to \a value. - \since 1.1 -*/ - -#include "moc_qcameraexposure.cpp" -QT_END_NAMESPACE diff --git a/src/multimediakit/qcameraexposure.h b/src/multimediakit/qcameraexposure.h deleted file mode 100644 index 088e7c036..000000000 --- a/src/multimediakit/qcameraexposure.h +++ /dev/null @@ -1,185 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QCAMERAEXPOSURE_H -#define QCAMERAEXPOSURE_H - -#include -#include - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -QT_MODULE(Multimedia) - - -class QCamera; -class QCameraExposurePrivate; - -class Q_MULTIMEDIA_EXPORT QCameraExposure : public QObject -{ - Q_OBJECT - Q_PROPERTY(qreal aperture READ aperture NOTIFY apertureChanged) - Q_PROPERTY(qreal shutterSpeed READ shutterSpeed NOTIFY shutterSpeedChanged) - Q_PROPERTY(int isoSensitivity READ isoSensitivity NOTIFY isoSensitivityChanged) - Q_PROPERTY(qreal exposureCompensation READ exposureCompensation WRITE setExposureCompensation NOTIFY exposureCompensationChanged) - Q_PROPERTY(bool flashReady READ isFlashReady NOTIFY flashReady) - Q_PROPERTY(QCameraExposure::FlashModes flashMode READ flashMode WRITE setFlashMode) - Q_PROPERTY(QCameraExposure::ExposureMode exposureMode READ exposureMode WRITE setExposureMode) - Q_PROPERTY(QCameraExposure::MeteringMode meteringMode READ meteringMode WRITE setMeteringMode) - - Q_ENUMS(FlashMode) - Q_ENUMS(ExposureMode) - Q_ENUMS(MeteringMode) -public: - enum FlashMode { - FlashAuto = 0x1, - FlashOff = 0x2, - FlashOn = 0x4, - FlashRedEyeReduction = 0x8, - FlashFill = 0x10, - FlashTorch = 0x20, - FlashSlowSyncFrontCurtain = 0x40, - FlashSlowSyncRearCurtain = 0x80, - FlashManual = 0x100 - }; - Q_DECLARE_FLAGS(FlashModes, FlashMode) - - enum ExposureMode { - ExposureAuto = 0, - ExposureManual = 1, - ExposurePortrait = 2, - ExposureNight = 3, - ExposureBacklight = 4, - ExposureSpotlight = 5, - ExposureSports = 6, - ExposureSnow = 7, - ExposureBeach = 8, - ExposureLargeAperture = 9, - ExposureSmallAperture = 10, - ExposureModeVendor = 1000 - }; - - enum MeteringMode { - MeteringMatrix = 1, - MeteringAverage = 2, - MeteringSpot = 3 - }; - - bool isAvailable() const; - - FlashModes flashMode() const; - bool isFlashModeSupported(FlashModes mode) const; - bool isFlashReady() const; - - ExposureMode exposureMode() const; - bool isExposureModeSupported(ExposureMode mode) const; - - qreal exposureCompensation() const; - - MeteringMode meteringMode() const; - - bool isMeteringModeSupported(MeteringMode mode) const; - - int isoSensitivity() const; - QList supportedIsoSensitivities(bool *continuous = 0) const; - - qreal aperture() const; - QList supportedApertures(bool *continuous = 0) const; - - qreal shutterSpeed() const; - QList supportedShutterSpeeds(bool *continuous = 0) const; - -public Q_SLOTS: - void setFlashMode(FlashModes mode); - void setExposureMode(ExposureMode mode); - - void setExposureCompensation(qreal ev); - - void setMeteringMode(MeteringMode mode); - - void setManualIsoSensitivity(int iso); - void setAutoIsoSensitivity(); - - void setManualAperture(qreal aperture); - void setAutoAperture(); - - void setManualShutterSpeed(qreal seconds); - void setAutoShutterSpeed(); - -Q_SIGNALS: - void flashReady(bool); - - void apertureChanged(qreal); - void apertureRangeChanged(); - void shutterSpeedChanged(qreal); - void shutterSpeedRangeChanged(); - void isoSensitivityChanged(int); - void exposureCompensationChanged(qreal); - -private: - friend class QCamera; - explicit QCameraExposure(QCamera *parent = 0); - virtual ~QCameraExposure(); - - Q_DISABLE_COPY(QCameraExposure) - Q_DECLARE_PRIVATE(QCameraExposure) - Q_PRIVATE_SLOT(d_func(), void _q_exposureParameterChanged(int)) - Q_PRIVATE_SLOT(d_func(), void _q_exposureParameterRangeChanged(int)) - QCameraExposurePrivate *d_ptr; -}; - -Q_DECLARE_OPERATORS_FOR_FLAGS(QCameraExposure::FlashModes) - -QT_END_NAMESPACE - -Q_DECLARE_METATYPE(QCameraExposure::ExposureMode) -Q_DECLARE_METATYPE(QCameraExposure::FlashModes) -Q_DECLARE_METATYPE(QCameraExposure::MeteringMode) - -Q_MEDIA_ENUM_DEBUG(QCameraExposure, ExposureMode) -Q_MEDIA_ENUM_DEBUG(QCameraExposure, FlashMode) -Q_MEDIA_ENUM_DEBUG(QCameraExposure, MeteringMode) - -QT_END_HEADER - -#endif // QCAMERAEXPOSURE_H diff --git a/src/multimediakit/qcameraexposurecontrol.cpp b/src/multimediakit/qcameraexposurecontrol.cpp deleted file mode 100644 index edf127de5..000000000 --- a/src/multimediakit/qcameraexposurecontrol.cpp +++ /dev/null @@ -1,252 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include -#include "qmediacontrol_p.h" - -QT_BEGIN_NAMESPACE - -/*! - \class QCameraExposureControl - - \brief The QCameraExposureControl class allows controlling camera exposure parameters. - - \inmodule QtMultimediaKit - \ingroup multimedia-serv - \since 1.1 - - You can adjust a number of parameters that will affect images and video taken with - the corresponding QCamera object. - - There are a number of different parameters that can be adjusted, including: - - \table - \row - \header - \ - - \endtable - - The interface name of QCameraExposureControl is \c com.nokia.Qt.QCameraExposureControl/1.0 as - defined in QCameraExposureControl_iid. - - \sa QCamera -*/ - -/*! - \macro QCameraExposureControl_iid - - \c com.nokia.Qt.QCameraExposureControl/1.0 - - Defines the interface name of the QCameraExposureControl class. - - \relates QCameraExposureControl -*/ - -/*! - Constructs a camera exposure control object with \a parent. -*/ -QCameraExposureControl::QCameraExposureControl(QObject *parent): - QMediaControl(*new QMediaControlPrivate, parent) -{ -} - -/*! - Destroys the camera control object. -*/ -QCameraExposureControl::~QCameraExposureControl() -{ -} - -/*! - \fn QCamera::ExposureMode QCameraExposureControl::exposureMode() const - - Returns the exposure mode. - \since 1.1 -*/ - - -/*! - \fn void QCameraExposureControl::setExposureMode(QCameraExposure::ExposureMode mode) - - Set the exposure mode to \a mode. - \since 1.1 -*/ - - -/*! - \fn bool QCameraExposureControl::isExposureModeSupported(QCameraExposure::ExposureMode mode) const - - Returns true if the exposure \a mode is supported. - \since 1.1 -*/ - - -/*! - \fn QCameraExposure::MeteringMode QCameraExposureControl::meteringMode() const - Returns the current metering mode. - \since 1.1 -*/ - -/*! - \fn void QCameraExposureControl::setMeteringMode(QCameraExposure::MeteringMode mode) - - Set the metering mode to \a mode. - \since 1.1 -*/ - - -/*! - \fn bool QCameraExposureControl::isMeteringModeSupported(QCameraExposure::MeteringMode mode) const - Returns true if the metering \a mode is supported. - \since 1.1 -*/ - -/*! - \enum QCameraExposureControl::ExposureParameter - \value InvalidParameter - Parameter is invalid. - \value ISO - Camera ISO sensitivity, specified as integer value. - \value Aperture - Lens aperture is specified as an qreal F number. - The supported apertures list can change depending on the focal length, - in such a case the exposureParameterRangeChanged() signal is emitted. - \value ShutterSpeed - Shutter speed in seconds, specified as qreal. - \value ExposureCompensation - Exposure compensation, specified as qreal EV value. - \value FlashPower - Manual flash power, specified as qreal value. - Accepted power range is [0..1.0], - with 0 value means no flash and 1.0 corresponds to full flash power. - - This value is only used in the \l{QCameraExposure::FlashManual}{manual flash mode}. - \value FlashCompensation - Flash compensation, specified as qreal EV value. - \value ExtendedExposureParameter - The base value for platform specific extended parameters. - For such parameters the sequential values starting from ExtendedExposureParameter shuld be used. -*/ - -/*! - \enum QCameraExposureControl::ParameterFlag - \value AutomaticValue - Use the automatic values for parameters. - \value ReadOnly - Parameters are read only. - \value ContinuousRange - Parameters are continuous in their range. -*/ - -/*! - \fn QCameraExposureControl::isParameterSupported(ExposureParameter parameter) const - - Returns true is exposure \a parameter is supported by backend. - \since 1.1 -*/ - -/*! - \fn QCameraExposureControl::exposureParameter(ExposureParameter parameter) const - - Returns the exposure \a parameter value, or invalid QVariant() if the value is unknown or not supported. - \since 1.1 -*/ - -/*! - \fn QCameraExposureControl::exposureParameterFlags(ExposureParameter parameter) const - - Returns the properties of exposure \a parameter. - \since 1.1 -*/ - - -/*! - \fn QCameraExposureControl::supportedParameterRange(ExposureParameter parameter) const - - Returns the list of supported \a parameter values; - \since 1.1 -*/ - -/*! - \fn bool QCameraExposureControl::setExposureParameter(ExposureParameter parameter, const QVariant& value) - - Set the exposure \a parameter to \a value. - If a null or invalid QVariant is passed, backend should choose the value automatically, - and if possible report the actual value to user with QCameraExposureControl::exposureParameter(). - - Returns true if parameter is supported and value is correct. - \since 1.1 -*/ - -/*! - \fn QCameraExposureControl::extendedParameterName(ExposureParameter parameter) - - Returns the extended exposure \a parameter name. - \since 1.1 -*/ - -/*! - \fn void QCameraExposureControl::flashReady(bool ready) - - Signal emitted when flash state changes, flash is charged \a ready. - \since 1.1 -*/ - -/*! - \fn void QCameraExposureControl::exposureParameterChanged(int parameter) - - Signal emitted when the exposure \a parameter has changed. - \since 1.1 -*/ - -/*! - - \fn void QCameraExposureControl::exposureParameterRangeChanged(int parameter) - - Signal emitted when the exposure \a parameter range has changed. - \since 1.1 -*/ - - -#include "moc_qcameraexposurecontrol.cpp" -QT_END_NAMESPACE - diff --git a/src/multimediakit/qcameraexposurecontrol.h b/src/multimediakit/qcameraexposurecontrol.h deleted file mode 100644 index ff60784bf..000000000 --- a/src/multimediakit/qcameraexposurecontrol.h +++ /dev/null @@ -1,124 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QCAMERAEXPOSURECONTROL_H -#define QCAMERAEXPOSURECONTROL_H - -#include -#include - -#include -#include -#include - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -QT_MODULE(Multimedia) - - -class Q_MULTIMEDIA_EXPORT QCameraExposureControl : public QMediaControl -{ - Q_OBJECT - Q_ENUMS(ExposureParameter) - -public: - ~QCameraExposureControl(); - - enum ExposureParameter { - InvalidParameter = 0, - ISO = 1, - Aperture = 2, - ShutterSpeed = 3, - ExposureCompensation = 4, - FlashPower = 5, - FlashCompensation = 6, - ExtendedExposureParameter = 1000 - }; - - enum ParameterFlag { - AutomaticValue = 0x01, - ReadOnly = 0x02, - ContinuousRange = 0x04 - }; - Q_DECLARE_FLAGS(ParameterFlags, ParameterFlag) - - virtual QCameraExposure::ExposureMode exposureMode() const = 0; - virtual void setExposureMode(QCameraExposure::ExposureMode mode) = 0; - virtual bool isExposureModeSupported(QCameraExposure::ExposureMode mode) const = 0; - - virtual QCameraExposure::MeteringMode meteringMode() const = 0; - virtual void setMeteringMode(QCameraExposure::MeteringMode mode) = 0; - virtual bool isMeteringModeSupported(QCameraExposure::MeteringMode mode) const = 0; - - virtual bool isParameterSupported(ExposureParameter parameter) const = 0; - virtual QVariant exposureParameter(ExposureParameter parameter) const = 0; - virtual ParameterFlags exposureParameterFlags(ExposureParameter parameter) const = 0; - virtual QVariantList supportedParameterRange(ExposureParameter parameter) const = 0; - virtual bool setExposureParameter(ExposureParameter parameter, const QVariant& value) = 0; - - virtual QString extendedParameterName(ExposureParameter parameter) = 0; - -Q_SIGNALS: - void flashReady(bool); - - void exposureParameterChanged(int parameter); - void exposureParameterRangeChanged(int parameter); - -protected: - QCameraExposureControl(QObject* parent = 0); -}; - -#define QCameraExposureControl_iid "com.nokia.Qt.QCameraExposureControl/1.0" -Q_MEDIA_DECLARE_CONTROL(QCameraExposureControl, QCameraExposureControl_iid) - -Q_DECLARE_OPERATORS_FOR_FLAGS(QCameraExposureControl::ParameterFlags) - -Q_MEDIA_ENUM_DEBUG(QCameraExposureControl, ExposureParameter) - -QT_END_NAMESPACE - -QT_END_HEADER - - -#endif // QCAMERAEXPOSURECONTROL_H - diff --git a/src/multimediakit/qcameraflashcontrol.cpp b/src/multimediakit/qcameraflashcontrol.cpp deleted file mode 100644 index 66550baf5..000000000 --- a/src/multimediakit/qcameraflashcontrol.cpp +++ /dev/null @@ -1,141 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include -#include "qmediacontrol_p.h" - -QT_BEGIN_NAMESPACE - -/*! - \class QCameraFlashControl - - \brief The QCameraFlashControl class allows controlling a camera's flash. - - \ingroup multimedia-serv - \inmodule QtMultimediaKit - \since 1.1 - - \inmodule QtMultimediaKit - - You can set the type of flash effect used when an image is captured, and test to see - if the flash hardware is ready to fire. - - You can retrieve this control from the camera object in the usual way: - - Some camera devices may not have flash hardware, or may not be configurable. In that - case, there will be no QCameraFlashControl available. - - The interface name of QCameraFlashControl is \c com.nokia.Qt.QCameraFlashControl/1.0 as - defined in QCameraFlashControl_iid. - - \sa QCamera -*/ - -/*! - \macro QCameraFlashControl_iid - - \c com.nokia.Qt.QCameraFlashControl/1.0 - - Defines the interface name of the QCameraFlashControl class. - - \relates QCameraFlashControl -*/ - -/*! - Constructs a camera flash control object with \a parent. -*/ -QCameraFlashControl::QCameraFlashControl(QObject *parent): - QMediaControl(*new QMediaControlPrivate, parent) -{ -} - -/*! - Destroys the camera control object. -*/ -QCameraFlashControl::~QCameraFlashControl() -{ -} - -/*! - \fn QCamera::FlashModes QCameraFlashControl::flashMode() const - - Returns the current flash mode. - \since 1.1 -*/ - -/*! - \fn void QCameraFlashControl::setFlashMode(QCameraExposure::FlashModes mode) - - Set the current flash \a mode. - - Usually a single QCameraExposure::FlashMode flag is used, - but some non conflicting flags combination are also allowed, - like QCameraExposure::FlashManual | QCameraExposure::FlashSlowSyncRearCurtain. - \since 1.1 -*/ - - -/*! - \fn QCameraFlashControl::isFlashModeSupported(QCameraExposure::FlashModes mode) const - - Return true if the reqested flash \a mode is supported. - Some QCameraExposure::FlashMode values can be combined, - for example QCameraExposure::FlashManual | QCameraExposure::FlashSlowSyncRearCurtain - \since 1.1 -*/ - -/*! - \fn bool QCameraFlashControl::isFlashReady() const - - Returns true if flash is charged. - \since 1.1 -*/ - -/*! - \fn void QCameraFlashControl::flashReady(bool ready) - - Signal emitted when flash state changes to \a ready. - \since 1.1 -*/ - -#include "moc_qcameraflashcontrol.cpp" -QT_END_NAMESPACE - diff --git a/src/multimediakit/qcameraflashcontrol.h b/src/multimediakit/qcameraflashcontrol.h deleted file mode 100644 index 89b3b9d06..000000000 --- a/src/multimediakit/qcameraflashcontrol.h +++ /dev/null @@ -1,87 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QCAMERAFLASHCONTROL_H -#define QCAMERAFLASHCONTROL_H - -#include -#include - -#include -#include - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -QT_MODULE(Multimedia) - - -class Q_MULTIMEDIA_EXPORT QCameraFlashControl : public QMediaControl -{ - Q_OBJECT - -public: - ~QCameraFlashControl(); - - virtual QCameraExposure::FlashModes flashMode() const = 0; - virtual void setFlashMode(QCameraExposure::FlashModes mode) = 0; - virtual bool isFlashModeSupported(QCameraExposure::FlashModes mode) const = 0; - - virtual bool isFlashReady() const = 0; - -Q_SIGNALS: - void flashReady(bool); - -protected: - QCameraFlashControl(QObject* parent = 0); -}; - -#define QCameraFlashControl_iid "com.nokia.Qt.QCameraFlashControl/1.0" -Q_MEDIA_DECLARE_CONTROL(QCameraFlashControl, QCameraFlashControl_iid) - -QT_END_NAMESPACE - -QT_END_HEADER - - -#endif // QCAMERAFLASHCONTROL_H - diff --git a/src/multimediakit/qcamerafocus.cpp b/src/multimediakit/qcamerafocus.cpp deleted file mode 100644 index 8db33ff29..000000000 --- a/src/multimediakit/qcamerafocus.cpp +++ /dev/null @@ -1,478 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include - -#include -#include - -#include -#include -#include -#include -#include -#include -#include - -QT_BEGIN_NAMESPACE - -namespace -{ -class CameraFocusRegisterMetaTypes -{ -public: - CameraFocusRegisterMetaTypes() - { - qRegisterMetaType("QCameraFocus::FocusModes"); - qRegisterMetaType("QCameraFocus::FocusPointMode"); - } -} _registerCameraFocusMetaTypes; -} - - -class QCameraFocusZoneData : public QSharedData -{ -public: - QCameraFocusZoneData(): - status(QCameraFocusZone::Invalid) - { - - } - - QCameraFocusZoneData(const QRectF &_area, QCameraFocusZone::FocusZoneStatus _status): - area(_area), - status(_status) - { - - } - - - QCameraFocusZoneData(const QCameraFocusZoneData &other): - QSharedData(other), - area(other.area), - status(other.status) - { - } - - QCameraFocusZoneData& operator=(const QCameraFocusZoneData &other) - { - area = other.area; - status = other.status; - return *this; - } - - QRectF area; - QCameraFocusZone::FocusZoneStatus status; -}; - -QCameraFocusZone::QCameraFocusZone() - :d(new QCameraFocusZoneData) -{ - -} - -QCameraFocusZone::QCameraFocusZone(const QRectF &area, QCameraFocusZone::FocusZoneStatus status) - :d(new QCameraFocusZoneData(area, status)) -{ -} - -QCameraFocusZone::QCameraFocusZone(const QCameraFocusZone &other) - :d(other.d) -{ - -} - -QCameraFocusZone::~QCameraFocusZone() -{ - -} - -QCameraFocusZone& QCameraFocusZone::operator=(const QCameraFocusZone &other) -{ - d = other.d; - return *this; -} - -bool QCameraFocusZone::operator==(const QCameraFocusZone &other) const -{ - return d == other.d || - (d->area == other.d->area && d->status == other.d->status); -} - -bool QCameraFocusZone::operator!=(const QCameraFocusZone &other) const -{ - return !(*this == other); -} - -bool QCameraFocusZone::isValid() const -{ - return d->status != Invalid && !d->area.isValid(); -} - -QRectF QCameraFocusZone::area() const -{ - return d->area; -} - -QCameraFocusZone::FocusZoneStatus QCameraFocusZone::status() const -{ - return d->status; -} - -void QCameraFocusZone::setStatus(QCameraFocusZone::FocusZoneStatus status) -{ - d->status = status; -} - - -/*! - \class QCameraFocus - - - \brief The QCameraFocus class provides interface for - focus and zoom related camera settings. - - \inmodule QtMultimediaKit - \ingroup camera - \since 1.1 - -*/ - - -class QCameraFocusPrivate : public QMediaObjectPrivate -{ - Q_DECLARE_NON_CONST_PUBLIC(QCameraFocus) -public: - void initControls(); - - QCameraFocus *q_ptr; - - QCamera *camera; - QCameraFocusControl *focusControl; -}; - - -void QCameraFocusPrivate::initControls() -{ - Q_Q(QCameraFocus); - - focusControl = 0; - - QMediaService *service = camera->service(); - if (service) - focusControl = qobject_cast(service->requestControl(QCameraFocusControl_iid)); - - if (focusControl) { - q->connect(focusControl, SIGNAL(opticalZoomChanged(qreal)), q, SIGNAL(opticalZoomChanged(qreal))); - q->connect(focusControl, SIGNAL(digitalZoomChanged(qreal)), q, SIGNAL(digitalZoomChanged(qreal))); - q->connect(focusControl, SIGNAL(maximumOpticalZoomChanged(qreal)), - q, SIGNAL(maximumOpticalZoomChanged(qreal))); - q->connect(focusControl, SIGNAL(maximumDigitalZoomChanged(qreal)), - q, SIGNAL(maximumDigitalZoomChanged(qreal))); - q->connect(focusControl, SIGNAL(focusZonesChanged()), q, SIGNAL(focusZonesChanged())); - } -} - -/*! - Construct a QCameraFocus for \a camera. -*/ - -QCameraFocus::QCameraFocus(QCamera *camera): - QObject(camera), d_ptr(new QCameraFocusPrivate) -{ - Q_D(QCameraFocus); - d->camera = camera; - d->q_ptr = this; - d->initControls(); -} - - -/*! - Destroys the camera focus object. -*/ - -QCameraFocus::~QCameraFocus() -{ -} - -/*! - Returns true if focus related settings are supported by this camera. - \since 1.1 -*/ -bool QCameraFocus::isAvailable() const -{ - return d_func()->focusControl != 0; -} - -/*! - \property QCameraFocus::focusMode - \brief The current camera focus mode. - - \since 1.1 - \sa QCameraFocus::isFocusModeSupported() -*/ - -QCameraFocus::FocusMode QCameraFocus::focusMode() const -{ - return d_func()->focusControl ? d_func()->focusControl->focusMode() : QCameraFocus::AutoFocus; -} - -void QCameraFocus::setFocusMode(QCameraFocus::FocusMode mode) -{ - if (d_func()->focusControl) - d_func()->focusControl->setFocusMode(mode); -} - -/*! - Returns true if the focus \a mode is supported by camera. - \since 1.1 -*/ - -bool QCameraFocus::isFocusModeSupported(QCameraFocus::FocusMode mode) const -{ - return d_func()->focusControl ? d_func()->focusControl->isFocusModeSupported(mode) : false; -} - -/*! - \property QCameraFocus::focusPointMode - \brief The current camera focus point selection mode. - - \sa QCameraFocus::isFocusPointModeSupported() - \since 1.1 -*/ - -QCameraFocus::FocusPointMode QCameraFocus::focusPointMode() const -{ - return d_func()->focusControl ? - d_func()->focusControl->focusPointMode() : - QCameraFocus::FocusPointAuto; -} - -void QCameraFocus::setFocusPointMode(QCameraFocus::FocusPointMode mode) -{ - if (d_func()->focusControl) - d_func()->focusControl->setFocusPointMode(mode); - else - qWarning("Focus points mode selection is not supported"); -} - -/*! - Returns true if focus point \a mode is supported. - \since 1.1 - */ -bool QCameraFocus::isFocusPointModeSupported(QCameraFocus::FocusPointMode mode) const -{ - return d_func()->focusControl ? - d_func()->focusControl->isFocusPointModeSupported(mode) : - false; - -} - -/*! - \property QCameraFocus::customFocusPoint - - Position of custom focus point, in relative frame coordinates: - QPointF(0,0) points to the left top frame point, QPointF(0.5,0.5) points to the frame center. - - Custom focus point is used only in FocusPointCustom focus mode. - \since 1.1 - */ - -QPointF QCameraFocus::customFocusPoint() const -{ - return d_func()->focusControl ? - d_func()->focusControl->customFocusPoint() : - QPointF(0.5,0.5); -} - -void QCameraFocus::setCustomFocusPoint(const QPointF &point) -{ - if (d_func()->focusControl) - d_func()->focusControl->setCustomFocusPoint(point); - else - qWarning("Focus points selection is not supported"); - -} - -/*! - \property QCameraFocus::focusZones - - Returns the list of active focus zones. - - If QCamera::FocusPointAuto or QCamera::FocusPointFaceDetection focus mode is selected - this method returns the list of zones the camera is actually focused on. - - The coordinates system is the same as for custom focus points: - QPointF(0,0) points to the left top frame point, QPointF(0.5,0.5) points to the frame center. - \since 1.1 - */ -QCameraFocusZoneList QCameraFocus::focusZones() const -{ - return d_func()->focusControl ? - d_func()->focusControl->focusZones() : - QCameraFocusZoneList(); -} - -/*! - Returns the maximum optical zoom - \since 1.1 -*/ - -qreal QCameraFocus::maximumOpticalZoom() const -{ - return d_func()->focusControl ? d_func()->focusControl->maximumOpticalZoom() : 1.0; -} - -/*! - Returns the maximum digital zoom - \since 1.1 -*/ - -qreal QCameraFocus::maximumDigitalZoom() const -{ - return d_func()->focusControl ? d_func()->focusControl->maximumDigitalZoom() : 1.0; -} - -/*! - \property QCameraFocus::opticalZoom - \brief The current optical zoom value. - - \since 1.1 - \sa QCameraFocus::digitalZoom -*/ - -qreal QCameraFocus::opticalZoom() const -{ - return d_func()->focusControl ? d_func()->focusControl->opticalZoom() : 1.0; -} - -/*! - \property QCameraFocus::digitalZoom - \brief The current digital zoom value. - - \since 1.1 - \sa QCameraFocus::opticalZoom -*/ -qreal QCameraFocus::digitalZoom() const -{ - return d_func()->focusControl ? d_func()->focusControl->digitalZoom() : 1.0; -} - - -/*! - Set the camera \a optical and \a digital zoom values. - \since 1.1 -*/ -void QCameraFocus::zoomTo(qreal optical, qreal digital) -{ - if (d_func()->focusControl) - d_func()->focusControl->zoomTo(optical, digital); - else - qWarning("The camera doesn't support zooming."); -} - -/*! - \enum QCameraFocus::FocusMode - - \value ManualFocus Manual or fixed focus mode. - \value AutoFocus One-shot auto focus mode. - \value ContinuousFocus Continuous auto focus mode. - \value InfinityFocus Focus strictly to infinity. - \value HyperfocalFocus Focus to hyperfocal distance, with with the maximum depth of field achieved. - All objects at distances from half of this - distance out to infinity will be acceptably sharp. - \value MacroFocus One shot auto focus to objects close to camera. -*/ - -/*! - \enum QCameraFocus::FocusPointMode - - \value FocusPointAuto Automatically select one or multiple focus points. - \value FocusPointCenter Focus to the frame center. - \value FocusPointFaceDetection Focus on faces in the frame. - \value FocusPointCustom Focus to the custom point, defined by QCameraFocus::customFocusPoint property. -*/ - -/*! - \fn void QCameraFocus::opticalZoomChanged(qreal value) - - Signal emitted when optical zoom value changes to new \a value. - \since 1.1 -*/ - -/*! - \fn void QCameraFocus::digitalZoomChanged(qreal value) - - Signal emitted when digital zoom value changes to new \a value. - \since 1.1 -*/ - -/*! - \fn void QCameraFocus::maximumOpticalZoomChanged(qreal zoom) - - Signal emitted when the maximum supported optical \a zoom value changed. - \since 1.1 -*/ - -/*! - \fn void QCameraFocus::maximumDigitalZoomChanged(qreal zoom) - - Signal emitted when the maximum supported digital \a zoom value changed. - - The maximum supported zoom value can depend on other camera settings, - like capture mode or resolution. - \since 1.1 -*/ - - - -/*! - \fn QCameraFocus::focusZonesChanged() - - Signal is emitted when the set of zones, camera focused on is changed. - - Usually the zones list is changed when the camera is focused. - \since 1.1 -*/ - - -#include "moc_qcamerafocus.cpp" -QT_END_NAMESPACE diff --git a/src/multimediakit/qcamerafocus.h b/src/multimediakit/qcamerafocus.h deleted file mode 100644 index 064af7aa1..000000000 --- a/src/multimediakit/qcamerafocus.h +++ /dev/null @@ -1,183 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QCAMERAFOCUS_H -#define QCAMERAFOCUS_H - -#include -#include -#include -#include -#include -#include - -#include -#include - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -QT_MODULE(Multimedia) - - -class QCamera; - -class QCameraFocusZoneData; - -class Q_MULTIMEDIA_EXPORT QCameraFocusZone { -public: - enum FocusZoneStatus { - Invalid, - Unused, - Selected, - Focused - }; - - QCameraFocusZone(); - QCameraFocusZone(const QRectF &area, FocusZoneStatus status = Selected); - QCameraFocusZone(const QCameraFocusZone &other); - - QCameraFocusZone& operator=(const QCameraFocusZone &other); - bool operator==(const QCameraFocusZone &other) const; - bool operator!=(const QCameraFocusZone &other) const; - - ~QCameraFocusZone(); - - bool isValid() const; - - QRectF area() const; - - FocusZoneStatus status() const; - void setStatus(FocusZoneStatus status); - -private: - QSharedDataPointer d; -}; - -typedef QList QCameraFocusZoneList; - - -class QCameraFocusPrivate; -class Q_MULTIMEDIA_EXPORT QCameraFocus : public QObject -{ - Q_OBJECT - - Q_PROPERTY(FocusMode focusMode READ focusMode WRITE setFocusMode) - Q_PROPERTY(FocusPointMode focusPointMode READ focusPointMode WRITE setFocusPointMode) - Q_PROPERTY(QPointF customFocusPoint READ customFocusPoint WRITE setCustomFocusPoint) - Q_PROPERTY(QCameraFocusZoneList focusZones READ focusZones NOTIFY focusZonesChanged) - Q_PROPERTY(qreal opticalZoom READ opticalZoom NOTIFY opticalZoomChanged) - Q_PROPERTY(qreal digitalZoom READ digitalZoom NOTIFY digitalZoomChanged) - - Q_ENUMS(FocusMode) - Q_ENUMS(FocusPointMode) -public: - enum FocusMode { - ManualFocus = 0x1, - HyperfocalFocus = 0x02, - InfinityFocus = 0x04, - AutoFocus = 0x8, - ContinuousFocus = 0x10, - MacroFocus = 0x20 - }; - Q_DECLARE_FLAGS(FocusModes, FocusMode) - - enum FocusPointMode { - FocusPointAuto, - FocusPointCenter, - FocusPointFaceDetection, - FocusPointCustom - }; - - bool isAvailable() const; - - FocusMode focusMode() const; - void setFocusMode(FocusMode mode); - bool isFocusModeSupported(FocusMode mode) const; - - FocusPointMode focusPointMode() const; - void setFocusPointMode(FocusPointMode mode); - bool isFocusPointModeSupported(FocusPointMode) const; - QPointF customFocusPoint() const; - void setCustomFocusPoint(const QPointF &point); - - QCameraFocusZoneList focusZones() const; - - qreal maximumOpticalZoom() const; - qreal maximumDigitalZoom() const; - qreal opticalZoom() const; - qreal digitalZoom() const; - - void zoomTo(qreal opticalZoom, qreal digitalZoom); - -Q_SIGNALS: - void opticalZoomChanged(qreal); - void digitalZoomChanged(qreal); - - void focusZonesChanged(); - - void maximumOpticalZoomChanged(qreal); - void maximumDigitalZoomChanged(qreal); - -private: - friend class QCamera; - QCameraFocus(QCamera *camera); - ~QCameraFocus(); - - Q_DISABLE_COPY(QCameraFocus) - Q_DECLARE_PRIVATE(QCameraFocus) - QCameraFocusPrivate *d_ptr; -}; - -Q_DECLARE_OPERATORS_FOR_FLAGS(QCameraFocus::FocusModes) - -QT_END_NAMESPACE - -Q_DECLARE_METATYPE(QCameraFocus::FocusModes) -Q_DECLARE_METATYPE(QCameraFocus::FocusPointMode) - -Q_MEDIA_ENUM_DEBUG(QCameraFocus, FocusMode) -Q_MEDIA_ENUM_DEBUG(QCameraFocus, FocusPointMode) - -QT_END_HEADER - -#endif // QCAMERAFOCUS_H diff --git a/src/multimediakit/qcamerafocuscontrol.cpp b/src/multimediakit/qcamerafocuscontrol.cpp deleted file mode 100644 index d48cd6c38..000000000 --- a/src/multimediakit/qcamerafocuscontrol.cpp +++ /dev/null @@ -1,253 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include -#include "qmediacontrol_p.h" - -QT_BEGIN_NAMESPACE - -/*! - \class QCameraFocusControl - - - \brief The QCameraFocusControl class supplies control for - focusing related camera parameters. - - \inmodule QtMultimediaKit - \ingroup multimedia-serv - \since 1.1 - - The interface name of QCameraFocusControl is \c com.nokia.Qt.QCameraFocusControl/1.0 as - defined in QCameraFocusControl_iid. - - - \sa QMediaService::requestControl(), QCamera -*/ - -/*! - \macro QCameraFocusControl_iid - - \c com.nokia.Qt.QCameraFocusControl/1.0 - - Defines the interface name of the QCameraFocusControl class. - - \relates QCameraFocusControl -*/ - -/*! - Constructs a camera control object with \a parent. -*/ - -QCameraFocusControl::QCameraFocusControl(QObject *parent): - QMediaControl(*new QMediaControlPrivate, parent) -{ -} - -/*! - Destruct the camera control object. -*/ - -QCameraFocusControl::~QCameraFocusControl() -{ -} - - -/*! - \fn QCameraFocus::FocusMode QCameraFocusControl::focusMode() const - - Returns the focus mode being used. - \since 1.1 -*/ - - -/*! - \fn void QCameraFocusControl::setFocusMode(QCameraFocus::FocusMode mode) - - Set the focus mode to \a mode. - \since 1.1 -*/ - - -/*! - \fn bool QCameraFocusControl::isFocusModeSupported(QCameraFocus::FocusMode mode) const - - Returns true if focus \a mode is supported. - \since 1.1 -*/ - - -/*! - \fn qreal QCameraFocusControl::maximumOpticalZoom() const - - Returns the maximum optical zoom value, or 1.0 if optical zoom is not supported. - \since 1.1 -*/ - - -/*! - \fn qreal QCameraFocusControl::maximumDigitalZoom() const - - Returns the maximum digital zoom value, or 1.0 if digital zoom is not supported. - \since 1.1 -*/ - - -/*! - \fn qreal QCameraFocusControl::opticalZoom() const - - Return the current optical zoom value. - \since 1.1 -*/ - -/*! - \fn qreal QCameraFocusControl::digitalZoom() const - - Return the current digital zoom value. - \since 1.1 -*/ - - -/*! - \fn void QCameraFocusControl::zoomTo(qreal optical, qreal digital) - - Sets \a optical and \a digital zoom values. - \since 1.1 -*/ - -/*! - \fn QCameraFocusControl::focusPointMode() const - - Returns the camera focus point selection mode. - \since 1.1 -*/ - -/*! - \fn QCameraFocusControl::setFocusPointMode(QCameraFocus::FocusPointMode mode) - - Sets the camera focus point selection \a mode. - \since 1.1 -*/ - -/*! - \fn QCameraFocusControl::isFocusPointModeSupported(QCameraFocus::FocusPointMode mode) const - - Returns true if the camera focus point \a mode is supported. - \since 1.1 -*/ - -/*! - \fn QCameraFocusControl::customFocusPoint() const - - Return the position of custom focus point, in relative frame coordinates: - QPointF(0,0) points to the left top frame point, QPointF(0.5,0.5) points to the frame center. - - Custom focus point is used only in FocusPointCustom focus mode. - \since 1.1 -*/ - -/*! - \fn QCameraFocusControl::setCustomFocusPoint(const QPointF &point) - - Sets the custom focus \a point. - - If camera supports fixed set of focus points, - it should use the nearest supported focus point, - and return the actual focus point with QCameraFocusControl::focusZones(). - - \since 1.1 - \sa QCameraFocusControl::customFocusPoint(), QCameraFocusControl::focusZones() -*/ - -/*! - \fn QCameraFocusControl::focusZones() const - - Returns the list of zones, the camera is using for focusing or focused on. - \since 1.1 -*/ - -/*! - \fn void QCameraFocusControl::opticalZoomChanged(qreal zoom) - - Signal emitted when the optical \a zoom value changed. - \since 1.1 -*/ - -/*! - \fn void QCameraFocusControl::digitalZoomChanged(qreal zoom) - - Signal emitted when the digital \a zoom value changed. - \since 1.1 -*/ - -/*! - \fn void QCameraFocusControl::maximumOpticalZoomChanged(qreal zoom) - - Signal emitted when the maximum supported optical \a zoom value changed. - \since 1.1 -*/ - -/*! - \fn void QCameraFocusControl::maximumDigitalZoomChanged(qreal zoom) - - Signal emitted when the maximum supported digital \a zoom value changed. - - The maximum supported zoom value can depend on other camera settings, - like capture mode or resolution. - \since 1.1 -*/ - - -/*! - \fn QCameraFocusControl::focusZonesChanged() - - Signal is emitted when the set of zones, camera focused on is changed. - - Usually the zones list is changed when the camera is focused. - - \since 1.1 - \sa QCameraFocusControl::focusZones() -*/ - - - -#include "moc_qcamerafocuscontrol.cpp" -QT_END_NAMESPACE - diff --git a/src/multimediakit/qcamerafocuscontrol.h b/src/multimediakit/qcamerafocuscontrol.h deleted file mode 100644 index 20ffe6af1..000000000 --- a/src/multimediakit/qcamerafocuscontrol.h +++ /dev/null @@ -1,103 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QCAMERAFOCUSCONTROL_H -#define QCAMERAFOCUSCONTROL_H - -#include -#include - -#include - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -QT_MODULE(Multimedia) - - -class Q_MULTIMEDIA_EXPORT QCameraFocusControl : public QMediaControl -{ - Q_OBJECT - -public: - ~QCameraFocusControl(); - - virtual QCameraFocus::FocusMode focusMode() const = 0; - virtual void setFocusMode(QCameraFocus::FocusMode mode) = 0; - virtual bool isFocusModeSupported(QCameraFocus::FocusMode mode) const = 0; - - virtual qreal maximumOpticalZoom() const = 0; - virtual qreal maximumDigitalZoom() const = 0; - virtual qreal opticalZoom() const = 0; - virtual qreal digitalZoom() const = 0; - - virtual void zoomTo(qreal optical, qreal digital) = 0; - - virtual QCameraFocus::FocusPointMode focusPointMode() const = 0; - virtual void setFocusPointMode(QCameraFocus::FocusPointMode mode) = 0; - virtual bool isFocusPointModeSupported(QCameraFocus::FocusPointMode mode) const = 0; - virtual QPointF customFocusPoint() const = 0; - virtual void setCustomFocusPoint(const QPointF &point) = 0; - - virtual QCameraFocusZoneList focusZones() const = 0; - -Q_SIGNALS: - void opticalZoomChanged(qreal opticalZoom); - void digitalZoomChanged(qreal digitalZoom); - void focusZonesChanged(); - void maximumOpticalZoomChanged(qreal); - void maximumDigitalZoomChanged(qreal); - -protected: - QCameraFocusControl(QObject* parent = 0); -}; - -#define QCameraFocusControl_iid "com.nokia.Qt.QCameraFocusingControl/1.0" -Q_MEDIA_DECLARE_CONTROL(QCameraFocusControl, QCameraFocusControl_iid) - -QT_END_NAMESPACE - -QT_END_HEADER - - -#endif // QCAMERAFOCUSCONTROL_H - diff --git a/src/multimediakit/qcameraimagecapture.cpp b/src/multimediakit/qcameraimagecapture.cpp deleted file mode 100644 index 28372790c..000000000 --- a/src/multimediakit/qcameraimagecapture.cpp +++ /dev/null @@ -1,681 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -QT_BEGIN_NAMESPACE - -/*! - \class QCameraImageCapture - \inmodule QtMultimediaKit - \ingroup camera - \since 1.1 - - - \brief The QCameraImageCapture class is used for the recording of media content. - - The QCameraImageCapture class is a high level images recording class. - It's not intended to be used alone but for accessing the media - recording functions of other media objects, like QCamera. - - \snippet doc/src/snippets/multimedia-snippets/camera.cpp Camera - - \snippet doc/src/snippets/multimedia-snippets/camera.cpp Camera keys - - \sa QCamera -*/ - -namespace -{ -class MediaRecorderRegisterMetaTypes -{ -public: - MediaRecorderRegisterMetaTypes() - { - qRegisterMetaType("QCameraImageCapture::Error"); - qRegisterMetaType("QCameraImageCapture::CaptureDestination"); - qRegisterMetaType("QCameraImageCapture::CaptureDestinations"); - } -} _registerRecorderMetaTypes; -} - - -class QCameraImageCapturePrivate -{ - Q_DECLARE_NON_CONST_PUBLIC(QCameraImageCapture) -public: - QCameraImageCapturePrivate(); - - QMediaObject *mediaObject; - - QCameraImageCaptureControl *control; - QImageEncoderControl *encoderControl; - QCameraCaptureDestinationControl *captureDestinationControl; - QCameraCaptureBufferFormatControl *bufferFormatControl; - - QCameraImageCapture::Error error; - QString errorString; - - void _q_error(int id, int error, const QString &errorString); - void _q_readyChanged(bool); - void _q_serviceDestroyed(); - - void unsetError() { error = QCameraImageCapture::NoError; errorString.clear(); } - - QCameraImageCapture *q_ptr; -}; - -QCameraImageCapturePrivate::QCameraImageCapturePrivate(): - mediaObject(0), - control(0), - encoderControl(0), - captureDestinationControl(0), - bufferFormatControl(0), - error(QCameraImageCapture::NoError) -{ -} - -void QCameraImageCapturePrivate::_q_error(int id, int error, const QString &errorString) -{ - Q_Q(QCameraImageCapture); - - this->error = QCameraImageCapture::Error(error); - this->errorString = errorString; - - emit q->error(id, this->error, errorString); -} - -void QCameraImageCapturePrivate::_q_readyChanged(bool ready) -{ - Q_Q(QCameraImageCapture); - emit q->readyForCaptureChanged(ready); -} - -void QCameraImageCapturePrivate::_q_serviceDestroyed() -{ - mediaObject = 0; - control = 0; - encoderControl = 0; - captureDestinationControl = 0; - bufferFormatControl = 0; -} - -/*! - Constructs a media recorder which records the media produced by \a mediaObject. - - The \a parent is passed to QMediaObject. -*/ - -QCameraImageCapture::QCameraImageCapture(QMediaObject *mediaObject, QObject *parent): - QObject(parent), d_ptr(new QCameraImageCapturePrivate) -{ - Q_D(QCameraImageCapture); - - d->q_ptr = this; - - if (mediaObject) - mediaObject->bind(this); -} - -/*! - Destroys images capture object. -*/ - -QCameraImageCapture::~QCameraImageCapture() -{ - Q_D(QCameraImageCapture); - - if (d->mediaObject) - d->mediaObject->unbind(this); -} - -/*! - \reimp - \since 1.1 -*/ -QMediaObject *QCameraImageCapture::mediaObject() const -{ - return d_func()->mediaObject; -} - -/*! - \reimp - \since 1.1 -*/ -bool QCameraImageCapture::setMediaObject(QMediaObject *mediaObject) -{ - Q_D(QCameraImageCapture); - - if (d->mediaObject) { - if (d->control) { - disconnect(d->control, SIGNAL(imageExposed(int)), - this, SIGNAL(imageExposed(int))); - disconnect(d->control, SIGNAL(imageCaptured(int,QImage)), - this, SIGNAL(imageCaptured(int,QImage))); - disconnect(d->control, SIGNAL(imageAvailable(int,QVideoFrame)), - this, SIGNAL(imageAvailable(int,QVideoFrame))); - disconnect(d->control, SIGNAL(imageMetadataAvailable(int,QtMultimediaKit::MetaData,QVariant)), - this, SIGNAL(imageMetadataAvailable(int,QtMultimediaKit::MetaData,QVariant))); - disconnect(d->control, SIGNAL(imageMetadataAvailable(int,QString,QVariant)), - this, SIGNAL(imageMetadataAvailable(int,QString,QVariant))); - disconnect(d->control, SIGNAL(imageSaved(int,QString)), - this, SIGNAL(imageSaved(int,QString))); - disconnect(d->control, SIGNAL(readyForCaptureChanged(bool)), - this, SLOT(_q_readyChanged(bool))); - disconnect(d->control, SIGNAL(error(int,int,QString)), - this, SLOT(_q_error(int,int,QString))); - - if (d->captureDestinationControl) { - disconnect(d->captureDestinationControl, SIGNAL(captureDestinationChanged(QCameraImageCapture::CaptureDestinations)), - this, SIGNAL(captureDestinationChanged(QCameraImageCapture::CaptureDestinations))); - } - - if (d->bufferFormatControl) { - disconnect(d->bufferFormatControl, SIGNAL(bufferFormatChanged(QVideoFrame::PixelFormat)), - this, SIGNAL(bufferFormatChanged(QVideoFrame::PixelFormat))); - } - - QMediaService *service = d->mediaObject->service(); - service->releaseControl(d->control); - if (d->encoderControl) - service->releaseControl(d->encoderControl); - if (d->captureDestinationControl) - service->releaseControl(d->captureDestinationControl); - if (d->bufferFormatControl) - service->releaseControl(d->bufferFormatControl); - - disconnect(service, SIGNAL(destroyed()), this, SLOT(_q_serviceDestroyed())); - } - } - - d->mediaObject = mediaObject; - - if (d->mediaObject) { - QMediaService *service = mediaObject->service(); - if (service) { - d->control = qobject_cast(service->requestControl(QCameraImageCaptureControl_iid)); - - if (d->control) { - d->encoderControl = qobject_cast(service->requestControl(QImageEncoderControl_iid)); - d->captureDestinationControl = qobject_cast( - service->requestControl(QCameraCaptureDestinationControl_iid)); - d->bufferFormatControl = qobject_cast( - service->requestControl(QCameraCaptureBufferFormatControl_iid)); - - connect(d->control, SIGNAL(imageExposed(int)), - this, SIGNAL(imageExposed(int))); - connect(d->control, SIGNAL(imageCaptured(int,QImage)), - this, SIGNAL(imageCaptured(int,QImage))); - connect(d->control, SIGNAL(imageMetadataAvailable(int,QtMultimediaKit::MetaData,QVariant)), - this, SIGNAL(imageMetadataAvailable(int,QtMultimediaKit::MetaData,QVariant))); - connect(d->control, SIGNAL(imageMetadataAvailable(int,QString,QVariant)), - this, SIGNAL(imageMetadataAvailable(int,QString,QVariant))); - connect(d->control, SIGNAL(imageAvailable(int,QVideoFrame)), - this, SIGNAL(imageAvailable(int,QVideoFrame))); - connect(d->control, SIGNAL(imageSaved(int, QString)), - this, SIGNAL(imageSaved(int, QString))); - connect(d->control, SIGNAL(readyForCaptureChanged(bool)), - this, SLOT(_q_readyChanged(bool))); - connect(d->control, SIGNAL(error(int,int,QString)), - this, SLOT(_q_error(int,int,QString))); - - if (d->captureDestinationControl) { - connect(d->captureDestinationControl, SIGNAL(captureDestinationChanged(QCameraImageCapture::CaptureDestinations)), - this, SIGNAL(captureDestinationChanged(QCameraImageCapture::CaptureDestinations))); - } - - if (d->bufferFormatControl) { - connect(d->bufferFormatControl, SIGNAL(bufferFormatChanged(QVideoFrame::PixelFormat)), - this, SIGNAL(bufferFormatChanged(QVideoFrame::PixelFormat))); - } - - connect(service, SIGNAL(destroyed()), this, SLOT(_q_serviceDestroyed())); - - return true; - } - } - } - - // without QCameraImageCaptureControl discard the media object - d->mediaObject = 0; - d->control = 0; - d->encoderControl = 0; - d->captureDestinationControl = 0; - d->bufferFormatControl = 0; - - return false; -} - -/*! - Returns true if the images capture service ready to use. - \since 1.1 -*/ -bool QCameraImageCapture::isAvailable() const -{ - if (d_func()->control != NULL) - return true; - else - return false; -} - -/*! - Returns the availability error code. - \since 1.1 -*/ -QtMultimediaKit::AvailabilityError QCameraImageCapture::availabilityError() const -{ - if (d_func()->control != NULL) - return QtMultimediaKit::NoError; - else - return QtMultimediaKit::ServiceMissingError; -} - -/*! - Returns the current error state. - - \since 1.1 - \sa errorString() -*/ - -QCameraImageCapture::Error QCameraImageCapture::error() const -{ - return d_func()->error; -} - -/*! - Returns a string describing the current error state. - - \since 1.1 - \sa error() -*/ - -QString QCameraImageCapture::errorString() const -{ - return d_func()->errorString; -} - - -/*! - Returns a list of supported image codecs. - \since 1.1 -*/ -QStringList QCameraImageCapture::supportedImageCodecs() const -{ - return d_func()->encoderControl ? - d_func()->encoderControl->supportedImageCodecs() : QStringList(); -} - -/*! - Returns a description of an image \a codec. - \since 1.1 -*/ -QString QCameraImageCapture::imageCodecDescription(const QString &codec) const -{ - return d_func()->encoderControl ? - d_func()->encoderControl->imageCodecDescription(codec) : QString(); -} - -/*! - Returns a list of resolutions images can be encoded at. - - If non null image \a settings parameter is passed, - the returned list is reduced to resolution supported with partial settings like image codec or quality applied. - - If the encoder supports arbitrary resolutions within the supported range, - *\a continuous is set to true, otherwise *\a continuous is set to false. - - \since 1.1 - \sa QImageEncoderSettings::resolution() -*/ -QList QCameraImageCapture::supportedResolutions(const QImageEncoderSettings &settings, bool *continuous) const -{ - if (continuous) - *continuous = false; - - return d_func()->encoderControl ? - d_func()->encoderControl->supportedResolutions(settings, continuous) : QList(); -} - -/*! - Returns the image encoder settings being used. - - \since 1.1 - \sa setEncodingSettings() -*/ - -QImageEncoderSettings QCameraImageCapture::encodingSettings() const -{ - return d_func()->encoderControl ? - d_func()->encoderControl->imageSettings() : QImageEncoderSettings(); -} - -/*! - Sets the image encoding \a settings. - - If some parameters are not specified, or null settings are passed, - the encoder choose the default encoding parameters. - - \since 1.1 - \sa encodingSettings() -*/ - -void QCameraImageCapture::setEncodingSettings(const QImageEncoderSettings &settings) -{ - Q_D(QCameraImageCapture); - - if (d->encoderControl) { - QCamera *camera = qobject_cast(d->mediaObject); - if (camera && camera->captureMode() == QCamera::CaptureStillImage) { - QMetaObject::invokeMethod(camera, - "_q_preparePropertyChange", - Qt::DirectConnection, - Q_ARG(int, QCameraControl::ImageEncodingSettings)); - } - - d->encoderControl->setImageSettings(settings); - } -} - -/*! - Returns the list of supported buffer image capture formats. - - \since 1.1 - \sa bufferFormat() setBufferFormat() -*/ -QList QCameraImageCapture::supportedBufferFormats() const -{ - if (d_func()->bufferFormatControl) - return d_func()->bufferFormatControl->supportedBufferFormats(); - else - return QList(); -} - -/*! - Returns the buffer image capture format being used. - - \since 1.2 - \sa supportedBufferCaptureFormats() setBufferCaptureFormat() -*/ -QVideoFrame::PixelFormat QCameraImageCapture::bufferFormat() const -{ - if (d_func()->bufferFormatControl) - return d_func()->bufferFormatControl->bufferFormat(); - else - return QVideoFrame::Format_Invalid; -} - -/*! - Sets the buffer image capture format to be used. - - \since 1.2 - \sa bufferCaptureFormat() supportedBufferCaptureFormats() captureDestination() -*/ -void QCameraImageCapture::setBufferFormat(const QVideoFrame::PixelFormat format) -{ - if (d_func()->bufferFormatControl) - d_func()->bufferFormatControl->setBufferFormat(format); -} - -/*! - Returns true if the image capture \a destination is supported; otherwise returns false. - - \since 1.2 - \sa captureDestination() setCaptureDestination() -*/ -bool QCameraImageCapture::isCaptureDestinationSupported(QCameraImageCapture::CaptureDestinations destination) const -{ - if (d_func()->captureDestinationControl) - return d_func()->captureDestinationControl->isCaptureDestinationSupported(destination); - else - return destination == CaptureToFile; -} - -/*! - Returns the image capture destination being used. - - \since 1.2 - \sa isCaptureDestinationSupported() setCaptureDestination() -*/ -QCameraImageCapture::CaptureDestinations QCameraImageCapture::captureDestination() const -{ - if (d_func()->captureDestinationControl) - return d_func()->captureDestinationControl->captureDestination(); - else - return CaptureToFile; -} - -/*! - Sets the capture \a destination to be used. - - \since 1.2 - \sa isCaptureDestinationSupported() captureDestination() -*/ -void QCameraImageCapture::setCaptureDestination(QCameraImageCapture::CaptureDestinations destination) -{ - Q_D(QCameraImageCapture); - - if (d->captureDestinationControl) - d->captureDestinationControl->setCaptureDestination(destination); -} - -/*! - \property QCameraImageCapture::readyForCapture - Indicates the service is ready to capture a an image immediately. - \since 1.1 -*/ - -bool QCameraImageCapture::isReadyForCapture() const -{ - if (d_func()->control) - return d_func()->control->isReadyForCapture(); - else - return false; -} - -/*! - \fn QCameraImageCapture::readyForCaptureChanged(bool ready) - - Signals that a camera's \a ready for capture state has changed. - \since 1.1 -*/ - - -/*! - Capture the image and save it to \a file. - This operation is asynchronous in majority of cases, - followed by signals QCameraImageCapture::imageCaptured(), QCameraImageCapture::imageSaved() - or QCameraImageCapture::error(). - - If an empty \a file is passed, the camera backend choses - the default location and naming scheme for photos on the system, - if only file name without full path is specified, the image will be saved to - the default directory, with a full path reported with imageCaptured() and imageSaved() signals. - - QCameraImageCapture::capture returns the capture Id parameter, used with - imageExposed(), imageCaptured() and imageSaved() signals. - \since 1.1 -*/ -int QCameraImageCapture::capture(const QString &file) -{ - Q_D(QCameraImageCapture); - - d->unsetError(); - - if (d->control) { - return d->control->capture(file); - } else { - d->error = NotSupportedFeatureError; - d->errorString = tr("Device does not support images capture."); - - emit error(-1, d->error, d->errorString); - } - - return -1; -} - -/*! - Cancel incomplete capture requests. - Already captured and queused for proicessing images may be discarded. - \since 1.1 -*/ -void QCameraImageCapture::cancelCapture() -{ - Q_D(QCameraImageCapture); - - d->unsetError(); - - if (d->control) { - d->control->cancelCapture(); - } else { - d->error = NotSupportedFeatureError; - d->errorString = tr("Device does not support images capture."); - - emit error(-1, d->error, d->errorString); - } -} - - -/*! - \enum QCameraImageCapture::Error - - \value NoError No Errors. - \value NotReadyError The service is not ready for capture yet. - \value ResourceError Device is not ready or not available. - \value NotSupportedFeatureError Device does not support stillimages capture. - \value FormatError Current format is not supported. - \value OutOfSpaceError No space left on device. -*/ - -/*! - \enum QCameraImageCapture::DriveMode - - \value SingleImageCapture Drive mode is capturing a single picture. -*/ - -/*! - \fn QCameraImageCapture::error(int id, QCameraImageCapture::Error error, const QString &errorString) - - Signals that the capture request \a id has failed with an \a error - and \a errorString description. - \since 1.1 -*/ - -/*! - \fn QCameraImageCapture::bufferFormatChanged(QVideoFrame::PixelFormat format) - - Signal emitted when the buffer \a format for the buffer image capture has changed. - \since 1.2 -*/ - -/*! - \fn QCameraImageCapture::captureDestinationChanged(CaptureDestinations destination) - - Signal emitted when the capture \a destination has changed. - \since 1.2 -*/ - -/*! - \fn QCameraImageCapture::imageExposed(int id) - - Signal emitted when the frame with request \a id was exposed. - \since 1.1 -*/ - -/*! - \fn QCameraImageCapture::imageCaptured(int id, const QImage &preview); - - Signal emitted when the frame with request \a id was captured, but not processed and saved yet. - Frame \a preview can be displayed to user. - \since 1.1 -*/ - -/*! - \fn QCameraImageCapture::imageMetadataAvailable(int id, QtMultimediaKit::MetaData key, const QVariant &value) - - Signals that a metadata for an image with request \a id is available. - This signal is emitted for metadata \a value with a \a key listed in QtMultimediaKit::MetaData enum. - - This signal is emitted between imageExposed and imageSaved signals. - \since 1.2 -*/ - -/*! - \fn QCameraImageCapture::imageMetadataAvailable(int id, const QString &key, const QVariant &value) - - Signals that a metadata for an image with request \a id is available. - This signal is emitted for extended metadata \a value with a \a key not listed in QtMultimediaKit::MetaData enum. - - This signal is emitted between imageExposed and imageSaved signals. - \since 1.2 -*/ - - -/*! - \fn QCameraImageCapture::imageAvailable(int id, const QVideoFrame &buffer) - - Signal emitted when the frame with request \a id is available as \a buffer. - \since 1.2 -*/ - -/*! - \fn QCameraImageCapture::imageSaved(int id, const QString &fileName) - - Signal emitted when the frame with request \a id was saved to \a fileName. - \since 1.1 -*/ - - -#include "moc_qcameraimagecapture.cpp" -QT_END_NAMESPACE - diff --git a/src/multimediakit/qcameraimagecapture.h b/src/multimediakit/qcameraimagecapture.h deleted file mode 100644 index f4a5a9c11..000000000 --- a/src/multimediakit/qcameraimagecapture.h +++ /dev/null @@ -1,170 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QCAMERAIMAGECAPTURE_H -#define QCAMERAIMAGECAPTURE_H - -#include -#include -#include -#include - -#include - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -QT_MODULE(Multimedia) - -class QSize; -QT_END_NAMESPACE - -QT_BEGIN_NAMESPACE - -class QImageEncoderSettings; - -class QCameraImageCapturePrivate; -class Q_MULTIMEDIA_EXPORT QCameraImageCapture : public QObject, public QMediaBindableInterface -{ - Q_OBJECT - Q_INTERFACES(QMediaBindableInterface) - Q_ENUMS(Error) - Q_ENUMS(CaptureDestination) - Q_PROPERTY(bool readyForCapture READ isReadyForCapture NOTIFY readyForCaptureChanged) -public: - enum Error - { - NoError, - NotReadyError, - ResourceError, - OutOfSpaceError, - NotSupportedFeatureError, - FormatError - }; - - enum DriveMode - { - SingleImageCapture - }; - - enum CaptureDestination - { - CaptureToFile = 0x01, - CaptureToBuffer = 0x02 - }; - Q_DECLARE_FLAGS(CaptureDestinations, CaptureDestination) - - QCameraImageCapture(QMediaObject *mediaObject, QObject *parent = 0); - ~QCameraImageCapture(); - - bool isAvailable() const; - QtMultimediaKit::AvailabilityError availabilityError() const; - - QMediaObject *mediaObject() const; - - Error error() const; - QString errorString() const; - - bool isReadyForCapture() const; - - QStringList supportedImageCodecs() const; - QString imageCodecDescription(const QString &codecName) const; - - QList supportedResolutions(const QImageEncoderSettings &settings = QImageEncoderSettings(), - bool *continuous = 0) const; - - QImageEncoderSettings encodingSettings() const; - void setEncodingSettings(const QImageEncoderSettings& settings); - - QList supportedBufferFormats() const; - QVideoFrame::PixelFormat bufferFormat() const; - void setBufferFormat(QVideoFrame::PixelFormat format); - - bool isCaptureDestinationSupported(CaptureDestinations destination) const; - CaptureDestinations captureDestination() const; - void setCaptureDestination(CaptureDestinations destination); - -public Q_SLOTS: - int capture(const QString &location = QString()); - void cancelCapture(); - -Q_SIGNALS: - void error(int id, QCameraImageCapture::Error error, const QString &errorString); - - void readyForCaptureChanged(bool); - void bufferFormatChanged(QVideoFrame::PixelFormat); - void captureDestinationChanged(QCameraImageCapture::CaptureDestinations); - - void imageExposed(int id); - void imageCaptured(int id, const QImage &preview); - void imageMetadataAvailable(int id, QtMultimediaKit::MetaData key, const QVariant &value); - void imageMetadataAvailable(int id, const QString &key, const QVariant &value); - void imageAvailable(int id, const QVideoFrame &image); - void imageSaved(int id, const QString &fileName); - -protected: - bool setMediaObject(QMediaObject *); - - QCameraImageCapturePrivate *d_ptr; -private: - Q_DISABLE_COPY(QCameraImageCapture) - Q_DECLARE_PRIVATE(QCameraImageCapture) - Q_PRIVATE_SLOT(d_func(), void _q_error(int, int, const QString &)) - Q_PRIVATE_SLOT(d_func(), void _q_readyChanged(bool)) - Q_PRIVATE_SLOT(d_func(), void _q_serviceDestroyed()) -}; - -Q_DECLARE_OPERATORS_FOR_FLAGS(QCameraImageCapture::CaptureDestinations) - -QT_END_NAMESPACE - -Q_DECLARE_METATYPE(QCameraImageCapture::Error) -Q_DECLARE_METATYPE(QCameraImageCapture::CaptureDestination) -Q_DECLARE_METATYPE(QCameraImageCapture::CaptureDestinations) - -Q_MEDIA_ENUM_DEBUG(QCameraImageCapture, Error) -Q_MEDIA_ENUM_DEBUG(QCameraImageCapture, CaptureDestination) - -QT_END_HEADER - -#endif - diff --git a/src/multimediakit/qcameraimagecapturecontrol.cpp b/src/multimediakit/qcameraimagecapturecontrol.cpp deleted file mode 100644 index 00689ed63..000000000 --- a/src/multimediakit/qcameraimagecapturecontrol.cpp +++ /dev/null @@ -1,208 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include -#include - -QT_BEGIN_NAMESPACE - -/*! - \class QCameraImageCaptureControl - - \brief The QCameraImageCaptureControl class provides a control interface - for image capture services. - - \inmodule QtMultimediaKit - \ingroup multimedia-serv - \since 1.1 - - - - The interface name of QCameraImageCaptureControl is \c com.nokia.Qt.QCameraImageCaptureControl/1.0 as - defined in QCameraImageCaptureControl_iid. - - - \sa QMediaService::requestControl() -*/ - -/*! - \macro QCameraImageCaptureControl_iid - - \c com.nokia.Qt.QCameraImageCaptureControl/1.0 - - Defines the interface name of the QCameraImageCaptureControl class. - - \relates QCameraImageCaptureControl -*/ - -/*! - Constructs a new image capture control object with the given \a parent -*/ -QCameraImageCaptureControl::QCameraImageCaptureControl(QObject *parent) - :QMediaControl(parent) -{ -} - -/*! - Destroys an image capture control. -*/ -QCameraImageCaptureControl::~QCameraImageCaptureControl() -{ -} - -/*! - \fn QCameraImageCaptureControl::isReadyForCapture() const - - Identifies if a capture control is ready to perform a capture - immediately (all the resources necessary for image capture are allocated, - hardware initialized, flash is charged, etc). - - Returns true if the camera is ready for capture; and false if it is not. - \since 1.1 -*/ - -/*! - \fn QCameraImageCaptureControl::readyForCaptureChanged(bool ready) - - Signals that a capture control's \a ready state has changed. - \since 1.1 -*/ - -/*! - \fn QCameraImageCaptureControl::capture(const QString &fileName) - - Initiates the capture of an image to \a fileName. - The \a fileName can be relative or empty, - in this case the service should use the system specific place - and file naming scheme. - - Returns the capture request id number, which is used later - with imageExposed(), imageCaptured() and imageSaved() signals. - \since 1.1 -*/ - -/*! - \fn QCameraImageCaptureControl::cancelCapture() - - Cancel pending capture requests. - \since 1.1 -*/ - -/*! - \fn QCameraImageCaptureControl::imageExposed(int requestId) - - Signals that an image with it \a requestId - has just been exposed. - This signal can be used for the shutter sound or other indicaton. - \since 1.1 -*/ - -/*! - \fn QCameraImageCaptureControl::imageCaptured(int requestId, const QImage &preview) - - Signals that an image with it \a requestId - has been captured and a \a preview is available. - \since 1.1 -*/ - -/*! - \fn QCameraImageCaptureControl::imageMetadataAvailable(int id, QtMultimediaKit::MetaData key, const QVariant &value) - - Signals that a metadata for an image with request \a id is available. - This signal is emitted for metadata \a value with a \a key listed in QtMultimediaKit::MetaData enum. - - This signal should be emitted between imageExposed and imageSaved signals. - \since 1.2 -*/ - -/*! - \fn QCameraImageCaptureControl::imageMetadataAvailable(int id, const QString &key, const QVariant &value) - - Signals that a metadata for an image with request \a id is available. - This signal is emitted for extended metadata \a value with a \a key not listed in QtMultimediaKit::MetaData enum. - - This signal should be emitted between imageExposed and imageSaved signals. - \since 1.2 -*/ - -/*! - \fn QCameraImageCaptureControl::imageAvailable(int requestId, const QVideoFrame &buffer) - - Signals that a captured \a buffer with a \a requestId is available. - \since 1.2 -*/ - -/*! - \fn QCameraImageCaptureControl::imageSaved(int requestId, const QString &fileName) - - Signals that a captured image with a \a requestId has been saved - to \a fileName. - \since 1.1 -*/ - -/*! - \fn QCameraImageCaptureControl::driveMode() const - - Returns the current camera drive mode. - \since 1.1 -*/ - -/*! - \fn QCameraImageCaptureControl::setDriveMode(QCameraImageCapture::DriveMode mode) - - Sets the current camera drive \a mode. - \since 1.1 -*/ - - -/*! - \fn QCameraImageCaptureControl::error(int id, int error, const QString &errorString) - - Signals the capture request \a id failed with \a error code and message \a errorString. - - \since 1.1 - \sa QCameraImageCapture::Error -*/ - - -#include "moc_qcameraimagecapturecontrol.cpp" -QT_END_NAMESPACE - diff --git a/src/multimediakit/qcameraimagecapturecontrol.h b/src/multimediakit/qcameraimagecapturecontrol.h deleted file mode 100644 index b9ac599f6..000000000 --- a/src/multimediakit/qcameraimagecapturecontrol.h +++ /dev/null @@ -1,99 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QCAMERAIMAGECAPTURECONTROL_H -#define QCAMERAIMAGECAPTURECONTROL_H - -#include -#include - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -QT_MODULE(Multimedia) - -class QImage; -QT_END_NAMESPACE - -QT_BEGIN_NAMESPACE - -class Q_MULTIMEDIA_EXPORT QCameraImageCaptureControl : public QMediaControl -{ - Q_OBJECT - -public: - ~QCameraImageCaptureControl(); - - virtual bool isReadyForCapture() const = 0; - - virtual QCameraImageCapture::DriveMode driveMode() const = 0; - virtual void setDriveMode(QCameraImageCapture::DriveMode mode) = 0; - - virtual int capture(const QString &fileName) = 0; - virtual void cancelCapture() = 0; - -Q_SIGNALS: - void readyForCaptureChanged(bool); - - void imageExposed(int id); - void imageCaptured(int id, const QImage &preview); - void imageMetadataAvailable(int id, QtMultimediaKit::MetaData key, const QVariant &value); - void imageMetadataAvailable(int id, const QString &key, const QVariant &value); - void imageAvailable(int id, const QVideoFrame &buffer); - void imageSaved(int id, const QString &fileName); - - void error(int id, int error, const QString &errorString); - -protected: - QCameraImageCaptureControl(QObject* parent = 0); -}; - -#define QCameraImageCaptureControl_iid "com.nokia.Qt.QCameraImageCaptureControl/1.0" -Q_MEDIA_DECLARE_CONTROL(QCameraImageCaptureControl, QCameraImageCaptureControl_iid) - -QT_END_NAMESPACE - -QT_END_HEADER - - -#endif // QCAMERAIMAGECAPTURECONTROL_H - diff --git a/src/multimediakit/qcameraimageprocessing.cpp b/src/multimediakit/qcameraimageprocessing.cpp deleted file mode 100644 index 79419a52b..000000000 --- a/src/multimediakit/qcameraimageprocessing.cpp +++ /dev/null @@ -1,352 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include - -#include - -#include -#include -#include -#include -#include -#include -#include -#include - -QT_BEGIN_NAMESPACE - -/*! - \class QCameraImageProcessing - - - \brief The QCameraImageProcessing class provides interface for - focus and zoom related camera settings. - - \inmodule QtMultimediaKit - \ingroup camera - \since 1.1 - -*/ - - -class QCameraImageProcessingPrivate : public QMediaObjectPrivate -{ - Q_DECLARE_NON_CONST_PUBLIC(QCameraImageProcessing) -public: - void initControls(); - - QCameraImageProcessing *q_ptr; - - QCamera *camera; - QCameraImageProcessingControl *imageControl; -}; - - -void QCameraImageProcessingPrivate::initControls() -{ - imageControl = 0; - - QMediaService *service = camera->service(); - if (service) - imageControl = qobject_cast(service->requestControl(QCameraImageProcessingControl_iid)); -} - -/*! - Construct a QCameraImageProcessing for \a camera. -*/ - -QCameraImageProcessing::QCameraImageProcessing(QCamera *camera): - QObject(camera), d_ptr(new QCameraImageProcessingPrivate) -{ - Q_D(QCameraImageProcessing); - d->camera = camera; - d->q_ptr = this; - d->initControls(); -} - - -/*! - Destroys the camera focus object. -*/ - -QCameraImageProcessing::~QCameraImageProcessing() -{ -} - - -/*! - Returns true if image processing related settings are supported by this camera. - \since 1.1 -*/ -bool QCameraImageProcessing::isAvailable() const -{ - return d_func()->imageControl != 0; -} - - -/*! - Returns the white balance mode being used. - \since 1.1 -*/ - -QCameraImageProcessing::WhiteBalanceMode QCameraImageProcessing::whiteBalanceMode() const -{ - return d_func()->imageControl ? d_func()->imageControl->whiteBalanceMode() : QCameraImageProcessing::WhiteBalanceAuto; -} - -/*! - Sets the white balance to \a mode. - \since 1.1 -*/ - -void QCameraImageProcessing::setWhiteBalanceMode(QCameraImageProcessing::WhiteBalanceMode mode) -{ - if (d_func()->imageControl) - d_func()->imageControl->setWhiteBalanceMode(mode); -} - -/*! - Returns true if the white balance \a mode is supported. - \since 1.1 -*/ - -bool QCameraImageProcessing::isWhiteBalanceModeSupported(QCameraImageProcessing::WhiteBalanceMode mode) const -{ - return d_func()->imageControl ? d_func()->imageControl->isWhiteBalanceModeSupported(mode) : false; -} - -/*! - Returns the current color temperature if the - manual white balance is active, otherwise the - return value is undefined. - \since 1.1 -*/ - -int QCameraImageProcessing::manualWhiteBalance() const -{ - QVariant value; - - if (d_func()->imageControl) - value = d_func()->imageControl->processingParameter(QCameraImageProcessingControl::ColorTemperature); - - return value.toInt(); -} - -/*! - Sets manual white balance to \a colorTemperature - \since 1.1 -*/ - -void QCameraImageProcessing::setManualWhiteBalance(int colorTemperature) -{ - if (d_func()->imageControl) { - d_func()->imageControl->setProcessingParameter( - QCameraImageProcessingControl::ColorTemperature, - QVariant(colorTemperature)); - } -} - -/*! - Return the contrast. - \since 1.1 -*/ -int QCameraImageProcessing::contrast() const -{ - QVariant value; - - if (d_func()->imageControl) - value = d_func()->imageControl->processingParameter(QCameraImageProcessingControl::Contrast); - - return value.toInt(); -} - -/*! - Set the contrast to \a value. - - Valid contrast values range between -100 and 100, the default is 0. - \since 1.1 -*/ -void QCameraImageProcessing::setContrast(int value) -{ - if (d_func()->imageControl) - d_func()->imageControl->setProcessingParameter(QCameraImageProcessingControl::Contrast, - QVariant(value)); -} - -/*! - Returns the saturation value. - \since 1.1 -*/ -int QCameraImageProcessing::saturation() const -{ - QVariant value; - - if (d_func()->imageControl) - value = d_func()->imageControl->processingParameter(QCameraImageProcessingControl::Saturation); - - return value.toInt(); -} - -/*! - Sets the saturation value to \a value. - - Valid saturation values range between -100 and 100, the default is 0. - \since 1.1 -*/ - -void QCameraImageProcessing::setSaturation(int value) -{ - if (d_func()->imageControl) - d_func()->imageControl->setProcessingParameter(QCameraImageProcessingControl::Saturation, - QVariant(value)); -} - -/*! - Identifies if sharpening is supported. - - Returns true if sharpening is supported; and false if it is not. - \since 1.1 -*/ -bool QCameraImageProcessing::isSharpeningSupported() const -{ - if (d_func()->imageControl) - return d_func()->imageControl->isProcessingParameterSupported(QCameraImageProcessingControl::Sharpening); - else - return false; -} - -/*! - Returns the sharpening level. - \since 1.1 -*/ -int QCameraImageProcessing::sharpeningLevel() const -{ - QVariant value; - - if (d_func()->imageControl) - value = d_func()->imageControl->processingParameter(QCameraImageProcessingControl::Sharpening); - - if (value.isNull()) - return -1; - else - return value.toInt(); -} - -/*! - Sets the sharpening \a level. - - Valid sharpening level values range between -1 for default sharpening level, - 0 for sharpening disabled and 100 for maximum sharpening applied. - \since 1.1 -*/ - -void QCameraImageProcessing::setSharpeningLevel(int level) -{ - Q_D(QCameraImageProcessing); - if (d->imageControl) - d->imageControl->setProcessingParameter(QCameraImageProcessingControl::Sharpening, - level == -1 ? QVariant() : QVariant(level)); -} - -/*! - Returns true if denoising is supported. - \since 1.1 -*/ -bool QCameraImageProcessing::isDenoisingSupported() const -{ - if (d_func()->imageControl) - return d_func()->imageControl->isProcessingParameterSupported(QCameraImageProcessingControl::Denoising); - else - return false; -} - -/*! - Returns the denoising level. - \since 1.1 -*/ -int QCameraImageProcessing::denoisingLevel() const -{ - QVariant value; - - if (d_func()->imageControl) - value = d_func()->imageControl->processingParameter(QCameraImageProcessingControl::Denoising); - - if (value.isNull()) - return -1; - else - return value.toInt(); -} - -/*! - Sets the denoising \a level. - - Valid denoising level values range between -1 for default denoising level, - 0 for denoising disabled and 100 for maximum denoising applied. - \since 1.1 -*/ -void QCameraImageProcessing::setDenoisingLevel(int level) -{ - Q_D(QCameraImageProcessing); - if (d->imageControl) - d->imageControl->setProcessingParameter(QCameraImageProcessingControl::Denoising, - level == -1 ? QVariant() : QVariant(level)); -} - - -/*! - \enum QCameraImageProcessing::WhiteBalanceMode - - \value WhiteBalanceManual Manual white balance. In this mode the white balance should be set with - setManualWhiteBalance() - \value WhiteBalanceAuto Auto white balance mode. - \value WhiteBalanceSunlight Sunlight white balance mode. - \value WhiteBalanceCloudy Cloudy white balance mode. - \value WhiteBalanceShade Shade white balance mode. - \value WhiteBalanceTungsten Tungsten white balance mode. - \value WhiteBalanceFluorescent Fluorescent white balance mode. - \value WhiteBalanceFlash Flash white balance mode. - \value WhiteBalanceSunset Sunset white balance mode. - \value WhiteBalanceVendor Vendor defined white balance mode. -*/ - -#include "moc_qcameraimageprocessing.cpp" -QT_END_NAMESPACE diff --git a/src/multimediakit/qcameraimageprocessing.h b/src/multimediakit/qcameraimageprocessing.h deleted file mode 100644 index 42a7eb589..000000000 --- a/src/multimediakit/qcameraimageprocessing.h +++ /dev/null @@ -1,124 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QCAMERAIMAGEPROCESSING_H -#define QCAMERAIMAGEPROCESSING_H - -#include -#include -#include -#include -#include - -#include -#include -#include -#include - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -QT_MODULE(Multimedia) - - -class QCamera; - -class QCameraImageProcessingPrivate; -class Q_MULTIMEDIA_EXPORT QCameraImageProcessing : public QObject -{ - Q_OBJECT - Q_ENUMS(WhiteBalanceMode) -public: - enum WhiteBalanceMode { - WhiteBalanceAuto = 0, - WhiteBalanceManual = 1, - WhiteBalanceSunlight = 2, - WhiteBalanceCloudy = 3, - WhiteBalanceShade = 4, - WhiteBalanceTungsten = 5, - WhiteBalanceFluorescent = 6, - WhiteBalanceFlash = 7, - WhiteBalanceSunset = 8, - WhiteBalanceVendor = 1000 - }; - - bool isAvailable() const; - - WhiteBalanceMode whiteBalanceMode() const; - void setWhiteBalanceMode(WhiteBalanceMode mode); - bool isWhiteBalanceModeSupported(WhiteBalanceMode mode) const; - int manualWhiteBalance() const; - void setManualWhiteBalance(int colorTemperature); - - int contrast() const; - void setContrast(int value); - - int saturation() const; - void setSaturation(int value); - - bool isSharpeningSupported() const; - int sharpeningLevel() const; - void setSharpeningLevel(int value); - - bool isDenoisingSupported() const; - int denoisingLevel() const; - void setDenoisingLevel(int value); - -private: - friend class QCamera; - QCameraImageProcessing(QCamera *camera); - ~QCameraImageProcessing(); - - Q_DISABLE_COPY(QCameraImageProcessing) - Q_DECLARE_PRIVATE(QCameraImageProcessing) - QCameraImageProcessingPrivate *d_ptr; -}; - -QT_END_NAMESPACE - -Q_DECLARE_METATYPE(QCameraImageProcessing::WhiteBalanceMode) - -Q_MEDIA_ENUM_DEBUG(QCameraImageProcessing, WhiteBalanceMode) - -QT_END_HEADER - -#endif // QCAMERAIMAGEPROCESSING_H diff --git a/src/multimediakit/qcameraimageprocessingcontrol.cpp b/src/multimediakit/qcameraimageprocessingcontrol.cpp deleted file mode 100644 index 453c2d575..000000000 --- a/src/multimediakit/qcameraimageprocessingcontrol.cpp +++ /dev/null @@ -1,169 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include -#include "qmediacontrol_p.h" - -QT_BEGIN_NAMESPACE - -/*! - \class QCameraImageProcessingControl - \inmodule QtMultimediaKit - \ingroup multimedia-serv - \since 1.1 - - - \brief The QCameraImageProcessingControl class provides an abstract class - for controlling image processing parameters, like white balance, - contrast, saturation, sharpening and denoising. - - The interface name of QCameraImageProcessingControl is \c com.nokia.Qt.QCameraImageProcessingControl/1.0 as - defined in QCameraImageProcessingControl_iid. - - - - \sa QMediaService::requestControl(), QCamera -*/ - -/*! - \macro QCameraImageProcessingControl_iid - - \c com.nokia.Qt.QCameraImageProcessingControl/1.0 - - Defines the interface name of the QCameraImageProcessingControl class. - - \relates QCameraImageProcessingControl -*/ - -/*! - Constructs an image processing control object with \a parent. -*/ - -QCameraImageProcessingControl::QCameraImageProcessingControl(QObject *parent): - QMediaControl(*new QMediaControlPrivate, parent) -{ -} - -/*! - Destruct the image processing control object. -*/ - -QCameraImageProcessingControl::~QCameraImageProcessingControl() -{ -} - - -/*! - \fn QCameraImageProcessingControl::whiteBalanceMode() const - Return the white balance mode being used. - \since 1.1 -*/ - -/*! - \fn QCameraImageProcessingControl::setWhiteBalanceMode(QCameraImageProcessing::WhiteBalanceMode mode) - Set the white balance mode to \a mode - \since 1.1 -*/ - -/*! - \fn QCameraImageProcessingControl::isWhiteBalanceModeSupported(QCameraImageProcessing::WhiteBalanceMode mode) const - Returns true if the white balance \a mode is supported. - The backend should support at least QCameraImageProcessing::WhiteBalanceAuto mode. - \since 1.1 -*/ - -/*! - \fn bool QCameraImageProcessingControl::isProcessingParameterSupported(ProcessingParameter parameter) const - - Returns true if the camera supports adjusting image processing \a parameter. - - Usually the the supported settings is static, - but some parameter may not be available depending on other - camera settings, like presets. - In such case the currently supported parameters should be returned. - \since 1.1 -*/ - -/*! - \fn QCameraImageProcessingControl::processingParameter(ProcessingParameter parameter) const - Returns the image processing \a parameter value. - \since 1.1 -*/ - -/*! - \fn QCameraImageProcessingControl::setProcessingParameter(ProcessingParameter parameter, QVariant value) - - Sets the image processing \a parameter \a value. - Passing the null or invalid QVariant value allows - backend to choose the suitable parameter value. - - The valid values range depends on the parameter type, - for contrast, saturation and brightness value should be - between -100 and 100, the default is 0, - - For sharpening and denoising the range is 0..100, - 0 for sharpening or denoising disabled - and 100 for maximum sharpening/denoising applied. - \since 1.1 -*/ - -/*! - \enum QCameraImageProcessingControl::ProcessingParameter - - \value Contrast - Image contrast. - \value Saturation - Image saturation. - \value Brightness - Image brightness. - \value Sharpening - Amount of sharpening applied. - \value Denoising - Amount of denoising applied. - \value ColorTemperature - Color temperature in K. This value is used when the manual white balance mode is selected. - \value ExtendedParameter - The base value for platform specific extended parameters. - */ - -#include "moc_qcameraimageprocessingcontrol.cpp" -QT_END_NAMESPACE - diff --git a/src/multimediakit/qcameraimageprocessingcontrol.h b/src/multimediakit/qcameraimageprocessingcontrol.h deleted file mode 100644 index 8c739287c..000000000 --- a/src/multimediakit/qcameraimageprocessingcontrol.h +++ /dev/null @@ -1,100 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QCAMERAIMAGEPROCESSINGCONTROL_H -#define QCAMERAIMAGEPROCESSINGCONTROL_H - -#include -#include - -#include -#include - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -QT_MODULE(Multimedia) - - -class Q_MULTIMEDIA_EXPORT QCameraImageProcessingControl : public QMediaControl -{ - Q_OBJECT - Q_ENUMS(ProcessingParameter) - -public: - ~QCameraImageProcessingControl(); - - enum ProcessingParameter { - Contrast = 0, - Saturation = 1, - Brightness = 2, - Sharpening = 3, - Denoising = 4, - ColorTemperature = 5, - ExtendedParameter = 1000 - }; - - virtual QCameraImageProcessing::WhiteBalanceMode whiteBalanceMode() const = 0; - virtual void setWhiteBalanceMode(QCameraImageProcessing::WhiteBalanceMode mode) = 0; - virtual bool isWhiteBalanceModeSupported(QCameraImageProcessing::WhiteBalanceMode) const = 0; - - virtual bool isProcessingParameterSupported(ProcessingParameter) const = 0; - virtual QVariant processingParameter(ProcessingParameter parameter) const = 0; - virtual void setProcessingParameter(ProcessingParameter parameter, QVariant value) = 0; - -protected: - QCameraImageProcessingControl(QObject* parent = 0); -}; - -#define QCameraImageProcessingControl_iid "com.nokia.Qt.QCameraImageProcessingControl/1.0" -Q_MEDIA_DECLARE_CONTROL(QCameraImageProcessingControl, QCameraImageProcessingControl_iid) - -QT_END_NAMESPACE - -Q_DECLARE_METATYPE(QCameraImageProcessingControl::ProcessingParameter) - -Q_MEDIA_ENUM_DEBUG(QCameraImageProcessingControl, ProcessingParameter) - -QT_END_HEADER - -#endif - diff --git a/src/multimediakit/qcameralockscontrol.cpp b/src/multimediakit/qcameralockscontrol.cpp deleted file mode 100644 index 03a58b162..000000000 --- a/src/multimediakit/qcameralockscontrol.cpp +++ /dev/null @@ -1,134 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include -#include "qmediacontrol_p.h" - -QT_BEGIN_NAMESPACE - -/*! - \class QCameraLocksControl - - - - \brief The QCameraLocksControl class is an abstract base class for - classes that control still cameras or video cameras. - - \inmodule QtMultimediaKit - \ingroup multimedia-serv - \since 1.1 - - This service is provided by a QMediaService object via - QMediaService::control(). It is used by QCamera. - - The interface name of QCameraLocksControl is \c com.nokia.Qt.QCameraLocksControl/1.0 as - defined in QCameraLocksControl_iid. - - - \sa QMediaService::requestControl(), QCamera -*/ - -/*! - \macro QCameraLocksControl_iid - - \c com.nokia.Qt.QCameraLocksControl/1.0 - - Defines the interface name of the QCameraLocksControl class. - - \relates QCameraLocksControl -*/ - -/*! - Constructs a camera locks control object with \a parent. -*/ - -QCameraLocksControl::QCameraLocksControl(QObject *parent): - QMediaControl(*new QMediaControlPrivate, parent) -{ -} - -/*! - Destruct the camera locks control object. -*/ - -QCameraLocksControl::~QCameraLocksControl() -{ -} - -/*! - \fn QCameraLocksControl::supportedLocks() const - - Returns the lock types, the camera supports. - \since 1.1 -*/ - -/*! - \fn QCameraLocksControl::lockStatus(QCamera::LockType lock) const - - Returns the camera \a lock status. - \since 1.1 -*/ - -/*! - \fn QCameraLocksControl::searchAndLock(QCamera::LockTypes locks) - - Request camera \a locks. - \since 1.1 -*/ - -/*! - \fn QCameraLocksControl::unlock(QCamera::LockTypes locks) - - Unlock camera \a locks. - \since 1.1 -*/ - -/*! - \fn QCameraLocksControl::lockStatusChanged(QCamera::LockType lock, QCamera::LockStatus status, QCamera::LockChangeReason reason) - - Signals the \a lock \a status was changed with a specified \a reason. - \since 1.1 -*/ - - - -#include "moc_qcameralockscontrol.cpp" -QT_END_NAMESPACE diff --git a/src/multimediakit/qcameralockscontrol.h b/src/multimediakit/qcameralockscontrol.h deleted file mode 100644 index 93120ee1a..000000000 --- a/src/multimediakit/qcameralockscontrol.h +++ /dev/null @@ -1,86 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QCAMERALOCKSCONTROL_H -#define QCAMERALOCKSCONTROL_H - -#include -#include - -#include - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -QT_MODULE(Multimedia) - - -class Q_MULTIMEDIA_EXPORT QCameraLocksControl : public QMediaControl -{ - Q_OBJECT -public: - ~QCameraLocksControl(); - - virtual QCamera::LockTypes supportedLocks() const = 0; - - virtual QCamera::LockStatus lockStatus(QCamera::LockType lock) const = 0; - - virtual void searchAndLock(QCamera::LockTypes locks) = 0; - virtual void unlock(QCamera::LockTypes locks) = 0; - -Q_SIGNALS: - void lockStatusChanged(QCamera::LockType type, QCamera::LockStatus status, QCamera::LockChangeReason reason); - -protected: - QCameraLocksControl(QObject* parent = 0); -}; - -#define QCameraLocksControl_iid "com.nokia.Qt.QCameraLocksControl/1.0" -Q_MEDIA_DECLARE_CONTROL(QCameraLocksControl, QCameraLocksControl_iid) - -QT_END_NAMESPACE - -QT_END_HEADER - - -#endif // QCAMERALOCKSCONTROL_H - diff --git a/src/multimediakit/qimageencodercontrol.cpp b/src/multimediakit/qimageencodercontrol.cpp deleted file mode 100644 index 9eeb949ac..000000000 --- a/src/multimediakit/qimageencodercontrol.cpp +++ /dev/null @@ -1,142 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qimageencodercontrol.h" -#include - -QT_BEGIN_NAMESPACE - -/*! - \class QImageEncoderControl - - \inmodule QtMultimediaKit - \ingroup multimedia-serv - \since 1.0 - - \brief The QImageEncoderControl class provides access to the settings of a media service that - performs image encoding. - - If a QMediaService supports encoding image data it will implement QImageEncoderControl. - This control allows to \l {setImageSettings()}{set image encoding settings} and - provides functions for quering supported image \l {supportedImageCodecs()}{codecs} and - \l {supportedResolutions()}{resolutions}. - - The interface name of QImageEncoderControl is \c com.nokia.Qt.QImageEncoderControl/1.0 as - defined in QImageEncoderControl_iid. - - \sa QImageEncoderSettings, QMediaService::requestControl() -*/ - -/*! - \macro QImageEncoderControl_iid - - \c com.nokia.Qt.QImageEncoderControl/1.0 - - Defines the interface name of the QImageEncoderControl class. - - \relates QImageEncoderControl -*/ - -/*! - Constructs a new image encoder control object with the given \a parent -*/ -QImageEncoderControl::QImageEncoderControl(QObject *parent) - :QMediaControl(parent) -{ -} - -/*! - Destroys the image encoder control. -*/ -QImageEncoderControl::~QImageEncoderControl() -{ -} - -/*! - \fn QImageEncoderControl::supportedResolutions(const QImageEncoderSettings &settings = QImageEncoderSettings(), - bool *continuous = 0) const - - Returns a list of supported resolutions. - - If non null image \a settings parameter is passed, - the returned list is reduced to resolutions supported with partial settings applied. - It can be used to query the list of resolutions, supported by specific image codec. - - If the encoder supports arbitrary resolutions within the supported resolutions range, - *\a continuous is set to true, otherwise *\a continuous is set to false. - \since 1.0 -*/ - -/*! - \fn QImageEncoderControl::supportedImageCodecs() const - - Returns a list of supported image codecs. - \since 1.0 -*/ - -/*! - \fn QImageEncoderControl::imageCodecDescription(const QString &codec) const - - Returns a description of an image \a codec. - \since 1.0 -*/ - -/*! - \fn QImageEncoderControl::imageSettings() const - - Returns the currently used image encoder settings. - - The returned value may be different tha passed to QImageEncoderControl::setImageSettings() - if the settings contains the default or undefined parameters. - In this case if the undefined parameters are already resolved, they should be returned. - \since 1.0 -*/ - -/*! - \fn QImageEncoderControl::setImageSettings(const QImageEncoderSettings &settings) - - Sets the selected image encoder \a settings. - \since 1.0 -*/ - -#include "moc_qimageencodercontrol.cpp" -QT_END_NAMESPACE - diff --git a/src/multimediakit/qimageencodercontrol.h b/src/multimediakit/qimageencodercontrol.h deleted file mode 100644 index c8a8261a4..000000000 --- a/src/multimediakit/qimageencodercontrol.h +++ /dev/null @@ -1,91 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QIMAGEENCODERCONTROL_H -#define QIMAGEENCODERCONTROL_H - -#include "qmediacontrol.h" -#include "qmediarecorder.h" -#include "qmediaencodersettings.h" - -#include - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -QT_MODULE(Multimedia) - -class QByteArray; -class QStringList; -QT_END_NAMESPACE - -QT_BEGIN_NAMESPACE - -class Q_MULTIMEDIA_EXPORT QImageEncoderControl : public QMediaControl -{ - Q_OBJECT - -public: - virtual ~QImageEncoderControl(); - - virtual QStringList supportedImageCodecs() const = 0; - virtual QString imageCodecDescription(const QString &codecName) const = 0; - - virtual QList supportedResolutions(const QImageEncoderSettings &settings, - bool *continuous = 0) const = 0; - - virtual QImageEncoderSettings imageSettings() const = 0; - virtual void setImageSettings(const QImageEncoderSettings &settings) = 0; - -protected: - QImageEncoderControl(QObject *parent = 0); -}; - -#define QImageEncoderControl_iid "com.nokia.Qt.QImageEncoderControl/1.0" -Q_MEDIA_DECLARE_CONTROL(QImageEncoderControl, QImageEncoderControl_iid) - -QT_END_NAMESPACE - -QT_END_HEADER - - -#endif diff --git a/src/multimediakit/qlocalmediaplaylistprovider.cpp b/src/multimediakit/qlocalmediaplaylistprovider.cpp deleted file mode 100644 index 84d54ecfd..000000000 --- a/src/multimediakit/qlocalmediaplaylistprovider.cpp +++ /dev/null @@ -1,194 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qlocalmediaplaylistprovider.h" -#include "qmediaplaylistprovider_p.h" -#include "qmediacontent.h" - -QT_BEGIN_NAMESPACE - -class QLocalMediaPlaylistProviderPrivate: public QMediaPlaylistProviderPrivate -{ -public: - QList resources; -}; - -QLocalMediaPlaylistProvider::QLocalMediaPlaylistProvider(QObject *parent) - :QMediaPlaylistProvider(*new QLocalMediaPlaylistProviderPrivate, parent) -{ -} - -QLocalMediaPlaylistProvider::~QLocalMediaPlaylistProvider() -{ -} - -bool QLocalMediaPlaylistProvider::isReadOnly() const -{ - return false; -} - -int QLocalMediaPlaylistProvider::mediaCount() const -{ - return d_func()->resources.size(); -} - -QMediaContent QLocalMediaPlaylistProvider::media(int pos) const -{ - return d_func()->resources.value(pos); -} - -bool QLocalMediaPlaylistProvider::addMedia(const QMediaContent &content) -{ - Q_D(QLocalMediaPlaylistProvider); - - int pos = d->resources.count(); - - emit mediaAboutToBeInserted(pos, pos); - d->resources.append(content); - emit mediaInserted(pos, pos); - - return true; -} - -bool QLocalMediaPlaylistProvider::addMedia(const QList &items) -{ - Q_D(QLocalMediaPlaylistProvider); - - if (items.isEmpty()) - return true; - - int pos = d->resources.count(); - int end = pos+items.count()-1; - - emit mediaAboutToBeInserted(pos, end); - d->resources.append(items); - emit mediaInserted(pos, end); - - return true; -} - - -bool QLocalMediaPlaylistProvider::insertMedia(int pos, const QMediaContent &content) -{ - Q_D(QLocalMediaPlaylistProvider); - - emit mediaAboutToBeInserted(pos, pos); - d->resources.insert(pos, content); - emit mediaInserted(pos,pos); - - return true; -} - -bool QLocalMediaPlaylistProvider::insertMedia(int pos, const QList &items) -{ - Q_D(QLocalMediaPlaylistProvider); - - if (items.isEmpty()) - return true; - - const int last = pos+items.count()-1; - - emit mediaAboutToBeInserted(pos, last); - for (int i=0; iresources.insert(pos+i, items.at(i)); - emit mediaInserted(pos, last); - - return true; -} - -bool QLocalMediaPlaylistProvider::removeMedia(int fromPos, int toPos) -{ - Q_D(QLocalMediaPlaylistProvider); - - Q_ASSERT(fromPos >= 0); - Q_ASSERT(fromPos <= toPos); - Q_ASSERT(toPos < mediaCount()); - - emit mediaAboutToBeRemoved(fromPos, toPos); - d->resources.erase(d->resources.begin()+fromPos, d->resources.begin()+toPos+1); - emit mediaRemoved(fromPos, toPos); - - return true; -} - -bool QLocalMediaPlaylistProvider::removeMedia(int pos) -{ - Q_D(QLocalMediaPlaylistProvider); - - emit mediaAboutToBeRemoved(pos, pos); - d->resources.removeAt(pos); - emit mediaRemoved(pos, pos); - - return true; -} - -bool QLocalMediaPlaylistProvider::clear() -{ - Q_D(QLocalMediaPlaylistProvider); - if (!d->resources.isEmpty()) { - int lastPos = mediaCount()-1; - emit mediaAboutToBeRemoved(0, lastPos); - d->resources.clear(); - emit mediaRemoved(0, lastPos); - } - - return true; -} - -void QLocalMediaPlaylistProvider::shuffle() -{ - Q_D(QLocalMediaPlaylistProvider); - if (!d->resources.isEmpty()) { - QList resources; - - while (!d->resources.isEmpty()) { - resources.append(d->resources.takeAt(qrand() % d->resources.size())); - } - - d->resources = resources; - emit mediaChanged(0, mediaCount()-1); - } - -} - -#include "moc_qlocalmediaplaylistprovider.cpp" -QT_END_NAMESPACE - diff --git a/src/multimediakit/qlocalmediaplaylistprovider.h b/src/multimediakit/qlocalmediaplaylistprovider.h deleted file mode 100644 index e712a3f73..000000000 --- a/src/multimediakit/qlocalmediaplaylistprovider.h +++ /dev/null @@ -1,87 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QLOCALMEDIAPAYLISTPROVIDER_H -#define QLOCALMEDIAPAYLISTPROVIDER_H - -#include "qmediaplaylistprovider.h" - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -QT_MODULE(Multimedia) - - -class QLocalMediaPlaylistProviderPrivate; -class Q_MULTIMEDIA_EXPORT QLocalMediaPlaylistProvider : public QMediaPlaylistProvider -{ - Q_OBJECT -public: - QLocalMediaPlaylistProvider(QObject *parent=0); - virtual ~QLocalMediaPlaylistProvider(); - - virtual int mediaCount() const; - virtual QMediaContent media(int pos) const; - - virtual bool isReadOnly() const; - - virtual bool addMedia(const QMediaContent &content); - virtual bool addMedia(const QList &items); - virtual bool insertMedia(int pos, const QMediaContent &content); - virtual bool insertMedia(int pos, const QList &items); - virtual bool removeMedia(int pos); - virtual bool removeMedia(int start, int end); - virtual bool clear(); - -public Q_SLOTS: - virtual void shuffle(); - -private: - Q_DECLARE_PRIVATE(QLocalMediaPlaylistProvider) -}; - -QT_END_NAMESPACE - -QT_END_HEADER - - -#endif // QLOCALMEDIAPAYLISTSOURCE_H diff --git a/src/multimediakit/qmediabackgroundplaybackcontrol.cpp b/src/multimediakit/qmediabackgroundplaybackcontrol.cpp deleted file mode 100644 index 0413fba01..000000000 --- a/src/multimediakit/qmediabackgroundplaybackcontrol.cpp +++ /dev/null @@ -1,149 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qmediabackgroundplaybackcontrol.h" -#include "qmediacontrol_p.h" - -QT_BEGIN_NAMESPACE - - -/*! - \class QMediaBackgroundPlaybackControl - \inmodule QtMultimediaKit - \ingroup multimedia - \since 5.0 - - - \brief The QMediaBackgroundPlaybackControl class provides access to the background playback - related control of a QMediaService. - - If a QMediaService can play media in background, it should implement QMediaBackgroundPlaybackControl. - This control provides a means to set the \l {setContextId()}{contextId} for application, - \l {acquire()}{acquire the resource for playback} and \l {release()} {release the playback resource}. - - The interface name of QMediaBackgroundPlaybackControl is \c com.nokia.Qt.QMediaBackgroundPlaybackControl/1.0 as - defined in QMediaBackgroundPlaybackControl_iid. - - \sa QMediaService::requestControl(), QMediaPlayer -*/ - -/*! - \macro QMediaBackgroundPlaybackControl_iid - - \c com.nokia.Qt.QMediaBackgroundPlaybackControl/1.0 - - Defines the interface name of the QMediaBackgroundPlaybackControl class. - - \relates QMediaBackgroundPlaybackControl -*/ - -/*! - Destroys a media background playback control. -*/ -QMediaBackgroundPlaybackControl::~QMediaBackgroundPlaybackControl() -{ -} - -/*! - Constructs a new media background playback control with the given \a parent. -*/ -QMediaBackgroundPlaybackControl::QMediaBackgroundPlaybackControl(QObject *parent): - QMediaControl(*new QMediaControlPrivate, parent) -{ -} - -/*! - \fn QMediaBackgroundPlaybackControl::setContextId(const QString& contextId) - - Sets the contextId for the application, the last contextId will be released if previously set. - \l {acquire()}{acquire method} will be automatically invoked after setting a new contextId. - - contextId is an unique string set by the application and is used by the background daemon to - distinguish and manage different context for different application. - - \since 1.0 -*/ - -/*! - \fn QMediaBackgroundPlaybackControl::acquire() - - Try to acquire the playback resource for current application - \since 1.0 -*/ - -/*! - \fn QMediaBackgroundPlaybackControl::release() - - Give up the playback resource if current applicaiton holds it. - \since 1.0 -*/ - -/*! - \property QMediaBackgroundPlaybackControl::isAcquired() - \brief indicate whether the background playback resource is granted or not - - It may take sometime for the backend to actually update this value before the first use. - - By default this property is false - - \since 1.0 -*/ - -/*! - \fn QMediaBackgroundPlaybackControl::acquired() - - Signals that the playback resource is acquired - - \since 1.0 -*/ - -/*! - \fn QMediaBackgroundPlaybackControl::lost() - - Signals that the playback resource is lost - - \since 1.0 -*/ - -#include "moc_qmediabackgroundplaybackcontrol.cpp" -QT_END_NAMESPACE - - diff --git a/src/multimediakit/qmediabackgroundplaybackcontrol.h b/src/multimediakit/qmediabackgroundplaybackcontrol.h deleted file mode 100644 index 2cf8d1935..000000000 --- a/src/multimediakit/qmediabackgroundplaybackcontrol.h +++ /dev/null @@ -1,83 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QMEDIABACKGROUNDPLAYBACKCONTROL_H -#define QMEDIABACKGROUNDPLAYBACKCONTROL_H - -#include "qmediacontrol.h" - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -QT_MODULE(Multimedia) - - -class Q_MULTIMEDIA_EXPORT QMediaBackgroundPlaybackControl : public QMediaControl -{ - Q_OBJECT - -public: - virtual ~QMediaBackgroundPlaybackControl(); - - virtual void setContextId(const QString& contextId) = 0; - virtual void acquire() = 0; - virtual void release() = 0; - - virtual bool isAcquired() const = 0; - -Q_SIGNALS: - void acquired(); - void lost(); - -protected: - QMediaBackgroundPlaybackControl(QObject* parent = 0); -}; - -#define QMediaBackgroundPlaybackControl_iid "com.nokia.Qt.QMediaBackgroundPlaybackControl/1.0" -Q_MEDIA_DECLARE_CONTROL(QMediaBackgroundPlaybackControl, QMediaBackgroundPlaybackControl_iid) - -QT_END_NAMESPACE - -QT_END_HEADER - - -#endif // QMEDIABACKGROUNDPLAYBACKCONTROL_H diff --git a/src/multimediakit/qmediabindableinterface.cpp b/src/multimediakit/qmediabindableinterface.cpp deleted file mode 100644 index 28b713457..000000000 --- a/src/multimediakit/qmediabindableinterface.cpp +++ /dev/null @@ -1,85 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include - -QT_BEGIN_NAMESPACE - -/*! - \class QMediaBindableInterface - \inmodule QtMultimediaKit - \ingroup multimedia - \since 1.0 - - - \brief The QMediaBindableInterface class is the base class for objects extending media objects functionality. - - \sa -*/ - -/*! - Destroys a media helper object. -*/ - -QMediaBindableInterface::~QMediaBindableInterface() -{ -} - -/*! - \fn QMediaBindableInterface::mediaObject() const; - - Return the currently attached media object. - \since 1.0 -*/ - - -/*! - \fn QMediaBindableInterface::setMediaObject(QMediaObject *object); - - Attaches to the media \a object. - Returns true if attached successfully, otherwise returns false. - \since 1.0 -*/ - - - -QT_END_NAMESPACE - diff --git a/src/multimediakit/qmediabindableinterface.h b/src/multimediakit/qmediabindableinterface.h deleted file mode 100644 index 02b5b1a21..000000000 --- a/src/multimediakit/qmediabindableinterface.h +++ /dev/null @@ -1,77 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QMEDIABINDABLEINTERFACE_H -#define QMEDIABINDABLEINTERFACE_H - -#include - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -QT_MODULE(Multimedia) - - -class QMediaObject; - -class Q_MULTIMEDIA_EXPORT QMediaBindableInterface -{ -public: - virtual ~QMediaBindableInterface(); - - virtual QMediaObject *mediaObject() const = 0; - -protected: - friend class QMediaObject; - virtual bool setMediaObject(QMediaObject *object) = 0; -}; - -#define QMediaBindableInterface_iid \ - "com.nokia.Qt.QMediaBindableInterface/1.0" -Q_DECLARE_INTERFACE(QMediaBindableInterface, QMediaBindableInterface_iid) - -QT_END_NAMESPACE - -QT_END_HEADER - - -#endif // QMEDIABINDABLEINTERFACE_H diff --git a/src/multimediakit/qmediacontainercontrol.cpp b/src/multimediakit/qmediacontainercontrol.cpp deleted file mode 100644 index 1c317d915..000000000 --- a/src/multimediakit/qmediacontainercontrol.cpp +++ /dev/null @@ -1,126 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - - -#include "qmediacontainercontrol.h" - -QT_BEGIN_NAMESPACE - -/*! - \class QMediaContainerControl - - \brief The QMediaContainerControl class provides access to the output container format of a QMediaService - - \inmodule QtMultimediaKit - \ingroup multimedia-serv - \since 1.0 - - If a QMediaService supports writing encoded data it will implement - QMediaContainerControl. This control provides information about the output - containers supported by a media service and allows one to be selected as - the current output containers. - - The functionality provided by this control is exposed to application code - through the QMediaRecorder class. - - The interface name of QMediaContainerControl is \c com.nokia.Qt.QMediaContainerControl/1.0 as - defined in QMediaContainerControl_iid. - - \sa QMediaService::requestControl(), QMediaRecorder -*/ - -/*! - \macro QMediaContainerControl_iid - - \c com.nokia.Qt.QMediaContainerControl/1.0 - - Defines the interface name of the QMediaContainerControl class. - - \relates QMediaContainerControl -*/ - -/*! - Constructs a new media container control with the given \a parent. -*/ -QMediaContainerControl::QMediaContainerControl(QObject *parent) - :QMediaControl(parent) -{ -} - -/*! - Destroys a media container control. -*/ -QMediaContainerControl::~QMediaContainerControl() -{ -} - - -/*! - \fn QMediaContainerControl::supportedContainers() const - - Returns a list of MIME types of supported container formats. - \since 1.0 -*/ - -/*! - \fn QMediaContainerControl::containerMimeType() const - - Returns the MIME type of the selected container format. - \since 1.0 -*/ - -/*! - \fn QMediaContainerControl::setContainerMimeType(const QString &mimeType) - - Sets the current container format to the format identified by the given \a mimeType. - \since 1.0 -*/ - -/*! - \fn QMediaContainerControl::containerDescription(const QString &mimeType) const - - Returns a description of the container format identified by the given \a mimeType. - \since 1.0 -*/ - -#include "moc_qmediacontainercontrol.cpp" -QT_END_NAMESPACE - diff --git a/src/multimediakit/qmediacontainercontrol.h b/src/multimediakit/qmediacontainercontrol.h deleted file mode 100644 index af48605d0..000000000 --- a/src/multimediakit/qmediacontainercontrol.h +++ /dev/null @@ -1,80 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - - -#ifndef QMEDIACONTAINERCONTROL_H -#define QMEDIACONTAINERCONTROL_H - -#include "qmediacontrol.h" - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -QT_MODULE(Multimedia) - - -class Q_MULTIMEDIA_EXPORT QMediaContainerControl : public QMediaControl -{ - Q_OBJECT - -public: - virtual ~QMediaContainerControl(); - - virtual QStringList supportedContainers() const = 0; - virtual QString containerMimeType() const = 0; - virtual void setContainerMimeType(const QString &formatMimeType) = 0; - - virtual QString containerDescription(const QString &formatMimeType) const = 0; - -protected: - QMediaContainerControl(QObject *parent = 0); -}; - -#define QMediaContainerControl_iid "com.nokia.Qt.QMediaContainerControl/1.0" -Q_MEDIA_DECLARE_CONTROL(QMediaContainerControl, QMediaContainerControl_iid) - -QT_END_NAMESPACE - -QT_END_HEADER - - -#endif // QMEDIACONTAINERCONTROL_H diff --git a/src/multimediakit/qmediacontent.cpp b/src/multimediakit/qmediacontent.cpp deleted file mode 100644 index 8cd7e2d95..000000000 --- a/src/multimediakit/qmediacontent.cpp +++ /dev/null @@ -1,254 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include -#include - -#include "qmediacontent.h" - -QT_BEGIN_NAMESPACE - - -class QMediaContentPrivate : public QSharedData -{ -public: - QMediaContentPrivate() {} - QMediaContentPrivate(const QMediaResourceList &r): - resources(r) {} - - QMediaContentPrivate(const QMediaContentPrivate &other): - QSharedData(other), - resources(other.resources) - {} - - bool operator ==(const QMediaContentPrivate &other) const - { - return resources == other.resources; - } - - QMediaResourceList resources; -private: - QMediaContentPrivate& operator=(const QMediaContentPrivate &other); -}; - - -/*! - \class QMediaContent - - \brief The QMediaContent class provides access to the resources relating to a media content. - - \inmodule QtMultimediaKit - \ingroup multimedia - \since 1.0 - - QMediaContent is used within the multimedia framework as the logical handle - to media content. A QMediaContent object is composed of one or more - \l {QMediaResource}s where each resource provides the URL and format - information of a different encoding of the content. - - A non-null QMediaContent will always have a primary or canonical reference to - the content available through the canonicalUrl() or canonicalResource() - methods, any additional resources are optional. -*/ - - -/*! - Constructs a null QMediaContent. -*/ - -QMediaContent::QMediaContent() -{ -} - -/*! - Constructs a media content with \a url providing a reference to the content. - \since 1.0 -*/ - -QMediaContent::QMediaContent(const QUrl &url): - d(new QMediaContentPrivate) -{ - d->resources << QMediaResource(url); -} - -/*! - Constructs a media content with \a request providing a reference to the content. - - This constructor can be used to reference media content via network protocols such as HTTP. - This may include additional information required to obtain the resource, such as Cookies or HTTP headers. - \since 1.0 -*/ - -QMediaContent::QMediaContent(const QNetworkRequest &request): - d(new QMediaContentPrivate) -{ - d->resources << QMediaResource(request); -} - -/*! - Constructs a media content with \a resource providing a reference to the content. - \since 1.0 -*/ - -QMediaContent::QMediaContent(const QMediaResource &resource): - d(new QMediaContentPrivate) -{ - d->resources << resource; -} - -/*! - Constructs a media content with \a resources providing a reference to the content. - \since 1.0 -*/ - -QMediaContent::QMediaContent(const QMediaResourceList &resources): - d(new QMediaContentPrivate(resources)) -{ -} - -/*! - Constructs a copy of the media content \a other. - \since 1.0 -*/ - -QMediaContent::QMediaContent(const QMediaContent &other): - d(other.d) -{ -} - -/*! - Destroys the media content object. -*/ - -QMediaContent::~QMediaContent() -{ -} - -/*! - Assigns the value of \a other to this media content. - \since 1.0 -*/ - -QMediaContent& QMediaContent::operator=(const QMediaContent &other) -{ - d = other.d; - return *this; -} - -/*! - Returns true if \a other is equivalent to this media content; false otherwise. - \since 1.0 -*/ - -bool QMediaContent::operator==(const QMediaContent &other) const -{ - return (d.constData() == 0 && other.d.constData() == 0) || - (d.constData() != 0 && other.d.constData() != 0 && - *d.constData() == *other.d.constData()); -} - -/*! - Returns true if \a other is not equivalent to this media content; false otherwise. - \since 1.0 -*/ - -bool QMediaContent::operator!=(const QMediaContent &other) const -{ - return !(*this == other); -} - -/*! - Returns true if this media content is null (uninitialized); false otherwise. - \since 1.0 -*/ - -bool QMediaContent::isNull() const -{ - return d.constData() == 0; -} - -/*! - Returns a QUrl that represents that canonical resource for this media content. - \since 1.0 -*/ - -QUrl QMediaContent::canonicalUrl() const -{ - return canonicalResource().url(); -} - -/*! - Returns a QNetworkRequest that represents that canonical resource for this media content. - \since 1.0 -*/ - -QNetworkRequest QMediaContent::canonicalRequest() const -{ - return canonicalResource().request(); -} - -/*! - Returns a QMediaResource that represents that canonical resource for this media content. - \since 1.0 -*/ - -QMediaResource QMediaContent::canonicalResource() const -{ - return d.constData() != 0 - ? d->resources.value(0) - : QMediaResource(); -} - -/*! - Returns a list of alternative resources for this media content. The first item in this list - is always the canonical resource. - \since 1.0 -*/ - -QMediaResourceList QMediaContent::resources() const -{ - return d.constData() != 0 - ? d->resources - : QMediaResourceList(); -} - -QT_END_NAMESPACE - diff --git a/src/multimediakit/qmediacontent.h b/src/multimediakit/qmediacontent.h deleted file mode 100644 index 99471f305..000000000 --- a/src/multimediakit/qmediacontent.h +++ /dev/null @@ -1,95 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QMEDIACONTENT_H -#define QMEDIACONTENT_H - -#include -#include - -#include "qmediaresource.h" - -#include - - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -QT_MODULE(Multimedia) - - -class QMediaContentPrivate; -class Q_MULTIMEDIA_EXPORT QMediaContent -{ -public: - QMediaContent(); - QMediaContent(const QUrl &contentUrl); - QMediaContent(const QNetworkRequest &contentRequest); - QMediaContent(const QMediaResource &contentResource); - QMediaContent(const QMediaResourceList &resources); - QMediaContent(const QMediaContent &other); - ~QMediaContent(); - - QMediaContent& operator=(const QMediaContent &other); - - bool operator==(const QMediaContent &other) const; - bool operator!=(const QMediaContent &other) const; - - bool isNull() const; - - QUrl canonicalUrl() const; - QNetworkRequest canonicalRequest() const; - QMediaResource canonicalResource() const; - - QMediaResourceList resources() const; - -private: - QSharedDataPointer d; -}; - -QT_END_NAMESPACE - -Q_DECLARE_METATYPE(QMediaContent) - -QT_END_HEADER - -#endif // QMEDIACONTENT_H diff --git a/src/multimediakit/qmediacontrol.cpp b/src/multimediakit/qmediacontrol.cpp deleted file mode 100644 index dc823a4b9..000000000 --- a/src/multimediakit/qmediacontrol.cpp +++ /dev/null @@ -1,138 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include -#include - -#include "qmediacontrol.h" -#include "qmediacontrol_p.h" - - - -QT_BEGIN_NAMESPACE - -/*! - \class QMediaControl - \inmodule QtMultimediaKit - \ingroup multimedia-serv - \since 1.0 - - - \brief The QMediaControl class provides a base interface for media service controls. - - Media controls provide an interface to individual features provided by a - media service. Most services implement a principal control which exposes - the core functionality of the service and a number of optional controls which - expose any additional functionality. - - A pointer to a control implemented by a media service can be obtained using - the \l {QMediaService::requestControl()} member of QMediaService. If the - service doesn't implement a control it will instead return a null pointer. - - \snippet doc/src/snippets/multimedia-snippets/media.cpp Request control - - Alternatively if the IId of the control has been declared using - Q_MEDIA_DECLARE_CONTROL the template version of - QMediaService::requestControl() can be used to request the service without - explicitly passing the IId or using qobject_cast(). - - \snippet doc/src/snippets/multimedia-snippets/media.cpp Request control templated - - Most application code will not interface directly with a media service's - controls, instead the QMediaObject which owns the service acts as an - intermediary between one or more controls and the application. - - \sa QMediaService, QMediaObject -*/ - -/*! - \macro Q_MEDIA_DECLARE_CONTROL(Class, IId) - \relates QMediaControl - - The Q_MEDIA_DECLARE_CONTROL macro declares an \a IId for a \a Class that - inherits from QMediaControl. - - Declaring an IId for a QMediaControl allows an instance of that control to - be requested from QMediaService::requestControl() without explicitly - passing the IId. - - \snippet doc/src/snippets/multimedia-snippets/media.cpp Request control templated - - \sa QMediaService::requestControl() -*/ - -/*! - Destroys a media control. -*/ - -QMediaControl::~QMediaControl() -{ - delete d_ptr; -} - -/*! - Constructs a media control with the given \a parent. - \since 1.0 -*/ - -QMediaControl::QMediaControl(QObject *parent) - : QObject(parent) - , d_ptr(new QMediaControlPrivate) -{ - d_ptr->q_ptr = this; -} - -/*! - \internal - \since 1.0 -*/ - -QMediaControl::QMediaControl(QMediaControlPrivate &dd, QObject *parent) - : QObject(parent) - , d_ptr(&dd) - -{ - d_ptr->q_ptr = this; -} - -#include "moc_qmediacontrol.cpp" -QT_END_NAMESPACE - diff --git a/src/multimediakit/qmediacontrol.h b/src/multimediakit/qmediacontrol.h deleted file mode 100644 index 47cc13524..000000000 --- a/src/multimediakit/qmediacontrol.h +++ /dev/null @@ -1,87 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QABSTRACTMEDIACONTROL_H -#define QABSTRACTMEDIACONTROL_H - -#include - -#include -#include -#include - - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -QT_MODULE(Multimedia) - - -class QMediaControlPrivate; -class Q_MULTIMEDIA_EXPORT QMediaControl : public QObject -{ - Q_OBJECT - -public: - ~QMediaControl(); - -protected: - QMediaControl(QObject *parent = 0); - QMediaControl(QMediaControlPrivate &dd, QObject *parent = 0); - - QMediaControlPrivate *d_ptr; - -private: - Q_DECLARE_PRIVATE(QMediaControl) -}; - -template const char *qmediacontrol_iid() { return 0; } - -#define Q_MEDIA_DECLARE_CONTROL(Class, IId) \ - template <> inline const char *qmediacontrol_iid() { return IId; } - -QT_END_NAMESPACE - -QT_END_HEADER - - -#endif // QABSTRACTMEDIACONTROL_H diff --git a/src/multimediakit/qmediacontrol_p.h b/src/multimediakit/qmediacontrol_p.h deleted file mode 100644 index cde6cc688..000000000 --- a/src/multimediakit/qmediacontrol_p.h +++ /dev/null @@ -1,80 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QABSTRACTMEDIACONTROL_P_H -#define QABSTRACTMEDIACONTROL_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 - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -QT_MODULE(Multimedia) - - -class QMediaControl; - -class QMediaControlPrivate -{ -public: - virtual ~QMediaControlPrivate() {} - - QMediaControl *q_ptr; -}; - -QT_END_NAMESPACE - -QT_END_HEADER - - -#endif diff --git a/src/multimediakit/qmediaencodersettings.cpp b/src/multimediakit/qmediaencodersettings.cpp deleted file mode 100644 index a87ed6883..000000000 --- a/src/multimediakit/qmediaencodersettings.cpp +++ /dev/null @@ -1,822 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qmediaencodersettings.h" - -QT_BEGIN_NAMESPACE - -class QAudioEncoderSettingsPrivate : public QSharedData -{ -public: - QAudioEncoderSettingsPrivate() : - isNull(true), - encodingMode(QtMultimediaKit::ConstantQualityEncoding), - bitrate(-1), - sampleRate(-1), - channels(-1), - quality(QtMultimediaKit::NormalQuality) - { - } - - QAudioEncoderSettingsPrivate(const QAudioEncoderSettingsPrivate &other): - QSharedData(other), - isNull(other.isNull), - encodingMode(other.encodingMode), - codec(other.codec), - bitrate(other.bitrate), - sampleRate(other.sampleRate), - channels(other.channels), - quality(other.quality) - { - } - - bool isNull; - QtMultimediaKit::EncodingMode encodingMode; - QString codec; - int bitrate; - int sampleRate; - int channels; - QtMultimediaKit::EncodingQuality quality; - -private: - QAudioEncoderSettingsPrivate& operator=(const QAudioEncoderSettingsPrivate &other); -}; - -/*! - \class QAudioEncoderSettings - - \brief The QAudioEncoderSettings class provides a set of audio encoder settings. - - \inmodule QtMultimediaKit - \ingroup multimedia - \since 1.0 - - A audio encoder settings object is used to specify the audio encoder - settings used by QMediaRecorder. Audio encoder settings are selected by - constructing a QAudioEncoderSettings object, setting the desired properties - and then passing it to a QMediaRecorder instance using the - QMediaRecorder::setEncodingSettings() function. - - \snippet doc/src/snippets/multimedia-snippets/media.cpp Audio encoder settings - - \sa QMediaRecorder, QAudioEncoderControl -*/ - -/*! - Construct a null audio encoder settings object. -*/ -QAudioEncoderSettings::QAudioEncoderSettings() - :d(new QAudioEncoderSettingsPrivate) -{ -} - -/*! - Constructs a copy of the audio encoder settings object \a other. - \since 1.0 -*/ - -QAudioEncoderSettings::QAudioEncoderSettings(const QAudioEncoderSettings& other) - :d(other.d) -{ -} - -/*! - Destroys an audio encoder settings object. -*/ - -QAudioEncoderSettings::~QAudioEncoderSettings() -{ -} - -/*! - Assigns the value of \a other to an audio encoder settings object. - \since 1.0 -*/ - -QAudioEncoderSettings& QAudioEncoderSettings::operator=(const QAudioEncoderSettings &other) -{ - d = other.d; - return *this; -} - -/*! - Determines if \a other is of equal value to an audio encoder settings - object. - - Returns true if the settings objects are of equal value, and false if they - are not of equal value. - \since 1.0 -*/ - -bool QAudioEncoderSettings::operator==(const QAudioEncoderSettings &other) const -{ - return (d == other.d) || - (d->isNull == other.d->isNull && - d->encodingMode == other.d->encodingMode && - d->bitrate == other.d->bitrate && - d->sampleRate == other.d->sampleRate && - d->channels == other.d->channels && - d->quality == other.d->quality && - d->codec == other.d->codec); -} - -/*! - Determines if \a other is of equal value to an audio encoder settings - object. - - Returns true if the settings objects are not of equal value, and true if - they are of equal value. - \since 1.0 -*/ - -bool QAudioEncoderSettings::operator!=(const QAudioEncoderSettings &other) const -{ - return !(*this == other); -} - -/*! - Identifies if an audio settings object is initialized. - - Returns true if the settings object is null, and false if it is not. - \since 1.0 -*/ - -bool QAudioEncoderSettings::isNull() const -{ - return d->isNull; -} - -/*! - Returns the audio encoding mode. - - \since 1.0 - \sa QtMultimediaKit::EncodingMode -*/ -QtMultimediaKit::EncodingMode QAudioEncoderSettings::encodingMode() const -{ - return d->encodingMode; -} - -/*! - Sets the audio encoding \a mode setting. - - If QtMultimediaKit::ConstantQualityEncoding is set, the quality - encoding parameter is used and bit rate is ignored, - otherwise the bitrate is used. - - The audio codec, channels count and sample rate settings are used in all - the encoding modes. - - \since 1.0 - \sa encodingMode(), QtMultimediaKit::EncodingMode -*/ -void QAudioEncoderSettings::setEncodingMode(QtMultimediaKit::EncodingMode mode) -{ - d->encodingMode = mode; -} - -/*! - Returns the audio codec. - \since 1.0 -*/ -QString QAudioEncoderSettings::codec() const -{ - return d->codec; -} - -/*! - Sets the audio \a codec. - \since 1.0 -*/ -void QAudioEncoderSettings::setCodec(const QString& codec) -{ - d->isNull = false; - d->codec = codec; -} - -/*! - Returns the bit rate of the compressed audio stream in bits per second. - \since 1.0 -*/ -int QAudioEncoderSettings::bitRate() const -{ - return d->bitrate; -} - -/*! - Returns the number of audio channels. - \since 1.0 -*/ -int QAudioEncoderSettings::channelCount() const -{ - return d->channels; -} - -/*! - Sets the number of audio \a channels. - - A value of -1 indicates the encoder should make an optimal choice based on - what is available from the audio source and the limitations of the codec. - \since 1.0 -*/ -void QAudioEncoderSettings::setChannelCount(int channels) -{ - d->isNull = false; - d->channels = channels; -} - -/*! - Sets the audio bit \a rate in bits per second. - \since 1.0 -*/ -void QAudioEncoderSettings::setBitRate(int rate) -{ - d->isNull = false; - d->bitrate = rate; -} - -/*! - Returns the audio sample rate in Hz. - \since 1.0 -*/ -int QAudioEncoderSettings::sampleRate() const -{ - return d->sampleRate; -} - -/*! - Sets the audio sample \a rate in Hz. - - A value of -1 indicates the encoder should make an optimal choice based on what is avaialbe - from the audio source and the limitations of the codec. - \since 1.0 - */ -void QAudioEncoderSettings::setSampleRate(int rate) -{ - d->isNull = false; - d->sampleRate = rate; -} - -/*! - Returns the audio encoding quality. - \since 1.0 -*/ - -QtMultimediaKit::EncodingQuality QAudioEncoderSettings::quality() const -{ - return d->quality; -} - -/*! - Set the audio encoding \a quality. - - Setting the audio quality parameter allows backend to choose the balanced - set of encoding parameters to achieve the desired quality level. - - The \a quality settings parameter is only used in the - \l {QtMultimediaKit::ConstantQualityEncoding}{constant quality} \l{encodingMode()}{encoding mode}. - \since 1.0 -*/ -void QAudioEncoderSettings::setQuality(QtMultimediaKit::EncodingQuality quality) -{ - d->isNull = false; - d->quality = quality; -} - -class QVideoEncoderSettingsPrivate : public QSharedData -{ -public: - QVideoEncoderSettingsPrivate() : - isNull(true), - encodingMode(QtMultimediaKit::ConstantQualityEncoding), - bitrate(-1), - frameRate(0), - quality(QtMultimediaKit::NormalQuality) - { - } - - QVideoEncoderSettingsPrivate(const QVideoEncoderSettingsPrivate &other): - QSharedData(other), - isNull(other.isNull), - encodingMode(other.encodingMode), - codec(other.codec), - bitrate(other.bitrate), - resolution(other.resolution), - frameRate(other.frameRate), - quality(other.quality) - { - } - - bool isNull; - QtMultimediaKit::EncodingMode encodingMode; - QString codec; - int bitrate; - QSize resolution; - qreal frameRate; - QtMultimediaKit::EncodingQuality quality; - -private: - QVideoEncoderSettingsPrivate& operator=(const QVideoEncoderSettingsPrivate &other); -}; - -/*! - \class QVideoEncoderSettings - - \brief The QVideoEncoderSettings class provides a set of video encoder settings. - \since 1.0 - - A video encoder settings object is used to specify the video encoder - settings used by QMediaRecorder. Video encoder settings are selected by - constructing a QVideoEncoderSettings object, setting the desired properties - and then passing it to a QMediaRecorder instance using the - QMediaRecorder::setEncodingSettings() function. - - \snippet doc/src/snippets/multimedia-snippets/media.cpp Video encoder settings - - \sa QMediaRecorder, QVideoEncoderControl -*/ - -/*! - Constructs a null video encoder settings object. -*/ - -QVideoEncoderSettings::QVideoEncoderSettings() - :d(new QVideoEncoderSettingsPrivate) -{ -} - -/*! - Constructs a copy of the video encoder settings object \a other. - \since 1.0 -*/ - -QVideoEncoderSettings::QVideoEncoderSettings(const QVideoEncoderSettings& other) - :d(other.d) -{ -} - -/*! - Destroys a video encoder settings object. -*/ - -QVideoEncoderSettings::~QVideoEncoderSettings() -{ -} - -/*! - Assigns the value of \a other to a video encoder settings object. - \since 1.0 -*/ -QVideoEncoderSettings &QVideoEncoderSettings::operator=(const QVideoEncoderSettings &other) -{ - d = other.d; - return *this; -} - -/*! - Determines if \a other is of equal value to a video encoder settings object. - - Returns true if the settings objects are of equal value, and false if they - are not of equal value. - \since 1.0 -*/ -bool QVideoEncoderSettings::operator==(const QVideoEncoderSettings &other) const -{ - return (d == other.d) || - (d->isNull == other.d->isNull && - d->encodingMode == other.d->encodingMode && - d->bitrate == other.d->bitrate && - d->quality == other.d->quality && - d->codec == other.d->codec && - d->resolution == other.d->resolution && - qFuzzyCompare(d->frameRate, other.d->frameRate)); -} - -/*! - Determines if \a other is of equal value to a video encoder settings object. - - Returns true if the settings objects are not of equal value, and false if - they are of equal value. - \since 1.0 -*/ -bool QVideoEncoderSettings::operator!=(const QVideoEncoderSettings &other) const -{ - return !(*this == other); -} - -/*! - Identifies if a video encoder settings object is uninitalized. - - Returns true if the settings are null, and false if they are not. - \since 1.0 -*/ -bool QVideoEncoderSettings::isNull() const -{ - return d->isNull; -} - -/*! - Returns the video encoding mode. - - \since 1.0 - \sa QtMultimediaKit::EncodingMode -*/ -QtMultimediaKit::EncodingMode QVideoEncoderSettings::encodingMode() const -{ - return d->encodingMode; -} - -/*! - Sets the video encoding \a mode. - - If QtMultimediaKit::ConstantQualityEncoding is set, - the quality encoding parameter is used and bit rate is ignored, - otherwise the bitrate is used. - - The rest of encoding settings are respected regardless of encoding mode. - - \since 1.0 - \sa QtMultimediaKit::EncodingMode -*/ -void QVideoEncoderSettings::setEncodingMode(QtMultimediaKit::EncodingMode mode) -{ - d->isNull = false; - d->encodingMode = mode; -} - -/*! - Returns the video codec. - \since 1.0 -*/ - -QString QVideoEncoderSettings::codec() const -{ - return d->codec; -} - -/*! - Sets the video \a codec. - \since 1.0 -*/ -void QVideoEncoderSettings::setCodec(const QString& codec) -{ - d->isNull = false; - d->codec = codec; -} - -/*! - Returns bit rate of the encoded video stream in bits per second. - \since 1.0 -*/ -int QVideoEncoderSettings::bitRate() const -{ - return d->bitrate; -} - -/*! - Sets the bit rate of the encoded video stream to \a value. - \since 1.0 -*/ - -void QVideoEncoderSettings::setBitRate(int value) -{ - d->isNull = false; - d->bitrate = value; -} - -/*! - Returns the video frame rate. - \since 1.0 -*/ -qreal QVideoEncoderSettings::frameRate() const -{ - return d->frameRate; -} - -/*! - \fn QVideoEncoderSettings::setFrameRate(qreal rate) - - Sets the video frame \a rate. - - A value of 0 indicates the encoder should make an optimal choice based on what is available - from the video source and the limitations of the codec. - \since 1.0 -*/ - -void QVideoEncoderSettings::setFrameRate(qreal rate) -{ - d->isNull = false; - d->frameRate = rate; -} - -/*! - Returns the resolution of the encoded video. - \since 1.0 -*/ - -QSize QVideoEncoderSettings::resolution() const -{ - return d->resolution; -} - -/*! - Sets the \a resolution of the encoded video. - - An empty QSize indicates the encoder should make an optimal choice based on - what is available from the video source and the limitations of the codec. - \since 1.0 -*/ - -void QVideoEncoderSettings::setResolution(const QSize &resolution) -{ - d->isNull = false; - d->resolution = resolution; -} - -/*! - Sets the \a width and \a height of the resolution of the encoded video. - - \overload - \since 1.0 -*/ - -void QVideoEncoderSettings::setResolution(int width, int height) -{ - d->isNull = false; - d->resolution = QSize(width, height); -} - -/*! - Returns the video encoding quality. - \since 1.0 -*/ - -QtMultimediaKit::EncodingQuality QVideoEncoderSettings::quality() const -{ - return d->quality; -} - -/*! - Sets the video encoding \a quality. - - Setting the video quality parameter allows backend to choose the balanced - set of encoding parameters to achieve the desired quality level. - - The \a quality settings parameter is only used in the - \l {QtMultimediaKit::ConstantQualityEncoding}{constant quality} \l{encodingMode()}{encoding mode}. - The \a quality settings parameter is only used in the \l - {QtMultimediaKit::ConstantQualityEncoding}{constant quality} - \l{encodingMode()}{encoding mode}. - \since 1.0 -*/ - -void QVideoEncoderSettings::setQuality(QtMultimediaKit::EncodingQuality quality) -{ - d->isNull = false; - d->quality = quality; -} - - - -class QImageEncoderSettingsPrivate : public QSharedData -{ -public: - QImageEncoderSettingsPrivate() : - isNull(true), - quality(QtMultimediaKit::NormalQuality) - { - } - - QImageEncoderSettingsPrivate(const QImageEncoderSettingsPrivate &other): - QSharedData(other), - isNull(other.isNull), - codec(other.codec), - resolution(other.resolution), - quality(other.quality) - { - } - - bool isNull; - QString codec; - QSize resolution; - QtMultimediaKit::EncodingQuality quality; - -private: - QImageEncoderSettingsPrivate& operator=(const QImageEncoderSettingsPrivate &other); -}; - -/*! - \class QImageEncoderSettings - - - \brief The QImageEncoderSettings class provides a set of image encoder - settings. - \since 1.0 - - A image encoder settings object is used to specify the image encoder - settings used by QCameraImageCapture. Image encoder settings are selected - by constructing a QImageEncoderSettings object, setting the desired - properties and then passing it to a QCameraImageCapture instance using the - QCameraImageCapture::setImageSettings() function. - - \snippet doc/src/snippets/multimedia-snippets/media.cpp Image encoder settings - - \sa QImageEncoderControl -*/ - -/*! - Constructs a null image encoder settings object. -*/ - -QImageEncoderSettings::QImageEncoderSettings() - :d(new QImageEncoderSettingsPrivate) -{ -} - -/*! - Constructs a copy of the image encoder settings object \a other. - \since 1.0 -*/ - -QImageEncoderSettings::QImageEncoderSettings(const QImageEncoderSettings& other) - :d(other.d) -{ -} - -/*! - Destroys a image encoder settings object. -*/ - -QImageEncoderSettings::~QImageEncoderSettings() -{ -} - -/*! - Assigns the value of \a other to a image encoder settings object. - \since 1.0 -*/ -QImageEncoderSettings &QImageEncoderSettings::operator=(const QImageEncoderSettings &other) -{ - d = other.d; - return *this; -} - -/*! - Determines if \a other is of equal value to a image encoder settings - object. - - Returns true if the settings objects are of equal value, and false if they - are not of equal value. - \since 1.0 -*/ -bool QImageEncoderSettings::operator==(const QImageEncoderSettings &other) const -{ - return (d == other.d) || - (d->isNull == other.d->isNull && - d->quality == other.d->quality && - d->codec == other.d->codec && - d->resolution == other.d->resolution); - -} - -/*! - Determines if \a other is of equal value to a image encoder settings - object. - - Returns true if the settings objects are not of equal value, and false if - they are of equal value. - \since 1.0 -*/ -bool QImageEncoderSettings::operator!=(const QImageEncoderSettings &other) const -{ - return !(*this == other); -} - -/*! - Identifies if a image encoder settings object is uninitalized. - - Returns true if the settings are null, and false if they are not. - \since 1.0 -*/ -bool QImageEncoderSettings::isNull() const -{ - return d->isNull; -} - -/*! - Returns the image codec. - \since 1.0 -*/ - -QString QImageEncoderSettings::codec() const -{ - return d->codec; -} - -/*! - Sets the image \a codec. - \since 1.0 -*/ -void QImageEncoderSettings::setCodec(const QString& codec) -{ - d->isNull = false; - d->codec = codec; -} - -/*! - Returns the resolution of the encoded image. - \since 1.0 -*/ - -QSize QImageEncoderSettings::resolution() const -{ - return d->resolution; -} - -/*! - Sets the \a resolution of the encoded image. - - An empty QSize indicates the encoder should make an optimal choice based on - what is available from the image source and the limitations of the codec. - \since 1.0 -*/ - -void QImageEncoderSettings::setResolution(const QSize &resolution) -{ - d->isNull = false; - d->resolution = resolution; -} - -/*! - Sets the \a width and \a height of the resolution of the encoded image. - - \overload - \since 1.0 -*/ - -void QImageEncoderSettings::setResolution(int width, int height) -{ - d->isNull = false; - d->resolution = QSize(width, height); -} - -/*! - Returns the image encoding quality. - \since 1.0 -*/ - -QtMultimediaKit::EncodingQuality QImageEncoderSettings::quality() const -{ - return d->quality; -} - -/*! - Sets the image encoding \a quality. - \since 1.0 -*/ - -void QImageEncoderSettings::setQuality(QtMultimediaKit::EncodingQuality quality) -{ - d->isNull = false; - d->quality = quality; -} -QT_END_NAMESPACE - diff --git a/src/multimediakit/qmediaencodersettings.h b/src/multimediakit/qmediaencodersettings.h deleted file mode 100644 index 14edc08f3..000000000 --- a/src/multimediakit/qmediaencodersettings.h +++ /dev/null @@ -1,168 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QMEDIAENCODERSETTINGS_H -#define QMEDIAENCODERSETTINGS_H - -#include -#include -#include -#include -#include "qtmedianamespace.h" - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -QT_MODULE(Multimedia) - - - -class QAudioEncoderSettingsPrivate; -class Q_MULTIMEDIA_EXPORT QAudioEncoderSettings -{ -public: - QAudioEncoderSettings(); - QAudioEncoderSettings(const QAudioEncoderSettings& other); - - ~QAudioEncoderSettings(); - - QAudioEncoderSettings& operator=(const QAudioEncoderSettings &other); - bool operator==(const QAudioEncoderSettings &other) const; - bool operator!=(const QAudioEncoderSettings &other) const; - - bool isNull() const; - - QtMultimediaKit::EncodingMode encodingMode() const; - void setEncodingMode(QtMultimediaKit::EncodingMode); - - QString codec() const; - void setCodec(const QString& codec); - - int bitRate() const; - void setBitRate(int bitrate); - - int channelCount() const; - void setChannelCount(int channels); - - int sampleRate() const; - void setSampleRate(int rate); - - QtMultimediaKit::EncodingQuality quality() const; - void setQuality(QtMultimediaKit::EncodingQuality quality); - -private: - QSharedDataPointer d; -}; - -class QVideoEncoderSettingsPrivate; -class Q_MULTIMEDIA_EXPORT QVideoEncoderSettings -{ -public: - QVideoEncoderSettings(); - QVideoEncoderSettings(const QVideoEncoderSettings& other); - - ~QVideoEncoderSettings(); - - QVideoEncoderSettings& operator=(const QVideoEncoderSettings &other); - bool operator==(const QVideoEncoderSettings &other) const; - bool operator!=(const QVideoEncoderSettings &other) const; - - bool isNull() const; - - QtMultimediaKit::EncodingMode encodingMode() const; - void setEncodingMode(QtMultimediaKit::EncodingMode); - - QString codec() const; - void setCodec(const QString &); - - QSize resolution() const; - void setResolution(const QSize &); - void setResolution(int width, int height); - - qreal frameRate() const; - void setFrameRate(qreal rate); - - int bitRate() const; - void setBitRate(int bitrate); - - QtMultimediaKit::EncodingQuality quality() const; - void setQuality(QtMultimediaKit::EncodingQuality quality); - -private: - QSharedDataPointer d; -}; - -class QImageEncoderSettingsPrivate; -class Q_MULTIMEDIA_EXPORT QImageEncoderSettings -{ -public: - QImageEncoderSettings(); - QImageEncoderSettings(const QImageEncoderSettings& other); - - ~QImageEncoderSettings(); - - QImageEncoderSettings& operator=(const QImageEncoderSettings &other); - bool operator==(const QImageEncoderSettings &other) const; - bool operator!=(const QImageEncoderSettings &other) const; - - bool isNull() const; - - QString codec() const; - void setCodec(const QString &); - - QSize resolution() const; - void setResolution(const QSize &); - void setResolution(int width, int height); - - QtMultimediaKit::EncodingQuality quality() const; - void setQuality(QtMultimediaKit::EncodingQuality quality); - -private: - QSharedDataPointer d; -}; - -QT_END_NAMESPACE - -QT_END_HEADER - - -#endif diff --git a/src/multimediakit/qmediaenumdebug.h b/src/multimediakit/qmediaenumdebug.h deleted file mode 100644 index 3fa7ee820..000000000 --- a/src/multimediakit/qmediaenumdebug.h +++ /dev/null @@ -1,79 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QMEDIAENUMDEBUG_H -#define QMEDIAENUMDEBUG_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 -#include - -QT_BEGIN_HEADER - -#ifndef QT_NO_DEBUG_STREAM - -#define Q_MEDIA_ENUM_DEBUG(Class,Enum) \ -inline QDebug operator<<(QDebug dbg, Class::Enum value) \ -{ \ - int index = Class::staticMetaObject.indexOfEnumerator(#Enum); \ - dbg.nospace() << #Class << "::" << Class::staticMetaObject.enumerator(index).valueToKey(value); \ - return dbg.space(); \ -} - -#else - -#define Q_MEDIA_ENUM_DEBUG(Class,Enum) - -#endif //QT_NO_DEBUG_STREAM - -QT_END_HEADER - -#endif - diff --git a/src/multimediakit/qmediaimageviewer.cpp b/src/multimediakit/qmediaimageviewer.cpp deleted file mode 100644 index cac508f8d..000000000 --- a/src/multimediakit/qmediaimageviewer.cpp +++ /dev/null @@ -1,604 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qmediaimageviewer.h" - -#include "qmediaobject_p.h" -#include "qmediaimageviewerservice_p.h" - -#include -#include -#include -#include -#include - -#include -#include -#include -#include - -QT_BEGIN_NAMESPACE - -class QMediaImageViewerPrivate : public QMediaObjectPrivate -{ - Q_DECLARE_NON_CONST_PUBLIC(QMediaImageViewer) -public: - QMediaImageViewerPrivate(): - viewerControl(0), playlist(0), - state(QMediaImageViewer::StoppedState), timeout(3000), pauseTime(0) - { - } - - void _q_mediaStatusChanged(QMediaImageViewer::MediaStatus status); - void _q_playlistMediaChanged(const QMediaContent &content); - void _q_playlistDestroyed(); - - QMediaImageViewerControl *viewerControl; - QMediaPlaylist *playlist; - QPointer videoOutput; - QVideoSurfaceOutput surfaceOutput; - QMediaImageViewer::State state; - int timeout; - int pauseTime; - QTime time; - QBasicTimer timer; - QMediaContent media; -}; - -void QMediaImageViewerPrivate::_q_mediaStatusChanged(QMediaImageViewer::MediaStatus status) -{ - switch (status) { - case QMediaImageViewer::NoMedia: - case QMediaImageViewer::LoadingMedia: - emit q_func()->mediaStatusChanged(status); - break; - case QMediaImageViewer::LoadedMedia: - if (state == QMediaImageViewer::PlayingState) { - time.start(); - timer.start(qMax(0, timeout), q_func()); - q_func()->addPropertyWatch("elapsedTime"); - } - emit q_func()->mediaStatusChanged(status); - emit q_func()->elapsedTimeChanged(0); - break; - case QMediaImageViewer::InvalidMedia: - emit q_func()->mediaStatusChanged(status); - - if (state == QMediaImageViewer::PlayingState) { - playlist->next(); - if (playlist->currentIndex() < 0) - emit q_func()->stateChanged(state = QMediaImageViewer::StoppedState); - } - break; - } -} - -void QMediaImageViewerPrivate::_q_playlistMediaChanged(const QMediaContent &content) -{ - media = content; - pauseTime = 0; - - viewerControl->showMedia(media); - - emit q_func()->mediaChanged(media); -} - -void QMediaImageViewerPrivate::_q_playlistDestroyed() -{ - playlist = 0; - timer.stop(); - - if (state != QMediaImageViewer::StoppedState) - emit q_func()->stateChanged(state = QMediaImageViewer::StoppedState); - - q_func()->setMedia(QMediaContent()); -} - -/*! - \class QMediaImageViewer - \brief The QMediaImageViewer class provides a means of viewing image media. - \inmodule QtMultimediaKit - \ingroup multimedia - \since 1.0 - - - QMediaImageViewer is used together with a media display object such as - QVideoWidget to present an image. A display object is attached to the - image viewer by means of the bind function. - - \snippet doc/src/snippets/multimedia-snippets/media.cpp Binding - - QMediaImageViewer can be paired with a QMediaPlaylist to create a slide - show of images. Constructing a QMediaPlaylist with a pointer to an - instance of QMediaImageViewer will attach it to the image viewer; - changing the playlist's selection will then change the media displayed - by the image viewer. With a playlist attached QMediaImageViewer's - play(), pause(), and stop() slots can be control the progression of the - playlist. The \l timeout property determines how long an image is - displayed for before progressing to the next in the playlist, and the - \l elapsedTime property holds how the duration the current image has - been displayed for. - - \snippet doc/src/snippets/multimedia-snippets/media.cpp Playlist -*/ - -/*! - \enum QMediaImageViewer::State - - Enumerates the possible control states an image viewer may be in. The - control state of an image viewer determines whether the image viewer is - automatically progressing through images in an attached playlist. - - \value StoppedState The image viewer is stopped, and will not automatically move to the next - image. The \l elapsedTime is fixed at 0. - \value PlayingState The slide show is playing, and will move to the next image when the - \l elapsedTime reaches the \l timeout. The \l elapsedTime is being incremented. - \value PausedState The image viewer is paused, and will not automatically move the to next - image. The \l elapsedTime is fixed at the time the image viewer was paused. -*/ - -/*! - \enum QMediaImageViewer::MediaStatus - - Enumerates the status of an image viewer's current media. - - \value NoMedia There is no current media. - \value LoadingMedia The image viewer is loading the current media. - \value LoadedMedia The image viewer has loaded the current media. - \value InvalidMedia The current media cannot be loaded. -*/ - -/*! - Constructs a new image viewer with the given \a parent. -*/ -QMediaImageViewer::QMediaImageViewer(QObject *parent) - : QMediaObject(*new QMediaImageViewerPrivate, parent, new QMediaImageViewerService) -{ - Q_D(QMediaImageViewer); - - d->viewerControl = qobject_cast( - d->service->requestControl(QMediaImageViewerControl_iid)); - - connect(d->viewerControl, SIGNAL(mediaStatusChanged(QMediaImageViewer::MediaStatus)), - this, SLOT(_q_mediaStatusChanged(QMediaImageViewer::MediaStatus))); -} - -/*! - Destroys an image viewer. -*/ -QMediaImageViewer::~QMediaImageViewer() -{ - Q_D(QMediaImageViewer); - - delete d->service; -} - -/*! - \property QMediaImageViewer::state - \brief the playlist control state of a slide show. - \since 1.0 -*/ - -QMediaImageViewer::State QMediaImageViewer::state() const -{ - return d_func()->state; -} - -/*! - \fn QMediaImageViewer::stateChanged(QMediaImageViewer::State state) - - Signals that the playlist control \a state of an image viewer has changed. - \since 1.0 -*/ - -/*! - \property QMediaImageViewer::mediaStatus - \brief the status of the current media. - \since 1.0 -*/ - -QMediaImageViewer::MediaStatus QMediaImageViewer::mediaStatus() const -{ - return d_func()->viewerControl->mediaStatus(); -} - -/*! - \fn QMediaImageViewer::mediaStatusChanged(QMediaImageViewer::MediaStatus status) - - Signals the the \a status of the current media has changed. - \since 1.0 -*/ - -/*! - \property QMediaImageViewer::media - \brief the media an image viewer is presenting. - \since 1.0 -*/ - -QMediaContent QMediaImageViewer::media() const -{ - Q_D(const QMediaImageViewer); - - return d->media; -} - -void QMediaImageViewer::setMedia(const QMediaContent &media) -{ - Q_D(QMediaImageViewer); - - if (d->playlist && d->playlist->currentMedia() != media) { - disconnect(d->playlist, SIGNAL(currentMediaChanged(QMediaContent)), - this, SLOT(_q_playlistMediaChanged(QMediaContent))); - disconnect(d->playlist, SIGNAL(destroyed()), this, SLOT(_q_playlistDestroyed())); - - d->playlist = 0; - } - - d->media = media; - - if (d->timer.isActive()) { - d->pauseTime = 0; - d->timer.stop(); - removePropertyWatch("elapsedTime"); - emit elapsedTimeChanged(0); - } - - if (d->state != QMediaImageViewer::StoppedState) - emit stateChanged(d->state = QMediaImageViewer::StoppedState); - - d->viewerControl->showMedia(d->media); - - emit mediaChanged(d->media); -} - -/*! - Use \a playlist as the source of images to be displayed in the viewer. - \since 1.0 -*/ -void QMediaImageViewer::setPlaylist(QMediaPlaylist *playlist) -{ - Q_D(QMediaImageViewer); - - if (d->playlist) { - disconnect(d->playlist, SIGNAL(currentMediaChanged(QMediaContent)), - this, SLOT(_q_playlistMediaChanged(QMediaContent))); - disconnect(d->playlist, SIGNAL(destroyed()), this, SLOT(_q_playlistDestroyed())); - - QMediaObject::unbind(d->playlist); - } - - d->playlist = playlist; - - if (d->playlist) { - connect(d->playlist, SIGNAL(currentMediaChanged(QMediaContent)), - this, SLOT(_q_playlistMediaChanged(QMediaContent))); - connect(d->playlist, SIGNAL(destroyed()), this, SLOT(_q_playlistDestroyed())); - - QMediaObject::bind(d->playlist); - - setMedia(d->playlist->currentMedia()); - } else { - setMedia(QMediaContent()); - } -} - -/*! - Returns the current playlist, or 0 if none. - \since 1.0 -*/ -QMediaPlaylist *QMediaImageViewer::playlist() const -{ - return d_func()->playlist; -} - -/*! - \fn QMediaImageViewer::mediaChanged(const QMediaContent &media) - - Signals that the \a media an image viewer is presenting has changed. - \since 1.0 -*/ - -/*! - \property QMediaImageViewer::timeout - \brief the amount of time in milliseconds an image is displayed for before moving to the next - image. - - The timeout only applies if the image viewer has a playlist attached and is in the PlayingState. - \since 1.0 -*/ - -int QMediaImageViewer::timeout() const -{ - return d_func()->timeout; -} - -void QMediaImageViewer::setTimeout(int timeout) -{ - Q_D(QMediaImageViewer); - - d->timeout = qMax(0, timeout); - - if (d->timer.isActive()) - d->timer.start(qMax(0, d->timeout - d->pauseTime - d->time.elapsed()), this); -} - -/*! - \property QMediaImageViewer::elapsedTime - \brief the amount of time in milliseconds that has elapsed since the current image was loaded. - - The elapsed time only increases while the image viewer is in the PlayingState. If stopped the - elapsed time will be reset to 0. - \since 1.0 -*/ - -int QMediaImageViewer::elapsedTime() const -{ - Q_D(const QMediaImageViewer); - - int elapsedTime = d->pauseTime; - - if (d->timer.isActive()) - elapsedTime += d->time.elapsed(); - - return elapsedTime; -} - -/*! - \fn QMediaImageViewer::elapsedTimeChanged(int time) - - Signals that the amount of \a time in milliseconds since the current - image was loaded has changed. - - This signal is emitted at a regular interval when the image viewer is - in the PlayingState and an image is loaded. The notification interval - is controlled by the QMediaObject::notifyInterval property. - - \since 1.0 - \sa timeout, QMediaObject::notifyInterval -*/ - -/*! - Sets a video \a widget as the current video output. - - This will unbind any previous video output bound with setVideoOutput(). - \since 1.1 -*/ - -void QMediaImageViewer::setVideoOutput(QVideoWidget *widget) -{ - Q_D(QMediaImageViewer); - - if (d->videoOutput) - unbind(d->videoOutput); - - // We don't know (in this library) that QVideoWidget inherits QObject - QObject *widgetObject = reinterpret_cast(widget); - - d->videoOutput = widgetObject && bind(widgetObject) ? widgetObject : 0; -} - -/*! - Sets a video \a item as the current video output. - - This will unbind any previous video output bound with setVideoOutput(). - \since 1.1 -*/ - -void QMediaImageViewer::setVideoOutput(QGraphicsVideoItem *item) -{ - Q_D(QMediaImageViewer); - - if (d->videoOutput) - unbind(d->videoOutput); - - // We don't know (in this library) that QGraphicsVideoItem (multiply) inherits QObject - // but QObject inheritance depends on QObject coming first, so try this out. - QObject *itemObject = reinterpret_cast(item); - - d->videoOutput = itemObject && bind(itemObject) ? itemObject : 0; -} - -/*! - Sets a video \a surface as the video output of a image viewer. - - If a video output has already been set on the image viewer the new surface - will replace it. - \since 1.2 -*/ - -void QMediaImageViewer::setVideoOutput(QAbstractVideoSurface *surface) -{ - Q_D(QMediaImageViewer); - - d->surfaceOutput.setVideoSurface(surface); - - if (d->videoOutput != &d->surfaceOutput) { - if (d->videoOutput) - unbind(d->videoOutput); - - d->videoOutput = bind(&d->surfaceOutput) ? &d->surfaceOutput : 0; - } -} - -/*! - \internal - \since 1.0 -*/ -bool QMediaImageViewer::bind(QObject *object) -{ - if (QMediaPlaylist *playlist = qobject_cast(object)) { - setPlaylist(playlist); - - return true; - } else { - return QMediaObject::bind(object); - } -} - -/*! - \internal - \since 1.0 - */ -void QMediaImageViewer::unbind(QObject *object) -{ - if (object == d_func()->playlist) - setPlaylist(0); - else - QMediaObject::unbind(object); -} - -/*! - Starts a slide show. - - If the playlist has no current media this will start at the beginning of the playlist, otherwise - it will resume from the current media. - - If no playlist is attached to an image viewer this will do nothing. - \since 1.0 -*/ -void QMediaImageViewer::play() -{ - Q_D(QMediaImageViewer); - - if (d->playlist && d->playlist->mediaCount() > 0 && d->state != PlayingState) { - d->state = PlayingState; - - switch (d->viewerControl->mediaStatus()) { - case NoMedia: - case InvalidMedia: - d->playlist->next(); - if (d->playlist->currentIndex() < 0) - d->state = StoppedState; - break; - case LoadingMedia: - break; - case LoadedMedia: - d->time.start(); - d->timer.start(qMax(0, d->timeout - d->pauseTime), this); - break; - } - - if (d->state == PlayingState) - emit stateChanged(d->state); - } -} - -/*! - Pauses a slide show. - - The current media and elapsed time are retained. If resumed, the current image will be - displayed for the remainder of the time out period before the next image is loaded. - \since 1.0 -*/ -void QMediaImageViewer::pause() -{ - Q_D(QMediaImageViewer); - - if (d->state == PlayingState) { - if (d->viewerControl->mediaStatus() == LoadedMedia) { - d->pauseTime += d->timeout - d->time.elapsed(); - d->timer.stop(); - removePropertyWatch("elapsedTime"); - } - - emit stateChanged(d->state = PausedState); - emit elapsedTimeChanged(d->pauseTime); - } -} - -/*! - Stops a slide show. - - The current media is retained, but the elapsed time is discarded. If resumed, the current - image will be displayed for the full time out period before the next image is loaded. - \since 1.0 -*/ -void QMediaImageViewer::stop() -{ - Q_D(QMediaImageViewer); - - switch (d->state) { - case PlayingState: - d->timer.stop(); - removePropertyWatch("elapsedTime"); - // fall through. - case PausedState: - d->pauseTime = 0; - d->state = QMediaImageViewer::StoppedState; - - emit stateChanged(d->state); - emit elapsedTimeChanged(0); - break; - case StoppedState: - break; - } -} - -/*! - \reimp - - \internal - \since 1.0 -*/ -void QMediaImageViewer::timerEvent(QTimerEvent *event) -{ - Q_D(QMediaImageViewer); - - if (event->timerId() == d->timer.timerId()) { - d->timer.stop(); - removePropertyWatch("elapsedTime"); - emit elapsedTimeChanged(d->pauseTime = d->timeout); - - d->playlist->next(); - - if (d->playlist->currentIndex() < 0) { - d->pauseTime = 0; - emit stateChanged(d->state = StoppedState); - emit elapsedTimeChanged(0); - } - } else { - QMediaObject::timerEvent(event); - } -} - -#include "moc_qmediaimageviewer.cpp" -QT_END_NAMESPACE - diff --git a/src/multimediakit/qmediaimageviewer.h b/src/multimediakit/qmediaimageviewer.h deleted file mode 100644 index 7010fad3f..000000000 --- a/src/multimediakit/qmediaimageviewer.h +++ /dev/null @@ -1,142 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QMEDIAIMAGEVIEWER_H -#define QMEDIAIMAGEVIEWER_H - -#include "qmediaobject.h" -#include "qmediacontent.h" -#include - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -QT_MODULE(Multimedia) - - -class QAbstractVideoSurface; -class QGraphicsVideoItem; -class QMediaPlaylist; -class QVideoWidget; - -class QMediaImageViewerPrivate; -class Q_MULTIMEDIA_EXPORT QMediaImageViewer : public QMediaObject -{ - Q_OBJECT - Q_PROPERTY(State state READ state NOTIFY stateChanged) - Q_PROPERTY(MediaStatus mediaStatus READ mediaStatus NOTIFY mediaStatusChanged) - Q_PROPERTY(QMediaContent media READ media WRITE setMedia NOTIFY mediaChanged) - Q_PROPERTY(int timeout READ timeout WRITE setTimeout) - Q_PROPERTY(int elapsedTime READ elapsedTime NOTIFY elapsedTimeChanged) - Q_ENUMS(State MediaStatus) - -public: - enum State - { - StoppedState, - PlayingState, - PausedState - }; - - enum MediaStatus - { - NoMedia, - LoadingMedia, - LoadedMedia, - InvalidMedia - }; - - explicit QMediaImageViewer(QObject *parent = 0); - ~QMediaImageViewer(); - - State state() const; - MediaStatus mediaStatus() const; - - QMediaContent media() const; - QMediaPlaylist *playlist() const; - - int timeout() const; - int elapsedTime() const; - - void setVideoOutput(QVideoWidget *widget); - void setVideoOutput(QGraphicsVideoItem *item); - void setVideoOutput(QAbstractVideoSurface *surface); - - bool bind(QObject *); - void unbind(QObject *); - -public Q_SLOTS: - void setMedia(const QMediaContent &media); - void setPlaylist(QMediaPlaylist *playlist); - - void play(); - void pause(); - void stop(); - - void setTimeout(int timeout); - -Q_SIGNALS: - void stateChanged(QMediaImageViewer::State state); - void mediaStatusChanged(QMediaImageViewer::MediaStatus status); - void mediaChanged(const QMediaContent &media); - void elapsedTimeChanged(int time); -protected: - void timerEvent(QTimerEvent *event); - -private: - Q_DECLARE_PRIVATE(QMediaImageViewer) - Q_PRIVATE_SLOT(d_func(), void _q_mediaStatusChanged(QMediaImageViewer::MediaStatus)) - Q_PRIVATE_SLOT(d_func(), void _q_playlistMediaChanged(const QMediaContent &)) - Q_PRIVATE_SLOT(d_func(), void _q_playlistDestroyed()) -}; - -QT_END_NAMESPACE - -Q_DECLARE_METATYPE(QMediaImageViewer::State) -Q_DECLARE_METATYPE(QMediaImageViewer::MediaStatus) - -Q_MEDIA_ENUM_DEBUG(QMediaImageViewer, State) -Q_MEDIA_ENUM_DEBUG(QMediaImageViewer, MediaStatus) - -QT_END_HEADER - -#endif diff --git a/src/multimediakit/qmediaimageviewerservice.cpp b/src/multimediakit/qmediaimageviewerservice.cpp deleted file mode 100644 index 65de7a81b..000000000 --- a/src/multimediakit/qmediaimageviewerservice.cpp +++ /dev/null @@ -1,463 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qmediaimageviewerservice_p.h" - -#include "qmediacontrol_p.h" -#include "qmediaservice_p.h" - -#include -#include -#include -#include - -#include - -#include -#include - -#include -#include -#include - -#include -#include - -QT_BEGIN_NAMESPACE - -class QMediaImageViewerServicePrivate : public QMediaServicePrivate -{ -public: - QMediaImageViewerServicePrivate() - : viewerControl(0) - , rendererControl(0) - , network(0) - , internalNetwork(0) - { - } - - bool load(QIODevice *device); - void clear(); - - QMediaImageViewerControl *viewerControl; - QMediaImageViewerRenderer *rendererControl; - QNetworkAccessManager *network; - QNetworkAccessManager *internalNetwork; - QImage m_image; -}; - - -QMediaImageViewerRenderer::QMediaImageViewerRenderer(QObject *parent) - : QVideoRendererControl(parent) - , m_surface(0) -{ -} - -QMediaImageViewerRenderer::~QMediaImageViewerRenderer() -{ - if (m_surface) - m_surface->stop(); -} - -QAbstractVideoSurface *QMediaImageViewerRenderer::surface() const -{ - return m_surface; -} - -void QMediaImageViewerRenderer::setSurface(QAbstractVideoSurface *surface) -{ - if (m_surface) - m_surface->stop(); - - m_surface = surface; - - if (m_surface && !m_image.isNull()) - showImage(m_image); -} - -void QMediaImageViewerRenderer::showImage(const QImage &image) -{ - m_image = image; - - if (m_surface) { - if (m_image.isNull()) { - m_surface->stop(); - } else { - QVideoSurfaceFormat format( - image.size(), QVideoFrame::pixelFormatFromImageFormat(image.format())); - - if (!m_surface->isFormatSupported(format)) { - foreach (QVideoFrame::PixelFormat pixelFormat, m_surface->supportedPixelFormats()) { - const QImage::Format imageFormat - = QVideoFrame::imageFormatFromPixelFormat(pixelFormat); - - if (imageFormat != QImage::Format_Invalid) { - format = QVideoSurfaceFormat(image.size(), pixelFormat); - - if (m_surface->isFormatSupported(format) && m_surface->start(format)) { - m_image = image.convertToFormat(imageFormat); - - m_surface->present(QVideoFrame(m_image)); - - return; - } - } - } - } else if (m_surface->start(format)) { - m_surface->present(QVideoFrame(image)); - } - } - } -} - -bool QMediaImageViewerServicePrivate::load(QIODevice *device) -{ - QImageReader reader(device); - - if (!reader.canRead()) { - m_image = QImage(); - } else { - m_image = reader.read(); - } - - if (rendererControl) - rendererControl->showImage(m_image); - - return !m_image.isNull(); -} - -void QMediaImageViewerServicePrivate::clear() -{ - m_image = QImage(); - - if (rendererControl) - rendererControl->showImage(m_image); -} - -/*! - \class QMediaImageViewerService - \since 1.0 - \internal -*/ - -/*! -*/ -QMediaImageViewerService::QMediaImageViewerService(QObject *parent) - : QMediaService(*new QMediaImageViewerServicePrivate, parent) -{ - Q_D(QMediaImageViewerService); - - d->viewerControl = new QMediaImageViewerControl(this); -} - -/*! -*/ -QMediaImageViewerService::~QMediaImageViewerService() -{ - Q_D(QMediaImageViewerService); - - delete d->rendererControl; - delete d->viewerControl; -} - -/*! -*/ -QMediaControl *QMediaImageViewerService::requestControl(const char *name) -{ - Q_D(QMediaImageViewerService); - - if (qstrcmp(name, QMediaImageViewerControl_iid) == 0) { - return d->viewerControl; - } else if (qstrcmp(name, QVideoRendererControl_iid) == 0) { - if (!d->rendererControl) { - d->rendererControl = new QMediaImageViewerRenderer; - d->rendererControl->showImage(d->m_image); - - return d->rendererControl; - } - } - return 0; -} - -void QMediaImageViewerService::releaseControl(QMediaControl *control) -{ - Q_D(QMediaImageViewerService); - - if (!control) { - qWarning("QMediaService::releaseControl():" - " Attempted release of null control"); - } else if (control == d->rendererControl) { - delete d->rendererControl; - - d->rendererControl = 0; - } -} - -/*! -*/ -QNetworkAccessManager *QMediaImageViewerService::networkManager() const -{ - Q_D(const QMediaImageViewerService); - - if (!d->network) { - QMediaImageViewerServicePrivate *_d = const_cast(d); - - if (!_d->internalNetwork) - _d->internalNetwork = new QNetworkAccessManager( - const_cast(this)); - - _d->network = d->internalNetwork; - } - - return d->network; -} - - -void QMediaImageViewerService::setNetworkManager(QNetworkAccessManager *manager) -{ - d_func()->network = manager; -} - -class QMediaImageViewerControlPrivate : public QMediaControlPrivate -{ - Q_DECLARE_NON_CONST_PUBLIC(QMediaImageViewerControl) -public: - QMediaImageViewerControlPrivate() - : service(0) - , getReply(0) - , headReply(0) - , status(QMediaImageViewer::NoMedia) - { - foreach (const QByteArray &format, QImageReader::supportedImageFormats()) { - supportedExtensions.append( - QLatin1Char('.') + QString::fromLatin1(format.data(), format.size())); - } - } - - bool isImageType(const QUrl &url, const QString &mimeType) const; - - void loadImage(); - void cancelRequests(); - - void _q_getFinished(); - void _q_headFinished(); - - QMediaImageViewerService *service; - QNetworkReply *getReply; - QNetworkReply *headReply; - QMediaImageViewer::MediaStatus status; - QMediaContent media; - QMediaResource currentMedia; - QList possibleResources; - QStringList supportedExtensions; -}; - -bool QMediaImageViewerControlPrivate::isImageType(const QUrl &url, const QString &mimeType) const -{ - if (!mimeType.isEmpty()) { - return mimeType.startsWith(QLatin1String("image/")) - || mimeType == QLatin1String("application/xml+svg"); - } else if (url.scheme() == QLatin1String("file")) { - QString path = url.path(); - - foreach (const QString &extension, supportedExtensions) { - if (path.endsWith(extension, Qt::CaseInsensitive)) - return true; - } - } - return false; -} - -void QMediaImageViewerControlPrivate::loadImage() -{ - cancelRequests(); - - QMediaImageViewer::MediaStatus currentStatus = status; - status = QMediaImageViewer::InvalidMedia; - - QNetworkAccessManager *network = service->networkManager(); - - while (!possibleResources.isEmpty() && !headReply && !getReply) { - currentMedia = possibleResources.takeFirst(); - - QUrl url = currentMedia.url(); - QString mimeType = currentMedia.mimeType(); - - if (isImageType(url, mimeType)) { - getReply = network->get(QNetworkRequest(url)); - QObject::connect(getReply, SIGNAL(finished()), q_func(), SLOT(_q_getFinished())); - - status = QMediaImageViewer::LoadingMedia; - } else if (mimeType.isEmpty() && url.scheme() != QLatin1String("file")) { - headReply = network->head(QNetworkRequest(currentMedia.url())); - QObject::connect(headReply, SIGNAL(finished()), q_func(), SLOT(_q_headFinished())); - - status = QMediaImageViewer::LoadingMedia; - } - } - - if (status == QMediaImageViewer::InvalidMedia) - currentMedia = QMediaResource(); - - if (status != currentStatus) - emit q_func()->mediaStatusChanged(status); -} - -void QMediaImageViewerControlPrivate::cancelRequests() -{ - if (getReply) { - getReply->abort(); - getReply->deleteLater(); - getReply = 0; - } - - if (headReply) { - headReply->abort(); - headReply->deleteLater(); - headReply = 0; - } -} - -void QMediaImageViewerControlPrivate::_q_getFinished() -{ - if (getReply != q_func()->sender()) - return; - - QImage image; - - if (service->d_func()->load(getReply)) { - possibleResources.clear(); - - status = QMediaImageViewer::LoadedMedia; - - emit q_func()->mediaStatusChanged(status); - } else { - loadImage(); - } -} - -void QMediaImageViewerControlPrivate::_q_headFinished() -{ - if (headReply != q_func()->sender()) - return; - - QString mimeType = headReply->header(QNetworkRequest::ContentTypeHeader) - .toString().section(QLatin1Char(';'), 0, 0); - QUrl url = headReply->url(); - if (url.isEmpty()) - url = headReply->request().url(); - - headReply->deleteLater(); - headReply = 0; - - if (isImageType(url, mimeType) || mimeType.isEmpty()) { - QNetworkAccessManager *network = service->networkManager(); - - getReply = network->get(QNetworkRequest(url)); - - QObject::connect(getReply, SIGNAL(finished()), q_func(), SLOT(_q_getFinished())); - } else { - loadImage(); - } -} - -/*! - \class QMediaImageViewerControl - \internal - \since 1.1 -*/ -QMediaImageViewerControl::QMediaImageViewerControl(QMediaImageViewerService *parent) - : QMediaControl(*new QMediaImageViewerControlPrivate, parent) -{ - Q_D(QMediaImageViewerControl); - - d->service = parent; -} - -/*! -*/ -QMediaImageViewerControl::~QMediaImageViewerControl() -{ - Q_D(QMediaImageViewerControl); - - delete d->getReply; -} - -/*! - \since 1.1 -*/ -QMediaImageViewer::MediaStatus QMediaImageViewerControl::mediaStatus() const -{ - return d_func()->status; -} - -/*! - \fn QMediaImageViewerControl::mediaStatusChanged(QMediaImageViewer::MediaStatus status); - \since 1.1 -*/ - -/*! - \since 1.1 -*/ -void QMediaImageViewerControl::showMedia(const QMediaContent &media) -{ - Q_D(QMediaImageViewerControl); - - d->media = media; - d->currentMedia = QMediaResource(); - d->cancelRequests(); - - if (media.isNull()) { - d->service->d_func()->clear(); - if (d->status != QMediaImageViewer::NoMedia) { - d->status = QMediaImageViewer::NoMedia; - emit mediaStatusChanged(d->status); - } - } else { - d->possibleResources = media.resources(); - d->loadImage(); - } -} - - -#include "moc_qmediaimageviewerservice_p.cpp" -QT_END_NAMESPACE - diff --git a/src/multimediakit/qmediaimageviewerservice_p.h b/src/multimediakit/qmediaimageviewerservice_p.h deleted file mode 100644 index e40cdc5f4..000000000 --- a/src/multimediakit/qmediaimageviewerservice_p.h +++ /dev/null @@ -1,147 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QMEDIASLIDESHOWSERVICE_P_H -#define QMEDIASLIDESHOWSERVICE_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 -#include -#include -#include - -#include -#include - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -QT_MODULE(Multimedia) - -class QAbstractVideoSurface; -class QNetworkAccessManager; -QT_END_NAMESPACE - -QT_BEGIN_NAMESPACE - -class QMediaImageViewerServicePrivate; - -class Q_AUTOTEST_EXPORT QMediaImageViewerService : public QMediaService -{ - Q_OBJECT -public: - explicit QMediaImageViewerService(QObject *parent = 0); - ~QMediaImageViewerService(); - - QMediaControl *requestControl(const char *name); - void releaseControl(QMediaControl *); - - QNetworkAccessManager *networkManager() const; - void setNetworkManager(QNetworkAccessManager *manager); - -private: - Q_DECLARE_PRIVATE(QMediaImageViewerService) - friend class QMediaImageViewerControl; - friend class QMediaImageViewerControlPrivate; -}; - -class QMediaImageViewerControlPrivate; - -class QMediaImageViewerControl : public QMediaControl -{ - Q_OBJECT -public: - explicit QMediaImageViewerControl(QMediaImageViewerService *parent); - ~QMediaImageViewerControl(); - - QMediaImageViewer::MediaStatus mediaStatus() const; - - void showMedia(const QMediaContent &media); - -Q_SIGNALS: - void mediaStatusChanged(QMediaImageViewer::MediaStatus status); - -private: - Q_DECLARE_PRIVATE(QMediaImageViewerControl) - Q_PRIVATE_SLOT(d_func(), void _q_headFinished()) - Q_PRIVATE_SLOT(d_func(), void _q_getFinished()) -}; - -#define QMediaImageViewerControl_iid "com.nokia.Qt.QMediaImageViewerControl/1.0" -Q_MEDIA_DECLARE_CONTROL(QMediaImageViewerControl, QMediaImageViewerControl_iid) - -class QMediaImageViewerRenderer : public QVideoRendererControl -{ - Q_OBJECT -public: - QMediaImageViewerRenderer(QObject *parent = 0); - ~QMediaImageViewerRenderer(); - - QAbstractVideoSurface *surface() const; - void setSurface(QAbstractVideoSurface *surface); - - void showImage(const QImage &image); - -Q_SIGNALS: - void surfaceChanged(QAbstractVideoSurface *surface); - -private: - QPointer m_surface; - QImage m_image; -}; - -QT_END_NAMESPACE - -QT_END_HEADER - - -#endif diff --git a/src/multimediakit/qmedianetworkaccesscontrol.cpp b/src/multimediakit/qmedianetworkaccesscontrol.cpp deleted file mode 100644 index 3a18fab7a..000000000 --- a/src/multimediakit/qmedianetworkaccesscontrol.cpp +++ /dev/null @@ -1,103 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qmedianetworkaccesscontrol.h" - -QT_BEGIN_NAMESPACE - -/*! - \class QMediaNetworkAccessControl - \preliminary - \brief The QMediaNetworkAccessControl class allows the setting of the Network Access Point for media related activities. - \ingroup multimedia-serv - \inmodule QtMultimediaKit - \since 1.2 - - The functionality provided by this control allows the - setting of a Network Access Point. - - This control can be used to set a network access for various - network related activities. the exact nature in dependant on the underlying - usage by the supported QMediaObject -*/ - -QMediaNetworkAccessControl::QMediaNetworkAccessControl(QObject *parent) : - QMediaControl(parent) -{ -} - -/*! - Destroys a network access control. -*/ -QMediaNetworkAccessControl::~QMediaNetworkAccessControl() -{ -} - -/*! - \fn void QMediaNetworkAccessControl::setConfigurations(const QList &configurations); - - \a configurations contains a list of network configurations to be used for network access. - - It is assumed the list is given in highest to lowest preference order. - By calling this function all previous configurations will be invalidated - and replaced with the new list. - \since 1.2 -*/ - -/* - \fn QNetworkConfiguration QMediaNetworkAccessControl::currentConfiguration() const - - Returns the current active configuration in use. - A default constructed QNetworkConfigration is returned if no user supplied configuration are in use. -*/ - - -/*! - \fn QMediaNetworkAccessControl::configurationChanged(const QNetworkConfiguration &configuration) - This signal is emitted when the current active network configuration changes - to \a configuration. - \since 1.2 -*/ - - - -#include "moc_qmedianetworkaccesscontrol.cpp" -QT_END_NAMESPACE diff --git a/src/multimediakit/qmedianetworkaccesscontrol.h b/src/multimediakit/qmedianetworkaccesscontrol.h deleted file mode 100644 index 22ee95711..000000000 --- a/src/multimediakit/qmedianetworkaccesscontrol.h +++ /dev/null @@ -1,83 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - - -#ifndef QMEDIANETWORKACCESSCONTROL_H -#define QMEDIANETWORKACCESSCONTROL_H - -#include "qmediacontrol.h" - -#include -#include - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -QT_MODULE(Multimedia) - - -class Q_MULTIMEDIA_EXPORT QMediaNetworkAccessControl : public QMediaControl -{ - Q_OBJECT -public: - - virtual ~QMediaNetworkAccessControl(); - - virtual void setConfigurations(const QList &configuration) = 0; - virtual QNetworkConfiguration currentConfiguration() const = 0; - -Q_SIGNALS: - void configurationChanged(const QNetworkConfiguration& configuration); - -protected: - QMediaNetworkAccessControl(QObject *parent = 0); -}; - -#define QMediaNetworkAccessControl_iid "com.nokia.Qt.QMediaNetworkAccessControl/1.0" -Q_MEDIA_DECLARE_CONTROL(QMediaNetworkAccessControl, QMediaNetworkAccessControl_iid) - -QT_END_NAMESPACE - -QT_END_HEADER - - -#endif diff --git a/src/multimediakit/qmediaobject.cpp b/src/multimediakit/qmediaobject.cpp deleted file mode 100644 index 2f6840e04..000000000 --- a/src/multimediakit/qmediaobject.cpp +++ /dev/null @@ -1,423 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include -#include - -#include "qmediaobject_p.h" - -#include -#include -#include - - -QT_BEGIN_NAMESPACE - -void QMediaObjectPrivate::_q_notify() -{ - Q_Q(QMediaObject); - - const QMetaObject* m = q->metaObject(); - - foreach (int pi, notifyProperties) { - QMetaProperty p = m->property(pi); - p.notifySignal().invoke( - q, QGenericArgument(QMetaType::typeName(p.userType()), p.read(q).data())); - } -} - - -/*! - \class QMediaObject - - \brief The QMediaObject class provides a common base for multimedia objects. - - \inmodule QtMultimediaKit - \ingroup multimedia - \since 1.0 - - QMediaObject derived classes provide access to the functionality of a - QMediaService. Each media object hosts a QMediaService and uses the - QMediaControl interfaces implemented by the service to implement its - API. Most media objects when constructed will request a new - QMediaService instance from a QMediaServiceProvider, but some like - QMediaRecorder will share a service with another object. - - QMediaObject itself provides an API for accessing a media - service's \l {metaData()}{meta-data} and a means of connecting other media objects, - and peripheral classes like QVideoWidget and QMediaPlaylist. - - \sa QMediaService, QMediaControl -*/ - -/*! - Destroys this media object. -*/ - -QMediaObject::~QMediaObject() -{ - delete d_ptr; -} - -/*! - Returns the service availability error state. - \since 1.0 -*/ - -QtMultimediaKit::AvailabilityError QMediaObject::availabilityError() const -{ - return d_func()->service == 0 ? QtMultimediaKit::ServiceMissingError : QtMultimediaKit::NoError; -} - -/*! - Returns true if the service is available for use. - \since 1.0 -*/ - -bool QMediaObject::isAvailable() const -{ - return d_func()->service != 0; -} - -/*! - Returns the media service that provides the functionality of this multimedia object. - \since 1.0 -*/ - -QMediaService* QMediaObject::service() const -{ - return d_func()->service; -} - -int QMediaObject::notifyInterval() const -{ - return d_func()->notifyTimer->interval(); -} - -void QMediaObject::setNotifyInterval(int milliSeconds) -{ - Q_D(QMediaObject); - - if (d->notifyTimer->interval() != milliSeconds) { - d->notifyTimer->setInterval(milliSeconds); - - emit notifyIntervalChanged(milliSeconds); - } -} - -/*! - Bind \a object to this QMediaObject instance. - - This method establishes a relationship between this media object and a - helper object. The nature of the relationship depends on both parties. This - methods returns true if the helper was successfully bound, false otherwise. - - Most subclasses of QMediaObject provide more convenient functions - that wrap this functionality, so this function rarely needs to be - called directly. - - The object passed must implement the QMediaBindableInterface interface. - - \since 1.0 - \sa QMediaBindableInterface -*/ -bool QMediaObject::bind(QObject *object) -{ - QMediaBindableInterface *helper = qobject_cast(object); - if (!helper) - return false; - - QMediaObject *currentObject = helper->mediaObject(); - - if (currentObject == this) - return true; - - if (currentObject) - currentObject->unbind(object); - - return helper->setMediaObject(this); -} - -/*! - Detach \a object from the QMediaObject instance. - - Unbind the helper object from this media object. A warning - will be generated if the object was not previously bound to this - object. - - \since 1.0 - \sa QMediaBindableInterface -*/ -void QMediaObject::unbind(QObject *object) -{ - QMediaBindableInterface *helper = qobject_cast(object); - - if (helper && helper->mediaObject() == this) - helper->setMediaObject(0); - else - qWarning() << "QMediaObject: Trying to unbind not connected helper object"; -} - -/*! - Constructs a media object which uses the functionality provided by a media \a service. - - The \a parent is passed to QObject. - - This class is meant as a base class for multimedia objects so this - constructor is protected. - \since 1.0 -*/ - -QMediaObject::QMediaObject(QObject *parent, QMediaService *service): - QObject(parent), - d_ptr(new QMediaObjectPrivate) - -{ - Q_D(QMediaObject); - - d->q_ptr = this; - - d->notifyTimer = new QTimer(this); - d->notifyTimer->setInterval(1000); - connect(d->notifyTimer, SIGNAL(timeout()), SLOT(_q_notify())); - - d->service = service; - - setupMetaData(); -} - -/*! - \internal -*/ - -QMediaObject::QMediaObject(QMediaObjectPrivate &dd, QObject *parent, - QMediaService *service): - QObject(parent), - d_ptr(&dd) -{ - Q_D(QMediaObject); - d->q_ptr = this; - - d->notifyTimer = new QTimer(this); - d->notifyTimer->setInterval(1000); - connect(d->notifyTimer, SIGNAL(timeout()), SLOT(_q_notify())); - - d->service = service; - - setupMetaData(); -} - -/*! - Watch the property \a name. The property's notify signal will be emitted - once every \code notifyInterval milliseconds. - - \since 1.0 - \sa notifyInterval -*/ - -void QMediaObject::addPropertyWatch(QByteArray const &name) -{ - Q_D(QMediaObject); - - const QMetaObject* m = metaObject(); - - int index = m->indexOfProperty(name.constData()); - - if (index != -1 && m->property(index).hasNotifySignal()) { - d->notifyProperties.insert(index); - - if (!d->notifyTimer->isActive()) - d->notifyTimer->start(); - } -} - -/*! - Remove property \a name from the list of properties whose changes are - regularly signaled. - - \since 1.0 - \sa notifyInterval -*/ - -void QMediaObject::removePropertyWatch(QByteArray const &name) -{ - Q_D(QMediaObject); - - int index = metaObject()->indexOfProperty(name.constData()); - - if (index != -1) { - d->notifyProperties.remove(index); - - if (d->notifyProperties.isEmpty()) - d->notifyTimer->stop(); - } -} - -/*! - \property QMediaObject::notifyInterval - - The interval at which notifiable properties will update. - - The interval is expressed in milliseconds, the default value is 1000. - - \since 1.0 - \sa addPropertyWatch(), removePropertyWatch() -*/ - -/*! - \fn void QMediaObject::notifyIntervalChanged(int milliseconds) - - Signal a change in the notify interval period to \a milliseconds. - \since 1.0 -*/ - -/*! - Returns true if there is meta-data associated with this media object, else false. - \since 1.0 -*/ - -bool QMediaObject::isMetaDataAvailable() const -{ - Q_D(const QMediaObject); - - return d->metaDataControl - ? d->metaDataControl->isMetaDataAvailable() - : false; -} - -/*! - \fn QMediaObject::metaDataAvailableChanged(bool available) - - Signals that the \a available state of a media object's meta-data has changed. - \since 1.0 -*/ - -/*! - Returns the value associated with a meta-data \a key. - \since 1.0 -*/ -QVariant QMediaObject::metaData(QtMultimediaKit::MetaData key) const -{ - Q_D(const QMediaObject); - - return d->metaDataControl - ? d->metaDataControl->metaData(key) - : QVariant(); -} - -/*! - Returns a list of keys there is meta-data available for. - \since 1.0 -*/ -QList QMediaObject::availableMetaData() const -{ - Q_D(const QMediaObject); - - return d->metaDataControl - ? d->metaDataControl->availableMetaData() - : QList(); -} - -/*! - \fn QMediaObject::metaDataChanged() - - Signals that this media object's meta-data has changed. - \since 1.0 -*/ - -/*! - Returns the value associated with a meta-data \a key. - - The naming and type of extended meta-data is not standardized, so the values and meaning - of keys may vary between backends. - \since 1.0 -*/ -QVariant QMediaObject::extendedMetaData(const QString &key) const -{ - Q_D(const QMediaObject); - - return d->metaDataControl - ? d->metaDataControl->extendedMetaData(key) - : QVariant(); -} - -/*! - Returns a list of keys there is extended meta-data available for. - \since 1.0 -*/ -QStringList QMediaObject::availableExtendedMetaData() const -{ - Q_D(const QMediaObject); - - return d->metaDataControl - ? d->metaDataControl->availableExtendedMetaData() - : QStringList(); -} - - -void QMediaObject::setupMetaData() -{ - Q_D(QMediaObject); - - if (d->service != 0) { - d->metaDataControl = qobject_cast( - d->service->requestControl(QMetaDataReaderControl_iid)); - - if (d->metaDataControl) { - connect(d->metaDataControl, SIGNAL(metaDataChanged()), SIGNAL(metaDataChanged())); - connect(d->metaDataControl, - SIGNAL(metaDataAvailableChanged(bool)), - SIGNAL(metaDataAvailableChanged(bool))); - } - } -} - -/*! - \fn QMediaObject::availabilityChanged(bool available) - - Signal emitted when the availability state has changed to \a available - \since 1.0 -*/ - - -#include "moc_qmediaobject.cpp" -QT_END_NAMESPACE - diff --git a/src/multimediakit/qmediaobject.h b/src/multimediakit/qmediaobject.h deleted file mode 100644 index 0fcf4cdee..000000000 --- a/src/multimediakit/qmediaobject.h +++ /dev/null @@ -1,118 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QABSTRACTMEDIAOBJECT_H -#define QABSTRACTMEDIAOBJECT_H - -#include -#include - -#include -#include "qtmedianamespace.h" - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -QT_MODULE(Multimedia) - - -class QMediaService; -class QMediaBindableInterface; - -class QMediaObjectPrivate; -class Q_MULTIMEDIA_EXPORT QMediaObject : public QObject -{ - Q_OBJECT - Q_PROPERTY(int notifyInterval READ notifyInterval WRITE setNotifyInterval NOTIFY notifyIntervalChanged) -public: - ~QMediaObject(); - - virtual bool isAvailable() const; - virtual QtMultimediaKit::AvailabilityError availabilityError() const; - - virtual QMediaService* service() const; - - int notifyInterval() const; - void setNotifyInterval(int milliSeconds); - - virtual bool bind(QObject *); - virtual void unbind(QObject *); - - bool isMetaDataAvailable() const; - - QVariant metaData(QtMultimediaKit::MetaData key) const; - QList availableMetaData() const; - - QVariant extendedMetaData(const QString &key) const; - QStringList availableExtendedMetaData() const; - -Q_SIGNALS: - void notifyIntervalChanged(int milliSeconds); - - void metaDataAvailableChanged(bool available); - void metaDataChanged(); - - void availabilityChanged(bool available); - -protected: - QMediaObject(QObject *parent, QMediaService *service); - QMediaObject(QMediaObjectPrivate &dd, QObject *parent, QMediaService *service); - - void addPropertyWatch(QByteArray const &name); - void removePropertyWatch(QByteArray const &name); - - QMediaObjectPrivate *d_ptr; - -private: - void setupMetaData(); - - Q_DECLARE_PRIVATE(QMediaObject) - Q_PRIVATE_SLOT(d_func(), void _q_notify()) -}; - - -QT_END_NAMESPACE - -QT_END_HEADER - - -#endif // QABSTRACTMEDIAOBJECT_H diff --git a/src/multimediakit/qmediaobject_p.h b/src/multimediakit/qmediaobject_p.h deleted file mode 100644 index f27420cf0..000000000 --- a/src/multimediakit/qmediaobject_p.h +++ /dev/null @@ -1,99 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QABSTRACTMEDIAOBJECT_P_H -#define QABSTRACTMEDIAOBJECT_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 -#include -#include - -#include "qmediaobject.h" - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -QT_MODULE(Multimedia) - - -class QMetaDataReaderControl; - -#define Q_DECLARE_NON_CONST_PUBLIC(Class) \ - inline Class* q_func() { return static_cast(q_ptr); } \ - friend class Class; - - -class QMediaObjectPrivate -{ - Q_DECLARE_PUBLIC(QMediaObject) - -public: - QMediaObjectPrivate():metaDataControl(0), notifyTimer(0) {} - virtual ~QMediaObjectPrivate() {} - - void _q_notify(); - - QMediaService *service; - QMetaDataReaderControl *metaDataControl; - QTimer* notifyTimer; - QSet notifyProperties; - - QMediaObject *q_ptr; -}; - -QT_END_NAMESPACE - -QT_END_HEADER - - -#endif diff --git a/src/multimediakit/qmediaplayer.cpp b/src/multimediakit/qmediaplayer.cpp deleted file mode 100644 index 4e87e9c42..000000000 --- a/src/multimediakit/qmediaplayer.cpp +++ /dev/null @@ -1,1139 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include -#include -#include -#include -#include - - -#include "qmediaplayer.h" - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -QT_BEGIN_NAMESPACE - -/*! - \class QMediaPlayer - \brief The QMediaPlayer class allows the playing of a media source. - \inmodule QtMultimediaKit - \ingroup multimedia - \since 1.0 - - - - The QMediaPlayer class is a high level media playback class. It can be used - to playback such content as songs, movies and internet radio. The content - to playback is specified as a QMediaContent, which can be thought of as a - main or canonical URL with addition information attached. When provided - with a QMediaContent playback may be able to commence. - - \snippet doc/src/snippets/multimedia-snippets/media.cpp Player - - QVideoWidget can be used with QMediaPlayer for video rendering and QMediaPlaylist - for accessing playlist functionality. - - \snippet doc/src/snippets/multimedia-snippets/media.cpp Movie playlist - - \sa QMediaObject, QMediaService, QVideoWidget, QMediaPlaylist -*/ - -namespace -{ -class MediaPlayerRegisterMetaTypes -{ -public: - MediaPlayerRegisterMetaTypes() - { - qRegisterMetaType("QMediaPlayer::State"); - qRegisterMetaType("QMediaPlayer::MediaStatus"); - qRegisterMetaType("QMediaPlayer::Error"); - } -} _registerPlayerMetaTypes; -} - -class QMediaPlayerPrivate : public QMediaObjectPrivate -{ - Q_DECLARE_NON_CONST_PUBLIC(QMediaPlayer) - -public: - QMediaPlayerPrivate() - : provider(0) - , control(0) - , playlistSourceControl(0) - , state(QMediaPlayer::StoppedState) - , error(QMediaPlayer::NoError) - , filterStates(false) - , playlist(0) - {} - - QMediaServiceProvider *provider; - QMediaPlayerControl* control; - QMediaPlaylistSourceControl* playlistSourceControl; - QMediaPlayer::State state; - QMediaPlayer::Error error; - QString errorString; - bool filterStates; - - QPointer videoOutput; - QMediaPlaylist *playlist; - QMediaNetworkAccessControl *networkAccessControl; - QVideoSurfaceOutput surfaceOutput; - - void _q_stateChanged(QMediaPlayer::State state); - void _q_mediaStatusChanged(QMediaPlayer::MediaStatus status); - void _q_error(int error, const QString &errorString); - void _q_updateMedia(const QMediaContent&); - void _q_playlistDestroyed(); -}; - -void QMediaPlayerPrivate::_q_stateChanged(QMediaPlayer::State ps) -{ - Q_Q(QMediaPlayer); - - if (filterStates) - return; - - if (playlist - && ps != state && ps == QMediaPlayer::StoppedState - && (control->mediaStatus() == QMediaPlayer::EndOfMedia || - control->mediaStatus() == QMediaPlayer::InvalidMedia)) { - playlist->next(); - ps = control->state(); - } - - if (ps != state) { - state = ps; - - if (ps == QMediaPlayer::PlayingState) - q->addPropertyWatch("position"); - else - q->removePropertyWatch("position"); - - emit q->stateChanged(ps); - } -} - -void QMediaPlayerPrivate::_q_mediaStatusChanged(QMediaPlayer::MediaStatus status) -{ - Q_Q(QMediaPlayer); - - switch (status) { - case QMediaPlayer::StalledMedia: - case QMediaPlayer::BufferingMedia: - q->addPropertyWatch("bufferStatus"); - emit q->mediaStatusChanged(status); - break; - default: - q->removePropertyWatch("bufferStatus"); - emit q->mediaStatusChanged(status); - break; - } - -} - -void QMediaPlayerPrivate::_q_error(int error, const QString &errorString) -{ - Q_Q(QMediaPlayer); - - this->error = QMediaPlayer::Error(error); - this->errorString = errorString; - - emit q->error(this->error); -} - -void QMediaPlayerPrivate::_q_updateMedia(const QMediaContent &media) -{ - Q_Q(QMediaPlayer); - - if (!control) - return; - - const QMediaPlayer::State currentState = state; - - filterStates = true; - control->setMedia(media, 0); - - if (!media.isNull()) { - switch (currentState) { - case QMediaPlayer::PlayingState: - control->play(); - break; - case QMediaPlayer::PausedState: - control->pause(); - break; - default: - break; - } - } - filterStates = false; - - state = control->state(); - - if (state != currentState) { - if (state == QMediaPlayer::PlayingState) - q->addPropertyWatch("position"); - else - q->removePropertyWatch("position"); - - emit q->stateChanged(state); - } -} - -void QMediaPlayerPrivate::_q_playlistDestroyed() -{ - playlist = 0; - - if (!control) - return; - - if (playlistSourceControl) - playlistSourceControl->setPlaylist(0); - - control->setMedia(QMediaContent(), 0); -} - -static QMediaService *playerService(QMediaPlayer::Flags flags, QMediaServiceProvider *provider) -{ - if (flags) { - QMediaServiceProviderHint::Features features = 0; - if (flags & QMediaPlayer::LowLatency) - features |= QMediaServiceProviderHint::LowLatencyPlayback; - - if (flags & QMediaPlayer::StreamPlayback) - features |= QMediaServiceProviderHint::StreamPlayback; - - if (flags & QMediaPlayer::VideoSurface) - features |= QMediaServiceProviderHint::VideoSurface; - - return provider->requestService(Q_MEDIASERVICE_MEDIAPLAYER, - QMediaServiceProviderHint(features)); - } else - return provider->requestService(Q_MEDIASERVICE_MEDIAPLAYER); -} - - -/*! - Construct a QMediaPlayer that uses the playback service from \a provider, - parented to \a parent and with \a flags. - - If a playback service is not specified the system default will be used. - \since 1.0 -*/ - -QMediaPlayer::QMediaPlayer(QObject *parent, QMediaPlayer::Flags flags, QMediaServiceProvider *provider): - QMediaObject(*new QMediaPlayerPrivate, - parent, - playerService(flags,provider)) -{ - Q_D(QMediaPlayer); - - d->provider = provider; - - if (d->service == 0) { - d->error = ServiceMissingError; - } else { - d->control = qobject_cast(d->service->requestControl(QMediaPlayerControl_iid)); - d->playlistSourceControl = qobject_cast(d->service->requestControl(QMediaPlaylistSourceControl_iid)); - d->networkAccessControl = qobject_cast(d->service->requestControl(QMediaNetworkAccessControl_iid)); - if (d->control != 0) { - connect(d->control, SIGNAL(mediaChanged(QMediaContent)), SIGNAL(mediaChanged(QMediaContent))); - connect(d->control, SIGNAL(stateChanged(QMediaPlayer::State)), SLOT(_q_stateChanged(QMediaPlayer::State))); - connect(d->control, SIGNAL(mediaStatusChanged(QMediaPlayer::MediaStatus)), - SLOT(_q_mediaStatusChanged(QMediaPlayer::MediaStatus))); - connect(d->control, SIGNAL(error(int,QString)), SLOT(_q_error(int,QString))); - - connect(d->control, SIGNAL(durationChanged(qint64)), SIGNAL(durationChanged(qint64))); - connect(d->control, SIGNAL(positionChanged(qint64)), SIGNAL(positionChanged(qint64))); - connect(d->control, SIGNAL(audioAvailableChanged(bool)), SIGNAL(audioAvailableChanged(bool))); - connect(d->control, SIGNAL(videoAvailableChanged(bool)), SIGNAL(videoAvailableChanged(bool))); - connect(d->control, SIGNAL(volumeChanged(int)), SIGNAL(volumeChanged(int))); - connect(d->control, SIGNAL(mutedChanged(bool)), SIGNAL(mutedChanged(bool))); - connect(d->control, SIGNAL(seekableChanged(bool)), SIGNAL(seekableChanged(bool))); - connect(d->control, SIGNAL(playbackRateChanged(qreal)), SIGNAL(playbackRateChanged(qreal))); - connect(d->control, SIGNAL(bufferStatusChanged(int)), SIGNAL(bufferStatusChanged(int))); - - if (d->control->state() == PlayingState) - addPropertyWatch("position"); - - if (d->control->mediaStatus() == StalledMedia || d->control->mediaStatus() == BufferingMedia) - addPropertyWatch("bufferStatus"); - } - if (d->networkAccessControl != 0) { - connect(d->networkAccessControl, SIGNAL(configurationChanged(QNetworkConfiguration)), - this, SIGNAL(networkConfigurationChanged(QNetworkConfiguration))); - } - } -} - - -/*! - Destroys the player object. -*/ - -QMediaPlayer::~QMediaPlayer() -{ - Q_D(QMediaPlayer); - - if (d->service) { - if (d->control) - d->service->releaseControl(d->control); - } - - d->provider->releaseService(d->service); -} - -QMediaContent QMediaPlayer::media() const -{ - Q_D(const QMediaPlayer); - - if (d->control != 0) - return d->control->media(); - - return QMediaContent(); -} - -/*! - Returns the stream source of media data. - - This is only valid if a stream was passed to setMedia(). - - \since 1.0 - \sa setMedia() -*/ - -const QIODevice *QMediaPlayer::mediaStream() const -{ - Q_D(const QMediaPlayer); - - if (d->control != 0) - return d->control->mediaStream(); - - return 0; -} - -QMediaPlaylist *QMediaPlayer::playlist() const -{ - return d_func()->playlistSourceControl ? - d_func()->playlistSourceControl->playlist() : - d_func()->playlist; -} - -void QMediaPlayer::setPlaylist(QMediaPlaylist *playlist) -{ - Q_D(QMediaPlayer); - - if (d->playlistSourceControl) { - if (d->playlistSourceControl->playlist()) - disconnect(d->playlist, SIGNAL(destroyed()), this, SLOT(_q_playlistDestroyed())); - - d->playlistSourceControl->setPlaylist(playlist); - - if (playlist) - connect(d->playlist, SIGNAL(destroyed()), this, SLOT(_q_playlistDestroyed())); - } else { - if (d->playlist) { - disconnect(d->playlist, SIGNAL(currentMediaChanged(QMediaContent)), - this, SLOT(_q_updateMedia(QMediaContent))); - disconnect(d->playlist, SIGNAL(destroyed()), this, SLOT(_q_playlistDestroyed())); - } - - d->playlist = playlist; - - if (d->playlist) { - connect(d->playlist, SIGNAL(currentMediaChanged(QMediaContent)), - this, SLOT(_q_updateMedia(QMediaContent))); - connect(d->playlist, SIGNAL(destroyed()), this, SLOT(_q_playlistDestroyed())); - - if (d->control != 0) - d->control->setMedia(playlist->currentMedia(), 0); - } else { - setMedia(QMediaContent(), 0); - } - - } -} - -/*! - Sets the network access points for remote media playback. - \a configurations contains, in ascending preferential order, a list of - configuration that can be used for network access. - - This will invalidate the choice of previous configurations. - \since 1.2 -*/ -void QMediaPlayer::setNetworkConfigurations(const QList &configurations) -{ - Q_D(QMediaPlayer); - - if (d->networkAccessControl) - d->networkAccessControl->setConfigurations(configurations); -} - -QMediaPlayer::State QMediaPlayer::state() const -{ - return d_func()->state; -} - -QMediaPlayer::MediaStatus QMediaPlayer::mediaStatus() const -{ - Q_D(const QMediaPlayer); - - if (d->control != 0) - return d->control->mediaStatus(); - - return QMediaPlayer::UnknownMediaStatus; -} - -qint64 QMediaPlayer::duration() const -{ - Q_D(const QMediaPlayer); - - if (d->control != 0) - return d->control->duration(); - - return -1; -} - -qint64 QMediaPlayer::position() const -{ - Q_D(const QMediaPlayer); - - if (d->control != 0) - return d->control->position(); - - return 0; -} - -int QMediaPlayer::volume() const -{ - Q_D(const QMediaPlayer); - - if (d->control != 0) - return d->control->volume(); - - return 0; -} - -bool QMediaPlayer::isMuted() const -{ - Q_D(const QMediaPlayer); - - if (d->control != 0) - return d->control->isMuted(); - - return false; -} - -int QMediaPlayer::bufferStatus() const -{ - Q_D(const QMediaPlayer); - - if (d->control != 0) - return d->control->bufferStatus(); - - return 0; -} - -bool QMediaPlayer::isAudioAvailable() const -{ - Q_D(const QMediaPlayer); - - if (d->control != 0) - return d->control->isAudioAvailable(); - - return false; -} - -bool QMediaPlayer::isVideoAvailable() const -{ - Q_D(const QMediaPlayer); - - if (d->control != 0) - return d->control->isVideoAvailable(); - - return false; -} - -bool QMediaPlayer::isSeekable() const -{ - Q_D(const QMediaPlayer); - - if (d->control != 0) - return d->control->isSeekable(); - - return false; -} - -qreal QMediaPlayer::playbackRate() const -{ - Q_D(const QMediaPlayer); - - if (d->control != 0) - return d->control->playbackRate(); - - return 0.0; -} - -/*! - Returns the current error state. - \since 1.0 -*/ - -QMediaPlayer::Error QMediaPlayer::error() const -{ - return d_func()->error; -} - -QString QMediaPlayer::errorString() const -{ - return d_func()->errorString; -} - -/*! - Returns the current network access point in use. - If a default contructed QNetworkConfiguration is returned - this feature is not available or that none of the - current supplied configurations are in use. - \since 1.2 -*/ -QNetworkConfiguration QMediaPlayer::currentNetworkConfiguration() const -{ - Q_D(const QMediaPlayer); - - if (d->networkAccessControl) - return d_func()->networkAccessControl->currentConfiguration(); - - return QNetworkConfiguration(); -} - -//public Q_SLOTS: -/*! - Start or resume playing the current source. - \since 1.0 -*/ - -void QMediaPlayer::play() -{ - Q_D(QMediaPlayer); - - if (d->control == 0) { - QMetaObject::invokeMethod(this, "_q_error", Qt::QueuedConnection, - Q_ARG(int, QMediaPlayer::ServiceMissingError), - Q_ARG(QString, tr("The QMediaPlayer object does not have a valid service"))); - return; - } - - //if playlist control is available, the service should advance itself - if (d->playlist && d->playlist->currentIndex() == -1 && !d->playlist->isEmpty()) - d->playlist->setCurrentIndex(0); - - // Reset error conditions - d->error = NoError; - d->errorString = QString(); - - d->control->play(); -} - -/*! - Pause playing the current source. - \since 1.0 -*/ - -void QMediaPlayer::pause() -{ - Q_D(QMediaPlayer); - - if (d->control != 0) - d->control->pause(); -} - -/*! - Stop playing, and reset the play position to the beginning. - \since 1.0 -*/ - -void QMediaPlayer::stop() -{ - Q_D(QMediaPlayer); - - if (d->control != 0) - d->control->stop(); -} - -void QMediaPlayer::setPosition(qint64 position) -{ - Q_D(QMediaPlayer); - - if (d->control == 0 || !isSeekable()) - return; - - d->control->setPosition(qBound(qint64(0), position, duration())); -} - -void QMediaPlayer::setVolume(int v) -{ - Q_D(QMediaPlayer); - - if (d->control == 0) - return; - - int clamped = qBound(0, v, 100); - if (clamped == volume()) - return; - - d->control->setVolume(clamped); -} - -void QMediaPlayer::setMuted(bool muted) -{ - Q_D(QMediaPlayer); - - if (d->control == 0 || muted == isMuted()) - return; - - d->control->setMuted(muted); -} - -void QMediaPlayer::setPlaybackRate(qreal rate) -{ - Q_D(QMediaPlayer); - - if (d->control != 0) - d->control->setPlaybackRate(rate); -} - -/*! - Sets the current \a media source. - - If a \a stream is supplied; media data will be read from it instead of resolving the media - source. In this case the media source may still be used to resolve additional information - about the media such as mime type. - - Setting the media to a null QMediaContent will cause the player to discard all - information relating to the current media source and to cease all I/O operations related - to that media. - \since 1.0 -*/ - -void QMediaPlayer::setMedia(const QMediaContent &media, QIODevice *stream) -{ - Q_D(QMediaPlayer); - - if (playlist() && playlist()->currentMedia() != media) - setPlaylist(0); - - if (d->control != 0) - d_func()->control->setMedia(media, stream); -} - -/*! - \internal - \since 1.0 -*/ - -bool QMediaPlayer::bind(QObject *obj) -{ - return QMediaObject::bind(obj); -} - -/*! - \internal - \since 1.0 -*/ - -void QMediaPlayer::unbind(QObject *obj) -{ - QMediaObject::unbind(obj); -} - -/*! - Returns the level of support a media player has for a \a mimeType and a set of \a codecs. - - The \a flags argument allows additional requirements such as performance indicators to be - specified. - \since 1.0 -*/ -QtMultimediaKit::SupportEstimate QMediaPlayer::hasSupport(const QString &mimeType, - const QStringList& codecs, - Flags flags) -{ - return QMediaServiceProvider::defaultServiceProvider()->hasSupport(QByteArray(Q_MEDIASERVICE_MEDIAPLAYER), - mimeType, - codecs, - flags); -} - -/*! - \deprecated - Returns a list of MIME types supported by the media player. - - The \a flags argument causes the resultant list to be restricted to MIME types which can be supported - given additional requirements, such as performance indicators. - - This function may not return useful results on some platforms, and support for a specific file of a - given mime type is not guaranteed even if the mime type is in general supported. In addition, in some - cases this function will need to load all available media plugins and query them for their support, which - may take some time. - \since 1.0 -*/ -QStringList QMediaPlayer::supportedMimeTypes(Flags flags) -{ - return QMediaServiceProvider::defaultServiceProvider()->supportedMimeTypes(QByteArray(Q_MEDIASERVICE_MEDIAPLAYER), - flags); -} - -/*! - \fn void QMediaPlayer::setVideoOutput(QVideoWidget* output) - - Attach a QVideoWidget video \a output to the media player. - - If the media player has already video output attached, - it will be replaced with a new one. - \since 1.0 -*/ -void QMediaPlayer::setVideoOutput(QVideoWidget *output) -{ - Q_D(QMediaPlayer); - - if (d->videoOutput) - unbind(d->videoOutput); - - // We don't know (in this library) that QVideoWidget inherits QObject - QObject *outputObject = reinterpret_cast(output); - - d->videoOutput = outputObject && bind(outputObject) ? outputObject : 0; -} - -/*! - \fn void QMediaPlayer::setVideoOutput(QGraphicsVideoItem* output) - - Attach a QGraphicsVideoItem video \a output to the media player. - - If the media player has already video output attached, - it will be replaced with a new one. - \since 1.0 -*/ -void QMediaPlayer::setVideoOutput(QGraphicsVideoItem *output) -{ - Q_D(QMediaPlayer); - - if (d->videoOutput) - unbind(d->videoOutput); - - // We don't know (in this library) that QGraphicsVideoItem (multiply) inherits QObject - // but QObject inheritance depends on QObject coming first, so try this out. - QObject *outputObject = reinterpret_cast(output); - - d->videoOutput = outputObject && bind(outputObject) ? outputObject : 0; -} - -/*! - Sets a video \a surface as the video output of a media player. - - If a video output has already been set on the media player the new surface - will replace it. - \since 1.2 -*/ - -void QMediaPlayer::setVideoOutput(QAbstractVideoSurface *surface) -{ - Q_D(QMediaPlayer); - - d->surfaceOutput.setVideoSurface(surface); - - if (d->videoOutput != &d->surfaceOutput) { - if (d->videoOutput) - unbind(d->videoOutput); - - d->videoOutput = bind(&d->surfaceOutput) ? &d->surfaceOutput : 0; - } -} - -// Enums -/*! - \enum QMediaPlayer::State - - Defines the current state of a media player. - - \value PlayingState The media player is currently playing content. - \value PausedState The media player has paused playback, playback of the current track will - resume from the position the player was paused at. - \value StoppedState The media player is not playing content, playback will begin from the start - of the current track. -*/ - -/*! - \enum QMediaPlayer::MediaStatus - - Defines the status of a media player's current media. - - \value UnknownMediaStatus The status of the media cannot be determined. - \value NoMedia The is no current media. The player is in the StoppedState. - \value LoadingMedia The current media is being loaded. The player may be in any state. - \value LoadedMedia The current media has been loaded. The player is in the StoppedState. - \value StalledMedia Playback of the current media has stalled due to insufficient buffering or - some other temporary interruption. The player is in the PlayingState or PausedState. - \value BufferingMedia The player is buffering data but has enough data buffered for playback to - continue for the immediate future. The player is in the PlayingState or PausedState. - \value BufferedMedia The player has fully buffered the current media. The player is in the - PlayingState or PausedState. - \value EndOfMedia Playback has reached the end of the current media. The player is in the - StoppedState. - \value InvalidMedia The current media cannot be played. The player is in the StoppedState. -*/ - -/*! - \enum QMediaPlayer::Error - - Defines a media player error condition. - - \value NoError No error has occurred. - \value ResourceError A media resource couldn't be resolved. - \value FormatError The format of a media resource isn't (fully) supported. Playback may still - be possible, but without an audio or video component. - \value NetworkError A network error occurred. - \value AccessDeniedError There are not the appropriate permissions to play a media resource. - \value ServiceMissingError A valid playback service was not found, playback cannot proceed. -*/ - -// Signals -/*! - \fn QMediaPlayer::error(QMediaPlayer::Error error) - - Signals that an \a error condition has occurred. - - \since 1.0 - \sa errorString() -*/ - -/*! - \fn void QMediaPlayer::stateChanged(State state) - - \since 1.0 - Signal the \a state of the Player object has changed. -*/ - -/*! - \fn QMediaPlayer::mediaStatusChanged(QMediaPlayer::MediaStatus status) - - Signals that the \a status of the current media has changed. - - \since 1.0 - \sa mediaStatus() -*/ - -/*! - \fn void QMediaPlayer::mediaChanged(const QMediaContent &media); - - Signals that the current playing content will be obtained from \a media. - - \since 1.0 - \sa media() -*/ - -/*! - \fn void QMediaPlayer::playbackRateChanged(qreal rate); - - Signals the playbackRate has changed to \a rate. - \since 1.0 -*/ - -/*! - \fn void QMediaPlayer::seekableChanged(bool seekable); - - Signals the \a seekable status of the player object has changed. - \since 1.0 -*/ - -// Properties -/*! - \property QMediaPlayer::state - \brief the media player's playback state. - - By default this property is QMediaPlayer::Stopped - - \since 1.0 - \sa mediaStatus(), play(), pause(), stop() -*/ - -/*! - \property QMediaPlayer::error - \brief a string describing the last error condition. - - \since 1.0 - \sa error() -*/ - -/*! - \property QMediaPlayer::media - \brief the active media source being used by the player object. - - The player object will use the QMediaContent for selection of the content to - be played. - - By default this property has a null QMediaContent. - - Setting this property to a null QMediaContent will cause the player to discard all - information relating to the current media source and to cease all I/O operations related - to that media. - - \since 1.0 - \sa QMediaContent -*/ - -/*! - \property QMediaPlayer::playlist - \brief the media playlist being used by the player object. - - The player object will use the current playlist item for selection of the content to - be played. - - By default this property is set to null. - - If the media playlist is used as a source, QMediaPlayer::media is updated with - a current playlist item. The current source should be selected with - QMediaPlaylist::setCurrentIndex(int) instead of QMediaPlayer::setMedia(), - otherwise the current playlist will be discarded. - - \since 1.0 - \sa QMediaContent -*/ - - -/*! - \property QMediaPlayer::mediaStatus - \brief the status of the current media stream. - - The stream status describes how the playback of the current stream is - progressing. - - By default this property is QMediaPlayer::NoMedia - - \since 1.0 - \sa state -*/ - -/*! - \property QMediaPlayer::duration - \brief the duration of the current media. - - The value is the total playback time in milliseconds of the current media. - The value may change across the life time of the QMediaPlayer object and - may not be available when initial playback begins, connect to the - durationChanged() signal to receive status notifications. - \since 1.0 -*/ - -/*! - \property QMediaPlayer::position - \brief the playback position of the current media. - - The value is the current playback position, expressed in milliseconds since - the beginning of the media. Periodically changes in the position will be - indicated with the signal positionChanged(), the interval between updates - can be set with QMediaObject's method setNotifyInterval(). - \since 1.0 -*/ - -/*! - \property QMediaPlayer::volume - \brief the current playback volume. - - The playback volume is a linear in effect and the value can range from 0 - - 100, values outside this range will be clamped. - \since 1.0 -*/ - -/*! - \property QMediaPlayer::muted - \brief the muted state of the current media. - - The value will be true if the playback volume is muted; otherwise false. - \since 1.0 -*/ - -/*! - \property QMediaPlayer::bufferStatus - \brief the percentage of the temporary buffer filled before playback begins. - - When the player object is buffering; this property holds the percentage of - the temporary buffer that is filled. The buffer will need to reach 100% - filled before playback can resume, at which time the MediaStatus will be - BufferedMedia. - - \since 1.0 - \sa mediaStatus() -*/ - -/*! - \property QMediaPlayer::audioAvailable - \brief the audio availabilty status for the current media. - - As the life time of QMediaPlayer can be longer than the playback of one - QMediaContent, this property may change over time, the - audioAvailableChanged signal can be used to monitor it's status. - \since 1.0 -*/ - -/*! - \property QMediaPlayer::videoAvailable - \brief the video availability status for the current media. - - If available, the QVideoWidget class can be used to view the video. As the - life time of QMediaPlayer can be longer than the playback of one - QMediaContent, this property may change over time, the - videoAvailableChanged signal can be used to monitor it's status. - - \since 1.0 - \sa QVideoWidget, QMediaContent -*/ - -/*! - \property QMediaPlayer::seekable - \brief the seek-able status of the current media - - If seeking is supported this property will be true; false otherwise. The - status of this property may change across the life time of the QMediaPlayer - object, use the seekableChanged signal to monitor changes. - \since 1.0 -*/ - -/*! - \property QMediaPlayer::playbackRate - \brief the playback rate of the current media. - - This value is a multiplier applied to the media's standard play rate. By - default this value is 1.0, indicating that the media is playing at the - standard pace. Values higher than 1.0 will increase the rate of play. - Values less than zero can be set and indicate the media will rewind at the - multiplier of the standard pace. - - Not all playback services support change of the playback rate. It is - framework defined as to the status and quality of audio and video - while fast forwarding or rewinding. - \since 1.0 -*/ - -/*! - \fn void QMediaPlayer::durationChanged(qint64 duration) - - Signal the duration of the content has changed to \a duration, expressed in milliseconds. - \since 1.0 -*/ - -/*! - \fn void QMediaPlayer::positionChanged(qint64 position) - - Signal the position of the content has changed to \a position, expressed in - milliseconds. - \since 1.0 -*/ - -/*! - \fn void QMediaPlayer::volumeChanged(int volume) - - Signal the playback volume has changed to \a volume. - \since 1.0 -*/ - -/*! - \fn void QMediaPlayer::mutedChanged(bool muted) - - Signal the mute state has changed to \a muted. - \since 1.0 -*/ - -/*! - \fn void QMediaPlayer::videoAvailableChanged(bool videoAvailable) - - Signal the availability of visual content has changed to \a videoAvailable. - \since 1.0 -*/ - -/*! - \fn void QMediaPlayer::audioAvailableChanged(bool available) - - Signals the availability of audio content has changed to \a available. - \since 1.0 -*/ - -/*! - \fn void QMediaPlayer::bufferStatusChanged(int percentFilled) - - Signal the amount of the local buffer filled as a percentage by \a percentFilled. - \since 1.0 -*/ - -/*! - \fn void QMediaPlayer::networkConfigurationChanged(const QNetworkConfiguration &configuration) - - Signal that the active in use network access point has been changed to \a configuration and all subsequent network access will use this \a configuration. - \since 1.2 -*/ - -/*! - \enum QMediaPlayer::Flag - - \value LowLatency The player is expected to be used with simple audio formats, - but playback should start without significant delay. - Such playback service can be used for beeps, ringtones, etc. - - \value StreamPlayback The player is expected to play QIODevice based streams. - If passed to QMediaPlayer constructor, the service supporting - streams playback will be chosen. - - \value VideoSurface The player is expected to be able to render to a - QAbstractVideoSurface \l {setVideoOutput()}{output}. -*/ - -#include "moc_qmediaplayer.cpp" -QT_END_NAMESPACE - diff --git a/src/multimediakit/qmediaplayer.h b/src/multimediakit/qmediaplayer.h deleted file mode 100644 index 6bd318483..000000000 --- a/src/multimediakit/qmediaplayer.h +++ /dev/null @@ -1,227 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QMEDIAPLAYER_H -#define QMEDIAPLAYER_H - - -#include "qmediaserviceprovider.h" -#include "qmediaobject.h" -#include "qmediacontent.h" -#include "qmediaenumdebug.h" - -#include - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -QT_MODULE(Multimedia) - - -class QAbstractVideoSurface; -class QMediaPlaylist; -class QVideoWidget; -class QGraphicsVideoItem; - -class QMediaPlayerPrivate; -class Q_MULTIMEDIA_EXPORT QMediaPlayer : public QMediaObject -{ - Q_OBJECT - Q_PROPERTY(QMediaContent media READ media WRITE setMedia NOTIFY mediaChanged) - Q_PROPERTY(QMediaPlaylist * playlist READ playlist WRITE setPlaylist) - Q_PROPERTY(qint64 duration READ duration NOTIFY durationChanged) - Q_PROPERTY(qint64 position READ position WRITE setPosition NOTIFY positionChanged) - Q_PROPERTY(int volume READ volume WRITE setVolume NOTIFY volumeChanged) - Q_PROPERTY(bool muted READ isMuted WRITE setMuted NOTIFY mutedChanged) - Q_PROPERTY(int bufferStatus READ bufferStatus NOTIFY bufferStatusChanged) - Q_PROPERTY(bool audioAvailable READ isAudioAvailable NOTIFY audioAvailableChanged) - Q_PROPERTY(bool videoAvailable READ isVideoAvailable NOTIFY videoAvailableChanged) - Q_PROPERTY(bool seekable READ isSeekable NOTIFY seekableChanged) - Q_PROPERTY(qreal playbackRate READ playbackRate WRITE setPlaybackRate NOTIFY playbackRateChanged) - Q_PROPERTY(State state READ state NOTIFY stateChanged) - Q_PROPERTY(MediaStatus mediaStatus READ mediaStatus NOTIFY mediaStatusChanged) - Q_PROPERTY(QString error READ errorString) - Q_ENUMS(State) - Q_ENUMS(MediaStatus) - Q_ENUMS(Error) - -public: - enum State - { - StoppedState, - PlayingState, - PausedState - }; - - enum MediaStatus - { - UnknownMediaStatus, - NoMedia, - LoadingMedia, - LoadedMedia, - StalledMedia, - BufferingMedia, - BufferedMedia, - EndOfMedia, - InvalidMedia - }; - - enum Flag - { - LowLatency = 0x01, - StreamPlayback = 0x02, - VideoSurface = 0x04 - }; - Q_DECLARE_FLAGS(Flags, Flag) - - enum Error - { - NoError, - ResourceError, - FormatError, - NetworkError, - AccessDeniedError, - ServiceMissingError - }; - - QMediaPlayer(QObject *parent = 0, Flags flags = 0, QMediaServiceProvider *provider = QMediaServiceProvider::defaultServiceProvider()); - ~QMediaPlayer(); - - static QtMultimediaKit::SupportEstimate hasSupport(const QString &mimeType, - const QStringList& codecs = QStringList(), - Flags flags = 0); - static QStringList supportedMimeTypes(Flags flags = 0); - - void setVideoOutput(QVideoWidget *); - void setVideoOutput(QGraphicsVideoItem *); - void setVideoOutput(QAbstractVideoSurface *surface); - - QMediaContent media() const; - const QIODevice *mediaStream() const; - QMediaPlaylist *playlist() const; - - State state() const; - MediaStatus mediaStatus() const; - - qint64 duration() const; - qint64 position() const; - - int volume() const; - bool isMuted() const; - bool isAudioAvailable() const; - bool isVideoAvailable() const; - - int bufferStatus() const; - - bool isSeekable() const; - qreal playbackRate() const; - - Error error() const; - QString errorString() const; - - QNetworkConfiguration currentNetworkConfiguration() const; - -public Q_SLOTS: - void play(); - void pause(); - void stop(); - - void setPosition(qint64 position); - void setVolume(int volume); - void setMuted(bool muted); - - void setPlaybackRate(qreal rate); - - void setMedia(const QMediaContent &media, QIODevice *stream = 0); - void setPlaylist(QMediaPlaylist *playlist); - - void setNetworkConfigurations(const QList &configurations); - -Q_SIGNALS: - void mediaChanged(const QMediaContent &media); - - void stateChanged(QMediaPlayer::State newState); - void mediaStatusChanged(QMediaPlayer::MediaStatus status); - - void durationChanged(qint64 duration); - void positionChanged(qint64 position); - - void volumeChanged(int volume); - void mutedChanged(bool muted); - void audioAvailableChanged(bool available); - void videoAvailableChanged(bool videoAvailable); - - void bufferStatusChanged(int percentFilled); - - void seekableChanged(bool seekable); - void playbackRateChanged(qreal rate); - - void error(QMediaPlayer::Error error); - - void networkConfigurationChanged(const QNetworkConfiguration &configuration); -public: - virtual bool bind(QObject *); - virtual void unbind(QObject *); - -private: - Q_DISABLE_COPY(QMediaPlayer) - Q_DECLARE_PRIVATE(QMediaPlayer) - Q_PRIVATE_SLOT(d_func(), void _q_stateChanged(QMediaPlayer::State)) - Q_PRIVATE_SLOT(d_func(), void _q_mediaStatusChanged(QMediaPlayer::MediaStatus)) - Q_PRIVATE_SLOT(d_func(), void _q_error(int, const QString &)) - Q_PRIVATE_SLOT(d_func(), void _q_updateMedia(const QMediaContent&)) - Q_PRIVATE_SLOT(d_func(), void _q_playlistDestroyed()) -}; - -QT_END_NAMESPACE - -Q_DECLARE_METATYPE(QMediaPlayer::State) -Q_DECLARE_METATYPE(QMediaPlayer::MediaStatus) -Q_DECLARE_METATYPE(QMediaPlayer::Error) - -Q_MEDIA_ENUM_DEBUG(QMediaPlayer, State) -Q_MEDIA_ENUM_DEBUG(QMediaPlayer, MediaStatus) -Q_MEDIA_ENUM_DEBUG(QMediaPlayer, Error) - -QT_END_HEADER - -#endif // QMEDIAPLAYER_H diff --git a/src/multimediakit/qmediaplayercontrol.cpp b/src/multimediakit/qmediaplayercontrol.cpp deleted file mode 100644 index 4062306a2..000000000 --- a/src/multimediakit/qmediaplayercontrol.cpp +++ /dev/null @@ -1,414 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qmediaplayercontrol.h" -#include "qmediacontrol_p.h" -#include "qmediaplayer.h" - -QT_BEGIN_NAMESPACE - - -/*! - \class QMediaPlayerControl - \inmodule QtMultimediaKit - \ingroup multimedia-serv - \since 1.0 - - - \brief The QMediaPlayerControl class provides access to the media playing - functionality of a QMediaService. - - If a QMediaService can play media is will implement QMediaPlayerControl. - This control provides a means to set the \l {setMedia()}{media} to play, - \l {play()}{start}, \l {pause()} {pause} and \l {stop()}{stop} playback, - \l {setPosition()}{seek}, and control the \l {setVolume()}{volume}. - It also provides feedback on the \l {duration()}{duration} of the media, - the current \l {position()}{position}, and \l {bufferStatus()}{buffering} - progress. - - The functionality provided by this control is exposed to application - code through the QMediaPlayer class. - - The interface name of QMediaPlayerControl is \c com.nokia.Qt.QMediaPlayerControl/1.0 as - defined in QMediaPlayerControl_iid. - - \sa QMediaService::requestControl(), QMediaPlayer -*/ - -/*! - \macro QMediaPlayerControl_iid - - \c com.nokia.Qt.QMediaPlayerControl/1.0 - - Defines the interface name of the QMediaPlayerControl class. - - \relates QMediaPlayerControl -*/ - -/*! - Destroys a media player control. -*/ -QMediaPlayerControl::~QMediaPlayerControl() -{ -} - -/*! - Constructs a new media player control with the given \a parent. -*/ -QMediaPlayerControl::QMediaPlayerControl(QObject *parent): - QMediaControl(*new QMediaControlPrivate, parent) -{ -} - -/*! - \fn QMediaPlayerControl::state() const - - Returns the state of a player control. - \since 1.0 -*/ - -/*! - \fn QMediaPlayerControl::stateChanged(QMediaPlayer::State state) - - Signals that the \a state of a player control has changed. - - \since 1.0 - \sa state() -*/ - -/*! - \fn QMediaPlayerControl::mediaStatus() const - - Returns the status of the current media. - \since 1.0 -*/ - -/*! - \fn QMediaPlayerControl::mediaStatusChanged(QMediaPlayer::MediaStatus status) - - Signals that the \a status of the current media has changed. - - \since 1.0 - \sa mediaStatus() -*/ - - -/*! - \fn QMediaPlayerControl::duration() const - - Returns the duration of the current media in milliseconds. - \since 1.0 -*/ - -/*! - \fn QMediaPlayerControl::durationChanged(qint64 duration) - - Signals that the \a duration of the current media has changed. - - \since 1.0 - \sa duration() -*/ - -/*! - \fn QMediaPlayerControl::position() const - - Returns the current playback position in milliseconds. - \since 1.0 -*/ - -/*! - \fn QMediaPlayerControl::setPosition(qint64 position) - - Sets the playback \a position of the current media. This will initiate a seek and it may take - some time for playback to reach the position set. - \since 1.0 -*/ - -/*! - \fn QMediaPlayerControl::positionChanged(qint64 position) - - Signals the playback \a position has changed. - - This is only emitted in when there has been a discontinous change in the playback postion, such - as a seek or the position being reset. - - \since 1.0 - \sa position() -*/ - -/*! - \fn QMediaPlayerControl::volume() const - - Returns the audio volume of a player control. - \since 1.0 -*/ - -/*! - \fn QMediaPlayerControl::setVolume(int volume) - - Sets the audio \a volume of a player control. - \since 1.0 -*/ - -/*! - \fn QMediaPlayerControl::volumeChanged(int volume) - - Signals the audio \a volume of a player control has changed. - - \since 1.0 - \sa volume() -*/ - -/*! - \fn QMediaPlayerControl::isMuted() const - - Returns the mute state of a player control. - \since 1.0 -*/ - -/*! - \fn QMediaPlayerControl::setMuted(bool mute) - - Sets the \a mute state of a player control. - \since 1.0 -*/ - -/*! - \fn QMediaPlayerControl::mutedChanged(bool mute) - - Signals a change in the \a mute status of a player control. - - \since 1.0 - \sa isMuted() -*/ - -/*! - \fn QMediaPlayerControl::bufferStatus() const - - Returns the buffering progress of the current media. Progress is measured in the percentage - of the buffer filled. - \since 1.0 -*/ - -/*! - \fn QMediaPlayerControl::bufferStatusChanged(int progress) - - Signals that buffering \a progress has changed. - - \since 1.0 - \sa bufferStatus() -*/ - -/*! - \fn QMediaPlayerControl::isAudioAvailable() const - - Identifies if there is audio output available for the current media. - - Returns true if audio output is available and false otherwise. - \since 1.0 -*/ - -/*! - \fn QMediaPlayerControl::audioAvailableChanged(bool audio) - - Signals that there has been a change in the availability of \a audio output. - - \since 1.0 - \sa isAudioAvailable() -*/ - -/*! - \fn QMediaPlayerControl::isVideoAvailable() const - - Identifies if there is video output available for the current media. - - Returns true if video output is available and false otherwise. - \since 1.0 -*/ - -/*! - \fn QMediaPlayerControl::videoAvailableChanged(bool video) - - Signals that there has been a change in the availability of \a video output. - - \since 1.0 - \sa isVideoAvailable() -*/ - -/*! - \fn QMediaPlayerControl::isSeekable() const - - Identifies if the current media is seekable. - - Returns true if it possible to seek within the current media, and false otherwise. - \since 1.0 -*/ - -/*! - \fn QMediaPlayerControl::seekableChanged(bool seekable) - - Signals that the \a seekable state of a player control has changed. - - \since 1.0 - \sa isSeekable() -*/ - -/*! - \fn QMediaPlayerControl::availablePlaybackRanges() const - - Returns a range of times in milliseconds that can be played back. - - Usually for local files this is a continuous interval equal to [0..duration()] - or an empty time range if seeking is not supported, but for network sources - it refers to the buffered parts of the media. - \since 1.0 -*/ - -/*! - \fn QMediaPlayerControl::availablePlaybackRangesChanged(const QMediaTimeRange &ranges) - - Signals that the available media playback \a ranges have changed. - - \since 1.0 - \sa QMediaPlayerControl::availablePlaybackRanges() -*/ - -/*! - \fn qreal QMediaPlayerControl::playbackRate() const - - Returns the rate of playback. - \since 1.0 -*/ - -/*! - \fn QMediaPlayerControl::setPlaybackRate(qreal rate) - - Sets the \a rate of playback. - \since 1.0 -*/ - -/*! - \fn QMediaPlayerControl::media() const - - Returns the current media source. - \since 1.0 -*/ - -/*! - \fn QMediaPlayerControl::mediaStream() const - - Returns the current media stream. This is only a valid if a stream was passed to setMedia(). - - \since 1.0 - \sa setMedia() -*/ - -/*! - \fn QMediaPlayerControl::setMedia(const QMediaContent &media, QIODevice *stream) - - Sets the current \a media source. If a \a stream is supplied; data will be read from that - instead of attempting to resolve the media source. The media source may still be used to - supply media information such as mime type. - - Setting the media to a null QMediaContent will cause the control to discard all - information relating to the current media source and to cease all I/O operations related - to that media. - \since 1.0 -*/ - -/*! - \fn QMediaPlayerControl::mediaChanged(const QMediaContent& content) - - Signals that the current media \a content has changed. - \since 1.0 -*/ - -/*! - \fn QMediaPlayerControl::play() - - Starts playback of the current media. - - If successful the player control will immediately enter the \l {QMediaPlayer::PlayingState} - {playing} state. - - \since 1.0 - \sa state() -*/ - -/*! - \fn QMediaPlayerControl::pause() - - Pauses playback of the current media. - - If sucessful the player control will immediately enter the \l {QMediaPlayer::PausedState} - {paused} state. - - \since 1.0 - \sa state(), play(), stop() -*/ - -/*! - \fn QMediaPlayerControl::stop() - - Stops playback of the current media. - - If successful the player control will immediately enter the \l {QMediaPlayer::StoppedState} - {stopped} state. - \since 1.0 -*/ - -/*! - \fn QMediaPlayerControl::error(int error, const QString &errorString) - - Signals that an \a error has occurred. The \a errorString provides a more detailed explanation. - \since 1.0 -*/ - -/*! - \fn QMediaPlayerControl::playbackRateChanged(qreal rate) - - Signal emitted when playback rate changes to \a rate. - \since 1.0 -*/ - -#include "moc_qmediaplayercontrol.cpp" -QT_END_NAMESPACE - diff --git a/src/multimediakit/qmediaplayercontrol.h b/src/multimediakit/qmediaplayercontrol.h deleted file mode 100644 index a6e02ee9a..000000000 --- a/src/multimediakit/qmediaplayercontrol.h +++ /dev/null @@ -1,131 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QMEDIAPLAYERCONTROL_H -#define QMEDIAPLAYERCONTROL_H - -#include "qmediacontrol.h" -#include "qmediaplayer.h" -#include "qmediatimerange.h" - -#include - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -QT_MODULE(Multimedia) - - -class QMediaPlaylist; - -class Q_MULTIMEDIA_EXPORT QMediaPlayerControl : public QMediaControl -{ - Q_OBJECT - -public: - ~QMediaPlayerControl(); - - virtual QMediaPlayer::State state() const = 0; - - virtual QMediaPlayer::MediaStatus mediaStatus() const = 0; - - virtual qint64 duration() const = 0; - - virtual qint64 position() const = 0; - virtual void setPosition(qint64 position) = 0; - - virtual int volume() const = 0; - virtual void setVolume(int volume) = 0; - - virtual bool isMuted() const = 0; - virtual void setMuted(bool muted) = 0; - - virtual int bufferStatus() const = 0; - - virtual bool isAudioAvailable() const = 0; - virtual bool isVideoAvailable() const = 0; - - virtual bool isSeekable() const = 0; - - virtual QMediaTimeRange availablePlaybackRanges() const = 0; - - virtual qreal playbackRate() const = 0; - virtual void setPlaybackRate(qreal rate) = 0; - - virtual QMediaContent media() const = 0; - virtual const QIODevice *mediaStream() const = 0; - virtual void setMedia(const QMediaContent &media, QIODevice *stream) = 0; - - virtual void play() = 0; - virtual void pause() = 0; - virtual void stop() = 0; - -Q_SIGNALS: - void mediaChanged(const QMediaContent& content); - void durationChanged(qint64 duration); - void positionChanged(qint64 position); - void stateChanged(QMediaPlayer::State newState); - void mediaStatusChanged(QMediaPlayer::MediaStatus status); - void volumeChanged(int volume); - void mutedChanged(bool muted); - void audioAvailableChanged(bool audioAvailable); - void videoAvailableChanged(bool videoAvailable); - void bufferStatusChanged(int percentFilled); - void seekableChanged(bool); - void availablePlaybackRangesChanged(const QMediaTimeRange&); - void playbackRateChanged(qreal rate); - void error(int error, const QString &errorString); - -protected: - QMediaPlayerControl(QObject* parent = 0); -}; - -#define QMediaPlayerControl_iid "com.nokia.Qt.QMediaPlayerControl/1.0" -Q_MEDIA_DECLARE_CONTROL(QMediaPlayerControl, QMediaPlayerControl_iid) - -QT_END_NAMESPACE - -QT_END_HEADER - - -#endif // QMEDIAPLAYERCONTROL_H - diff --git a/src/multimediakit/qmediaplaylist.cpp b/src/multimediakit/qmediaplaylist.cpp deleted file mode 100644 index a1690ba24..000000000 --- a/src/multimediakit/qmediaplaylist.cpp +++ /dev/null @@ -1,756 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qmediaplaylist.h" -#include "qmediaplaylist_p.h" -#include "qmediaplaylistprovider.h" -#include "qlocalmediaplaylistprovider.h" -#include "qmediaplaylistioplugin.h" -#include "qmediaservice.h" -#include "qmediaplaylistcontrol.h" -#include "qmediaplayercontrol.h" - -#include -#include -#include -#include -#include - -#include "qmediapluginloader_p.h" - -QT_BEGIN_NAMESPACE - -Q_GLOBAL_STATIC_WITH_ARGS(QMediaPluginLoader, playlistIOLoader, - (QMediaPlaylistIOInterface_iid, QLatin1String("playlistformats"), Qt::CaseInsensitive)) - - -/*! - \class QMediaPlaylist - \inmodule QtMultimediaKit - \ingroup multimedia - \since 1.0 - - - \brief The QMediaPlaylist class provides a list of media content to play. - - QMediaPlaylist is intended to be used with other media objects, - like QMediaPlayer or QMediaImageViewer. - - QMediaPlaylist allows to access the service intrinsic playlist functionality - if available, otherwise it provides the the local memory playlist implementation. - - \snippet doc/src/snippets/multimedia-snippets/media.cpp Movie playlist - - Depending on playlist source implementation, most of the playlist mutating - operations can be asynchronous. - - \sa QMediaContent -*/ - - -/*! - \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 for with the given \a parent. -*/ - -QMediaPlaylist::QMediaPlaylist(QObject *parent) - : QObject(parent) - , d_ptr(new QMediaPlaylistPrivate) -{ - Q_D(QMediaPlaylist); - - d->q_ptr = this; - d->localPlaylistControl = new QLocalMediaPlaylistControl(this); - - setMediaObject(0); -} - -/*! - Destroys the playlist. - */ - -QMediaPlaylist::~QMediaPlaylist() -{ - Q_D(QMediaPlaylist); - - if (d->mediaObject) - d->mediaObject->unbind(this); - - delete d_ptr; -} - -/*! - Returns the QMediaObject instance that this QMediaPlaylist is bound too, - or 0 otherwise. - \since 1.0 -*/ -QMediaObject *QMediaPlaylist::mediaObject() const -{ - return d_func()->mediaObject; -} - -/*! - \internal - If \a mediaObject is null or doesn't have an intrinsic playlist, - internal local memory playlist source will be created. - \since 1.0 -*/ -bool QMediaPlaylist::setMediaObject(QMediaObject *mediaObject) -{ - Q_D(QMediaPlaylist); - - if (mediaObject && mediaObject == d->mediaObject) - return true; - - QMediaService *service = mediaObject - ? mediaObject->service() : 0; - - QMediaPlaylistControl *newControl = 0; - - if (service) - newControl = qobject_cast(service->requestControl(QMediaPlaylistControl_iid)); - - if (!newControl) - newControl = d->localPlaylistControl; - - if (d->control != newControl) { - int oldSize = 0; - if (d->control) { - QMediaPlaylistProvider *playlist = d->control->playlistProvider(); - oldSize = playlist->mediaCount(); - disconnect(playlist, SIGNAL(loadFailed(QMediaPlaylist::Error,QString)), - this, SLOT(_q_loadFailed(QMediaPlaylist::Error,QString))); - - disconnect(playlist, SIGNAL(mediaChanged(int,int)), this, SIGNAL(mediaChanged(int,int))); - disconnect(playlist, SIGNAL(mediaAboutToBeInserted(int,int)), this, SIGNAL(mediaAboutToBeInserted(int,int))); - disconnect(playlist, SIGNAL(mediaInserted(int,int)), this, SIGNAL(mediaInserted(int,int))); - disconnect(playlist, SIGNAL(mediaAboutToBeRemoved(int,int)), this, SIGNAL(mediaAboutToBeRemoved(int,int))); - disconnect(playlist, SIGNAL(mediaRemoved(int,int)), this, SIGNAL(mediaRemoved(int,int))); - - disconnect(playlist, SIGNAL(loaded()), this, SIGNAL(loaded())); - - disconnect(d->control, SIGNAL(playbackModeChanged(QMediaPlaylist::PlaybackMode)), - this, SIGNAL(playbackModeChanged(QMediaPlaylist::PlaybackMode))); - disconnect(d->control, SIGNAL(currentIndexChanged(int)), - this, SIGNAL(currentIndexChanged(int))); - disconnect(d->control, SIGNAL(currentMediaChanged(QMediaContent)), - this, SIGNAL(currentMediaChanged(QMediaContent))); - - if (d->mediaObject) - d->mediaObject->service()->releaseControl(d->control); - } - - d->control = newControl; - QMediaPlaylistProvider *playlist = d->control->playlistProvider(); - connect(playlist, SIGNAL(loadFailed(QMediaPlaylist::Error,QString)), - this, SLOT(_q_loadFailed(QMediaPlaylist::Error,QString))); - - connect(playlist, SIGNAL(mediaChanged(int,int)), this, SIGNAL(mediaChanged(int,int))); - connect(playlist, SIGNAL(mediaAboutToBeInserted(int,int)), this, SIGNAL(mediaAboutToBeInserted(int,int))); - connect(playlist, SIGNAL(mediaInserted(int,int)), this, SIGNAL(mediaInserted(int,int))); - connect(playlist, SIGNAL(mediaAboutToBeRemoved(int,int)), this, SIGNAL(mediaAboutToBeRemoved(int,int))); - connect(playlist, SIGNAL(mediaRemoved(int,int)), this, SIGNAL(mediaRemoved(int,int))); - - connect(playlist, SIGNAL(loaded()), this, SIGNAL(loaded())); - - connect(d->control, SIGNAL(playbackModeChanged(QMediaPlaylist::PlaybackMode)), - this, SIGNAL(playbackModeChanged(QMediaPlaylist::PlaybackMode))); - connect(d->control, SIGNAL(currentIndexChanged(int)), - this, SIGNAL(currentIndexChanged(int))); - connect(d->control, SIGNAL(currentMediaChanged(QMediaContent)), - this, SIGNAL(currentMediaChanged(QMediaContent))); - - if (oldSize) - emit mediaRemoved(0, oldSize-1); - - if (playlist->mediaCount()) { - emit mediaAboutToBeInserted(0,playlist->mediaCount()-1); - emit mediaInserted(0,playlist->mediaCount()-1); - } - } - - d->mediaObject = mediaObject; - - return true; -} - -/*! - \property QMediaPlaylist::playbackMode - - This property defines the order, items in playlist are played. - - \since 1.0 - \sa QMediaPlaylist::PlaybackMode -*/ - -QMediaPlaylist::PlaybackMode QMediaPlaylist::playbackMode() const -{ - return d_func()->control->playbackMode(); -} - -void QMediaPlaylist::setPlaybackMode(QMediaPlaylist::PlaybackMode mode) -{ - Q_D(QMediaPlaylist); - d->control->setPlaybackMode(mode); -} - -/*! - Returns position of the current media content in the playlist. - \since 1.0 -*/ -int QMediaPlaylist::currentIndex() const -{ - return d_func()->control->currentIndex(); -} - -/*! - Returns the current media content. - \since 1.0 -*/ - -QMediaContent QMediaPlaylist::currentMedia() const -{ - return d_func()->playlist()->media(currentIndex()); -} - -/*! - 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. - - \since 1.0 - \sa QMediaPlaylist::playbackMode -*/ -int QMediaPlaylist::nextIndex(int steps) const -{ - return d_func()->control->nextIndex(steps); -} - -/*! - Returns the index of the item, which would be current after calling previous() - \a steps times. - - \since 1.0 - \sa QMediaPlaylist::playbackMode -*/ - -int QMediaPlaylist::previousIndex(int steps) const -{ - return d_func()->control->previousIndex(steps); -} - - -/*! - Returns the number of items in the playlist. - - \since 1.0 - \sa isEmpty() - */ -int QMediaPlaylist::mediaCount() const -{ - return d_func()->playlist()->mediaCount(); -} - -/*! - Returns true if the playlist contains no items; otherwise returns false. - - \since 1.0 - \sa mediaCount() - */ -bool QMediaPlaylist::isEmpty() const -{ - return mediaCount() == 0; -} - -/*! - Returns true if the playlist can be modified; otherwise returns false. - - \since 1.0 - \sa mediaCount() - */ -bool QMediaPlaylist::isReadOnly() const -{ - return d_func()->playlist()->isReadOnly(); -} - -/*! - Returns the media content at \a index in the playlist. - \since 1.0 -*/ - -QMediaContent QMediaPlaylist::media(int index) const -{ - return d_func()->playlist()->media(index); -} - -/*! - Append the media \a content to the playlist. - - Returns true if the operation is successful, otherwise return false. - \since 1.0 - */ -bool QMediaPlaylist::addMedia(const QMediaContent &content) -{ - return d_func()->control->playlistProvider()->addMedia(content); -} - -/*! - Append multiple media content \a items to the playlist. - - Returns true if the operation is successful, otherwise return false. - \since 1.0 - */ -bool QMediaPlaylist::addMedia(const QList &items) -{ - return d_func()->control->playlistProvider()->addMedia(items); -} - -/*! - Insert the media \a content to the playlist at position \a pos. - - Returns true if the operation is successful, otherwise false. - \since 1.0 -*/ - -bool QMediaPlaylist::insertMedia(int pos, const QMediaContent &content) -{ - return d_func()->playlist()->insertMedia(pos, content); -} - -/*! - Insert multiple media content \a items to the playlist at position \a pos. - - Returns true if the operation is successful, otherwise false. - \since 1.0 -*/ - -bool QMediaPlaylist::insertMedia(int pos, const QList &items) -{ - return d_func()->playlist()->insertMedia(pos, items); -} - -/*! - Remove the item from the playlist at position \a pos. - - Returns true if the operation is successful, otherwise return false. - \since 1.0 - */ -bool QMediaPlaylist::removeMedia(int pos) -{ - Q_D(QMediaPlaylist); - return d->playlist()->removeMedia(pos); -} - -/*! - Remove items in the playlist from \a start to \a end inclusive. - - Returns true if the operation is successful, otherwise return false. - \since 1.0 - */ -bool QMediaPlaylist::removeMedia(int start, int end) -{ - Q_D(QMediaPlaylist); - return d->playlist()->removeMedia(start, end); -} - -/*! - Remove all the items from the playlist. - - Returns true if the operation is successful, otherwise return false. - \since 1.0 - */ -bool QMediaPlaylist::clear() -{ - Q_D(QMediaPlaylist); - return d->playlist()->clear(); -} - -bool QMediaPlaylistPrivate::readItems(QMediaPlaylistReader *reader) -{ - while (!reader->atEnd()) - playlist()->addMedia(reader->readItem()); - - return true; -} - -bool QMediaPlaylistPrivate::writeItems(QMediaPlaylistWriter *writer) -{ - for (int i=0; imediaCount(); i++) { - if (!writer->writeItem(playlist()->media(i))) - return false; - } - writer->close(); - return true; -} - -/*! - 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(). - \since 1.0 -*/ -void QMediaPlaylist::load(const QUrl &location, const char *format) -{ - Q_D(QMediaPlaylist); - - d->error = NoError; - d->errorString.clear(); - - if (d->playlist()->load(location,format)) - return; - - if (isReadOnly()) { - d->error = AccessDeniedError; - d->errorString = tr("Could not add items to read only playlist."); - emit loadFailed(); - return; - } - - foreach (QString const& key, playlistIOLoader()->keys()) { - QMediaPlaylistIOInterface* plugin = qobject_cast(playlistIOLoader()->instance(key)); - if (plugin && plugin->canRead(location,format)) { - QMediaPlaylistReader *reader = plugin->createReader(location,QByteArray(format)); - if (reader && d->readItems(reader)) { - delete reader; - emit loaded(); - return; - } - delete reader; - } - } - - d->error = FormatNotSupportedError; - d->errorString = tr("Playlist format is not supported"); - emit loadFailed(); - - return; -} - -/*! - 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(). - \since 1.0 -*/ -void QMediaPlaylist::load(QIODevice * device, const char *format) -{ - Q_D(QMediaPlaylist); - - d->error = NoError; - d->errorString.clear(); - - if (d->playlist()->load(device,format)) - return; - - if (isReadOnly()) { - d->error = AccessDeniedError; - d->errorString = tr("Could not add items to read only playlist."); - emit loadFailed(); - return; - } - - foreach (QString const& key, playlistIOLoader()->keys()) { - QMediaPlaylistIOInterface* plugin = qobject_cast(playlistIOLoader()->instance(key)); - if (plugin && plugin->canRead(device,format)) { - QMediaPlaylistReader *reader = plugin->createReader(device,QByteArray(format)); - if (reader && d->readItems(reader)) { - delete reader; - emit loaded(); - return; - } - delete reader; - } - } - - d->error = FormatNotSupportedError; - d->errorString = tr("Playlist format is not supported"); - emit loadFailed(); - - return; -} - -/*! - 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. - \since 1.0 - */ -bool QMediaPlaylist::save(const QUrl &location, const char *format) -{ - Q_D(QMediaPlaylist); - - d->error = NoError; - d->errorString.clear(); - - if (d->playlist()->save(location,format)) - return true; - - 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. - \since 1.0 -*/ -bool QMediaPlaylist::save(QIODevice * device, const char *format) -{ - Q_D(QMediaPlaylist); - - d->error = NoError; - d->errorString.clear(); - - if (d->playlist()->save(device,format)) - return true; - - foreach (QString const& key, playlistIOLoader()->keys()) { - QMediaPlaylistIOInterface* plugin = qobject_cast(playlistIOLoader()->instance(key)); - if (plugin && plugin->canWrite(device,format)) { - QMediaPlaylistWriter *writer = plugin->createWriter(device,QByteArray(format)); - if (writer && d->writeItems(writer)) { - delete writer; - return true; - } - delete writer; - } - } - - d->error = FormatNotSupportedError; - d->errorString = tr("Playlist format is not supported."); - - return false; -} - -/*! - Returns the last error condition. - \since 1.0 -*/ -QMediaPlaylist::Error QMediaPlaylist::error() const -{ - return d_func()->error; -} - -/*! - Returns the string describing the last error condition. - \since 1.0 -*/ -QString QMediaPlaylist::errorString() const -{ - return d_func()->errorString; -} - -/*! - Shuffle items in the playlist. - \since 1.0 -*/ -void QMediaPlaylist::shuffle() -{ - d_func()->playlist()->shuffle(); -} - - -/*! - Advance to the next media content in playlist. - \since 1.0 -*/ -void QMediaPlaylist::next() -{ - d_func()->control->next(); -} - -/*! - Return to the previous media content in playlist. - \since 1.0 -*/ -void QMediaPlaylist::previous() -{ - d_func()->control->previous(); -} - -/*! - Activate media content from playlist at position \a playlistPosition. - \since 1.0 -*/ - -void QMediaPlaylist::setCurrentIndex(int playlistPosition) -{ - d_func()->control->setCurrentIndex(playlistPosition); -} - -/*! - \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. - \since 1.0 - */ - -/*! - \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. - \since 1.0 - */ - -/*! - \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. - \since 1.0 - */ - -/*! - \fn void QMediaPlaylist::currentIndexChanged(int position) - - Signal emitted when playlist position changed to \a position. - \since 1.0 -*/ - -/*! - \fn void QMediaPlaylist::playbackModeChanged(QMediaPlaylist::PlaybackMode mode) - - Signal emitted when playback mode changed to \a mode. - \since 1.0 -*/ - -/*! - \fn void QMediaPlaylist::mediaAboutToBeInserted(int start, int end) - - Signal emitted when items are to be inserted at \a start and ending at \a end. - \since 1.0 -*/ - -/*! - \fn void QMediaPlaylist::mediaAboutToBeRemoved(int start, int end) - - Signal emitted when item are to be deleted at \a start and ending at \a end. - \since 1.0 -*/ - -/*! - \fn void QMediaPlaylist::currentMediaChanged(const QMediaContent &content) - - Signal emitted when current media changes to \a content. - \since 1.0 -*/ - -/*! - \property QMediaPlaylist::currentIndex - \brief Current position. - \since 1.0 -*/ - -/*! - \property QMediaPlaylist::currentMedia - \brief Current media content. - \since 1.0 -*/ - -/*! - \fn QMediaPlaylist::loaded() - - Signal emitted when playlist finished loading. - \since 1.0 -*/ - -/*! - \fn QMediaPlaylist::loadFailed() - - Signal emitted if failed to load playlist. - \since 1.0 -*/ - -/*! - \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. -*/ - -#include "moc_qmediaplaylist.cpp" -#include "moc_qmediaplaylist_p.cpp" -QT_END_NAMESPACE - diff --git a/src/multimediakit/qmediaplaylist.h b/src/multimediakit/qmediaplaylist.h deleted file mode 100644 index 7b4b62260..000000000 --- a/src/multimediakit/qmediaplaylist.h +++ /dev/null @@ -1,154 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QMEDIAPLAYLIST_H -#define QMEDIAPLAYLIST_H - -#include - -#include -#include -#include -#include - - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -QT_MODULE(Multimedia) - - -class QMediaPlaylistProvider; - -class QMediaPlaylistPrivate; -class Q_MULTIMEDIA_EXPORT QMediaPlaylist : public QObject, public QMediaBindableInterface -{ - Q_OBJECT - Q_INTERFACES(QMediaBindableInterface) - Q_PROPERTY(QMediaPlaylist::PlaybackMode playbackMode READ playbackMode WRITE setPlaybackMode NOTIFY playbackModeChanged) - Q_PROPERTY(QMediaContent currentMedia READ currentMedia NOTIFY currentMediaChanged) - Q_PROPERTY(int currentIndex READ currentIndex WRITE setCurrentIndex NOTIFY currentIndexChanged) - Q_ENUMS(PlaybackMode Error) - -public: - enum PlaybackMode { CurrentItemOnce, CurrentItemInLoop, Sequential, Loop, Random }; - enum Error { NoError, FormatError, FormatNotSupportedError, NetworkError, AccessDeniedError }; - - QMediaPlaylist(QObject *parent = 0); - virtual ~QMediaPlaylist(); - - QMediaObject *mediaObject() const; - - PlaybackMode playbackMode() const; - void setPlaybackMode(PlaybackMode mode); - - int currentIndex() const; - QMediaContent currentMedia() const; - - int nextIndex(int steps = 1) const; - int previousIndex(int steps = 1) const; - - QMediaContent media(int index) const; - - int mediaCount() const; - bool isEmpty() const; - bool isReadOnly() const; - - bool addMedia(const QMediaContent &content); - bool addMedia(const QList &items); - bool insertMedia(int index, const QMediaContent &content); - bool insertMedia(int index, const QList &items); - bool removeMedia(int pos); - bool removeMedia(int start, int end); - bool clear(); - - void load(const QUrl &location, const char *format = 0); - void load(QIODevice * device, const char *format = 0); - - bool save(const QUrl &location, const char *format = 0); - bool save(QIODevice * device, const char *format); - - Error error() const; - QString errorString() const; - -public Q_SLOTS: - void shuffle(); - - void next(); - void previous(); - - void setCurrentIndex(int index); - -Q_SIGNALS: - void currentIndexChanged(int index); - void playbackModeChanged(QMediaPlaylist::PlaybackMode mode); - void currentMediaChanged(const QMediaContent&); - - 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(); - -protected: - bool setMediaObject(QMediaObject *object); - QMediaPlaylistPrivate *d_ptr; - -private: - Q_DECLARE_PRIVATE(QMediaPlaylist) - Q_PRIVATE_SLOT(d_func(), void _q_loadFailed(QMediaPlaylist::Error, const QString &)) -}; - -QT_END_NAMESPACE - -Q_DECLARE_METATYPE(QMediaPlaylist::PlaybackMode) -Q_DECLARE_METATYPE(QMediaPlaylist::Error) - -Q_MEDIA_ENUM_DEBUG(QMediaPlaylist, PlaybackMode) -Q_MEDIA_ENUM_DEBUG(QMediaPlaylist, Error) - -QT_END_HEADER - -#endif // QMEDIAPLAYLIST_H diff --git a/src/multimediakit/qmediaplaylist_p.h b/src/multimediakit/qmediaplaylist_p.h deleted file mode 100644 index c04483c02..000000000 --- a/src/multimediakit/qmediaplaylist_p.h +++ /dev/null @@ -1,177 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#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 "qmediaplaylistcontrol.h" -#include "qmediaplayer.h" -#include "qmediaplayercontrol.h" -#include "qlocalmediaplaylistprovider.h" -#include "qmediaobject_p.h" - -#include - -#ifdef Q_MOC_RUN -# pragma Q_MOC_EXPAND_MACROS -#endif - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -QT_MODULE(Multimedia) - - -class QMediaPlaylistControl; -class QMediaPlaylistProvider; -class QMediaPlaylistReader; -class QMediaPlaylistWriter; -class QMediaPlayerControl; - -class QMediaPlaylistPrivate -{ - Q_DECLARE_PUBLIC(QMediaPlaylist) -public: - QMediaPlaylistPrivate() - :mediaObject(0), - control(0), - localPlaylistControl(0), - error(QMediaPlaylist::NoError) - { - } - - virtual ~QMediaPlaylistPrivate() {} - - void _q_loadFailed(QMediaPlaylist::Error error, const QString &errorString) - { - this->error = error; - this->errorString = errorString; - - emit q_ptr->loadFailed(); - } - - void _q_mediaObjectDeleted() - { - Q_Q(QMediaPlaylist); - mediaObject = 0; - if (control != localPlaylistControl) - control = 0; - q->setMediaObject(0); - } - - QMediaObject *mediaObject; - - QMediaPlaylistControl *control; - QMediaPlaylistProvider *playlist() const { return control->playlistProvider(); } - - QMediaPlaylistControl *localPlaylistControl; - - bool readItems(QMediaPlaylistReader *reader); - bool writeItems(QMediaPlaylistWriter *writer); - - QMediaPlaylist::Error error; - QString errorString; - - QMediaPlaylist *q_ptr; -}; - - -class QLocalMediaPlaylistControl : public QMediaPlaylistControl -{ - Q_OBJECT -public: - QLocalMediaPlaylistControl(QObject *parent) - :QMediaPlaylistControl(parent) - { - QMediaPlaylistProvider *playlist = new QLocalMediaPlaylistProvider(this); - m_navigator = new QMediaPlaylistNavigator(playlist,this); - m_navigator->setPlaybackMode(QMediaPlaylist::Sequential); - - connect(m_navigator, SIGNAL(currentIndexChanged(int)), SIGNAL(currentIndexChanged(int))); - connect(m_navigator, SIGNAL(activated(QMediaContent)), SIGNAL(currentMediaChanged(QMediaContent))); - connect(m_navigator, SIGNAL(playbackModeChanged(QMediaPlaylist::PlaybackMode)), SIGNAL(playbackModeChanged(QMediaPlaylist::PlaybackMode))); - } - - virtual ~QLocalMediaPlaylistControl() {}; - - QMediaPlaylistProvider* playlistProvider() const { return m_navigator->playlist(); } - bool setPlaylistProvider(QMediaPlaylistProvider *mediaPlaylist) - { - m_navigator->setPlaylist(mediaPlaylist); - emit playlistProviderChanged(); - return true; - } - - int currentIndex() const { return m_navigator->currentIndex(); } - void setCurrentIndex(int position) { m_navigator->jump(position); } - int nextIndex(int steps) const { return m_navigator->nextIndex(steps); } - int previousIndex(int steps) const { return m_navigator->previousIndex(steps); } - - void next() { m_navigator->next(); } - void previous() { m_navigator->previous(); } - - QMediaPlaylist::PlaybackMode playbackMode() const { return m_navigator->playbackMode(); } - void setPlaybackMode(QMediaPlaylist::PlaybackMode mode) { m_navigator->setPlaybackMode(mode); } - -private: - QMediaPlaylistNavigator *m_navigator; -}; - - -QT_END_NAMESPACE - -QT_END_HEADER - - -#endif // QMEDIAPLAYLIST_P_H diff --git a/src/multimediakit/qmediaplaylistcontrol.cpp b/src/multimediakit/qmediaplaylistcontrol.cpp deleted file mode 100644 index cf1513863..000000000 --- a/src/multimediakit/qmediaplaylistcontrol.cpp +++ /dev/null @@ -1,219 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - - -#include "qmediaplaylistcontrol.h" -#include "qmediacontrol_p.h" - -QT_BEGIN_NAMESPACE - -/*! - \class QMediaPlaylistControl - \inmodule QtMultimediaKit - \ingroup multimedia-serv - \since 1.0 - - - \brief The QMediaPlaylistControl class provides access to the playlist - functionality of a QMediaService. - - If a QMediaService contains an internal playlist it will implement - QMediaPlaylistControl. This control provides access to the contents of the - \l {playlistProvider()}{playlist}, as well as the \l - {currentIndex()}{position} of the current media, and a means of navigating - to the \l {next()}{next} and \l {previous()}{previous} media. - - The functionality provided by the control is exposed to application code - through the QMediaPlaylist class. - - The interface name of QMediaPlaylistControl is \c com.nokia.Qt.QMediaPlaylistControl/1.0 as - defined in QMediaPlaylistControl_iid. - - \sa QMediaService::requestControl(), QMediaPlayer -*/ - -/*! - \macro QMediaPlaylistControl_iid - - \c com.nokia.Qt.QMediaPlaylistControl/1.0 - - Defines the interface name of the QMediaPlaylistControl class. - - \relates QMediaPlaylistControl -*/ - -/*! - Create a new playlist control object with the given \a parent. -*/ -QMediaPlaylistControl::QMediaPlaylistControl(QObject *parent): - QMediaControl(*new QMediaControlPrivate, parent) -{ -} - -/*! - Destroys the playlist control. -*/ -QMediaPlaylistControl::~QMediaPlaylistControl() -{ -} - - -/*! - \fn QMediaPlaylistControl::playlistProvider() const - - Returns the playlist used by this media player. - \since 1.0 -*/ - -/*! - \fn QMediaPlaylistControl::setPlaylistProvider(QMediaPlaylistProvider *playlist) - - Set the playlist of this media player to \a playlist. - - In many cases it is possible just to use the playlist - constructed by player, but sometimes replacing the whole - playlist allows to avoid copyting of all the items bettween playlists. - - Returns true if player can use this passed playlist; otherwise returns false. - - \since 1.0 -*/ - -/*! - \fn QMediaPlaylistControl::currentIndex() const - - Returns position of the current media source in the playlist. - \since 1.0 -*/ - -/*! - \fn QMediaPlaylistControl::setCurrentIndex(int position) - - Jump to the item at the given \a position. - \since 1.0 -*/ - -/*! - \fn QMediaPlaylistControl::nextIndex(int step) const - - Returns the index of item, which were current after calling next() - \a step times. - - Returned value depends on the size of playlist, current position - and playback mode. - - \since 1.0 - \sa QMediaPlaylist::playbackMode -*/ - -/*! - \fn QMediaPlaylistControl::previousIndex(int step) const - - Returns the index of item, which were current after calling previous() - \a step times. - - \since 1.0 - \sa QMediaPlaylist::playbackMode -*/ - -/*! - \fn QMediaPlaylistControl::next() - - Moves to the next item in playlist. - \since 1.0 -*/ - -/*! - \fn QMediaPlaylistControl::previous() - - Returns to the previous item in playlist. - \since 1.0 -*/ - -/*! - \fn QMediaPlaylistControl::playbackMode() const - - Returns the playlist navigation mode. - - \since 1.0 - \sa QMediaPlaylist::PlaybackMode -*/ - -/*! - \fn QMediaPlaylistControl::setPlaybackMode(QMediaPlaylist::PlaybackMode mode) - - Sets the playback \a mode. - - \since 1.0 - \sa QMediaPlaylist::PlaybackMode -*/ - -/*! - \fn QMediaPlaylistControl::playlistProviderChanged() - - Signal emitted when the playlist provider has changed. - \since 1.0 -*/ - -/*! - \fn QMediaPlaylistControl::currentIndexChanged(int position) - - Signal emitted when the playlist \a position is changed. - \since 1.0 -*/ - -/*! - \fn QMediaPlaylistControl::playbackModeChanged(QMediaPlaylist::PlaybackMode mode) - - Signal emitted when the playback \a mode is changed. - \since 1.0 -*/ - -/*! - \fn QMediaPlaylistControl::currentMediaChanged(const QMediaContent& content) - - Signal emitted when current media changes to \a content. - \since 1.0 -*/ - -#include "moc_qmediaplaylistcontrol.cpp" -QT_END_NAMESPACE - diff --git a/src/multimediakit/qmediaplaylistcontrol.h b/src/multimediakit/qmediaplaylistcontrol.h deleted file mode 100644 index 2cce448fa..000000000 --- a/src/multimediakit/qmediaplaylistcontrol.h +++ /dev/null @@ -1,98 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - - -#ifndef QMEDIAPLAYLISTCONTROL_H -#define QMEDIAPLAYLISTCONTROL_H - -#include "qmediacontrol.h" -#include "qmediaplaylistnavigator.h" - - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -QT_MODULE(Multimedia) - - -class QMediaPlaylistProvider; - -class Q_MULTIMEDIA_EXPORT QMediaPlaylistControl : public QMediaControl -{ - Q_OBJECT - -public: - virtual ~QMediaPlaylistControl(); - - virtual QMediaPlaylistProvider* playlistProvider() const = 0; - virtual bool setPlaylistProvider(QMediaPlaylistProvider *playlist) = 0; - - virtual int currentIndex() const = 0; - virtual void setCurrentIndex(int position) = 0; - virtual int nextIndex(int steps) const = 0; - virtual int previousIndex(int steps) const = 0; - - virtual void next() = 0; - virtual void previous() = 0; - - virtual QMediaPlaylist::PlaybackMode playbackMode() const = 0; - virtual void setPlaybackMode(QMediaPlaylist::PlaybackMode mode) = 0; - -Q_SIGNALS: - void playlistProviderChanged(); - void currentIndexChanged(int position); - void currentMediaChanged(const QMediaContent&); - void playbackModeChanged(QMediaPlaylist::PlaybackMode mode); - -protected: - QMediaPlaylistControl(QObject* parent = 0); -}; - -#define QMediaPlaylistControl_iid "com.nokia.Qt.QMediaPlaylistControl/1.0" -Q_MEDIA_DECLARE_CONTROL(QMediaPlaylistControl, QMediaPlaylistControl_iid) - -QT_END_NAMESPACE - -QT_END_HEADER - - -#endif // QMEDIAPLAYLISTCONTROL_H diff --git a/src/multimediakit/qmediaplaylistioplugin.cpp b/src/multimediakit/qmediaplaylistioplugin.cpp deleted file mode 100644 index 28afbc7bd..000000000 --- a/src/multimediakit/qmediaplaylistioplugin.cpp +++ /dev/null @@ -1,204 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qmediaplaylistioplugin.h" - -QT_BEGIN_NAMESPACE - -/*! - \class QMediaPlaylistReader - - \brief The QMediaPlaylistReader class provides an interface for reading a playlist file. - \inmodule QtMultimediaKit - \since 1.0 - - \sa QMediaPlaylistIOPlugin -*/ - -/*! - Destroys a media playlist reader. -*/ -QMediaPlaylistReader::~QMediaPlaylistReader() -{ -} - -/*! - \fn QMediaPlaylistReader::atEnd() const - - Identifies if a playlist reader has reached the end of its input. - - Returns true if the reader has reached the end; and false otherwise. - \since 1.0 -*/ - -/*! - \fn QMediaPlaylistReader::readItem() - - Reads an item of media from a playlist file. - - Returns the read media, or a null QMediaContent if no more media is available. - \since 1.0 -*/ - -/*! - \fn QMediaPlaylistReader::close() - - Closes a playlist reader's input device. - \since 1.0 -*/ - -/*! - \class QMediaPlaylistWriter - - \brief The QMediaPlaylistWriter class provides an interface for writing a playlist file. - - \since 1.0 - \sa QMediaPlaylistIOPlugin -*/ - -/*! - Destroys a media playlist writer. -*/ -QMediaPlaylistWriter::~QMediaPlaylistWriter() -{ -} - -/*! - \fn QMediaPlaylistWriter::writeItem(const QMediaContent &media) - - Writes an item of \a media to a playlist file. - - Returns true if the media was written successfully; and false otherwise. - \since 1.0 -*/ - -/*! - \fn QMediaPlaylistWriter::close() - - Finalizes the writing of a playlist and closes the output device. - \since 1.0 -*/ - -/*! - \class QMediaPlaylistIOPlugin - \brief The QMediaPlaylistIOPlugin class provides an interface for media playlist I/O plug-ins. - \since 1.0 -*/ - -/*! - Constructs a media playlist I/O plug-in with the given \a parent. -*/ -QMediaPlaylistIOPlugin::QMediaPlaylistIOPlugin(QObject *parent) - :QObject(parent) -{ -} - -/*! - Destroys a media playlist I/O plug-in. -*/ -QMediaPlaylistIOPlugin::~QMediaPlaylistIOPlugin() -{ -} - -/*! - \fn QMediaPlaylistIOPlugin::canRead(QIODevice *device, const QByteArray &format) const - - Identifies if plug-in can read \a format data from an I/O \a device. - - Returns true if the data can be read; and false otherwise. - \since 1.0 -*/ - -/*! - \fn QMediaPlaylistIOPlugin::canRead(const QUrl& location, const QByteArray &format) const - - Identifies if a plug-in can read \a format data from a URL \a location. - - Returns true if the data can be read; and false otherwise. - \since 1.0 -*/ - -/*! - \fn QMediaPlaylistIOPlugin::canWrite(QIODevice *device, const QByteArray &format) const - - Identifies if a plug-in can write \a format data to an I/O \a device. - - Returns true if the data can be written; and false otherwise. - \since 1.0 -*/ - -/*! - \fn QMediaPlaylistIOPlugin::keys() const - - Returns a list of format keys supported by a plug-in. - \since 1.0 -*/ - -/*! - \fn QMediaPlaylistIOPlugin::createReader(QIODevice *device, const QByteArray &format) - - Returns a new QMediaPlaylistReader which reads \a format data from an I/O \a device. - - If the device is invalid or the format is unsupported this will return a null pointer. - \since 1.0 -*/ - -/*! - \fn QMediaPlaylistIOPlugin::createReader(const QUrl& location, const QByteArray &format) - - Returns a new QMediaPlaylistReader which reads \a format data from a URL \a location. - - If the location or the format is unsupported this will return a null pointer. - \since 1.0 -*/ - -/*! - \fn QMediaPlaylistIOPlugin::createWriter(QIODevice *device, const QByteArray &format) - - Returns a new QMediaPlaylistWriter which writes \a format data to an I/O \a device. - - If the device is invalid or the format is unsupported this will return a null pointer. - \since 1.0 -*/ - -#include "moc_qmediaplaylistioplugin.cpp" -QT_END_NAMESPACE - diff --git a/src/multimediakit/qmediaplaylistioplugin.h b/src/multimediakit/qmediaplaylistioplugin.h deleted file mode 100644 index 4234fb8ea..000000000 --- a/src/multimediakit/qmediaplaylistioplugin.h +++ /dev/null @@ -1,126 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QMEDIAPLAYLISTIOPLUGIN_H -#define QMEDIAPLAYLISTIOPLUGIN_H - -#include -#include -#include - -#include - -#include "qmediacontent.h" - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -QT_MODULE(Multimedia) - -class QString; -class QUrl; -class QByteArray; -class QIODevice; -class QStringList; - -class Q_MULTIMEDIA_EXPORT QMediaPlaylistReader -{ -public: - virtual ~QMediaPlaylistReader(); - - virtual bool atEnd() const = 0; - virtual QMediaContent readItem() = 0; - virtual void close() = 0; -}; - -class Q_MULTIMEDIA_EXPORT QMediaPlaylistWriter -{ -public: - virtual ~QMediaPlaylistWriter(); - - virtual bool writeItem(const QMediaContent &content) = 0; - virtual void close() = 0; -}; - -struct Q_MULTIMEDIA_EXPORT QMediaPlaylistIOInterface : public QFactoryInterface -{ - virtual bool canRead(QIODevice *device, const QByteArray &format = QByteArray() ) const = 0; - virtual bool canRead(const QUrl& location, const QByteArray &format = QByteArray()) const = 0; - - virtual bool canWrite(QIODevice *device, const QByteArray &format) const = 0; - - virtual QMediaPlaylistReader *createReader(QIODevice *device, const QByteArray &format = QByteArray()) = 0; - virtual QMediaPlaylistReader *createReader(const QUrl& location, const QByteArray &format = QByteArray()) = 0; - - virtual QMediaPlaylistWriter *createWriter(QIODevice *device, const QByteArray &format) = 0; -}; - -#define QMediaPlaylistIOInterface_iid "com.nokia.Qt.QMediaPlaylistIOInterface" -Q_DECLARE_INTERFACE(QMediaPlaylistIOInterface, QMediaPlaylistIOInterface_iid); - -class Q_MULTIMEDIA_EXPORT QMediaPlaylistIOPlugin : public QObject, public QMediaPlaylistIOInterface -{ -Q_OBJECT -Q_INTERFACES(QMediaPlaylistIOInterface:QFactoryInterface) -public: - explicit QMediaPlaylistIOPlugin(QObject *parent = 0); - virtual ~QMediaPlaylistIOPlugin(); - - virtual bool canRead(QIODevice *device, const QByteArray &format = QByteArray() ) const = 0; - virtual bool canRead(const QUrl& location, const QByteArray &format = QByteArray()) const = 0; - - virtual bool canWrite(QIODevice *device, const QByteArray &format) const = 0; - - virtual QStringList keys() const = 0; - - virtual QMediaPlaylistReader *createReader(QIODevice *device, const QByteArray &format = QByteArray()) = 0; - virtual QMediaPlaylistReader *createReader(const QUrl& location, const QByteArray &format = QByteArray()) = 0; - - virtual QMediaPlaylistWriter *createWriter(QIODevice *device, const QByteArray &format) = 0; -}; - -QT_END_NAMESPACE - -QT_END_HEADER - - -#endif // QMEDIAPLAYLISTIOPLUGIN_H diff --git a/src/multimediakit/qmediaplaylistnavigator.cpp b/src/multimediakit/qmediaplaylistnavigator.cpp deleted file mode 100644 index a4d38e4a1..000000000 --- a/src/multimediakit/qmediaplaylistnavigator.cpp +++ /dev/null @@ -1,568 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qmediaplaylistnavigator.h" -#include "qmediaplaylistprovider.h" -#include "qmediaplaylist.h" -#include "qmediaobject_p.h" - -#include - -QT_BEGIN_NAMESPACE - -class QMediaPlaylistNullProvider : public QMediaPlaylistProvider -{ -public: - QMediaPlaylistNullProvider() :QMediaPlaylistProvider() {} - virtual ~QMediaPlaylistNullProvider() {} - virtual int mediaCount() const {return 0;} - virtual QMediaContent media(int) const { return QMediaContent(); } -}; - -Q_GLOBAL_STATIC(QMediaPlaylistNullProvider, _q_nullMediaPlaylist) - -class QMediaPlaylistNavigatorPrivate -{ - Q_DECLARE_NON_CONST_PUBLIC(QMediaPlaylistNavigator) -public: - QMediaPlaylistNavigatorPrivate() - :playlist(0), - currentPos(-1), - lastValidPos(-1), - playbackMode(QMediaPlaylist::Sequential), - randomPositionsOffset(-1) - { - } - - QMediaPlaylistProvider *playlist; - int currentPos; - int lastValidPos; //to be used with CurrentItemOnce playback mode - QMediaPlaylist::PlaybackMode playbackMode; - QMediaContent currentItem; - - mutable QList randomModePositions; - mutable int randomPositionsOffset; - - int nextItemPos(int steps = 1) const; - int previousItemPos(int steps = 1) const; - - void _q_mediaInserted(int start, int end); - void _q_mediaRemoved(int start, int end); - void _q_mediaChanged(int start, int end); - - QMediaPlaylistNavigator *q_ptr; -}; - - -int QMediaPlaylistNavigatorPrivate::nextItemPos(int steps) const -{ - if (playlist->mediaCount() == 0) - return -1; - - if (steps == 0) - return currentPos; - - switch (playbackMode) { - case QMediaPlaylist::CurrentItemOnce: - return /*currentPos == -1 ? lastValidPos :*/ -1; - case QMediaPlaylist::CurrentItemInLoop: - return currentPos; - case QMediaPlaylist::Sequential: - { - int nextPos = currentPos+steps; - return nextPos < playlist->mediaCount() ? nextPos : -1; - } - case QMediaPlaylist::Loop: - return (currentPos+steps) % playlist->mediaCount(); - case QMediaPlaylist::Random: - { - //TODO: limit the history size - - if (randomPositionsOffset == -1) { - randomModePositions.clear(); - randomModePositions.append(currentPos); - randomPositionsOffset = 0; - } - - while (randomModePositions.size() < randomPositionsOffset+steps+1) - randomModePositions.append(-1); - int res = randomModePositions[randomPositionsOffset+steps]; - if (res<0 || res >= playlist->mediaCount()) { - res = qrand() % playlist->mediaCount(); - randomModePositions[randomPositionsOffset+steps] = res; - } - - return res; - } - } - - return -1; -} - -int QMediaPlaylistNavigatorPrivate::previousItemPos(int steps) const -{ - if (playlist->mediaCount() == 0) - return -1; - - if (steps == 0) - return currentPos; - - switch (playbackMode) { - case QMediaPlaylist::CurrentItemOnce: - return /*currentPos == -1 ? lastValidPos :*/ -1; - case QMediaPlaylist::CurrentItemInLoop: - return currentPos; - case QMediaPlaylist::Sequential: - { - int prevPos = currentPos == -1 ? playlist->mediaCount() - steps : currentPos - steps; - return prevPos>=0 ? prevPos : -1; - } - case QMediaPlaylist::Loop: - { - int prevPos = currentPos - steps; - while (prevPos<0) - prevPos += playlist->mediaCount(); - return prevPos; - } - case QMediaPlaylist::Random: - { - //TODO: limit the history size - - if (randomPositionsOffset == -1) { - randomModePositions.clear(); - randomModePositions.append(currentPos); - randomPositionsOffset = 0; - } - - while (randomPositionsOffset-steps < 0) { - randomModePositions.prepend(-1); - randomPositionsOffset++; - } - - int res = randomModePositions[randomPositionsOffset-steps]; - if (res<0 || res >= playlist->mediaCount()) { - res = qrand() % playlist->mediaCount(); - randomModePositions[randomPositionsOffset-steps] = res; - } - - return res; - } - } - - return -1; -} - -/*! - \class QMediaPlaylistNavigator - - \brief The QMediaPlaylistNavigator class provides navigation for a media playlist. - \inmodule QtMultimediaKit - \ingroup multimedia - \since 1.0 - - \sa QMediaPlaylist, QMediaPlaylistProvider -*/ - - -/*! - Constructs a media playlist navigator for a \a playlist. - - The \a parent is passed to QObject. - \since 1.0 - */ -QMediaPlaylistNavigator::QMediaPlaylistNavigator(QMediaPlaylistProvider *playlist, QObject *parent) - : QObject(parent) - , d_ptr(new QMediaPlaylistNavigatorPrivate) -{ - d_ptr->q_ptr = this; - - setPlaylist(playlist ? playlist : _q_nullMediaPlaylist()); -} - -/*! - Destroys a media playlist navigator. - */ - -QMediaPlaylistNavigator::~QMediaPlaylistNavigator() -{ - delete d_ptr; -} - - -/*! \property QMediaPlaylistNavigator::playbackMode - Contains the playback mode. - \since 1.0 - */ -QMediaPlaylist::PlaybackMode QMediaPlaylistNavigator::playbackMode() const -{ - return d_func()->playbackMode; -} - -/*! - Sets the playback \a mode. - \since 1.0 - */ -void QMediaPlaylistNavigator::setPlaybackMode(QMediaPlaylist::PlaybackMode mode) -{ - Q_D(QMediaPlaylistNavigator); - if (d->playbackMode == mode) - return; - - if (mode == QMediaPlaylist::Random) { - d->randomPositionsOffset = 0; - d->randomModePositions.append(d->currentPos); - } else if (d->playbackMode == QMediaPlaylist::Random) { - d->randomPositionsOffset = -1; - d->randomModePositions.clear(); - } - - d->playbackMode = mode; - - emit playbackModeChanged(mode); - emit surroundingItemsChanged(); -} - -/*! - Returns the playlist being navigated. - \since 1.0 -*/ - -QMediaPlaylistProvider *QMediaPlaylistNavigator::playlist() const -{ - return d_func()->playlist; -} - -/*! - Sets the \a playlist to navigate. - \since 1.0 -*/ -void QMediaPlaylistNavigator::setPlaylist(QMediaPlaylistProvider *playlist) -{ - Q_D(QMediaPlaylistNavigator); - - if (d->playlist == playlist) - return; - - if (d->playlist) { - d->playlist->disconnect(this); - } - - if (playlist) { - d->playlist = playlist; - } else { - //assign to shared readonly null playlist - d->playlist = _q_nullMediaPlaylist(); - } - - connect(d->playlist, SIGNAL(mediaInserted(int,int)), SLOT(_q_mediaInserted(int,int))); - connect(d->playlist, SIGNAL(mediaRemoved(int,int)), SLOT(_q_mediaRemoved(int,int))); - connect(d->playlist, SIGNAL(mediaChanged(int,int)), SLOT(_q_mediaChanged(int,int))); - - d->randomPositionsOffset = -1; - d->randomModePositions.clear(); - - if (d->currentPos != -1) { - d->currentPos = -1; - emit currentIndexChanged(-1); - } - - if (!d->currentItem.isNull()) { - d->currentItem = QMediaContent(); - emit activated(d->currentItem); //stop playback - } -} - -/*! \property QMediaPlaylistNavigator::currentItem - - Contains the media at the current position in the playlist. - - \since 1.0 - \sa currentIndex() -*/ - -QMediaContent QMediaPlaylistNavigator::currentItem() const -{ - return itemAt(d_func()->currentPos); -} - -/*! \fn QMediaContent QMediaPlaylistNavigator::nextItem(int steps) const - - Returns the media that is \a steps positions ahead of the current - position in the playlist. - - \since 1.0 - \sa nextIndex() -*/ -QMediaContent QMediaPlaylistNavigator::nextItem(int steps) const -{ - return itemAt(nextIndex(steps)); -} - -/*! - Returns the media that is \a steps positions behind the current - position in the playlist. - - \since 1.0 - \sa previousIndex() - */ -QMediaContent QMediaPlaylistNavigator::previousItem(int steps) const -{ - return itemAt(previousIndex(steps)); -} - -/*! - Returns the media at a \a position in the playlist. - \since 1.0 - */ -QMediaContent QMediaPlaylistNavigator::itemAt(int position) const -{ - return d_func()->playlist->media(position); -} - -/*! \property QMediaPlaylistNavigator::currentIndex - - Contains the position of the current media. - - If no media is current, the property contains -1. - - \since 1.0 - \sa nextIndex(), previousIndex() -*/ - -int QMediaPlaylistNavigator::currentIndex() const -{ - return d_func()->currentPos; -} - -/*! - Returns a position \a steps ahead of the current position - accounting for the playbackMode(). - - If the position is beyond the end of the playlist, this value - returned is -1. - - \since 1.0 - \sa currentIndex(), previousIndex(), playbackMode() -*/ - -int QMediaPlaylistNavigator::nextIndex(int steps) const -{ - return d_func()->nextItemPos(steps); -} - -/*! - - Returns a position \a steps behind the current position accounting - for the playbackMode(). - - If the position is prior to the beginning of the playlist this will - return -1. - - \since 1.0 - \sa currentIndex(), nextIndex(), playbackMode() -*/ -int QMediaPlaylistNavigator::previousIndex(int steps) const -{ - return d_func()->previousItemPos(steps); -} - -/*! - Advances to the next item in the playlist. - - \since 1.0 - \sa previous(), jump(), playbackMode() - */ -void QMediaPlaylistNavigator::next() -{ - Q_D(QMediaPlaylistNavigator); - - int nextPos = d->nextItemPos(); - - if ( playbackMode() == QMediaPlaylist::Random ) - d->randomPositionsOffset++; - - jump(nextPos); -} - -/*! - Returns to the previous item in the playlist, - - \since 1.0 - \sa next(), jump(), playbackMode() - */ -void QMediaPlaylistNavigator::previous() -{ - Q_D(QMediaPlaylistNavigator); - - int prevPos = d->previousItemPos(); - if ( playbackMode() == QMediaPlaylist::Random ) - d->randomPositionsOffset--; - - jump(prevPos); -} - -/*! - Jumps to a new \a position in the playlist. - \since 1.0 - */ -void QMediaPlaylistNavigator::jump(int position) -{ - Q_D(QMediaPlaylistNavigator); - - if (position<-1 || position>=d->playlist->mediaCount()) { - qWarning() << "QMediaPlaylistNavigator: Jump outside playlist range"; - position = -1; - } - - if (position != -1) - d->lastValidPos = position; - - if (playbackMode() == QMediaPlaylist::Random) { - if (d->randomModePositions[d->randomPositionsOffset] != position) { - d->randomModePositions.clear(); - d->randomModePositions.append(position); - d->randomPositionsOffset = 0; - } - } - - if (position != -1) - d->currentItem = d->playlist->media(position); - else - d->currentItem = QMediaContent(); - - if (position != d->currentPos) { - d->currentPos = position; - emit currentIndexChanged(d->currentPos); - emit surroundingItemsChanged(); - } - - emit activated(d->currentItem); -} - -/*! - \internal - \since 1.0 -*/ -void QMediaPlaylistNavigatorPrivate::_q_mediaInserted(int start, int end) -{ - Q_Q(QMediaPlaylistNavigator); - - if (currentPos >= start) { - currentPos = end-start+1; - q->jump(currentPos); - } - - //TODO: check if they really changed - emit q->surroundingItemsChanged(); -} - -/*! - \internal - \since 1.0 -*/ -void QMediaPlaylistNavigatorPrivate::_q_mediaRemoved(int start, int end) -{ - Q_Q(QMediaPlaylistNavigator); - - if (currentPos > end) { - currentPos = currentPos - end-start+1; - q->jump(currentPos); - } else if (currentPos >= start) { - //current item was removed - currentPos = qMin(start, playlist->mediaCount()-1); - q->jump(currentPos); - } - - //TODO: check if they really changed - emit q->surroundingItemsChanged(); -} - -/*! - \internal - \since 1.0 -*/ -void QMediaPlaylistNavigatorPrivate::_q_mediaChanged(int start, int end) -{ - Q_Q(QMediaPlaylistNavigator); - - if (currentPos >= start && currentPos<=end) { - QMediaContent src = playlist->media(currentPos); - if (src != currentItem) { - currentItem = src; - emit q->activated(src); - } - } - - //TODO: check if they really changed - emit q->surroundingItemsChanged(); -} - -/*! - \fn QMediaPlaylistNavigator::activated(const QMediaContent &media) - - Signals that the current \a media has changed. - \since 1.0 -*/ - -/*! - \fn QMediaPlaylistNavigator::currentIndexChanged(int position) - - Signals the \a position of the current media has changed. - \since 1.0 -*/ - -/*! - \fn QMediaPlaylistNavigator::playbackModeChanged(QMediaPlaylist::PlaybackMode mode) - - Signals that the playback \a mode has changed. - \since 1.0 -*/ - -/*! - \fn QMediaPlaylistNavigator::surroundingItemsChanged() - - Signals that media immediately surrounding the current position has changed. - \since 1.0 -*/ - -#include "moc_qmediaplaylistnavigator.cpp" -QT_END_NAMESPACE - diff --git a/src/multimediakit/qmediaplaylistnavigator.h b/src/multimediakit/qmediaplaylistnavigator.h deleted file mode 100644 index 72e452072..000000000 --- a/src/multimediakit/qmediaplaylistnavigator.h +++ /dev/null @@ -1,115 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QMEDIAPLAYLISTNAVIGATOR_H -#define QMEDIAPLAYLISTNAVIGATOR_H - -#include "qmediaplaylistprovider.h" -#include "qmediaplaylist.h" -#include - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -QT_MODULE(Multimedia) - - -class QMediaPlaylistNavigatorPrivate; -class Q_MULTIMEDIA_EXPORT QMediaPlaylistNavigator : public QObject -{ - Q_OBJECT - Q_PROPERTY(QMediaPlaylist::PlaybackMode playbackMode READ playbackMode WRITE setPlaybackMode NOTIFY playbackModeChanged) - Q_PROPERTY(int currentIndex READ currentIndex WRITE jump NOTIFY currentIndexChanged) - Q_PROPERTY(QMediaContent currentItem READ currentItem) - -public: - QMediaPlaylistNavigator(QMediaPlaylistProvider *playlist, QObject *parent = 0); - virtual ~QMediaPlaylistNavigator(); - - QMediaPlaylistProvider *playlist() const; - void setPlaylist(QMediaPlaylistProvider *playlist); - - QMediaPlaylist::PlaybackMode playbackMode() const; - - QMediaContent currentItem() const; - QMediaContent nextItem(int steps = 1) const; - QMediaContent previousItem(int steps = 1) const; - - QMediaContent itemAt(int position) const; - - int currentIndex() const; - int nextIndex(int steps = 1) const; - int previousIndex(int steps = 1) const; - -public Q_SLOTS: - void next(); - void previous(); - - void jump(int); - - void setPlaybackMode(QMediaPlaylist::PlaybackMode mode); - -Q_SIGNALS: - void activated(const QMediaContent &content); - void currentIndexChanged(int); - void playbackModeChanged(QMediaPlaylist::PlaybackMode mode); - - void surroundingItemsChanged(); - -protected: - QMediaPlaylistNavigatorPrivate *d_ptr; - -private: - Q_DISABLE_COPY(QMediaPlaylistNavigator) - Q_DECLARE_PRIVATE(QMediaPlaylistNavigator) - - Q_PRIVATE_SLOT(d_func(), void _q_mediaInserted(int start, int end)) - Q_PRIVATE_SLOT(d_func(), void _q_mediaRemoved(int start, int end)) - Q_PRIVATE_SLOT(d_func(), void _q_mediaChanged(int start, int end)) -}; - -QT_END_NAMESPACE - -QT_END_HEADER - - -#endif // QMEDIAPLAYLISTNAVIGATOR_H diff --git a/src/multimediakit/qmediaplaylistprovider.cpp b/src/multimediakit/qmediaplaylistprovider.cpp deleted file mode 100644 index 81cd7a7fc..000000000 --- a/src/multimediakit/qmediaplaylistprovider.cpp +++ /dev/null @@ -1,329 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qmediaplaylistprovider.h" -#include "qmediaplaylistprovider_p.h" - -#include - -QT_BEGIN_NAMESPACE - -/*! - \class QMediaPlaylistProvider - - \brief The QMediaPlaylistProvider class provides an abstract list of media. - \inmodule QtMultimediaKit - \since 1.0 - - \sa QMediaPlaylist -*/ - -/*! - Constructs a playlist provider with the given \a parent. -*/ -QMediaPlaylistProvider::QMediaPlaylistProvider(QObject *parent) - :QObject(parent), d_ptr(new QMediaPlaylistProviderPrivate) -{ -} - -/*! - \internal -*/ -QMediaPlaylistProvider::QMediaPlaylistProvider(QMediaPlaylistProviderPrivate &dd, QObject *parent) - :QObject(parent), d_ptr(&dd) -{ -} - -/*! - Destroys a playlist provider. -*/ -QMediaPlaylistProvider::~QMediaPlaylistProvider() -{ - delete d_ptr; -} - -/*! - \fn QMediaPlaylistProvider::mediaCount() const; - - Returns the size of playlist. - \since 1.0 -*/ - -/*! - \fn QMediaPlaylistProvider::media(int index) const; - - Returns the media at \a index in the playlist. - - If the index is invalid this will return a null media content. - \since 1.0 -*/ - - -/*! - Loads a playlist from from a URL \a location. If no playlist \a format is specified the loader - will inspect the URL or probe the headers to guess the format. - - New items are appended to playlist. - - Returns true if the provider supports the format and loading from the locations URL protocol, - otherwise this will return false. - \since 1.0 -*/ -bool QMediaPlaylistProvider::load(const QUrl &location, const char *format) -{ - Q_UNUSED(location); - Q_UNUSED(format); - return false; -} - -/*! - Loads a playlist from from an I/O \a device. If no playlist \a format is specified the loader - will probe the headers to guess the format. - - New items are appended to playlist. - - Returns true if the provider supports the format and loading from an I/O device, otherwise this - will return false. - \since 1.0 -*/ -bool QMediaPlaylistProvider::load(QIODevice * device, const char *format) -{ - Q_UNUSED(device); - Q_UNUSED(format); - return false; -} - -/*! - Saves the contents of a playlist to a URL \a location. If no playlist \a format is specified - the writer will inspect the URL to guess the format. - - Returns true if the playlist was saved successfully; and false otherwise. - \since 1.0 - */ -bool QMediaPlaylistProvider::save(const QUrl &location, const char *format) -{ - Q_UNUSED(location); - Q_UNUSED(format); - return false; -} - -/*! - Saves the contents of a playlist to an I/O \a device in the specified \a format. - - Returns true if the playlist was saved successfully; and false otherwise. - \since 1.0 -*/ -bool QMediaPlaylistProvider::save(QIODevice * device, const char *format) -{ - Q_UNUSED(device); - Q_UNUSED(format); - return false; -} - -/*! - Returns true if a playlist is read-only; otherwise returns false. - \since 1.0 -*/ -bool QMediaPlaylistProvider::isReadOnly() const -{ - return true; -} - -/*! - Append \a media to a playlist. - - Returns true if the media was appended; and false otherwise. - \since 1.0 -*/ -bool QMediaPlaylistProvider::addMedia(const QMediaContent &media) -{ - Q_UNUSED(media); - return false; -} - -/*! - Append multiple media \a items to a playlist. - - Returns true if the media items were appended; and false otherwise. - \since 1.0 -*/ -bool QMediaPlaylistProvider::addMedia(const QList &items) -{ - foreach(const QMediaContent &item, items) { - if (!addMedia(item)) - return false; - } - - return true; -} - -/*! - Inserts \a media into a playlist at \a position. - - Returns true if the media was inserted; and false otherwise. - \since 1.0 -*/ -bool QMediaPlaylistProvider::insertMedia(int position, const QMediaContent &media) -{ - Q_UNUSED(position); - Q_UNUSED(media); - return false; -} - -/*! - Inserts multiple media \a items into a playlist at \a position. - - Returns true if the media \a items were inserted; and false otherwise. - \since 1.0 -*/ -bool QMediaPlaylistProvider::insertMedia(int position, const QList &items) -{ - for (int i=0; i - -#include "qmediacontent.h" -#include "qmediaplaylist.h" - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -QT_MODULE(Multimedia) - -class QString; -QT_END_NAMESPACE - -QT_BEGIN_NAMESPACE - -class QMediaPlaylistProviderPrivate; -class Q_MULTIMEDIA_EXPORT QMediaPlaylistProvider : public QObject -{ -Q_OBJECT -public: - QMediaPlaylistProvider(QObject *parent=0); - virtual ~QMediaPlaylistProvider(); - - virtual bool load(const QUrl &location, const char *format = 0); - virtual bool load(QIODevice * device, const char *format = 0); - virtual bool save(const QUrl &location, const char *format = 0); - virtual bool save(QIODevice * device, const char *format); - - virtual int mediaCount() const = 0; - virtual QMediaContent media(int index) const = 0; - - virtual bool isReadOnly() const; - - virtual bool addMedia(const QMediaContent &content); - virtual bool addMedia(const QList &contentList); - virtual bool insertMedia(int index, const QMediaContent &content); - virtual bool insertMedia(int index, const QList &content); - virtual bool removeMedia(int pos); - virtual bool removeMedia(int start, int end); - virtual bool clear(); - -public Q_SLOTS: - virtual void shuffle(); - -Q_SIGNALS: - 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(QMediaPlaylist::Error, const QString& errorMessage); - -protected: - QMediaPlaylistProviderPrivate *d_ptr; - QMediaPlaylistProvider(QMediaPlaylistProviderPrivate &dd, QObject *parent); - -private: - Q_DECLARE_PRIVATE(QMediaPlaylistProvider) -}; - -QT_END_NAMESPACE - -QT_END_HEADER - - -#endif // QMEDIAPLAYLISTPROVIDER_H diff --git a/src/multimediakit/qmediaplaylistprovider_p.h b/src/multimediakit/qmediaplaylistprovider_p.h deleted file mode 100644 index 71fb86f20..000000000 --- a/src/multimediakit/qmediaplaylistprovider_p.h +++ /dev/null @@ -1,80 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QMEDIAPLAYLISTPROVIDER_P_H -#define QMEDIAPLAYLISTPROVIDER_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" - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -QT_MODULE(Multimedia) - - -class QMediaPlaylistProviderPrivate -{ -public: - QMediaPlaylistProviderPrivate() - {} - virtual ~QMediaPlaylistProviderPrivate() - {} -}; - -QT_END_NAMESPACE - -QT_END_HEADER - - - -#endif // QMEDIAPLAYLISTSOURCE_P_H diff --git a/src/multimediakit/qmediaplaylistsourcecontrol.cpp b/src/multimediakit/qmediaplaylistsourcecontrol.cpp deleted file mode 100644 index 3a788f486..000000000 --- a/src/multimediakit/qmediaplaylistsourcecontrol.cpp +++ /dev/null @@ -1,128 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - - -#include -#include - -QT_BEGIN_NAMESPACE - -/*! - \class QMediaPlaylistSourceControl - \inmodule QtMultimediaKit - \ingroup multimedia-serv - \since 1.0 - - - \brief The QMediaPlaylistSourceControl class provides access to the playlist playback - functionality of a QMediaService. - - This control allows QMediaPlaylist to be passed directly to the service - instead of playing media sources one by one. This control should be - implemented if backend benefits from knowing the next media source to be - played, for example for preloading, cross fading or gap-less playback. - - If QMediaPlaylistSourceControl is provided, the backend must listen for - current playlist item changes to load corresponding media source and - advance the playlist with QMediaPlaylist::next() when playback of the - current media is finished. - - The interface name of QMediaPlaylistSourceControl is \c com.nokia.Qt.QMediaPlaylistSourceControl/1.0 as - defined in QMediaPlaylistSourceControl_iid. - - \sa QMediaService::requestControl(), QMediaPlayer -*/ - -/*! - \macro QMediaPlaylistSourceControl_iid - - \c com.nokia.Qt.QMediaPlaylistSourceControl/1.0 - - Defines the interface name of the QMediaPlaylistSourceControl class. - - \relates QMediaPlaylistSourceControl -*/ - -/*! - Create a new playlist source control object with the given \a parent. -*/ -QMediaPlaylistSourceControl::QMediaPlaylistSourceControl(QObject *parent): - QMediaControl(*new QMediaControlPrivate, parent) -{ -} - -/*! - Destroys the playlist control. -*/ -QMediaPlaylistSourceControl::~QMediaPlaylistSourceControl() -{ -} - - -/*! - \fn QMediaPlaylistSourceControl::playlist() const - - Returns the current playlist. - Should return a null pointer if no playlist is assigned. - \since 1.0 -*/ - -/*! - \fn QMediaPlaylistSourceControl::setPlaylist(QMediaPlaylist *playlist) - - Set the playlist of this media player to \a playlist. - If a null pointer is passed, the playlist source should be disabled. - - The current media should be replaced with the current item of the media playlist. - \since 1.0 -*/ - - -/*! - \fn QMediaPlaylistSourceControl::playlistChanged(QMediaPlaylist* playlist) - - Signal emitted when the playlist has changed to \a playlist. - \since 1.0 -*/ - -#include "moc_qmediaplaylistsourcecontrol.cpp" -QT_END_NAMESPACE - diff --git a/src/multimediakit/qmediaplaylistsourcecontrol.h b/src/multimediakit/qmediaplaylistsourcecontrol.h deleted file mode 100644 index 040bb6431..000000000 --- a/src/multimediakit/qmediaplaylistsourcecontrol.h +++ /dev/null @@ -1,82 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - - -#ifndef QMEDIAPLAYLISTSOURCECONTROL_H -#define QMEDIAPLAYLISTSOURCECONTROL_H - -#include - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -QT_MODULE(Multimedia) - - -class QMediaPlaylist; - -class Q_MULTIMEDIA_EXPORT QMediaPlaylistSourceControl : public QMediaControl -{ - Q_OBJECT - -public: - virtual ~QMediaPlaylistSourceControl(); - - virtual QMediaPlaylist *playlist() const = 0; - virtual void setPlaylist(QMediaPlaylist *) = 0; - -Q_SIGNALS: - void playlistChanged(QMediaPlaylist* playlist); - -protected: - QMediaPlaylistSourceControl(QObject* parent = 0); -}; - -#define QMediaPlaylistSourceControl_iid "com.nokia.Qt.QMediaPlaylistSourceControl/1.0" -Q_MEDIA_DECLARE_CONTROL(QMediaPlaylistSourceControl, QMediaPlaylistSourceControl_iid) - -QT_END_NAMESPACE - -QT_END_HEADER - - -#endif // QMEDIAPLAYLISTCONTROL_H diff --git a/src/multimediakit/qmediapluginloader.cpp b/src/multimediakit/qmediapluginloader.cpp deleted file mode 100644 index 32f336959..000000000 --- a/src/multimediakit/qmediapluginloader.cpp +++ /dev/null @@ -1,213 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qmediapluginloader_p.h" -#include -#include -#include -#include - -#include "qmediaserviceproviderplugin.h" - -#if defined(Q_OS_MAC) -# include -#endif - -QT_BEGIN_NAMESPACE - -typedef QMap ObjectListMap; -Q_GLOBAL_STATIC(ObjectListMap, staticMediaPlugins); - - -QMediaPluginLoader::QMediaPluginLoader(const char *iid, const QString &location, Qt::CaseSensitivity): - m_iid(iid) -{ - m_location = QString::fromLatin1("/%1").arg(location); - load(); -} - -QStringList QMediaPluginLoader::keys() const -{ - return m_instances.keys(); -} - -QObject* QMediaPluginLoader::instance(QString const &key) -{ - return m_instances.value(key).value(0); -} - -QList QMediaPluginLoader::instances(QString const &key) -{ - return m_instances.value(key); -} - -//to be used for testing purposes only -void QMediaPluginLoader::setStaticPlugins(const QString &location, const QObjectList& objects) -{ - staticMediaPlugins()->insert(QString::fromLatin1("/%1").arg(location), objects); -} - -QStringList QMediaPluginLoader::availablePlugins() const -{ - QStringList paths; - QStringList plugins; - -#if defined(Q_OS_MAC) - QString imageSuffix(qgetenv("DYLD_IMAGE_SUFFIX")); - - // Bundle plugin directory - CFBundleRef mainBundle = CFBundleGetMainBundle(); - if (mainBundle != 0) { - CFURLRef baseUrl = CFBundleCopyBundleURL(mainBundle); - CFURLRef pluginUrlPart = CFBundleCopyBuiltInPlugInsURL(mainBundle); - CFStringRef pluginPathPart = CFURLCopyFileSystemPath(pluginUrlPart, kCFURLPOSIXPathStyle); - CFURLRef pluginUrl = CFURLCreateCopyAppendingPathComponent(0, baseUrl, pluginPathPart, true); - CFStringRef pluginPath = CFURLCopyFileSystemPath(pluginUrl, kCFURLPOSIXPathStyle); - - CFIndex length = CFStringGetLength(pluginPath); - UniChar buffer[length]; - CFStringGetCharacters(pluginPath, CFRangeMake(0, length), buffer); - - paths << QString(reinterpret_cast(buffer), length); - - CFRelease(pluginPath); - CFRelease(pluginUrl); - CFRelease(pluginPathPart); - CFRelease(pluginUrlPart); - CFRelease(baseUrl); - } -#endif - - // Qt paths - paths << QCoreApplication::libraryPaths(); - - foreach (const QString &path, paths) { - QDir typeDir(path + m_location); - foreach (const QString &file, typeDir.entryList(QDir::Files)) { -#if defined(Q_OS_MAC) - if (!imageSuffix.isEmpty()) { // Only add appropriate images - if (file.lastIndexOf(imageSuffix, -6) == -1) - continue; - } else { // Ignore any images with common suffixes - if (file.endsWith(QLatin1String("_debug.dylib")) || - file.endsWith(QLatin1String("_profile.dylib"))) - continue; - } -#elif defined(Q_OS_UNIX) - // Ignore separate debug files - if (file.endsWith(QLatin1String(".debug"))) - continue; -#elif defined(Q_OS_WIN) - // Ignore non-dlls - if (!file.endsWith(QLatin1String(".dll"), Qt::CaseInsensitive)) - continue; -#endif - plugins << typeDir.absoluteFilePath(file); - } - } - - return plugins; -} - -void QMediaPluginLoader::load() -{ - if (!m_instances.isEmpty()) - return; - -#if !defined QT_NO_DEBUG - const bool showDebug = qgetenv("QT_DEBUG_PLUGINS").toInt() > 0; -#endif - - if (staticMediaPlugins() && staticMediaPlugins()->contains(m_location)) { - foreach(QObject *o, staticMediaPlugins()->value(m_location)) { - if (o != 0 && o->qt_metacast(m_iid) != 0) { - QFactoryInterface* p = qobject_cast(o); - if (p != 0) { - foreach (QString const &key, p->keys()) - m_instances[key].append(o); - } - } - } - } else { - QSet loadedPlugins; - - foreach (const QString &plugin, availablePlugins()) { - QString fileName = QFileInfo(plugin).fileName(); - //don't try to load plugin with the same name if it's already loaded - if (loadedPlugins.contains(fileName)) { -#if !defined QT_NO_DEBUG - if (showDebug) - qDebug() << "Skip loading plugin" << plugin; -#endif - continue; - } - - QPluginLoader loader(plugin); - - QObject *o = loader.instance(); - if (o != 0 && o->qt_metacast(m_iid) != 0) { - QFactoryInterface* p = qobject_cast(o); - if (p != 0) { - foreach (const QString &key, p->keys()) - m_instances[key].append(o); - - loadedPlugins.insert(fileName); -#if !defined QT_NO_DEBUG - if (showDebug) - qDebug() << "Loaded plugin" << plugin << "services:" << p->keys(); -#endif - } - - continue; - } else { -#if !defined QT_NO_DEBUG - if (showDebug) - qWarning() << "QMediaPluginLoader: Failed to load plugin: " << plugin << loader.errorString(); -#endif - } - - delete o; - } - } -} - -QT_END_NAMESPACE - diff --git a/src/multimediakit/qmediapluginloader_p.h b/src/multimediakit/qmediapluginloader_p.h deleted file mode 100644 index 2f0a4d939..000000000 --- a/src/multimediakit/qmediapluginloader_p.h +++ /dev/null @@ -1,99 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QMEDIAPLUGINLOADER_H -#define QMEDIAPLUGINLOADER_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 -#include -#include -#include -#include - - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -QT_MODULE(Multimedia) - - -class QMediaServiceProviderPlugin; - -class Q_AUTOTEST_EXPORT QMediaPluginLoader -{ -public: - QMediaPluginLoader(const char *iid, - const QString &suffix = QString(), - Qt::CaseSensitivity = Qt::CaseSensitive); - - QStringList keys() const; - QObject* instance(QString const &key); - QList instances(QString const &key); - - static void setStaticPlugins(const QString &location, const QObjectList& objects); - -private: - void load(); - QStringList availablePlugins() const; - - QByteArray m_iid; - QString m_location; - QMap > m_instances; -}; - -QT_END_NAMESPACE - -QT_END_HEADER - - -#endif // QMEDIAPLUGINLOADER_H diff --git a/src/multimediakit/qmediarecorder.cpp b/src/multimediakit/qmediarecorder.cpp deleted file mode 100644 index 2584359ef..000000000 --- a/src/multimediakit/qmediarecorder.cpp +++ /dev/null @@ -1,904 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qmediarecorder.h" - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include - -#include - -QT_BEGIN_NAMESPACE - -/*! - \class QMediaRecorder - \inmodule QtMultimediaKit - \ingroup multimedia - \since 1.0 - - - \brief The QMediaRecorder class is used for the recording of media content. - - The QMediaRecorder class is a high level media recording class. It's not - intended to be used alone but for accessing the media recording functions - of other media objects, like QRadioTuner, or QAudioCaptureSource. - - \snippet doc/src/snippets/multimedia-snippets/media.cpp Media recorder - - \sa QAudioCaptureSource -*/ - -namespace -{ -class MediaRecorderRegisterMetaTypes -{ -public: - MediaRecorderRegisterMetaTypes() - { - qRegisterMetaType("QMediaRecorder::State"); - qRegisterMetaType("QMediaRecorder::Error"); - } -} _registerRecorderMetaTypes; -} - - -class QMediaRecorderPrivate -{ - Q_DECLARE_NON_CONST_PUBLIC(QMediaRecorder) - -public: - QMediaRecorderPrivate(); - - QMediaObject *mediaObject; - - QMediaRecorderControl *control; - QMediaContainerControl *formatControl; - QAudioEncoderControl *audioControl; - QVideoEncoderControl *videoControl; - QMetaDataWriterControl *metaDataControl; - - QTimer* notifyTimer; - - QMediaRecorder::State state; - QMediaRecorder::Error error; - QString errorString; - - void _q_stateChanged(QMediaRecorder::State state); - void _q_error(int error, const QString &errorString); - void _q_serviceDestroyed(); - void _q_notify(); - void _q_updateNotifyInterval(int ms); - - QMediaRecorder *q_ptr; -}; - -QMediaRecorderPrivate::QMediaRecorderPrivate(): - mediaObject(0), - control(0), - formatControl(0), - audioControl(0), - videoControl(0), - metaDataControl(0), - notifyTimer(0), - state(QMediaRecorder::StoppedState), - error(QMediaRecorder::NoError) -{ -} - -#define ENUM_NAME(c,e,v) (c::staticMetaObject.enumerator(c::staticMetaObject.indexOfEnumerator(e)).valueToKey((v))) - -void QMediaRecorderPrivate::_q_stateChanged(QMediaRecorder::State ps) -{ - Q_Q(QMediaRecorder); - - if (ps == QMediaRecorder::RecordingState) - notifyTimer->start(); - else - notifyTimer->stop(); - -// qDebug() << "Recorder state changed:" << ENUM_NAME(QMediaRecorder,"State",ps); - if (state != ps) { - emit q->stateChanged(ps); - } - - state = ps; -} - - -void QMediaRecorderPrivate::_q_error(int error, const QString &errorString) -{ - Q_Q(QMediaRecorder); - - this->error = QMediaRecorder::Error(error); - this->errorString = errorString; - - emit q->error(this->error); -} - -void QMediaRecorderPrivate::_q_serviceDestroyed() -{ - mediaObject = 0; - control = 0; - formatControl = 0; - audioControl = 0; - videoControl = 0; - metaDataControl = 0; -} - -void QMediaRecorderPrivate::_q_notify() -{ - emit q_func()->durationChanged(q_func()->duration()); -} - -void QMediaRecorderPrivate::_q_updateNotifyInterval(int ms) -{ - notifyTimer->setInterval(ms); -} - - -/*! - Constructs a media recorder which records the media produced by \a mediaObject. - - The \a parent is passed to QMediaObject. - \since 1.0 -*/ - -QMediaRecorder::QMediaRecorder(QMediaObject *mediaObject, QObject *parent): - QObject(parent), - d_ptr(new QMediaRecorderPrivate) -{ - Q_D(QMediaRecorder); - d->q_ptr = this; - setMediaObject(mediaObject); - - d->notifyTimer = new QTimer(this); - d->notifyTimer->setInterval(mediaObject->notifyInterval()); - connect(d->notifyTimer, SIGNAL(timeout()), SLOT(_q_notify())); - connect(mediaObject, SIGNAL(notifyIntervalChanged(int)), SLOT(_q_updateNotifyInterval(int))); -} - -/*! - Destroys a media recorder object. -*/ - -QMediaRecorder::~QMediaRecorder() -{ -} - -/*! - Returns the QMediaObject instance that this QMediaRecorder is bound too, - or 0 otherwise. - \since 1.0 -*/ -QMediaObject *QMediaRecorder::mediaObject() const -{ - return d_func()->mediaObject; -} - -/*! - \internal - \since 1.0 -*/ -bool QMediaRecorder::setMediaObject(QMediaObject *object) -{ - Q_D(QMediaRecorder); - - if (object == d->mediaObject) - return true; - - if (d->mediaObject) { - if (d->control) { - disconnect(d->control, SIGNAL(stateChanged(QMediaRecorder::State)), - this, SLOT(_q_stateChanged(QMediaRecorder::State))); - - disconnect(d->control, SIGNAL(mutedChanged(bool)), - this, SIGNAL(mutedChanged(bool))); - - disconnect(d->control, SIGNAL(durationChanged(qint64)), - this, SIGNAL(durationChanged(qint64))); - - disconnect(d->control, SIGNAL(error(int,QString)), - this, SLOT(_q_error(int,QString))); - } - - QMediaService *service = d->mediaObject->service(); - - if (service) { - disconnect(service, SIGNAL(destroyed()), this, SLOT(_q_serviceDestroyed())); - - if (d->control) - service->releaseControl(d->control); - if (d->formatControl) - service->releaseControl(d->formatControl); - if (d->audioControl) - service->releaseControl(d->audioControl); - if (d->videoControl) - service->releaseControl(d->videoControl); - if (d->metaDataControl) { - disconnect(d->metaDataControl, SIGNAL(metaDataChanged()), - this, SIGNAL(metaDataChanged())); - disconnect(d->metaDataControl, SIGNAL(metaDataAvailableChanged(bool)), - this, SIGNAL(metaDataAvailableChanged(bool))); - disconnect(d->metaDataControl, SIGNAL(writableChanged(bool)), - this, SIGNAL(metaDataWritableChanged(bool))); - - service->releaseControl(d->metaDataControl); - } - } - } - - d->control = 0; - d->formatControl = 0; - d->audioControl = 0; - d->videoControl = 0; - d->metaDataControl = 0; - - d->mediaObject = object; - - if (d->mediaObject) { - QMediaService *service = d->mediaObject->service(); - - if (service) { - d->control = qobject_cast(service->requestControl(QMediaRecorderControl_iid)); - - if (d->control) { - d->formatControl = qobject_cast(service->requestControl(QMediaContainerControl_iid)); - d->audioControl = qobject_cast(service->requestControl(QAudioEncoderControl_iid)); - d->videoControl = qobject_cast(service->requestControl(QVideoEncoderControl_iid)); - - QMediaControl *control = service->requestControl(QMetaDataWriterControl_iid); - if (control) { - d->metaDataControl = qobject_cast(control); - if (!d->metaDataControl) { - service->releaseControl(control); - } else { - connect(d->metaDataControl, - SIGNAL(metaDataChanged()), - SIGNAL(metaDataChanged())); - connect(d->metaDataControl, - SIGNAL(metaDataAvailableChanged(bool)), - SIGNAL(metaDataAvailableChanged(bool))); - connect(d->metaDataControl, - SIGNAL(writableChanged(bool)), - SIGNAL(metaDataWritableChanged(bool))); - } - } - - connect(d->control, SIGNAL(stateChanged(QMediaRecorder::State)), - this, SLOT(_q_stateChanged(QMediaRecorder::State))); - - connect(d->control, SIGNAL(mutedChanged(bool)), - this, SIGNAL(mutedChanged(bool))); - - connect(d->control, SIGNAL(durationChanged(qint64)), - this, SIGNAL(durationChanged(qint64))); - - connect(d->control, SIGNAL(error(int,QString)), - this, SLOT(_q_error(int,QString))); - - connect(service, SIGNAL(destroyed()), this, SLOT(_q_serviceDestroyed())); - - - return true; - } - } - - d->mediaObject = 0; - return false; - } - - return true; -} - -/*! - \property QMediaRecorder::outputLocation - \brief the destination location of media content. - - Setting the location can fail, for example when the service supports only - local file system locations but a network URL was passed. If the service - does not support media recording this setting the output location will - always fail. - - The \a location can be relative or empty; - in this case the recorder uses the system specific place and file naming scheme. - After recording has stated, QMediaRecorder::outputLocation() returns the actual output location. - \since 1.0 -*/ - -/*! - Returns true if media recorder service ready to use. - \since 1.0 -*/ -bool QMediaRecorder::isAvailable() const -{ - if (d_func()->control != NULL) - return true; - else - return false; -} - -/*! - Returns the availability error code. - \since 1.0 -*/ -QtMultimediaKit::AvailabilityError QMediaRecorder::availabilityError() const -{ - if (d_func()->control != NULL) - return QtMultimediaKit::NoError; - else - return QtMultimediaKit::ServiceMissingError; -} - -QUrl QMediaRecorder::outputLocation() const -{ - return d_func()->control ? d_func()->control->outputLocation() : QUrl(); -} - -bool QMediaRecorder::setOutputLocation(const QUrl &location) -{ - Q_D(QMediaRecorder); - return d->control ? d->control->setOutputLocation(location) : false; -} - -/*! - Returns the current media recorder state. - - \since 1.0 - \sa QMediaRecorder::State -*/ - -QMediaRecorder::State QMediaRecorder::state() const -{ - return d_func()->control ? QMediaRecorder::State(d_func()->control->state()) : StoppedState; -} - -/*! - Returns the current error state. - - \since 1.0 - \sa errorString() -*/ - -QMediaRecorder::Error QMediaRecorder::error() const -{ - return d_func()->error; -} - -/*! - Returns a string describing the current error state. - - \since 1.0 - \sa error() -*/ - -QString QMediaRecorder::errorString() const -{ - return d_func()->errorString; -} - -/*! - \property QMediaRecorder::duration - - \brief the recorded media duration in milliseconds. - \since 1.0 -*/ - -qint64 QMediaRecorder::duration() const -{ - return d_func()->control ? d_func()->control->duration() : 0; -} - -/*! - \property QMediaRecorder::muted - - \brief whether a recording audio stream is muted. - \since 1.0 -*/ - -bool QMediaRecorder::isMuted() const -{ - return d_func()->control ? d_func()->control->isMuted() : 0; -} - -void QMediaRecorder::setMuted(bool muted) -{ - Q_D(QMediaRecorder); - - if (d->control) - d->control->setMuted(muted); -} - -/*! - Returns a list of MIME types of supported container formats. - \since 1.0 -*/ -QStringList QMediaRecorder::supportedContainers() const -{ - return d_func()->formatControl ? - d_func()->formatControl->supportedContainers() : QStringList(); -} - -/*! - Returns a description of a container format \a mimeType. - \since 1.0 -*/ -QString QMediaRecorder::containerDescription(const QString &mimeType) const -{ - return d_func()->formatControl ? - d_func()->formatControl->containerDescription(mimeType) : QString(); -} - -/*! - Returns the MIME type of the selected container format. - \since 1.0 -*/ - -QString QMediaRecorder::containerMimeType() const -{ - return d_func()->formatControl ? - d_func()->formatControl->containerMimeType() : QString(); -} - -/*! - Returns a list of supported audio codecs. - \since 1.0 -*/ -QStringList QMediaRecorder::supportedAudioCodecs() const -{ - return d_func()->audioControl ? - d_func()->audioControl->supportedAudioCodecs() : QStringList(); -} - -/*! - Returns a description of an audio \a codec. - \since 1.0 -*/ -QString QMediaRecorder::audioCodecDescription(const QString &codec) const -{ - return d_func()->audioControl ? - d_func()->audioControl->codecDescription(codec) : QString(); -} - -/*! - Returns a list of supported audio sample rates. - - If non null audio \a settings parameter is passed, the returned list is - reduced to sample rates supported with partial settings applied. - - This can be used to query the list of sample rates, supported by specific - audio codec. - - If the encoder supports arbitrary sample rates within the supported rates - range, *\a continuous is set to true, otherwise *\a continuous is set to - false. - \since 1.0 -*/ - -QList QMediaRecorder::supportedAudioSampleRates(const QAudioEncoderSettings &settings, bool *continuous) const -{ - if (continuous) - *continuous = false; - - return d_func()->audioControl ? - d_func()->audioControl->supportedSampleRates(settings, continuous) : QList(); -} - -/*! - Returns a list of resolutions video can be encoded at. - - If non null video \a settings parameter is passed, the returned list is - reduced to resolution supported with partial settings like video codec or - framerate applied. - - If the encoder supports arbitrary resolutions within the supported range, - *\a continuous is set to true, otherwise *\a continuous is set to false. - - \since 1.0 - \sa QVideoEncoderSettings::resolution() -*/ -QList QMediaRecorder::supportedResolutions(const QVideoEncoderSettings &settings, bool *continuous) const -{ - if (continuous) - *continuous = false; - - return d_func()->videoControl ? - d_func()->videoControl->supportedResolutions(settings, continuous) : QList(); -} - -/*! - Returns a list of frame rates video can be encoded at. - - If non null video \a settings parameter is passed, the returned list is - reduced to frame rates supported with partial settings like video codec or - resolution applied. - - If the encoder supports arbitrary frame rates within the supported range, - *\a continuous is set to true, otherwise *\a continuous is set to false. - - \since 1.0 - \sa QVideoEncoderSettings::frameRate() -*/ -QList QMediaRecorder::supportedFrameRates(const QVideoEncoderSettings &settings, bool *continuous) const -{ - if (continuous) - *continuous = false; - - return d_func()->videoControl ? - d_func()->videoControl->supportedFrameRates(settings, continuous) : QList(); -} - -/*! - Returns a list of supported video codecs. - \since 1.0 -*/ -QStringList QMediaRecorder::supportedVideoCodecs() const -{ - return d_func()->videoControl ? - d_func()->videoControl->supportedVideoCodecs() : QStringList(); -} - -/*! - Returns a description of a video \a codec. - - \since 1.0 - \sa setEncodingSettings() -*/ -QString QMediaRecorder::videoCodecDescription(const QString &codec) const -{ - return d_func()->videoControl ? - d_func()->videoControl->videoCodecDescription(codec) : QString(); -} - -/*! - Returns the audio encoder settings being used. - - \since 1.0 - \sa setEncodingSettings() -*/ - -QAudioEncoderSettings QMediaRecorder::audioSettings() const -{ - return d_func()->audioControl ? - d_func()->audioControl->audioSettings() : QAudioEncoderSettings(); -} - -/*! - Returns the video encoder settings being used. - - \since 1.0 - \sa setEncodingSettings() -*/ - -QVideoEncoderSettings QMediaRecorder::videoSettings() const -{ - return d_func()->videoControl ? - d_func()->videoControl->videoSettings() : QVideoEncoderSettings(); -} - -/*! - Sets the \a audio and \a video encoder settings and \a container format MIME type. - - If some parameters are not specified, or null settings are passed, the - encoder will choose default encoding parameters, depending on media - source properties. - While setEncodingSettings is optional, the backend can preload - encoding pipeline to improve recording startup time. - - It's only possible to change settings when the encoder is in the - QMediaEncoder::StoppedState state. - - \since 1.0 - \sa audioSettings(), videoSettings(), containerMimeType() -*/ - -void QMediaRecorder::setEncodingSettings(const QAudioEncoderSettings &audio, - const QVideoEncoderSettings &video, - const QString &container) -{ - Q_D(QMediaRecorder); - - QCamera *camera = qobject_cast(d->mediaObject); - if (camera && camera->captureMode() == QCamera::CaptureVideo) { - QMetaObject::invokeMethod(camera, - "_q_preparePropertyChange", - Qt::DirectConnection, - Q_ARG(int, QCameraControl::VideoEncodingSettings)); - } - - if (d->audioControl) - d->audioControl->setAudioSettings(audio); - - if (d->videoControl) - d->videoControl->setVideoSettings(video); - - if (d->formatControl) - d->formatControl->setContainerMimeType(container); - - if (d->control) - d->control->applySettings(); -} - - -/*! - Start recording. - - This is an asynchronous call, with signal - stateCahnged(QMediaRecorder::RecordingState) being emitted when recording - started, otherwise the error() signal is emitted. - \since 1.0 -*/ - -void QMediaRecorder::record() -{ - Q_D(QMediaRecorder); - - // reset error - d->error = NoError; - d->errorString = QString(); - - if (d->control) - d->control->record(); -} - -/*! - Pause recording. - \since 1.0 -*/ - -void QMediaRecorder::pause() -{ - Q_D(QMediaRecorder); - if (d->control) - d->control->pause(); -} - -/*! - Stop recording. - \since 1.0 -*/ - -void QMediaRecorder::stop() -{ - Q_D(QMediaRecorder); - if (d->control) - d->control->stop(); -} - -/*! - \enum QMediaRecorder::State - - \value StoppedState The recorder is not active. - \value RecordingState The recorder is currently active and producing data. - \value PausedState The recorder is paused. -*/ - -/*! - \enum QMediaRecorder::Error - - \value NoError No Errors. - \value ResourceError Device is not ready or not available. - \value FormatError Current format is not supported. -*/ - -/*! - \fn QMediaRecorder::stateChanged(State state) - - Signals that a media recorder's \a state has changed. - \since 1.0 -*/ - -/*! - \fn QMediaRecorder::durationChanged(qint64 duration) - - Signals that the \a duration of the recorded media has changed. - \since 1.0 -*/ - -/*! - \fn QMediaRecorder::error(QMediaRecorder::Error error) - - Signals that an \a error has occurred. - \since 1.0 -*/ - -/*! - \fn QMediaRecorder::mutedChanged(bool muted) - - Signals that the \a muted state has changed. If true the recording is being muted. - \since 1.0 -*/ - -/*! - \property QMediaRecorder::metaDataAvailable - \brief whether access to a media object's meta-data is available. - - If this is true there is meta-data available, otherwise there is no meta-data available. - \since 1.0 -*/ - -bool QMediaRecorder::isMetaDataAvailable() const -{ - Q_D(const QMediaRecorder); - - return d->metaDataControl - ? d->metaDataControl->isMetaDataAvailable() - : false; -} - -/*! - \fn QMediaRecorder::metaDataAvailableChanged(bool available) - - Signals that the \a available state of a media object's meta-data has changed. - \since 1.0 -*/ - -/*! - \property QMediaRecorder::metaDataWritable - \brief whether a media object's meta-data is writable. - - If this is true the meta-data is writable, otherwise the meta-data is read-only. - \since 1.0 -*/ - -bool QMediaRecorder::isMetaDataWritable() const -{ - Q_D(const QMediaRecorder); - - return d->metaDataControl - ? d->metaDataControl->isWritable() - : false; -} - -/*! - \fn QMediaRecorder::metaDataWritableChanged(bool writable) - - Signals that the \a writable state of a media object's meta-data has changed. - \since 1.0 -*/ - -/*! - Returns the value associated with a meta-data \a key. - \since 1.0 -*/ -QVariant QMediaRecorder::metaData(QtMultimediaKit::MetaData key) const -{ - Q_D(const QMediaRecorder); - - return d->metaDataControl - ? d->metaDataControl->metaData(key) - : QVariant(); -} - -/*! - Sets a \a value for a meta-data \a key. - - \note To ensure that meta data is set corretly, it should be set before starting the recording. - Once the recording is stopped, any meta data set will be attached to the next recording. - \since 1.0 -*/ -void QMediaRecorder::setMetaData(QtMultimediaKit::MetaData key, const QVariant &value) -{ - Q_D(QMediaRecorder); - - if (d->metaDataControl) - d->metaDataControl->setMetaData(key, value); -} - -/*! - Returns a list of keys there is meta-data available for. - \since 1.0 -*/ -QList QMediaRecorder::availableMetaData() const -{ - Q_D(const QMediaRecorder); - - return d->metaDataControl - ? d->metaDataControl->availableMetaData() - : QList(); -} - -/*! - \fn QMediaRecorder::metaDataChanged() - - Signals that a media object's meta-data has changed. - \since 1.0 -*/ - -/*! - Returns the value associated with a meta-data \a key. - - The naming and type of extended meta-data is not standardized, so the values and meaning - of keys may vary between backends. - \since 1.0 -*/ -QVariant QMediaRecorder::extendedMetaData(const QString &key) const -{ - Q_D(const QMediaRecorder); - - return d->metaDataControl - ? d->metaDataControl->extendedMetaData(key) - : QVariant(); -} - -/*! - Sets a \a value for a meta-data \a key. - - The naming and type of extended meta-data is not standardized, so the values and meaning - of keys may vary between backends. - \since 1.0 -*/ -void QMediaRecorder::setExtendedMetaData(const QString &key, const QVariant &value) -{ - Q_D(QMediaRecorder); - - if (d->metaDataControl) - d->metaDataControl->setExtendedMetaData(key, value); -} - -/*! - Returns a list of keys there is extended meta-data available for. - \since 1.0 -*/ -QStringList QMediaRecorder::availableExtendedMetaData() const -{ - Q_D(const QMediaRecorder); - - return d->metaDataControl - ? d->metaDataControl->availableExtendedMetaData() - : QStringList(); -} - -#include "moc_qmediarecorder.cpp" -QT_END_NAMESPACE - diff --git a/src/multimediakit/qmediarecorder.h b/src/multimediakit/qmediarecorder.h deleted file mode 100644 index 1e99b95c6..000000000 --- a/src/multimediakit/qmediarecorder.h +++ /dev/null @@ -1,197 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QMEDIARECORDER_H -#define QMEDIARECORDER_H - -#include -#include -#include -#include -#include - -#include - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -QT_MODULE(Multimedia) - -class QUrl; -class QSize; -class QAudioFormat; -QT_END_NAMESPACE - -QT_BEGIN_NAMESPACE - -class QMediaRecorderService; -class QAudioEncoderSettings; -class QVideoEncoderSettings; - -class QMediaRecorderPrivate; -class Q_MULTIMEDIA_EXPORT QMediaRecorder : public QObject, public QMediaBindableInterface -{ - Q_OBJECT - Q_INTERFACES(QMediaBindableInterface) - Q_ENUMS(State) - Q_ENUMS(Error) - Q_PROPERTY(qint64 duration READ duration NOTIFY durationChanged) - Q_PROPERTY(QUrl outputLocation READ outputLocation WRITE setOutputLocation) - Q_PROPERTY(bool muted READ isMuted WRITE setMuted NOTIFY mutedChanged) - Q_PROPERTY(bool metaDataAvailable READ isMetaDataAvailable NOTIFY metaDataAvailableChanged) - Q_PROPERTY(bool metaDataWritable READ isMetaDataWritable NOTIFY metaDataWritableChanged) -public: - - enum State - { - StoppedState, - RecordingState, - PausedState - }; - - enum Error - { - NoError, - ResourceError, - FormatError - }; - - QMediaRecorder(QMediaObject *mediaObject, QObject *parent = 0); - ~QMediaRecorder(); - - QMediaObject *mediaObject() const; - - bool isAvailable() const; - QtMultimediaKit::AvailabilityError availabilityError() const; - - QUrl outputLocation() const; - bool setOutputLocation(const QUrl &location); - - State state() const; - - Error error() const; - QString errorString() const; - - qint64 duration() const; - - bool isMuted() const; - - QStringList supportedContainers() const; - QString containerDescription(const QString &containerMimeType) const; - - QStringList supportedAudioCodecs() const; - QString audioCodecDescription(const QString &codecName) const; - - QList supportedAudioSampleRates(const QAudioEncoderSettings &settings = QAudioEncoderSettings(), - bool *continuous = 0) const; - - QStringList supportedVideoCodecs() const; - QString videoCodecDescription(const QString &codecName) const; - - QList supportedResolutions(const QVideoEncoderSettings &settings = QVideoEncoderSettings(), - bool *continuous = 0) const; - - QList supportedFrameRates(const QVideoEncoderSettings &settings = QVideoEncoderSettings(), - bool *continuous = 0) const; - - QAudioEncoderSettings audioSettings() const; - QVideoEncoderSettings videoSettings() const; - QString containerMimeType() const; - - void setEncodingSettings(const QAudioEncoderSettings &audioSettings, - const QVideoEncoderSettings &videoSettings = QVideoEncoderSettings(), - const QString &containerMimeType = QString()); - - - bool isMetaDataAvailable() const; - bool isMetaDataWritable() const; - - QVariant metaData(QtMultimediaKit::MetaData key) const; - void setMetaData(QtMultimediaKit::MetaData key, const QVariant &value); - QList availableMetaData() const; - - QVariant extendedMetaData(const QString &key) const; - void setExtendedMetaData(const QString &key, const QVariant &value); - QStringList availableExtendedMetaData() const; - -public Q_SLOTS: - void record(); - void pause(); - void stop(); - void setMuted(bool muted); - -Q_SIGNALS: - void stateChanged(QMediaRecorder::State state); - void durationChanged(qint64 duration); - void mutedChanged(bool muted); - - void error(QMediaRecorder::Error error); - - void metaDataAvailableChanged(bool available); - void metaDataWritableChanged(bool writable); - void metaDataChanged(); - -protected: - bool setMediaObject(QMediaObject *object); - -private: - QMediaRecorderPrivate *d_ptr; - Q_DISABLE_COPY(QMediaRecorder) - Q_DECLARE_PRIVATE(QMediaRecorder) - Q_PRIVATE_SLOT(d_func(), void _q_stateChanged(QMediaRecorder::State)) - Q_PRIVATE_SLOT(d_func(), void _q_error(int, const QString &)) - Q_PRIVATE_SLOT(d_func(), void _q_serviceDestroyed()) - Q_PRIVATE_SLOT(d_func(), void _q_notify()) - Q_PRIVATE_SLOT(d_func(), void _q_updateNotifyInterval(int)) -}; - -QT_END_NAMESPACE - -Q_DECLARE_METATYPE(QMediaRecorder::State) -Q_DECLARE_METATYPE(QMediaRecorder::Error) - -Q_MEDIA_ENUM_DEBUG(QMediaRecorder, State) -Q_MEDIA_ENUM_DEBUG(QMediaRecorder, Error) - -QT_END_HEADER - -#endif // QMEDIARECORDER_H diff --git a/src/multimediakit/qmediarecordercontrol.cpp b/src/multimediakit/qmediarecordercontrol.cpp deleted file mode 100644 index 1f98d65ac..000000000 --- a/src/multimediakit/qmediarecordercontrol.cpp +++ /dev/null @@ -1,209 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qmediarecordercontrol.h" - -QT_BEGIN_NAMESPACE - - -/*! - \class QMediaRecorderControl - \inmodule QtMultimediaKit - \ingroup multimedia-serv - \since 1.0 - - - \brief The QMediaRecorderControl class provides access to the recording - functionality of a QMediaService. - - If a QMediaService can record media it will implement QMediaRecorderControl. - This control provides a means to set the \l {outputLocation()}{output location}, - and \l {record()}{start}, \l {pause()}{pause} and \l {stop()}{stop} - recording. It also provides feedback on the \l {duration()}{duration} - of the recording. - - The functionality provided by this control is exposed to application - code through the QMediaRecorder class. - - The interface name of QMediaRecorderControl is \c com.nokia.Qt.QMediaRecorderControl/1.0 as - defined in QMediaRecorderControl_iid. - - \sa QMediaService::requestControl(), QMediaRecorder - -*/ - -/*! - \macro QMediaRecorderControl_iid - - \c com.nokia.Qt.QMediaRecorderControl/1.0 - - Defines the interface name of the QMediaRecorderControl class. - - \relates QMediaRecorderControl -*/ - -/*! - Constructs a media recorder control with the given \a parent. -*/ - -QMediaRecorderControl::QMediaRecorderControl(QObject* parent) - : QMediaControl(parent) -{ -} - -/*! - Destroys a media recorder control. -*/ - -QMediaRecorderControl::~QMediaRecorderControl() -{ -} - -/*! - \fn QUrl QMediaRecorderControl::outputLocation() const - - Returns the current output location being used. - \since 1.0 -*/ - -/*! - \fn bool QMediaRecorderControl::setOutputLocation(const QUrl &location) - - Sets the output \a location and returns if this operation is successful. - If file at the output location already exists, it should be overwritten. - - The \a location can be relative or empty; - in this case the service should use the system specific place and file naming scheme. - After recording has stated, QMediaRecorderControl::outputLocation() should return the actual output location. - \since 1.0 -*/ - -/*! - \fn int QMediaRecorderControl::state() const - - Return the current recording state. - \since 1.0 -*/ - -/*! - \fn qint64 QMediaRecorderControl::duration() const - - Return the current duration in milliseconds. - \since 1.0 -*/ - -/*! - \fn void QMediaRecorderControl::record() - - Start recording. - \since 1.0 -*/ - -/*! - \fn void QMediaRecorderControl::pause() - - Pause recording. - \since 1.0 -*/ - -/*! - \fn void QMediaRecorderControl::stop() - - Stop recording. - \since 1.0 -*/ - -/*! - \fn void QMediaRecorderControl::applySettings() - - Commits the encoder settings and performs pre-initialization to reduce delays when recording - is started. - \since 1.0 -*/ - -/*! - \fn bool QMediaRecorderControl::isMuted() const - - Returns true if the recorder is muted, and false if it is not. - \since 1.0 -*/ - -/*! - \fn void QMediaRecorderControl::setMuted(bool muted) - - Sets the \a muted state of a media recorder. - \since 1.0 -*/ - - -/*! - \fn void QMediaRecorderControl::stateChanged(QMediaRecorder::State state) - - Signals that the \a state of a media recorder has changed. - \since 1.0 -*/ - -/*! - \fn void QMediaRecorderControl::durationChanged(qint64 duration) - - Signals that the \a duration of the recorded media has changed. - - This only emitted when there is a discontinuous change in the duration such as being reset to 0. - \since 1.0 -*/ - -/*! - \fn void QMediaRecorderControl::mutedChanged(bool muted) - - Signals that the \a muted state of a media recorder has changed. - \since 1.0 -*/ - -/*! - \fn void QMediaRecorderControl::error(int error, const QString &errorString) - - Signals that an \a error has occurred. The \a errorString describes the error. - \since 1.0 -*/ - -#include "moc_qmediarecordercontrol.cpp" -QT_END_NAMESPACE - diff --git a/src/multimediakit/qmediarecordercontrol.h b/src/multimediakit/qmediarecordercontrol.h deleted file mode 100644 index 26f244c08..000000000 --- a/src/multimediakit/qmediarecordercontrol.h +++ /dev/null @@ -1,101 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QMEDIARECORDERCONTROL_H -#define QMEDIARECORDERCONTROL_H - -#include "qmediacontrol.h" -#include "qmediarecorder.h" - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -QT_MODULE(Multimedia) - -class QUrl; -QT_END_NAMESPACE - -QT_BEGIN_NAMESPACE - -class Q_MULTIMEDIA_EXPORT QMediaRecorderControl : public QMediaControl -{ - Q_OBJECT - -public: - virtual ~QMediaRecorderControl(); - - virtual QUrl outputLocation() const = 0; - virtual bool setOutputLocation(const QUrl &location) = 0; - - virtual QMediaRecorder::State state() const = 0; - - virtual qint64 duration() const = 0; - - virtual bool isMuted() const = 0; - - virtual void applySettings() = 0; - -Q_SIGNALS: - void stateChanged(QMediaRecorder::State state); - void durationChanged(qint64 position); - void mutedChanged(bool muted); - void error(int error, const QString &errorString); - -public Q_SLOTS: - virtual void record() = 0; - virtual void pause() = 0; - virtual void stop() = 0; - virtual void setMuted(bool muted) = 0; - -protected: - QMediaRecorderControl(QObject* parent = 0); -}; - -#define QMediaRecorderControl_iid "com.nokia.Qt.QMediaRecorderControl/1.0" -Q_MEDIA_DECLARE_CONTROL(QMediaRecorderControl, QMediaRecorderControl_iid) - -QT_END_NAMESPACE - -QT_END_HEADER - - -#endif diff --git a/src/multimediakit/qmediaresource.cpp b/src/multimediakit/qmediaresource.cpp deleted file mode 100644 index 84f4e6c68..000000000 --- a/src/multimediakit/qmediaresource.cpp +++ /dev/null @@ -1,440 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qmediaresource.h" - -#include -#include -#include - -QT_BEGIN_NAMESPACE - -/*! - \class QMediaResource - - \brief The QMediaResource class provides a description of a media resource. - \inmodule QtMultimediaKit - \ingroup multimedia - \since 1.0 - - A media resource is composed of a \l {url()}{URL} containing the - location of the resource and a set of properties that describe the - format of the resource. The properties provide a means to assess a - resource without first attempting to load it, and in situations where - media be represented by multiple alternative representations provide a - means to select the appropriate resource. - - Media made available by a remote services can often be available in - multiple encodings or quality levels, this allows a client to select - an appropriate resource based on considerations such as codecs supported, - network bandwidth, and display constraints. QMediaResource includes - information such as the \l {mimeType()}{MIME type}, \l {audioCodec()}{audio} - and \l {videoCodec()}{video} codecs, \l {audioBitRate()}{audio} and - \l {videoBitRate()}{video} bit rates, and \l {resolution()}{resolution} - so these constraints and others can be evaluated. - - The only mandatory property of a QMediaResource is the url(). - - \sa QMediaContent -*/ - -/*! - \typedef QMediaResourceList - - Synonym for \c QList -*/ - -/*! - Constructs a null media resource. -*/ -QMediaResource::QMediaResource() -{ -} - -/*! - Constructs a media resource with the given \a mimeType from a \a url. - \since 1.0 -*/ -QMediaResource::QMediaResource(const QUrl &url, const QString &mimeType) -{ - values.insert(Url, url); - values.insert(MimeType, mimeType); -} - -/*! - Constructs a media resource with the given \a mimeType from a network \a request. - \since 1.0 -*/ -QMediaResource::QMediaResource(const QNetworkRequest &request, const QString &mimeType) -{ - values.insert(Request, QVariant::fromValue(request)); - values.insert(Url, request.url()); - values.insert(MimeType, mimeType); -} - -/*! - Constructs a copy of a media resource \a other. - \since 1.0 -*/ -QMediaResource::QMediaResource(const QMediaResource &other) - : values(other.values) -{ -} - -/*! - Assigns the value of \a other to a media resource. - \since 1.0 -*/ -QMediaResource &QMediaResource::operator =(const QMediaResource &other) -{ - values = other.values; - - return *this; -} - -/*! - Destroys a media resource. -*/ -QMediaResource::~QMediaResource() -{ -} - - -/*! - Compares a media resource to \a other. - - Returns true if the resources are identical, and false otherwise. - \since 1.0 -*/ -bool QMediaResource::operator ==(const QMediaResource &other) const -{ - // Compare requests directly as QNetworkRequests are "custom types". - foreach (int key, values.keys()) { - switch (key) { - case Request: - if (request() != other.request()) - return false; - break; - default: - if (values.value(key) != other.values.value(key)) - return false; - } - } - return true; -} - -/*! - Compares a media resource to \a other. - - Returns true if they are different, and false otherwise. - \since 1.0 -*/ -bool QMediaResource::operator !=(const QMediaResource &other) const -{ - return !(*this == other); -} - -/*! - Identifies if a media resource is null. - - Returns true if the resource is null, and false otherwise. - \since 1.0 -*/ -bool QMediaResource::isNull() const -{ - return values.isEmpty(); -} - -/*! - Returns the URL of a media resource. - \since 1.0 -*/ -QUrl QMediaResource::url() const -{ - return qvariant_cast(values.value(Url)); -} - -/*! - Returns the network request associated with this media resource. - \since 1.0 -*/ -QNetworkRequest QMediaResource::request() const -{ - if(values.contains(Request)) - return qvariant_cast(values.value(Request)); - - return QNetworkRequest(url()); -} - -/*! - Returns the MIME type of a media resource. - - This may be null if the MIME type is unknown. - \since 1.0 -*/ -QString QMediaResource::mimeType() const -{ - return qvariant_cast(values.value(MimeType)); -} - -/*! - Returns the language of a media resource as an ISO 639-2 code. - - This may be null if the language is unknown. - \since 1.0 -*/ -QString QMediaResource::language() const -{ - return qvariant_cast(values.value(Language)); -} - -/*! - Sets the \a language of a media resource. - \since 1.0 -*/ -void QMediaResource::setLanguage(const QString &language) -{ - if (!language.isNull()) - values.insert(Language, language); - else - values.remove(Language); -} - -/*! - Returns the audio codec of a media resource. - - This may be null if the media resource does not contain an audio stream, or the codec is - unknown. - \since 1.0 -*/ -QString QMediaResource::audioCodec() const -{ - return qvariant_cast(values.value(AudioCodec)); -} - -/*! - Sets the audio \a codec of a media resource. - \since 1.0 -*/ -void QMediaResource::setAudioCodec(const QString &codec) -{ - if (!codec.isNull()) - values.insert(AudioCodec, codec); - else - values.remove(AudioCodec); -} - -/*! - Returns the video codec of a media resource. - - This may be null if the media resource does not contain a video stream, or the codec is - unknonwn. - \since 1.0 -*/ -QString QMediaResource::videoCodec() const -{ - return qvariant_cast(values.value(VideoCodec)); -} - -/*! - Sets the video \a codec of media resource. - \since 1.0 -*/ -void QMediaResource::setVideoCodec(const QString &codec) -{ - if (!codec.isNull()) - values.insert(VideoCodec, codec); - else - values.remove(VideoCodec); -} - -/*! - Returns the size in bytes of a media resource. - - This may be zero if the size is unknown. - \since 1.0 -*/ -qint64 QMediaResource::dataSize() const -{ - return qvariant_cast(values.value(DataSize)); -} - -/*! - Sets the \a size in bytes of a media resource. - \since 1.0 -*/ -void QMediaResource::setDataSize(const qint64 size) -{ - if (size != 0) - values.insert(DataSize, size); - else - values.remove(DataSize); -} - -/*! - Returns the bit rate in bits per second of a media resource's audio stream. - - This may be zero if the bit rate is unknown, or the resource contains no audio stream. - \since 1.0 -*/ -int QMediaResource::audioBitRate() const -{ - return values.value(AudioBitRate).toInt(); -} - -/*! - Sets the bit \a rate in bits per second of a media resource's video stream. - \since 1.0 -*/ -void QMediaResource::setAudioBitRate(int rate) -{ - if (rate != 0) - values.insert(AudioBitRate, rate); - else - values.remove(AudioBitRate); -} - -/*! - Returns the audio sample rate of a media resource. - - This may be zero if the sample size is unknown, or the resource contains no audio stream. - \since 1.0 -*/ -int QMediaResource::sampleRate() const -{ - return qvariant_cast(values.value(SampleRate)); -} - -/*! - Sets the audio \a sampleRate of a media resource. - \since 1.0 -*/ -void QMediaResource::setSampleRate(int sampleRate) -{ - if (sampleRate != 0) - values.insert(SampleRate, sampleRate); - else - values.remove(SampleRate); -} - -/*! - Returns the number of audio channels in a media resource. - - This may be zero if the sample size is unknown, or the resource contains no audio stream. - \since 1.0 -*/ -int QMediaResource::channelCount() const -{ - return qvariant_cast(values.value(ChannelCount)); -} - -/*! - Sets the number of audio \a channels in a media resource. - \since 1.0 -*/ -void QMediaResource::setChannelCount(int channels) -{ - if (channels != 0) - values.insert(ChannelCount, channels); - else - values.remove(ChannelCount); -} - -/*! - Returns the bit rate in bits per second of a media resource's video stream. - - This may be zero if the bit rate is unknown, or the resource contains no video stream. - \since 1.0 -*/ -int QMediaResource::videoBitRate() const -{ - return values.value(VideoBitRate).toInt(); -} - -/*! - Sets the bit \a rate in bits per second of a media resource's video stream. - \since 1.0 -*/ -void QMediaResource::setVideoBitRate(int rate) -{ - if (rate != 0) - values.insert(VideoBitRate, rate); - else - values.remove(VideoBitRate); -} - -/*! - Returns the resolution in pixels of a media resource. - - This may be null is the resolution is unknown, or the resource contains no pixel data (i.e. the - resource is an audio stream. - \since 1.0 -*/ -QSize QMediaResource::resolution() const -{ - return qvariant_cast(values.value(Resolution)); -} - -/*! - Sets the \a resolution in pixels of a media resource. - \since 1.0 -*/ -void QMediaResource::setResolution(const QSize &resolution) -{ - if (resolution.width() != -1 || resolution.height() != -1) - values.insert(Resolution, resolution); - else - values.remove(Resolution); -} - -/*! - Sets the \a width and \a height in pixels of a media resource. - \since 1.0 -*/ -void QMediaResource::setResolution(int width, int height) -{ - if (width != -1 || height != -1) - values.insert(Resolution, QSize(width, height)); - else - values.remove(Resolution); -} -QT_END_NAMESPACE - diff --git a/src/multimediakit/qmediaresource.h b/src/multimediakit/qmediaresource.h deleted file mode 100644 index 02469e04c..000000000 --- a/src/multimediakit/qmediaresource.h +++ /dev/null @@ -1,134 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QMEDIARESOURCE_H -#define QMEDIARESOURCE_H - -#include -#include -#include - -#include - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -QT_MODULE(Multimedia) - - -class Q_MULTIMEDIA_EXPORT QMediaResource -{ -public: - QMediaResource(); - QMediaResource(const QUrl &url, const QString &mimeType = QString()); - QMediaResource(const QNetworkRequest &request, const QString &mimeType = QString()); - QMediaResource(const QMediaResource &other); - QMediaResource &operator =(const QMediaResource &other); - ~QMediaResource(); - - bool isNull() const; - - bool operator ==(const QMediaResource &other) const; - bool operator !=(const QMediaResource &other) const; - - QUrl url() const; - QNetworkRequest request() const; - QString mimeType() const; - - QString language() const; - void setLanguage(const QString &language); - - QString audioCodec() const; - void setAudioCodec(const QString &codec); - - QString videoCodec() const; - void setVideoCodec(const QString &codec); - - qint64 dataSize() const; - void setDataSize(const qint64 size); - - int audioBitRate() const; - void setAudioBitRate(int rate); - - int sampleRate() const; - void setSampleRate(int frequency); - - int channelCount() const; - void setChannelCount(int channels); - - int videoBitRate() const; - void setVideoBitRate(int rate); - - QSize resolution() const; - void setResolution(const QSize &resolution); - void setResolution(int width, int height); - - -private: - enum Property - { - Url, - Request, - MimeType, - Language, - AudioCodec, - VideoCodec, - DataSize, - AudioBitRate, - VideoBitRate, - SampleRate, - ChannelCount, - Resolution - }; - QMap values; -}; - -typedef QList QMediaResourceList; - -QT_END_NAMESPACE - -Q_DECLARE_METATYPE(QMediaResource) -Q_DECLARE_METATYPE(QMediaResourceList) - -QT_END_HEADER - -#endif diff --git a/src/multimediakit/qmediaservice.cpp b/src/multimediakit/qmediaservice.cpp deleted file mode 100644 index 1a7fca360..000000000 --- a/src/multimediakit/qmediaservice.cpp +++ /dev/null @@ -1,151 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qmediaservice.h" -#include "qmediaservice_p.h" - -#include - - - -QT_BEGIN_NAMESPACE - - -/*! - \class QMediaService - \brief The QMediaService class provides a common base class for media - service implementations. - \inmodule QtMultimediaKit - \ingroup multimedia-serv - \since 1.0 - - - Media services provide implementations of the functionality promised - by media objects, and allow multiple providers to implement a QMediaObject. - - To provide the functionality of a QMediaObject media services implement - QMediaControl interfaces. Services typically implement one core media - control which provides the core feature of a media object, and some - number of additional controls which provide either optional features of - the media object, or features of a secondary media object or peripheral - object. - - A pointer to media service's QMediaControl implementation can be obtained - by passing the control's interface name to the requestControl() function. - - \snippet doc/src/snippets/multimedia-snippets/media.cpp Request control - - Media objects can use services loaded dynamically from plug-ins or - implemented statically within an applications. Plug-in based services - should also implement the QMediaServiceProviderPlugin interface. Static - services should implement the QMediaServiceProvider interface. - - \sa QMediaObject, QMediaControl, QMediaServiceProvider, QMediaServiceProviderPlugin -*/ - -/*! - Construct a media service with the given \a parent. This class is meant as a - base class for Multimedia services so this constructor is protected. -*/ - -QMediaService::QMediaService(QObject *parent) - : QObject(parent) - , d_ptr(new QMediaServicePrivate) -{ - d_ptr->q_ptr = this; -} - -/*! - \internal -*/ -QMediaService::QMediaService(QMediaServicePrivate &dd, QObject *parent) - : QObject(parent) - , d_ptr(&dd) -{ - d_ptr->q_ptr = this; -} - -/*! - Destroys a media service. -*/ - -QMediaService::~QMediaService() -{ - delete d_ptr; -} - -/*! - \fn QMediaControl* QMediaService::requestControl(const char *interface) - - Returns a pointer to the media control implementing \a interface. - - If the service does not implement the control, or if it is unavailable a - null pointer is returned instead. - - Controls must be returned to the service when no longer needed using the - releaseControl() function. - \since 1.0 -*/ - -/*! - \fn T QMediaService::requestControl() - - Returns a pointer to the media control of type T implemented by a media service. - - If the service does not implement the control, or if it is unavailable a - null pointer is returned instead. - - Controls must be returned to the service when no longer needed using the - releaseControl() function. - \since 1.0 -*/ - -/*! - \fn void QMediaService::releaseControl(QMediaControl *control); - - Releases a \a control back to the service. - \since 1.0 -*/ - -#include "moc_qmediaservice.cpp" - -QT_END_NAMESPACE - diff --git a/src/multimediakit/qmediaservice.h b/src/multimediakit/qmediaservice.h deleted file mode 100644 index 7bf90ba4f..000000000 --- a/src/multimediakit/qmediaservice.h +++ /dev/null @@ -1,97 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QABSTRACTMEDIASERVICE_H -#define QABSTRACTMEDIASERVICE_H - -#include -#include -#include - -#include "qmediacontrol.h" - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -QT_MODULE(Multimedia) - - -class QMediaServicePrivate; -class Q_MULTIMEDIA_EXPORT QMediaService : public QObject -{ - Q_OBJECT - -public: - ~QMediaService(); - - virtual QMediaControl* requestControl(const char *name) = 0; - -#ifndef QT_NO_MEMBER_TEMPLATES - template inline T requestControl() { - if (QMediaControl *control = requestControl(qmediacontrol_iid())) { - if (T typedControl = qobject_cast(control)) - return typedControl; - releaseControl(control); - } - return 0; - } -#endif - - virtual void releaseControl(QMediaControl *control) = 0; - -protected: - QMediaService(QObject* parent); - QMediaService(QMediaServicePrivate &dd, QObject *parent); - - QMediaServicePrivate *d_ptr; - -private: - Q_DECLARE_PRIVATE(QMediaService) -}; - -QT_END_NAMESPACE - -QT_END_HEADER - - -#endif // QABSTRACTMEDIASERVICE_H - diff --git a/src/multimediakit/qmediaservice_p.h b/src/multimediakit/qmediaservice_p.h deleted file mode 100644 index 83fd7287f..000000000 --- a/src/multimediakit/qmediaservice_p.h +++ /dev/null @@ -1,80 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QABSTRACTMEDIASERVICE_P_H -#define QABSTRACTMEDIASERVICE_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. -// - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -QT_MODULE(Multimedia) - - -class QAudioDeviceControl; - -class QMediaServicePrivate -{ -public: - QMediaServicePrivate(): q_ptr(0) {} - virtual ~QMediaServicePrivate() {} - - QMediaService *q_ptr; -}; - -QT_END_NAMESPACE - -QT_END_HEADER - - - -#endif diff --git a/src/multimediakit/qmediaserviceprovider.cpp b/src/multimediakit/qmediaserviceprovider.cpp deleted file mode 100644 index 33ed3fbbd..000000000 --- a/src/multimediakit/qmediaserviceprovider.cpp +++ /dev/null @@ -1,783 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include -#include - -#include "qmediaservice.h" -#include "qmediaserviceprovider.h" -#include "qmediaserviceproviderplugin.h" -#include "qmediapluginloader_p.h" -#include "qmediaplayer.h" - -QT_BEGIN_NAMESPACE - -class QMediaServiceProviderHintPrivate : public QSharedData -{ -public: - QMediaServiceProviderHintPrivate(QMediaServiceProviderHint::Type type) - :type(type), features(0) - { - } - - QMediaServiceProviderHintPrivate(const QMediaServiceProviderHintPrivate &other) - :QSharedData(other), - type(other.type), - device(other.device), - mimeType(other.mimeType), - codecs(other.codecs), - features(other.features) - { - } - - ~QMediaServiceProviderHintPrivate() - { - } - - QMediaServiceProviderHint::Type type; - QByteArray device; - QString mimeType; - QStringList codecs; - QMediaServiceProviderHint::Features features; -}; - -/*! - \class QMediaServiceProviderHint - - \brief The QMediaServiceProviderHint class describes what is required of a QMediaService. - - \inmodule QtMultimediaKit - \ingroup multimedia-serv - \since 1.0 - - The QMediaServiceProvider class uses hints to select an appropriate media service. -*/ - -/*! - \enum QMediaServiceProviderHint::Feature - - Enumerates features a media service may provide. - - \value LowLatencyPlayback - The service is expected to play simple audio formats, - but playback should start without significant delay. - Such playback service can be used for beeps, ringtones, etc. - - \value RecordingSupport - The service provides audio or video recording functions. - - \value StreamPlayback - The service is capable of playing QIODevice based streams. - - \value VideoSurface - The service is capable of renderering to a QAbstractVideoSurface - output. - - \value BackgroundPlayback - The service is capable of doing playback in the background -*/ - -/*! - \enum QMediaServiceProviderHint::Type - - Enumerates the possible types of media service provider hint. - - \value Null En empty hint, use the default service. - \value ContentType Select media service most suitable for certain content type. - \value Device Select media service which supports certain device. - \value SupportedFeatures Select media service supporting the set of optional features. -*/ - - -/*! - Constructs an empty media service provider hint. -*/ -QMediaServiceProviderHint::QMediaServiceProviderHint() - :d(new QMediaServiceProviderHintPrivate(Null)) -{ -} - -/*! - Constructs a ContentType media service provider hint. - - This type of hint describes a service that is able to play content of a specific MIME \a type - encoded with one or more of the listed \a codecs. - \since 1.0 -*/ -QMediaServiceProviderHint::QMediaServiceProviderHint(const QString &type, const QStringList& codecs) - :d(new QMediaServiceProviderHintPrivate(ContentType)) -{ - d->mimeType = type; - d->codecs = codecs; -} - -/*! - Constructs a Device media service provider hint. - - This type of hint describes a media service that utilizes a specific \a device. - \since 1.0 -*/ -QMediaServiceProviderHint::QMediaServiceProviderHint(const QByteArray &device) - :d(new QMediaServiceProviderHintPrivate(Device)) -{ - d->device = device; -} - -/*! - Constructs a SupportedFeatures media service provider hint. - - This type of hint describes a service which supports a specific set of \a features. - \since 1.0 -*/ -QMediaServiceProviderHint::QMediaServiceProviderHint(QMediaServiceProviderHint::Features features) - :d(new QMediaServiceProviderHintPrivate(SupportedFeatures)) -{ - d->features = features; -} - -/*! - Constructs a copy of the media service provider hint \a other. - \since 1.0 -*/ -QMediaServiceProviderHint::QMediaServiceProviderHint(const QMediaServiceProviderHint &other) - :d(other.d) -{ -} - -/*! - Destroys a media service provider hint. -*/ -QMediaServiceProviderHint::~QMediaServiceProviderHint() -{ -} - -/*! - Assigns the value \a other to a media service provider hint. - \since 1.0 -*/ -QMediaServiceProviderHint& QMediaServiceProviderHint::operator=(const QMediaServiceProviderHint &other) -{ - d = other.d; - return *this; -} - -/*! - Identifies if \a other is of equal value to a media service provider hint. - - Returns true if the hints are equal, and false if they are not. - \since 1.0 -*/ -bool QMediaServiceProviderHint::operator == (const QMediaServiceProviderHint &other) const -{ - return (d == other.d) || - (d->type == other.d->type && - d->device == other.d->device && - d->mimeType == other.d->mimeType && - d->codecs == other.d->codecs && - d->features == other.d->features); -} - -/*! - Identifies if \a other is not of equal value to a media service provider hint. - - Returns true if the hints are not equal, and false if they are. - \since 1.0 -*/ -bool QMediaServiceProviderHint::operator != (const QMediaServiceProviderHint &other) const -{ - return !(*this == other); -} - -/*! - Returns true if a media service provider is null. - \since 1.0 -*/ -bool QMediaServiceProviderHint::isNull() const -{ - return d->type == Null; -} - -/*! - Returns the type of a media service provider hint. - \since 1.0 -*/ -QMediaServiceProviderHint::Type QMediaServiceProviderHint::type() const -{ - return d->type; -} - -/*! - Returns the mime type of the media a service is expected to be able play. - \since 1.0 -*/ -QString QMediaServiceProviderHint::mimeType() const -{ - return d->mimeType; -} - -/*! - Returns a list of codes a media service is expected to be able to decode. - \since 1.0 -*/ -QStringList QMediaServiceProviderHint::codecs() const -{ - return d->codecs; -} - -/*! - Returns the name of a device a media service is expected to utilize. - \since 1.0 -*/ -QByteArray QMediaServiceProviderHint::device() const -{ - return d->device; -} - -/*! - Returns a set of features a media service is expected to provide. - \since 1.0 -*/ -QMediaServiceProviderHint::Features QMediaServiceProviderHint::features() const -{ - return d->features; -} - - -Q_GLOBAL_STATIC_WITH_ARGS(QMediaPluginLoader, loader, - (QMediaServiceProviderFactoryInterface_iid, QLatin1String("mediaservice"), Qt::CaseInsensitive)) - - -class QPluginServiceProvider : public QMediaServiceProvider -{ - QMap pluginMap; - -public: - QMediaService* requestService(const QByteArray &type, const QMediaServiceProviderHint &hint) - { - QString key(QLatin1String(type.constData())); - - QListplugins; - foreach (QObject *obj, loader()->instances(key)) { - QMediaServiceProviderPlugin *plugin = - qobject_cast(obj); - if (plugin) - plugins << plugin; - } - - if (!plugins.isEmpty()) { - QMediaServiceProviderPlugin *plugin = 0; - - switch (hint.type()) { - case QMediaServiceProviderHint::Null: - plugin = plugins[0]; - //special case for media player, if low latency was not asked, - //prefer services not offering it, since they are likely to support - //more formats - if (type == QByteArray(Q_MEDIASERVICE_MEDIAPLAYER)) { - foreach (QMediaServiceProviderPlugin *currentPlugin, plugins) { - QMediaServiceFeaturesInterface *iface = - qobject_cast(currentPlugin); - - if (!iface || !(iface->supportedFeatures(type) & - QMediaServiceProviderHint::LowLatencyPlayback)) { - plugin = currentPlugin; - break; - } - - } - } - break; - case QMediaServiceProviderHint::SupportedFeatures: - plugin = plugins[0]; - foreach (QMediaServiceProviderPlugin *currentPlugin, plugins) { - QMediaServiceFeaturesInterface *iface = - qobject_cast(currentPlugin); - - if (iface) { - if ((iface->supportedFeatures(type) & hint.features()) == hint.features()) { - plugin = currentPlugin; - break; - } - } - } - break; - case QMediaServiceProviderHint::Device: { - foreach (QMediaServiceProviderPlugin *currentPlugin, plugins) { - QMediaServiceSupportedDevicesInterface *iface = - qobject_cast(currentPlugin); - - if (!iface) { - // the plugin may support the device, - // but this choice still can be overridden - plugin = currentPlugin; - } else { - if (iface->devices(type).contains(hint.device())) { - plugin = currentPlugin; - break; - } - } - } - } - break; - case QMediaServiceProviderHint::ContentType: { - QtMultimediaKit::SupportEstimate estimate = QtMultimediaKit::NotSupported; - foreach (QMediaServiceProviderPlugin *currentPlugin, plugins) { - QtMultimediaKit::SupportEstimate currentEstimate = QtMultimediaKit::MaybeSupported; - QMediaServiceSupportedFormatsInterface *iface = - qobject_cast(currentPlugin); - - if (iface) - currentEstimate = iface->hasSupport(hint.mimeType(), hint.codecs()); - - if (currentEstimate > estimate) { - estimate = currentEstimate; - plugin = currentPlugin; - - if (currentEstimate == QtMultimediaKit::PreferredService) - break; - } - } - } - break; - } - - if (plugin != 0) { - QMediaService *service = plugin->create(key); - if (service != 0) - pluginMap.insert(service, plugin); - - return service; - } - } - - qWarning() << "defaultServiceProvider::requestService(): no service found for -" << key; - return 0; - } - - void releaseService(QMediaService *service) - { - if (service != 0) { - QMediaServiceProviderPlugin *plugin = pluginMap.take(service); - - if (plugin != 0) - plugin->release(service); - } - } - - QtMultimediaKit::SupportEstimate hasSupport(const QByteArray &serviceType, - const QString &mimeType, - const QStringList& codecs, - int flags) const - { - QList instances = loader()->instances(QLatin1String(serviceType)); - - if (instances.isEmpty()) - return QtMultimediaKit::NotSupported; - - bool allServicesProvideInterface = true; - QtMultimediaKit::SupportEstimate supportEstimate = QtMultimediaKit::NotSupported; - - foreach(QObject *obj, instances) { - QMediaServiceSupportedFormatsInterface *iface = - qobject_cast(obj); - - - if (flags) { - QMediaServiceFeaturesInterface *iface = - qobject_cast(obj); - - if (iface) { - QMediaServiceProviderHint::Features features = iface->supportedFeatures(serviceType); - - //if low latency playback was asked, skip services known - //not to provide low latency playback - if ((flags & QMediaPlayer::LowLatency) && - !(features & QMediaServiceProviderHint::LowLatencyPlayback)) - continue; - - //the same for QIODevice based streams support - if ((flags & QMediaPlayer::StreamPlayback) && - !(features & QMediaServiceProviderHint::StreamPlayback)) - continue; - } - } - - if (iface) - supportEstimate = qMax(supportEstimate, iface->hasSupport(mimeType, codecs)); - else - allServicesProvideInterface = false; - } - - //don't return PreferredService - supportEstimate = qMin(supportEstimate, QtMultimediaKit::ProbablySupported); - - //Return NotSupported only if no services are available of serviceType - //or all the services returned NotSupported, otherwise return at least MaybeSupported - if (!allServicesProvideInterface) - supportEstimate = qMax(QtMultimediaKit::MaybeSupported, supportEstimate); - - return supportEstimate; - } - - QStringList supportedMimeTypes(const QByteArray &serviceType, int flags) const - { - QList instances = loader()->instances(QLatin1String(serviceType)); - - QStringList supportedTypes; - - foreach(QObject *obj, instances) { - QMediaServiceSupportedFormatsInterface *iface = - qobject_cast(obj); - - - if (flags) { - QMediaServiceFeaturesInterface *iface = - qobject_cast(obj); - - if (iface) { - QMediaServiceProviderHint::Features features = iface->supportedFeatures(serviceType); - - // If low latency playback was asked for, skip MIME types from services known - // not to provide low latency playback - if ((flags & QMediaPlayer::LowLatency) && - !(features & QMediaServiceProviderHint::LowLatencyPlayback)) - continue; - - //the same for QIODevice based streams support - if ((flags & QMediaPlayer::StreamPlayback) && - !(features & QMediaServiceProviderHint::StreamPlayback)) - continue; - - //the same for QAbstractVideoSurface support - if ((flags & QMediaPlayer::VideoSurface) && - !(features & QMediaServiceProviderHint::VideoSurface)) - continue; - } - } - - if (iface) { - supportedTypes << iface->supportedMimeTypes(); - } - } - - // Multiple services may support the same MIME type - supportedTypes.removeDuplicates(); - - return supportedTypes; - } - - QList devices(const QByteArray &serviceType) const - { - QList res; - - foreach (QObject *obj, loader()->instances(QLatin1String(serviceType))) { - QMediaServiceSupportedDevicesInterface *iface = - qobject_cast(obj); - - if (iface) { - res.append(iface->devices(serviceType)); - } - } - - return res; - } - - QString deviceDescription(const QByteArray &serviceType, const QByteArray &device) - { - foreach (QObject *obj, loader()->instances(QLatin1String(serviceType))) { - QMediaServiceSupportedDevicesInterface *iface = - qobject_cast(obj); - - if (iface) { - if (iface->devices(serviceType).contains(device)) - return iface->deviceDescription(serviceType, device); - } - } - - return QString(); - } -}; - -Q_GLOBAL_STATIC(QPluginServiceProvider, pluginProvider); - -/*! - \class QMediaServiceProvider - - \brief The QMediaServiceProvider class provides an abstract allocator for media services. - \since 1.0 -*/ - -/*! - \fn QMediaServiceProvider::requestService(const QByteArray &type, const QMediaServiceProviderHint &hint) - - Requests an instance of a \a type service which best matches the given \a - hint. - - Returns a pointer to the requested service, or a null pointer if there is - no suitable service. - - The returned service must be released with releaseService when it is - finished with. - \since 1.0 -*/ - -/*! - \fn QMediaServiceProvider::releaseService(QMediaService *service) - - Releases a media \a service requested with requestService(). - \since 1.0 -*/ - -/*! - \fn QtMultimediaKit::SupportEstimate QMediaServiceProvider::hasSupport(const QByteArray &serviceType, const QString &mimeType, const QStringList& codecs, int flags) const - - Returns how confident a media service provider is that is can provide a \a - serviceType service that is able to play media of a specific \a mimeType - that is encoded using the listed \a codecs while adhering to constraints - identified in \a flags. - \since 1.0 -*/ -QtMultimediaKit::SupportEstimate QMediaServiceProvider::hasSupport(const QByteArray &serviceType, - const QString &mimeType, - const QStringList& codecs, - int flags) const -{ - Q_UNUSED(serviceType); - Q_UNUSED(mimeType); - Q_UNUSED(codecs); - Q_UNUSED(flags); - - return QtMultimediaKit::MaybeSupported; -} - -/*! - \fn QStringList QMediaServiceProvider::supportedMimeTypes(const QByteArray &serviceType, int flags) const - - Returns a list of MIME types supported by the service provider for the - specified \a serviceType. - - The resultant list is restricted to MIME types which can be supported given - the constraints in \a flags. - \since 1.0 -*/ -QStringList QMediaServiceProvider::supportedMimeTypes(const QByteArray &serviceType, int flags) const -{ - Q_UNUSED(serviceType); - Q_UNUSED(flags); - - return QStringList(); -} - -/*! - Returns the list of devices related to \a service type. - \since 1.0 -*/ -QList QMediaServiceProvider::devices(const QByteArray &service) const -{ - Q_UNUSED(service); - return QList(); -} - -/*! - Returns the description of \a device related to \a serviceType, suitable for use by - an application for display. - \since 1.0 -*/ -QString QMediaServiceProvider::deviceDescription(const QByteArray &serviceType, const QByteArray &device) -{ - Q_UNUSED(serviceType); - Q_UNUSED(device); - return QString(); -} - - -#ifdef QT_BUILD_INTERNAL - -static QMediaServiceProvider *qt_defaultMediaServiceProvider = 0; - -/*! - Sets a media service \a provider as the default. - - \internal - \since 1.0 -*/ -void QMediaServiceProvider::setDefaultServiceProvider(QMediaServiceProvider *provider) -{ - qt_defaultMediaServiceProvider = provider; -} - -#endif - -/*! - Returns a default provider of media services. -*/ -QMediaServiceProvider *QMediaServiceProvider::defaultServiceProvider() -{ -#ifdef QT_BUILD_INTERNAL - return qt_defaultMediaServiceProvider != 0 - ? qt_defaultMediaServiceProvider - : static_cast(pluginProvider()); -#else - return pluginProvider(); -#endif -} - -/*! - \class QMediaServiceProviderPlugin - - \brief The QMediaServiceProviderPlugin class interface provides an interface for QMediaService - plug-ins. - \since 1.0 - - A media service provider plug-in may implement one or more of - QMediaServiceSupportedFormatsInterface, - QMediaServiceSupportedDevicesInterface, and QMediaServiceFeaturesInterface - to identify the features it supports. -*/ - -/*! - \fn QMediaServiceProviderPlugin::keys() const - - Returns a list of keys for media services a plug-in can create. - \since 1.0 -*/ - -/*! - \fn QMediaServiceProviderPlugin::create(const QString &key) - - Constructs a new instance of the QMediaService identified by \a key. - - The QMediaService returned must be destroyed with release(). - \since 1.0 -*/ - -/*! - \fn QMediaServiceProviderPlugin::release(QMediaService *service) - - Destroys a media \a service constructed with create(). - \since 1.0 -*/ - - -/*! - \class QMediaServiceSupportedFormatsInterface - \brief The QMediaServiceSupportedFormatsInterface class interface - identifies if a media service plug-in supports a media format. - \since 1.0 - - A QMediaServiceProviderPlugin may implement this interface. -*/ - -/*! - \fn QMediaServiceSupportedFormatsInterface::~QMediaServiceSupportedFormatsInterface() - - Destroys a media service supported formats interface. -*/ - -/*! - \fn QMediaServiceSupportedFormatsInterface::hasSupport(const QString &mimeType, const QStringList& codecs) const - - Returns the level of support a media service plug-in has for a \a mimeType - and set of \a codecs. - \since 1.0 -*/ - -/*! - \fn QMediaServiceSupportedFormatsInterface::supportedMimeTypes() const - - Returns a list of MIME types supported by the media service plug-in. - \since 1.0 -*/ - -/*! - \class QMediaServiceSupportedDevicesInterface - \brief The QMediaServiceSupportedDevicesInterface class interface - identifies the devices supported by a media service plug-in. - \since 1.0 - - A QMediaServiceProviderPlugin may implement this interface. -*/ - -/*! - \fn QMediaServiceSupportedDevicesInterface::~QMediaServiceSupportedDevicesInterface() - - Destroys a media service supported devices interface. -*/ - -/*! - \fn QMediaServiceSupportedDevicesInterface::devices(const QByteArray &service) const - - Returns a list of devices supported by a plug-in \a service. - \since 1.0 -*/ - -/*! - \fn QMediaServiceSupportedDevicesInterface::deviceDescription(const QByteArray &service, const QByteArray &device) - - Returns a description of a \a device supported by a plug-in \a service. - \since 1.0 -*/ - -/*! - \class QMediaServiceFeaturesInterface - \brief The QMediaServiceFeaturesInterface class interface identifies - features supported by a media service plug-in. - \since 1.0 - - A QMediaServiceProviderPlugin may implement this interface. -*/ - -/*! - \fn QMediaServiceFeaturesInterface::~QMediaServiceFeaturesInterface() - - Destroys a media service features interface. -*/ -/*! - \fn QMediaServiceFeaturesInterface::supportedFeatures(const QByteArray &service) const - - Returns a set of features supported by a plug-in \a service. - \since 1.0 -*/ - -#include "moc_qmediaserviceprovider.cpp" -#include "moc_qmediaserviceproviderplugin.cpp" -QT_END_NAMESPACE - diff --git a/src/multimediakit/qmediaserviceprovider.h b/src/multimediakit/qmediaserviceprovider.h deleted file mode 100644 index 01a7e3461..000000000 --- a/src/multimediakit/qmediaserviceprovider.h +++ /dev/null @@ -1,186 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QMEDIASERVICEPROVIDER_H -#define QMEDIASERVICEPROVIDER_H - -#include -#include -#include -#include "qtmedianamespace.h" - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -QT_MODULE(Multimedia) - - -class QMediaService; - -class QMediaServiceProviderHintPrivate; -class Q_MULTIMEDIA_EXPORT QMediaServiceProviderHint -{ -public: - enum Type { Null, ContentType, Device, SupportedFeatures }; - - enum Feature { - LowLatencyPlayback = 0x01, - RecordingSupport = 0x02, - StreamPlayback = 0x04, - VideoSurface = 0x08, - BackgroundPlayback = 0x10, - }; - Q_DECLARE_FLAGS(Features, Feature) - - QMediaServiceProviderHint(); - QMediaServiceProviderHint(const QString &mimeType, const QStringList& codecs); - QMediaServiceProviderHint(const QByteArray &device); - QMediaServiceProviderHint(Features features); - QMediaServiceProviderHint(const QMediaServiceProviderHint &other); - ~QMediaServiceProviderHint(); - - QMediaServiceProviderHint& operator=(const QMediaServiceProviderHint &other); - - bool operator == (const QMediaServiceProviderHint &other) const; - bool operator != (const QMediaServiceProviderHint &other) const; - - bool isNull() const; - - Type type() const; - - QString mimeType() const; - QStringList codecs() const; - - QByteArray device() const; - - Features features() const; - - //to be extended, if necessary - -private: - QSharedDataPointer d; -}; - -Q_DECLARE_OPERATORS_FOR_FLAGS(QMediaServiceProviderHint::Features) - -class Q_MULTIMEDIA_EXPORT QMediaServiceProvider : public QObject -{ - Q_OBJECT - -public: - virtual QMediaService* requestService(const QByteArray &type, const QMediaServiceProviderHint &hint = QMediaServiceProviderHint()) = 0; - virtual void releaseService(QMediaService *service) = 0; - - virtual QtMultimediaKit::SupportEstimate hasSupport(const QByteArray &serviceType, - const QString &mimeType, - const QStringList& codecs, - int flags = 0) const; - virtual QStringList supportedMimeTypes(const QByteArray &serviceType, int flags = 0) const; - - virtual QList devices(const QByteArray &serviceType) const; - virtual QString deviceDescription(const QByteArray &serviceType, const QByteArray &device); - - static QMediaServiceProvider* defaultServiceProvider(); - -#ifdef QT_BUILD_INTERNAL - static void setDefaultServiceProvider(QMediaServiceProvider *provider); -#endif -}; - -/*! - Service with support for media playback - Required Controls: QMediaPlayerControl - Optional Controls: QMediaPlaylistControl, QAudioDeviceControl - Video Output Controls (used by QWideoWidget and QGraphicsVideoItem): - Required: QVideoOutputControl - Optional: QVideoWindowControl, QVideoRendererControl, QVideoWidgetControl -*/ -#define Q_MEDIASERVICE_MEDIAPLAYER "com.nokia.qt.mediaplayer" - -/*! - Service with support for background media playback - Required Controls: QMediaPlayerControl, QMediaBackgroundPlaybackControl - Optional Controls: QMediaPlaylistControl, QAudioDeviceControl -*/ -#define Q_MEDIASERVICE_BACKGROUNDMEDIAPLAYER "com.nokia.qt.backgroundmediaplayer" - -/*! - Service with support for recording from audio sources - Required Controls: QAudioDeviceControl - Recording Controls (QMediaRecorder): - Required: QMediaRecorderControl - Recommended: QAudioEncoderControl - Optional: QMediaContainerControl -*/ -#define Q_MEDIASERVICE_AUDIOSOURCE "com.nokia.qt.audiosource" - -/*! - Service with support for camera use. - Required Controls: QCameraControl - Optional Controls: QCameraExposureControl, QCameraFocusControl, QCameraImageProcessingControl - Still Capture Controls: QCameraImageCaptureControl - Video Capture Controls (QMediaRecorder): - Required: QMediaRecorderControl - Recommended: QAudioEncoderControl, QVideoEncoderControl, QMediaContainerControl - Viewfinder Video Output Controls (used by QCameraViewfinder and QGraphicsVideoItem): - Required: QVideoOutputControl - Optional: QVideoWindowControl, QVideoRendererControl, QVideoWidgetControl -*/ -#define Q_MEDIASERVICE_CAMERA "com.nokia.qt.camera" - -/*! - Service with support for radio tuning. - Required Controls: QRadioTunerControl - Recording Controls (Optional, used by QMediaRecorder): - Required: QMediaRecorderControl - Recommended: QAudioEncoderControl - Optional: QMediaContainerControl -*/ -#define Q_MEDIASERVICE_RADIO "com.nokia.qt.radio" - - -QT_END_NAMESPACE - -QT_END_HEADER - - -#endif // QMEDIASERVICEPROVIDER_H diff --git a/src/multimediakit/qmediaserviceproviderplugin.h b/src/multimediakit/qmediaserviceproviderplugin.h deleted file mode 100644 index 5d150a22b..000000000 --- a/src/multimediakit/qmediaserviceproviderplugin.h +++ /dev/null @@ -1,129 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QMEDIASERVICEPROVIDERPLUGIN_H -#define QMEDIASERVICEPROVIDERPLUGIN_H - -#include -#include -#include -#include -#include "qmediaserviceprovider.h" - -#ifdef Q_MOC_RUN -# pragma Q_MOC_EXPAND_MACROS -#endif - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -QT_MODULE(Multimedia) - - -class QMediaService; - -struct Q_MULTIMEDIA_EXPORT QMediaServiceProviderFactoryInterface : public QFactoryInterface -{ - virtual QStringList keys() const = 0; - virtual QMediaService* create(QString const& key) = 0; - virtual void release(QMediaService *service) = 0; -}; - -#define QMediaServiceProviderFactoryInterface_iid \ - "com.nokia.Qt.QMediaServiceProviderFactoryInterface/1.0" -Q_DECLARE_INTERFACE(QMediaServiceProviderFactoryInterface, QMediaServiceProviderFactoryInterface_iid) - - -struct Q_MULTIMEDIA_EXPORT QMediaServiceSupportedFormatsInterface -{ - virtual ~QMediaServiceSupportedFormatsInterface() {} - virtual QtMultimediaKit::SupportEstimate hasSupport(const QString &mimeType, const QStringList& codecs) const = 0; - virtual QStringList supportedMimeTypes() const = 0; -}; - -#define QMediaServiceSupportedFormatsInterface_iid \ - "com.nokia.Qt.QMediaServiceSupportedFormatsInterface/1.0" -Q_DECLARE_INTERFACE(QMediaServiceSupportedFormatsInterface, QMediaServiceSupportedFormatsInterface_iid) - - -struct Q_MULTIMEDIA_EXPORT QMediaServiceSupportedDevicesInterface -{ - virtual ~QMediaServiceSupportedDevicesInterface() {} - virtual QList devices(const QByteArray &service) const = 0; - virtual QString deviceDescription(const QByteArray &service, const QByteArray &device) = 0; -}; - -#define QMediaServiceSupportedDevicesInterface_iid \ - "com.nokia.Qt.QMediaServiceSupportedDevicesInterface/1.0" -Q_DECLARE_INTERFACE(QMediaServiceSupportedDevicesInterface, QMediaServiceSupportedDevicesInterface_iid) - - - -struct Q_MULTIMEDIA_EXPORT QMediaServiceFeaturesInterface -{ - virtual ~QMediaServiceFeaturesInterface() {} - virtual QMediaServiceProviderHint::Features supportedFeatures(const QByteArray &service) const = 0; -}; - -#define QMediaServiceFeaturesInterface_iid \ - "com.nokia.Qt.QMediaServiceFeaturesInterface/1.0" -Q_DECLARE_INTERFACE(QMediaServiceFeaturesInterface, QMediaServiceFeaturesInterface_iid) - - -class Q_MULTIMEDIA_EXPORT QMediaServiceProviderPlugin : public QObject, public QMediaServiceProviderFactoryInterface -{ - Q_OBJECT - Q_INTERFACES(QMediaServiceProviderFactoryInterface:QFactoryInterface) - -public: - virtual QStringList keys() const = 0; - virtual QMediaService* create(const QString& key) = 0; - virtual void release(QMediaService *service) = 0; -}; - -QT_END_NAMESPACE - -QT_END_HEADER - - - -#endif // QMEDIASERVICEPROVIDERPLUGIN_H diff --git a/src/multimediakit/qmediastreamscontrol.cpp b/src/multimediakit/qmediastreamscontrol.cpp deleted file mode 100644 index 58b935355..000000000 --- a/src/multimediakit/qmediastreamscontrol.cpp +++ /dev/null @@ -1,162 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qmediastreamscontrol.h" -#include "qmediacontrol_p.h" - -QT_BEGIN_NAMESPACE - -/*! - \class QMediaStreamsControl - \preliminary - - \inmodule QtMultimediaKit - \ingroup multimedia-serv - \brief The QMediaStreamsControl class provides a media stream selection control. - - \ingroup multimedia-serv - \since 1.0 - - The QMediaStreamsControl class provides descriptions of the available media streams - and allows individual streams to be activated and deactivated. - - The interface name of QMediaStreamsControl is \c com.nokia.Qt.MediaStreamsControl as - defined in QMediaStreamsControl_iid. - - \sa QMediaService::requestControl() -*/ - -/*! - \macro QMediaStreamsControl_iid - - \c com.nokia.Qt.MediaStreamsControl - - Defines the interface name of the QMediaStreamsControl class. - - \relates QMediaStreamsControl - \since 1.0 -*/ - -/*! - Constructs a new media streams control with the given \a parent. -*/ -QMediaStreamsControl::QMediaStreamsControl(QObject *parent) - :QMediaControl(*new QMediaControlPrivate, parent) -{ -} - -/*! - Destroys a media streams control. -*/ -QMediaStreamsControl::~QMediaStreamsControl() -{ -} - -/*! - \enum QMediaStreamsControl::StreamType - - Media stream type. - - \value AudioStream Audio stream. - \value VideoStream Video stream. - \value SubPictureStream Subpicture or teletext stream. - \value UnknownStream The stream type is unknown. - \value DataStream -*/ - -/*! - \fn QMediaStreamsControl::streamCount() - - Returns the number of media streams. - \since 1.0 -*/ - -/*! - \fn QMediaStreamsControl::streamType(int stream) - - Return the type of a media \a stream. - \since 1.0 -*/ - -/*! - \fn QMediaStreamsControl::metaData(int stream, QtMultimediaKit::MetaData key) - - Returns the meta-data value of \a key for a given \a stream. - - Useful metadata keya are QtMultimediaKit::Title, QtMultimediaKit::Description and QtMultimediaKit::Language. - \since 1.0 -*/ - -/*! - \fn QMediaStreamsControl::isActive(int stream) - - Returns true if the media \a stream is active. - \since 1.0 -*/ - -/*! - \fn QMediaStreamsControl::setActive(int stream, bool state) - - Sets the active \a state of a media \a stream. - - Setting the active state of a media stream to true will activate it. If any other stream - of the same type was previously active it will be deactivated. Setting the active state fo a - media stream to false will deactivate it. - \since 1.0 -*/ - -/*! - \fn QMediaStreamsControl::streamsChanged() - - The signal is emitted when the available streams list is changed. - \since 1.0 -*/ - -/*! - \fn QMediaStreamsControl::activeStreamsChanged() - - The signal is emitted when the active streams list is changed. - \since 1.0 -*/ - -#include "moc_qmediastreamscontrol.cpp" -QT_END_NAMESPACE - diff --git a/src/multimediakit/qmediastreamscontrol.h b/src/multimediakit/qmediastreamscontrol.h deleted file mode 100644 index 10c38e130..000000000 --- a/src/multimediakit/qmediastreamscontrol.h +++ /dev/null @@ -1,95 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - - -#ifndef QMEDIASTREAMSCONTROL_H -#define QMEDIASTREAMSCONTROL_H - -#include "qmediacontrol.h" -#include "qtmedianamespace.h" -#include "qtmultimediakitdefs.h" -#include - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -QT_MODULE(Multimedia) - - -class Q_MULTIMEDIA_EXPORT QMediaStreamsControl : public QMediaControl -{ - Q_OBJECT - Q_ENUMS(SteamType) -public: - enum StreamType { UnknownStream, VideoStream, AudioStream, SubPictureStream, DataStream }; - - virtual ~QMediaStreamsControl(); - - virtual int streamCount() = 0; - virtual StreamType streamType(int streamNumber) = 0; - - virtual QVariant metaData(int streamNumber, QtMultimediaKit::MetaData key) = 0; - - virtual bool isActive(int streamNumber) = 0; - virtual void setActive(int streamNumber, bool state) = 0; - -Q_SIGNALS: - void streamsChanged(); - void activeStreamsChanged(); - -protected: - QMediaStreamsControl(QObject *parent = 0); -}; - -#define QMediaStreamsControl_iid "com.nokia.Qt.QMediaStreamsControl/1.0" -Q_MEDIA_DECLARE_CONTROL(QMediaStreamsControl, QMediaStreamsControl_iid) - -QT_END_NAMESPACE - -Q_DECLARE_METATYPE(QMediaStreamsControl::StreamType) - -Q_MEDIA_ENUM_DEBUG(QMediaStreamsControl, StreamType) - -QT_END_HEADER - -#endif // QMEDIASTREAMSCONTROL_H - diff --git a/src/multimediakit/qmediatimerange.cpp b/src/multimediakit/qmediatimerange.cpp deleted file mode 100644 index 6da9fd640..000000000 --- a/src/multimediakit/qmediatimerange.cpp +++ /dev/null @@ -1,759 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include - -#include "qmediatimerange.h" - -QT_BEGIN_NAMESPACE - -/*! - \class QMediaTimeInterval - \brief The QMediaTimeInterval class represents a time interval with integer precision. - \inmodule QtMultimediaKit - \ingroup multimedia - \since 1.0 - - An interval is specified by an inclusive start() and end() time. These - must be set in the constructor, as this is an immutable class. The - specific units of time represented by the class have not been defined - it - is suitable for any times which can be represented by a signed 64 bit - integer. - - The isNormal() method determines if a time interval is normal (a normal - time interval has start() <= end()). An abnormal interval can be converted - in to a normal interval by calling the normalized() method. - - The contains() method determines if a specified time lies within the time - interval. - - The translated() method returns a time interval which has been translated - forwards or backwards through time by a specified offset. - - \sa QMediaTimeRange -*/ - -/*! - \fn QMediaTimeInterval::QMediaTimeInterval() - - Constructs an empty interval. -*/ -QMediaTimeInterval::QMediaTimeInterval() - : s(0) - , e(0) -{ - -} - -/*! - \fn QMediaTimeInterval::QMediaTimeInterval(qint64 start, qint64 end) - - Constructs an interval with the specified \a start and \a end times. - \since 1.0 -*/ -QMediaTimeInterval::QMediaTimeInterval(qint64 start, qint64 end) - : s(start) - , e(end) -{ - -} - -/*! - \fn QMediaTimeInterval::QMediaTimeInterval(const QMediaTimeInterval &other) - - Constructs an interval by taking a copy of \a other. - \since 1.0 -*/ -QMediaTimeInterval::QMediaTimeInterval(const QMediaTimeInterval &other) - : s(other.s) - , e(other.e) -{ - -} - -/*! - \fn QMediaTimeInterval::start() const - - Returns the start time of the interval. - - \since 1.0 - \sa end() -*/ -qint64 QMediaTimeInterval::start() const -{ - return s; -} - -/*! - \fn QMediaTimeInterval::end() const - - Returns the end time of the interval. - - \since 1.0 - \sa start() -*/ -qint64 QMediaTimeInterval::end() const -{ - return e; -} - -/*! - \fn QMediaTimeInterval::contains(qint64 time) const - - Returns true if the time interval contains the specified \a time. - That is, start() <= time <= end(). - \since 1.0 -*/ -bool QMediaTimeInterval::contains(qint64 time) const -{ - return isNormal() ? (s <= time && time <= e) - : (e <= time && time <= s); -} - -/*! - \fn QMediaTimeInterval::isNormal() const - - Returns true if this time interval is normal. - A normal time interval has start() <= end(). - - \since 1.0 - \sa normalized() -*/ -bool QMediaTimeInterval::isNormal() const -{ - return s <= e; -} - -/*! - \fn QMediaTimeInterval::normalized() const - - Returns a normalized version of this interval. - - If the start() time of the interval is greater than the end() time, - then the returned interval has the start and end times swapped. - \since 1.0 -*/ -QMediaTimeInterval QMediaTimeInterval::normalized() const -{ - if(s > e) - return QMediaTimeInterval(e, s); - - return *this; -} - -/*! - \fn QMediaTimeInterval::translated(qint64 offset) const - - Returns a copy of this time interval, translated by a value of \a offset. - An interval can be moved forward through time with a positive offset, or backward - through time with a negative offset. - \since 1.0 -*/ -QMediaTimeInterval QMediaTimeInterval::translated(qint64 offset) const -{ - return QMediaTimeInterval(s + offset, e + offset); -} - -/*! - \fn operator==(const QMediaTimeInterval &a, const QMediaTimeInterval &b) - \relates QMediaTimeRange - - Returns true if \a a is exactly equal to \a b. - \since 1.0 -*/ -bool operator==(const QMediaTimeInterval &a, const QMediaTimeInterval &b) -{ - return a.start() == b.start() && a.end() == b.end(); -} - -/*! - \fn operator!=(const QMediaTimeInterval &a, const QMediaTimeInterval &b) - \relates QMediaTimeRange - - Returns true if \a a is not exactly equal to \a b. - \since 1.0 -*/ -bool operator!=(const QMediaTimeInterval &a, const QMediaTimeInterval &b) -{ - return a.start() != b.start() || a.end() != b.end(); -} - -class QMediaTimeRangePrivate : public QSharedData -{ -public: - - QMediaTimeRangePrivate(); - QMediaTimeRangePrivate(const QMediaTimeRangePrivate &other); - QMediaTimeRangePrivate(const QMediaTimeInterval &interval); - - QList intervals; - - void addInterval(const QMediaTimeInterval &interval); - void removeInterval(const QMediaTimeInterval &interval); -}; - -QMediaTimeRangePrivate::QMediaTimeRangePrivate() - : QSharedData() -{ - -} - -QMediaTimeRangePrivate::QMediaTimeRangePrivate(const QMediaTimeRangePrivate &other) - : QSharedData() - , intervals(other.intervals) -{ - -} - -QMediaTimeRangePrivate::QMediaTimeRangePrivate(const QMediaTimeInterval &interval) - : QSharedData() -{ - if(interval.isNormal()) - intervals << interval; -} - -void QMediaTimeRangePrivate::addInterval(const QMediaTimeInterval &interval) -{ - // Handle normalized intervals only - if(!interval.isNormal()) - return; - - // Find a place to insert the interval - int i; - for (i = 0; i < intervals.count(); i++) { - // Insert before this element - if(interval.s < intervals[i].s) { - intervals.insert(i, interval); - break; - } - } - - // Interval needs to be added to the end of the list - if (i == intervals.count()) - intervals.append(interval); - - // Do we need to correct the element before us? - if(i > 0 && intervals[i - 1].e >= interval.s - 1) - i--; - - // Merge trailing ranges - while (i < intervals.count() - 1 - && intervals[i].e >= intervals[i + 1].s - 1) { - intervals[i].e = qMax(intervals[i].e, intervals[i + 1].e); - intervals.removeAt(i + 1); - } -} - -void QMediaTimeRangePrivate::removeInterval(const QMediaTimeInterval &interval) -{ - // Handle normalized intervals only - if(!interval.isNormal()) - return; - - for (int i = 0; i < intervals.count(); i++) { - QMediaTimeInterval r = intervals[i]; - - if (r.e < interval.s) { - // Before the removal interval - continue; - } else if (interval.e < r.s) { - // After the removal interval - stop here - break; - } else if (r.s < interval.s && interval.e < r.e) { - // Split case - a single range has a chunk removed - intervals[i].e = interval.s -1; - addInterval(QMediaTimeInterval(interval.e + 1, r.e)); - break; - } else if (r.s < interval.s) { - // Trimming Tail Case - intervals[i].e = interval.s - 1; - } else if (interval.e < r.e) { - // Trimming Head Case - we can stop after this - intervals[i].s = interval.e + 1; - break; - } else { - // Complete coverage case - intervals.removeAt(i); - --i; - } - } -} - -/*! - \class QMediaTimeRange - \brief The QMediaTimeRange class represents a set of zero or more disjoint - time intervals. - \ingroup multimedia - \since 1.0 - - \reentrant - - The earliestTime(), latestTime(), intervals() and isEmpty() - methods are used to get information about the current time range. - - The addInterval(), removeInterval() and clear() methods are used to modify - the current time range. - - When adding or removing intervals from the time range, existing intervals - within the range may be expanded, trimmed, deleted, merged or split to ensure - that all intervals within the time range remain distinct and disjoint. As a - consequence, all intervals added or removed from a time range must be - \l{QMediaTimeInterval::isNormal()}{normal}. - - \sa QMediaTimeInterval -*/ - -/*! - \fn QMediaTimeRange::QMediaTimeRange() - - Constructs an empty time range. -*/ -QMediaTimeRange::QMediaTimeRange() - : d(new QMediaTimeRangePrivate) -{ - -} - -/*! - \fn QMediaTimeRange::QMediaTimeRange(qint64 start, qint64 end) - - Constructs a time range that contains an initial interval from - \a start to \a end inclusive. - - If the interval is not \l{QMediaTimeInterval::isNormal()}{normal}, - the resulting time range will be empty. - - \since 1.0 - \sa addInterval() -*/ -QMediaTimeRange::QMediaTimeRange(qint64 start, qint64 end) - : d(new QMediaTimeRangePrivate(QMediaTimeInterval(start, end))) -{ - -} - -/*! - \fn QMediaTimeRange::QMediaTimeRange(const QMediaTimeInterval &interval) - - Constructs a time range that contains an intitial interval, \a interval. - - If \a interval is not \l{QMediaTimeInterval::isNormal()}{normal}, - the resulting time range will be empty. - - \since 1.0 - \sa addInterval() -*/ -QMediaTimeRange::QMediaTimeRange(const QMediaTimeInterval &interval) - : d(new QMediaTimeRangePrivate(interval)) -{ - -} - -/*! - \fn QMediaTimeRange::QMediaTimeRange(const QMediaTimeRange &range) - - Constructs a time range by copying another time \a range. - \since 1.0 -*/ -QMediaTimeRange::QMediaTimeRange(const QMediaTimeRange &range) - : d(range.d) -{ - -} - -/*! - \fn QMediaTimeRange::~QMediaTimeRange() - - Destructor. -*/ -QMediaTimeRange::~QMediaTimeRange() -{ - -} - -/*! - \fn QMediaTimeRange::operator=(const QMediaTimeRange &other) - - Takes a copy of the \a other time range and returns itself. - \since 1.0 -*/ -QMediaTimeRange &QMediaTimeRange::operator=(const QMediaTimeRange &other) -{ - d = other.d; - return *this; -} - -/*! - \fn QMediaTimeRange::operator=(const QMediaTimeInterval &interval) - - Sets the time range to a single continuous interval, \a interval. - \since 1.0 -*/ -QMediaTimeRange &QMediaTimeRange::operator=(const QMediaTimeInterval &interval) -{ - d = new QMediaTimeRangePrivate(interval); - return *this; -} - -/*! - \fn QMediaTimeRange::earliestTime() const - - Returns the earliest time within the time range. - - For empty time ranges, this value is equal to zero. - - \since 1.0 - \sa latestTime() -*/ -qint64 QMediaTimeRange::earliestTime() const -{ - if (!d->intervals.isEmpty()) - return d->intervals[0].s; - - return 0; -} - -/*! - \fn QMediaTimeRange::latestTime() const - - Returns the latest time within the time range. - - For empty time ranges, this value is equal to zero. - - \since 1.0 - \sa earliestTime() -*/ -qint64 QMediaTimeRange::latestTime() const -{ - if (!d->intervals.isEmpty()) - return d->intervals[d->intervals.count() - 1].e; - - return 0; -} - -/*! - \fn QMediaTimeRange::addInterval(qint64 start, qint64 end) - \overload - - Adds the interval specified by \a start and \a end - to the time range. - - \since 1.0 - \sa addInterval() -*/ -void QMediaTimeRange::addInterval(qint64 start, qint64 end) -{ - d->addInterval(QMediaTimeInterval(start, end)); -} - -/*! - \fn QMediaTimeRange::addInterval(const QMediaTimeInterval &interval) - - Adds the specified \a interval to the time range. - - Adding intervals which are not \l{QMediaTimeInterval::isNormal()}{normal} - is invalid, and will be ignored. - - If the specified interval is adjacent to, or overlaps existing - intervals within the time range, these intervals will be merged. - - This operation takes \l{linear time} - - \since 1.0 - \sa removeInterval() -*/ -void QMediaTimeRange::addInterval(const QMediaTimeInterval &interval) -{ - d->addInterval(interval); -} - -/*! - \fn QMediaTimeRange::addTimeRange(const QMediaTimeRange &range) - - Adds each of the intervals in \a range to this time range. - - Equivalent to calling addInterval() for each interval in \a range. - \since 1.0 -*/ -void QMediaTimeRange::addTimeRange(const QMediaTimeRange &range) -{ - foreach(const QMediaTimeInterval &i, range.intervals()) { - d->addInterval(i); - } -} - -/*! - \fn QMediaTimeRange::removeInterval(qint64 start, qint64 end) - \overload - - Removes the interval specified by \a start and \a end - from the time range. - - \since 1.0 - \sa removeInterval() -*/ -void QMediaTimeRange::removeInterval(qint64 start, qint64 end) -{ - d->removeInterval(QMediaTimeInterval(start, end)); -} - -/*! - \fn QMediaTimeRange::removeInterval(const QMediaTimeInterval &interval) - - Removes the specified \a interval from the time range. - - Removing intervals which are not \l{QMediaTimeInterval::isNormal()}{normal} - is invalid, and will be ignored. - - Intervals within the time range will be trimmed, split or deleted - such that no intervals within the time range include any part of the - target interval. - - This operation takes \l{linear time} - - \since 1.0 - \sa addInterval() -*/ -void QMediaTimeRange::removeInterval(const QMediaTimeInterval &interval) -{ - d->removeInterval(interval); -} - -/*! - \fn QMediaTimeRange::removeTimeRange(const QMediaTimeRange &range) - - Removes each of the intervals in \a range from this time range. - - Equivalent to calling removeInterval() for each interval in \a range. - \since 1.0 -*/ -void QMediaTimeRange::removeTimeRange(const QMediaTimeRange &range) -{ - foreach(const QMediaTimeInterval &i, range.intervals()) { - d->removeInterval(i); - } -} - -/*! - \fn QMediaTimeRange::operator+=(const QMediaTimeRange &other) - - Adds each interval in \a other to the time range and returns the result. - \since 1.0 -*/ -QMediaTimeRange& QMediaTimeRange::operator+=(const QMediaTimeRange &other) -{ - addTimeRange(other); - return *this; -} - -/*! - \fn QMediaTimeRange::operator+=(const QMediaTimeInterval &interval) - - Adds the specified \a interval to the time range and returns the result. - \since 1.0 -*/ -QMediaTimeRange& QMediaTimeRange::operator+=(const QMediaTimeInterval &interval) -{ - addInterval(interval); - return *this; -} - -/*! - \fn QMediaTimeRange::operator-=(const QMediaTimeRange &other) - - Removes each interval in \a other from the time range and returns the result. - \since 1.0 -*/ -QMediaTimeRange& QMediaTimeRange::operator-=(const QMediaTimeRange &other) -{ - removeTimeRange(other); - return *this; -} - -/*! - \fn QMediaTimeRange::operator-=(const QMediaTimeInterval &interval) - - Removes the specified \a interval from the time range and returns the result. - \since 1.0 -*/ -QMediaTimeRange& QMediaTimeRange::operator-=(const QMediaTimeInterval &interval) -{ - removeInterval(interval); - return *this; -} - -/*! - \fn QMediaTimeRange::clear() - - Removes all intervals from the time range. - - \since 1.0 - \sa removeInterval() -*/ -void QMediaTimeRange::clear() -{ - d->intervals.clear(); -} - -/*! - \fn QMediaTimeRange::intervals() const - - Returns the list of intervals covered by this time range. - \since 1.0 -*/ -QList QMediaTimeRange::intervals() const -{ - return d->intervals; -} - -/*! - \fn QMediaTimeRange::isEmpty() const - - Returns true if there are no intervals within the time range. - - \since 1.0 - \sa intervals() -*/ -bool QMediaTimeRange::isEmpty() const -{ - return d->intervals.isEmpty(); -} - -/*! - \fn QMediaTimeRange::isContinuous() const - - Returns true if the time range consists of a continuous interval. - That is, there is one or fewer disjoint intervals within the time range. - \since 1.0 -*/ -bool QMediaTimeRange::isContinuous() const -{ - return (d->intervals.count() <= 1); -} - -/*! - \fn QMediaTimeRange::contains(qint64 time) const - - Returns true if the specified \a time lies within the time range. - \since 1.0 -*/ -bool QMediaTimeRange::contains(qint64 time) const -{ - for (int i = 0; i < d->intervals.count(); i++) { - if (d->intervals[i].contains(time)) - return true; - - if (time < d->intervals[i].s) - break; - } - - return false; -} - -/*! - \fn operator==(const QMediaTimeRange &a, const QMediaTimeRange &b) - \relates QMediaTimeRange - - Returns true if all intervals in \a a are present in \a b. - \since 1.0 -*/ -bool operator==(const QMediaTimeRange &a, const QMediaTimeRange &b) -{ - if (a.intervals().count() != b.intervals().count()) - return false; - - for (int i = 0; i < a.intervals().count(); i++) - { - if(a.intervals()[i] != b.intervals()[i]) - return false; - } - - return true; -} - -/*! - \fn operator!=(const QMediaTimeRange &a, const QMediaTimeRange &b) - \relates QMediaTimeRange - - Returns true if one or more intervals in \a a are not present in \a b. - \since 1.0 -*/ -bool operator!=(const QMediaTimeRange &a, const QMediaTimeRange &b) -{ - return !(a == b); -} - -/*! - \fn operator+(const QMediaTimeRange &r1, const QMediaTimeRange &r2) - - Returns a time range containing the union between \a r1 and \a r2. - \since 1.0 - */ -QMediaTimeRange operator+(const QMediaTimeRange &r1, const QMediaTimeRange &r2) -{ - return (QMediaTimeRange(r1) += r2); -} - -/*! - \fn operator-(const QMediaTimeRange &r1, const QMediaTimeRange &r2) - - Returns a time range containing \a r2 subtracted from \a r1. - \since 1.0 - */ -QMediaTimeRange operator-(const QMediaTimeRange &r1, const QMediaTimeRange &r2) -{ - return (QMediaTimeRange(r1) -= r2); -} - -#ifndef QT_NO_DEBUG_STREAM -QDebug operator<<(QDebug dbg, const QMediaTimeRange &range) -{ - dbg.nospace() << "QMediaTimeRange( "; - foreach (const QMediaTimeInterval &interval, range.intervals()) { - dbg.nospace() << "(" << interval.start() << ", " << interval.end() << ") "; - } - dbg.space() << ")"; - return dbg; -} -#endif - -QT_END_NAMESPACE - diff --git a/src/multimediakit/qmediatimerange.h b/src/multimediakit/qmediatimerange.h deleted file mode 100644 index 927801f34..000000000 --- a/src/multimediakit/qmediatimerange.h +++ /dev/null @@ -1,140 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QMEDIATIMERANGE_H -#define QMEDIATIMERANGE_H - -#include -#include "qtmedianamespace.h" -#include - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -QT_MODULE(Multimedia) - - -class QMediaTimeRangePrivate; - -class Q_MULTIMEDIA_EXPORT QMediaTimeInterval -{ -public: - QMediaTimeInterval(); - QMediaTimeInterval(qint64 start, qint64 end); - QMediaTimeInterval(const QMediaTimeInterval&); - - qint64 start() const; - qint64 end() const; - - bool contains(qint64 time) const; - - bool isNormal() const; - QMediaTimeInterval normalized() const; - QMediaTimeInterval translated(qint64 offset) const; - -private: - friend class QMediaTimeRangePrivate; - friend class QMediaTimeRange; - - qint64 s; - qint64 e; -}; - -Q_MULTIMEDIA_EXPORT bool operator==(const QMediaTimeInterval&, const QMediaTimeInterval&); -Q_MULTIMEDIA_EXPORT bool operator!=(const QMediaTimeInterval&, const QMediaTimeInterval&); - -class Q_MULTIMEDIA_EXPORT QMediaTimeRange -{ -public: - - QMediaTimeRange(); - QMediaTimeRange(qint64 start, qint64 end); - QMediaTimeRange(const QMediaTimeInterval&); - QMediaTimeRange(const QMediaTimeRange &range); - ~QMediaTimeRange(); - - QMediaTimeRange &operator=(const QMediaTimeRange&); - QMediaTimeRange &operator=(const QMediaTimeInterval&); - - qint64 earliestTime() const; - qint64 latestTime() const; - - QList intervals() const; - bool isEmpty() const; - bool isContinuous() const; - - bool contains(qint64 time) const; - - void addInterval(qint64 start, qint64 end); - void addInterval(const QMediaTimeInterval &interval); - void addTimeRange(const QMediaTimeRange&); - - void removeInterval(qint64 start, qint64 end); - void removeInterval(const QMediaTimeInterval &interval); - void removeTimeRange(const QMediaTimeRange&); - - QMediaTimeRange& operator+=(const QMediaTimeRange&); - QMediaTimeRange& operator+=(const QMediaTimeInterval&); - QMediaTimeRange& operator-=(const QMediaTimeRange&); - QMediaTimeRange& operator-=(const QMediaTimeInterval&); - - void clear(); - -private: - QSharedDataPointer d; -}; - -Q_MULTIMEDIA_EXPORT bool operator==(const QMediaTimeRange&, const QMediaTimeRange&); -Q_MULTIMEDIA_EXPORT bool operator!=(const QMediaTimeRange&, const QMediaTimeRange&); -Q_MULTIMEDIA_EXPORT QMediaTimeRange operator+(const QMediaTimeRange&, const QMediaTimeRange&); -Q_MULTIMEDIA_EXPORT QMediaTimeRange operator-(const QMediaTimeRange&, const QMediaTimeRange&); - -#ifndef QT_NO_DEBUG_STREAM -Q_MULTIMEDIA_EXPORT QDebug operator<<(QDebug, const QMediaTimeRange &); -#endif - -QT_END_NAMESPACE - -QT_END_HEADER - - -#endif // QMEDIATIMERANGE_H diff --git a/src/multimediakit/qmetadatareadercontrol.cpp b/src/multimediakit/qmetadatareadercontrol.cpp deleted file mode 100644 index c877201d8..000000000 --- a/src/multimediakit/qmetadatareadercontrol.cpp +++ /dev/null @@ -1,163 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include -#include - -QT_BEGIN_NAMESPACE - - -/*! - \class QMetaDataReaderControl - \inmodule QtMultimediaKit - \ingroup multimedia-serv - \since 1.0 - - - \brief The QMetaDataReaderControl class provides read access to the - meta-data of a QMediaService's media. - - If a QMediaService can provide read or write access to the meta-data of - its current media it will implement QMetaDataReaderControl. This control - provides functions for both retrieving and setting meta-data values. - Meta-data may be addressed by the well defined keys in the - QtMultimediaKit::MetaData enumeration using the metaData() functions, or by - string keys using the extendedMetaData() functions. - - The functionality provided by this control is exposed to application - code by the meta-data members of QMediaObject, and so meta-data access - is potentially available in any of the media object classes. Any media - service may implement QMetaDataReaderControl. - - The interface name of QMetaDataReaderControl is - \c com.nokia.Qt.QMetaDataReaderControl/1.0 as defined in - QMetaDataReaderControl_iid. - - \sa QMediaService::requestControl(), QMediaObject -*/ - -/*! - \macro QMetaDataReaderControl_iid - - \c com.nokia.Qt.QMetaDataReaderControl/1.0 - - Defines the interface name of the QMetaDataReaderControl class. - - \relates QMetaDataReaderControl -*/ - -/*! - Construct a QMetaDataReaderControl with \a parent. This class is meant as a base class - for service specific meta data providers so this constructor is protected. -*/ - -QMetaDataReaderControl::QMetaDataReaderControl(QObject *parent): - QMediaControl(*new QMediaControlPrivate, parent) -{ -} - -/*! - Destroy the meta-data object. -*/ - -QMetaDataReaderControl::~QMetaDataReaderControl() -{ -} - -/*! - \fn bool QMetaDataReaderControl::isMetaDataAvailable() const - - Identifies if meta-data is available from a media service. - - Returns true if the meta-data is available and false otherwise. - \since 1.0 -*/ - -/*! - \fn QVariant QMetaDataReaderControl::metaData(QtMultimediaKit::MetaData key) const - - Returns the meta-data for the given \a key. - \since 1.0 -*/ - -/*! - \fn QMetaDataReaderControl::availableMetaData() const - - Returns a list of keys there is meta-data available for. - \since 1.0 -*/ - -/*! - \fn QMetaDataReaderControl::extendedMetaData(const QString &key) const - - Returns the metaData for an abitrary string \a key. - - The valid selection of keys for extended meta-data is determined by the provider and the meaning - and type may differ between providers. - \since 1.0 -*/ - -/*! - \fn QMetaDataReaderControl::availableExtendedMetaData() const - - Returns a list of keys there is extended meta-data available for. - \since 1.0 -*/ - - -/*! - \fn void QMetaDataReaderControl::metaDataChanged() - - Signal the changes of meta-data. - \since 1.0 -*/ - -/*! - \fn void QMetaDataReaderControl::metaDataAvailableChanged(bool available) - - Signal the availability of meta-data has changed, \a available will - be true if the multimedia object has meta-data. - \since 1.0 -*/ - -#include "moc_qmetadatareadercontrol.cpp" -QT_END_NAMESPACE - diff --git a/src/multimediakit/qmetadatareadercontrol.h b/src/multimediakit/qmetadatareadercontrol.h deleted file mode 100644 index 4689e30bc..000000000 --- a/src/multimediakit/qmetadatareadercontrol.h +++ /dev/null @@ -1,92 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QMETADATAREADERCONTROL_H -#define QMETADATAREADERCONTROL_H - -#include -#include - -#include - -#include -#include "qtmedianamespace.h" - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -QT_MODULE(Multimedia) - - - -class Q_MULTIMEDIA_EXPORT QMetaDataReaderControl : public QMediaControl -{ - Q_OBJECT -public: - ~QMetaDataReaderControl(); - - virtual bool isMetaDataAvailable() const = 0; - - virtual QVariant metaData(QtMultimediaKit::MetaData key) const = 0; - virtual QList availableMetaData() const = 0; - - virtual QVariant extendedMetaData(const QString &key) const = 0; - virtual QStringList availableExtendedMetaData() const = 0; - -Q_SIGNALS: - void metaDataChanged(); - - void metaDataAvailableChanged(bool available); - -protected: - QMetaDataReaderControl(QObject *parent = 0); -}; - -#define QMetaDataReaderControl_iid "com.nokia.Qt.QMetaDataReaderControl/1.0" -Q_MEDIA_DECLARE_CONTROL(QMetaDataReaderControl, QMetaDataReaderControl_iid) - -QT_END_NAMESPACE - -QT_END_HEADER - - -#endif // QMETADATAPROVIDER_H diff --git a/src/multimediakit/qmetadatawritercontrol.cpp b/src/multimediakit/qmetadatawritercontrol.cpp deleted file mode 100644 index 3e5bf42e3..000000000 --- a/src/multimediakit/qmetadatawritercontrol.cpp +++ /dev/null @@ -1,195 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include -#include - -QT_BEGIN_NAMESPACE - - -/*! - \class QMetaDataWriterControl - \inmodule QtMultimediaKit - \ingroup multimedia-serv - \since 1.0 - - - \brief The QMetaDataWriterControl class provides write access to the - meta-data of a QMediaService's media. - - If a QMediaService can provide write access to the meta-data of its - current media it will implement QMetaDataWriterControl. This control - provides functions for both retrieving and setting meta-data values. - Meta-data may be addressed by the well defined keys in the - QtMultimediaKit::MetaData enumeration using the metaData() functions, or - by string keys using the extendedMetaData() functions. - - The functionality provided by this control is exposed to application code - by the meta-data members of QMediaObject, and so meta-data access is - potentially available in any of the media object classes. Any media - service may implement QMetaDataControl. - - The interface name of QMetaDataWriterControl is \c com.nokia.Qt.QMetaDataWriterControl/1.0 as - defined in QMetaDataWriterControl_iid. - - \sa QMediaService::requestControl(), QMediaObject -*/ - -/*! - \macro QMetaDataWriterControl_iid - - \c com.nokia.Qt.QMetaDataWriterControl/1.0 - - Defines the interface name of the QMetaDataWriterControl class. - - \relates QMetaDataWriterControl -*/ - -/*! - Construct a QMetaDataWriterControl with \a parent. This class is meant as a base class - for service specific meta data providers so this constructor is protected. -*/ - -QMetaDataWriterControl::QMetaDataWriterControl(QObject *parent): - QMediaControl(*new QMediaControlPrivate, parent) -{ -} - -/*! - Destroy the meta-data writer control. -*/ - -QMetaDataWriterControl::~QMetaDataWriterControl() -{ -} - -/*! - \fn bool QMetaDataWriterControl::isMetaDataAvailable() const - - Identifies if meta-data is available from a media service. - - Returns true if the meta-data is available and false otherwise. - \since 1.0 -*/ - -/*! - \fn bool QMetaDataWriterControl::isWritable() const - - Identifies if a media service's meta-data can be edited. - - Returns true if the meta-data is writable and false otherwise. - \since 1.0 -*/ - -/*! - \fn QVariant QMetaDataWriterControl::metaData(QtMultimediaKit::MetaData key) const - - Returns the meta-data for the given \a key. - \since 1.0 -*/ - -/*! - \fn void QMetaDataWriterControl::setMetaData(QtMultimediaKit::MetaData key, const QVariant &value) - - Sets the \a value of the meta-data element with the given \a key. - \since 1.0 -*/ - -/*! - \fn QMetaDataWriterControl::availableMetaData() const - - Returns a list of keys there is meta-data available for. -*/ - -/*! - \fn QMetaDataWriterControl::extendedMetaData(const QString &key) const - - Returns the meta-data for an abitrary string \a key. - - The valid selection of keys for extended meta-data is determined by the provider and the meaning - and type may differ between providers. - \since 1.0 -*/ - -/*! - \fn QMetaDataWriterControl::setExtendedMetaData(const QString &key, const QVariant &value) - - Change the value of the meta-data element with an abitrary string \a key to \a value. - - The valid selection of keys for extended meta-data is determined by the provider and the meaning - and type may differ between providers. - \since 1.0 -*/ - -/*! - \fn QMetaDataWriterControl::availableExtendedMetaData() const - - Returns a list of keys there is extended meta-data available for. - \since 1.0 -*/ - - -/*! - \fn void QMetaDataWriterControl::metaDataChanged() - - Signal the changes of meta-data. - \since 1.0 -*/ - -/*! - \fn void QMetaDataWriterControl::metaDataAvailableChanged(bool available) - - Signal the availability of meta-data has changed, \a available will - be true if the multimedia object has meta-data. - \since 1.0 -*/ - -/*! - \fn void QMetaDataWriterControl::writableChanged(bool writable) - - Signal a change in the writable status of meta-data, \a writable will be - true if meta-data elements can be added or adjusted. - \since 1.0 -*/ - -#include "moc_qmetadatawritercontrol.cpp" -QT_END_NAMESPACE - diff --git a/src/multimediakit/qmetadatawritercontrol.h b/src/multimediakit/qmetadatawritercontrol.h deleted file mode 100644 index 41a2fbba7..000000000 --- a/src/multimediakit/qmetadatawritercontrol.h +++ /dev/null @@ -1,97 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QMETADATAWRITERCONTROL_H -#define QMETADATAWRITERCONTROL_H - -#include "qmediacontrol.h" -#include "qmediaobject.h" - -#include "qmediaresource.h" - -#include -#include "qtmedianamespace.h" - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -QT_MODULE(Multimedia) - - - -class Q_MULTIMEDIA_EXPORT QMetaDataWriterControl : public QMediaControl -{ - Q_OBJECT -public: - ~QMetaDataWriterControl(); - - virtual bool isWritable() const = 0; - virtual bool isMetaDataAvailable() const = 0; - - virtual QVariant metaData(QtMultimediaKit::MetaData key) const = 0; - virtual void setMetaData(QtMultimediaKit::MetaData key, const QVariant &value) = 0; - virtual QList availableMetaData() const = 0; - - virtual QVariant extendedMetaData(const QString &key) const = 0; - virtual void setExtendedMetaData(const QString &key, const QVariant &value) = 0; - virtual QStringList availableExtendedMetaData() const = 0; - - -Q_SIGNALS: - void metaDataChanged(); - - void writableChanged(bool writable); - void metaDataAvailableChanged(bool available); - -protected: - QMetaDataWriterControl(QObject *parent = 0); -}; - -#define QMetaDataWriterControl_iid "com.nokia.Qt.QMetaDataWriterControl/1.0" -Q_MEDIA_DECLARE_CONTROL(QMetaDataWriterControl, QMetaDataWriterControl_iid) - -QT_END_NAMESPACE - -QT_END_HEADER - - -#endif diff --git a/src/multimediakit/qradiotuner.cpp b/src/multimediakit/qradiotuner.cpp deleted file mode 100644 index 6398e2ba9..000000000 --- a/src/multimediakit/qradiotuner.cpp +++ /dev/null @@ -1,614 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qradiotuner.h" -#include "qmediaservice.h" -#include "qmediaobject_p.h" -#include "qradiotunercontrol.h" - -#include - - -QT_BEGIN_NAMESPACE - -/*! - \class QRadioTuner - \brief The QRadioTuner class provides an interface to the systems analog radio device. - - \inmodule QtMultimediaKit - \ingroup multimedia - \since 1.0 - - You can control the systems analog radio device using this interface, for example: - - \snippet doc/src/snippets/multimedia-snippets/media.cpp Radio tuner - - The radio object will emit signals for any changes in state such as: - bandChanged(), frequencyChanged(), stereoStatusChanged(), searchingChanged(), - signalStrengthChanged(), volumeChanged(), mutedChanged(). - - You can change between the frequency bands using setBand() however it is recommended - that you check to make sure the band is available first using isBandSupported(). - -*/ - - -class QRadioTunerPrivate : public QMediaObjectPrivate -{ -public: - QRadioTunerPrivate():provider(0), control(0) {} - QMediaServiceProvider *provider; - QRadioTunerControl* control; -}; - - - -/*! - Constructs a radio tuner based on a media service allocated by a media service \a provider. - - The \a parent is passed to QMediaObject. - \since 1.0 -*/ - -QRadioTuner::QRadioTuner(QObject *parent, QMediaServiceProvider* provider): - QMediaObject(*new QRadioTunerPrivate, parent, provider->requestService(Q_MEDIASERVICE_RADIO)) -{ - Q_D(QRadioTuner); - - d->provider = provider; - - if (d->service != 0) { - d->control = qobject_cast(d->service->requestControl(QRadioTunerControl_iid)); - if (d->control != 0) { - connect(d->control, SIGNAL(stateChanged(QRadioTuner::State)), SIGNAL(stateChanged(QRadioTuner::State))); - connect(d->control, SIGNAL(bandChanged(QRadioTuner::Band)), SIGNAL(bandChanged(QRadioTuner::Band))); - connect(d->control, SIGNAL(frequencyChanged(int)), SIGNAL(frequencyChanged(int))); - connect(d->control, SIGNAL(stereoStatusChanged(bool)), SIGNAL(stereoStatusChanged(bool))); - connect(d->control, SIGNAL(searchingChanged(bool)), SIGNAL(searchingChanged(bool))); - connect(d->control, SIGNAL(signalStrengthChanged(int)), SIGNAL(signalStrengthChanged(int))); - connect(d->control, SIGNAL(volumeChanged(int)), SIGNAL(volumeChanged(int))); - connect(d->control, SIGNAL(mutedChanged(bool)), SIGNAL(mutedChanged(bool))); - connect(d->control, SIGNAL(error(QRadioTuner::Error)), SIGNAL(error(QRadioTuner::Error))); - } - } -} - -/*! - Destroys a radio tuner. -*/ - -QRadioTuner::~QRadioTuner() -{ - Q_D(QRadioTuner); - - if (d->service && d->control) - d->service->releaseControl(d->control); - - d->provider->releaseService(d->service); -} - -/*! - Returns true if the radio tuner service is ready to use. - \since 1.0 -*/ -bool QRadioTuner::isAvailable() const -{ - if (d_func()->control != NULL) - return d_func()->control->isAvailable(); - else - return false; -} - -/*! - Returns the availability error state. - \since 1.0 -*/ -QtMultimediaKit::AvailabilityError QRadioTuner::availabilityError() const -{ - if (d_func()->control != NULL) - return d_func()->control->availabilityError(); - else - return QtMultimediaKit::ServiceMissingError; -} - -/*! - \property QRadioTuner::state - Return the current radio tuner state. - - \since 1.0 - \sa QRadioTuner::State -*/ - -QRadioTuner::State QRadioTuner::state() const -{ - return d_func()->control ? - d_func()->control->state() : QRadioTuner::StoppedState; -} - -/*! - \property QRadioTuner::band - \brief the frequency band a radio tuner is tuned to. - - \since 1.0 - \sa QRadioTuner::Band -*/ - -QRadioTuner::Band QRadioTuner::band() const -{ - Q_D(const QRadioTuner); - - if (d->control != 0) - return d->control->band(); - - return QRadioTuner::FM; -} - -/*! - \property QRadioTuner::frequency - \brief the frequency in Hertz a radio tuner is tuned to. - \since 1.0 -*/ - -int QRadioTuner::frequency() const -{ - Q_D(const QRadioTuner); - - if (d->control != 0) - return d->control->frequency(); - - return 0; -} - -/*! - Returns the number of Hertz to increment the frequency by when stepping through frequencies - within a given \a band. - \since 1.0 -*/ - -int QRadioTuner::frequencyStep(QRadioTuner::Band band) const -{ - Q_D(const QRadioTuner); - - if(d->control != 0) - return d->control->frequencyStep(band); - - return 0; -} - -/*! - Returns a frequency \a band's minimum and maximum frequency. - \since 1.0 -*/ - -QPair QRadioTuner::frequencyRange(QRadioTuner::Band band) const -{ - Q_D(const QRadioTuner); - - if(d->control != 0) - return d->control->frequencyRange(band); - - return qMakePair(0,0); -} - -/*! - \property QRadioTuner::stereo - \brief whether a radio tuner is receiving a stereo signal. - \since 1.0 -*/ - -bool QRadioTuner::isStereo() const -{ - Q_D(const QRadioTuner); - - if (d->control != 0) - return d->control->isStereo(); - - return false; -} - - -/*! - \property QRadioTuner::stereoMode - \brief the stereo mode of a radio tuner. - \since 1.0 -*/ - -QRadioTuner::StereoMode QRadioTuner::stereoMode() const -{ - Q_D(const QRadioTuner); - - if (d->control != 0) - return d->control->stereoMode(); - - return QRadioTuner::Auto; -} - -void QRadioTuner::setStereoMode(QRadioTuner::StereoMode mode) -{ - Q_D(QRadioTuner); - - if (d->control != 0) - return d->control->setStereoMode(mode); -} - -/*! - Identifies if a frequency \a band is supported by a radio tuner. - - Returns true if the band is supported, and false if it is not. - \since 1.0 -*/ - -bool QRadioTuner::isBandSupported(QRadioTuner::Band band) const -{ - Q_D(const QRadioTuner); - - if (d->control != 0) - return d->control->isBandSupported(band); - - return false; -} - -/*! - Activate the radio device. - \since 1.0 -*/ - -void QRadioTuner::start() -{ - Q_D(const QRadioTuner); - - if (d->control != 0) - d->control->start(); -} - -/*! - Deactivate the radio device. - \since 1.0 -*/ - -void QRadioTuner::stop() -{ - Q_D(const QRadioTuner); - - if (d->control != 0) - d->control->stop(); -} - -/*! - \property QRadioTuner::signalStrength - \brief the strength of the current radio signal as a percentage. - \since 1.0 -*/ - -int QRadioTuner::signalStrength() const -{ - Q_D(const QRadioTuner); - - if (d->control != 0) - return d->control->signalStrength(); - - return 0; -} - -/*! - \property QRadioTuner::volume - \brief the volume of a radio tuner's audio output as a percentage. - \since 1.0 -*/ - - -int QRadioTuner::volume() const -{ - Q_D(const QRadioTuner); - - if (d->control != 0) - return d->control->volume(); - - return 0; -} - -/*! - \property QRadioTuner::muted - \brief whether a radio tuner's audio output is muted. - \since 1.0 -*/ - -bool QRadioTuner::isMuted() const -{ - Q_D(const QRadioTuner); - - if (d->control != 0) - return d->control->isMuted(); - - return false; -} - -/*! - Sets a radio tuner's frequency \a band. - - Changing the band will reset the \l frequency to the new band's minimum frequency. - \since 1.0 -*/ - -void QRadioTuner::setBand(QRadioTuner::Band band) -{ - Q_D(QRadioTuner); - - if (d->control != 0) - d->control->setBand(band); -} - -/*! - Sets a radio tuner's \a frequency. - - If the tuner is set to a frequency outside the current \l band, the band will be changed to - one occupied by the new frequency. - \since 1.0 -*/ - -void QRadioTuner::setFrequency(int frequency) -{ - Q_D(QRadioTuner); - - if (d->control != 0) - d->control->setFrequency(frequency); -} - -void QRadioTuner::setVolume(int volume) -{ - Q_D(QRadioTuner); - - if (d->control != 0) - d->control->setVolume(volume); -} - -void QRadioTuner::setMuted(bool muted) -{ - Q_D(QRadioTuner); - - if (d->control != 0) - d->control->setMuted(muted); -} - -/*! - \property QRadioTuner::searching - \brief whether a radio tuner is currently scanning for a signal. - - \sa searchForward(), searchBackward(), cancelSearch() - \since 1.0 -*/ - -bool QRadioTuner::isSearching() const -{ - Q_D(const QRadioTuner); - - if (d->control != 0) - return d->control->isSearching(); - - return false; -} - -/*! - Starts a forward scan for a signal, starting from the current \l frequency. - - \since 1.0 - \sa searchBackward(), cancelSearch(), searching -*/ - -void QRadioTuner::searchForward() -{ - Q_D(QRadioTuner); - - if (d->control != 0) - d->control->searchForward(); -} - -/*! - Starts a backwards scan for a signal, starting from the current \l frequency. - - \since 1.0 - \sa searchForward(), cancelSearch(), searching -*/ - -void QRadioTuner::searchBackward() -{ - Q_D(QRadioTuner); - - if (d->control != 0) - d->control->searchBackward(); -} - -/*! - Stops scanning for a signal. - - \since 1.0 - \sa searchForward(), searchBackward(), searching -*/ - -void QRadioTuner::cancelSearch() -{ - Q_D(QRadioTuner); - - if (d->control != 0) - d->control->cancelSearch(); -} - -/*! - Returns the error state of a radio tuner. - - \since 1.0 - \sa errorString() -*/ - -QRadioTuner::Error QRadioTuner::error() const -{ - Q_D(const QRadioTuner); - - if (d->control != 0) - return d->control->error(); - - return QRadioTuner::ResourceError; -} - -/*! - Returns a description of a radio tuner's error state. - - \since 1.0 - \sa error() -*/ - -QString QRadioTuner::errorString() const -{ - Q_D(const QRadioTuner); - - if (d->control != 0) - return d->control->errorString(); - - return QString(); -} - -/*! - \fn void QRadioTuner::bandChanged(QRadioTuner::Band band) - - Signals a radio tuner's \a band has changed. - \since 1.0 -*/ - -/*! - \fn void QRadioTuner::frequencyChanged(int frequency) - - Signals that the \a frequency a radio tuner is tuned to has changed. - \since 1.0 -*/ - -/*! - \fn void QRadioTuner::mutedChanged(bool muted) - - Signals that the \a muted state of a radio tuner's audio output has changed. - \since 1.0 -*/ - -/*! - \fn void QRadioTuner::volumeChanged(int volume) - - Signals that the \a volume of a radio tuner's audio output has changed. - \since 1.0 -*/ - -/*! - \fn void QRadioTuner::searchingChanged(bool searching) - - Signals that the \a searching state of a radio tuner has changed. - \since 1.0 -*/ - -/*! - \fn void QRadioTuner::stereoStatusChanged(bool stereo) - - Signals that the \a stereo state of a radio tuner has changed. - \since 1.0 -*/ - -/*! - \fn void QRadioTuner::signalStrengthChanged(int strength) - - Signals that the \a strength of the signal received by a radio tuner has changed. - \since 1.0 -*/ - -/*! - \fn void QRadioTuner::error(QRadioTuner::Error error) - - Signals that an \a error occurred. - \since 1.0 -*/ - -/*! - \enum QRadioTuner::State - - Enumerates radio tuner states. - - \value ActiveState The tuner is started and active. - \value StoppedState The tuner device is stopped. -*/ - - -/*! - \enum QRadioTuner::Band - - Enumerates radio frequency bands. - - \value AM 520 to 1610 kHz, 9 or 10kHz channel spacing, extended 1610 to 1710 kHz - \value FM 87.5 to 108.0 MHz, except Japan 76-90 MHz - \value SW 1.711 to 30.0 MHz, divided into 15 bands. 5kHz channel spacing - \value LW 148.5 to 283.5 kHz, 9kHz channel spacing (Europe, Africa, Asia) - \value FM2 range not defined, used when area supports more than one FM range. -*/ - -/*! - \enum QRadioTuner::Error - - Enumerates radio tuner error conditions. - - \value NoError No errors have occurred. - \value ResourceError There is no radio service available. - \value OpenError Unable to open radio device. - \value OutOfRangeError An attempt to set a frequency or band that is not supported by radio device. -*/ - -/*! - \enum QRadioTuner::StereoMode - - Enumerates radio tuner policy for receiving stereo signals. - - \value Auto Uses the stereo mode matching the station. - \value ForceStereo Provide stereo mode, converting if required. - \value ForceMono Provide mono mode, converting if required. -*/ - -/*! \fn void QRadioTuner::stateChanged(QRadioTuner::State state) - This signal is emitted when the state changes to \a state. - \since 1.0 - */ - -#include "moc_qradiotuner.cpp" -QT_END_NAMESPACE - diff --git a/src/multimediakit/qradiotuner.h b/src/multimediakit/qradiotuner.h deleted file mode 100644 index c0f94125f..000000000 --- a/src/multimediakit/qradiotuner.h +++ /dev/null @@ -1,158 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QRADIOTUNER_H -#define QRADIOTUNER_H - -#include - -#include "qmediaobject.h" -#include "qmediaserviceprovider.h" -#include - -#include - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -QT_MODULE(Multimedia) - - -class QRadioTunerPrivate; -class Q_MULTIMEDIA_EXPORT QRadioTuner : public QMediaObject -{ - Q_OBJECT - Q_PROPERTY(State state READ state NOTIFY stateChanged) - Q_PROPERTY(Band band READ band WRITE setBand NOTIFY bandChanged) - Q_PROPERTY(int frequency READ frequency WRITE setFrequency NOTIFY frequencyChanged) - Q_PROPERTY(bool stereo READ isStereo NOTIFY stereoStatusChanged) - Q_PROPERTY(StereoMode stereoMode READ stereoMode WRITE setStereoMode) - Q_PROPERTY(int signalStrength READ signalStrength NOTIFY signalStrengthChanged) - Q_PROPERTY(int volume READ volume WRITE setVolume NOTIFY volumeChanged) - Q_PROPERTY(bool muted READ isMuted WRITE setMuted NOTIFY mutedChanged) - Q_PROPERTY(bool searching READ isSearching NOTIFY searchingChanged) - Q_ENUMS(State) - Q_ENUMS(Band) - Q_ENUMS(Error) - Q_ENUMS(StereoMode) - -public: - enum State { ActiveState, StoppedState }; - enum Band { AM, FM, SW, LW, FM2 }; - enum Error { NoError, ResourceError, OpenError, OutOfRangeError }; - enum StereoMode { ForceStereo, ForceMono, Auto }; - - QRadioTuner(QObject *parent = 0, QMediaServiceProvider *provider = QMediaServiceProvider::defaultServiceProvider()); - ~QRadioTuner(); - - bool isAvailable() const; - QtMultimediaKit::AvailabilityError availabilityError() const; - - State state() const; - - Band band() const; - - bool isBandSupported(Band b) const; - - int frequency() const; - int frequencyStep(Band band) const; - QPair frequencyRange(Band band) const; - - bool isStereo() const; - void setStereoMode(QRadioTuner::StereoMode mode); - StereoMode stereoMode() const; - - int signalStrength() const; - - int volume() const; - bool isMuted() const; - - bool isSearching() const; - - Error error() const; - QString errorString() const; - -public Q_SLOTS: - void searchForward(); - void searchBackward(); - void cancelSearch(); - - void setBand(Band band); - void setFrequency(int frequency); - - void setVolume(int volume); - void setMuted(bool muted); - - void start(); - void stop(); - -Q_SIGNALS: - void stateChanged(QRadioTuner::State state); - void bandChanged(QRadioTuner::Band band); - void frequencyChanged(int frequency); - void stereoStatusChanged(bool stereo); - void searchingChanged(bool searching); - void signalStrengthChanged(int signalStrength); - void volumeChanged(int volume); - void mutedChanged(bool muted); - void error(QRadioTuner::Error error); - -private: - Q_DISABLE_COPY(QRadioTuner) - Q_DECLARE_PRIVATE(QRadioTuner) -}; - -QT_END_NAMESPACE - -Q_DECLARE_METATYPE(QRadioTuner::State) -Q_DECLARE_METATYPE(QRadioTuner::Band) -Q_DECLARE_METATYPE(QRadioTuner::Error) -Q_DECLARE_METATYPE(QRadioTuner::StereoMode) - -Q_MEDIA_ENUM_DEBUG(QRadioTuner, State) -Q_MEDIA_ENUM_DEBUG(QRadioTuner, Band) -Q_MEDIA_ENUM_DEBUG(QRadioTuner, Error) -Q_MEDIA_ENUM_DEBUG(QRadioTuner, StereoMode) - -QT_END_HEADER - -#endif // QRADIOPLAYER_H diff --git a/src/multimediakit/qradiotunercontrol.cpp b/src/multimediakit/qradiotunercontrol.cpp deleted file mode 100644 index d468b0348..000000000 --- a/src/multimediakit/qradiotunercontrol.cpp +++ /dev/null @@ -1,364 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include -#include "qradiotunercontrol.h" -#include "qmediacontrol_p.h" - -QT_BEGIN_NAMESPACE - - -/*! - \class QRadioTunerControl - \inmodule QtMultimediaKit - \ingroup multimedia-serv - \since 1.0 - - - \brief The QRadioTunerControl class provides access to the radio tuning - functionality of a QMediaService. - - If a QMediaService can tune an analog radio device it will implement - QRadioTunerControl. This control provides a means to tune a radio device - to a specific \l {setFrequency()}{frequency} as well as search \l - {searchForward()}{forwards} and \l {searchBackward()}{backwards} for a - signal. - - The functionality provided by this control is exposed to application code - through the QRadioTuner class. - - The interface name of QRadioTunerControl is \c com.nokia.Qt.QRadioTunerControl/1.0 as - defined in QRadioTunerControl_iid. - - \sa QMediaService::requestControl(), QRadioTuner -*/ - -/*! - \macro QRadioTunerControl_iid - - \c com.nokia.Qt.QRadioTunerControl/1.0 - - Defines the interface name of the QRadioTunerControl class. - - \relates QRadioTunerControl -*/ - -/*! - Constructs a radio tuner control with the given \a parent. -*/ - -QRadioTunerControl::QRadioTunerControl(QObject *parent): - QMediaControl(*new QMediaControlPrivate, parent) -{ -} - -/*! - Destroys a radio tuner control. -*/ - -QRadioTunerControl::~QRadioTunerControl() -{ -} - -/*! - \fn bool QRadioTunerControl::isAvailable() const - - Returns true if the radio service is ready to use. - \since 1.0 -*/ - -/*! - \fn QtMultimediaKit::AvailabilityError QRadioTunerControl::availabilityError() const - - Returns the error state of the radio service. - \since 1.0 -*/ - -/*! - \fn QRadioTuner::State QRadioTunerControl::state() const - - Returns the current radio tuner state. - \since 1.0 -*/ - -/*! - \fn QRadioTuner::Band QRadioTunerControl::band() const - - Returns the frequency band a radio tuner is tuned to. - \since 1.0 -*/ - -/*! - \fn void QRadioTunerControl::bandChanged(QRadioTuner::Band band) - - Signals that the frequency \a band a radio tuner is tuned to has changed. - \since 1.0 -*/ - -/*! - \fn void QRadioTunerControl::setBand(QRadioTuner::Band band) - - Sets the frequecy \a band a radio tuner is tuned to. - - Changing the frequency band will reset the frequency to the minimum frequency of the new band. - \since 1.0 -*/ - -/*! - \fn bool QRadioTunerControl::isBandSupported(QRadioTuner::Band band) const - - Identifies if a frequency \a band is supported. - - Returns true if the band is supported, and false if it is not. - \since 1.0 -*/ - -/*! - \fn int QRadioTunerControl::frequency() const - - Returns the frequency a radio tuner is tuned to. - \since 1.0 -*/ - -/*! - \fn int QRadioTunerControl::frequencyStep(QRadioTuner::Band band) const - - Returns the number of Hertz to increment the frequency by when stepping through frequencies - within a given \a band. - \since 1.0 -*/ - -/*! - \fn QPair QRadioTunerControl::frequencyRange(QRadioTuner::Band band) const - - Returns a frequency \a band's minimum and maximum frequency. - \since 1.0 -*/ - -/*! - \fn void QRadioTunerControl::setFrequency(int frequency) - - Sets the \a frequency a radio tuner is tuned to. - \since 1.0 -*/ - -/*! - \fn bool QRadioTunerControl::isStereo() const - - Identifies if a radio tuner is receiving a stereo signal. - - Returns true if the tuner is receiving a stereo signal, and false if it is not. - \since 1.0 -*/ - -/*! - \fn QRadioTuner::StereoMode QRadioTunerControl::stereoMode() const - - Returns a radio tuner's stereo mode. - - \since 1.0 - \sa QRadioTuner::StereoMode -*/ - -/*! - \fn void QRadioTunerControl::setStereoMode(QRadioTuner::StereoMode mode) - - Sets a radio tuner's stereo \a mode. - - \since 1.0 - \sa QRadioTuner::StereoMode -*/ - -/*! - \fn int QRadioTunerControl::signalStrength() const - - Return a radio tuner's current signal strength as a percentage. - \since 1.0 -*/ - -/*! - \fn int QRadioTunerControl::volume() const - - Returns the volume of a radio tuner's audio output as a percentage. - \since 1.0 -*/ - -/*! - \fn void QRadioTunerControl::setVolume(int volume) - - Sets the percentage \a volume of a radio tuner's audio output. - \since 1.0 -*/ - -/*! - \fn bool QRadioTunerControl::isMuted() const - - Identifies if a radio tuner's audio output is muted. - - Returns true if the audio is muted, and false if it is not. - \since 1.0 -*/ - -/*! - \fn void QRadioTunerControl::setMuted(bool muted) - - Sets the \a muted state of a radio tuner's audio output. - \since 1.0 -*/ - -/*! - \fn bool QRadioTunerControl::isSearching() const - - Identifies if a radio tuner is currently scanning for signal. - - Returns true if the tuner is scanning, and false if it is not. - \since 1.0 -*/ - -/*! - \fn void QRadioTunerControl::searchForward() - - Starts a forward scan for a signal, starting from the current \l frequency(). - \since 1.0 -*/ - -/*! - \fn void QRadioTunerControl::searchBackward() - - Starts a backwards scan for a signal, starting from the current \l frequency(). - \since 1.0 -*/ - -/*! - \fn void QRadioTunerControl::cancelSearch() - - Stops scanning for a signal. - \since 1.0 -*/ - -/*! - \fn void QRadioTunerControl::start() - - Activate the radio device. - \since 1.0 -*/ - -/*! - \fn QRadioTunerControl::stop() - - Deactivate the radio device. - \since 1.0 -*/ - -/*! - \fn QRadioTuner::Error QRadioTunerControl::error() const - - Returns the error state of a radio tuner. - \since 1.0 -*/ - -/*! - \fn QString QRadioTunerControl::errorString() const - - Returns a string describing a radio tuner's error state. - \since 1.0 -*/ - -/*! - \fn void QRadioTunerControl::stateChanged(QRadioTuner::State state) - - Signals that the \a state of a radio tuner has changed. - \since 1.0 -*/ - - -/*! - \fn void QRadioTunerControl::frequencyChanged(int frequency) - - Signals that the \a frequency a radio tuner is tuned to has changed. - \since 1.0 -*/ - -/*! - \fn void QRadioTunerControl::stereoStatusChanged(bool stereo) - - Signals that the \a stereo state of a radio tuner has changed. - \since 1.0 -*/ - -/*! - \fn void QRadioTunerControl::searchingChanged(bool searching) - - Signals that the \a searching state of a radio tuner has changed. - \since 1.0 -*/ - -/*! - \fn void QRadioTunerControl::signalStrengthChanged(int strength) - - Signals that the percentage \a strength of the signal received by a radio tuner has changed. - \since 1.0 -*/ - -/*! - \fn void QRadioTunerControl::volumeChanged(int volume) - - Signals that the percentage \a volume of radio tuner's audio output has changed. - \since 1.0 -*/ - -/*! - \fn void QRadioTunerControl::mutedChanged(bool muted) - - Signals that the \a muted state of a radio tuner's audio output has changed. - \since 1.0 -*/ - -/*! - \fn void QRadioTunerControl::error(QRadioTuner::Error error) - - Signals that an \a error has occurred. - \since 1.0 -*/ - -#include "moc_qradiotunercontrol.cpp" -QT_END_NAMESPACE - diff --git a/src/multimediakit/qradiotunercontrol.h b/src/multimediakit/qradiotunercontrol.h deleted file mode 100644 index ae6990ddc..000000000 --- a/src/multimediakit/qradiotunercontrol.h +++ /dev/null @@ -1,123 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QRADIOTUNERCONTROL_H -#define QRADIOTUNERCONTROL_H - -#include "qmediacontrol.h" -#include "qradiotuner.h" - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -QT_MODULE(Multimedia) - - -class Q_MULTIMEDIA_EXPORT QRadioTunerControl : public QMediaControl -{ - Q_OBJECT - -public: - ~QRadioTunerControl(); - - virtual bool isAvailable() const = 0; - virtual QtMultimediaKit::AvailabilityError availabilityError() const = 0; - - virtual QRadioTuner::State state() const = 0; - - virtual QRadioTuner::Band band() const = 0; - virtual void setBand(QRadioTuner::Band b) = 0; - virtual bool isBandSupported(QRadioTuner::Band b) const = 0; - - virtual int frequency() const = 0; - virtual int frequencyStep(QRadioTuner::Band b) const = 0; - virtual QPair frequencyRange(QRadioTuner::Band b) const = 0; - virtual void setFrequency(int frequency) = 0; - - virtual bool isStereo() const = 0; - virtual QRadioTuner::StereoMode stereoMode() const = 0; - virtual void setStereoMode(QRadioTuner::StereoMode mode) = 0; - - virtual int signalStrength() const = 0; - - virtual int volume() const = 0; - virtual void setVolume(int volume) = 0; - - virtual bool isMuted() const = 0; - virtual void setMuted(bool muted) = 0; - - virtual bool isSearching() const = 0; - - virtual void searchForward() = 0; - virtual void searchBackward() = 0; - virtual void cancelSearch() = 0; - - virtual void start() = 0; - virtual void stop() = 0; - - virtual QRadioTuner::Error error() const = 0; - virtual QString errorString() const = 0; - -Q_SIGNALS: - void stateChanged(QRadioTuner::State state); - void bandChanged(QRadioTuner::Band band); - void frequencyChanged(int frequency); - void stereoStatusChanged(bool stereo); - void searchingChanged(bool searching); - void signalStrengthChanged(int signalStrength); - void volumeChanged(int volume); - void mutedChanged(bool muted); - void error(QRadioTuner::Error err); - -protected: - QRadioTunerControl(QObject *parent = 0); -}; - -#define QRadioTunerControl_iid "com.nokia.Qt.QRadioTunerControl/1.0" -Q_MEDIA_DECLARE_CONTROL(QRadioTunerControl, QRadioTunerControl_iid) - -QT_END_NAMESPACE - -QT_END_HEADER - - -#endif // QRADIOTUNERCONTROL_H diff --git a/src/multimediakit/qtmedianamespace.h b/src/multimediakit/qtmedianamespace.h deleted file mode 100644 index cadbc28d9..000000000 --- a/src/multimediakit/qtmedianamespace.h +++ /dev/null @@ -1,198 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QTMEDIANAMESPACE_H -#define QTMEDIANAMESPACE_H - -#include -#include - -#include - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -QT_MODULE(Multimedia) - - -namespace QtMultimediaKit -{ - enum MetaData - { - // Common - Title, - SubTitle, - Author, - Comment, - Description, - Category, - Genre, - Year, - Date, - UserRating, - Keywords, - Language, - Publisher, - Copyright, - ParentalRating, - RatingOrganisation, - - // Media - Size, - MediaType, - Duration, - - // Audio - AudioBitRate, - AudioCodec, - AverageLevel, - ChannelCount, - PeakValue, - SampleRate, - - // Music - AlbumTitle, - AlbumArtist, - ContributingArtist, - Composer, - Conductor, - Lyrics, - Mood, - TrackNumber, - TrackCount, - - CoverArtUrlSmall, - CoverArtUrlLarge, - - // Image/Video - Resolution, - PixelAspectRatio, - - // Video - VideoFrameRate, - VideoBitRate, - VideoCodec, - - PosterUrl, - - // Movie - ChapterNumber, - Director, - LeadPerformer, - Writer, - - // Photos - CameraManufacturer, - CameraModel, - Event, - Subject, - Orientation, - ExposureTime, - FNumber, - ExposureProgram, - ISOSpeedRatings, - ExposureBiasValue, - DateTimeOriginal, - DateTimeDigitized, - SubjectDistance, - MeteringMode, - LightSource, - Flash, - FocalLength, - ExposureMode, - WhiteBalance, - DigitalZoomRatio, - FocalLengthIn35mmFilm, - SceneCaptureType, - GainControl, - Contrast, - Saturation, - Sharpness, - DeviceSettingDescription, - - PosterImage, - CoverArtImage, - ThumbnailImage - - }; - - enum SupportEstimate - { - NotSupported, - MaybeSupported, - ProbablySupported, - PreferredService - }; - - enum EncodingQuality - { - VeryLowQuality, - LowQuality, - NormalQuality, - HighQuality, - VeryHighQuality - }; - - enum EncodingMode - { - ConstantQualityEncoding, - ConstantBitRateEncoding, - AverageBitRateEncoding, - TwoPassEncoding - }; - - enum AvailabilityError - { - NoError, - ServiceMissingError, - BusyError, - ResourceError - }; - -} - -QT_END_NAMESPACE - -QT_END_HEADER - - -#endif diff --git a/src/multimediakit/qtmedianamespace.qdoc b/src/multimediakit/qtmedianamespace.qdoc deleted file mode 100644 index dd6a1e44b..000000000 --- a/src/multimediakit/qtmedianamespace.qdoc +++ /dev/null @@ -1,208 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:FDL$ -** GNU Free Documentation License -** Alternatively, this file may be used under the terms of the GNU Free -** Documentation License version 1.3 as published by the Free Software -** Foundation and appearing in the file included in the packaging of -** this file. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms -** and conditions contained in a signed written agreement between you -** and Nokia. -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -/*! - \namespace QtMultimediaKit - \ingroup multimedia - \inmodule QtMultimediaKit - - \brief The QtMultimediaKit namespace contains miscellaneous identifiers used throughout the Qt Media services library. - - QtMultimediaKit is a module containing the low level, low latency, - Multimedia APIs which were introduced in Qt 4.6 and also includes the - high level QtMultimedia APIs which were introduced in QtMobility 1.0. - -*/ - -/*! - \enum QtMultimediaKit::MetaData - - This enum provides identifiers for meta-data attributes. - - \note Not all identifiers are supported on all platforms. Please consult vendor documentation for specific support - on different platforms. - - Common attributes - \value Title The title of the media. QString. - \value SubTitle The sub-title of the media. QString. - \value Author The authors of the media. QStringList. - \value Comment A user comment about the media. QString. - \value Description A description of the media. QString - \value Category The category of the media. QStringList. - \value Genre The genre of the media. QStringList. - \value Year The year of release of the media. int. - \value Date The date of the media. QDate. - \value UserRating A user rating of the media. int [0..100]. - \value Keywords A list of keywords describing the media. QStringList. - \value Language The language of media, as an ISO 639-2 code. - - \value Publisher The publisher of the media. QString. - \value Copyright The media's copyright notice. QString. - \value ParentalRating The parental rating of the media. QString. - \value RatingOrganisation The organisation responsible for the parental rating of the media. - QString. - - Media attributes - \value Size The size in bytes of the media. qint64 - \value MediaType The type of the media (audio, video, etc). QString. - \value Duration The duration in millseconds of the media. qint64. - - Audio attributes - \value AudioBitRate The bit rate of the media's audio stream in bits per second. int. - \value AudioCodec The codec of the media's audio stream. QString. - \value AverageLevel The average volume level of the media. int. - \value ChannelCount The number of channels in the media's audio stream. int. - \value PeakValue The peak volume of the media's audio stream. int - \value SampleRate The sample rate of the media's audio stream in hertz. int - - Music attributes - \value AlbumTitle The title of the album the media belongs to. QString. - \value AlbumArtist The principal artist of the album the media belongs to. QString. - \value ContributingArtist The artists contributing to the media. QStringList. - \value Composer The composer of the media. QStringList. - \value Conductor The conductor of the media. QString. - \value Lyrics The lyrics to the media. QString. - \value Mood The mood of the media. QString. - \value TrackNumber The track number of the media. int. - \value TrackCount The number of tracks on the album containing the media. int. - - \value CoverArtUrlSmall The URL of a small cover art image. QUrl. - \value CoverArtUrlLarge The URL of a large cover art image. QUrl. - \value CoverArtImage An embedded cover art image. QImage. - - Image and video attributes - \value Resolution The dimensions of an image or video. QSize. - \value PixelAspectRatio The pixel aspect ratio of an image or video. QSize. - - Video attributes - \value VideoFrameRate The frame rate of the media's video stream. qreal. - \value VideoBitRate The bit rate of the media's video stream in bits per second. int. - \value VideoCodec The codec of the media's video stream. QString. - - \value PosterUrl The URL of a poster image. QUrl. - \value PosterImage An embedded poster image. QImage. - - Movie attributes - \value ChapterNumber The chapter number of the media. int. - \value Director The director of the media. QString. - \value LeadPerformer The lead performer in the media. QStringList. - \value Writer The writer of the media. QStringList. - - Photo attributes. - \value CameraManufacturer The manufacturer of the camera used to capture the media. QString. - \value CameraModel The model of the camera used to capture the media. QString. - \value Event The event during which the media was captured. QString. - \value Subject The subject of the media. QString. - \value Orientation Orientation of image. - \value ExposureTime Exposure time, given in seconds. - \value FNumber The F Number. - \value ExposureProgram - The class of the program used by the camera to set exposure when the picture is taken. - \value ISOSpeedRatings - Indicates the ISO Speed and ISO Latitude of the camera or input device as specified in ISO 12232. - \value ExposureBiasValue - The exposure bias. - The unit is the APEX (Additive System of Photographic Exposure) setting. - \value DateTimeOriginal The date and time when the original image data was generated. - \value DateTimeDigitized The date and time when the image was stored as digital data. - \value SubjectDistance The distance to the subject, given in meters. - \value MeteringMode The metering mode. - \value LightSource - The kind of light source. - \value Flash - Status of flash when the image was shot. - \value FocalLength - The actual focal length of the lens, in mm. - \value ExposureMode - Indicates the exposure mode set when the image was shot. - \value WhiteBalance - Indicates the white balance mode set when the image was shot. - \value DigitalZoomRatio - Indicates the digital zoom ratio when the image was shot. - \value FocalLengthIn35mmFilm - Indicates the equivalent focal length assuming a 35mm film camera, in mm. - \value SceneCaptureType - Indicates the type of scene that was shot. - It can also be used to record the mode in which the image was shot. - \value GainControl - Indicates the degree of overall image gain adjustment. - \value Contrast - Indicates the direction of contrast processing applied by the camera when the image was shot. - \value Saturation - Indicates the direction of saturation processing applied by the camera when the image was shot. - \value Sharpness - Indicates the direction of sharpness processing applied by the camera when the image was shot. - \value DeviceSettingDescription - Exif tag, indicates information on the picture-taking conditions of a particular camera model. QString - - \value ThumbnailImage An embedded thumbnail image. QImage. -*/ - -/*! - \enum QtMultimediaKit::SupportEstimate - - Enumerates the levels of support a media service provider may have for a feature. - - \value NotSupported The feature is not supported. - \value MaybeSupported The feature may be supported. - \value ProbablySupported The feature is probably supported. - \value PreferredService The service is the preferred provider of a service. -*/ - -/*! - \enum QtMultimediaKit::EncodingQuality - - Enumerates quality encoding levels. - - \value VeryLowQuality - \value LowQuality - \value NormalQuality - \value HighQuality - \value VeryHighQuality -*/ - -/*! - \enum QtMultimediaKit::EncodingMode - - Enumerates encoding modes. - - \value ConstantQualityEncoding - \value ConstantBitRateEncoding - \value AverageBitRateEncoding - \value TwoPassEncoding -*/ - -/*! - \enum QtMultimediaKit::AvailabilityError - - Enumerates Service status errors. - - \value NoError The service is operating correctly. - \value ServiceMissingError There is no service available to provide the requested functionality. - \value ResourceError The service could not allocate resources required to function correctly. - \value BusyError The service must wait for access to necessary resources. -*/ diff --git a/src/multimediakit/qtmultimediakitdefs.h b/src/multimediakit/qtmultimediakitdefs.h deleted file mode 100644 index c7ba7101d..000000000 --- a/src/multimediakit/qtmultimediakitdefs.h +++ /dev/null @@ -1,90 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -// -// 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. -// - -#ifndef QTMULTIMEDIAKIT_P_H -#define QTMULTIMEDIAKIT_P_H - -#include - -QT_BEGIN_HEADER - -#if defined(Q_OS_WIN) -# if defined(QT_NODLL) -# undef QT_MAKEDLL -# undef QT_DLL -# elif defined(QT_MAKEDLL) -# if defined(QT_DLL) -# undef QT_DLL -# endif -# if defined(QT_BUILD_MULTIMEDIA_LIB) -# define Q_MULTIMEDIA_EXPORT Q_DECL_EXPORT -# else -# define Q_MULTIMEDIA_EXPORT Q_DECL_IMPORT -# endif -# elif defined(QT_DLL) /* use a Qt DLL library */ -# define Q_MULTIMEDIA_EXPORT Q_DECL_IMPORT -# endif -#endif - -#if !defined(Q_MULTIMEDIA_EXPORT) -# if defined(QT_SHARED) -# define Q_MULTIMEDIA_EXPORT Q_DECL_EXPORT -# else -# define Q_MULTIMEDIA_EXPORT -# endif -#endif - -QT_END_HEADER - - -#endif // QMULTIMEDIAKIT_P_H - diff --git a/src/multimediakit/qvideodevicecontrol.cpp b/src/multimediakit/qvideodevicecontrol.cpp deleted file mode 100644 index e1c5f099d..000000000 --- a/src/multimediakit/qvideodevicecontrol.cpp +++ /dev/null @@ -1,159 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qvideodevicecontrol.h" - -QT_BEGIN_NAMESPACE - -/*! - \class QVideoDeviceControl - - \brief The QVideoDeviceControl class provides an video device selector media control. - \inmodule QtMultimediaKit - \ingroup multimedia-serv - \since 1.0 - - The QVideoDeviceControl class provides descriptions of the video devices - available on a system and allows one to be selected as the endpoint of a - media service. - - The interface name of QVideoDeviceControl is \c com.nokia.Qt.VideoDeviceControl as - defined in QVideoDeviceControl_iid. -*/ - -/*! - \macro QVideoDeviceControl_iid - - \c com.nokia.Qt.VideoDeviceControl - - Defines the interface name of the QVideoDeviceControl class. - - \relates QVideoDeviceControl -*/ - -/*! - Constructs a video device control with the given \a parent. -*/ -QVideoDeviceControl::QVideoDeviceControl(QObject *parent) - :QMediaControl(parent) -{ -} - -/*! - Destroys a video device control. -*/ -QVideoDeviceControl::~QVideoDeviceControl() -{ -} - -/*! - \fn QVideoDeviceControl::deviceCount() const - - Returns the number of available video devices; - \since 1.0 -*/ - -/*! - \fn QVideoDeviceControl::deviceName(int index) const - - Returns the name of the video device at \a index. - \since 1.0 -*/ - -/*! - \fn QVideoDeviceControl::deviceDescription(int index) const - - Returns a description of the video device at \a index. - \since 1.0 -*/ - -/*! - \fn QVideoDeviceControl::deviceIcon(int index) const - - Returns an icon for the video device at \a index. - \since 1.0 -*/ - -/*! - \fn QVideoDeviceControl::defaultDevice() const - - Returns the index of the default video device. - \since 1.0 -*/ - -/*! - \fn QVideoDeviceControl::selectedDevice() const - - Returns the index of the selected video device. - \since 1.0 -*/ - -/*! - \fn QVideoDeviceControl::setSelectedDevice(int index) - - Sets the selected video device \a index. - \since 1.0 -*/ - -/*! - \fn QVideoDeviceControl::devicesChanged() - - Signals that the list of available video devices has changed. - \since 1.0 -*/ - -/*! - \fn QVideoDeviceControl::selectedDeviceChanged(int index) - - Signals that the selected video device \a index has changed. - \since 1.0 -*/ - -/*! - \fn QVideoDeviceControl::selectedDeviceChanged(const QString &name) - - Signals that the selected video device \a name has changed. - \since 1.0 -*/ - -#include "moc_qvideodevicecontrol.cpp" -QT_END_NAMESPACE - diff --git a/src/multimediakit/qvideodevicecontrol.h b/src/multimediakit/qvideodevicecontrol.h deleted file mode 100644 index 6f44c4671..000000000 --- a/src/multimediakit/qvideodevicecontrol.h +++ /dev/null @@ -1,88 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QVIDEODEVICECONTROL_H -#define QVIDEODEVICECONTROL_H - -#include "qmediacontrol.h" - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -QT_MODULE(Multimedia) - -class Q_MULTIMEDIA_EXPORT QVideoDeviceControl : public QMediaControl -{ - Q_OBJECT - -public: - virtual ~QVideoDeviceControl(); - - virtual int deviceCount() const = 0; - - virtual QString deviceName(int index) const = 0; - virtual QString deviceDescription(int index) const = 0; - virtual QIcon deviceIcon(int index) const = 0; - - virtual int defaultDevice() const = 0; - virtual int selectedDevice() const = 0; - -public Q_SLOTS: - virtual void setSelectedDevice(int index) = 0; - -Q_SIGNALS: - void selectedDeviceChanged(int index); - void selectedDeviceChanged(const QString &deviceName); - void devicesChanged(); - -protected: - QVideoDeviceControl(QObject *parent = 0); -}; - -#define QVideoDeviceControl_iid "com.nokia.Qt.QVideoDeviceControl/1.0" -Q_MEDIA_DECLARE_CONTROL(QVideoDeviceControl, QVideoDeviceControl_iid) - -QT_END_NAMESPACE - -QT_END_HEADER - -#endif // QVIDEODEVICECONTROL_H diff --git a/src/multimediakit/qvideoencodercontrol.cpp b/src/multimediakit/qvideoencodercontrol.cpp deleted file mode 100644 index b747f0ef6..000000000 --- a/src/multimediakit/qvideoencodercontrol.cpp +++ /dev/null @@ -1,190 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qvideoencodercontrol.h" -#include -#include - -QT_BEGIN_NAMESPACE - -/*! - \class QVideoEncoderControl - - \inmodule QtMultimediaKit - \ingroup multimedia-serv - \since 1.0 - - \brief The QVideoEncoderControl class provides access to the settings - of a media service that performs video encoding. - - If a QMediaService supports encoding video data it will implement - QVideoEncoderControl. This control provides information about the limits - of restricted video encoder options and allows the selection of a set of - video encoder settings as specified in a QVideoEncoderSettings object. - - The functionality provided by this control is exposed to application code - through the QMediaRecorder class. - - The interface name of QVideoEncoderControl is \c com.nokia.Qt.QVideoEncoderControl/1.0 as - defined in QVideoEncoderControl_iid. - - \sa QMediaRecorder, QVideoEncoderSettings, QMediaService::requestControl() -*/ - -/*! - \macro QVideoEncoderControl_iid - - \c com.nokia.Qt.QVideoEncoderControl/1.0 - - Defines the interface name of the QVideoEncoderControl class. - - \relates QVideoEncoderControl -*/ - -/*! - Create a new video encoder control object with the given \a parent. -*/ -QVideoEncoderControl::QVideoEncoderControl(QObject *parent) - :QMediaControl(parent) -{ -} - -/*! - Destroys a video encoder control. -*/ -QVideoEncoderControl::~QVideoEncoderControl() -{ -} - -/*! - \fn QVideoEncoderControl::supportedVideoCodecs() const - - Returns the list of supported video codecs. - \since 1.0 -*/ - -/*! - \fn QVideoEncoderControl::videoCodecDescription(const QString &codec) const - - Returns a description of a video \a codec. - \since 1.0 -*/ - -/*! - \fn QVideoEncoderControl::supportedEncodingOptions(const QString &codec) const - - Returns a list of supported encoding options for a video \a codec. - - The names and types of the options in the list is system dependent. - \since 1.0 -*/ - -/*! - \fn QVideoEncoderControl::encodingOption(const QString &codec, const QString &option) const - - Returns the value of a video \a codec \a option. - \since 1.0 -*/ - -/*! - \fn QVideoEncoderControl::setEncodingOption(const QString &codec, const QString &option, const QVariant &value) - - Sets the \a value of a \a codec specific \a option. - \since 1.0 -*/ - -/*! - \fn QVideoEncoderControl::supportedResolutions(const QVideoEncoderSettings &settings = QVideoEncoderSettings(), - bool *continuous = 0) const - - Returns a list of supported resolutions. - - If non null video \a settings parameter is passed, - the returned list is reduced to resolution supported with partial settings like - \l {QVideoEncoderSettings::setCodec()}{video codec} or - \l {QVideoEncoderSettings::setFrameRate()}{frame rate} applied. - - If the encoder supports arbitrary resolutions within the supported resolutions range, - *\a continuous is set to true, otherwise *\a continuous is set to false. - - \since 1.0 - \sa QVideoEncoderSettings::resolution() -*/ - -/*! - \fn QVideoEncoderControl::supportedFrameRates(const QVideoEncoderSettings &settings = QVideoEncoderSettings(), - bool *continuous = 0) const - - Returns a list of supported frame rates. - - If non null video \a settings parameter is passed, - the returned list is reduced to frame rates supported with partial settings like - \l {QVideoEncoderSettings::setCodec()}{video codec} or - \l {QVideoEncoderSettings::setResolution()}{video resolution} applied. - - If the encoder supports arbitrary frame rates within the supported range, - *\a continuous is set to true, otherwise *\a continuous is set to false. - - \since 1.0 - \sa QVideoEncoderSettings::frameRate() -*/ - -/*! - \fn QVideoEncoderControl::videoSettings() const - - Returns the video encoder settings. - - The returned value may be different tha passed to QVideoEncoderControl::setVideoSettings() - if the settings contains the default or undefined parameters. - In this case if the undefined parameters are already resolved, they should be returned. - \since 1.0 -*/ - -/*! - \fn QVideoEncoderControl::setVideoSettings(const QVideoEncoderSettings &settings) - - Sets the selected video encoder \a settings. - \since 1.0 -*/ - -#include "moc_qvideoencodercontrol.cpp" -QT_END_NAMESPACE - diff --git a/src/multimediakit/qvideoencodercontrol.h b/src/multimediakit/qvideoencodercontrol.h deleted file mode 100644 index 343af8039..000000000 --- a/src/multimediakit/qvideoencodercontrol.h +++ /dev/null @@ -1,98 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QVIDEOENCODERCONTROL_H -#define QVIDEOENCODERCONTROL_H - -#include "qmediacontrol.h" -#include "qmediarecorder.h" - -#include -#include - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -QT_MODULE(Multimedia) - -class QByteArray; -class QStringList; -QT_END_NAMESPACE - -QT_BEGIN_NAMESPACE - -class Q_MULTIMEDIA_EXPORT QVideoEncoderControl : public QMediaControl -{ - Q_OBJECT - -public: - virtual ~QVideoEncoderControl(); - - virtual QList supportedResolutions(const QVideoEncoderSettings &settings, - bool *continuous = 0) const = 0; - - virtual QList supportedFrameRates(const QVideoEncoderSettings &settings, - bool *continuous = 0) const = 0; - - virtual QStringList supportedVideoCodecs() const = 0; - virtual QString videoCodecDescription(const QString &codecName) const = 0; - - virtual QVideoEncoderSettings videoSettings() const = 0; - virtual void setVideoSettings(const QVideoEncoderSettings &settings) = 0; - - virtual QStringList supportedEncodingOptions(const QString &codec) const = 0; - virtual QVariant encodingOption(const QString &codec, const QString &name) const = 0; - virtual void setEncodingOption(const QString &codec, const QString &name, const QVariant &value) = 0; - -protected: - QVideoEncoderControl(QObject *parent = 0); -}; - -#define QVideoEncoderControl_iid "com.nokia.Qt.QVideoEncoderControl/1.0" -Q_MEDIA_DECLARE_CONTROL(QVideoEncoderControl, QVideoEncoderControl_iid) - -QT_END_NAMESPACE - -QT_END_HEADER - - -#endif diff --git a/src/multimediakit/qvideorenderercontrol.cpp b/src/multimediakit/qvideorenderercontrol.cpp deleted file mode 100644 index 0025d187f..000000000 --- a/src/multimediakit/qvideorenderercontrol.cpp +++ /dev/null @@ -1,114 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qvideorenderercontrol.h" - -#include "qmediacontrol_p.h" - -QT_BEGIN_NAMESPACE - -/*! - \class QVideoRendererControl - - - \brief The QVideoRendererControl class provides a control for rendering - to a video surface. - - \inmodule QtMultimediaKit - \ingroup multimedia-serv - \since 1.0 - - Using the surface() property of QVideoRendererControl a - QAbstractVideoSurface may be set as the video render target of a - QMediaService. - - \snippet doc/src/snippets/multimedia-snippets/video.cpp Video renderer control - - QVideoRendererControl is one of a number of possible video output controls. - - The interface name of QVideoRendererControl is \c com.nokia.Qt.QVideoRendererControl/1.0 as - defined in QVideoRendererControl_iid. - - \sa QMediaService::requestControl(), QVideoWidget -*/ - -/*! - \macro QVideoRendererControl_iid - - \c com.nokia.Qt.QVideoRendererControl/1.0 - - Defines the interface name of the QVideoRendererControl class. - - \relates QVideoRendererControl -*/ - -/*! - Constructs a new video renderer media end point with the given \a parent. -*/ -QVideoRendererControl::QVideoRendererControl(QObject *parent) - : QMediaControl(parent) -{ -} - -/*! - Destroys a video renderer media end point. -*/ -QVideoRendererControl::~QVideoRendererControl() -{ -} - -/*! - \fn QVideoRendererControl::surface() const - - Returns the surface a video producer renders to. - \since 1.0 -*/ - -/*! - \fn QVideoRendererControl::setSurface(QAbstractVideoSurface *surface) - - Sets the \a surface a video producer renders to. - \since 1.0 -*/ - -#include "moc_qvideorenderercontrol.cpp" -QT_END_NAMESPACE - diff --git a/src/multimediakit/qvideorenderercontrol.h b/src/multimediakit/qvideorenderercontrol.h deleted file mode 100644 index b3a70837c..000000000 --- a/src/multimediakit/qvideorenderercontrol.h +++ /dev/null @@ -1,81 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QVIDEORENDERERCONTROL_H -#define QVIDEORENDERERCONTROL_H - -#include "qmediacontrol.h" - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -QT_MODULE(Multimedia) - -class QAbstractVideoSurface; -QT_END_NAMESPACE - -QT_BEGIN_NAMESPACE - - -class Q_MULTIMEDIA_EXPORT QVideoRendererControl : public QMediaControl -{ - Q_OBJECT - -public: - ~QVideoRendererControl(); - - virtual QAbstractVideoSurface *surface() const = 0; - virtual void setSurface(QAbstractVideoSurface *surface) = 0; - -protected: - QVideoRendererControl(QObject *parent = 0); -}; - -#define QVideoRendererControl_iid "com.nokia.Qt.QVideoRendererControl/1.0" -Q_MEDIA_DECLARE_CONTROL(QVideoRendererControl, QVideoRendererControl_iid) - -QT_END_NAMESPACE - -QT_END_HEADER - - -#endif // QVIDEORENDERERCONTROL_H diff --git a/src/multimediakit/qvideosurfaceoutput.cpp b/src/multimediakit/qvideosurfaceoutput.cpp deleted file mode 100644 index cdbec5596..000000000 --- a/src/multimediakit/qvideosurfaceoutput.cpp +++ /dev/null @@ -1,100 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qvideosurfaceoutput_p.h" - -#include -#include -#include - - -QVideoSurfaceOutput::QVideoSurfaceOutput(QObject*parent) - : QObject(parent) -{ -} - -QVideoSurfaceOutput::~QVideoSurfaceOutput() -{ - if (m_control) { - m_control.data()->setSurface(0); - m_service.data()->releaseControl(m_control.data()); - } -} - -QMediaObject *QVideoSurfaceOutput::mediaObject() const -{ - return m_object.data(); -} - -void QVideoSurfaceOutput::setVideoSurface(QAbstractVideoSurface *surface) -{ - m_surface = surface; - - if (m_control) - m_control.data()->setSurface(surface); -} - -bool QVideoSurfaceOutput::setMediaObject(QMediaObject *object) -{ - if (m_control) { - m_control.data()->setSurface(0); - m_service.data()->releaseControl(m_control.data()); - } - m_control.clear(); - m_service.clear(); - m_object.clear(); - - if (object) { - if (QMediaService *service = object->service()) { - if (QMediaControl *control = service->requestControl(QVideoRendererControl_iid)) { - if ((m_control = qobject_cast(control))) { - m_service = service; - m_object = object; - m_control.data()->setSurface(m_surface.data()); - - return true; - } - service->releaseControl(control); - } - } - } - return false; -} diff --git a/src/multimediakit/qvideosurfaceoutput_p.h b/src/multimediakit/qvideosurfaceoutput_p.h deleted file mode 100644 index 76ec5e84d..000000000 --- a/src/multimediakit/qvideosurfaceoutput_p.h +++ /dev/null @@ -1,86 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QVIDEOSURFACEOUTPUT_P_H -#define QVIDEOSURFACEOUTPUT_P_H - -#include - -#include - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -QT_MODULE(Multimedia) - - -class QAbstractVideoSurface; -class QVideoRendererControl; - -class QVideoSurfaceOutput : public QObject, public QMediaBindableInterface -{ - Q_OBJECT - Q_INTERFACES(QMediaBindableInterface) -public: - QVideoSurfaceOutput(QObject*parent = 0); - ~QVideoSurfaceOutput(); - - QMediaObject *mediaObject() const; - - void setVideoSurface(QAbstractVideoSurface *surface); - -protected: - bool setMediaObject(QMediaObject *object); - -private: - QWeakPointer m_surface; - QWeakPointer m_control; - QWeakPointer m_service; - QWeakPointer m_object; -}; - -QT_END_NAMESPACE - -QT_END_HEADER - - -#endif diff --git a/src/multimediakit/video/qabstractvideobuffer.cpp b/src/multimediakit/video/qabstractvideobuffer.cpp deleted file mode 100644 index 88c00f6a5..000000000 --- a/src/multimediakit/video/qabstractvideobuffer.cpp +++ /dev/null @@ -1,202 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qabstractvideobuffer_p.h" - -#include - -QT_BEGIN_NAMESPACE - -/*! - \class QAbstractVideoBuffer - \brief The QAbstractVideoBuffer class is an abstraction for video data. - \since 1.0 - \inmodule QtMultimediaKit - - The QVideoFrame class makes use of a QAbstractVideoBuffer internally to reference a buffer of - video data. Creating a subclass of QAbstractVideoBuffer will allow you to construct video - frames from preallocated or static buffers. - - The contents of a buffer can be accessed by mapping the buffer to memory using the map() - function which returns a pointer to memory containing the contents of the the video buffer. - The memory returned by map() is released by calling the unmap() function. - - The handle() of a buffer may also be used to manipulate its contents using type specific APIs. - The type of a buffer's handle is given by the handleType() function. - - \sa QVideoFrame -*/ - -/*! - \enum QAbstractVideoBuffer::HandleType - - Identifies the type of a video buffers handle. - - \value NoHandle The buffer has no handle, its data can only be accessed by mapping the buffer. - \value GLTextureHandle The handle of the buffer is an OpenGL texture ID. - \value XvShmImageHandle The handle contains pointer to shared memory XVideo image. - \value CoreImageHandle The handle contains pointer to Mac OS X CIImage. - \value QPixmapHandle The handle of the buffer is a QPixmap. - \value UserHandle Start value for user defined handle types. - - \sa handleType() -*/ - -/*! - \enum QAbstractVideoBuffer::MapMode - - Enumerates how a video buffer's data is mapped to memory. - - \value NotMapped The video buffer has is not mapped to memory. - \value ReadOnly The mapped memory is populated with data from the video buffer when mapped, but - the content of the mapped memory may be discarded when unmapped. - \value WriteOnly The mapped memory is uninitialized when mapped, and the content will be used to - populate the video buffer when unmapped. - \value ReadWrite The mapped memory is populated with data from the video buffer, and the - video buffer is repopulated with the content of the mapped memory. - - \sa mapMode(), map() -*/ - -/*! - Constructs an abstract video buffer of the given \a type. -*/ -QAbstractVideoBuffer::QAbstractVideoBuffer(HandleType type) - : d_ptr(new QAbstractVideoBufferPrivate) -{ - Q_D(QAbstractVideoBuffer); - - d->handleType = type; -} - -/*! - \internal -*/ -QAbstractVideoBuffer::QAbstractVideoBuffer(QAbstractVideoBufferPrivate &dd, HandleType type) - : d_ptr(&dd) -{ - Q_D(QAbstractVideoBuffer); - - d->handleType = type; -} - -/*! - Destroys an abstract video buffer. -*/ -QAbstractVideoBuffer::~QAbstractVideoBuffer() -{ - delete d_ptr; -} - -/*! - Returns the type of a video buffer's handle. - - \since 1.0 - \sa handle() -*/ -QAbstractVideoBuffer::HandleType QAbstractVideoBuffer::handleType() const -{ - return d_func()->handleType; -} - -/*! - \fn QAbstractVideoBuffer::mapMode() const - - Returns the mode a video buffer is mapped in. - - \since 1.0 - \sa map() -*/ - -/*! - \fn QAbstractVideoBuffer::map(MapMode mode, int *numBytes, int *bytesPerLine) - - Maps the contents of a video buffer to memory. - - The map \a mode indicates whether the contents of the mapped memory should be read from and/or - written to the buffer. If the map mode includes the QAbstractVideoBuffer::ReadOnly flag the - mapped memory will be populated with the content of the video buffer when mapped. If the map - mode includes the QAbstractVideoBuffer::WriteOnly flag the content of the mapped memory will be - persisted in the buffer when unmapped. - - When access to the data is no longer needed be sure to call the unmap() function to release the - mapped memory. - - Returns a pointer to the mapped memory region, or a null pointer if the mapping failed. The - size in bytes of the mapped memory region is returned in \a numBytes, and the line stride in \a - bytesPerLine. - - When access to the data is no longer needed be sure to unmap() the buffer. - - \note Writing to memory that is mapped as read-only is undefined, and may result in changes - to shared data. - - \since 1.0 - \sa unmap(), mapMode() -*/ - -/*! - \fn QAbstractVideoBuffer::unmap() - - Releases the memory mapped by the map() function - - If the \l {QAbstractVideoBuffer::MapMode}{MapMode} included the QAbstractVideoBuffer::WriteOnly - flag this will persist the current content of the mapped memory to the video frame. - - \since 1.0 - \sa map() -*/ - -/*! - Returns a type specific handle to the data buffer. - - The type of the handle is given by handleType() function. - - \since 1.0 - \sa handleType() -*/ -QVariant QAbstractVideoBuffer::handle() const -{ - return QVariant(); -} - - -QT_END_NAMESPACE diff --git a/src/multimediakit/video/qabstractvideobuffer.h b/src/multimediakit/video/qabstractvideobuffer.h deleted file mode 100644 index 5662ee140..000000000 --- a/src/multimediakit/video/qabstractvideobuffer.h +++ /dev/null @@ -1,112 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QABSTRACTVIDEOBUFFER_H -#define QABSTRACTVIDEOBUFFER_H - -#include -#include - - -#include - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -QT_MODULE(Multimedia) - - -class QVariant; - -class QAbstractVideoBufferPrivate; - -class Q_MULTIMEDIA_EXPORT QAbstractVideoBuffer -{ -public: - enum HandleType - { - NoHandle, - GLTextureHandle, - XvShmImageHandle, - CoreImageHandle, - QPixmapHandle, - UserHandle = 1000 - }; - - enum MapMode - { - NotMapped = 0x00, - ReadOnly = 0x01, - WriteOnly = 0x02, - ReadWrite = ReadOnly | WriteOnly - }; - - QAbstractVideoBuffer(HandleType type); - virtual ~QAbstractVideoBuffer(); - - HandleType handleType() const; - - virtual MapMode mapMode() const = 0; - - virtual uchar *map(MapMode mode, int *numBytes, int *bytesPerLine) = 0; - virtual void unmap() = 0; - - virtual QVariant handle() const; - -protected: - QAbstractVideoBuffer(QAbstractVideoBufferPrivate &dd, HandleType type); - - QAbstractVideoBufferPrivate *d_ptr; - -private: - Q_DECLARE_PRIVATE(QAbstractVideoBuffer) - Q_DISABLE_COPY(QAbstractVideoBuffer) -}; - -QT_END_NAMESPACE - -Q_DECLARE_METATYPE(QAbstractVideoBuffer::HandleType) -Q_DECLARE_METATYPE(QAbstractVideoBuffer::MapMode) - -QT_END_HEADER - -#endif diff --git a/src/multimediakit/video/qabstractvideobuffer_p.h b/src/multimediakit/video/qabstractvideobuffer_p.h deleted file mode 100644 index 80c37222b..000000000 --- a/src/multimediakit/video/qabstractvideobuffer_p.h +++ /dev/null @@ -1,88 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QABSTRACTVIDEOBUFFER_P_H -#define QABSTRACTVIDEOBUFFER_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 -#include "qabstractvideobuffer.h" - -#include -#include - - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -QT_MODULE(Multimedia) - - -class QAbstractVideoBufferPrivate -{ -public: - QAbstractVideoBufferPrivate() - : handleType(QAbstractVideoBuffer::NoHandle) - {} - - virtual ~QAbstractVideoBufferPrivate() - {} - - QAbstractVideoBuffer::HandleType handleType; -}; - -QT_END_NAMESPACE - -QT_END_HEADER - - -#endif diff --git a/src/multimediakit/video/qabstractvideosurface.cpp b/src/multimediakit/video/qabstractvideosurface.cpp deleted file mode 100644 index 62a8acf57..000000000 --- a/src/multimediakit/video/qabstractvideosurface.cpp +++ /dev/null @@ -1,340 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -//TESTED_COMPONENT=src/multimedia - -#include "qabstractvideosurface.h" - -#include "qvideosurfaceformat.h" - -#include - -QT_BEGIN_NAMESPACE - -Q_DECLARE_METATYPE(QVideoSurfaceFormat) -Q_DECLARE_METATYPE(QAbstractVideoSurface::Error) - -/*! - \class QAbstractVideoSurface - \brief The QAbstractVideoSurface class is a base class for video presentation surfaces. - \since 1.0 - \inmodule QtMultimediaKit - - A video surface presents a continuous stream of identically formatted frames, where the format - of each frame is compatible with a stream format supplied when starting a presentation. - - The QAbstractVideoSurface class defines the standard interface that video producers use to - inter-operate with video presentation surfaces. It is not supposed to be instantiated directly. - Instead, you should subclass it to create new video surfaces. - - A list of pixel formats a surface can present is given by the supportedPixelFormats() function, - and the isFormatSupported() function will test if a video surface format is supported. If a - format is not supported the nearestFormat() function may be able to suggest a similar format. - For example, if a surface supports fixed set of resolutions it may suggest the smallest - supported resolution that contains the proposed resolution. - - The start() function takes a supported format and enables a video surface. Once started a - surface will begin displaying the frames it receives in the present() function. Surfaces may - hold a reference to the buffer of a presented video frame until a new frame is presented or - streaming is stopped. The stop() function will disable a surface and a release any video - buffers it holds references to. -*/ - -/*! - \enum QAbstractVideoSurface::Error - This enum describes the errors that may be returned by the error() function. - - \value NoError No error occurred. - \value UnsupportedFormatError A video format was not supported. - \value IncorrectFormatError A video frame was not compatible with the format of the surface. - \value StoppedError The surface has not been started. - \value ResourceError The surface could not allocate some resource. -*/ - -/*! - Constructs a video surface with the given \a parent. -*/ -QAbstractVideoSurface::QAbstractVideoSurface(QObject *parent) - : QObject(parent) -{ - setProperty("_q_surfaceFormat", QVariant::fromValue(QVideoSurfaceFormat())); - setProperty("_q_active", false); - setProperty("_q_error", QVariant::fromValue(QAbstractVideoSurface::NoError)); - setProperty("_q_nativeResolution", QSize()); -} - -// XXX Qt5 -/*! - \internal - - This is deprecated. - - Since we need to build without access to Qt's private headers we can't reliably inherit - from QObjectPrivate. Binary compatibility means we can't remove this constructor or - add a d pointer to QAbstractVideoSurface. -*/ -QAbstractVideoSurface::QAbstractVideoSurface(QAbstractVideoSurfacePrivate &, QObject *parent) - : QObject(parent) -{ -} - -/*! - Destroys a video surface. -*/ -QAbstractVideoSurface::~QAbstractVideoSurface() -{ -} - -/*! - \fn QAbstractVideoSurface::supportedPixelFormats(QAbstractVideoBuffer::HandleType type) const - - Returns a list of pixel formats a video surface can present for a given handle \a type. - - The pixel formats returned for the QAbstractVideoBuffer::NoHandle type are valid for any buffer - that can be mapped in read-only mode. - - Types that are first in the list can be assumed to be faster to render. - \since 1.0 -*/ - -/*! - Tests a video surface \a format to determine if a surface can accept it. - - Returns true if the format is supported by the surface, and false otherwise. - \since 1.0 -*/ -bool QAbstractVideoSurface::isFormatSupported(const QVideoSurfaceFormat &format) const -{ - return supportedPixelFormats(format.handleType()).contains(format.pixelFormat()); -} - -/*! - Returns a supported video surface format that is similar to \a format. - - A similar surface format is one that has the same \l {QVideoSurfaceFormat::pixelFormat()}{pixel - format} and \l {QVideoSurfaceFormat::handleType()}{handle type} but may differ in some of the other - properties. For example, if there are restrictions on the \l {QVideoSurfaceFormat::frameSize()} - {frame sizes} a video surface can accept it may suggest a format with a larger frame size and - a \l {QVideoSurfaceFormat::viewport()}{viewport} the size of the original frame size. - - If the format is already supported it will be returned unchanged, or if there is no similar - supported format an invalid format will be returned. - \since 1.0 -*/ -QVideoSurfaceFormat QAbstractVideoSurface::nearestFormat(const QVideoSurfaceFormat &format) const -{ - return isFormatSupported(format) - ? format - : QVideoSurfaceFormat(); -} - -/*! - \fn QAbstractVideoSurface::supportedFormatsChanged() - - Signals that the set of formats supported by a video surface has changed. - - \since 1.0 - \sa supportedPixelFormats(), isFormatSupported() -*/ - -/*! - Returns the format of a video surface. - \since 1.0 -*/ -QVideoSurfaceFormat QAbstractVideoSurface::surfaceFormat() const -{ - return property("_q_format").value(); -} - -/*! - \fn QAbstractVideoSurface::surfaceFormatChanged(const QVideoSurfaceFormat &format) - - Signals that the configured \a format of a video surface has changed. - - \since 1.0 - \sa surfaceFormat(), start() -*/ - -/*! - Starts a video surface presenting \a format frames. - - Returns true if the surface was started, and false if an error occurred. - - \since 1.0 - \sa isActive(), stop() -*/ -bool QAbstractVideoSurface::start(const QVideoSurfaceFormat &format) -{ - bool wasActive = property("_q_active").toBool(); - - setProperty("_q_active", true); - setProperty("_q_format", QVariant::fromValue(format)); - setProperty("_q_error", QVariant::fromValue(NoError)); - - emit surfaceFormatChanged(format); - - if (!wasActive) - emit activeChanged(true); - - return true; -} - -/*! - Stops a video surface presenting frames and releases any resources acquired in start(). - - \since 1.0 - \sa isActive(), start() -*/ -void QAbstractVideoSurface::stop() -{ - if (property("_q_active").toBool()) { - setProperty("_q_format", QVariant::fromValue(QVideoSurfaceFormat())); - setProperty("_q_active", false); - - emit activeChanged(false); - emit surfaceFormatChanged(surfaceFormat()); - } -} - -/*! - Indicates whether a video surface has been started. - - Returns true if the surface has been started, and false otherwise. - \since 1.0 -*/ -bool QAbstractVideoSurface::isActive() const -{ - return property("_q_active").toBool(); -} - -/*! - \fn QAbstractVideoSurface::activeChanged(bool active) - - Signals that the \a active state of a video surface has changed. - - \since 1.0 - \sa isActive(), start(), stop() -*/ - -/*! - \fn QAbstractVideoSurface::present(const QVideoFrame &frame) - - Presents a video \a frame. - - Returns true if the frame was presented, and false if an error occurred. - - Not all surfaces will block until the presentation of a frame has completed. Calling present() - on a non-blocking surface may fail if called before the presentation of a previous frame has - completed. In such cases the surface may not return to a ready state until it has had an - opportunity to process events. - - If present() fails for any other reason the surface will immediately enter the stopped state - and an error() value will be set. - - A video surface must be in the started state for present() to succeed, and the format of the - video frame must be compatible with the current video surface format. - - \since 1.0 - \sa error() -*/ - -/*! - Returns the last error that occurred. - - If a surface fails to start(), or stops unexpectedly this function can be called to discover - what error occurred. - \since 1.0 -*/ - -QAbstractVideoSurface::Error QAbstractVideoSurface::error() const -{ - return property("_q_error").value(); -} - -/*! - Sets the value of error() to \a error. - \since 1.0 -*/ -void QAbstractVideoSurface::setError(Error error) -{ - setProperty("_q_error", QVariant::fromValue(error)); -} - -/*! - \property QAbstractVideoSurface::nativeResolution - - The native resolution of video surface. - This is the resolution of video frames the surface - can render with optimal quality and/or performance. - - The native resolution is not always known and can be changed during playback. - \since 1.1 - */ -QSize QAbstractVideoSurface::nativeResolution() const -{ - return property("_q_nativeResolution").toSize(); -} - -/*! - Set the video surface native \a resolution. - \since 1.1 - */ -void QAbstractVideoSurface::setNativeResolution(const QSize &resolution) -{ - const QSize nativeResolution = property("_q_nativeResolution").toSize(); - - if (nativeResolution != resolution) { - setProperty("_q_nativeResolution", resolution); - - emit nativeResolutionChanged(resolution); - } -} -/*! - \fn QAbstractVideoSurface::nativeResolutionChanged(const QSize &resolution); - - Signals the native \a resolution of video surface has changed. - \since 1.1 -*/ - -QT_END_NAMESPACE - -#include "moc_qabstractvideosurface.cpp" - diff --git a/src/multimediakit/video/qabstractvideosurface.h b/src/multimediakit/video/qabstractvideosurface.h deleted file mode 100644 index 37c4d385f..000000000 --- a/src/multimediakit/video/qabstractvideosurface.h +++ /dev/null @@ -1,115 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QABSTRACTVIDEOSURFACE_H -#define QABSTRACTVIDEOSURFACE_H - -#include -#include - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -QT_MODULE(Multimedia) - - -class QRectF; -class QVideoSurfaceFormat; - -class QAbstractVideoSurfacePrivate; - -class Q_MULTIMEDIA_EXPORT QAbstractVideoSurface : public QObject -{ - Q_OBJECT - Q_PROPERTY(QSize nativeResolution READ nativeResolution NOTIFY nativeResolutionChanged) -public: - enum Error - { - NoError, - UnsupportedFormatError, - IncorrectFormatError, - StoppedError, - ResourceError - }; - - explicit QAbstractVideoSurface(QObject *parent = 0); - ~QAbstractVideoSurface(); - - virtual QList supportedPixelFormats( - QAbstractVideoBuffer::HandleType handleType = QAbstractVideoBuffer::NoHandle) const = 0; - virtual bool isFormatSupported(const QVideoSurfaceFormat &format) const; - virtual QVideoSurfaceFormat nearestFormat(const QVideoSurfaceFormat &format) const; - - QVideoSurfaceFormat surfaceFormat() const; - - QSize nativeResolution() const; - - virtual bool start(const QVideoSurfaceFormat &format); - virtual void stop(); - - bool isActive() const; - - virtual bool present(const QVideoFrame &frame) = 0; - - Error error() const; - -Q_SIGNALS: - void activeChanged(bool active); - void surfaceFormatChanged(const QVideoSurfaceFormat &format); - void supportedFormatsChanged(); - void nativeResolutionChanged(const QSize &); - -protected: - QAbstractVideoSurface(QAbstractVideoSurfacePrivate &dd, QObject *parent); - - void setError(Error error); - void setNativeResolution(const QSize &resolution); - -private: - Q_DECLARE_PRIVATE(QAbstractVideoSurface) -}; - -QT_END_NAMESPACE - -QT_END_HEADER - -#endif diff --git a/src/multimediakit/video/qimagevideobuffer.cpp b/src/multimediakit/video/qimagevideobuffer.cpp deleted file mode 100644 index e16abc30b..000000000 --- a/src/multimediakit/video/qimagevideobuffer.cpp +++ /dev/null @@ -1,106 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qimagevideobuffer_p.h" - -#include "qabstractvideobuffer_p.h" - -#include -#include - -QT_BEGIN_NAMESPACE - -class QImageVideoBufferPrivate : public QAbstractVideoBufferPrivate -{ -public: - QImageVideoBufferPrivate() - : mapMode(QAbstractVideoBuffer::NotMapped) - { - } - - QAbstractVideoBuffer::MapMode mapMode; - QImage image; -}; - -QImageVideoBuffer::QImageVideoBuffer(const QImage &image) - : QAbstractVideoBuffer(*new QImageVideoBufferPrivate, NoHandle) -{ - Q_D(QImageVideoBuffer); - - d->image = image; -} - -QImageVideoBuffer::~QImageVideoBuffer() -{ -} - -QAbstractVideoBuffer::MapMode QImageVideoBuffer::mapMode() const -{ - return d_func()->mapMode; -} - -uchar *QImageVideoBuffer::map(MapMode mode, int *numBytes, int *bytesPerLine) -{ - Q_D(QImageVideoBuffer); - - if (d->mapMode == NotMapped && d->image.bits() && mode != NotMapped) { - d->mapMode = mode; - - if (numBytes) - *numBytes = d->image.byteCount(); - - if (bytesPerLine) - *bytesPerLine = d->image.bytesPerLine(); - - return d->image.bits(); - } else { - return 0; - } -} - -void QImageVideoBuffer::unmap() -{ - Q_D(QImageVideoBuffer); - - d->mapMode = NotMapped; -} - -QT_END_NAMESPACE diff --git a/src/multimediakit/video/qimagevideobuffer_p.h b/src/multimediakit/video/qimagevideobuffer_p.h deleted file mode 100644 index dae952ed4..000000000 --- a/src/multimediakit/video/qimagevideobuffer_p.h +++ /dev/null @@ -1,87 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QIMAGEVIDEOBUFFER_P_H -#define QIMAGEVIDEOBUFFER_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 - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -QT_MODULE(Multimedia) - - -class QImage; - -class QImageVideoBufferPrivate; - -class Q_MULTIMEDIA_EXPORT QImageVideoBuffer : public QAbstractVideoBuffer -{ - Q_DECLARE_PRIVATE(QImageVideoBuffer) -public: - QImageVideoBuffer(const QImage &image); - ~QImageVideoBuffer(); - - MapMode mapMode() const; - - uchar *map(MapMode mode, int *numBytes, int *bytesPerLine); - void unmap(); -}; - -QT_END_NAMESPACE - -QT_END_HEADER - - -#endif diff --git a/src/multimediakit/video/qmemoryvideobuffer.cpp b/src/multimediakit/video/qmemoryvideobuffer.cpp deleted file mode 100644 index d3516182a..000000000 --- a/src/multimediakit/video/qmemoryvideobuffer.cpp +++ /dev/null @@ -1,132 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qmemoryvideobuffer_p.h" - -#include "qabstractvideobuffer_p.h" -#include - -QT_BEGIN_NAMESPACE - -class QMemoryVideoBufferPrivate : public QAbstractVideoBufferPrivate -{ -public: - QMemoryVideoBufferPrivate() - : bytesPerLine(0) - , mapMode(QAbstractVideoBuffer::NotMapped) - { - } - - int bytesPerLine; - QAbstractVideoBuffer::MapMode mapMode; - QByteArray data; -}; - -/*! - \class QMemoryVideoBuffer - \brief The QMemoryVideoBuffer class provides a system memory allocated video data buffer. - \internal - - QMemoryVideoBuffer is the default video buffer for allocating system memory. It may be used to - allocate memory for a QVideoFrame without implementing your own QAbstractVideoBuffer. -*/ - -/*! - Constructs a video buffer with an image stride of \a bytesPerLine from a byte \a array. -*/ -QMemoryVideoBuffer::QMemoryVideoBuffer(const QByteArray &array, int bytesPerLine) - : QAbstractVideoBuffer(*new QMemoryVideoBufferPrivate, NoHandle) -{ - Q_D(QMemoryVideoBuffer); - - d->data = array; - d->bytesPerLine = bytesPerLine; -} - -/*! - Destroys a system memory allocated video buffer. -*/ -QMemoryVideoBuffer::~QMemoryVideoBuffer() -{ -} - -/*! - \reimp - \since 1.1 -*/ -QAbstractVideoBuffer::MapMode QMemoryVideoBuffer::mapMode() const -{ - return d_func()->mapMode; -} - -/*! - \reimp - \since 1.1 -*/ -uchar *QMemoryVideoBuffer::map(MapMode mode, int *numBytes, int *bytesPerLine) -{ - Q_D(QMemoryVideoBuffer); - - if (d->mapMode == NotMapped && d->data.data() && mode != NotMapped) { - d->mapMode = mode; - - if (numBytes) - *numBytes = d->data.size(); - - if (bytesPerLine) - *bytesPerLine = d->bytesPerLine; - - return reinterpret_cast(d->data.data()); - } else { - return 0; - } -} - -/*! - \reimp - \since 1.1 -*/ -void QMemoryVideoBuffer::unmap() -{ - d_func()->mapMode = NotMapped; -} - -QT_END_NAMESPACE diff --git a/src/multimediakit/video/qmemoryvideobuffer_p.h b/src/multimediakit/video/qmemoryvideobuffer_p.h deleted file mode 100644 index d5bc4e3c8..000000000 --- a/src/multimediakit/video/qmemoryvideobuffer_p.h +++ /dev/null @@ -1,89 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QMEMORYVIDEOBUFFER_P_H -#define QMEMORYVIDEOBUFFER_P_H - -#include - -// -// 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. -// - -QT_BEGIN_HEADER - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -QT_MODULE(Multimedia) - - -class QMemoryVideoBufferPrivate; - -class Q_MULTIMEDIA_EXPORT QMemoryVideoBuffer : public QAbstractVideoBuffer -{ - Q_DECLARE_PRIVATE(QMemoryVideoBuffer) -public: - QMemoryVideoBuffer(const QByteArray &data, int bytesPerLine); - ~QMemoryVideoBuffer(); - - MapMode mapMode() const; - - uchar *map(MapMode mode, int *numBytes, int *bytesPerLine); - void unmap(); -}; - -QT_END_NAMESPACE - -QT_END_HEADER - - -QT_END_HEADER - -#endif diff --git a/src/multimediakit/video/qvideoframe.cpp b/src/multimediakit/video/qvideoframe.cpp deleted file mode 100644 index 7c6bbdb11..000000000 --- a/src/multimediakit/video/qvideoframe.cpp +++ /dev/null @@ -1,776 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qvideoframe.h" - -#include "qimagevideobuffer_p.h" -#include "qmemoryvideobuffer_p.h" - -#include -#include -#include -#include -#include - -QT_BEGIN_NAMESPACE - -namespace -{ -class QVideoFramePrivateRegisterMetaTypes -{ -public: - QVideoFramePrivateRegisterMetaTypes() - { - qRegisterMetaType("QVideoFrame::PixelFormat"); - } -} _registerMetaTypes; -} - - -class QVideoFramePrivate : public QSharedData -{ -public: - QVideoFramePrivate() - : startTime(-1) - , endTime(-1) - , data(0) - , mappedBytes(0) - , bytesPerLine(0) - , pixelFormat(QVideoFrame::Format_Invalid) - , fieldType(QVideoFrame::ProgressiveFrame) - , buffer(0) - { - } - - QVideoFramePrivate(const QSize &size, QVideoFrame::PixelFormat format) - : size(size) - , startTime(-1) - , endTime(-1) - , data(0) - , mappedBytes(0) - , bytesPerLine(0) - , pixelFormat(format) - , fieldType(QVideoFrame::ProgressiveFrame) - , buffer(0) - { - } - - ~QVideoFramePrivate() - { - delete buffer; - } - - QSize size; - qint64 startTime; - qint64 endTime; - uchar *data; - int mappedBytes; - int bytesPerLine; - QVideoFrame::PixelFormat pixelFormat; - QVideoFrame::FieldType fieldType; - QAbstractVideoBuffer *buffer; - -private: - Q_DISABLE_COPY(QVideoFramePrivate) -}; - -/*! - \class QVideoFrame - \brief The QVideoFrame class provides a representation of a frame of video data. - \since 1.0 - \inmodule QtMultimediaKit - - A QVideoFrame encapsulates the data of a video frame, and information about the frame. - - The contents of a video frame can be mapped to memory using the map() function. While - mapped, the video data can accessed using the bits() function, which returns a pointer to a - buffer. The total size of this buffer is given by the mappedBytes() function, and the size of each line is given - by bytesPerLine(). The return value of the handle() function may be used to access frame data - using the internal buffer's native APIs. - - The video data in a QVideoFrame is encapsulated in a QAbstractVideoBuffer. A QVideoFrame - may be constructed from any buffer type by subclassing the QAbstractVideoBuffer class. - - \note QVideoFrame is explicitly shared, any change made to video frame will also apply to any - copies. -*/ - -/*! - \enum QVideoFrame::PixelFormat - - Enumerates video data types. - - \value Format_Invalid - The frame is invalid. - - \value Format_ARGB32 - The frame is stored using a 32-bit ARGB format (0xAARRGGBB). This is equivalent to - QImage::Format_ARGB32. - - \value Format_ARGB32_Premultiplied - The frame stored using a premultiplied 32-bit ARGB format (0xAARRGGBB). This is equivalent - to QImage::Format_ARGB32_Premultiplied. - - \value Format_RGB32 - The frame stored using a 32-bit RGB format (0xffRRGGBB). This is equivalent to - QImage::Format_RGB32 - - \value Format_RGB24 - The frame is stored using a 24-bit RGB format (8-8-8). This is equivalent to - QImage::Format_RGB888 - - \value Format_RGB565 - The frame is stored using a 16-bit RGB format (5-6-5). This is equivalent to - QImage::Format_RGB16. - - \value Format_RGB555 - The frame is stored using a 16-bit RGB format (5-5-5). This is equivalent to - QImage::Format_RGB555. - - \value Format_ARGB8565_Premultiplied - The frame is stored using a 24-bit premultiplied ARGB format (8-6-6-5). - - \value Format_BGRA32 - The frame is stored using a 32-bit ARGB format (0xBBGGRRAA). - - \value Format_BGRA32_Premultiplied - The frame is stored using a premultiplied 32bit BGRA format. - - \value Format_BGR32 - The frame is stored using a 32-bit BGR format (0xBBGGRRff). - - \value Format_BGR24 - The frame is stored using a 24-bit BGR format (0xBBGGRR). - - \value Format_BGR565 - The frame is stored using a 16-bit BGR format (5-6-5). - - \value Format_BGR555 - The frame is stored using a 16-bit BGR format (5-5-5). - - \value Format_BGRA5658_Premultiplied - The frame is stored using a 24-bit premultiplied BGRA format (5-6-5-8). - - \value Format_AYUV444 - The frame is stored using a packed 32-bit AYUV format (0xAAYYUUVV). - - \value Format_AYUV444_Premultiplied - The frame is stored using a packed premultiplied 32-bit AYUV format (0xAAYYUUVV). - - \value Format_YUV444 - The frame is stored using a 24-bit packed YUV format (8-8-8). - - \value Format_YUV420P - The frame is stored using an 8-bit per component planar YUV format with the U and V planes - horizontally and vertically sub-sampled, i.e. the height and width of the U and V planes are - half that of the Y plane. - - \value Format_YV12 - The frame is stored using an 8-bit per component planar YVU format with the V and U planes - horizontally and vertically sub-sampled, i.e. the height and width of the V and U planes are - half that of the Y plane. - - \value Format_UYVY - The frame is stored using an 8-bit per component packed YUV format with the U and V planes - horizontally sub-sampled (U-Y-V-Y), i.e. two horizontally adjacent pixels are stored as a 32-bit - macropixel which has a Y value for each pixel and common U and V values. - - \value Format_YUYV - The frame is stored using an 8-bit per component packed YUV format with the U and V planes - horizontally sub-sampled (Y-U-Y-V), i.e. two horizontally adjacent pixels are stored as a 32-bit - macropixel which has a Y value for each pixel and common U and V values. - - \value Format_NV12 - The frame is stored using an 8-bit per component semi-planar YUV format with a Y plane (Y) - followed by a horizontally and vertically sub-sampled, packed UV plane (U-V). - - \value Format_NV21 - The frame is stored using an 8-bit per component semi-planar YUV format with a Y plane (Y) - followed by a horizontally and vertically sub-sampled, packed VU plane (V-U). - - \value Format_IMC1 - The frame is stored using an 8-bit per component planar YUV format with the U and V planes - horizontally and vertically sub-sampled. This is similar to the Format_YUV420P type, except - that the bytes per line of the U and V planes are padded out to the same stride as the Y plane. - - \value Format_IMC2 - The frame is stored using an 8-bit per component planar YUV format with the U and V planes - horizontally and vertically sub-sampled. This is similar to the Format_YUV420P type, except - that the lines of the U and V planes are interleaved, i.e. each line of U data is followed by a - line of V data creating a single line of the same stride as the Y data. - - \value Format_IMC3 - The frame is stored using an 8-bit per component planar YVU format with the V and U planes - horizontally and vertically sub-sampled. This is similar to the Format_YV12 type, except that - the bytes per line of the V and U planes are padded out to the same stride as the Y plane. - - \value Format_IMC4 - The frame is stored using an 8-bit per component planar YVU format with the V and U planes - horizontally and vertically sub-sampled. This is similar to the Format_YV12 type, except that - the lines of the V and U planes are interleaved, i.e. each line of V data is followed by a line - of U data creating a single line of the same stride as the Y data. - - \value Format_Y8 - The frame is stored using an 8-bit greyscale format. - - \value Format_Y16 - The frame is stored using a 16-bit linear greyscale format. Little endian. - - \value Format_Jpeg - The frame is stored in compressed Jpeg format. - - \value Format_CameraRaw - The frame is stored using a device specific camera raw format. - - \value Format_AdobeDng - The frame is stored using raw Adobe Digital Negative (DNG) format. - - \value Format_User - Start value for user defined pixel formats. -*/ - -/*! - \enum QVideoFrame::FieldType - - Specifies the field an interlaced video frame belongs to. - - \value ProgressiveFrame The frame is not interlaced. - \value TopField The frame contains a top field. - \value BottomField The frame contains a bottom field. - \value InterlacedFrame The frame contains a merged top and bottom field. -*/ - -/*! - Constructs a null video frame. -*/ -QVideoFrame::QVideoFrame() - : d(new QVideoFramePrivate) -{ -} - -/*! - Constructs a video frame from a \a buffer with the given pixel \a format and \a size in pixels. - - \note This doesn't increment the reference count of the video buffer. - \since 1.0 -*/ -QVideoFrame::QVideoFrame( - QAbstractVideoBuffer *buffer, const QSize &size, PixelFormat format) - : d(new QVideoFramePrivate(size, format)) -{ - d->buffer = buffer; -} - -/*! - Constructs a video frame of the given pixel \a format and \a size in pixels. - - The \a bytesPerLine (stride) is the length of each scan line in bytes, and \a bytes is the total - number of bytes that must be allocated for the frame. - \since 1.0 -*/ -QVideoFrame::QVideoFrame(int bytes, const QSize &size, int bytesPerLine, PixelFormat format) - : d(new QVideoFramePrivate(size, format)) -{ - if (bytes > 0) { - QByteArray data; - data.resize(bytes); - - // Check the memory was successfully allocated. - if (!data.isEmpty()) - d->buffer = new QMemoryVideoBuffer(data, bytesPerLine); - } -} - -/*! - Constructs a video frame from an \a image. - - \note This will construct an invalid video frame if there is no frame type equivalent to the - image format. - - \since 1.0 - \sa pixelFormatFromImageFormat() -*/ -QVideoFrame::QVideoFrame(const QImage &image) - : d(new QVideoFramePrivate( - image.size(), pixelFormatFromImageFormat(image.format()))) -{ - if (d->pixelFormat != Format_Invalid) - d->buffer = new QImageVideoBuffer(image); -} - -/*! - Constructs a copy of \a other. - - \since 1.0 -*/ -QVideoFrame::QVideoFrame(const QVideoFrame &other) - : d(other.d) -{ -} - -/*! - Assigns the contents of \a other to a video frame. - \since 1.0 -*/ -QVideoFrame &QVideoFrame::operator =(const QVideoFrame &other) -{ - d = other.d; - - return *this; -} - -/*! - Destroys a video frame. -*/ -QVideoFrame::~QVideoFrame() -{ -} - -/*! - Identifies whether a video frame is valid. - - An invalid frame has no video buffer associated with it. - - Returns true if the frame is valid, and false if it is not. - \since 1.0 -*/ -bool QVideoFrame::isValid() const -{ - return d->buffer != 0; -} - -/*! - Returns the color format of a video frame. - \since 1.0 -*/ -QVideoFrame::PixelFormat QVideoFrame::pixelFormat() const -{ - return d->pixelFormat; -} - -/*! - Returns the type of a video frame's handle. - - \since 1.0 -*/ -QAbstractVideoBuffer::HandleType QVideoFrame::handleType() const -{ - return d->buffer ? d->buffer->handleType() : QAbstractVideoBuffer::NoHandle; -} - -/*! - Returns the dimensions of a video frame. - \since 1.0 -*/ -QSize QVideoFrame::size() const -{ - return d->size; -} - -/*! - Returns the width of a video frame. - \since 1.0 -*/ -int QVideoFrame::width() const -{ - return d->size.width(); -} - -/*! - Returns the height of a video frame. - \since 1.0 -*/ -int QVideoFrame::height() const -{ - return d->size.height(); -} - -/*! - Returns the field an interlaced video frame belongs to. - - If the video is not interlaced this will return WholeFrame. - \since 1.0 -*/ -QVideoFrame::FieldType QVideoFrame::fieldType() const -{ - return d->fieldType; -} - -/*! - Sets the \a field an interlaced video frame belongs to. - \since 1.0 -*/ -void QVideoFrame::setFieldType(QVideoFrame::FieldType field) -{ - d->fieldType = field; -} - -/*! - Identifies if a video frame's contents are currently mapped to system memory. - - This is a convenience function which checks that the \l {QAbstractVideoBuffer::MapMode}{MapMode} - of the frame is not equal to QAbstractVideoBuffer::NotMapped. - - Returns true if the contents of the video frame are mapped to system memory, and false - otherwise. - - \since 1.0 - \sa mapMode(), QAbstractVideoBuffer::MapMode -*/ - -bool QVideoFrame::isMapped() const -{ - return d->buffer != 0 && d->buffer->mapMode() != QAbstractVideoBuffer::NotMapped; -} - -/*! - Identifies if the mapped contents of a video frame will be persisted when the frame is unmapped. - - This is a convenience function which checks if the \l {QAbstractVideoBuffer::MapMode}{MapMode} - contains the QAbstractVideoBuffer::WriteOnly flag. - - Returns true if the video frame will be updated when unmapped, and false otherwise. - - \note The result of altering the data of a frame that is mapped in read-only mode is undefined. - Depending on the buffer implementation the changes may be persisted, or worse alter a shared - buffer. - - \since 1.0 - \sa mapMode(), QAbstractVideoBuffer::MapMode -*/ -bool QVideoFrame::isWritable() const -{ - return d->buffer != 0 && (d->buffer->mapMode() & QAbstractVideoBuffer::WriteOnly); -} - -/*! - Identifies if the mapped contents of a video frame were read from the frame when it was mapped. - - This is a convenience function which checks if the \l {QAbstractVideoBuffer::MapMode}{MapMode} - contains the QAbstractVideoBuffer::WriteOnly flag. - - Returns true if the contents of the mapped memory were read from the video frame, and false - otherwise. - - \since 1.0 - \sa mapMode(), QAbstractVideoBuffer::MapMode -*/ -bool QVideoFrame::isReadable() const -{ - return d->buffer != 0 && (d->buffer->mapMode() & QAbstractVideoBuffer::ReadOnly); -} - -/*! - Returns the mode a video frame was mapped to system memory in. - - \since 1.0 - \sa map(), QAbstractVideoBuffer::MapMode -*/ -QAbstractVideoBuffer::MapMode QVideoFrame::mapMode() const -{ - return d->buffer != 0 ? d->buffer->mapMode() : QAbstractVideoBuffer::NotMapped; -} - -/*! - Maps the contents of a video frame to memory. - - The map \a mode indicates whether the contents of the mapped memory should be read from and/or - written to the frame. If the map mode includes the QAbstractVideoBuffer::ReadOnly flag the - mapped memory will be populated with the content of the video frame when mapped. If the map - mode inclues the QAbstractVideoBuffer::WriteOnly flag the content of the mapped memory will be - persisted in the frame when unmapped. - - While mapped the contents of a video frame can be accessed directly through the pointer returned - by the bits() function. - - When access to the data is no longer needed be sure to call the unmap() function to release the - mapped memory and possibly update the video frame contents. - - Returns true if the buffer was mapped to memory in the given \a mode and false otherwise. - - \since 1.0 - \sa unmap(), mapMode(), bits() -*/ -bool QVideoFrame::map(QAbstractVideoBuffer::MapMode mode) -{ - if (d->buffer != 0 && d->data == 0) { - Q_ASSERT(d->bytesPerLine == 0); - Q_ASSERT(d->mappedBytes == 0); - - d->data = d->buffer->map(mode, &d->mappedBytes, &d->bytesPerLine); - - return d->data != 0; - } - - return false; -} - -/*! - Releases the memory mapped by the map() function. - - If the \l {QAbstractVideoBuffer::MapMode}{MapMode} included the QAbstractVideoBuffer::WriteOnly - flag this will persist the current content of the mapped memory to the video frame. - - \since 1.0 - \sa map() -*/ -void QVideoFrame::unmap() -{ - if (d->data != 0) { - d->mappedBytes = 0; - d->bytesPerLine = 0; - d->data = 0; - - d->buffer->unmap(); - } -} - -/*! - Returns the number of bytes in a scan line. - - \note This is the bytes per line of the first plane only. The bytes per line of subsequent - planes should be calculated as per the frame type. - - This value is only valid while the frame data is \l {map()}{mapped}. - - \since 1.0 - \sa bits(), map(), mappedBytes() -*/ -int QVideoFrame::bytesPerLine() const -{ - return d->bytesPerLine; -} - -/*! - Returns a pointer to the start of the frame data buffer. - - This value is only valid while the frame data is \l {map()}{mapped}. - - Changes made to data accessed via this pointer (when mapped with write access) - are only guaranteed to have been persisted when unmap() is called. - - \since 1.0 - \sa map(), mappedBytes(), bytesPerLine() -*/ -uchar *QVideoFrame::bits() -{ - return d->data; -} - -/*! - Returns a pointer to the start of the frame data buffer. - - This value is only valid while the frame data is \l {map()}{mapped}. - - If the buffer was not mapped with read access, the contents of this - buffer will initially be uninitialized. - - \since 1.0 - \sa map(), mappedBytes(), bytesPerLine() -*/ -const uchar *QVideoFrame::bits() const -{ - return d->data; -} - -/*! - Returns the number of bytes occupied by the mapped frame data. - - This value is only valid while the frame data is \l {map()}{mapped}. - - \since 1.0 - \sa map() -*/ -int QVideoFrame::mappedBytes() const -{ - return d->mappedBytes; -} - -/*! - Returns a type specific handle to a video frame's buffer. - - For an OpenGL texture this would be the texture ID. - - \since 1.0 - \sa QAbstractVideoBuffer::handle() -*/ -QVariant QVideoFrame::handle() const -{ - return d->buffer != 0 ? d->buffer->handle() : QVariant(); -} - -/*! - Returns the presentation time when the frame should be displayed. - \since 1.0 -*/ -qint64 QVideoFrame::startTime() const -{ - return d->startTime; -} - -/*! - Sets the presentation \a time when the frame should be displayed. - \since 1.0 -*/ -void QVideoFrame::setStartTime(qint64 time) -{ - d->startTime = time; -} - -/*! - Returns the presentation time when a frame should stop being displayed. - - \since 1.0 -*/ -qint64 QVideoFrame::endTime() const -{ - return d->endTime; -} - -/*! - Sets the presentation \a time when a frame should stop being displayed. - \since 1.0 -*/ -void QVideoFrame::setEndTime(qint64 time) -{ - d->endTime = time; -} - -/*! - Returns a video pixel format equivalent to an image \a format. If there is no equivalent - format QVideoFrame::InvalidType is returned instead. - \since 1.0 -*/ -QVideoFrame::PixelFormat QVideoFrame::pixelFormatFromImageFormat(QImage::Format format) -{ - switch (format) { - case QImage::Format_Invalid: - case QImage::Format_Mono: - case QImage::Format_MonoLSB: - case QImage::Format_Indexed8: - return Format_Invalid; - case QImage::Format_RGB32: - return Format_RGB32; - case QImage::Format_ARGB32: - return Format_ARGB32; - case QImage::Format_ARGB32_Premultiplied: - return Format_ARGB32_Premultiplied; - case QImage::Format_RGB16: - return Format_RGB565; - case QImage::Format_ARGB8565_Premultiplied: - return Format_ARGB8565_Premultiplied; - case QImage::Format_RGB666: - case QImage::Format_ARGB6666_Premultiplied: - return Format_Invalid; - case QImage::Format_RGB555: - return Format_RGB555; - case QImage::Format_ARGB8555_Premultiplied: - return Format_Invalid; - case QImage::Format_RGB888: - return Format_RGB24; - case QImage::Format_RGB444: - case QImage::Format_ARGB4444_Premultiplied: - return Format_Invalid; - case QImage::NImageFormats: - return Format_Invalid; - } - return Format_Invalid; -} - -/*! - Returns an image format equivalent to a video frame pixel \a format. If there is no equivalent - format QImage::Format_Invalid is returned instead. - \since 1.0 -*/ -QImage::Format QVideoFrame::imageFormatFromPixelFormat(PixelFormat format) -{ - switch (format) { - case Format_Invalid: - return QImage::Format_Invalid; - case Format_ARGB32: - return QImage::Format_ARGB32; - case Format_ARGB32_Premultiplied: - return QImage::Format_ARGB32_Premultiplied; - case Format_RGB32: - return QImage::Format_RGB32; - case Format_RGB24: - return QImage::Format_RGB888; - case Format_RGB565: - return QImage::Format_RGB16; - case Format_RGB555: - return QImage::Format_RGB555; - case Format_ARGB8565_Premultiplied: - return QImage::Format_ARGB8565_Premultiplied; - case Format_BGRA32: - case Format_BGRA32_Premultiplied: - case Format_BGR32: - case Format_BGR24: - return QImage::Format_Invalid; - case Format_BGR565: - case Format_BGR555: - case Format_BGRA5658_Premultiplied: - case Format_AYUV444: - case Format_AYUV444_Premultiplied: - case Format_YUV444: - case Format_YUV420P: - case Format_YV12: - case Format_UYVY: - case Format_YUYV: - case Format_NV12: - case Format_NV21: - case Format_IMC1: - case Format_IMC2: - case Format_IMC3: - case Format_IMC4: - case Format_Y8: - case Format_Y16: - case Format_Jpeg: - case Format_CameraRaw: - case Format_AdobeDng: - return QImage::Format_Invalid; - case Format_User: - return QImage::Format_Invalid; - } - return QImage::Format_Invalid; -} - -QT_END_NAMESPACE - diff --git a/src/multimediakit/video/qvideoframe.h b/src/multimediakit/video/qvideoframe.h deleted file mode 100644 index 6dffaf59d..000000000 --- a/src/multimediakit/video/qvideoframe.h +++ /dev/null @@ -1,174 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QVIDEOFRAME_H -#define QVIDEOFRAME_H - -#include -#include -#include -#include - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -QT_MODULE(Multimedia) - -class QSize; -class QVariant; - -class QVideoFramePrivate; - -class Q_MULTIMEDIA_EXPORT QVideoFrame -{ -public: - enum FieldType - { - ProgressiveFrame, - TopField, - BottomField, - InterlacedFrame - }; - - enum PixelFormat - { - Format_Invalid, - Format_ARGB32, - Format_ARGB32_Premultiplied, - Format_RGB32, - Format_RGB24, - Format_RGB565, - Format_RGB555, - Format_ARGB8565_Premultiplied, - Format_BGRA32, - Format_BGRA32_Premultiplied, - Format_BGR32, - Format_BGR24, - Format_BGR565, - Format_BGR555, - Format_BGRA5658_Premultiplied, - - Format_AYUV444, - Format_AYUV444_Premultiplied, - Format_YUV444, - Format_YUV420P, - Format_YV12, - Format_UYVY, - Format_YUYV, - Format_NV12, - Format_NV21, - Format_IMC1, - Format_IMC2, - Format_IMC3, - Format_IMC4, - Format_Y8, - Format_Y16, - - Format_Jpeg, - - Format_CameraRaw, - Format_AdobeDng, - - Format_User = 1000 - }; - - QVideoFrame(); - QVideoFrame(QAbstractVideoBuffer *buffer, const QSize &size, PixelFormat format); - QVideoFrame(int bytes, const QSize &size, int bytesPerLine, PixelFormat format); - QVideoFrame(const QImage &image); - QVideoFrame(const QVideoFrame &other); - ~QVideoFrame(); - - QVideoFrame &operator =(const QVideoFrame &other); - - bool isValid() const; - - PixelFormat pixelFormat() const; - - QAbstractVideoBuffer::HandleType handleType() const; - - QSize size() const; - int width() const; - int height() const; - - FieldType fieldType() const; - void setFieldType(FieldType); - - bool isMapped() const; - bool isReadable() const; - bool isWritable() const; - - QAbstractVideoBuffer::MapMode mapMode() const; - - bool map(QAbstractVideoBuffer::MapMode mode); - void unmap(); - - int bytesPerLine() const; - - uchar *bits(); - const uchar *bits() const; - int mappedBytes() const; - - QVariant handle() const; - - qint64 startTime() const; - void setStartTime(qint64 time); - - qint64 endTime() const; - void setEndTime(qint64 time); - - static PixelFormat pixelFormatFromImageFormat(QImage::Format format); - static QImage::Format imageFormatFromPixelFormat(PixelFormat format); - -private: - QExplicitlySharedDataPointer d; -}; - -QT_END_NAMESPACE - -Q_DECLARE_METATYPE(QVideoFrame::FieldType) -Q_DECLARE_METATYPE(QVideoFrame::PixelFormat) - -QT_END_HEADER - -#endif - diff --git a/src/multimediakit/video/qvideosurfaceformat.cpp b/src/multimediakit/video/qvideosurfaceformat.cpp deleted file mode 100644 index 4d198e186..000000000 --- a/src/multimediakit/video/qvideosurfaceformat.cpp +++ /dev/null @@ -1,707 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qvideosurfaceformat.h" - -#include -#include -#include -#include -#include - -QT_BEGIN_NAMESPACE - -class QVideoSurfaceFormatPrivate : public QSharedData -{ -public: - QVideoSurfaceFormatPrivate() - : pixelFormat(QVideoFrame::Format_Invalid) - , handleType(QAbstractVideoBuffer::NoHandle) - , scanLineDirection(QVideoSurfaceFormat::TopToBottom) - , pixelAspectRatio(1, 1) - , ycbcrColorSpace(QVideoSurfaceFormat::YCbCr_Undefined) - , frameRate(0.0) - { - } - - QVideoSurfaceFormatPrivate( - const QSize &size, - QVideoFrame::PixelFormat format, - QAbstractVideoBuffer::HandleType type) - : pixelFormat(format) - , handleType(type) - , scanLineDirection(QVideoSurfaceFormat::TopToBottom) - , frameSize(size) - , pixelAspectRatio(1, 1) - , ycbcrColorSpace(QVideoSurfaceFormat::YCbCr_Undefined) - , viewport(QPoint(0, 0), size) - , frameRate(0.0) - { - } - - QVideoSurfaceFormatPrivate(const QVideoSurfaceFormatPrivate &other) - : QSharedData(other) - , pixelFormat(other.pixelFormat) - , handleType(other.handleType) - , scanLineDirection(other.scanLineDirection) - , frameSize(other.frameSize) - , pixelAspectRatio(other.pixelAspectRatio) - , ycbcrColorSpace(other.ycbcrColorSpace) - , viewport(other.viewport) - , frameRate(other.frameRate) - , propertyNames(other.propertyNames) - , propertyValues(other.propertyValues) - { - } - - bool operator ==(const QVideoSurfaceFormatPrivate &other) const - { - if (pixelFormat == other.pixelFormat - && handleType == other.handleType - && scanLineDirection == other.scanLineDirection - && frameSize == other.frameSize - && pixelAspectRatio == other.pixelAspectRatio - && viewport == other.viewport - && frameRatesEqual(frameRate, other.frameRate) - && ycbcrColorSpace == other.ycbcrColorSpace - && propertyNames.count() == other.propertyNames.count()) { - for (int i = 0; i < propertyNames.count(); ++i) { - int j = other.propertyNames.indexOf(propertyNames.at(i)); - - if (j == -1 || propertyValues.at(i) != other.propertyValues.at(j)) - return false; - } - return true; - } else { - return false; - } - } - - inline static bool frameRatesEqual(qreal r1, qreal r2) - { - return qAbs(r1 - r2) <= 0.00001 * qMin(qAbs(r1), qAbs(r2)); - } - - QVideoFrame::PixelFormat pixelFormat; - QAbstractVideoBuffer::HandleType handleType; - QVideoSurfaceFormat::Direction scanLineDirection; - QSize frameSize; - QSize pixelAspectRatio; - QVideoSurfaceFormat::YCbCrColorSpace ycbcrColorSpace; - QRect viewport; - qreal frameRate; - QList propertyNames; - QList propertyValues; -}; - -/*! - \class QVideoSurfaceFormat - \brief The QVideoSurfaceFormat class specifies the stream format of a video presentation - surface. - \since 1.0 - \inmodule QtMultimediaKit - - A video surface presents a stream of video frames. The surface's format describes the type of - the frames and determines how they should be presented. - - The core properties of a video stream required to setup a video surface are the pixel format - given by pixelFormat(), and the frame dimensions given by frameSize(). - - If the surface is to present frames using a frame's handle a surface format will also include - a handle type which is given by the handleType() function. - - The region of a frame that is actually displayed on a video surface is given by the viewport(). - A stream may have a viewport less than the entire region of a frame to allow for videos smaller - than the nearest optimal size of a video frame. For example the width of a frame may be - extended so that the start of each scan line is eight byte aligned. - - Other common properties are the pixelAspectRatio(), scanLineDirection(), and frameRate(). - Additionally a stream may have some additional type specific properties which are listed by the - dynamicPropertyNames() function and can be accessed using the property(), and setProperty() - functions. -*/ - -/*! - \enum QVideoSurfaceFormat::Direction - - Enumerates the layout direction of video scan lines. - - \value TopToBottom Scan lines are arranged from the top of the frame to the bottom. - \value BottomToTop Scan lines are arranged from the bottom of the frame to the top. -*/ - -/*! - \enum QVideoSurfaceFormat::YCbCrColorSpace - - Enumerates the Y'CbCr color space of video frames. - - \value YCbCr_Undefined - No color space is specified. - - \value YCbCr_BT601 - A Y'CbCr color space defined by ITU-R recommendation BT.601 - with Y value range from 16 to 235, and Cb/Cr range from 16 to 240. - Used in standard definition video. - - \value YCbCr_BT709 - A Y'CbCr color space defined by ITU-R BT.709 with the same values range as YCbCr_BT601. Used - for HDTV. - - \value YCbCr_xvYCC601 - The BT.601 color space with the value range extended to 0 to 255. - It is backward compatibile with BT.601 and uses values outside BT.601 range to represent a - wider range of colors. - - \value YCbCr_xvYCC709 - The BT.709 color space with the value range extended to 0 to 255. - - \value YCbCr_JPEG - The full range Y'CbCr color space used in JPEG files. -*/ - -/*! - Constructs a null video stream format. -*/ -QVideoSurfaceFormat::QVideoSurfaceFormat() - : d(new QVideoSurfaceFormatPrivate) -{ -} - -/*! - Contructs a description of stream which receives stream of \a type buffers with given frame - \a size and pixel \a format. - \since 1.0 -*/ -QVideoSurfaceFormat::QVideoSurfaceFormat( - const QSize& size, QVideoFrame::PixelFormat format, QAbstractVideoBuffer::HandleType type) - : d(new QVideoSurfaceFormatPrivate(size, format, type)) -{ -} - -/*! - Constructs a copy of \a other. - \since 1.0 -*/ -QVideoSurfaceFormat::QVideoSurfaceFormat(const QVideoSurfaceFormat &other) - : d(other.d) -{ -} - -/*! - Assigns the values of \a other to this object. - \since 1.0 -*/ -QVideoSurfaceFormat &QVideoSurfaceFormat::operator =(const QVideoSurfaceFormat &other) -{ - d = other.d; - - return *this; -} - -/*! - Destroys a video stream description. -*/ -QVideoSurfaceFormat::~QVideoSurfaceFormat() -{ -} - -/*! - Identifies if a video surface format has a valid pixel format and frame size. - - Returns true if the format is valid, and false otherwise. - \since 1.0 -*/ -bool QVideoSurfaceFormat::isValid() const -{ - return d->pixelFormat != QVideoFrame::Format_Invalid && d->frameSize.isValid(); -} - -/*! - Returns true if \a other is the same as this video format, and false if they are different. - \since 1.0 -*/ -bool QVideoSurfaceFormat::operator ==(const QVideoSurfaceFormat &other) const -{ - return d == other.d || *d == *other.d; -} - -/*! - Returns true if \a other is different to a video format, and false if they are the same. - \since 1.0 -*/ -bool QVideoSurfaceFormat::operator !=(const QVideoSurfaceFormat &other) const -{ - return d != other.d && !(*d == *other.d); -} - -/*! - Returns the pixel format of frames in a video stream. - \since 1.0 -*/ -QVideoFrame::PixelFormat QVideoSurfaceFormat::pixelFormat() const -{ - return d->pixelFormat; -} - -/*! - Returns the type of handle the surface uses to present the frame data. - - If the handle type is QAbstractVideoBuffer::NoHandle buffers with any handle type are valid - provided they can be \l {QAbstractVideoBuffer::map()}{mapped} with the - QAbstractVideoBuffer::ReadOnly flag. If the handleType() is not QAbstractVideoBuffer::NoHandle - then the handle type of the buffer must be the same as that of the surface format. - \since 1.0 -*/ -QAbstractVideoBuffer::HandleType QVideoSurfaceFormat::handleType() const -{ - return d->handleType; -} - -/*! - Returns the dimensions of frames in a video stream. - - \sa frameWidth(), frameHeight() - \since 1.0 -*/ -QSize QVideoSurfaceFormat::frameSize() const -{ - return d->frameSize; -} - -/*! - Returns the width of frames in a video stream. - - \sa frameSize(), frameHeight() - \since 1.0 -*/ -int QVideoSurfaceFormat::frameWidth() const -{ - return d->frameSize.width(); -} - -/*! - Returns the height of frame in a video stream. - \since 1.0 -*/ -int QVideoSurfaceFormat::frameHeight() const -{ - return d->frameSize.height(); -} - -/*! - Sets the size of frames in a video stream to \a size. - - This will reset the viewport() to fill the entire frame. - \since 1.0 -*/ -void QVideoSurfaceFormat::setFrameSize(const QSize &size) -{ - d->frameSize = size; - d->viewport = QRect(QPoint(0, 0), size); -} - -/*! - \overload - - Sets the \a width and \a height of frames in a video stream. - - This will reset the viewport() to fill the entire frame. - \since 1.0 -*/ -void QVideoSurfaceFormat::setFrameSize(int width, int height) -{ - d->frameSize = QSize(width, height); - d->viewport = QRect(0, 0, width, height); -} - -/*! - Returns the viewport of a video stream. - - The viewport is the region of a video frame that is actually displayed. - - By default the viewport covers an entire frame. - \since 1.0 -*/ -QRect QVideoSurfaceFormat::viewport() const -{ - return d->viewport; -} - -/*! - Sets the viewport of a video stream to \a viewport. - \since 1.0 -*/ -void QVideoSurfaceFormat::setViewport(const QRect &viewport) -{ - d->viewport = viewport; -} - -/*! - Returns the direction of scan lines. - \since 1.0 -*/ -QVideoSurfaceFormat::Direction QVideoSurfaceFormat::scanLineDirection() const -{ - return d->scanLineDirection; -} - -/*! - Sets the \a direction of scan lines. - \since 1.0 -*/ -void QVideoSurfaceFormat::setScanLineDirection(Direction direction) -{ - d->scanLineDirection = direction; -} - -/*! - Returns the frame rate of a video stream in frames per second. - \since 1.0 -*/ -qreal QVideoSurfaceFormat::frameRate() const -{ - return d->frameRate; -} - -/*! - Sets the frame \a rate of a video stream in frames per second. - \since 1.0 -*/ -void QVideoSurfaceFormat::setFrameRate(qreal rate) -{ - d->frameRate = rate; -} - -/*! - Returns a video stream's pixel aspect ratio. - \since 1.0 -*/ -QSize QVideoSurfaceFormat::pixelAspectRatio() const -{ - return d->pixelAspectRatio; -} - -/*! - Sets a video stream's pixel aspect \a ratio. - \since 1.0 -*/ -void QVideoSurfaceFormat::setPixelAspectRatio(const QSize &ratio) -{ - d->pixelAspectRatio = ratio; -} - -/*! - \overload - - Sets the \a horizontal and \a vertical elements of a video stream's pixel aspect ratio. - \since 1.0 -*/ -void QVideoSurfaceFormat::setPixelAspectRatio(int horizontal, int vertical) -{ - d->pixelAspectRatio = QSize(horizontal, vertical); -} - -/*! - Returns the Y'CbCr color space of a video stream. - \since 1.0 -*/ -QVideoSurfaceFormat::YCbCrColorSpace QVideoSurfaceFormat::yCbCrColorSpace() const -{ - return d->ycbcrColorSpace; -} - -/*! - Sets the Y'CbCr color \a space of a video stream. - It is only used with raw YUV frame types. - \since 1.0 -*/ -void QVideoSurfaceFormat::setYCbCrColorSpace(QVideoSurfaceFormat::YCbCrColorSpace space) -{ - d->ycbcrColorSpace = space; -} - -/*! - Returns a suggested size in pixels for the video stream. - - This is the size of the viewport scaled according to the pixel aspect ratio. - \since 1.0 -*/ -QSize QVideoSurfaceFormat::sizeHint() const -{ - QSize size = d->viewport.size(); - - if (d->pixelAspectRatio.height() != 0) - size.setWidth(size.width() * d->pixelAspectRatio.width() / d->pixelAspectRatio.height()); - - return size; -} - -/*! - Returns a list of video format dynamic property names. - \since 1.0 -*/ -QList QVideoSurfaceFormat::propertyNames() const -{ - return (QList() - << "handleType" - << "pixelFormat" - << "frameSize" - << "frameWidth" - << "viewport" - << "scanLineDirection" - << "frameRate" - << "pixelAspectRatio" - << "sizeHint" - << "yCbCrColorSpace") - + d->propertyNames; -} - -/*! - Returns the value of the video format's \a name property. - \since 1.0 -*/ -QVariant QVideoSurfaceFormat::property(const char *name) const -{ - if (qstrcmp(name, "handleType") == 0) { - return qVariantFromValue(d->handleType); - } else if (qstrcmp(name, "pixelFormat") == 0) { - return qVariantFromValue(d->pixelFormat); - } else if (qstrcmp(name, "handleType") == 0) { - return qVariantFromValue(d->handleType); - } else if (qstrcmp(name, "frameSize") == 0) { - return d->frameSize; - } else if (qstrcmp(name, "frameWidth") == 0) { - return d->frameSize.width(); - } else if (qstrcmp(name, "frameHeight") == 0) { - return d->frameSize.height(); - } else if (qstrcmp(name, "viewport") == 0) { - return d->viewport; - } else if (qstrcmp(name, "scanLineDirection") == 0) { - return qVariantFromValue(d->scanLineDirection); - } else if (qstrcmp(name, "frameRate") == 0) { - return qVariantFromValue(d->frameRate); - } else if (qstrcmp(name, "pixelAspectRatio") == 0) { - return qVariantFromValue(d->pixelAspectRatio); - } else if (qstrcmp(name, "sizeHint") == 0) { - return sizeHint(); - } else if (qstrcmp(name, "yCbCrColorSpace") == 0) { - return qVariantFromValue(d->ycbcrColorSpace); - } else { - int id = 0; - for (; id < d->propertyNames.count() && d->propertyNames.at(id) != name; ++id) {} - - return id < d->propertyValues.count() - ? d->propertyValues.at(id) - : QVariant(); - } -} - -/*! - Sets the video format's \a name property to \a value. - - Trying to set a read only property will be ignored. - - \since 1.0 -*/ -void QVideoSurfaceFormat::setProperty(const char *name, const QVariant &value) -{ - if (qstrcmp(name, "handleType") == 0) { - // read only. - } else if (qstrcmp(name, "pixelFormat") == 0) { - // read only. - } else if (qstrcmp(name, "frameSize") == 0) { - if (qVariantCanConvert(value)) { - d->frameSize = qvariant_cast(value); - d->viewport = QRect(QPoint(0, 0), d->frameSize); - } - } else if (qstrcmp(name, "frameWidth") == 0) { - // read only. - } else if (qstrcmp(name, "frameHeight") == 0) { - // read only. - } else if (qstrcmp(name, "viewport") == 0) { - if (qVariantCanConvert(value)) - d->viewport = qvariant_cast(value); - } else if (qstrcmp(name, "scanLineDirection") == 0) { - if (qVariantCanConvert(value)) - d->scanLineDirection = qvariant_cast(value); - } else if (qstrcmp(name, "frameRate") == 0) { - if (qVariantCanConvert(value)) - d->frameRate = qvariant_cast(value); - } else if (qstrcmp(name, "pixelAspectRatio") == 0) { - if (qVariantCanConvert(value)) - d->pixelAspectRatio = qvariant_cast(value); - } else if (qstrcmp(name, "sizeHint") == 0) { - // read only. - } else if (qstrcmp(name, "yCbCrColorSpace") == 0) { - if (qVariantCanConvert(value)) - d->ycbcrColorSpace = qvariant_cast(value); - } else { - int id = 0; - for (; id < d->propertyNames.count() && d->propertyNames.at(id) != name; ++id) {} - - if (id < d->propertyValues.count()) { - if (value.isNull()) { - d->propertyNames.removeAt(id); - d->propertyValues.removeAt(id); - } else { - d->propertyValues[id] = value; - } - } else if (!value.isNull()) { - d->propertyNames.append(QByteArray(name)); - d->propertyValues.append(value); - } - } -} - - -#ifndef QT_NO_DEBUG_STREAM -QDebug operator<<(QDebug dbg, const QVideoSurfaceFormat &f) -{ - QString typeName; - switch (f.pixelFormat()) { - case QVideoFrame::Format_Invalid: - typeName = QLatin1String("Format_Invalid"); - break; - case QVideoFrame::Format_ARGB32: - typeName = QLatin1String("Format_ARGB32"); - break; - case QVideoFrame::Format_ARGB32_Premultiplied: - typeName = QLatin1String("Format_ARGB32_Premultiplied"); - break; - case QVideoFrame::Format_RGB32: - typeName = QLatin1String("Format_RGB32"); - break; - case QVideoFrame::Format_RGB24: - typeName = QLatin1String("Format_RGB24"); - break; - case QVideoFrame::Format_RGB565: - typeName = QLatin1String("Format_RGB565"); - break; - case QVideoFrame::Format_RGB555: - typeName = QLatin1String("Format_RGB555"); - break; - case QVideoFrame::Format_ARGB8565_Premultiplied: - typeName = QLatin1String("Format_ARGB8565_Premultiplied"); - break; - case QVideoFrame::Format_BGRA32: - typeName = QLatin1String("Format_BGRA32"); - break; - case QVideoFrame::Format_BGRA32_Premultiplied: - typeName = QLatin1String("Format_BGRA32_Premultiplied"); - break; - case QVideoFrame::Format_BGR32: - typeName = QLatin1String("Format_BGR32"); - break; - case QVideoFrame::Format_BGR24: - typeName = QLatin1String("Format_BGR24"); - break; - case QVideoFrame::Format_BGR565: - typeName = QLatin1String("Format_BGR565"); - break; - case QVideoFrame::Format_BGR555: - typeName = QLatin1String("Format_BGR555"); - break; - case QVideoFrame::Format_BGRA5658_Premultiplied: - typeName = QLatin1String("Format_BGRA5658_Premultiplied"); - break; - case QVideoFrame::Format_AYUV444: - typeName = QLatin1String("Format_AYUV444"); - break; - case QVideoFrame::Format_AYUV444_Premultiplied: - typeName = QLatin1String("Format_AYUV444_Premultiplied"); - break; - case QVideoFrame::Format_YUV444: - typeName = QLatin1String("Format_YUV444"); - break; - case QVideoFrame::Format_YUV420P: - typeName = QLatin1String("Format_YUV420P"); - break; - case QVideoFrame::Format_YV12: - typeName = QLatin1String("Format_YV12"); - break; - case QVideoFrame::Format_UYVY: - typeName = QLatin1String("Format_UYVY"); - break; - case QVideoFrame::Format_YUYV: - typeName = QLatin1String("Format_YUYV"); - break; - case QVideoFrame::Format_NV12: - typeName = QLatin1String("Format_NV12"); - break; - case QVideoFrame::Format_NV21: - typeName = QLatin1String("Format_NV21"); - break; - case QVideoFrame::Format_IMC1: - typeName = QLatin1String("Format_IMC1"); - break; - case QVideoFrame::Format_IMC2: - typeName = QLatin1String("Format_IMC2"); - break; - case QVideoFrame::Format_IMC3: - typeName = QLatin1String("Format_IMC3"); - break; - case QVideoFrame::Format_IMC4: - typeName = QLatin1String("Format_IMC4"); - break; - case QVideoFrame::Format_Y8: - typeName = QLatin1String("Format_Y8"); - break; - case QVideoFrame::Format_Y16: - typeName = QLatin1String("Format_Y16"); - break; - default: - typeName = QString(QLatin1String("UserType(%1)" )).arg(int(f.pixelFormat())); - } - - dbg.nospace() << "QVideoSurfaceFormat(" << typeName; - dbg.nospace() << ", " << f.frameSize(); - dbg.nospace() << ", viewport=" << f.viewport(); - dbg.nospace() << ", pixelAspectRatio=" << f.pixelAspectRatio(); - dbg.nospace() << ")"; - - foreach(const QByteArray& propertyName, f.propertyNames()) - dbg << "\n " << propertyName.data() << " = " << f.property(propertyName.data()); - - return dbg.space(); -} -#endif - -QT_END_NAMESPACE diff --git a/src/multimediakit/video/qvideosurfaceformat.h b/src/multimediakit/video/qvideosurfaceformat.h deleted file mode 100644 index f830b80a6..000000000 --- a/src/multimediakit/video/qvideosurfaceformat.h +++ /dev/null @@ -1,148 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QVIDEOSURFACEFORMAT_H -#define QVIDEOSURFACEFORMAT_H - -#include -#include -#include -#include -#include -#include - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -QT_MODULE(Multimedia) - - -class QDebug; - -class QVideoSurfaceFormatPrivate; - -class Q_MULTIMEDIA_EXPORT QVideoSurfaceFormat -{ -public: - enum Direction - { - TopToBottom, - BottomToTop - }; - - enum YCbCrColorSpace - { - YCbCr_Undefined, - YCbCr_BT601, - YCbCr_BT709, - YCbCr_xvYCC601, - YCbCr_xvYCC709, - YCbCr_JPEG, -#ifndef qdoc - YCbCr_CustomMatrix -#endif - }; - - QVideoSurfaceFormat(); - QVideoSurfaceFormat( - const QSize &size, - QVideoFrame::PixelFormat pixelFormat, - QAbstractVideoBuffer::HandleType handleType = QAbstractVideoBuffer::NoHandle); - QVideoSurfaceFormat(const QVideoSurfaceFormat &format); - ~QVideoSurfaceFormat(); - - QVideoSurfaceFormat &operator =(const QVideoSurfaceFormat &format); - - bool operator ==(const QVideoSurfaceFormat &format) const; - bool operator !=(const QVideoSurfaceFormat &format) const; - - bool isValid() const; - - QVideoFrame::PixelFormat pixelFormat() const; - QAbstractVideoBuffer::HandleType handleType() const; - - QSize frameSize() const; - void setFrameSize(const QSize &size); - void setFrameSize(int width, int height); - - int frameWidth() const; - int frameHeight() const; - - QRect viewport() const; - void setViewport(const QRect &viewport); - - Direction scanLineDirection() const; - void setScanLineDirection(Direction direction); - - qreal frameRate() const; - void setFrameRate(qreal rate); - - QSize pixelAspectRatio() const; - void setPixelAspectRatio(const QSize &ratio); - void setPixelAspectRatio(int width, int height); - - YCbCrColorSpace yCbCrColorSpace() const; - void setYCbCrColorSpace(YCbCrColorSpace colorSpace); - - QSize sizeHint() const; - - QList propertyNames() const; - QVariant property(const char *name) const; - void setProperty(const char *name, const QVariant &value); - -private: - QSharedDataPointer d; -}; - -#ifndef QT_NO_DEBUG_STREAM -Q_MULTIMEDIA_EXPORT QDebug operator<<(QDebug, const QVideoSurfaceFormat &); -#endif - -QT_END_NAMESPACE - -Q_DECLARE_METATYPE(QVideoSurfaceFormat::Direction) -Q_DECLARE_METATYPE(QVideoSurfaceFormat::YCbCrColorSpace) - -QT_END_HEADER - -#endif - diff --git a/src/multimediakit/video/video.pri b/src/multimediakit/video/video.pri deleted file mode 100644 index accaa3371..000000000 --- a/src/multimediakit/video/video.pri +++ /dev/null @@ -1,22 +0,0 @@ - -INCLUDEPATH += video - -PUBLIC_HEADERS += \ - video/qabstractvideobuffer.h \ - video/qabstractvideosurface.h \ - video/qvideoframe.h \ - video/qvideosurfaceformat.h - -PRIVATE_HEADERS += \ - video/qabstractvideobuffer_p.h \ - video/qimagevideobuffer_p.h \ - video/qmemoryvideobuffer_p.h - -SOURCES += \ - video/qabstractvideobuffer.cpp \ - video/qabstractvideosurface.cpp \ - video/qimagevideobuffer.cpp \ - video/qmemoryvideobuffer.cpp \ - video/qvideoframe.cpp \ - video/qvideosurfaceformat.cpp - diff --git a/src/multimediakitwidgets/multimediakitwidgets.pro b/src/multimediakitwidgets/multimediakitwidgets.pro deleted file mode 100644 index 37ea4d8ba..000000000 --- a/src/multimediakitwidgets/multimediakitwidgets.pro +++ /dev/null @@ -1,68 +0,0 @@ -load(qt_module) - -# distinct from QtMultimediaKit -TARGET = QtMultimediaKitWidgets -QPRO_PWD = $$PWD -QT = core gui multimediakit-private widgets - -CONFIG += module no_private_qt_headers_warning -MODULE_PRI += ../../modules/qt_multimediakitwidgets.pri - -contains(QT_CONFIG, opengl) | contains(QT_CONFIG, opengles2) { - QT += opengl -} else { - DEFINES += QT_NO_OPENGL -} - -!static:DEFINES += QT_MAKEDLL -DEFINES += QT_BUILD_MULTIMEDIAWIDGETS_LIB - -load(qt_module_config) - -PRIVATE_HEADERS += \ - qvideowidget_p.h \ - qpaintervideosurface_p.h \ - -PUBLIC_HEADERS += \ - qtmultimediakitwidgetdefs.h \ - qtmultimediakitwidgetsversion.h \ - qcameraviewfinder.h \ - qgraphicsvideoitem.h \ - qvideowidgetcontrol.h \ - qvideowidget.h \ - qvideowindowcontrol.h - -SOURCES += \ - qcameraviewfinder.cpp \ - qpaintervideosurface.cpp \ - qvideowidgetcontrol.cpp \ - qvideowidget.cpp \ - qvideowindowcontrol.cpp \ - -mac:!qpa { -!simulator { - PRIVATE_HEADERS += qpaintervideosurface_mac_p.h - OBJECTIVE_SOURCES += qpaintervideosurface_mac.mm -} - LIBS += -framework AppKit -framework QuartzCore -framework QTKit -} - -maemo6 { - isEqual(QT_ARCH,armv6) { - PRIVATE_HEADERS += qeglimagetexturesurface_p.h - SOURCES += qeglimagetexturesurface.cpp - - SOURCES += qgraphicsvideoitem_maemo6.cpp - - LIBS += -lX11 - } else { - SOURCES += qgraphicsvideoitem.cpp - } -} - -!maemo* { - SOURCES += qgraphicsvideoitem.cpp -} - -HEADERS += $$PUBLIC_HEADERS $$PRIVATE_HEADERS - diff --git a/src/multimediakitwidgets/qcameraviewfinder.cpp b/src/multimediakitwidgets/qcameraviewfinder.cpp deleted file mode 100644 index 42167ebb4..000000000 --- a/src/multimediakitwidgets/qcameraviewfinder.cpp +++ /dev/null @@ -1,113 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include - -#include - -#include -#include -#include -#include - -QT_USE_NAMESPACE - -/*! - \class QCameraViewfinder - - - \brief The QCameraViewfinder class provides a camera viewfinder widget. - - \inmodule QtMultimediaKit - \ingroup camera - \since 1.1 - - \snippet doc/src/snippets/multimedia-snippets/camera.cpp Camera - -*/ - -class QCameraViewfinderPrivate : public QVideoWidgetPrivate -{ - Q_DECLARE_NON_CONST_PUBLIC(QCameraViewfinder) -public: - QCameraViewfinderPrivate(): - QVideoWidgetPrivate() - { - } -}; - -/*! - Constructs a new camera viewfinder widget. - - The \a parent is passed to QVideoWidget. -*/ - -QCameraViewfinder::QCameraViewfinder(QWidget *parent) - :QVideoWidget(*new QCameraViewfinderPrivate, parent) -{ -} - -/*! - Destroys a camera viewfinder widget. -*/ -QCameraViewfinder::~QCameraViewfinder() -{ -} - -/*! - \reimp - \since 1.1 -*/ -QMediaObject *QCameraViewfinder::mediaObject() const -{ - return QVideoWidget::mediaObject(); -} - -/*! - \reimp - \since 1.1 -*/ -bool QCameraViewfinder::setMediaObject(QMediaObject *object) -{ - return QVideoWidget::setMediaObject(object); -} - -#include "moc_qcameraviewfinder.cpp" diff --git a/src/multimediakitwidgets/qcameraviewfinder.h b/src/multimediakitwidgets/qcameraviewfinder.h deleted file mode 100644 index 4ac39ebb9..000000000 --- a/src/multimediakitwidgets/qcameraviewfinder.h +++ /dev/null @@ -1,90 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QCAMERAVIEWFINDER_H -#define QCAMERAVIEWFINDER_H - -#include -#include -#include -#include -#include - -#include -#include -#include -#include - -#include - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -QT_MODULE(Multimedia) - - -class QCamera; - -class QCameraViewfinderPrivate; -class Q_MULTIMEDIA_EXPORT QCameraViewfinder : public QVideoWidget -{ - Q_OBJECT -public: - QCameraViewfinder(QWidget *parent = 0); - ~QCameraViewfinder(); - - QMediaObject *mediaObject() const; - -protected: - bool setMediaObject(QMediaObject *object); - -private: - Q_DISABLE_COPY(QCameraViewfinder) - Q_DECLARE_PRIVATE(QCameraViewfinder) -}; - -QT_END_NAMESPACE - -QT_END_HEADER - - -#endif // QCAMERA_H diff --git a/src/multimediakitwidgets/qeglimagetexturesurface.cpp b/src/multimediakitwidgets/qeglimagetexturesurface.cpp deleted file mode 100644 index dfab86c90..000000000 --- a/src/multimediakitwidgets/qeglimagetexturesurface.cpp +++ /dev/null @@ -1,554 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include -#include - -#include -#include -#include -#include -#include -#include - - -QT_BEGIN_NAMESPACE - -//#define DEBUG_OMAPFB_SURFACE - -const QAbstractVideoBuffer::HandleType EGLImageTextureHandle = -QAbstractVideoBuffer::HandleType(QAbstractVideoBuffer::UserHandle+3434); - -/*! - \class QOmapFbVideoSurface - \internal - \since 1.2 -*/ - -/*! -*/ -QEglImageTextureSurface::QEglImageTextureSurface(QObject *parent) - : QAbstractVideoSurface(parent) - , m_context(0) - , m_program(0) - , m_pixelFormat(QVideoFrame::Format_Invalid) - , m_ready(false) - , m_colorKey(49,0,49) - , m_fallbackSurface(0) - , m_fallbackSurfaceActive(false) -{ - m_fallbackSurface = new QPainterVideoSurface(this); -} - -/*! -*/ -QEglImageTextureSurface::~QEglImageTextureSurface() -{ - if (isActive()) - stop(); -} - -/*! - \since 1.2 -*/ -QList QEglImageTextureSurface::supportedPixelFormats( - QAbstractVideoBuffer::HandleType handleType) const -{ -#ifdef DEBUG_OMAPFB_SURFACE - qDebug() << Q_FUNC_INFO << handleType; -#endif - - if (handleType == EGLImageTextureHandle) { - return QList() - << QVideoFrame::Format_RGB32 - << QVideoFrame::Format_ARGB32; - } - - return m_fallbackSurface->supportedPixelFormats(handleType); -} - -const char *qt_glsl_eglTextureVertexShaderProgram = - "attribute highp vec4 vertexCoordArray;\n" - "attribute mediump vec2 textureCoordArray;\n" - "uniform highp mat4 positionMatrix;\n" - "varying mediump vec2 textureCoord;\n" - "void main (void)\n" - "{\n" - " gl_Position = positionMatrix * vertexCoordArray;\n" - " textureCoord = textureCoordArray;\n" - "}"; - -static const char* qt_glsl_eglTextureShaderProgram = - "#extension GL_OES_EGL_image_external: enable\n" - "\n" - "uniform samplerExternalOES texRgb;\n" - "varying mediump vec2 textureCoord;\n" - "\n" - "void main (void)\n" - "{\n" - " gl_FragColor = texture2D(texRgb, textureCoord);\n" - "}"; - - -/*! - \since 1.2 -*/ -bool QEglImageTextureSurface::start(const QVideoSurfaceFormat &format) -{ -#ifdef DEBUG_OMAPFB_SURFACE - qDebug() << Q_FUNC_INFO << format; -#endif - - m_fallbackSurfaceActive = false; - if (format.handleType() != EGLImageTextureHandle) { - qWarning() << Q_FUNC_INFO << "Non EGLImageTextureHandle based format requested, fallback to QPainterVideoSurface"; - connect(m_fallbackSurface, SIGNAL(activeChanged(bool)), - this, SIGNAL(activeChanged(bool))); - connect(m_fallbackSurface, SIGNAL(surfaceFormatChanged(QVideoSurfaceFormat)), - this, SIGNAL(surfaceFormatChanged(QVideoSurfaceFormat))); - connect(m_fallbackSurface, SIGNAL(supportedFormatsChanged()), - this, SIGNAL(supportedFormatsChanged())); - connect(m_fallbackSurface, SIGNAL(nativeResolutionChanged(QSize)), - this, SIGNAL(nativeResolutionChanged(QSize))); - connect(m_fallbackSurface, SIGNAL(frameChanged()), - this, SIGNAL(frameChanged())); - - if (m_fallbackSurface->start(format)) { - m_fallbackSurfaceActive = true; - QAbstractVideoSurface::start(format); - } else { - qWarning() << Q_FUNC_INFO << "failed to start video surface:" << m_fallbackSurface->error(); - setError(m_fallbackSurface->error()); - - disconnect(m_fallbackSurface, SIGNAL(activeChanged(bool)), - this, SIGNAL(activeChanged(bool))); - disconnect(m_fallbackSurface, SIGNAL(surfaceFormatChanged(QVideoSurfaceFormat)), - this, SIGNAL(surfaceFormatChanged(QVideoSurfaceFormat))); - disconnect(m_fallbackSurface, SIGNAL(supportedFormatsChanged()), - this, SIGNAL(supportedFormatsChanged())); - disconnect(m_fallbackSurface, SIGNAL(nativeResolutionChanged(QSize)), - this, SIGNAL(nativeResolutionChanged(QSize))); - disconnect(m_fallbackSurface, SIGNAL(frameChanged()), - this, SIGNAL(frameChanged())); - } - - return m_fallbackSurfaceActive; - } - - QAbstractVideoSurface::Error error = NoError; - - if (isActive()) - stop(); - - if (format.frameSize().isEmpty()) { - setError(UnsupportedFormatError); - } else if (m_context) { - m_context->makeCurrent(); - m_program = new QGLShaderProgram(m_context, this); - - if (!m_program->addShaderFromSourceCode(QGLShader::Vertex, qt_glsl_eglTextureVertexShaderProgram)) { - qWarning("QOmapFbVideoSurface: Vertex shader compile error %s", - qPrintable(m_program->log())); - error = ResourceError; - } - - if (error == NoError - && !m_program->addShaderFromSourceCode(QGLShader::Fragment, qt_glsl_eglTextureShaderProgram)) { - qWarning("QOmapFbVideoSurface: Vertex shader compile error %s", - qPrintable(m_program->log())); - error = QAbstractVideoSurface::ResourceError; - } - - if (error == NoError) { - m_program->bindAttributeLocation("textureCoordArray", 1); - if(!m_program->link()) { - qWarning("QOmapFbVideoSurface: Shader link error %s", qPrintable(m_program->log())); - m_program->removeAllShaders(); - error = QAbstractVideoSurface::ResourceError; - } - } - - if (error != QAbstractVideoSurface::NoError) { - delete m_program; - m_program = 0; - } - } - - if (error == QAbstractVideoSurface::NoError) { - m_scanLineDirection = format.scanLineDirection(); - m_frameSize = format.frameSize(); - m_pixelFormat = format.pixelFormat(); - m_frameSize = format.frameSize(); - m_sourceRect = format.viewport(); - m_ready = true; - - return QAbstractVideoSurface::start(format); - } - - QAbstractVideoSurface::stop(); - return false; -} - -/*! - \since 1.2 -*/ -void QEglImageTextureSurface::stop() -{ -#ifdef DEBUG_OMAPFB_SURFACE - qDebug() << Q_FUNC_INFO; -#endif - - if (m_fallbackSurfaceActive) { - m_fallbackSurface->stop(); - m_fallbackSurfaceActive = false; - - disconnect(m_fallbackSurface, SIGNAL(activeChanged(bool)), - this, SIGNAL(activeChanged(bool))); - disconnect(m_fallbackSurface, SIGNAL(surfaceFormatChanged(QVideoSurfaceFormat)), - this, SIGNAL(surfaceFormatChanged(QVideoSurfaceFormat))); - disconnect(m_fallbackSurface, SIGNAL(supportedFormatsChanged()), - this, SIGNAL(supportedFormatsChanged())); - disconnect(m_fallbackSurface, SIGNAL(nativeResolutionChanged(QSize)), - this, SIGNAL(nativeResolutionChanged(QSize))); - disconnect(m_fallbackSurface, SIGNAL(frameChanged()), - this, SIGNAL(frameChanged())); - - m_ready = false; - QAbstractVideoSurface::stop(); - } - - if (isActive()) { - if (m_context) - m_context->makeCurrent(); - m_frame = QVideoFrame(); - - m_program->removeAllShaders(); - delete m_program; - m_program = 0; - m_ready = false; - - QAbstractVideoSurface::stop(); - } -} - -/*! - \since 1.2 -*/ -bool QEglImageTextureSurface::present(const QVideoFrame &frame) -{ - if (m_fallbackSurfaceActive) { - if (m_fallbackSurface->present(frame)) { - return true; - } else { - setError(m_fallbackSurface->error()); - stop(); - return false; - } - } - - if (!m_ready) { - if (!isActive()) - setError(StoppedError); - else - m_frame = frame; - } else if (frame.isValid() - && (frame.pixelFormat() != m_pixelFormat || frame.size() != m_frameSize)) { - setError(IncorrectFormatError); - qWarning() << "Received frame of incorrect format, stopping the surface"; - - stop(); - } else { - if (m_context) - m_context->makeCurrent(); - m_frame = frame; - m_ready = false; - emit frameChanged(); - return true; - } - return false; -} - -/*! - \since 1.2 -*/ -int QEglImageTextureSurface::brightness() const -{ - return m_fallbackSurface->brightness(); -} - -/*! - \since 1.2 -*/ -void QEglImageTextureSurface::setBrightness(int brightness) -{ - m_fallbackSurface->setBrightness(brightness); -} - -/*! - \since 1.2 -*/ -int QEglImageTextureSurface::contrast() const -{ - return m_fallbackSurface->contrast(); -} - -/*! - \since 1.2 -*/ -void QEglImageTextureSurface::setContrast(int contrast) -{ - m_fallbackSurface->setContrast(contrast); -} - -/*! - \since 1.2 -*/ -int QEglImageTextureSurface::hue() const -{ - return m_fallbackSurface->hue(); -} - -/*! - \since 1.2 -*/ -void QEglImageTextureSurface::setHue(int hue) -{ - m_fallbackSurface->setHue(hue); -} - -/*! - \since 1.2 -*/ -int QEglImageTextureSurface::saturation() const -{ - return m_fallbackSurface->saturation(); -} - -/*! - \since 1.2 -*/ -void QEglImageTextureSurface::setSaturation(int saturation) -{ - m_fallbackSurface->setSaturation(saturation); -} - -/*! - \since 1.2 -*/ -bool QEglImageTextureSurface::isReady() const -{ - return m_fallbackSurfaceActive ? m_fallbackSurface->isReady() : m_ready; -} - -/*! - \since 1.2 -*/ -void QEglImageTextureSurface::setReady(bool ready) -{ - m_ready = ready; - if (m_fallbackSurfaceActive) - m_fallbackSurface->setReady(ready); -} - -/*! - \since 1.2 -*/ -void QEglImageTextureSurface::paint(QPainter *painter, const QRectF &target, const QRectF &sourceRect) -{ - if (m_fallbackSurfaceActive) { - m_fallbackSurface->paint(painter, target, sourceRect); - return; - } - - if (!isActive() || !m_frame.isValid()) { - painter->fillRect(target, QBrush(Qt::black)); - } else { - const QRectF source( - m_sourceRect.x() + m_sourceRect.width() * sourceRect.x(), - m_sourceRect.y() + m_sourceRect.height() * sourceRect.y(), - m_sourceRect.width() * sourceRect.width(), - m_sourceRect.height() * sourceRect.height()); - - bool stencilTestEnabled = glIsEnabled(GL_STENCIL_TEST); - bool scissorTestEnabled = glIsEnabled(GL_SCISSOR_TEST); - - painter->beginNativePainting(); - - if (stencilTestEnabled) - glEnable(GL_STENCIL_TEST); - if (scissorTestEnabled) - glEnable(GL_SCISSOR_TEST); - - const int width = QGLContext::currentContext()->device()->width(); - const int height = QGLContext::currentContext()->device()->height(); - - const QTransform transform = painter->deviceTransform(); - - const GLfloat wfactor = 2.0 / width; - const GLfloat hfactor = -2.0 / height; - - const GLfloat positionMatrix[4][4] = - { - { - /*(0,0)*/ GLfloat(wfactor * transform.m11() - transform.m13()), - /*(0,1)*/ GLfloat(hfactor * transform.m12() + transform.m13()), - /*(0,2)*/ 0.0, - /*(0,3)*/ GLfloat(transform.m13()) - }, { - /*(1,0)*/ GLfloat(wfactor * transform.m21() - transform.m23()), - /*(1,1)*/ GLfloat(hfactor * transform.m22() + transform.m23()), - /*(1,2)*/ 0.0, - /*(1,3)*/ GLfloat(transform.m23()) - }, { - /*(2,0)*/ 0.0, - /*(2,1)*/ 0.0, - /*(2,2)*/ -1.0, - /*(2,3)*/ 0.0 - }, { - /*(3,0)*/ GLfloat(wfactor * transform.dx() - transform.m33()), - /*(3,1)*/ GLfloat(hfactor * transform.dy() + transform.m33()), - /*(3,2)*/ 0.0, - /*(3,3)*/ GLfloat(transform.m33()) - } - }; - - const GLfloat vTop = m_scanLineDirection == QVideoSurfaceFormat::TopToBottom - ? target.top() - : target.bottom() + 1; - const GLfloat vBottom = m_scanLineDirection == QVideoSurfaceFormat::TopToBottom - ? target.bottom() + 1 - : target.top(); - - - const GLfloat vertexCoordArray[] = - { - GLfloat(target.left()) , GLfloat(vBottom), - GLfloat(target.right() + 1), GLfloat(vBottom), - GLfloat(target.left()) , GLfloat(vTop), - GLfloat(target.right() + 1), GLfloat(vTop) - }; - - const GLfloat txLeft = source.left() / m_frameSize.width(); - const GLfloat txRight = source.right() / m_frameSize.width(); - const GLfloat txTop = m_scanLineDirection == QVideoSurfaceFormat::TopToBottom - ? source.top() / m_frameSize.height() - : source.bottom() / m_frameSize.height(); - const GLfloat txBottom = m_scanLineDirection == QVideoSurfaceFormat::TopToBottom - ? source.bottom() / m_frameSize.height() - : source.top() / m_frameSize.height(); - - const GLfloat textureCoordArray[] = - { - txLeft , txBottom, - txRight, txBottom, - txLeft , txTop, - txRight, txTop - }; - - m_program->bind(); - - m_program->enableAttributeArray("vertexCoordArray"); - m_program->enableAttributeArray("textureCoordArray"); - m_program->setAttributeArray("vertexCoordArray", vertexCoordArray, 2); - m_program->setAttributeArray("textureCoordArray", textureCoordArray, 2); - m_program->setUniformValue("positionMatrix", positionMatrix); - m_program->setUniformValue("texRgb", 0); - - //map() binds the external texture - m_frame.map(QAbstractVideoBuffer::ReadOnly); - - glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); - - //it's necessary to unbind the external texture - m_frame.unmap(); - - m_program->release(); - - painter->endNativePainting(); - } -} - -/*! - \fn QOmapFbVideoSurface::frameChanged() - \since 1.2 -*/ - -/*! - \since 1.2 -*/ -const QGLContext *QEglImageTextureSurface::glContext() const -{ - return m_context; -} - -/*! - \since 1.2 -*/ -void QEglImageTextureSurface::setGLContext(QGLContext *context) -{ - if (m_context == context) - return; - - stop(); - - m_context = context; - - m_fallbackSurface->setGLContext(context); - if (m_fallbackSurface->supportedShaderTypes() & QPainterVideoSurface::GlslShader) { - m_fallbackSurface->setShaderType(QPainterVideoSurface::GlslShader); - } else { - m_fallbackSurface->setShaderType(QPainterVideoSurface::FragmentProgramShader); - } - - emit supportedFormatsChanged(); -} - -void QEglImageTextureSurface::viewportDestroyed() -{ - m_context = 0; - m_fallbackSurface->viewportDestroyed(); - - setError(ResourceError); - stop(); -} - -#include "moc_qeglimagetexturesurface_p.cpp" -QT_END_NAMESPACE diff --git a/src/multimediakitwidgets/qeglimagetexturesurface_p.h b/src/multimediakitwidgets/qeglimagetexturesurface_p.h deleted file mode 100644 index 9e941049d..000000000 --- a/src/multimediakitwidgets/qeglimagetexturesurface_p.h +++ /dev/null @@ -1,150 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QEGLIMAGETEXTURESURFACE_P_H -#define QEGLIMAGETEXTURESURFACE_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 -#include -#include -#include -#include - -#include - -#include -#include -#include - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -QT_MODULE(Multimedia) - -class QGLContext; -class QGLShaderProgram; -class QPainterVideoSurface; - -class QEglImageTextureSurface : public QAbstractVideoSurface -{ - Q_OBJECT -public: - explicit QEglImageTextureSurface(QObject *parent = 0); - ~QEglImageTextureSurface(); - - QList supportedPixelFormats( - QAbstractVideoBuffer::HandleType handleType = QAbstractVideoBuffer::NoHandle) const; - - bool start(const QVideoSurfaceFormat &format); - void stop(); - - bool present(const QVideoFrame &frame); - - int brightness() const; - void setBrightness(int brightness); - - int contrast() const; - void setContrast(int contrast); - - int hue() const; - void setHue(int hue); - - int saturation() const; - void setSaturation(int saturation); - - bool isReady() const; - void setReady(bool ready); - - void paint(QPainter *painter, const QRectF &target, const QRectF &source = QRectF(0, 0, 1, 1)); - - const QGLContext *glContext() const; - void setGLContext(QGLContext *context); - - bool isOverlayEnabled() const; - void setOverlayEnabled(bool enabled); - - QRect displayRect() const; - void setDisplayRect(const QRect &rect); - -public Q_SLOTS: - void viewportDestroyed(); - -Q_SIGNALS: - void frameChanged(); - -private: - QGLContext *m_context; - QGLShaderProgram *m_program; - - QVideoFrame m_frame; - - QVideoFrame::PixelFormat m_pixelFormat; - QVideoSurfaceFormat::Direction m_scanLineDirection; - QSize m_frameSize; - QRect m_sourceRect; - bool m_ready; - - QRect m_viewport; - QRect m_displayRect; - QColor m_colorKey; - - QPainterVideoSurface *m_fallbackSurface; - bool m_fallbackSurfaceActive; -}; - -QT_END_NAMESPACE - -QT_END_HEADER - - -#endif diff --git a/src/multimediakitwidgets/qgraphicsvideoitem.cpp b/src/multimediakitwidgets/qgraphicsvideoitem.cpp deleted file mode 100644 index 1f8f6db61..000000000 --- a/src/multimediakitwidgets/qgraphicsvideoitem.cpp +++ /dev/null @@ -1,432 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qgraphicsvideoitem.h" - -#include -#include -#include -#include - -#include -#include - -#include - -#if !defined(QT_NO_OPENGL) && !defined(QT_OPENGL_ES_1_CL) && !defined(QT_OPENGL_ES_1) -#include -#endif - -Q_DECLARE_METATYPE(QVideoSurfaceFormat) - -QT_BEGIN_NAMESPACE - -class QGraphicsVideoItemPrivate -{ -public: - QGraphicsVideoItemPrivate() - : q_ptr(0) - , surface(0) - , mediaObject(0) - , service(0) - , rendererControl(0) - , aspectRatioMode(Qt::KeepAspectRatio) - , updatePaintDevice(true) - , rect(0.0, 0.0, 320, 240) - { - } - - QGraphicsVideoItem *q_ptr; - - QPainterVideoSurface *surface; - QPointer mediaObject; - QMediaService *service; - QVideoRendererControl *rendererControl; - Qt::AspectRatioMode aspectRatioMode; - bool updatePaintDevice; - QRectF rect; - QRectF boundingRect; - QRectF sourceRect; - QSizeF nativeSize; - - void clearService(); - void updateRects(); - - void _q_present(); - void _q_formatChanged(const QVideoSurfaceFormat &format); - void _q_updateNativeSize(); - void _q_serviceDestroyed(); -}; - -void QGraphicsVideoItemPrivate::clearService() -{ - if (rendererControl) { - surface->stop(); - rendererControl->setSurface(0); - service->releaseControl(rendererControl); - rendererControl = 0; - } - if (service) { - QObject::disconnect(service, SIGNAL(destroyed()), q_ptr, SLOT(_q_serviceDestroyed())); - service = 0; - } -} - -void QGraphicsVideoItemPrivate::updateRects() -{ - q_ptr->prepareGeometryChange(); - - if (nativeSize.isEmpty()) { - //this is necessary for item to receive the - //first paint event and configure video surface. - boundingRect = rect; - } else if (aspectRatioMode == Qt::IgnoreAspectRatio) { - boundingRect = rect; - sourceRect = QRectF(0, 0, 1, 1); - } else if (aspectRatioMode == Qt::KeepAspectRatio) { - QSizeF size = nativeSize; - size.scale(rect.size(), Qt::KeepAspectRatio); - - boundingRect = QRectF(0, 0, size.width(), size.height()); - boundingRect.moveCenter(rect.center()); - - sourceRect = QRectF(0, 0, 1, 1); - } else if (aspectRatioMode == Qt::KeepAspectRatioByExpanding) { - boundingRect = rect; - - QSizeF size = rect.size(); - size.scale(nativeSize, Qt::KeepAspectRatio); - - sourceRect = QRectF( - 0, 0, size.width() / nativeSize.width(), size.height() / nativeSize.height()); - sourceRect.moveCenter(QPointF(0.5, 0.5)); - } -} - -void QGraphicsVideoItemPrivate::_q_present() -{ - if (q_ptr->isObscured()) { - q_ptr->update(boundingRect); - surface->setReady(true); - } else { - q_ptr->update(boundingRect); - } -} - -void QGraphicsVideoItemPrivate::_q_updateNativeSize() -{ - const QSize &size = surface->surfaceFormat().sizeHint(); - if (nativeSize != size) { - nativeSize = size; - - updateRects(); - emit q_ptr->nativeSizeChanged(nativeSize); - } -} - -void QGraphicsVideoItemPrivate::_q_serviceDestroyed() -{ - rendererControl = 0; - service = 0; - - surface->stop(); -} - - -/*! - \class QGraphicsVideoItem - - \brief The QGraphicsVideoItem class provides a graphics item which display video produced by a QMediaObject. - - \inmodule QtMultimediaKit - \ingroup multimedia - \since 1.0 - - Attaching a QGraphicsVideoItem to a QMediaObject allows it to display - the video or image output of that media object. A QGraphicsVideoItem - is attached to a media object by passing a pointer to the QMediaObject - to the setMediaObject() function. - - \snippet doc/src/snippets/multimedia-snippets/video.cpp Video graphics item - - \bold {Note}: Only a single display output can be attached to a media - object at one time. - - \sa QMediaObject, QMediaPlayer, QVideoWidget -*/ - -/*! - Constructs a graphics item that displays video. - - The \a parent is passed to QGraphicsItem. -*/ -QGraphicsVideoItem::QGraphicsVideoItem(QGraphicsItem *parent) - : QGraphicsObject(parent) - , d_ptr(new QGraphicsVideoItemPrivate) -{ - d_ptr->q_ptr = this; - d_ptr->surface = new QPainterVideoSurface; - - qRegisterMetaType(); - - connect(d_ptr->surface, SIGNAL(frameChanged()), this, SLOT(_q_present())); - connect(d_ptr->surface, SIGNAL(surfaceFormatChanged(QVideoSurfaceFormat)), - this, SLOT(_q_updateNativeSize()), Qt::QueuedConnection); -} - -/*! - Destroys a video graphics item. -*/ -QGraphicsVideoItem::~QGraphicsVideoItem() -{ - if (d_ptr->rendererControl) { - d_ptr->rendererControl->setSurface(0); - d_ptr->service->releaseControl(d_ptr->rendererControl); - } - - delete d_ptr->surface; - delete d_ptr; -} - -/*! - \property QGraphicsVideoItem::mediaObject - \brief the media object which provides the video displayed by a graphics - item. - \since 1.0 -*/ - -QMediaObject *QGraphicsVideoItem::mediaObject() const -{ - return d_func()->mediaObject; -} - -/*! - \internal - \since 1.0 -*/ -bool QGraphicsVideoItem::setMediaObject(QMediaObject *object) -{ - Q_D(QGraphicsVideoItem); - - if (object == d->mediaObject) - return true; - - d->clearService(); - - d->mediaObject = object; - - if (d->mediaObject) { - d->service = d->mediaObject->service(); - - if (d->service) { - QMediaControl *control = d->service->requestControl(QVideoRendererControl_iid); - if (control) { - d->rendererControl = qobject_cast(control); - - if (d->rendererControl) { - //don't set the surface untill the item is painted - //at least once and the surface is configured - if (!d->updatePaintDevice) - d->rendererControl->setSurface(d->surface); - else - update(boundingRect()); - - connect(d->service, SIGNAL(destroyed()), this, SLOT(_q_serviceDestroyed())); - - return true; - } - if (control) - d->service->releaseControl(control); - } - } - } - - d->mediaObject = 0; - return false; -} - -/*! - \property QGraphicsVideoItem::aspectRatioMode - \brief how a video is scaled to fit the graphics item's size. - \since 1.0 -*/ - -Qt::AspectRatioMode QGraphicsVideoItem::aspectRatioMode() const -{ - return d_func()->aspectRatioMode; -} - -void QGraphicsVideoItem::setAspectRatioMode(Qt::AspectRatioMode mode) -{ - Q_D(QGraphicsVideoItem); - - d->aspectRatioMode = mode; - d->updateRects(); -} - -/*! - \property QGraphicsVideoItem::offset - \brief the video item's offset. - - QGraphicsVideoItem will draw video using the offset for its top left - corner. - \since 1.0 -*/ - -QPointF QGraphicsVideoItem::offset() const -{ - return d_func()->rect.topLeft(); -} - -void QGraphicsVideoItem::setOffset(const QPointF &offset) -{ - Q_D(QGraphicsVideoItem); - - d->rect.moveTo(offset); - d->updateRects(); -} - -/*! - \property QGraphicsVideoItem::size - \brief the video item's size. - - QGraphicsVideoItem will draw video scaled to fit size according to its - fillMode. - \since 1.0 -*/ - -QSizeF QGraphicsVideoItem::size() const -{ - return d_func()->rect.size(); -} - -void QGraphicsVideoItem::setSize(const QSizeF &size) -{ - Q_D(QGraphicsVideoItem); - - d->rect.setSize(size.isValid() ? size : QSizeF(0, 0)); - d->updateRects(); -} - -/*! - \property QGraphicsVideoItem::nativeSize - \brief the native size of the video. - \since 1.0 -*/ - -QSizeF QGraphicsVideoItem::nativeSize() const -{ - return d_func()->nativeSize; -} - -/*! - \fn QGraphicsVideoItem::nativeSizeChanged(const QSizeF &size) - - Signals that the native \a size of the video has changed. - \since 1.0 -*/ - -/*! - \reimp - \since 1.0 -*/ -QRectF QGraphicsVideoItem::boundingRect() const -{ - return d_func()->boundingRect; -} - -/*! - \reimp - \since 1.0 -*/ -void QGraphicsVideoItem::paint( - QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) -{ - Q_D(QGraphicsVideoItem); - - Q_UNUSED(option); - Q_UNUSED(widget); - - if (d->surface && d->updatePaintDevice) { - d->updatePaintDevice = false; -#if !defined(QT_NO_OPENGL) && !defined(QT_OPENGL_ES_1_CL) && !defined(QT_OPENGL_ES_1) - if (widget) - connect(widget, SIGNAL(destroyed()), d->surface, SLOT(viewportDestroyed())); - - d->surface->setGLContext(const_cast(QGLContext::currentContext())); - if (d->surface->supportedShaderTypes() & QPainterVideoSurface::GlslShader) { - d->surface->setShaderType(QPainterVideoSurface::GlslShader); - } else { - d->surface->setShaderType(QPainterVideoSurface::FragmentProgramShader); - } -#endif - if (d->rendererControl && d->rendererControl->surface() != d->surface) - d->rendererControl->setSurface(d->surface); - } - - if (d->surface && d->surface->isActive()) { - d->surface->paint(painter, d->boundingRect, d->sourceRect); - d->surface->setReady(true); - } -} - -/*! - \reimp - - \internal - \since 1.0 -*/ -QVariant QGraphicsVideoItem::itemChange(GraphicsItemChange change, const QVariant &value) -{ - return QGraphicsItem::itemChange(change, value); -} - -/*! - \internal - \since 1.0 -*/ -void QGraphicsVideoItem::timerEvent(QTimerEvent *event) -{ - QGraphicsObject::timerEvent(event); -} - -#include "moc_qgraphicsvideoitem.cpp" -QT_END_NAMESPACE diff --git a/src/multimediakitwidgets/qgraphicsvideoitem.h b/src/multimediakitwidgets/qgraphicsvideoitem.h deleted file mode 100644 index cf8913417..000000000 --- a/src/multimediakitwidgets/qgraphicsvideoitem.h +++ /dev/null @@ -1,115 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QGRAPHICSVIDEOITEM_H -#define QGRAPHICSVIDEOITEM_H - -#include - -#include -#include - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -QT_MODULE(Multimedia) - -class QVideoSurfaceFormat; -QT_END_NAMESPACE - -QT_BEGIN_NAMESPACE - -class QGraphicsVideoItemPrivate; -class Q_MULTIMEDIA_EXPORT QGraphicsVideoItem : public QGraphicsObject, public QMediaBindableInterface -{ - Q_OBJECT - Q_INTERFACES(QMediaBindableInterface) - Q_PROPERTY(QMediaObject* mediaObject READ mediaObject WRITE setMediaObject) - Q_PROPERTY(Qt::AspectRatioMode aspectRatioMode READ aspectRatioMode WRITE setAspectRatioMode) - Q_PROPERTY(QPointF offset READ offset WRITE setOffset) - Q_PROPERTY(QSizeF size READ size WRITE setSize) - Q_PROPERTY(QSizeF nativeSize READ nativeSize NOTIFY nativeSizeChanged) -public: - QGraphicsVideoItem(QGraphicsItem *parent = 0); - ~QGraphicsVideoItem(); - - QMediaObject *mediaObject() const; - - Qt::AspectRatioMode aspectRatioMode() const; - void setAspectRatioMode(Qt::AspectRatioMode mode); - - QPointF offset() const; - void setOffset(const QPointF &offset); - - QSizeF size() const; - void setSize(const QSizeF &size); - - QSizeF nativeSize() const; - - QRectF boundingRect() const; - - void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0); - -Q_SIGNALS: - void nativeSizeChanged(const QSizeF &size); - -protected: - void timerEvent(QTimerEvent *event); - QVariant itemChange(GraphicsItemChange change, const QVariant &value); - - bool setMediaObject(QMediaObject *object); - - QGraphicsVideoItemPrivate *d_ptr; - -private: - Q_DECLARE_PRIVATE(QGraphicsVideoItem) - Q_PRIVATE_SLOT(d_func(), void _q_present()) - Q_PRIVATE_SLOT(d_func(), void _q_updateNativeSize()) - Q_PRIVATE_SLOT(d_func(), void _q_serviceDestroyed()) -}; - -QT_END_NAMESPACE - -QT_END_HEADER - - -#endif diff --git a/src/multimediakitwidgets/qgraphicsvideoitem_maemo6.cpp b/src/multimediakitwidgets/qgraphicsvideoitem_maemo6.cpp deleted file mode 100644 index 387a25042..000000000 --- a/src/multimediakitwidgets/qgraphicsvideoitem_maemo6.cpp +++ /dev/null @@ -1,498 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qgraphicsvideoitem.h" - -#include -#include -#include - -#include - -#include -#include -#include -#include -#include - -#include - -#include - -#if !defined(QT_NO_OPENGL) && !defined(QT_OPENGL_ES_1_CL) && !defined(QT_OPENGL_ES_1) -#include -#endif - -//#define ENABLE_OVERLAY - -namespace -{ -//XInitThreads is necessary for gltexturesink element. -//To ensure it's called before main() it's better to link to -//libQtMultimediaKit.so directly, not when QML multimedia plugin is loaded. -class InitThreads -{ -public: - InitThreads() - { - XInitThreads(); - } -} _initThreads; -} - -Q_DECLARE_METATYPE(QVideoSurfaceFormat) - -QT_BEGIN_NAMESPACE - -class QGraphicsVideoItemPrivate -{ -public: - QGraphicsVideoItemPrivate() - : q_ptr(0) - , surface(0) - , mediaObject(0) - , service(0) - , rendererControl(0) - , aspectRatioMode(Qt::KeepAspectRatio) - , updatePaintDevice(true) - , rect(0.0, 0.0, 320, 240) - { - } - - QGraphicsVideoItem *q_ptr; - - QEglImageTextureSurface *surface; - QPointer mediaObject; - QMediaService *service; - QVideoRendererControl *rendererControl; - Qt::AspectRatioMode aspectRatioMode; - bool updatePaintDevice; - QRectF rect; - QRectF boundingRect; - QRectF sourceRect; - QSizeF nativeSize; - - void clearService(); - void updateRects(); - - void _q_present(); - void _q_formatChanged(const QVideoSurfaceFormat &format); - void _q_updateNativeSize(); - void _q_serviceDestroyed(); -}; - -void QGraphicsVideoItemPrivate::clearService() -{ - if (rendererControl) { - surface->stop(); - rendererControl->setSurface(0); - service->releaseControl(rendererControl); - rendererControl = 0; - } - if (service) { - QObject::disconnect(service, SIGNAL(destroyed()), q_ptr, SLOT(_q_serviceDestroyed())); - service = 0; - } -} - -void QGraphicsVideoItemPrivate::updateRects() -{ - q_ptr->prepareGeometryChange(); - - if (nativeSize.isEmpty()) { - //this is necessary for item to receive the - //first paint event and configure video surface. - boundingRect = rect; - } else if (aspectRatioMode == Qt::IgnoreAspectRatio) { - boundingRect = rect; - sourceRect = QRectF(0, 0, 1, 1); - } else if (aspectRatioMode == Qt::KeepAspectRatio) { - QSizeF size = nativeSize; - size.scale(rect.size(), Qt::KeepAspectRatio); - - boundingRect = QRectF(0, 0, size.width(), size.height()); - boundingRect.moveCenter(rect.center()); - - sourceRect = QRectF(0, 0, 1, 1); - } else if (aspectRatioMode == Qt::KeepAspectRatioByExpanding) { - boundingRect = rect; - - QSizeF size = rect.size(); - size.scale(nativeSize, Qt::KeepAspectRatio); - - sourceRect = QRectF( - 0, 0, size.width() / nativeSize.width(), size.height() / nativeSize.height()); - sourceRect.moveCenter(QPointF(0.5, 0.5)); - } -} - -void QGraphicsVideoItemPrivate::_q_present() -{ - if (q_ptr->isObscured()) { - q_ptr->update(boundingRect); - surface->setReady(true); - } else { - q_ptr->update(boundingRect); - } -} - -void QGraphicsVideoItemPrivate::_q_updateNativeSize() -{ - QSize size = surface->surfaceFormat().sizeHint(); - if (size.isEmpty()) - size = rendererControl->property("nativeSize").toSize(); - - if (nativeSize != size) { - nativeSize = size; - - updateRects(); - emit q_ptr->nativeSizeChanged(nativeSize); - } -} - -void QGraphicsVideoItemPrivate::_q_serviceDestroyed() -{ - rendererControl = 0; - service = 0; - - surface->stop(); -} - - -/*! - \class QGraphicsVideoItem - - \brief The QGraphicsVideoItem class provides a graphics item which display video produced by a QMediaObject. - - \inmodule QtMultimediaKit - \ingroup multimedia - - Attaching a QGraphicsVideoItem to a QMediaObject allows it to display - the video or image output of that media object. A QGraphicsVideoItem - is attached to a media object by passing a pointer to the QMediaObject - to the setMediaObject() function. - - \code - player = new QMediaPlayer(this); - - QGraphicsVideoItem *item = new QGraphicsVideoItem; - player->setVideoOutput(item); - graphicsView->scene()->addItem(item); - graphicsView->show(); - - player->setMedia(video); - player->play(); - \endcode - - \bold {Note}: Only a single display output can be attached to a media - object at one time. - - \sa QMediaObject, QMediaPlayer, QVideoWidget -*/ - -/*! - Constructs a graphics item that displays video. - - The \a parent is passed to QGraphicsItem. -*/ -QGraphicsVideoItem::QGraphicsVideoItem(QGraphicsItem *parent) - : QGraphicsObject(parent) - , d_ptr(new QGraphicsVideoItemPrivate) -{ - d_ptr->q_ptr = this; - d_ptr->surface = new QEglImageTextureSurface(this); - - qRegisterMetaType(); - - connect(d_ptr->surface, SIGNAL(frameChanged()), this, SLOT(_q_present())); - connect(d_ptr->surface, SIGNAL(surfaceFormatChanged(QVideoSurfaceFormat)), - this, SLOT(_q_updateNativeSize()), Qt::QueuedConnection); -} - -/*! - Destroys a video graphics item. -*/ -QGraphicsVideoItem::~QGraphicsVideoItem() -{ - if (d_ptr->rendererControl) { - d_ptr->rendererControl->setSurface(0); - d_ptr->service->releaseControl(d_ptr->rendererControl); - } - - delete d_ptr->surface; - delete d_ptr; -} - -/*! - \property QGraphicsVideoItem::mediaObject - \brief the media object which provides the video displayed by a graphics - item. -*/ - -QMediaObject *QGraphicsVideoItem::mediaObject() const -{ - return d_func()->mediaObject; -} - -/*! - \internal -*/ -bool QGraphicsVideoItem::setMediaObject(QMediaObject *object) -{ - Q_D(QGraphicsVideoItem); - - if (object == d->mediaObject) - return true; - - d->clearService(); - - d->mediaObject = object; - - if (d->mediaObject) { - d->service = d->mediaObject->service(); - - if (d->service) { - QMediaControl *control = d->service->requestControl(QVideoRendererControl_iid); - if (control) { - d->rendererControl = qobject_cast(control); - - if (d->rendererControl) { - connect(d->rendererControl, SIGNAL(nativeSizeChanged()), - this, SLOT(_q_updateNativeSize()), Qt::QueuedConnection); - d->_q_updateNativeSize(); - //don't set the surface untill the item is painted - //at least once and the surface is configured - if (!d->updatePaintDevice) - d->rendererControl->setSurface(d->surface); - else - update(boundingRect()); - - connect(d->service, SIGNAL(destroyed()), this, SLOT(_q_serviceDestroyed())); - - return true; - } - if (control) - d->service->releaseControl(control); - } - } - } - - d->mediaObject = 0; - return false; -} - -/*! - \property QGraphicsVideoItem::aspectRatioMode - \brief how a video is scaled to fit the graphics item's size. -*/ - -Qt::AspectRatioMode QGraphicsVideoItem::aspectRatioMode() const -{ - return d_func()->aspectRatioMode; -} - -void QGraphicsVideoItem::setAspectRatioMode(Qt::AspectRatioMode mode) -{ - Q_D(QGraphicsVideoItem); - - d->aspectRatioMode = mode; - d->updateRects(); -} - -/*! - \property QGraphicsVideoItem::offset - \brief the video item's offset. - - QGraphicsVideoItem will draw video using the offset for its top left - corner. -*/ - -QPointF QGraphicsVideoItem::offset() const -{ - return d_func()->rect.topLeft(); -} - -void QGraphicsVideoItem::setOffset(const QPointF &offset) -{ - Q_D(QGraphicsVideoItem); - - d->rect.moveTo(offset); - d->updateRects(); -} - -/*! - \property QGraphicsVideoItem::size - \brief the video item's size. - - QGraphicsVideoItem will draw video scaled to fit size according to its - fillMode. -*/ - -QSizeF QGraphicsVideoItem::size() const -{ - return d_func()->rect.size(); -} - -void QGraphicsVideoItem::setSize(const QSizeF &size) -{ - Q_D(QGraphicsVideoItem); - - d->rect.setSize(size.isValid() ? size : QSizeF(0, 0)); - d->updateRects(); -} - -/*! - \property QGraphicsVideoItem::nativeSize - \brief the native size of the video. -*/ - -QSizeF QGraphicsVideoItem::nativeSize() const -{ - return d_func()->nativeSize; -} - -/*! - \fn QGraphicsVideoItem::nativeSizeChanged(const QSizeF &size) - - Signals that the native \a size of the video has changed. -*/ - -/*! - \reimp -*/ -QRectF QGraphicsVideoItem::boundingRect() const -{ - return d_func()->boundingRect; -} - -/*! - \reimp -*/ -void QGraphicsVideoItem::paint( - QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) -{ - Q_D(QGraphicsVideoItem); - - Q_UNUSED(option); - Q_UNUSED(widget); - - if (d->surface && d->rendererControl && d->updatePaintDevice) { - d->updatePaintDevice = false; - - if (widget) - d->rendererControl->setProperty("winId", qulonglong(widget->winId())); - -#if !defined(QT_NO_OPENGL) && !defined(QT_OPENGL_ES_1_CL) && !defined(QT_OPENGL_ES_1) - if (widget) - connect(widget, SIGNAL(destroyed()), d->surface, SLOT(viewportDestroyed())); - - d->surface->setGLContext(const_cast(QGLContext::currentContext())); -#endif - if (d->rendererControl->surface() != d->surface) - d->rendererControl->setSurface(d->surface); - } - - - //overlay doesn't work reliably - - //check if the item is obscured: -#ifdef ENABLE_OVERLAY - if (!isObscured()) { - bool obscured = false; - - if (scene()) { - foreach (QGraphicsItem *item, - scene()->items(mapToScene(boundingRect()), Qt::IntersectsItemBoundingRect) ) { - if (item->flags() & QGraphicsItem::ItemHasNoContents) - continue; - - if (item == this) - break; - - if (collidesWithItem(item)) { - obscured = true; - break; - } - } - } - - d->rendererControl->setProperty("overlayEnabled", !obscured); - } - - if (d->rendererControl->property("overlayEnabled").toBool()) { - QTransform transform = painter->combinedTransform(); - QRect overlayRect = transform.mapRect(d->boundingRect).toRect(); - - d->rendererControl->setProperty("overlayGeometry", overlayRect); - QMetaObject::invokeMethod(d->rendererControl, "repaintOverlay"); - - painter->fillRect(d->boundingRect, - d->rendererControl->property("colorKey").value()); - } else -#endif //ENABLE_OVERLAY - { - if (d->surface && d->surface->isActive()) { - d->surface->paint(painter, d->boundingRect, d->sourceRect); - d->surface->setReady(true); - } - } -} - -/*! - \reimp - - \internal -*/ -QVariant QGraphicsVideoItem::itemChange(GraphicsItemChange change, const QVariant &value) -{ - return QGraphicsItem::itemChange(change, value); -} - -/*! - \internal -*/ -void QGraphicsVideoItem::timerEvent(QTimerEvent *event) -{ - QGraphicsObject::timerEvent(event); -} - -#include "moc_qgraphicsvideoitem.cpp" -QT_END_NAMESPACE diff --git a/src/multimediakitwidgets/qpaintervideosurface.cpp b/src/multimediakitwidgets/qpaintervideosurface.cpp deleted file mode 100644 index bd82f7841..000000000 --- a/src/multimediakitwidgets/qpaintervideosurface.cpp +++ /dev/null @@ -1,1728 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include -#include - -#include - -#include -#include -#include - -#if !defined(QT_NO_OPENGL) && !defined(QT_OPENGL_ES_1_CL) && !defined(QT_OPENGL_ES_1) -#include -#ifndef GL_CLAMP_TO_EDGE -#define GL_CLAMP_TO_EDGE 0x812F -#endif -#endif - -#include -QT_BEGIN_NAMESPACE - -QVideoSurfacePainter::~QVideoSurfacePainter() -{ -} - -class QVideoSurfaceGenericPainter : public QVideoSurfacePainter -{ -public: - QVideoSurfaceGenericPainter(); - - QList supportedPixelFormats( - QAbstractVideoBuffer::HandleType handleType) const; - - bool isFormatSupported( - const QVideoSurfaceFormat &format, QVideoSurfaceFormat *similar) const; - - QAbstractVideoSurface::Error start(const QVideoSurfaceFormat &format); - void stop(); - - QAbstractVideoSurface::Error setCurrentFrame(const QVideoFrame &frame); - - QAbstractVideoSurface::Error paint( - const QRectF &target, QPainter *painter, const QRectF &source); - - void updateColors(int brightness, int contrast, int hue, int saturation); - -private: - QList m_imagePixelFormats; - QVideoFrame m_frame; - QSize m_imageSize; - QImage::Format m_imageFormat; - QVideoSurfaceFormat::Direction m_scanLineDirection; -}; - -QVideoSurfaceGenericPainter::QVideoSurfaceGenericPainter() - : m_imageFormat(QImage::Format_Invalid) - , m_scanLineDirection(QVideoSurfaceFormat::TopToBottom) -{ - m_imagePixelFormats - << QVideoFrame::Format_RGB32 -#ifndef QT_OPENGL_ES // The raster formats should be a subset of the GL formats. - << QVideoFrame::Format_RGB24 -#endif - << QVideoFrame::Format_ARGB32 - << QVideoFrame::Format_RGB565; -} - -QList QVideoSurfaceGenericPainter::supportedPixelFormats( - QAbstractVideoBuffer::HandleType handleType) const -{ - switch (handleType) { - case QAbstractVideoBuffer::QPixmapHandle: - case QAbstractVideoBuffer::NoHandle: - return m_imagePixelFormats; - default: - ; - } - return QList(); -} - -bool QVideoSurfaceGenericPainter::isFormatSupported( - const QVideoSurfaceFormat &format, QVideoSurfaceFormat *) const -{ - switch (format.handleType()) { - case QAbstractVideoBuffer::QPixmapHandle: - return true; - case QAbstractVideoBuffer::NoHandle: - return m_imagePixelFormats.contains(format.pixelFormat()) - && !format.frameSize().isEmpty(); - default: - ; - } - return false; -} - -QAbstractVideoSurface::Error QVideoSurfaceGenericPainter::start(const QVideoSurfaceFormat &format) -{ - m_frame = QVideoFrame(); - m_imageFormat = QVideoFrame::imageFormatFromPixelFormat(format.pixelFormat()); - m_imageSize = format.frameSize(); - m_scanLineDirection = format.scanLineDirection(); - - const QAbstractVideoBuffer::HandleType t = format.handleType(); - if (t == QAbstractVideoBuffer::NoHandle) { - if (m_imageFormat != QImage::Format_Invalid -#ifdef QT_OPENGL_ES - && format.pixelFormat() != QVideoFrame::Format_RGB24 -#endif - && !m_imageSize.isEmpty()) { - return QAbstractVideoSurface::NoError; - } - } else if (t == QAbstractVideoBuffer::QPixmapHandle) { - return QAbstractVideoSurface::NoError; - } - return QAbstractVideoSurface::UnsupportedFormatError; -} - -void QVideoSurfaceGenericPainter::stop() -{ - m_frame = QVideoFrame(); -} - -QAbstractVideoSurface::Error QVideoSurfaceGenericPainter::setCurrentFrame(const QVideoFrame &frame) -{ - m_frame = frame; - - return QAbstractVideoSurface::NoError; -} - -QAbstractVideoSurface::Error QVideoSurfaceGenericPainter::paint( - const QRectF &target, QPainter *painter, const QRectF &source) -{ - if (!m_frame.isValid()) { - painter->fillRect(target, Qt::black); - return QAbstractVideoSurface::NoError; - } - - if (m_frame.handleType() == QAbstractVideoBuffer::QPixmapHandle) { - painter->drawPixmap(target, m_frame.handle().value(), source); - } else if (m_frame.map(QAbstractVideoBuffer::ReadOnly)) { - QImage image( - m_frame.bits(), - m_imageSize.width(), - m_imageSize.height(), - m_frame.bytesPerLine(), - m_imageFormat); - - if (m_scanLineDirection == QVideoSurfaceFormat::BottomToTop) { - const QTransform oldTransform = painter->transform(); - - painter->scale(1, -1); - painter->translate(0, -target.bottom()); - painter->drawImage( - QRectF(target.x(), 0, target.width(), target.height()), image, source); - painter->setTransform(oldTransform); - } else { - painter->drawImage(target, image, source); - } - - m_frame.unmap(); - } else if (m_frame.isValid()) { - return QAbstractVideoSurface::IncorrectFormatError; - } else { - painter->fillRect(target, Qt::black); - } - return QAbstractVideoSurface::NoError; -} - -void QVideoSurfaceGenericPainter::updateColors(int, int, int, int) -{ -} - -#if !defined(QT_NO_OPENGL) && !defined(QT_OPENGL_ES_1_CL) && !defined(QT_OPENGL_ES_1) - -#ifndef Q_WS_MAC -# ifndef APIENTRYP -# ifdef APIENTRY -# define APIENTRYP APIENTRY * -# else -# define APIENTRY -# define APIENTRYP * -# endif -# endif -#else -# define APIENTRY -# define APIENTRYP * -#endif - -#ifndef GL_TEXTURE0 -# define GL_TEXTURE0 0x84C0 -# define GL_TEXTURE1 0x84C1 -# define GL_TEXTURE2 0x84C2 -#endif -#ifndef GL_PROGRAM_ERROR_STRING_ARB -# define GL_PROGRAM_ERROR_STRING_ARB 0x8874 -#endif - -#ifndef GL_UNSIGNED_SHORT_5_6_5 -# define GL_UNSIGNED_SHORT_5_6_5 33635 -#endif - -class QVideoSurfaceGLPainter : public QVideoSurfacePainter -{ -public: - QVideoSurfaceGLPainter(QGLContext *context); - ~QVideoSurfaceGLPainter(); - QList supportedPixelFormats( - QAbstractVideoBuffer::HandleType handleType) const; - - bool isFormatSupported( - const QVideoSurfaceFormat &format, QVideoSurfaceFormat *similar) const; - - QAbstractVideoSurface::Error setCurrentFrame(const QVideoFrame &frame); - - QAbstractVideoSurface::Error paint( - const QRectF &target, QPainter *painter, const QRectF &source); - - void updateColors(int brightness, int contrast, int hue, int saturation); - void viewportDestroyed(); - -protected: - void initRgbTextureInfo(GLenum internalFormat, GLuint format, GLenum type, const QSize &size); - void initYuv420PTextureInfo(const QSize &size); - void initYv12TextureInfo(const QSize &size); - -#ifndef QT_OPENGL_ES - typedef void (APIENTRY *_glActiveTexture) (GLenum); - _glActiveTexture glActiveTexture; -#endif - - QList m_imagePixelFormats; - QList m_glPixelFormats; - QMatrix4x4 m_colorMatrix; - QVideoFrame m_frame; - - QGLContext *m_context; - QAbstractVideoBuffer::HandleType m_handleType; - QVideoSurfaceFormat::Direction m_scanLineDirection; - QVideoSurfaceFormat::YCbCrColorSpace m_colorSpace; - GLenum m_textureFormat; - GLuint m_textureInternalFormat; - GLenum m_textureType; - int m_textureCount; - GLuint m_textureIds[3]; - int m_textureWidths[3]; - int m_textureHeights[3]; - int m_textureOffsets[3]; - bool m_yuv; -}; - -QVideoSurfaceGLPainter::QVideoSurfaceGLPainter(QGLContext *context) - : m_context(context) - , m_handleType(QAbstractVideoBuffer::NoHandle) - , m_scanLineDirection(QVideoSurfaceFormat::TopToBottom) - , m_colorSpace(QVideoSurfaceFormat::YCbCr_BT601) - , m_textureFormat(0) - , m_textureInternalFormat(0) - , m_textureType(0) - , m_textureCount(0) - , m_yuv(false) -{ -#ifndef QT_OPENGL_ES - glActiveTexture = (_glActiveTexture)m_context->getProcAddress(QLatin1String("glActiveTexture")); -#endif -} - -QVideoSurfaceGLPainter::~QVideoSurfaceGLPainter() -{ -} - -void QVideoSurfaceGLPainter::viewportDestroyed() -{ - m_context = 0; -} - -QList QVideoSurfaceGLPainter::supportedPixelFormats( - QAbstractVideoBuffer::HandleType handleType) const -{ - switch (handleType) { - case QAbstractVideoBuffer::NoHandle: - return m_imagePixelFormats; - case QAbstractVideoBuffer::QPixmapHandle: - case QAbstractVideoBuffer::GLTextureHandle: - return m_glPixelFormats; - default: - ; - } - return QList(); -} - -bool QVideoSurfaceGLPainter::isFormatSupported( - const QVideoSurfaceFormat &format, QVideoSurfaceFormat *) const -{ - if (format.frameSize().isEmpty()) { - return false; - } else { - switch (format.handleType()) { - case QAbstractVideoBuffer::NoHandle: - return m_imagePixelFormats.contains(format.pixelFormat()); - case QAbstractVideoBuffer::QPixmapHandle: - case QAbstractVideoBuffer::GLTextureHandle: - return m_glPixelFormats.contains(format.pixelFormat()); - default: - ; - } - } - return false; -} - -QAbstractVideoSurface::Error QVideoSurfaceGLPainter::setCurrentFrame(const QVideoFrame &frame) -{ - m_frame = frame; - - if (m_handleType == QAbstractVideoBuffer::GLTextureHandle) { - m_textureIds[0] = frame.handle().toInt(); - } else if (m_frame.map(QAbstractVideoBuffer::ReadOnly)) { - m_context->makeCurrent(); - - for (int i = 0; i < m_textureCount; ++i) { - glBindTexture(GL_TEXTURE_2D, m_textureIds[i]); - glTexImage2D( - GL_TEXTURE_2D, - 0, - m_textureInternalFormat, - m_textureWidths[i], - m_textureHeights[i], - 0, - m_textureFormat, - m_textureType, - m_frame.bits() + m_textureOffsets[i]); - glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); - glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); - glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); - glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); - } - m_frame.unmap(); - } else if (m_handleType != QAbstractVideoBuffer::QPixmapHandle && m_frame.isValid()) { - return QAbstractVideoSurface::IncorrectFormatError; - } - - return QAbstractVideoSurface::NoError; -} - -QAbstractVideoSurface::Error QVideoSurfaceGLPainter::paint( - const QRectF &target, QPainter *painter, const QRectF &source) -{ - if (!m_frame.isValid()) { - painter->fillRect(target, Qt::black); - return QAbstractVideoSurface::NoError; - } - - if (m_frame.handleType() == QAbstractVideoBuffer::QPixmapHandle) { - painter->drawPixmap(target, m_frame.handle().value(), source); - } else if (m_frame.isValid()) { - return QAbstractVideoSurface::IncorrectFormatError; - } else { - painter->fillRect(target, Qt::black); - } - return QAbstractVideoSurface::NoError; -} - -void QVideoSurfaceGLPainter::updateColors(int brightness, int contrast, int hue, int saturation) -{ - const qreal b = brightness / 200.0; - const qreal c = contrast / 100.0 + 1.0; - const qreal h = hue / 100.0; - const qreal s = saturation / 100.0 + 1.0; - - const qreal cosH = qCos(M_PI * h); - const qreal sinH = qSin(M_PI * h); - - const qreal h11 = 0.787 * cosH - 0.213 * sinH + 0.213; - const qreal h21 = -0.213 * cosH + 0.143 * sinH + 0.213; - const qreal h31 = -0.213 * cosH - 0.787 * sinH + 0.213; - - const qreal h12 = -0.715 * cosH - 0.715 * sinH + 0.715; - const qreal h22 = 0.285 * cosH + 0.140 * sinH + 0.715; - const qreal h32 = -0.715 * cosH + 0.715 * sinH + 0.715; - - const qreal h13 = -0.072 * cosH + 0.928 * sinH + 0.072; - const qreal h23 = -0.072 * cosH - 0.283 * sinH + 0.072; - const qreal h33 = 0.928 * cosH + 0.072 * sinH + 0.072; - - const qreal sr = (1.0 - s) * 0.3086; - const qreal sg = (1.0 - s) * 0.6094; - const qreal sb = (1.0 - s) * 0.0820; - - const qreal sr_s = sr + s; - const qreal sg_s = sg + s; - const qreal sb_s = sr + s; - - const float m4 = (s + sr + sg + sb) * (0.5 - 0.5 * c + b); - - m_colorMatrix(0, 0) = c * (sr_s * h11 + sg * h21 + sb * h31); - m_colorMatrix(0, 1) = c * (sr_s * h12 + sg * h22 + sb * h32); - m_colorMatrix(0, 2) = c * (sr_s * h13 + sg * h23 + sb * h33); - m_colorMatrix(0, 3) = m4; - - m_colorMatrix(1, 0) = c * (sr * h11 + sg_s * h21 + sb * h31); - m_colorMatrix(1, 1) = c * (sr * h12 + sg_s * h22 + sb * h32); - m_colorMatrix(1, 2) = c * (sr * h13 + sg_s * h23 + sb * h33); - m_colorMatrix(1, 3) = m4; - - m_colorMatrix(2, 0) = c * (sr * h11 + sg * h21 + sb_s * h31); - m_colorMatrix(2, 1) = c * (sr * h12 + sg * h22 + sb_s * h32); - m_colorMatrix(2, 2) = c * (sr * h13 + sg * h23 + sb_s * h33); - m_colorMatrix(2, 3) = m4; - - m_colorMatrix(3, 0) = 0.0; - m_colorMatrix(3, 1) = 0.0; - m_colorMatrix(3, 2) = 0.0; - m_colorMatrix(3, 3) = 1.0; - - if (m_yuv) { - QMatrix4x4 colorSpaceMatrix; - - switch (m_colorSpace) { - case QVideoSurfaceFormat::YCbCr_JPEG: - colorSpaceMatrix = QMatrix4x4( - 1.0, 0.000, 1.402, -0.701, - 1.0, -0.344, -0.714, 0.529, - 1.0, 1.772, 0.000, -0.886, - 0.0, 0.000, 0.000, 1.0000); - break; - case QVideoSurfaceFormat::YCbCr_BT709: - case QVideoSurfaceFormat::YCbCr_xvYCC709: - colorSpaceMatrix = QMatrix4x4( - 1.164, 0.000, 1.793, -0.5727, - 1.164, -0.534, -0.213, 0.3007, - 1.164, 2.115, 0.000, -1.1302, - 0.0, 0.000, 0.000, 1.0000); - break; - default: //BT 601: - colorSpaceMatrix = QMatrix4x4( - 1.164, 0.000, 1.596, -0.8708, - 1.164, -0.392, -0.813, 0.5296, - 1.164, 2.017, 0.000, -1.081, - 0.0, 0.000, 0.000, 1.0000); - } - - m_colorMatrix = m_colorMatrix * colorSpaceMatrix; - } -} - -void QVideoSurfaceGLPainter::initRgbTextureInfo( - GLenum internalFormat, GLuint format, GLenum type, const QSize &size) -{ - m_yuv = false; - m_textureInternalFormat = internalFormat; - m_textureFormat = format; - m_textureType = type; - m_textureCount = 1; - m_textureWidths[0] = size.width(); - m_textureHeights[0] = size.height(); - m_textureOffsets[0] = 0; -} - -void QVideoSurfaceGLPainter::initYuv420PTextureInfo(const QSize &size) -{ - int bytesPerLine = (size.width() + 3) & ~3; - int bytesPerLine2 = (size.width() / 2 + 3) & ~3; - - m_yuv = true; - m_textureInternalFormat = GL_LUMINANCE; - m_textureFormat = GL_LUMINANCE; - m_textureType = GL_UNSIGNED_BYTE; - m_textureCount = 3; - m_textureWidths[0] = bytesPerLine; - m_textureHeights[0] = size.height(); - m_textureOffsets[0] = 0; - m_textureWidths[1] = bytesPerLine2; - m_textureHeights[1] = size.height() / 2; - m_textureOffsets[1] = bytesPerLine * size.height(); - m_textureWidths[2] = bytesPerLine2; - m_textureHeights[2] = size.height() / 2; - m_textureOffsets[2] = bytesPerLine * size.height() + bytesPerLine2 * size.height()/2; -} - -void QVideoSurfaceGLPainter::initYv12TextureInfo(const QSize &size) -{ - int bytesPerLine = (size.width() + 3) & ~3; - int bytesPerLine2 = (size.width() / 2 + 3) & ~3; - - m_yuv = true; - m_textureInternalFormat = GL_LUMINANCE; - m_textureFormat = GL_LUMINANCE; - m_textureType = GL_UNSIGNED_BYTE; - m_textureCount = 3; - m_textureWidths[0] = bytesPerLine; - m_textureHeights[0] = size.height(); - m_textureOffsets[0] = 0; - m_textureWidths[1] = bytesPerLine2; - m_textureHeights[1] = size.height() / 2; - m_textureOffsets[1] = bytesPerLine * size.height() + bytesPerLine2 * size.height()/2; - m_textureWidths[2] = bytesPerLine2; - m_textureHeights[2] = size.height() / 2; - m_textureOffsets[2] = bytesPerLine * size.height(); -} - -#ifndef QT_OPENGL_ES - -# ifndef GL_FRAGMENT_PROGRAM_ARB -# define GL_FRAGMENT_PROGRAM_ARB 0x8804 -# define GL_PROGRAM_FORMAT_ASCII_ARB 0x8875 -# endif - -// Paints an RGB32 frame -static const char *qt_arbfp_xrgbShaderProgram = - "!!ARBfp1.0\n" - "PARAM matrix[4] = { program.local[0..2]," - "{ 0.0, 0.0, 0.0, 1.0 } };\n" - "TEMP xrgb;\n" - "TEX xrgb.xyz, fragment.texcoord[0], texture[0], 2D;\n" - "MOV xrgb.w, matrix[3].w;\n" - "DP4 result.color.x, xrgb.zyxw, matrix[0];\n" - "DP4 result.color.y, xrgb.zyxw, matrix[1];\n" - "DP4 result.color.z, xrgb.zyxw, matrix[2];\n" - "END"; - -// Paints an ARGB frame. -static const char *qt_arbfp_argbShaderProgram = - "!!ARBfp1.0\n" - "PARAM matrix[4] = { program.local[0..2]," - "{ 0.0, 0.0, 0.0, 1.0 } };\n" - "TEMP argb;\n" - "TEX argb, fragment.texcoord[0], texture[0], 2D;\n" - "MOV argb.w, matrix[3].w;\n" - "DP4 result.color.x, argb.zyxw, matrix[0];\n" - "DP4 result.color.y, argb.zyxw, matrix[1];\n" - "DP4 result.color.z, argb.zyxw, matrix[2];\n" - "TEX result.color.w, fragment.texcoord[0], texture, 2D;\n" - "END"; - -// Paints an RGB(A) frame. -static const char *qt_arbfp_rgbShaderProgram = - "!!ARBfp1.0\n" - "PARAM matrix[4] = { program.local[0..2]," - "{ 0.0, 0.0, 0.0, 1.0 } };\n" - "TEMP rgb;\n" - "TEX rgb, fragment.texcoord[0], texture[0], 2D;\n" - "MOV rgb.w, matrix[3].w;\n" - "DP4 result.color.x, rgb, matrix[0];\n" - "DP4 result.color.y, rgb, matrix[1];\n" - "DP4 result.color.z, rgb, matrix[2];\n" - "TEX result.color.w, fragment.texcoord[0], texture, 2D;\n" - "END"; - -// Paints a YUV420P or YV12 frame. -static const char *qt_arbfp_yuvPlanarShaderProgram = - "!!ARBfp1.0\n" - "PARAM matrix[4] = { program.local[0..2]," - "{ 0.0, 0.0, 0.0, 1.0 } };\n" - "TEMP yuv;\n" - "TEX yuv.x, fragment.texcoord[0], texture[0], 2D;\n" - "TEX yuv.y, fragment.texcoord[0], texture[1], 2D;\n" - "TEX yuv.z, fragment.texcoord[0], texture[2], 2D;\n" - "MOV yuv.w, matrix[3].w;\n" - "DP4 result.color.x, yuv, matrix[0];\n" - "DP4 result.color.y, yuv, matrix[1];\n" - "DP4 result.color.z, yuv, matrix[2];\n" - "END"; - -// Paints a YUV444 frame. -static const char *qt_arbfp_xyuvShaderProgram = - "!!ARBfp1.0\n" - "PARAM matrix[4] = { program.local[0..2]," - "{ 0.0, 0.0, 0.0, 1.0 } };\n" - "TEMP ayuv;\n" - "TEX ayuv, fragment.texcoord[0], texture[0], 2D;\n" - "MOV ayuv.x, matrix[3].w;\n" - "DP4 result.color.x, ayuv.yzwx, matrix[0];\n" - "DP4 result.color.y, ayuv.yzwx, matrix[1];\n" - "DP4 result.color.z, ayuv.yzwx, matrix[2];\n" - "END"; - -// Paints a AYUV444 frame. -static const char *qt_arbfp_ayuvShaderProgram = - "!!ARBfp1.0\n" - "PARAM matrix[4] = { program.local[0..2]," - "{ 0.0, 0.0, 0.0, 1.0 } };\n" - "TEMP ayuv;\n" - "TEX ayuv, fragment.texcoord[0], texture[0], 2D;\n" - "MOV ayuv.x, matrix[3].w;\n" - "DP4 result.color.x, ayuv.yzwx, matrix[0];\n" - "DP4 result.color.y, ayuv.yzwx, matrix[1];\n" - "DP4 result.color.z, ayuv.yzwx, matrix[2];\n" - "TEX result.color.w, fragment.texcoord[0], texture, 2D;\n" - "END"; - -class QVideoSurfaceArbFpPainter : public QVideoSurfaceGLPainter -{ -public: - QVideoSurfaceArbFpPainter(QGLContext *context); - - QAbstractVideoSurface::Error start(const QVideoSurfaceFormat &format); - void stop(); - - QAbstractVideoSurface::Error paint( - const QRectF &target, QPainter *painter, const QRectF &source); - -private: - typedef void (APIENTRY *_glProgramStringARB) (GLenum, GLenum, GLsizei, const GLvoid *); - typedef void (APIENTRY *_glBindProgramARB) (GLenum, GLuint); - typedef void (APIENTRY *_glDeleteProgramsARB) (GLsizei, const GLuint *); - typedef void (APIENTRY *_glGenProgramsARB) (GLsizei, GLuint *); - typedef void (APIENTRY *_glProgramLocalParameter4fARB) ( - GLenum, GLuint, GLfloat, GLfloat, GLfloat, GLfloat); - typedef void (APIENTRY *_glActiveTexture) (GLenum); - - _glProgramStringARB glProgramStringARB; - _glBindProgramARB glBindProgramARB; - _glDeleteProgramsARB glDeleteProgramsARB; - _glGenProgramsARB glGenProgramsARB; - _glProgramLocalParameter4fARB glProgramLocalParameter4fARB; - - GLuint m_programId; - QSize m_frameSize; -}; - -QVideoSurfaceArbFpPainter::QVideoSurfaceArbFpPainter(QGLContext *context) - : QVideoSurfaceGLPainter(context) - , m_programId(0) -{ - glProgramStringARB = (_glProgramStringARB) m_context->getProcAddress( - QLatin1String("glProgramStringARB")); - glBindProgramARB = (_glBindProgramARB) m_context->getProcAddress( - QLatin1String("glBindProgramARB")); - glDeleteProgramsARB = (_glDeleteProgramsARB) m_context->getProcAddress( - QLatin1String("glDeleteProgramsARB")); - glGenProgramsARB = (_glGenProgramsARB) m_context->getProcAddress( - QLatin1String("glGenProgramsARB")); - glProgramLocalParameter4fARB = (_glProgramLocalParameter4fARB) m_context->getProcAddress( - QLatin1String("glProgramLocalParameter4fARB")); - - m_imagePixelFormats - << QVideoFrame::Format_RGB32 - << QVideoFrame::Format_BGR32 - << QVideoFrame::Format_ARGB32 - << QVideoFrame::Format_RGB24 - << QVideoFrame::Format_BGR24 - << QVideoFrame::Format_RGB565 - << QVideoFrame::Format_AYUV444 - << QVideoFrame::Format_YUV444 - << QVideoFrame::Format_YV12 - << QVideoFrame::Format_YUV420P; - m_glPixelFormats - << QVideoFrame::Format_RGB32 - << QVideoFrame::Format_ARGB32; -} - -QAbstractVideoSurface::Error QVideoSurfaceArbFpPainter::start(const QVideoSurfaceFormat &format) -{ - Q_ASSERT(m_textureCount == 0); - - QAbstractVideoSurface::Error error = QAbstractVideoSurface::NoError; - - m_context->makeCurrent(); - - const char *program = 0; - - if (format.handleType() == QAbstractVideoBuffer::NoHandle) { - switch (format.pixelFormat()) { - case QVideoFrame::Format_RGB32: - initRgbTextureInfo(GL_RGBA, GL_RGBA, GL_UNSIGNED_BYTE, format.frameSize()); - program = qt_arbfp_xrgbShaderProgram; - break; - case QVideoFrame::Format_BGR32: - initRgbTextureInfo(GL_RGBA, GL_RGBA, GL_UNSIGNED_BYTE, format.frameSize()); - program = qt_arbfp_rgbShaderProgram; - break; - case QVideoFrame::Format_ARGB32: - initRgbTextureInfo(GL_RGBA, GL_RGBA, GL_UNSIGNED_BYTE, format.frameSize()); - program = qt_arbfp_argbShaderProgram; - break; - case QVideoFrame::Format_RGB24: - initRgbTextureInfo(GL_RGB8, GL_RGBA, GL_UNSIGNED_BYTE, format.frameSize()); - program = qt_arbfp_rgbShaderProgram; - break; - case QVideoFrame::Format_BGR24: - initRgbTextureInfo(GL_RGB8, GL_RGBA, GL_UNSIGNED_BYTE, format.frameSize()); - program = qt_arbfp_xrgbShaderProgram; - break; - case QVideoFrame::Format_RGB565: - initRgbTextureInfo(GL_RGB, GL_RGB, GL_UNSIGNED_SHORT_5_6_5, format.frameSize()); - program = qt_arbfp_rgbShaderProgram; - break; - case QVideoFrame::Format_YUV444: - initRgbTextureInfo(GL_RGB, GL_RGB, GL_UNSIGNED_BYTE, format.frameSize()); - program = qt_arbfp_xyuvShaderProgram; - m_yuv = true; - break; - case QVideoFrame::Format_AYUV444: - initRgbTextureInfo(GL_RGBA, GL_RGBA, GL_UNSIGNED_BYTE, format.frameSize()); - program = qt_arbfp_ayuvShaderProgram; - m_yuv = true; - break; - case QVideoFrame::Format_YV12: - initYv12TextureInfo(format.frameSize()); - program = qt_arbfp_yuvPlanarShaderProgram; - break; - case QVideoFrame::Format_YUV420P: - initYuv420PTextureInfo(format.frameSize()); - program = qt_arbfp_yuvPlanarShaderProgram; - break; - default: - break; - } - } else if (format.handleType() == QAbstractVideoBuffer::GLTextureHandle) { - switch (format.pixelFormat()) { - case QVideoFrame::Format_RGB32: - case QVideoFrame::Format_ARGB32: - m_yuv = false; - m_textureCount = 1; - program = qt_arbfp_rgbShaderProgram; - break; - default: - break; - } - } else if (format.handleType() == QAbstractVideoBuffer::QPixmapHandle) { - m_handleType = QAbstractVideoBuffer::QPixmapHandle; - return QAbstractVideoSurface::NoError; - } - - if (!program) { - error = QAbstractVideoSurface::UnsupportedFormatError; - } else { - glGenProgramsARB(1, &m_programId); - - GLenum glError = glGetError(); - if (glError != GL_NO_ERROR) { - qWarning("QPainterVideoSurface: ARBfb Shader allocation error %x", int(glError)); - m_textureCount = 0; - m_programId = 0; - - error = QAbstractVideoSurface::ResourceError; - } else { - glBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, m_programId); - glProgramStringARB( - GL_FRAGMENT_PROGRAM_ARB, - GL_PROGRAM_FORMAT_ASCII_ARB, - qstrlen(program), - reinterpret_cast(program)); - - if ((glError = glGetError()) != GL_NO_ERROR) { - const GLubyte* errorString = glGetString(GL_PROGRAM_ERROR_STRING_ARB); - - qWarning("QPainterVideoSurface: ARBfp Shader compile error %x, %s", - int(glError), - reinterpret_cast(errorString)); - glDeleteProgramsARB(1, &m_programId); - - m_textureCount = 0; - m_programId = 0; - - error = QAbstractVideoSurface::ResourceError; - } else { - m_handleType = format.handleType(); - m_scanLineDirection = format.scanLineDirection(); - m_frameSize = format.frameSize(); - m_colorSpace = format.yCbCrColorSpace(); - - if (m_handleType == QAbstractVideoBuffer::NoHandle) - glGenTextures(m_textureCount, m_textureIds); - } - } - } - - return error; -} - -void QVideoSurfaceArbFpPainter::stop() -{ - if (m_context) { - m_context->makeCurrent(); - - if (m_handleType != QAbstractVideoBuffer::GLTextureHandle) - glDeleteTextures(m_textureCount, m_textureIds); - glDeleteProgramsARB(1, &m_programId); - } - - m_textureCount = 0; - m_programId = 0; - m_handleType = QAbstractVideoBuffer::NoHandle; -} - -QAbstractVideoSurface::Error QVideoSurfaceArbFpPainter::paint( - const QRectF &target, QPainter *painter, const QRectF &source) -{ - if (!m_frame.isValid()) { - painter->fillRect(target, Qt::black); - return QAbstractVideoSurface::NoError; - } - - const QAbstractVideoBuffer::HandleType h = m_frame.handleType(); - if (h == QAbstractVideoBuffer::NoHandle || h == QAbstractVideoBuffer::GLTextureHandle) { - bool stencilTestEnabled = glIsEnabled(GL_STENCIL_TEST); - bool scissorTestEnabled = glIsEnabled(GL_SCISSOR_TEST); - - painter->beginNativePainting(); - - if (stencilTestEnabled) - glEnable(GL_STENCIL_TEST); - if (scissorTestEnabled) - glEnable(GL_SCISSOR_TEST); - - const float txLeft = source.left() / m_frameSize.width(); - const float txRight = source.right() / m_frameSize.width(); - const float txTop = m_scanLineDirection == QVideoSurfaceFormat::TopToBottom - ? source.top() / m_frameSize.height() - : source.bottom() / m_frameSize.height(); - const float txBottom = m_scanLineDirection == QVideoSurfaceFormat::TopToBottom - ? source.bottom() / m_frameSize.height() - : source.top() / m_frameSize.height(); - - const float tx_array[] = - { - txLeft , txBottom, - txRight, txBottom, - txLeft , txTop, - txRight, txTop - }; - - const GLfloat vTop = m_scanLineDirection == QVideoSurfaceFormat::TopToBottom - ? target.top() - : target.bottom() + 1; - const GLfloat vBottom = m_scanLineDirection == QVideoSurfaceFormat::TopToBottom - ? target.bottom() + 1 - : target.top(); - - const GLfloat v_array[] = - { - GLfloat(target.left()) , GLfloat(vBottom), - GLfloat(target.right() + 1), GLfloat(vBottom), - GLfloat(target.left()) , GLfloat(vTop), - GLfloat(target.right() + 1), GLfloat(vTop) - }; - - glEnable(GL_FRAGMENT_PROGRAM_ARB); - glBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, m_programId); - - glProgramLocalParameter4fARB( - GL_FRAGMENT_PROGRAM_ARB, - 0, - m_colorMatrix(0, 0), - m_colorMatrix(0, 1), - m_colorMatrix(0, 2), - m_colorMatrix(0, 3)); - glProgramLocalParameter4fARB( - GL_FRAGMENT_PROGRAM_ARB, - 1, - m_colorMatrix(1, 0), - m_colorMatrix(1, 1), - m_colorMatrix(1, 2), - m_colorMatrix(1, 3)); - glProgramLocalParameter4fARB( - GL_FRAGMENT_PROGRAM_ARB, - 2, - m_colorMatrix(2, 0), - m_colorMatrix(2, 1), - m_colorMatrix(2, 2), - m_colorMatrix(2, 3)); - - glActiveTexture(GL_TEXTURE0); - glBindTexture(GL_TEXTURE_2D, m_textureIds[0]); - - if (m_textureCount == 3) { - glActiveTexture(GL_TEXTURE1); - glBindTexture(GL_TEXTURE_2D, m_textureIds[1]); - glActiveTexture(GL_TEXTURE2); - glBindTexture(GL_TEXTURE_2D, m_textureIds[2]); - glActiveTexture(GL_TEXTURE0); - } - - glVertexPointer(2, GL_FLOAT, 0, v_array); - glTexCoordPointer(2, GL_FLOAT, 0, tx_array); - - glEnableClientState(GL_VERTEX_ARRAY); - glEnableClientState(GL_TEXTURE_COORD_ARRAY); - - glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); - - glDisableClientState(GL_TEXTURE_COORD_ARRAY); - glDisableClientState(GL_VERTEX_ARRAY); - glDisable(GL_FRAGMENT_PROGRAM_ARB); - - painter->endNativePainting(); - - return QAbstractVideoSurface::NoError; - } - - return QVideoSurfaceGLPainter::paint(target, painter, source); -} - -#endif - -static const char *qt_glsl_vertexShaderProgram = - "attribute highp vec4 vertexCoordArray;\n" - "attribute highp vec2 textureCoordArray;\n" - "uniform highp mat4 positionMatrix;\n" - "varying highp vec2 textureCoord;\n" - "void main(void)\n" - "{\n" - " gl_Position = positionMatrix * vertexCoordArray;\n" - " textureCoord = textureCoordArray;\n" - "}\n"; - -// Paints an RGB32 frame -static const char *qt_glsl_xrgbShaderProgram = - "uniform sampler2D texRgb;\n" - "uniform mediump mat4 colorMatrix;\n" - "varying highp vec2 textureCoord;\n" - "void main(void)\n" - "{\n" - " highp vec4 color = vec4(texture2D(texRgb, textureCoord.st).bgr, 1.0);\n" - " gl_FragColor = colorMatrix * color;\n" - "}\n"; - -// Paints an ARGB frame. -static const char *qt_glsl_argbShaderProgram = - "uniform sampler2D texRgb;\n" - "uniform mediump mat4 colorMatrix;\n" - "varying highp vec2 textureCoord;\n" - "void main(void)\n" - "{\n" - " highp vec4 color = vec4(texture2D(texRgb, textureCoord.st).bgr, 1.0);\n" - " color = colorMatrix * color;\n" - " gl_FragColor = vec4(color.rgb, texture2D(texRgb, textureCoord.st).a);\n" - "}\n"; - -// Paints an RGB(A) frame. -static const char *qt_glsl_rgbShaderProgram = - "uniform sampler2D texRgb;\n" - "uniform mediump mat4 colorMatrix;\n" - "varying highp vec2 textureCoord;\n" - "void main(void)\n" - "{\n" - " highp vec4 color = vec4(texture2D(texRgb, textureCoord.st).rgb, 1.0);\n" - " color = colorMatrix * color;\n" - " gl_FragColor = vec4(color.rgb, texture2D(texRgb, textureCoord.st).a);\n" - "}\n"; - -// Paints a YUV420P or YV12 frame. -static const char *qt_glsl_yuvPlanarShaderProgram = - "uniform sampler2D texY;\n" - "uniform sampler2D texU;\n" - "uniform sampler2D texV;\n" - "uniform mediump mat4 colorMatrix;\n" - "varying highp vec2 textureCoord;\n" - "void main(void)\n" - "{\n" - " highp vec4 color = vec4(\n" - " texture2D(texY, textureCoord.st).r,\n" - " texture2D(texU, textureCoord.st).r,\n" - " texture2D(texV, textureCoord.st).r,\n" - " 1.0);\n" - " gl_FragColor = colorMatrix * color;\n" - "}\n"; - -// Paints a YUV444 frame. -static const char *qt_glsl_xyuvShaderProgram = - "uniform sampler2D texRgb;\n" - "uniform mediump mat4 colorMatrix;\n" - "varying highp vec2 textureCoord;\n" - "void main(void)\n" - "{\n" - " highp vec4 color = vec4(texture2D(texRgb, textureCoord.st).gba, 1.0);\n" - " gl_FragColor = colorMatrix * color;\n" - "}\n"; - -// Paints a AYUV444 frame. -static const char *qt_glsl_ayuvShaderProgram = - "uniform sampler2D texRgb;\n" - "uniform mediump mat4 colorMatrix;\n" - "varying highp vec2 textureCoord;\n" - "void main(void)\n" - "{\n" - " highp vec4 color = vec4(texture2D(texRgb, textureCoord.st).gba, 1.0);\n" - " color = colorMatrix * color;\n" - " gl_FragColor = vec4(color.rgb, texture2D(texRgb, textureCoord.st).r);\n" - "}\n"; - -class QVideoSurfaceGlslPainter : public QVideoSurfaceGLPainter -{ -public: - QVideoSurfaceGlslPainter(QGLContext *context); - - QAbstractVideoSurface::Error start(const QVideoSurfaceFormat &format); - void stop(); - - QAbstractVideoSurface::Error paint( - const QRectF &target, QPainter *painter, const QRectF &source); - -private: - QGLShaderProgram m_program; - QSize m_frameSize; -}; - -QVideoSurfaceGlslPainter::QVideoSurfaceGlslPainter(QGLContext *context) - : QVideoSurfaceGLPainter(context) - , m_program(context) -{ - m_imagePixelFormats - << QVideoFrame::Format_RGB32 - << QVideoFrame::Format_BGR32 - << QVideoFrame::Format_ARGB32 -#ifndef QT_OPENGL_ES - << QVideoFrame::Format_RGB24 - << QVideoFrame::Format_BGR24 -#endif - << QVideoFrame::Format_RGB565 - << QVideoFrame::Format_YUV444 - << QVideoFrame::Format_AYUV444 - << QVideoFrame::Format_YV12 - << QVideoFrame::Format_YUV420P; - m_glPixelFormats - << QVideoFrame::Format_RGB32 - << QVideoFrame::Format_ARGB32; -} - -QAbstractVideoSurface::Error QVideoSurfaceGlslPainter::start(const QVideoSurfaceFormat &format) -{ - Q_ASSERT(m_textureCount == 0); - - QAbstractVideoSurface::Error error = QAbstractVideoSurface::NoError; - - m_context->makeCurrent(); - - const char *fragmentProgram = 0; - - if (format.handleType() == QAbstractVideoBuffer::NoHandle) { - switch (format.pixelFormat()) { - case QVideoFrame::Format_RGB32: - initRgbTextureInfo(GL_RGBA, GL_RGBA, GL_UNSIGNED_BYTE, format.frameSize()); - fragmentProgram = qt_glsl_xrgbShaderProgram; - break; - case QVideoFrame::Format_BGR32: - initRgbTextureInfo(GL_RGB, GL_RGBA, GL_UNSIGNED_BYTE, format.frameSize()); - fragmentProgram = qt_glsl_rgbShaderProgram; - break; - case QVideoFrame::Format_ARGB32: - initRgbTextureInfo(GL_RGBA, GL_RGBA, GL_UNSIGNED_BYTE, format.frameSize()); - fragmentProgram = qt_glsl_argbShaderProgram; - break; -#ifndef QT_OPENGL_ES - case QVideoFrame::Format_RGB24: - initRgbTextureInfo(GL_RGB8, GL_RGB, GL_UNSIGNED_BYTE, format.frameSize()); - fragmentProgram = qt_glsl_rgbShaderProgram; - break; - case QVideoFrame::Format_BGR24: - initRgbTextureInfo(GL_RGB8, GL_RGB, GL_UNSIGNED_BYTE, format.frameSize()); - fragmentProgram = qt_glsl_argbShaderProgram; - break; -#endif - case QVideoFrame::Format_RGB565: - initRgbTextureInfo(GL_RGB, GL_RGB, GL_UNSIGNED_SHORT_5_6_5, format.frameSize()); - fragmentProgram = qt_glsl_rgbShaderProgram; - break; - case QVideoFrame::Format_YUV444: - initRgbTextureInfo(GL_RGB, GL_RGB, GL_UNSIGNED_BYTE, format.frameSize()); - fragmentProgram = qt_glsl_xyuvShaderProgram; - m_yuv = true; - break; - case QVideoFrame::Format_AYUV444: - initRgbTextureInfo(GL_RGBA, GL_RGBA, GL_UNSIGNED_BYTE, format.frameSize()); - fragmentProgram = qt_glsl_ayuvShaderProgram; - m_yuv = true; - break; - case QVideoFrame::Format_YV12: - initYv12TextureInfo(format.frameSize()); - fragmentProgram = qt_glsl_yuvPlanarShaderProgram; - break; - case QVideoFrame::Format_YUV420P: - initYuv420PTextureInfo(format.frameSize()); - fragmentProgram = qt_glsl_yuvPlanarShaderProgram; - break; - default: - break; - } - } else if (format.handleType() == QAbstractVideoBuffer::GLTextureHandle) { - switch (format.pixelFormat()) { - case QVideoFrame::Format_RGB32: - case QVideoFrame::Format_ARGB32: - m_yuv = false; - m_textureCount = 1; - fragmentProgram = qt_glsl_rgbShaderProgram; - break; - default: - break; - } - } else if (format.handleType() == QAbstractVideoBuffer::QPixmapHandle) { - m_handleType = QAbstractVideoBuffer::QPixmapHandle; - return QAbstractVideoSurface::NoError; - } - - if (!fragmentProgram) { - error = QAbstractVideoSurface::UnsupportedFormatError; - } else if (!m_program.addShaderFromSourceCode(QGLShader::Vertex, qt_glsl_vertexShaderProgram)) { - qWarning("QPainterVideoSurface: Vertex shader compile error %s", - qPrintable(m_program.log())); - error = QAbstractVideoSurface::ResourceError; - } else if (!m_program.addShaderFromSourceCode(QGLShader::Fragment, fragmentProgram)) { - qWarning("QPainterVideoSurface: Shader compile error %s", qPrintable(m_program.log())); - error = QAbstractVideoSurface::ResourceError; - m_program.removeAllShaders(); - } else if(!m_program.link()) { - qWarning("QPainterVideoSurface: Shader link error %s", qPrintable(m_program.log())); - m_program.removeAllShaders(); - error = QAbstractVideoSurface::ResourceError; - } else { - m_handleType = format.handleType(); - m_scanLineDirection = format.scanLineDirection(); - m_frameSize = format.frameSize(); - m_colorSpace = format.yCbCrColorSpace(); - - if (m_handleType == QAbstractVideoBuffer::NoHandle) - glGenTextures(m_textureCount, m_textureIds); - } - - return error; -} - -void QVideoSurfaceGlslPainter::stop() -{ - if (m_context) { - m_context->makeCurrent(); - - if (m_handleType != QAbstractVideoBuffer::GLTextureHandle) - glDeleteTextures(m_textureCount, m_textureIds); - } - - m_program.removeAllShaders(); - - m_textureCount = 0; - m_handleType = QAbstractVideoBuffer::NoHandle; -} - -QAbstractVideoSurface::Error QVideoSurfaceGlslPainter::paint( - const QRectF &target, QPainter *painter, const QRectF &source) -{ - if (!m_frame.isValid()) { - painter->fillRect(target, Qt::black); - return QAbstractVideoSurface::NoError; - } - - const QAbstractVideoBuffer::HandleType h = m_frame.handleType(); - if (h == QAbstractVideoBuffer::NoHandle || h == QAbstractVideoBuffer::GLTextureHandle) { - bool stencilTestEnabled = glIsEnabled(GL_STENCIL_TEST); - bool scissorTestEnabled = glIsEnabled(GL_SCISSOR_TEST); - - painter->beginNativePainting(); - - if (stencilTestEnabled) - glEnable(GL_STENCIL_TEST); - if (scissorTestEnabled) - glEnable(GL_SCISSOR_TEST); - - const int width = QGLContext::currentContext()->device()->width(); - const int height = QGLContext::currentContext()->device()->height(); - - const QTransform transform = painter->deviceTransform(); - - const GLfloat wfactor = 2.0 / width; - const GLfloat hfactor = -2.0 / height; - - const GLfloat positionMatrix[4][4] = - { - { - /*(0,0)*/ GLfloat(wfactor * transform.m11() - transform.m13()), - /*(0,1)*/ GLfloat(hfactor * transform.m12() + transform.m13()), - /*(0,2)*/ 0.0, - /*(0,3)*/ GLfloat(transform.m13()) - }, { - /*(1,0)*/ GLfloat(wfactor * transform.m21() - transform.m23()), - /*(1,1)*/ GLfloat(hfactor * transform.m22() + transform.m23()), - /*(1,2)*/ 0.0, - /*(1,3)*/ GLfloat(transform.m23()) - }, { - /*(2,0)*/ 0.0, - /*(2,1)*/ 0.0, - /*(2,2)*/ -1.0, - /*(2,3)*/ 0.0 - }, { - /*(3,0)*/ GLfloat(wfactor * transform.dx() - transform.m33()), - /*(3,1)*/ GLfloat(hfactor * transform.dy() + transform.m33()), - /*(3,2)*/ 0.0, - /*(3,3)*/ GLfloat(transform.m33()) - } - }; - - const GLfloat vTop = m_scanLineDirection == QVideoSurfaceFormat::TopToBottom - ? target.top() - : target.bottom() + 1; - const GLfloat vBottom = m_scanLineDirection == QVideoSurfaceFormat::TopToBottom - ? target.bottom() + 1 - : target.top(); - - - const GLfloat vertexCoordArray[] = - { - GLfloat(target.left()) , GLfloat(vBottom), - GLfloat(target.right() + 1), GLfloat(vBottom), - GLfloat(target.left()) , GLfloat(vTop), - GLfloat(target.right() + 1), GLfloat(vTop) - }; - - const GLfloat txLeft = source.left() / m_frameSize.width(); - const GLfloat txRight = source.right() / m_frameSize.width(); - const GLfloat txTop = m_scanLineDirection == QVideoSurfaceFormat::TopToBottom - ? source.top() / m_frameSize.height() - : source.bottom() / m_frameSize.height(); - const GLfloat txBottom = m_scanLineDirection == QVideoSurfaceFormat::TopToBottom - ? source.bottom() / m_frameSize.height() - : source.top() / m_frameSize.height(); - - const GLfloat textureCoordArray[] = - { - txLeft , txBottom, - txRight, txBottom, - txLeft , txTop, - txRight, txTop - }; - - m_program.bind(); - - m_program.enableAttributeArray("vertexCoordArray"); - m_program.enableAttributeArray("textureCoordArray"); - m_program.setAttributeArray("vertexCoordArray", vertexCoordArray, 2); - m_program.setAttributeArray("textureCoordArray", textureCoordArray, 2); - m_program.setUniformValue("positionMatrix", positionMatrix); - - if (m_textureCount == 3) { - glActiveTexture(GL_TEXTURE0); - glBindTexture(GL_TEXTURE_2D, m_textureIds[0]); - glActiveTexture(GL_TEXTURE1); - glBindTexture(GL_TEXTURE_2D, m_textureIds[1]); - glActiveTexture(GL_TEXTURE2); - glBindTexture(GL_TEXTURE_2D, m_textureIds[2]); - glActiveTexture(GL_TEXTURE0); - - m_program.setUniformValue("texY", 0); - m_program.setUniformValue("texU", 1); - m_program.setUniformValue("texV", 2); - } else { - glActiveTexture(GL_TEXTURE0); - glBindTexture(GL_TEXTURE_2D, m_textureIds[0]); - - m_program.setUniformValue("texRgb", 0); - } - m_program.setUniformValue("colorMatrix", m_colorMatrix); - - glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); - - m_program.release(); - - painter->endNativePainting(); - - return QAbstractVideoSurface::NoError; - } - - return QVideoSurfaceGLPainter::paint(target, painter, source); -} - -#endif - -/*! - \class QPainterVideoSurface - \since 1.0 - \internal -*/ - -/*! -*/ -QPainterVideoSurface::QPainterVideoSurface(QObject *parent) - : QAbstractVideoSurface(parent) - , m_painter(0) -#if !defined(QT_NO_OPENGL) && !defined(QT_OPENGL_ES_1_CL) && !defined(QT_OPENGL_ES_1) - , m_glContext(0) - , m_shaderTypes(NoShaders) - , m_shaderType(NoShaders) -#endif - , m_brightness(0) - , m_contrast(0) - , m_hue(0) - , m_saturation(0) - , m_pixelFormat(QVideoFrame::Format_Invalid) - , m_colorsDirty(true) - , m_ready(false) -{ -} - -/*! -*/ -QPainterVideoSurface::~QPainterVideoSurface() -{ - if (isActive()) - m_painter->stop(); - - delete m_painter; -} - -/*! - \since 1.0 -*/ -QList QPainterVideoSurface::supportedPixelFormats( - QAbstractVideoBuffer::HandleType handleType) const -{ - if (!m_painter) - const_cast(this)->createPainter(); - - return m_painter->supportedPixelFormats(handleType); -} - -/*! - \since 1.0 -*/ -bool QPainterVideoSurface::isFormatSupported( - const QVideoSurfaceFormat &format, QVideoSurfaceFormat *similar) const -{ - if (!m_painter) - const_cast(this)->createPainter(); - - return m_painter->isFormatSupported(format, similar); -} - -/*! - \since 1.0 -*/ -bool QPainterVideoSurface::start(const QVideoSurfaceFormat &format) -{ - if (isActive()) - m_painter->stop(); - - if (!m_painter) - createPainter(); - - if (format.frameSize().isEmpty()) { - setError(UnsupportedFormatError); - } else { - QAbstractVideoSurface::Error error = m_painter->start(format); - - if (error != QAbstractVideoSurface::NoError) { - setError(error); - } else { - m_pixelFormat = format.pixelFormat(); - m_frameSize = format.frameSize(); - m_sourceRect = format.viewport(); - m_colorsDirty = true; - m_ready = true; - - return QAbstractVideoSurface::start(format); - } - } - - QAbstractVideoSurface::stop(); - - return false; -} - -/*! - \since 1.0 -*/ -void QPainterVideoSurface::stop() -{ - if (isActive()) { - m_painter->stop(); - m_ready = false; - - QAbstractVideoSurface::stop(); - } -} - -/*! - \since 1.0 -*/ -bool QPainterVideoSurface::present(const QVideoFrame &frame) -{ - if (!m_ready) { - if (!isActive()) - setError(StoppedError); - } else if (frame.isValid() - && (frame.pixelFormat() != m_pixelFormat || frame.size() != m_frameSize)) { - setError(IncorrectFormatError); - - stop(); - } else { - QAbstractVideoSurface::Error error = m_painter->setCurrentFrame(frame); - - if (error != QAbstractVideoSurface::NoError) { - setError(error); - - stop(); - } else { - m_ready = false; - - emit frameChanged(); - - return true; - } - } - return false; -} - -/*! - \since 1.0 -*/ -int QPainterVideoSurface::brightness() const -{ - return m_brightness; -} - -/*! - \since 1.0 -*/ -void QPainterVideoSurface::setBrightness(int brightness) -{ - m_brightness = brightness; - - m_colorsDirty = true; -} - -/*! - \since 1.0 -*/ -int QPainterVideoSurface::contrast() const -{ - return m_contrast; -} - -/*! - \since 1.0 -*/ -void QPainterVideoSurface::setContrast(int contrast) -{ - m_contrast = contrast; - - m_colorsDirty = true; -} - -/*! - \since 1.0 -*/ -int QPainterVideoSurface::hue() const -{ - return m_hue; -} - -/*! - \since 1.0 -*/ -void QPainterVideoSurface::setHue(int hue) -{ - m_hue = hue; - - m_colorsDirty = true; -} - -/*! - \since 1.0 -*/ -int QPainterVideoSurface::saturation() const -{ - return m_saturation; -} - -/*! - \since 1.0 -*/ -void QPainterVideoSurface::setSaturation(int saturation) -{ - m_saturation = saturation; - - m_colorsDirty = true; -} - -/*! - \since 1.0 -*/ -bool QPainterVideoSurface::isReady() const -{ - return m_ready; -} - -/*! - \since 1.0 -*/ -void QPainterVideoSurface::setReady(bool ready) -{ - m_ready = ready; -} - -/*! - \since 1.0 -*/ -void QPainterVideoSurface::paint(QPainter *painter, const QRectF &target, const QRectF &source) -{ - if (!isActive()) { - painter->fillRect(target, QBrush(Qt::black)); - } else { - if (m_colorsDirty) { - m_painter->updateColors(m_brightness, m_contrast, m_hue, m_saturation); - m_colorsDirty = false; - } - - const QRectF sourceRect( - m_sourceRect.x() + m_sourceRect.width() * source.x(), - m_sourceRect.y() + m_sourceRect.height() * source.y(), - m_sourceRect.width() * source.width(), - m_sourceRect.height() * source.height()); - - QAbstractVideoSurface::Error error = m_painter->paint(target, painter, sourceRect); - - if (error != QAbstractVideoSurface::NoError) { - setError(error); - - stop(); - } - } -} - -/*! - \fn QPainterVideoSurface::frameChanged() - \since 1.0 -*/ - -#if !defined(QT_NO_OPENGL) && !defined(QT_OPENGL_ES_1_CL) && !defined(QT_OPENGL_ES_1) - -/*! -*/ -const QGLContext *QPainterVideoSurface::glContext() const -{ - return m_glContext; -} - -/*! -*/ -void QPainterVideoSurface::setGLContext(QGLContext *context) -{ - if (m_glContext == context) - return; - - m_glContext = context; - - m_shaderTypes = NoShaders; - - if (m_glContext) { - m_glContext->makeCurrent(); - - const QByteArray extensions(reinterpret_cast(glGetString(GL_EXTENSIONS))); -#ifndef QT_OPENGL_ES - - if (extensions.contains("ARB_fragment_program")) - m_shaderTypes |= FragmentProgramShader; -#endif - if (QGLShaderProgram::hasOpenGLShaderPrograms(m_glContext) -#ifndef QT_OPENGL_ES_2 - && extensions.contains("ARB_shader_objects") -#endif - ) - m_shaderTypes |= GlslShader; - } - - ShaderType type = (m_shaderType & m_shaderTypes) - ? m_shaderType - : NoShaders; - - if (type != m_shaderType || type != NoShaders) { - m_shaderType = type; - - if (isActive()) { - m_painter->stop(); - delete m_painter; - m_painter = 0; - m_ready = false; - - setError(ResourceError); - QAbstractVideoSurface::stop(); - } - emit supportedFormatsChanged(); - } -} - -/*! - \enum QPainterVideoSurface::ShaderType - - \value NoShaders - \value FragmentProgramShader - \value HlslShader -*/ - -/*! - \typedef QPainterVideoSurface::ShaderTypes -*/ - -/*! - \since 1.0 -*/ -QPainterVideoSurface::ShaderTypes QPainterVideoSurface::supportedShaderTypes() const -{ - return m_shaderTypes; -} - -/*! - \since 1.0 -*/ -QPainterVideoSurface::ShaderType QPainterVideoSurface::shaderType() const -{ - return m_shaderType; -} - -/*! - \since 1.0 -*/ -void QPainterVideoSurface::setShaderType(ShaderType type) -{ - if (!(type & m_shaderTypes)) - type = NoShaders; - - if (type != m_shaderType) { - m_shaderType = type; - - if (isActive()) { - m_painter->stop(); - delete m_painter; - m_painter = 0; - m_ready = false; - - setError(ResourceError); - QAbstractVideoSurface::stop(); - } else { - delete m_painter; - m_painter = 0; - } - emit supportedFormatsChanged(); - } -} - -#endif - -void QPainterVideoSurface::viewportDestroyed() -{ - if (m_painter) { - m_painter->viewportDestroyed(); - - setError(ResourceError); - stop(); - delete m_painter; - m_painter = 0; - } -} - -void QPainterVideoSurface::createPainter() -{ - Q_ASSERT(!m_painter); - -#ifdef Q_WS_MAC - if (m_glContext) - m_glContext->makeCurrent(); - - m_painter = new QVideoSurfaceCoreGraphicsPainter(m_glContext != 0); - return; -#endif - -#if !defined(QT_NO_OPENGL) && !defined(QT_OPENGL_ES_1_CL) && !defined(QT_OPENGL_ES_1) - switch (m_shaderType) { -#ifndef QT_OPENGL_ES - case FragmentProgramShader: - Q_ASSERT(m_glContext); - m_glContext->makeCurrent(); - m_painter = new QVideoSurfaceArbFpPainter(m_glContext); - break; -#endif - case GlslShader: - Q_ASSERT(m_glContext); - m_glContext->makeCurrent(); - m_painter = new QVideoSurfaceGlslPainter(m_glContext); - break; - default: - m_painter = new QVideoSurfaceGenericPainter; - break; - } -#else - m_painter = new QVideoSurfaceGenericPainter; -#endif -} - -#include "moc_qpaintervideosurface_p.cpp" -QT_END_NAMESPACE - - diff --git a/src/multimediakitwidgets/qpaintervideosurface_mac.mm b/src/multimediakitwidgets/qpaintervideosurface_mac.mm deleted file mode 100644 index 02eabfe7d..000000000 --- a/src/multimediakitwidgets/qpaintervideosurface_mac.mm +++ /dev/null @@ -1,285 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include -#include -#include -#include - -#include "qpaintervideosurface_mac_p.h" - -#include - -#include - -#include -#include -#include - -#include - -QT_BEGIN_NAMESPACE - -extern CGContextRef qt_mac_cg_context(const QPaintDevice *pdev); //qpaintdevice_mac.cpp - -QVideoSurfaceCoreGraphicsPainter::QVideoSurfaceCoreGraphicsPainter(bool glSupported) - : ciContext(0) - , m_imageFormat(QImage::Format_Invalid) - , m_scanLineDirection(QVideoSurfaceFormat::TopToBottom) -{ - //qDebug() << "QVideoSurfaceCoreGraphicsPainter, GL supported:" << glSupported; - ciContext = 0; - m_imagePixelFormats - << QVideoFrame::Format_RGB32 - << QVideoFrame::Format_ARGB32 - << QVideoFrame::Format_ARGB32_Premultiplied - << QVideoFrame::Format_RGB24 - << QVideoFrame::Format_RGB565 - << QVideoFrame::Format_RGB555 - << QVideoFrame::Format_ARGB8565_Premultiplied; - - m_supportedHandles - << QAbstractVideoBuffer::NoHandle - << QAbstractVideoBuffer::CoreImageHandle; - - if (glSupported) - m_supportedHandles << QAbstractVideoBuffer::GLTextureHandle; -} - -QVideoSurfaceCoreGraphicsPainter::~QVideoSurfaceCoreGraphicsPainter() -{ - [(CIContext*)ciContext release]; -} - -QList QVideoSurfaceCoreGraphicsPainter::supportedPixelFormats( - QAbstractVideoBuffer::HandleType handleType) const -{ - return m_supportedHandles.contains(handleType) - ? m_imagePixelFormats - : QList(); -} - -bool QVideoSurfaceCoreGraphicsPainter::isFormatSupported( - const QVideoSurfaceFormat &format, QVideoSurfaceFormat *) const -{ - return m_supportedHandles.contains(format.handleType()) - && m_imagePixelFormats.contains(format.pixelFormat()) - && !format.frameSize().isEmpty(); -} - -QAbstractVideoSurface::Error QVideoSurfaceCoreGraphicsPainter::start(const QVideoSurfaceFormat &format) -{ - m_frame = QVideoFrame(); - m_imageFormat = QVideoFrame::imageFormatFromPixelFormat(format.pixelFormat()); - m_imageSize = format.frameSize(); - m_scanLineDirection = format.scanLineDirection(); - - return m_supportedHandles.contains(format.handleType()) - && m_imageFormat != QImage::Format_Invalid - && !m_imageSize.isEmpty() - ? QAbstractVideoSurface::NoError - : QAbstractVideoSurface::UnsupportedFormatError; -} - -void QVideoSurfaceCoreGraphicsPainter::stop() -{ - m_frame = QVideoFrame(); -} - -QAbstractVideoSurface::Error QVideoSurfaceCoreGraphicsPainter::setCurrentFrame(const QVideoFrame &frame) -{ - m_frame = frame; - - return QAbstractVideoSurface::NoError; -} - -QAbstractVideoSurface::Error QVideoSurfaceCoreGraphicsPainter::paint( - const QRectF &target, QPainter *painter, const QRectF &source) -{ - if (m_frame.handleType() == QAbstractVideoBuffer::CoreImageHandle) { - if (painter->paintEngine()->type() == QPaintEngine::CoreGraphics ) { - - CIImage *img = (CIImage*)(m_frame.handle().value()); - - if (img) { - CGContextRef cgContext = qt_mac_cg_context(painter->device()); - - if (cgContext) { - painter->beginNativePainting(); - - CGRect sRect = CGRectMake(source.x(), source.y(), source.width(), source.height()); - CGRect dRect = CGRectMake(target.x(), target.y(), target.width(), target.height()); - - NSBitmapImageRep *bitmap = [[NSBitmapImageRep alloc] initWithCIImage:img]; - - if (m_scanLineDirection == QVideoSurfaceFormat::TopToBottom) { - CGContextSaveGState( cgContext ); - CGContextTranslateCTM(cgContext, 0, dRect.origin.y + CGRectGetMaxY(dRect)); - CGContextScaleCTM(cgContext, 1, -1); - - CGContextDrawImage(cgContext, dRect, [bitmap CGImage]); - - CGContextRestoreGState(cgContext); - } else { - CGContextDrawImage(cgContext, dRect, [bitmap CGImage]); - } - - [bitmap release]; - - painter->endNativePainting(); - - return QAbstractVideoSurface::NoError; - } - } - } else if (painter->paintEngine()->type() == QPaintEngine::OpenGL2 || - painter->paintEngine()->type() == QPaintEngine::OpenGL) { - CIImage *img = (CIImage*)(m_frame.handle().value()); - - if (img) { - CGLContextObj cglContext = CGLGetCurrentContext(); - - if (cglContext) { - - if (!ciContext) { - CGLContextObj cglContext = CGLGetCurrentContext(); - NSOpenGLPixelFormat *nsglPixelFormat = [NSOpenGLView defaultPixelFormat]; - CGLPixelFormatObj cglPixelFormat = static_cast([nsglPixelFormat CGLPixelFormatObj]); - - ciContext = [CIContext contextWithCGLContext:cglContext - pixelFormat:cglPixelFormat - options:nil]; - - [(CIContext*)ciContext retain]; - } - - CGRect sRect = CGRectMake(source.x(), source.y(), source.width(), source.height()); - CGRect dRect = m_scanLineDirection == QVideoSurfaceFormat::TopToBottom ? - CGRectMake(target.x(), target.y()+target.height(), target.width(), -target.height()) : - CGRectMake(target.x(), target.y(), target.width(), target.height()); - - - painter->beginNativePainting(); - - [(CIContext*)ciContext drawImage:img inRect:dRect fromRect:sRect]; - - painter->endNativePainting(); - - return QAbstractVideoSurface::NoError; - } - } - } - } - - if (m_frame.handleType() == QAbstractVideoBuffer::GLTextureHandle && - (painter->paintEngine()->type() == QPaintEngine::OpenGL2 || - painter->paintEngine()->type() == QPaintEngine::OpenGL)) { - - painter->beginNativePainting(); - GLuint texture = m_frame.handle().toUInt(); - - glDisable(GL_CULL_FACE); - glEnable(GL_TEXTURE_2D); - - glBindTexture(GL_TEXTURE_2D, texture); - glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); - glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); - - const float txLeft = source.left() / m_frame.width(); - const float txRight = source.right() / m_frame.width(); - const float txTop = m_scanLineDirection == QVideoSurfaceFormat::TopToBottom - ? source.top() / m_frame.height() - : source.bottom() / m_frame.height(); - const float txBottom = m_scanLineDirection == QVideoSurfaceFormat::TopToBottom - ? source.bottom() / m_frame.height() - : source.top() / m_frame.height(); - - glBegin(GL_QUADS); - QRectF rect = target; - glTexCoord2f(txLeft, txBottom); - glVertex2f(rect.topLeft().x(), rect.topLeft().y()); - glTexCoord2f(txRight, txBottom); - glVertex2f(rect.topRight().x() + 1, rect.topRight().y()); - glTexCoord2f(txRight, txTop); - glVertex2f(rect.bottomRight().x() + 1, rect.bottomRight().y() + 1); - glTexCoord2f(txLeft, txTop); - glVertex2f(rect.bottomLeft().x(), rect.bottomLeft().y() + 1); - glEnd(); - painter->endNativePainting(); - - return QAbstractVideoSurface::NoError; - } - - //fallback case, software rendering - if (m_frame.map(QAbstractVideoBuffer::ReadOnly)) { - QImage image( - m_frame.bits(), - m_imageSize.width(), - m_imageSize.height(), - m_frame.bytesPerLine(), - m_imageFormat); - - if (m_scanLineDirection == QVideoSurfaceFormat::BottomToTop) { - const QTransform oldTransform = painter->transform(); - - painter->scale(1, -1); - painter->translate(0, -target.bottom()); - painter->drawImage( - QRectF(target.x(), 0, target.width(), target.height()), image, source); - painter->setTransform(oldTransform); - } else { - painter->drawImage(target, image, source); - } - - m_frame.unmap(); - } else if (m_frame.isValid()) { - return QAbstractVideoSurface::IncorrectFormatError; - } else { - painter->fillRect(target, Qt::black); - } - - return QAbstractVideoSurface::NoError; -} - -void QVideoSurfaceCoreGraphicsPainter::updateColors(int, int, int, int) -{ -} - -QT_END_NAMESPACE diff --git a/src/multimediakitwidgets/qpaintervideosurface_mac_p.h b/src/multimediakitwidgets/qpaintervideosurface_mac_p.h deleted file mode 100644 index d650d9ad7..000000000 --- a/src/multimediakitwidgets/qpaintervideosurface_mac_p.h +++ /dev/null @@ -1,103 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QPAINTERVIDEOSURFACE_MAC_P_H -#define QPAINTERVIDEOSURFACE_MAC_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 "qpaintervideosurface_p.h" -#include -#include - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -QT_MODULE(Multimedia) - - -class QVideoSurfaceCoreGraphicsPainter : public QVideoSurfacePainter -{ -public: - QVideoSurfaceCoreGraphicsPainter(bool glSupported); - ~QVideoSurfaceCoreGraphicsPainter(); - - QList supportedPixelFormats( - QAbstractVideoBuffer::HandleType handleType) const; - - bool isFormatSupported( - const QVideoSurfaceFormat &format, QVideoSurfaceFormat *similar) const; - - QAbstractVideoSurface::Error start(const QVideoSurfaceFormat &format); - void stop(); - - QAbstractVideoSurface::Error setCurrentFrame(const QVideoFrame &frame); - - QAbstractVideoSurface::Error paint( - const QRectF &target, QPainter *painter, const QRectF &source); - - void updateColors(int brightness, int contrast, int hue, int saturation); - -private: - void* ciContext; - QList m_imagePixelFormats; - QVideoFrame m_frame; - QSize m_imageSize; - QImage::Format m_imageFormat; - QVector m_supportedHandles; - QVideoSurfaceFormat::Direction m_scanLineDirection; -}; - -QT_END_NAMESPACE - -QT_END_HEADER - -#endif diff --git a/src/multimediakitwidgets/qpaintervideosurface_p.h b/src/multimediakitwidgets/qpaintervideosurface_p.h deleted file mode 100644 index 9b46e0395..000000000 --- a/src/multimediakitwidgets/qpaintervideosurface_p.h +++ /dev/null @@ -1,191 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QPAINTERVIDEOSURFACE_P_H -#define QPAINTERVIDEOSURFACE_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 -#include -#include -#include -#include -#include -#include - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -QT_MODULE(Multimedia) - -class QGLContext; -QT_END_NAMESPACE - -QT_USE_NAMESPACE - -QT_BEGIN_NAMESPACE - -class QVideoSurfacePainter -{ -public: - virtual ~QVideoSurfacePainter(); - - virtual QList supportedPixelFormats( - QAbstractVideoBuffer::HandleType handleType) const = 0; - - virtual bool isFormatSupported( - const QVideoSurfaceFormat &format, QVideoSurfaceFormat *similar) const = 0; - - virtual QAbstractVideoSurface::Error start(const QVideoSurfaceFormat &format) = 0; - virtual void stop() = 0; - - virtual QAbstractVideoSurface::Error setCurrentFrame(const QVideoFrame &frame) = 0; - - virtual QAbstractVideoSurface::Error paint( - const QRectF &target, QPainter *painter, const QRectF &source) = 0; - - virtual void updateColors(int brightness, int contrast, int hue, int saturation) = 0; - virtual void viewportDestroyed() {} -}; - - -class Q_AUTOTEST_EXPORT QPainterVideoSurface : public QAbstractVideoSurface -{ - Q_OBJECT -public: - explicit QPainterVideoSurface(QObject *parent = 0); - ~QPainterVideoSurface(); - - QList supportedPixelFormats( - QAbstractVideoBuffer::HandleType handleType = QAbstractVideoBuffer::NoHandle) const; - - bool isFormatSupported( - const QVideoSurfaceFormat &format, QVideoSurfaceFormat *similar = 0) const; - - bool start(const QVideoSurfaceFormat &format); - void stop(); - - bool present(const QVideoFrame &frame); - - int brightness() const; - void setBrightness(int brightness); - - int contrast() const; - void setContrast(int contrast); - - int hue() const; - void setHue(int hue); - - int saturation() const; - void setSaturation(int saturation); - - bool isReady() const; - void setReady(bool ready); - - void paint(QPainter *painter, const QRectF &target, const QRectF &source = QRectF(0, 0, 1, 1)); - -#if !defined(QT_NO_OPENGL) && !defined(QT_OPENGL_ES_1_CL) && !defined(QT_OPENGL_ES_1) - const QGLContext *glContext() const; - void setGLContext(QGLContext *context); - - enum ShaderType - { - NoShaders = 0x00, - FragmentProgramShader = 0x01, - GlslShader = 0x02 - }; - - Q_DECLARE_FLAGS(ShaderTypes, ShaderType) - - ShaderTypes supportedShaderTypes() const; - - ShaderType shaderType() const; - void setShaderType(ShaderType type); -#endif - -public Q_SLOTS: - void viewportDestroyed(); - -Q_SIGNALS: - void frameChanged(); - -private: - void createPainter(); - - QVideoSurfacePainter *m_painter; -#if !defined(QT_NO_OPENGL) && !defined(QT_OPENGL_ES_1_CL) && !defined(QT_OPENGL_ES_1) - QGLContext *m_glContext; - ShaderTypes m_shaderTypes; - ShaderType m_shaderType; -#endif - int m_brightness; - int m_contrast; - int m_hue; - int m_saturation; - - QVideoFrame::PixelFormat m_pixelFormat; - QSize m_frameSize; - QRect m_sourceRect; - bool m_colorsDirty; - bool m_ready; -}; - -#if !defined(QT_NO_OPENGL) && !defined(QT_OPENGL_ES_1_CL) && !defined(QT_OPENGL_ES_1) -Q_DECLARE_OPERATORS_FOR_FLAGS(QPainterVideoSurface::ShaderTypes) -#endif - -QT_END_NAMESPACE - -QT_END_HEADER - - -#endif diff --git a/src/multimediakitwidgets/qtmultimediakitwidgetdefs.h b/src/multimediakitwidgets/qtmultimediakitwidgetdefs.h deleted file mode 100644 index 6001629c6..000000000 --- a/src/multimediakitwidgets/qtmultimediakitwidgetdefs.h +++ /dev/null @@ -1,89 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -// -// 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. -// - -#ifndef QTMULTIMEDIAKITWIDGETS_P_H -#define QTMULTIMEDIAKITWIDGETS_P_H - -#include - -QT_BEGIN_HEADER - -#if defined(Q_OS_WIN) -# if defined(QT_NODLL) -# undef QT_MAKEDLL -# undef QT_DLL -# elif defined(QT_MAKEDLL) -# if defined(QT_DLL) -# undef QT_DLL -# endif -# if defined(QT_BUILD_MULTIMEDIA_LIB) -# define Q_MULTIMEDIAWIDGETS_EXPORT Q_DECL_EXPORT -# else -# define Q_MULTIMEDIAWIDGETS_EXPORT Q_DECL_IMPORT -# endif -# elif defined(QT_DLL) /* use a Qt DLL library */ -# define Q_MULTIMEDIAWIDGETS_EXPORT Q_DECL_IMPORT -# endif -#endif - -#if !defined(Q_MULTIMEDIAWIDGETS_EXPORT) -# if defined(QT_SHARED) -# define Q_MULTIMEDIAWIDGETS_EXPORT Q_DECL_EXPORT -# else -# define Q_MULTIMEDIAWIDGETS_EXPORT -# endif -#endif - -QT_END_HEADER - -#endif // QMULTIMEDIAKITWIDGETS_P_H - diff --git a/src/multimediakitwidgets/qvideowidget.cpp b/src/multimediakitwidgets/qvideowidget.cpp deleted file mode 100644 index 6ed9209c2..000000000 --- a/src/multimediakitwidgets/qvideowidget.cpp +++ /dev/null @@ -1,1043 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qvideowidget_p.h" - -#include -#include -#include -#include - -#include -#include -#include -#include - -#include -#include -#include -#include -#include - -using namespace Qt; - -QT_BEGIN_NAMESPACE - -QVideoWidgetControlBackend::QVideoWidgetControlBackend( - QMediaService *service, QVideoWidgetControl *control, QWidget *widget) - : m_service(service) - , m_widgetControl(control) -{ - connect(control, SIGNAL(brightnessChanged(int)), widget, SLOT(_q_brightnessChanged(int))); - connect(control, SIGNAL(contrastChanged(int)), widget, SLOT(_q_contrastChanged(int))); - connect(control, SIGNAL(hueChanged(int)), widget, SLOT(_q_hueChanged(int))); - connect(control, SIGNAL(saturationChanged(int)), widget, SLOT(_q_saturationChanged(int))); - connect(control, SIGNAL(fullScreenChanged(bool)), widget, SLOT(_q_fullScreenChanged(bool))); - - QBoxLayout *layout = new QVBoxLayout; - layout->setMargin(0); - layout->setSpacing(0); - - layout->addWidget(control->videoWidget()); - - widget->setLayout(layout); -} - -void QVideoWidgetControlBackend::releaseControl() -{ - m_service->releaseControl(m_widgetControl); -} - -void QVideoWidgetControlBackend::setBrightness(int brightness) -{ - m_widgetControl->setBrightness(brightness); -} - -void QVideoWidgetControlBackend::setContrast(int contrast) -{ - m_widgetControl->setContrast(contrast); -} - -void QVideoWidgetControlBackend::setHue(int hue) -{ - m_widgetControl->setHue(hue); -} - -void QVideoWidgetControlBackend::setSaturation(int saturation) -{ - m_widgetControl->setSaturation(saturation); -} - -void QVideoWidgetControlBackend::setFullScreen(bool fullScreen) -{ - m_widgetControl->setFullScreen(fullScreen); -} - - -Qt::AspectRatioMode QVideoWidgetControlBackend::aspectRatioMode() const -{ - return m_widgetControl->aspectRatioMode(); -} - -void QVideoWidgetControlBackend::setAspectRatioMode(Qt::AspectRatioMode mode) -{ - m_widgetControl->setAspectRatioMode(mode); -} - -QRendererVideoWidgetBackend::QRendererVideoWidgetBackend( - QMediaService *service, QVideoRendererControl *control, QWidget *widget) - : m_service(service) - , m_rendererControl(control) - , m_widget(widget) - , m_surface(new QPainterVideoSurface) - , m_aspectRatioMode(Qt::KeepAspectRatio) - , m_updatePaintDevice(true) -{ - connect(this, SIGNAL(brightnessChanged(int)), m_widget, SLOT(_q_brightnessChanged(int))); - connect(this, SIGNAL(contrastChanged(int)), m_widget, SLOT(_q_contrastChanged(int))); - connect(this, SIGNAL(hueChanged(int)), m_widget, SLOT(_q_hueChanged(int))); - connect(this, SIGNAL(saturationChanged(int)), m_widget, SLOT(_q_saturationChanged(int))); - connect(m_surface, SIGNAL(frameChanged()), this, SLOT(frameChanged())); - connect(m_surface, SIGNAL(surfaceFormatChanged(QVideoSurfaceFormat)), - this, SLOT(formatChanged(QVideoSurfaceFormat))); - - m_rendererControl->setSurface(m_surface); -} - -QRendererVideoWidgetBackend::~QRendererVideoWidgetBackend() -{ - delete m_surface; -} - -void QRendererVideoWidgetBackend::releaseControl() -{ - m_service->releaseControl(m_rendererControl); -} - -void QRendererVideoWidgetBackend::clearSurface() -{ - m_rendererControl->setSurface(0); -} - -void QRendererVideoWidgetBackend::setBrightness(int brightness) -{ - m_surface->setBrightness(brightness); - - emit brightnessChanged(brightness); -} - -void QRendererVideoWidgetBackend::setContrast(int contrast) -{ - m_surface->setContrast(contrast); - - emit contrastChanged(contrast); -} - -void QRendererVideoWidgetBackend::setHue(int hue) -{ - m_surface->setHue(hue); - - emit hueChanged(hue); -} - -void QRendererVideoWidgetBackend::setSaturation(int saturation) -{ - m_surface->setSaturation(saturation); - - emit saturationChanged(saturation); -} - -Qt::AspectRatioMode QRendererVideoWidgetBackend::aspectRatioMode() const -{ - return m_aspectRatioMode; -} - -void QRendererVideoWidgetBackend::setAspectRatioMode(Qt::AspectRatioMode mode) -{ - m_aspectRatioMode = mode; - - m_widget->updateGeometry(); -} - -void QRendererVideoWidgetBackend::setFullScreen(bool) -{ -} - -QSize QRendererVideoWidgetBackend::sizeHint() const -{ - return m_surface->surfaceFormat().sizeHint(); -} - -void QRendererVideoWidgetBackend::showEvent() -{ -} - -void QRendererVideoWidgetBackend::hideEvent(QHideEvent *) -{ -#if !defined(QT_NO_OPENGL) && !defined(QT_OPENGL_ES_1_CL) && !defined(QT_OPENGL_ES_1) - m_updatePaintDevice = true; - m_surface->setGLContext(0); -#endif -} - -void QRendererVideoWidgetBackend::resizeEvent(QResizeEvent *) -{ - updateRects(); -} - -void QRendererVideoWidgetBackend::moveEvent(QMoveEvent *) -{ -} - -void QRendererVideoWidgetBackend::paintEvent(QPaintEvent *event) -{ - QPainter painter(m_widget); - - if (m_widget->testAttribute(Qt::WA_OpaquePaintEvent)) { - QRegion borderRegion = event->region(); - borderRegion = borderRegion.subtracted(m_boundingRect); - - QBrush brush = m_widget->palette().window(); - - QVector rects = borderRegion.rects(); - for (QVector::iterator it = rects.begin(), end = rects.end(); it != end; ++it) { - painter.fillRect(*it, brush); - } - } - - if (m_surface->isActive() && m_boundingRect.intersects(event->rect())) { - m_surface->paint(&painter, m_boundingRect, m_sourceRect); - - m_surface->setReady(true); - } else { - #if !defined(QT_NO_OPENGL) && !defined(QT_OPENGL_ES_1_CL) && !defined(QT_OPENGL_ES_1) - if (m_updatePaintDevice && (painter.paintEngine()->type() == QPaintEngine::OpenGL - || painter.paintEngine()->type() == QPaintEngine::OpenGL2)) { - m_updatePaintDevice = false; - - m_surface->setGLContext(const_cast(QGLContext::currentContext())); - if (m_surface->supportedShaderTypes() & QPainterVideoSurface::GlslShader) { - m_surface->setShaderType(QPainterVideoSurface::GlslShader); - } else { - m_surface->setShaderType(QPainterVideoSurface::FragmentProgramShader); - } - } -#endif - } - -} - -void QRendererVideoWidgetBackend::formatChanged(const QVideoSurfaceFormat &format) -{ - m_nativeSize = format.sizeHint(); - - updateRects(); - - m_widget->updateGeometry(); - m_widget->update(); -} - -void QRendererVideoWidgetBackend::frameChanged() -{ - m_widget->update(m_boundingRect); -} - -void QRendererVideoWidgetBackend::updateRects() -{ - QRect rect = m_widget->rect(); - - if (m_nativeSize.isEmpty()) { - m_boundingRect = QRect(); - } else if (m_aspectRatioMode == Qt::IgnoreAspectRatio) { - m_boundingRect = rect; - m_sourceRect = QRectF(0, 0, 1, 1); - } else if (m_aspectRatioMode == Qt::KeepAspectRatio) { - QSize size = m_nativeSize; - size.scale(rect.size(), Qt::KeepAspectRatio); - - m_boundingRect = QRect(0, 0, size.width(), size.height()); - m_boundingRect.moveCenter(rect.center()); - - m_sourceRect = QRectF(0, 0, 1, 1); - } else if (m_aspectRatioMode == Qt::KeepAspectRatioByExpanding) { - m_boundingRect = rect; - - QSizeF size = rect.size(); - size.scale(m_nativeSize, Qt::KeepAspectRatio); - - m_sourceRect = QRectF( - 0, 0, size.width() / m_nativeSize.width(), size.height() / m_nativeSize.height()); - m_sourceRect.moveCenter(QPointF(0.5, 0.5)); - } -} - -QWindowVideoWidgetBackend::QWindowVideoWidgetBackend( - QMediaService *service, QVideoWindowControl *control, QWidget *widget) - : m_service(service) - , m_windowControl(control) - , m_widget(widget) - , m_aspectRatioMode(Qt::KeepAspectRatio) -{ - connect(control, SIGNAL(brightnessChanged(int)), m_widget, SLOT(_q_brightnessChanged(int))); - connect(control, SIGNAL(contrastChanged(int)), m_widget, SLOT(_q_contrastChanged(int))); - connect(control, SIGNAL(hueChanged(int)), m_widget, SLOT(_q_hueChanged(int))); - connect(control, SIGNAL(saturationChanged(int)), m_widget, SLOT(_q_saturationChanged(int))); - connect(control, SIGNAL(fullScreenChanged(bool)), m_widget, SLOT(_q_fullScreenChanged(bool))); - connect(control, SIGNAL(nativeSizeChanged()), m_widget, SLOT(_q_dimensionsChanged())); - - control->setWinId(widget->winId()); -} - -QWindowVideoWidgetBackend::~QWindowVideoWidgetBackend() -{ -} - -void QWindowVideoWidgetBackend::releaseControl() -{ - m_service->releaseControl(m_windowControl); -} - -void QWindowVideoWidgetBackend::setBrightness(int brightness) -{ - m_windowControl->setBrightness(brightness); -} - -void QWindowVideoWidgetBackend::setContrast(int contrast) -{ - m_windowControl->setContrast(contrast); -} - -void QWindowVideoWidgetBackend::setHue(int hue) -{ - m_windowControl->setHue(hue); -} - -void QWindowVideoWidgetBackend::setSaturation(int saturation) -{ - m_windowControl->setSaturation(saturation); -} - -void QWindowVideoWidgetBackend::setFullScreen(bool fullScreen) -{ - m_windowControl->setFullScreen(fullScreen); -} - -Qt::AspectRatioMode QWindowVideoWidgetBackend::aspectRatioMode() const -{ - return m_windowControl->aspectRatioMode(); -} - -void QWindowVideoWidgetBackend::setAspectRatioMode(Qt::AspectRatioMode mode) -{ - m_windowControl->setAspectRatioMode(mode); -} - -QSize QWindowVideoWidgetBackend::sizeHint() const -{ - return m_windowControl->nativeSize(); -} - -void QWindowVideoWidgetBackend::showEvent() -{ - m_windowControl->setWinId(m_widget->winId()); - - m_windowControl->setDisplayRect(m_widget->rect()); - -#if defined(Q_WS_WIN) - m_widget->setUpdatesEnabled(false); -#endif -} - -void QWindowVideoWidgetBackend::hideEvent(QHideEvent *) -{ -#if defined(Q_WS_WIN) - m_widget->setUpdatesEnabled(true); -#endif -} - -void QWindowVideoWidgetBackend::moveEvent(QMoveEvent *) -{ - m_windowControl->setDisplayRect(m_widget->rect()); -} - -void QWindowVideoWidgetBackend::resizeEvent(QResizeEvent *) -{ - m_windowControl->setDisplayRect(m_widget->rect()); -} - -void QWindowVideoWidgetBackend::paintEvent(QPaintEvent *event) -{ - if (m_widget->testAttribute(Qt::WA_OpaquePaintEvent)) { - QPainter painter(m_widget); - - painter.fillRect(event->rect(), m_widget->palette().window()); - } - - m_windowControl->repaint(); - - event->accept(); -} - -#if defined(Q_WS_WIN) -bool QWindowVideoWidgetBackend::winEvent(MSG *message, long *) -{ - if (message->message == WM_PAINT) - m_windowControl->repaint(); - - return false; -} -#endif - -void QVideoWidgetPrivate::setCurrentControl(QVideoWidgetControlInterface *control) -{ - if (currentControl != control) { - currentControl = control; - - currentControl->setBrightness(brightness); - currentControl->setContrast(contrast); - currentControl->setHue(hue); - currentControl->setSaturation(saturation); - currentControl->setAspectRatioMode(aspectRatioMode); - } -} - -void QVideoWidgetPrivate::clearService() -{ - if (service) { - QObject::disconnect(service, SIGNAL(destroyed()), q_func(), SLOT(_q_serviceDestroyed())); - - if (widgetBackend) { - QLayout *layout = q_func()->layout(); - - for (QLayoutItem *item = layout->takeAt(0); item; item = layout->takeAt(0)) { - item->widget()->setParent(0); - delete item; - } - delete layout; - - widgetBackend->releaseControl(); - - delete widgetBackend; - widgetBackend = 0; - } else if (rendererBackend) { - rendererBackend->clearSurface(); - rendererBackend->releaseControl(); - - delete rendererBackend; - rendererBackend = 0; - } else { - windowBackend->releaseControl(); - - delete windowBackend; - windowBackend = 0; - } - - currentBackend = 0; - currentControl = 0; - service = 0; - } -} - -bool QVideoWidgetPrivate::createWidgetBackend() -{ - if (QMediaControl *control = service->requestControl(QVideoWidgetControl_iid)) { - if (QVideoWidgetControl *widgetControl = qobject_cast(control)) { - widgetBackend = new QVideoWidgetControlBackend(service, widgetControl, q_func()); - - setCurrentControl(widgetBackend); - - return true; - } - service->releaseControl(control); - } - return false; -} - -bool QVideoWidgetPrivate::createWindowBackend() -{ - if (QMediaControl *control = service->requestControl(QVideoWindowControl_iid)) { - if (QVideoWindowControl *windowControl = qobject_cast(control)) { - windowBackend = new QWindowVideoWidgetBackend(service, windowControl, q_func()); - currentBackend = windowBackend; - - setCurrentControl(windowBackend); - - return true; - } - service->releaseControl(control); - } - return false; -} - -bool QVideoWidgetPrivate::createRendererBackend() -{ - if (QMediaControl *control = service->requestControl(QVideoRendererControl_iid)) { - if (QVideoRendererControl *rendererControl = qobject_cast(control)) { - rendererBackend = new QRendererVideoWidgetBackend(service, rendererControl, q_func()); - currentBackend = rendererBackend; - - setCurrentControl(rendererBackend); - - return true; - } - service->releaseControl(control); - } - return false; -} - -void QVideoWidgetPrivate::_q_serviceDestroyed() -{ - if (widgetBackend) - delete q_func()->layout(); - - delete widgetBackend; - delete windowBackend; - delete rendererBackend; - - widgetBackend = 0; - windowBackend = 0; - rendererBackend = 0; - currentControl = 0; - currentBackend = 0; - service = 0; -} - -void QVideoWidgetPrivate::_q_brightnessChanged(int b) -{ - if (b != brightness) - emit q_func()->brightnessChanged(brightness = b); -} - -void QVideoWidgetPrivate::_q_contrastChanged(int c) -{ - if (c != contrast) - emit q_func()->contrastChanged(contrast = c); -} - -void QVideoWidgetPrivate::_q_hueChanged(int h) -{ - if (h != hue) - emit q_func()->hueChanged(hue = h); -} - -void QVideoWidgetPrivate::_q_saturationChanged(int s) -{ - if (s != saturation) - emit q_func()->saturationChanged(saturation = s); -} - - -void QVideoWidgetPrivate::_q_fullScreenChanged(bool fullScreen) -{ - if (!fullScreen && q_func()->isFullScreen()) - q_func()->showNormal(); -} - -void QVideoWidgetPrivate::_q_dimensionsChanged() -{ - q_func()->updateGeometry(); - q_func()->update(); -} - -/*! - \class QVideoWidget - - - \brief The QVideoWidget class provides a widget which presents video - produced by a media object. - \ingroup multimedia - \inmodule QtMultimediaKit - \since 1.0 - - \inmodule QtMultimediaKit - - Attaching a QVideoWidget to a QMediaObject allows it to display the - video or image output of that media object. A QVideoWidget is attached - to media object by passing a pointer to the QMediaObject in its - constructor, and detached by destroying the QVideoWidget. - - \snippet doc/src/snippets/multimedia-snippets/video.cpp Video widget - - \bold {Note}: Only a single display output can be attached to a media - object at one time. - - \sa QMediaObject, QMediaPlayer, QGraphicsVideoItem -*/ - -/*! - Constructs a new video widget. - - The \a parent is passed to QWidget. -*/ -QVideoWidget::QVideoWidget(QWidget *parent) - : QWidget(parent, 0) - , d_ptr(new QVideoWidgetPrivate) -{ - d_ptr->q_ptr = this; -} - -/*! - \internal -*/ -QVideoWidget::QVideoWidget(QVideoWidgetPrivate &dd, QWidget *parent) - : QWidget(parent, 0) - , d_ptr(&dd) -{ - d_ptr->q_ptr = this; - - QPalette palette = QWidget::palette(); - palette.setColor(QPalette::Background, Qt::black); - setPalette(palette); -} - -/*! - Destroys a video widget. -*/ -QVideoWidget::~QVideoWidget() -{ - d_ptr->clearService(); - - delete d_ptr; -} - -/*! - \property QVideoWidget::mediaObject - \brief the media object which provides the video displayed by a widget. - \since 1.0 -*/ - -QMediaObject *QVideoWidget::mediaObject() const -{ - return d_func()->mediaObject; -} - -/*! - \internal - \since 1.0 -*/ -bool QVideoWidget::setMediaObject(QMediaObject *object) -{ - Q_D(QVideoWidget); - - if (object == d->mediaObject) - return true; - - d->clearService(); - - d->mediaObject = object; - - if (d->mediaObject) - d->service = d->mediaObject->service(); - - if (d->service) { - if (d->createWidgetBackend()) { - // Nothing to do here. - } else if ((!window() || !window()->testAttribute(Qt::WA_DontShowOnScreen)) - && d->createWindowBackend()) { - if (isVisible()) - d->windowBackend->showEvent(); - } else if (d->createRendererBackend()) { - if (isVisible()) - d->rendererBackend->showEvent(); - } else { - d->service = 0; - d->mediaObject = 0; - - return false; - } - - connect(d->service, SIGNAL(destroyed()), SLOT(_q_serviceDestroyed())); - } else { - d->mediaObject = 0; - - return false; - } - - return true; -} - -/*! - \property QVideoWidget::aspectRatioMode - \brief how video is scaled with respect to its aspect ratio. - \since 1.0 -*/ - -Qt::AspectRatioMode QVideoWidget::aspectRatioMode() const -{ - return d_func()->aspectRatioMode; -} - -void QVideoWidget::setAspectRatioMode(Qt::AspectRatioMode mode) -{ - Q_D(QVideoWidget); - - if (d->currentControl) { - d->currentControl->setAspectRatioMode(mode); - d->aspectRatioMode = d->currentControl->aspectRatioMode(); - } else { - d->aspectRatioMode = mode; - } -} - -/*! - \property QVideoWidget::fullScreen - \brief whether video display is confined to a window or is fullScreen. - \since 1.0 -*/ - -void QVideoWidget::setFullScreen(bool fullScreen) -{ - Q_D(QVideoWidget); - - if (fullScreen) { - Qt::WindowFlags flags = windowFlags(); - - d->nonFullScreenFlags = flags & (Qt::Window | Qt::SubWindow); - flags |= Qt::Window; - flags &= ~Qt::SubWindow; - setWindowFlags(flags); - - showFullScreen(); - } else { - showNormal(); - } -} - -/*! - \fn QVideoWidget::fullScreenChanged(bool fullScreen) - - Signals that the \a fullScreen mode of a video widget has changed. - - \since 1.0 - \sa fullScreen -*/ - -/*! - \property QVideoWidget::brightness - \brief an adjustment to the brightness of displayed video. - - Valid brightness values range between -100 and 100, the default is 0. - \since 1.0 -*/ - -int QVideoWidget::brightness() const -{ - return d_func()->brightness; -} - -void QVideoWidget::setBrightness(int brightness) -{ - Q_D(QVideoWidget); - - int boundedBrightness = qBound(-100, brightness, 100); - - if (d->currentControl) - d->currentControl->setBrightness(boundedBrightness); - else if (d->brightness != boundedBrightness) - emit brightnessChanged(d->brightness = boundedBrightness); -} - -/*! - \fn QVideoWidget::brightnessChanged(int brightness) - - Signals that a video widgets's \a brightness adjustment has changed. - - \since 1.0 - \sa brightness -*/ - -/*! - \property QVideoWidget::contrast - \brief an adjustment to the contrast of displayed video. - - Valid contrast values range between -100 and 100, the default is 0. - - \since 1.0 -*/ - -int QVideoWidget::contrast() const -{ - return d_func()->contrast; -} - -void QVideoWidget::setContrast(int contrast) -{ - Q_D(QVideoWidget); - - int boundedContrast = qBound(-100, contrast, 100); - - if (d->currentControl) - d->currentControl->setContrast(boundedContrast); - else if (d->contrast != boundedContrast) - emit contrastChanged(d->contrast = boundedContrast); -} - -/*! - \fn QVideoWidget::contrastChanged(int contrast) - - Signals that a video widgets's \a contrast adjustment has changed. - - \since 1.0 - \sa contrast -*/ - -/*! - \property QVideoWidget::hue - \brief an adjustment to the hue of displayed video. - - Valid hue values range between -100 and 100, the default is 0. - \since 1.0 -*/ - -int QVideoWidget::hue() const -{ - return d_func()->hue; -} - -void QVideoWidget::setHue(int hue) -{ - Q_D(QVideoWidget); - - int boundedHue = qBound(-100, hue, 100); - - if (d->currentControl) - d->currentControl->setHue(boundedHue); - else if (d->hue != boundedHue) - emit hueChanged(d->hue = boundedHue); -} - -/*! - \fn QVideoWidget::hueChanged(int hue) - - Signals that a video widgets's \a hue has changed. - - \since 1.0 - \sa hue -*/ - -/*! - \property QVideoWidget::saturation - \brief an adjustment to the saturation of displayed video. - - Valid saturation values range between -100 and 100, the default is 0. - \since 1.0 -*/ - -int QVideoWidget::saturation() const -{ - return d_func()->saturation; -} - -void QVideoWidget::setSaturation(int saturation) -{ - Q_D(QVideoWidget); - - int boundedSaturation = qBound(-100, saturation, 100); - - if (d->currentControl) - d->currentControl->setSaturation(boundedSaturation); - else if (d->saturation != boundedSaturation) - emit saturationChanged(d->saturation = boundedSaturation); - -} - -/*! - \fn QVideoWidget::saturationChanged(int saturation) - - Signals that a video widgets's \a saturation has changed. - - \since 1.0 - \sa saturation -*/ - -/*! - Returns the size hint for the current back end, - if there is one, or else the size hint from QWidget. - \since 1.0 - */ -QSize QVideoWidget::sizeHint() const -{ - Q_D(const QVideoWidget); - - if (d->currentBackend) - return d->currentBackend->sizeHint(); - else - return QWidget::sizeHint(); - - -} - -/*! - Current event \a event. - Returns the value of the baseclass QWidget::event(QEvent *event) function. - \since 1.0 -*/ -bool QVideoWidget::event(QEvent *event) -{ - Q_D(QVideoWidget); - - if (event->type() == QEvent::WindowStateChange) { - Qt::WindowFlags flags = windowFlags(); - - if (windowState() & Qt::WindowFullScreen) { - if (d->currentControl) - d->currentControl->setFullScreen(true); - - if (!d->wasFullScreen) - emit fullScreenChanged(d->wasFullScreen = true); - } else { - if (d->currentControl) - d->currentControl->setFullScreen(false); - - if (d->wasFullScreen) { - flags &= ~(Qt::Window | Qt::SubWindow); //clear the flags... - flags |= d->nonFullScreenFlags; //then we reset the flags (window and subwindow) - setWindowFlags(flags); - - emit fullScreenChanged(d->wasFullScreen = false); - } - } - } - return QWidget::event(event); -} - -/*! - Handles the show \a event. - \since 1.0 - */ -void QVideoWidget::showEvent(QShowEvent *event) -{ - Q_D(QVideoWidget); - - QWidget::showEvent(event); - - // The window backend won't work for re-directed windows so use the renderer backend instead. - if (d->windowBackend && window()->testAttribute(Qt::WA_DontShowOnScreen)) { - d->windowBackend->releaseControl(); - - delete d->windowBackend; - d->windowBackend = 0; - - d->createRendererBackend(); - } - - if (d->currentBackend) - d->currentBackend->showEvent(); -} - -/*! - - Handles the hide \a event. - \since 1.0 -*/ -void QVideoWidget::hideEvent(QHideEvent *event) -{ - Q_D(QVideoWidget); - - if (d->currentBackend) - d->currentBackend->hideEvent(event); - - QWidget::hideEvent(event); -} - -/*! - Handles the resize \a event. - \since 1.0 - */ -void QVideoWidget::resizeEvent(QResizeEvent *event) -{ - Q_D(QVideoWidget); - - QWidget::resizeEvent(event); - - if (d->currentBackend) - d->currentBackend->resizeEvent(event); -} - -/*! - Handles the move \a event. - \since 1.0 - */ -void QVideoWidget::moveEvent(QMoveEvent *event) -{ - Q_D(QVideoWidget); - - if (d->currentBackend) - d->currentBackend->moveEvent(event); -} - -/*! - Handles the paint \a event. - \since 1.0 - */ -void QVideoWidget::paintEvent(QPaintEvent *event) -{ - Q_D(QVideoWidget); - - if (d->currentBackend) { - d->currentBackend->paintEvent(event); - } else if (testAttribute(Qt::WA_OpaquePaintEvent)) { - QPainter painter(this); - - painter.fillRect(event->rect(), palette().window()); - } -} - - -#if defined(Q_WS_WIN) -/*! - \reimp - \internal - \since 1.1 -*/ -bool QVideoWidget::winEvent(MSG *message, long *result) -{ - return d_func()->windowBackend && d_func()->windowBackend->winEvent(message, result) - ? true - : QWidget::winEvent(message, result); -} -#endif - - -#include "moc_qvideowidget.cpp" -#include "moc_qvideowidget_p.cpp" -QT_END_NAMESPACE - diff --git a/src/multimediakitwidgets/qvideowidget.h b/src/multimediakitwidgets/qvideowidget.h deleted file mode 100644 index c0675c6e2..000000000 --- a/src/multimediakitwidgets/qvideowidget.h +++ /dev/null @@ -1,139 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QVIDEOWIDGET_H -#define QVIDEOWIDGET_H - -#include - -#include -#include - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -QT_MODULE(Multimedia) - - -class QMediaObject; - -class QVideoWidgetPrivate; -class Q_MULTIMEDIA_EXPORT QVideoWidget : public QWidget, public QMediaBindableInterface -{ - Q_OBJECT - Q_INTERFACES(QMediaBindableInterface) - Q_PROPERTY(QMediaObject* mediaObject READ mediaObject WRITE setMediaObject) - Q_PROPERTY(bool fullScreen READ isFullScreen WRITE setFullScreen NOTIFY fullScreenChanged) - Q_PROPERTY(Qt::AspectRatioMode aspectRatioMode READ aspectRatioMode WRITE setAspectRatioMode) - Q_PROPERTY(int brightness READ brightness WRITE setBrightness NOTIFY brightnessChanged) - Q_PROPERTY(int contrast READ contrast WRITE setContrast NOTIFY contrastChanged) - Q_PROPERTY(int hue READ hue WRITE setHue NOTIFY hueChanged) - Q_PROPERTY(int saturation READ saturation WRITE setSaturation NOTIFY saturationChanged) - -public: - QVideoWidget(QWidget *parent = 0); - ~QVideoWidget(); - - QMediaObject *mediaObject() const; - -#ifdef Q_QDOC - bool isFullScreen() const; -#endif - - Qt::AspectRatioMode aspectRatioMode() const; - - int brightness() const; - int contrast() const; - int hue() const; - int saturation() const; - - QSize sizeHint() const; - -public Q_SLOTS: - void setFullScreen(bool fullScreen); - void setAspectRatioMode(Qt::AspectRatioMode mode); - void setBrightness(int brightness); - void setContrast(int contrast); - void setHue(int hue); - void setSaturation(int saturation); - -Q_SIGNALS: - void fullScreenChanged(bool fullScreen); - void brightnessChanged(int brightness); - void contrastChanged(int contrast); - void hueChanged(int hue); - void saturationChanged(int saturation); - -protected: - bool event(QEvent *event); - void showEvent(QShowEvent *event); - void hideEvent(QHideEvent *event); - void resizeEvent(QResizeEvent *event); - void moveEvent(QMoveEvent *event); - void paintEvent(QPaintEvent *event); - - bool setMediaObject(QMediaObject *object); - -#if defined(Q_WS_WIN) - bool winEvent(MSG *message, long *result); -#endif - - QVideoWidget(QVideoWidgetPrivate &dd, QWidget *parent); - QVideoWidgetPrivate *d_ptr; - -private: - Q_DECLARE_PRIVATE(QVideoWidget) - Q_PRIVATE_SLOT(d_func(), void _q_serviceDestroyed()) - Q_PRIVATE_SLOT(d_func(), void _q_brightnessChanged(int)) - Q_PRIVATE_SLOT(d_func(), void _q_contrastChanged(int)) - Q_PRIVATE_SLOT(d_func(), void _q_hueChanged(int)) - Q_PRIVATE_SLOT(d_func(), void _q_saturationChanged(int)) - Q_PRIVATE_SLOT(d_func(), void _q_fullScreenChanged(bool)) - Q_PRIVATE_SLOT(d_func(), void _q_dimensionsChanged()) -}; - -QT_END_NAMESPACE - -QT_END_HEADER - - -#endif diff --git a/src/multimediakitwidgets/qvideowidget_p.h b/src/multimediakitwidgets/qvideowidget_p.h deleted file mode 100644 index ca9bc767a..000000000 --- a/src/multimediakitwidgets/qvideowidget_p.h +++ /dev/null @@ -1,290 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QVIDEOWIDGET_P_H -#define QVIDEOWIDGET_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 -#include "qvideowidget.h" - -#ifndef QT_NO_OPENGL -#include -#endif - -#include "qpaintervideosurface_p.h" - -#include - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -QT_MODULE(Multimedia) - - -class QMediaService; - -class QVideoWidgetControlInterface -{ -public: - virtual ~QVideoWidgetControlInterface() {} - - virtual void setBrightness(int brightness) = 0; - virtual void setContrast(int contrast) = 0; - virtual void setHue(int hue) = 0; - virtual void setSaturation(int saturation) = 0; - - virtual void setFullScreen(bool fullScreen) = 0; - - virtual Qt::AspectRatioMode aspectRatioMode() const = 0; - virtual void setAspectRatioMode(Qt::AspectRatioMode mode) = 0; -}; - -class QVideoWidgetBackend : public QObject, public QVideoWidgetControlInterface -{ - Q_OBJECT -public: - virtual QSize sizeHint() const = 0; - - virtual void showEvent() = 0; - virtual void hideEvent(QHideEvent *event) = 0; - virtual void resizeEvent(QResizeEvent *event) = 0; - virtual void moveEvent(QMoveEvent *event) = 0; - virtual void paintEvent(QPaintEvent *event) = 0; -}; - -class QVideoWidgetControl; - -class QVideoWidgetControlBackend : public QObject, public QVideoWidgetControlInterface -{ - Q_OBJECT -public: - QVideoWidgetControlBackend(QMediaService *service, QVideoWidgetControl *control, QWidget *widget); - - void releaseControl(); - - void setBrightness(int brightness); - void setContrast(int contrast); - void setHue(int hue); - void setSaturation(int saturation); - - void setFullScreen(bool fullScreen); - - Qt::AspectRatioMode aspectRatioMode() const; - void setAspectRatioMode(Qt::AspectRatioMode mode); - -private: - QMediaService *m_service; - QVideoWidgetControl *m_widgetControl; -}; - - -class QVideoRendererControl; - -class QRendererVideoWidgetBackend : public QVideoWidgetBackend -{ - Q_OBJECT -public: - QRendererVideoWidgetBackend(QMediaService *service, QVideoRendererControl *control, QWidget *widget); - ~QRendererVideoWidgetBackend(); - - void releaseControl(); - void clearSurface(); - - void setBrightness(int brightness); - void setContrast(int contrast); - void setHue(int hue); - void setSaturation(int saturation); - - void setFullScreen(bool fullScreen); - - Qt::AspectRatioMode aspectRatioMode() const; - void setAspectRatioMode(Qt::AspectRatioMode mode); - - QSize sizeHint() const; - - void showEvent(); - void hideEvent(QHideEvent *event); - void resizeEvent(QResizeEvent *event); - void moveEvent(QMoveEvent *event); - void paintEvent(QPaintEvent *event); - -Q_SIGNALS: - void fullScreenChanged(bool fullScreen); - void brightnessChanged(int brightness); - void contrastChanged(int contrast); - void hueChanged(int hue); - void saturationChanged(int saturation); - -private Q_SLOTS: - void formatChanged(const QVideoSurfaceFormat &format); - void frameChanged(); - -private: - void updateRects(); - - QMediaService *m_service; - QVideoRendererControl *m_rendererControl; - QWidget *m_widget; - QPainterVideoSurface *m_surface; - Qt::AspectRatioMode m_aspectRatioMode; - QRect m_boundingRect; - QRectF m_sourceRect; - QSize m_nativeSize; - bool m_updatePaintDevice; -}; - -class QVideoWindowControl; - -class QWindowVideoWidgetBackend : public QVideoWidgetBackend -{ - Q_OBJECT -public: - QWindowVideoWidgetBackend(QMediaService *service, QVideoWindowControl *control, QWidget *widget); - ~QWindowVideoWidgetBackend(); - - void releaseControl(); - - void setBrightness(int brightness); - void setContrast(int contrast); - void setHue(int hue); - void setSaturation(int saturation); - - void setFullScreen(bool fullScreen); - - Qt::AspectRatioMode aspectRatioMode() const; - void setAspectRatioMode(Qt::AspectRatioMode mode); - - QSize sizeHint() const; - - void showEvent(); - void hideEvent(QHideEvent *event); - void resizeEvent(QResizeEvent *event); - void moveEvent(QMoveEvent *event); - void paintEvent(QPaintEvent *event); - -#if defined(Q_WS_WIN) - bool winEvent(MSG *message, long *result); -#endif - -private: - QMediaService *m_service; - QVideoWindowControl *m_windowControl; - QWidget *m_widget; - Qt::AspectRatioMode m_aspectRatioMode; - QSize m_pixelAspectRatio; -}; - -class QMediaService; -class QVideoOutputControl; - -class QVideoWidgetPrivate -{ - Q_DECLARE_PUBLIC(QVideoWidget) -public: - QVideoWidgetPrivate() - : q_ptr(0) - , mediaObject(0) - , service(0) - , widgetBackend(0) - , windowBackend(0) - , rendererBackend(0) - , currentControl(0) - , currentBackend(0) - , brightness(0) - , contrast(0) - , hue(0) - , saturation(0) - , aspectRatioMode(Qt::KeepAspectRatio) - , nonFullScreenFlags(0) - , wasFullScreen(false) - { - } - - QVideoWidget *q_ptr; - QPointer mediaObject; - QMediaService *service; - QVideoWidgetControlBackend *widgetBackend; - QWindowVideoWidgetBackend *windowBackend; - QRendererVideoWidgetBackend *rendererBackend; - QVideoWidgetControlInterface *currentControl; - QVideoWidgetBackend *currentBackend; - int brightness; - int contrast; - int hue; - int saturation; - Qt::AspectRatioMode aspectRatioMode; - Qt::WindowFlags nonFullScreenFlags; - bool wasFullScreen; - - bool createWidgetBackend(); - bool createWindowBackend(); - bool createRendererBackend(); - - void setCurrentControl(QVideoWidgetControlInterface *control); - void clearService(); - - void _q_serviceDestroyed(); - void _q_brightnessChanged(int brightness); - void _q_contrastChanged(int contrast); - void _q_hueChanged(int hue); - void _q_saturationChanged(int saturation); - void _q_fullScreenChanged(bool fullScreen); - void _q_dimensionsChanged(); -}; - -QT_END_NAMESPACE - -QT_END_HEADER - - -#endif diff --git a/src/multimediakitwidgets/qvideowidgetcontrol.cpp b/src/multimediakitwidgets/qvideowidgetcontrol.cpp deleted file mode 100644 index acc4100df..000000000 --- a/src/multimediakitwidgets/qvideowidgetcontrol.cpp +++ /dev/null @@ -1,245 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qvideowidgetcontrol.h" -#include "private/qmediacontrol_p.h" - -QT_BEGIN_NAMESPACE - -/*! - \class QVideoWidgetControl - - - \brief The QVideoWidgetControl class provides a media control which - implements a video widget. - - \inmodule QtMultimediaKit - \ingroup multimedia-serv - \since 1.0 - - The videoWidget() property of QVideoWidgetControl provides a pointer to a - video widget implemented by the control's media service. This widget is - owned by the media service and so care should be taken not to delete it. - - \snippet doc/src/snippets/multimedia-snippets/video.cpp Video widget control - - QVideoWidgetControl is one of number of possible video output controls. - - The interface name of QVideoWidgetControl is \c com.nokia.Qt.QVideoWidgetControl/1.0 as - defined in QVideoWidgetControl_iid. - - \sa QMediaService::requestControl(), QVideoWidget -*/ - -/*! - \macro QVideoWidgetControl_iid - - \c com.nokia.Qt.QVideoWidgetControl/1.0 - - Defines the interface name of the QVideoWidgetControl class. - - \relates QVideoWidgetControl -*/ - -/*! - Constructs a new video widget control with the given \a parent. -*/ -QVideoWidgetControl::QVideoWidgetControl(QObject *parent) - :QMediaControl(parent) -{ -} - -/*! - Destroys a video widget control. -*/ -QVideoWidgetControl::~QVideoWidgetControl() -{ -} - -/*! - \fn QVideoWidgetControl::isFullScreen() const - - Returns true if the video is shown using the complete screen. - \since 1.0 -*/ - -/*! - \fn QVideoWidgetControl::setFullScreen(bool fullScreen) - - Sets whether a video widget is in \a fullScreen mode. - \since 1.0 -*/ - -/*! - \fn QVideoWidgetControl::fullScreenChanged(bool fullScreen) - - Signals that the \a fullScreen state of a video widget has changed. - \since 1.0 -*/ - -/*! - \fn QVideoWidgetControl::aspectRatioMode() const - - Returns how video is scaled to fit the widget with respect to its aspect ratio. - \since 1.0 -*/ - -/*! - \fn QVideoWidgetControl::setAspectRatioMode(Qt::AspectRatioMode mode) - - Sets the aspect ratio \a mode which determines how video is scaled to the fit the widget with - respect to its aspect ratio. - \since 1.0 -*/ - -/*! - \fn QVideoWidgetControl::brightness() const - - Returns the brightness adjustment applied to a video. - - Valid brightness values range between -100 and 100, the default is 0. - \since 1.0 -*/ - -/*! - \fn QVideoWidgetControl::setBrightness(int brightness) - - Sets a \a brightness adjustment for a video. - - Valid brightness values range between -100 and 100, the default is 0. - \since 1.0 -*/ - -/*! - \fn QVideoWidgetControl::brightnessChanged(int brightness) - - Signals that a video widget's \a brightness adjustment has changed. - \since 1.0 -*/ - -/*! - \fn QVideoWidgetControl::contrast() const - - Returns the contrast adjustment applied to a video. - - Valid contrast values range between -100 and 100, the default is 0. - \since 1.0 -*/ - -/*! - \fn QVideoWidgetControl::setContrast(int contrast) - - Sets the contrast adjustment for a video widget to \a contrast. - - Valid contrast values range between -100 and 100, the default is 0. - \since 1.0 -*/ - - -/*! - \fn QVideoWidgetControl::contrastChanged(int contrast) - - Signals that a video widget's \a contrast adjustment has changed. - \since 1.0 -*/ - -/*! - \fn QVideoWidgetControl::hue() const - - Returns the hue adjustment applied to a video widget. - - Value hue values range between -100 and 100, the default is 0. - \since 1.0 -*/ - -/*! - \fn QVideoWidgetControl::setHue(int hue) - - Sets a \a hue adjustment for a video widget. - - Valid hue values range between -100 and 100, the default is 0. - \since 1.0 -*/ - - -/*! - \fn QVideoWidgetControl::hueChanged(int hue) - - Signals that a video widget's \a hue adjustment has changed. - \since 1.0 -*/ - -/*! - \fn QVideoWidgetControl::saturation() const - - Returns the saturation adjustment applied to a video widget. - - Value saturation values range between -100 and 100, the default is 0. - \since 1.0 -*/ - - -/*! - \fn QVideoWidgetControl::setSaturation(int saturation) - - Sets a \a saturation adjustment for a video widget. - - Valid saturation values range between -100 and 100, the default is 0. - \since 1.0 -*/ - -/*! - \fn QVideoWidgetControl::saturationChanged(int saturation) - - Signals that a video widget's \a saturation adjustment has changed. - \since 1.0 -*/ - -/*! - \fn QVideoWidgetControl::videoWidget() - - Returns the QWidget. - \since 1.0 -*/ - -#include "moc_qvideowidgetcontrol.cpp" -QT_END_NAMESPACE - diff --git a/src/multimediakitwidgets/qvideowidgetcontrol.h b/src/multimediakitwidgets/qvideowidgetcontrol.h deleted file mode 100644 index c5ac880fa..000000000 --- a/src/multimediakitwidgets/qvideowidgetcontrol.h +++ /dev/null @@ -1,105 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QVIDEOWIDGETCONTROL_H -#define QVIDEOWIDGETCONTROL_H - -#include "qvideowidget.h" -#include "qmediacontrol.h" - -#include - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -QT_MODULE(Multimedia) - - -class QVideoWidgetControlPrivate; - -class Q_MULTIMEDIA_EXPORT QVideoWidgetControl : public QMediaControl -{ - Q_OBJECT - -public: - virtual ~QVideoWidgetControl(); - - virtual QWidget *videoWidget() = 0; - - virtual Qt::AspectRatioMode aspectRatioMode() const = 0; - virtual void setAspectRatioMode(Qt::AspectRatioMode mode) = 0; - - virtual bool isFullScreen() const = 0; - virtual void setFullScreen(bool fullScreen) = 0; - - virtual int brightness() const = 0; - virtual void setBrightness(int brightness) = 0; - - virtual int contrast() const = 0; - virtual void setContrast(int contrast) = 0; - - virtual int hue() const = 0; - virtual void setHue(int hue) = 0; - - virtual int saturation() const = 0; - virtual void setSaturation(int saturation) = 0; - -Q_SIGNALS: - void fullScreenChanged(bool fullScreen); - void brightnessChanged(int brightness); - void contrastChanged(int contrast); - void hueChanged(int hue); - void saturationChanged(int saturation); - -protected: - QVideoWidgetControl(QObject *parent = 0); -}; - -#define QVideoWidgetControl_iid "com.nokia.Qt.QVideoWidgetControl/1.0" -Q_MEDIA_DECLARE_CONTROL(QVideoWidgetControl, QVideoWidgetControl_iid) - -QT_END_NAMESPACE - -QT_END_HEADER - - -#endif diff --git a/src/multimediakitwidgets/qvideowindowcontrol.cpp b/src/multimediakitwidgets/qvideowindowcontrol.cpp deleted file mode 100644 index 26604496e..000000000 --- a/src/multimediakitwidgets/qvideowindowcontrol.cpp +++ /dev/null @@ -1,284 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qvideowindowcontrol.h" - -QT_BEGIN_NAMESPACE - -/*! - \class QVideoWindowControl - - \inmodule QtMultimediaKit - \ingroup multimedia-serv - \brief The QVideoWindowControl class provides a media control for rendering video to a window. - \since 1.0 - - - The winId() property QVideoWindowControl allows a platform specific window - ID to be set as the video render target of a QMediaService. The - displayRect() property is used to set the region of the window the video - should be rendered to, and the aspectRatioMode() property indicates how the - video should be scaled to fit the displayRect(). - - \snippet doc/src/snippets/multimedia-snippets/video.cpp Video window control - - QVideoWindowControl is one of a number of possible video output controls. - - The interface name of QVideoWindowControl is \c com.nokia.Qt.QVideoWindowControl/1.0 as - defined in QVideoWindowControl_iid. - - \sa QMediaService::requestControl(), QVideoWidget -*/ - -/*! - \macro QVideoWindowControl_iid - - \c com.nokia.Qt.QVideoWindowControl/1.0 - - Defines the interface name of the QVideoWindowControl class. - - \relates QVideoWindowControl -*/ - -/*! - Constructs a new video window control with the given \a parent. -*/ -QVideoWindowControl::QVideoWindowControl(QObject *parent) - : QMediaControl(parent) -{ -} - -/*! - Destroys a video window control. -*/ -QVideoWindowControl::~QVideoWindowControl() -{ -} - -/*! - \fn QVideoWindowControl::winId() const - - Returns the ID of the window a video overlay end point renders to. - \since 1.0 -*/ - -/*! - \fn QVideoWindowControl::setWinId(WId id) - - Sets the \a id of the window a video overlay end point renders to. - \since 1.0 -*/ - -/*! - \fn QVideoWindowControl::displayRect() const - Returns the sub-rect of a window where video is displayed. - \since 1.0 -*/ - -/*! - \fn QVideoWindowControl::setDisplayRect(const QRect &rect) - Sets the sub-\a rect of a window where video is displayed. - \since 1.0 -*/ - -/*! - \fn QVideoWindowControl::isFullScreen() const - - Identifies if a video overlay is a fullScreen overlay. - - Returns true if the video overlay is fullScreen, and false otherwise. - \since 1.0 -*/ - -/*! - \fn QVideoWindowControl::setFullScreen(bool fullScreen) - - Sets whether a video overlay is a \a fullScreen overlay. - \since 1.0 -*/ - -/*! - \fn QVideoWindowControl::fullScreenChanged(bool fullScreen) - - Signals that the \a fullScreen state of a video overlay has changed. - \since 1.0 -*/ - -/*! - \fn QVideoWindowControl::repaint() - - Repaints the last frame. - \since 1.0 -*/ - -/*! - \fn QVideoWindowControl::nativeSize() const - - Returns a suggested size for the video display based on the resolution and aspect ratio of the - video. - \since 1.0 -*/ - -/*! - \fn QVideoWindowControl::nativeSizeChanged() - - Signals that the native dimensions of the video have changed. - \since 1.0 -*/ - - -/*! - \fn QVideoWindowControl::aspectRatioMode() const - - Returns how video is scaled to fit the display region with respect to its aspect ratio. - \since 1.0 -*/ - -/*! - \fn QVideoWindowControl::setAspectRatioMode(Qt::AspectRatioMode mode) - - Sets the aspect ratio \a mode which determines how video is scaled to the fit the display region - with respect to its aspect ratio. - \since 1.0 -*/ - -/*! - \fn QVideoWindowControl::brightness() const - - Returns the brightness adjustment applied to a video overlay. - - Valid brightness values range between -100 and 100, the default is 0. - \since 1.0 -*/ - -/*! - \fn QVideoWindowControl::setBrightness(int brightness) - - Sets a \a brightness adjustment for a video overlay. - - Valid brightness values range between -100 and 100, the default is 0. - \since 1.0 -*/ - -/*! - \fn QVideoWindowControl::brightnessChanged(int brightness) - - Signals that a video overlay's \a brightness adjustment has changed. - \since 1.0 -*/ - -/*! - \fn QVideoWindowControl::contrast() const - - Returns the contrast adjustment applied to a video overlay. - - Valid contrast values range between -100 and 100, the default is 0. - \since 1.0 -*/ - -/*! - \fn QVideoWindowControl::setContrast(int contrast) - - Sets the \a contrast adjustment for a video overlay. - - Valid contrast values range between -100 and 100, the default is 0. - \since 1.0 -*/ - -/*! - \fn QVideoWindowControl::contrastChanged(int contrast) - - Signals that a video overlay's \a contrast adjustment has changed. - \since 1.0 -*/ - -/*! - \fn QVideoWindowControl::hue() const - - Returns the hue adjustment applied to a video overlay. - - Value hue values range between -100 and 100, the default is 0. - \since 1.0 -*/ - -/*! - \fn QVideoWindowControl::setHue(int hue) - - Sets a \a hue adjustment for a video overlay. - - Valid hue values range between -100 and 100, the default is 0. - \since 1.0 -*/ - -/*! - \fn QVideoWindowControl::hueChanged(int hue) - - Signals that a video overlay's \a hue adjustment has changed. - \since 1.0 -*/ - -/*! - \fn QVideoWindowControl::saturation() const - - Returns the saturation adjustment applied to a video overlay. - - Value saturation values range between -100 and 100, the default is 0. - \since 1.0 -*/ - -/*! - \fn QVideoWindowControl::setSaturation(int saturation) - Sets a \a saturation adjustment for a video overlay. - - Valid saturation values range between -100 and 100, the default is 0. - \since 1.0 -*/ - -/*! - \fn QVideoWindowControl::saturationChanged(int saturation) - - Signals that a video overlay's \a saturation adjustment has changed. - \since 1.0 -*/ - -#include "moc_qvideowindowcontrol.cpp" -QT_END_NAMESPACE - diff --git a/src/multimediakitwidgets/qvideowindowcontrol.h b/src/multimediakitwidgets/qvideowindowcontrol.h deleted file mode 100644 index 590ce64be..000000000 --- a/src/multimediakitwidgets/qvideowindowcontrol.h +++ /dev/null @@ -1,112 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QVIDEOWINDOWCONTROL_H -#define QVIDEOWINDOWCONTROL_H - -#include "qmediacontrol.h" -#include "qvideowidget.h" - -#include - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -QT_MODULE(Multimedia) - - -class Q_MULTIMEDIA_EXPORT QVideoWindowControl : public QMediaControl -{ - Q_OBJECT - -public: - ~QVideoWindowControl(); - - virtual WId winId() const = 0; - virtual void setWinId(WId id) = 0; - - virtual QRect displayRect() const = 0; - virtual void setDisplayRect(const QRect &rect) = 0; - - virtual bool isFullScreen() const = 0; - virtual void setFullScreen(bool fullScreen) = 0; - - virtual void repaint() = 0; - - virtual QSize nativeSize() const = 0; - - virtual Qt::AspectRatioMode aspectRatioMode() const = 0; - virtual void setAspectRatioMode(Qt::AspectRatioMode mode) = 0; - - virtual int brightness() const = 0; - virtual void setBrightness(int brightness) = 0; - - virtual int contrast() const = 0; - virtual void setContrast(int contrast) = 0; - - virtual int hue() const = 0; - virtual void setHue(int hue) = 0; - - virtual int saturation() const = 0; - virtual void setSaturation(int saturation) = 0; - -Q_SIGNALS: - void fullScreenChanged(bool fullScreen); - void brightnessChanged(int brightness); - void contrastChanged(int contrast); - void hueChanged(int hue); - void saturationChanged(int saturation); - void nativeSizeChanged(); - -protected: - QVideoWindowControl(QObject *parent = 0); -}; - -#define QVideoWindowControl_iid "com.nokia.Qt.QVideoWindowControl/1.0" -Q_MEDIA_DECLARE_CONTROL(QVideoWindowControl, QVideoWindowControl_iid) - -QT_END_NAMESPACE - -QT_END_HEADER - - -#endif diff --git a/src/multimediawidgets/multimediawidgets.pro b/src/multimediawidgets/multimediawidgets.pro new file mode 100644 index 000000000..9251f2f71 --- /dev/null +++ b/src/multimediawidgets/multimediawidgets.pro @@ -0,0 +1,68 @@ +load(qt_module) + +# distinct from QtMultimedia +TARGET = QtMultimediaWidgets +QPRO_PWD = $$PWD +QT = core gui multimedia-private widgets + +CONFIG += module no_private_qt_headers_warning +MODULE_PRI += ../../modules/qt_multimediawidgets.pri + +contains(QT_CONFIG, opengl) | contains(QT_CONFIG, opengles2) { + QT += opengl +} else { + DEFINES += QT_NO_OPENGL +} + +!static:DEFINES += QT_MAKEDLL +DEFINES += QT_BUILD_MULTIMEDIAWIDGETS_LIB + +load(qt_module_config) + +PRIVATE_HEADERS += \ + qvideowidget_p.h \ + qpaintervideosurface_p.h \ + +PUBLIC_HEADERS += \ + qtmultimediawidgetdefs.h \ + qtmultimediawidgetsversion.h \ + qcameraviewfinder.h \ + qgraphicsvideoitem.h \ + qvideowidgetcontrol.h \ + qvideowidget.h \ + qvideowindowcontrol.h + +SOURCES += \ + qcameraviewfinder.cpp \ + qpaintervideosurface.cpp \ + qvideowidgetcontrol.cpp \ + qvideowidget.cpp \ + qvideowindowcontrol.cpp \ + +mac:!qpa { +!simulator { + PRIVATE_HEADERS += qpaintervideosurface_mac_p.h + OBJECTIVE_SOURCES += qpaintervideosurface_mac.mm +} + LIBS += -framework AppKit -framework QuartzCore -framework QTKit +} + +maemo6 { + isEqual(QT_ARCH,armv6) { + PRIVATE_HEADERS += qeglimagetexturesurface_p.h + SOURCES += qeglimagetexturesurface.cpp + + SOURCES += qgraphicsvideoitem_maemo6.cpp + + LIBS += -lX11 + } else { + SOURCES += qgraphicsvideoitem.cpp + } +} + +!maemo* { + SOURCES += qgraphicsvideoitem.cpp +} + +HEADERS += $$PUBLIC_HEADERS $$PRIVATE_HEADERS + diff --git a/src/multimediawidgets/qcameraviewfinder.cpp b/src/multimediawidgets/qcameraviewfinder.cpp new file mode 100644 index 000000000..1d3f18549 --- /dev/null +++ b/src/multimediawidgets/qcameraviewfinder.cpp @@ -0,0 +1,113 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include + +#include + +#include +#include +#include +#include + +QT_USE_NAMESPACE + +/*! + \class QCameraViewfinder + + + \brief The QCameraViewfinder class provides a camera viewfinder widget. + + \inmodule QtMultimedia + \ingroup camera + \since 1.1 + + \snippet doc/src/snippets/multimedia-snippets/camera.cpp Camera + +*/ + +class QCameraViewfinderPrivate : public QVideoWidgetPrivate +{ + Q_DECLARE_NON_CONST_PUBLIC(QCameraViewfinder) +public: + QCameraViewfinderPrivate(): + QVideoWidgetPrivate() + { + } +}; + +/*! + Constructs a new camera viewfinder widget. + + The \a parent is passed to QVideoWidget. +*/ + +QCameraViewfinder::QCameraViewfinder(QWidget *parent) + :QVideoWidget(*new QCameraViewfinderPrivate, parent) +{ +} + +/*! + Destroys a camera viewfinder widget. +*/ +QCameraViewfinder::~QCameraViewfinder() +{ +} + +/*! + \reimp + \since 1.1 +*/ +QMediaObject *QCameraViewfinder::mediaObject() const +{ + return QVideoWidget::mediaObject(); +} + +/*! + \reimp + \since 1.1 +*/ +bool QCameraViewfinder::setMediaObject(QMediaObject *object) +{ + return QVideoWidget::setMediaObject(object); +} + +#include "moc_qcameraviewfinder.cpp" diff --git a/src/multimediawidgets/qcameraviewfinder.h b/src/multimediawidgets/qcameraviewfinder.h new file mode 100644 index 000000000..4ac39ebb9 --- /dev/null +++ b/src/multimediawidgets/qcameraviewfinder.h @@ -0,0 +1,90 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QCAMERAVIEWFINDER_H +#define QCAMERAVIEWFINDER_H + +#include +#include +#include +#include +#include + +#include +#include +#include +#include + +#include + +QT_BEGIN_HEADER + +QT_BEGIN_NAMESPACE + +QT_MODULE(Multimedia) + + +class QCamera; + +class QCameraViewfinderPrivate; +class Q_MULTIMEDIA_EXPORT QCameraViewfinder : public QVideoWidget +{ + Q_OBJECT +public: + QCameraViewfinder(QWidget *parent = 0); + ~QCameraViewfinder(); + + QMediaObject *mediaObject() const; + +protected: + bool setMediaObject(QMediaObject *object); + +private: + Q_DISABLE_COPY(QCameraViewfinder) + Q_DECLARE_PRIVATE(QCameraViewfinder) +}; + +QT_END_NAMESPACE + +QT_END_HEADER + + +#endif // QCAMERA_H diff --git a/src/multimediawidgets/qeglimagetexturesurface.cpp b/src/multimediawidgets/qeglimagetexturesurface.cpp new file mode 100644 index 000000000..dfab86c90 --- /dev/null +++ b/src/multimediawidgets/qeglimagetexturesurface.cpp @@ -0,0 +1,554 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include +#include + +#include +#include +#include +#include +#include +#include + + +QT_BEGIN_NAMESPACE + +//#define DEBUG_OMAPFB_SURFACE + +const QAbstractVideoBuffer::HandleType EGLImageTextureHandle = +QAbstractVideoBuffer::HandleType(QAbstractVideoBuffer::UserHandle+3434); + +/*! + \class QOmapFbVideoSurface + \internal + \since 1.2 +*/ + +/*! +*/ +QEglImageTextureSurface::QEglImageTextureSurface(QObject *parent) + : QAbstractVideoSurface(parent) + , m_context(0) + , m_program(0) + , m_pixelFormat(QVideoFrame::Format_Invalid) + , m_ready(false) + , m_colorKey(49,0,49) + , m_fallbackSurface(0) + , m_fallbackSurfaceActive(false) +{ + m_fallbackSurface = new QPainterVideoSurface(this); +} + +/*! +*/ +QEglImageTextureSurface::~QEglImageTextureSurface() +{ + if (isActive()) + stop(); +} + +/*! + \since 1.2 +*/ +QList QEglImageTextureSurface::supportedPixelFormats( + QAbstractVideoBuffer::HandleType handleType) const +{ +#ifdef DEBUG_OMAPFB_SURFACE + qDebug() << Q_FUNC_INFO << handleType; +#endif + + if (handleType == EGLImageTextureHandle) { + return QList() + << QVideoFrame::Format_RGB32 + << QVideoFrame::Format_ARGB32; + } + + return m_fallbackSurface->supportedPixelFormats(handleType); +} + +const char *qt_glsl_eglTextureVertexShaderProgram = + "attribute highp vec4 vertexCoordArray;\n" + "attribute mediump vec2 textureCoordArray;\n" + "uniform highp mat4 positionMatrix;\n" + "varying mediump vec2 textureCoord;\n" + "void main (void)\n" + "{\n" + " gl_Position = positionMatrix * vertexCoordArray;\n" + " textureCoord = textureCoordArray;\n" + "}"; + +static const char* qt_glsl_eglTextureShaderProgram = + "#extension GL_OES_EGL_image_external: enable\n" + "\n" + "uniform samplerExternalOES texRgb;\n" + "varying mediump vec2 textureCoord;\n" + "\n" + "void main (void)\n" + "{\n" + " gl_FragColor = texture2D(texRgb, textureCoord);\n" + "}"; + + +/*! + \since 1.2 +*/ +bool QEglImageTextureSurface::start(const QVideoSurfaceFormat &format) +{ +#ifdef DEBUG_OMAPFB_SURFACE + qDebug() << Q_FUNC_INFO << format; +#endif + + m_fallbackSurfaceActive = false; + if (format.handleType() != EGLImageTextureHandle) { + qWarning() << Q_FUNC_INFO << "Non EGLImageTextureHandle based format requested, fallback to QPainterVideoSurface"; + connect(m_fallbackSurface, SIGNAL(activeChanged(bool)), + this, SIGNAL(activeChanged(bool))); + connect(m_fallbackSurface, SIGNAL(surfaceFormatChanged(QVideoSurfaceFormat)), + this, SIGNAL(surfaceFormatChanged(QVideoSurfaceFormat))); + connect(m_fallbackSurface, SIGNAL(supportedFormatsChanged()), + this, SIGNAL(supportedFormatsChanged())); + connect(m_fallbackSurface, SIGNAL(nativeResolutionChanged(QSize)), + this, SIGNAL(nativeResolutionChanged(QSize))); + connect(m_fallbackSurface, SIGNAL(frameChanged()), + this, SIGNAL(frameChanged())); + + if (m_fallbackSurface->start(format)) { + m_fallbackSurfaceActive = true; + QAbstractVideoSurface::start(format); + } else { + qWarning() << Q_FUNC_INFO << "failed to start video surface:" << m_fallbackSurface->error(); + setError(m_fallbackSurface->error()); + + disconnect(m_fallbackSurface, SIGNAL(activeChanged(bool)), + this, SIGNAL(activeChanged(bool))); + disconnect(m_fallbackSurface, SIGNAL(surfaceFormatChanged(QVideoSurfaceFormat)), + this, SIGNAL(surfaceFormatChanged(QVideoSurfaceFormat))); + disconnect(m_fallbackSurface, SIGNAL(supportedFormatsChanged()), + this, SIGNAL(supportedFormatsChanged())); + disconnect(m_fallbackSurface, SIGNAL(nativeResolutionChanged(QSize)), + this, SIGNAL(nativeResolutionChanged(QSize))); + disconnect(m_fallbackSurface, SIGNAL(frameChanged()), + this, SIGNAL(frameChanged())); + } + + return m_fallbackSurfaceActive; + } + + QAbstractVideoSurface::Error error = NoError; + + if (isActive()) + stop(); + + if (format.frameSize().isEmpty()) { + setError(UnsupportedFormatError); + } else if (m_context) { + m_context->makeCurrent(); + m_program = new QGLShaderProgram(m_context, this); + + if (!m_program->addShaderFromSourceCode(QGLShader::Vertex, qt_glsl_eglTextureVertexShaderProgram)) { + qWarning("QOmapFbVideoSurface: Vertex shader compile error %s", + qPrintable(m_program->log())); + error = ResourceError; + } + + if (error == NoError + && !m_program->addShaderFromSourceCode(QGLShader::Fragment, qt_glsl_eglTextureShaderProgram)) { + qWarning("QOmapFbVideoSurface: Vertex shader compile error %s", + qPrintable(m_program->log())); + error = QAbstractVideoSurface::ResourceError; + } + + if (error == NoError) { + m_program->bindAttributeLocation("textureCoordArray", 1); + if(!m_program->link()) { + qWarning("QOmapFbVideoSurface: Shader link error %s", qPrintable(m_program->log())); + m_program->removeAllShaders(); + error = QAbstractVideoSurface::ResourceError; + } + } + + if (error != QAbstractVideoSurface::NoError) { + delete m_program; + m_program = 0; + } + } + + if (error == QAbstractVideoSurface::NoError) { + m_scanLineDirection = format.scanLineDirection(); + m_frameSize = format.frameSize(); + m_pixelFormat = format.pixelFormat(); + m_frameSize = format.frameSize(); + m_sourceRect = format.viewport(); + m_ready = true; + + return QAbstractVideoSurface::start(format); + } + + QAbstractVideoSurface::stop(); + return false; +} + +/*! + \since 1.2 +*/ +void QEglImageTextureSurface::stop() +{ +#ifdef DEBUG_OMAPFB_SURFACE + qDebug() << Q_FUNC_INFO; +#endif + + if (m_fallbackSurfaceActive) { + m_fallbackSurface->stop(); + m_fallbackSurfaceActive = false; + + disconnect(m_fallbackSurface, SIGNAL(activeChanged(bool)), + this, SIGNAL(activeChanged(bool))); + disconnect(m_fallbackSurface, SIGNAL(surfaceFormatChanged(QVideoSurfaceFormat)), + this, SIGNAL(surfaceFormatChanged(QVideoSurfaceFormat))); + disconnect(m_fallbackSurface, SIGNAL(supportedFormatsChanged()), + this, SIGNAL(supportedFormatsChanged())); + disconnect(m_fallbackSurface, SIGNAL(nativeResolutionChanged(QSize)), + this, SIGNAL(nativeResolutionChanged(QSize))); + disconnect(m_fallbackSurface, SIGNAL(frameChanged()), + this, SIGNAL(frameChanged())); + + m_ready = false; + QAbstractVideoSurface::stop(); + } + + if (isActive()) { + if (m_context) + m_context->makeCurrent(); + m_frame = QVideoFrame(); + + m_program->removeAllShaders(); + delete m_program; + m_program = 0; + m_ready = false; + + QAbstractVideoSurface::stop(); + } +} + +/*! + \since 1.2 +*/ +bool QEglImageTextureSurface::present(const QVideoFrame &frame) +{ + if (m_fallbackSurfaceActive) { + if (m_fallbackSurface->present(frame)) { + return true; + } else { + setError(m_fallbackSurface->error()); + stop(); + return false; + } + } + + if (!m_ready) { + if (!isActive()) + setError(StoppedError); + else + m_frame = frame; + } else if (frame.isValid() + && (frame.pixelFormat() != m_pixelFormat || frame.size() != m_frameSize)) { + setError(IncorrectFormatError); + qWarning() << "Received frame of incorrect format, stopping the surface"; + + stop(); + } else { + if (m_context) + m_context->makeCurrent(); + m_frame = frame; + m_ready = false; + emit frameChanged(); + return true; + } + return false; +} + +/*! + \since 1.2 +*/ +int QEglImageTextureSurface::brightness() const +{ + return m_fallbackSurface->brightness(); +} + +/*! + \since 1.2 +*/ +void QEglImageTextureSurface::setBrightness(int brightness) +{ + m_fallbackSurface->setBrightness(brightness); +} + +/*! + \since 1.2 +*/ +int QEglImageTextureSurface::contrast() const +{ + return m_fallbackSurface->contrast(); +} + +/*! + \since 1.2 +*/ +void QEglImageTextureSurface::setContrast(int contrast) +{ + m_fallbackSurface->setContrast(contrast); +} + +/*! + \since 1.2 +*/ +int QEglImageTextureSurface::hue() const +{ + return m_fallbackSurface->hue(); +} + +/*! + \since 1.2 +*/ +void QEglImageTextureSurface::setHue(int hue) +{ + m_fallbackSurface->setHue(hue); +} + +/*! + \since 1.2 +*/ +int QEglImageTextureSurface::saturation() const +{ + return m_fallbackSurface->saturation(); +} + +/*! + \since 1.2 +*/ +void QEglImageTextureSurface::setSaturation(int saturation) +{ + m_fallbackSurface->setSaturation(saturation); +} + +/*! + \since 1.2 +*/ +bool QEglImageTextureSurface::isReady() const +{ + return m_fallbackSurfaceActive ? m_fallbackSurface->isReady() : m_ready; +} + +/*! + \since 1.2 +*/ +void QEglImageTextureSurface::setReady(bool ready) +{ + m_ready = ready; + if (m_fallbackSurfaceActive) + m_fallbackSurface->setReady(ready); +} + +/*! + \since 1.2 +*/ +void QEglImageTextureSurface::paint(QPainter *painter, const QRectF &target, const QRectF &sourceRect) +{ + if (m_fallbackSurfaceActive) { + m_fallbackSurface->paint(painter, target, sourceRect); + return; + } + + if (!isActive() || !m_frame.isValid()) { + painter->fillRect(target, QBrush(Qt::black)); + } else { + const QRectF source( + m_sourceRect.x() + m_sourceRect.width() * sourceRect.x(), + m_sourceRect.y() + m_sourceRect.height() * sourceRect.y(), + m_sourceRect.width() * sourceRect.width(), + m_sourceRect.height() * sourceRect.height()); + + bool stencilTestEnabled = glIsEnabled(GL_STENCIL_TEST); + bool scissorTestEnabled = glIsEnabled(GL_SCISSOR_TEST); + + painter->beginNativePainting(); + + if (stencilTestEnabled) + glEnable(GL_STENCIL_TEST); + if (scissorTestEnabled) + glEnable(GL_SCISSOR_TEST); + + const int width = QGLContext::currentContext()->device()->width(); + const int height = QGLContext::currentContext()->device()->height(); + + const QTransform transform = painter->deviceTransform(); + + const GLfloat wfactor = 2.0 / width; + const GLfloat hfactor = -2.0 / height; + + const GLfloat positionMatrix[4][4] = + { + { + /*(0,0)*/ GLfloat(wfactor * transform.m11() - transform.m13()), + /*(0,1)*/ GLfloat(hfactor * transform.m12() + transform.m13()), + /*(0,2)*/ 0.0, + /*(0,3)*/ GLfloat(transform.m13()) + }, { + /*(1,0)*/ GLfloat(wfactor * transform.m21() - transform.m23()), + /*(1,1)*/ GLfloat(hfactor * transform.m22() + transform.m23()), + /*(1,2)*/ 0.0, + /*(1,3)*/ GLfloat(transform.m23()) + }, { + /*(2,0)*/ 0.0, + /*(2,1)*/ 0.0, + /*(2,2)*/ -1.0, + /*(2,3)*/ 0.0 + }, { + /*(3,0)*/ GLfloat(wfactor * transform.dx() - transform.m33()), + /*(3,1)*/ GLfloat(hfactor * transform.dy() + transform.m33()), + /*(3,2)*/ 0.0, + /*(3,3)*/ GLfloat(transform.m33()) + } + }; + + const GLfloat vTop = m_scanLineDirection == QVideoSurfaceFormat::TopToBottom + ? target.top() + : target.bottom() + 1; + const GLfloat vBottom = m_scanLineDirection == QVideoSurfaceFormat::TopToBottom + ? target.bottom() + 1 + : target.top(); + + + const GLfloat vertexCoordArray[] = + { + GLfloat(target.left()) , GLfloat(vBottom), + GLfloat(target.right() + 1), GLfloat(vBottom), + GLfloat(target.left()) , GLfloat(vTop), + GLfloat(target.right() + 1), GLfloat(vTop) + }; + + const GLfloat txLeft = source.left() / m_frameSize.width(); + const GLfloat txRight = source.right() / m_frameSize.width(); + const GLfloat txTop = m_scanLineDirection == QVideoSurfaceFormat::TopToBottom + ? source.top() / m_frameSize.height() + : source.bottom() / m_frameSize.height(); + const GLfloat txBottom = m_scanLineDirection == QVideoSurfaceFormat::TopToBottom + ? source.bottom() / m_frameSize.height() + : source.top() / m_frameSize.height(); + + const GLfloat textureCoordArray[] = + { + txLeft , txBottom, + txRight, txBottom, + txLeft , txTop, + txRight, txTop + }; + + m_program->bind(); + + m_program->enableAttributeArray("vertexCoordArray"); + m_program->enableAttributeArray("textureCoordArray"); + m_program->setAttributeArray("vertexCoordArray", vertexCoordArray, 2); + m_program->setAttributeArray("textureCoordArray", textureCoordArray, 2); + m_program->setUniformValue("positionMatrix", positionMatrix); + m_program->setUniformValue("texRgb", 0); + + //map() binds the external texture + m_frame.map(QAbstractVideoBuffer::ReadOnly); + + glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); + + //it's necessary to unbind the external texture + m_frame.unmap(); + + m_program->release(); + + painter->endNativePainting(); + } +} + +/*! + \fn QOmapFbVideoSurface::frameChanged() + \since 1.2 +*/ + +/*! + \since 1.2 +*/ +const QGLContext *QEglImageTextureSurface::glContext() const +{ + return m_context; +} + +/*! + \since 1.2 +*/ +void QEglImageTextureSurface::setGLContext(QGLContext *context) +{ + if (m_context == context) + return; + + stop(); + + m_context = context; + + m_fallbackSurface->setGLContext(context); + if (m_fallbackSurface->supportedShaderTypes() & QPainterVideoSurface::GlslShader) { + m_fallbackSurface->setShaderType(QPainterVideoSurface::GlslShader); + } else { + m_fallbackSurface->setShaderType(QPainterVideoSurface::FragmentProgramShader); + } + + emit supportedFormatsChanged(); +} + +void QEglImageTextureSurface::viewportDestroyed() +{ + m_context = 0; + m_fallbackSurface->viewportDestroyed(); + + setError(ResourceError); + stop(); +} + +#include "moc_qeglimagetexturesurface_p.cpp" +QT_END_NAMESPACE diff --git a/src/multimediawidgets/qeglimagetexturesurface_p.h b/src/multimediawidgets/qeglimagetexturesurface_p.h new file mode 100644 index 000000000..f56c9da78 --- /dev/null +++ b/src/multimediawidgets/qeglimagetexturesurface_p.h @@ -0,0 +1,150 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QEGLIMAGETEXTURESURFACE_P_H +#define QEGLIMAGETEXTURESURFACE_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 +#include +#include +#include +#include + +#include + +#include +#include +#include + +QT_BEGIN_HEADER + +QT_BEGIN_NAMESPACE + +QT_MODULE(Multimedia) + +class QGLContext; +class QGLShaderProgram; +class QPainterVideoSurface; + +class QEglImageTextureSurface : public QAbstractVideoSurface +{ + Q_OBJECT +public: + explicit QEglImageTextureSurface(QObject *parent = 0); + ~QEglImageTextureSurface(); + + QList supportedPixelFormats( + QAbstractVideoBuffer::HandleType handleType = QAbstractVideoBuffer::NoHandle) const; + + bool start(const QVideoSurfaceFormat &format); + void stop(); + + bool present(const QVideoFrame &frame); + + int brightness() const; + void setBrightness(int brightness); + + int contrast() const; + void setContrast(int contrast); + + int hue() const; + void setHue(int hue); + + int saturation() const; + void setSaturation(int saturation); + + bool isReady() const; + void setReady(bool ready); + + void paint(QPainter *painter, const QRectF &target, const QRectF &source = QRectF(0, 0, 1, 1)); + + const QGLContext *glContext() const; + void setGLContext(QGLContext *context); + + bool isOverlayEnabled() const; + void setOverlayEnabled(bool enabled); + + QRect displayRect() const; + void setDisplayRect(const QRect &rect); + +public Q_SLOTS: + void viewportDestroyed(); + +Q_SIGNALS: + void frameChanged(); + +private: + QGLContext *m_context; + QGLShaderProgram *m_program; + + QVideoFrame m_frame; + + QVideoFrame::PixelFormat m_pixelFormat; + QVideoSurfaceFormat::Direction m_scanLineDirection; + QSize m_frameSize; + QRect m_sourceRect; + bool m_ready; + + QRect m_viewport; + QRect m_displayRect; + QColor m_colorKey; + + QPainterVideoSurface *m_fallbackSurface; + bool m_fallbackSurfaceActive; +}; + +QT_END_NAMESPACE + +QT_END_HEADER + + +#endif diff --git a/src/multimediawidgets/qgraphicsvideoitem.cpp b/src/multimediawidgets/qgraphicsvideoitem.cpp new file mode 100644 index 000000000..120a24f26 --- /dev/null +++ b/src/multimediawidgets/qgraphicsvideoitem.cpp @@ -0,0 +1,432 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qgraphicsvideoitem.h" + +#include +#include +#include +#include + +#include +#include + +#include + +#if !defined(QT_NO_OPENGL) && !defined(QT_OPENGL_ES_1_CL) && !defined(QT_OPENGL_ES_1) +#include +#endif + +Q_DECLARE_METATYPE(QVideoSurfaceFormat) + +QT_BEGIN_NAMESPACE + +class QGraphicsVideoItemPrivate +{ +public: + QGraphicsVideoItemPrivate() + : q_ptr(0) + , surface(0) + , mediaObject(0) + , service(0) + , rendererControl(0) + , aspectRatioMode(Qt::KeepAspectRatio) + , updatePaintDevice(true) + , rect(0.0, 0.0, 320, 240) + { + } + + QGraphicsVideoItem *q_ptr; + + QPainterVideoSurface *surface; + QPointer mediaObject; + QMediaService *service; + QVideoRendererControl *rendererControl; + Qt::AspectRatioMode aspectRatioMode; + bool updatePaintDevice; + QRectF rect; + QRectF boundingRect; + QRectF sourceRect; + QSizeF nativeSize; + + void clearService(); + void updateRects(); + + void _q_present(); + void _q_formatChanged(const QVideoSurfaceFormat &format); + void _q_updateNativeSize(); + void _q_serviceDestroyed(); +}; + +void QGraphicsVideoItemPrivate::clearService() +{ + if (rendererControl) { + surface->stop(); + rendererControl->setSurface(0); + service->releaseControl(rendererControl); + rendererControl = 0; + } + if (service) { + QObject::disconnect(service, SIGNAL(destroyed()), q_ptr, SLOT(_q_serviceDestroyed())); + service = 0; + } +} + +void QGraphicsVideoItemPrivate::updateRects() +{ + q_ptr->prepareGeometryChange(); + + if (nativeSize.isEmpty()) { + //this is necessary for item to receive the + //first paint event and configure video surface. + boundingRect = rect; + } else if (aspectRatioMode == Qt::IgnoreAspectRatio) { + boundingRect = rect; + sourceRect = QRectF(0, 0, 1, 1); + } else if (aspectRatioMode == Qt::KeepAspectRatio) { + QSizeF size = nativeSize; + size.scale(rect.size(), Qt::KeepAspectRatio); + + boundingRect = QRectF(0, 0, size.width(), size.height()); + boundingRect.moveCenter(rect.center()); + + sourceRect = QRectF(0, 0, 1, 1); + } else if (aspectRatioMode == Qt::KeepAspectRatioByExpanding) { + boundingRect = rect; + + QSizeF size = rect.size(); + size.scale(nativeSize, Qt::KeepAspectRatio); + + sourceRect = QRectF( + 0, 0, size.width() / nativeSize.width(), size.height() / nativeSize.height()); + sourceRect.moveCenter(QPointF(0.5, 0.5)); + } +} + +void QGraphicsVideoItemPrivate::_q_present() +{ + if (q_ptr->isObscured()) { + q_ptr->update(boundingRect); + surface->setReady(true); + } else { + q_ptr->update(boundingRect); + } +} + +void QGraphicsVideoItemPrivate::_q_updateNativeSize() +{ + const QSize &size = surface->surfaceFormat().sizeHint(); + if (nativeSize != size) { + nativeSize = size; + + updateRects(); + emit q_ptr->nativeSizeChanged(nativeSize); + } +} + +void QGraphicsVideoItemPrivate::_q_serviceDestroyed() +{ + rendererControl = 0; + service = 0; + + surface->stop(); +} + + +/*! + \class QGraphicsVideoItem + + \brief The QGraphicsVideoItem class provides a graphics item which display video produced by a QMediaObject. + + \inmodule QtMultimedia + \ingroup multimedia + \since 1.0 + + Attaching a QGraphicsVideoItem to a QMediaObject allows it to display + the video or image output of that media object. A QGraphicsVideoItem + is attached to a media object by passing a pointer to the QMediaObject + to the setMediaObject() function. + + \snippet doc/src/snippets/multimedia-snippets/video.cpp Video graphics item + + \bold {Note}: Only a single display output can be attached to a media + object at one time. + + \sa QMediaObject, QMediaPlayer, QVideoWidget +*/ + +/*! + Constructs a graphics item that displays video. + + The \a parent is passed to QGraphicsItem. +*/ +QGraphicsVideoItem::QGraphicsVideoItem(QGraphicsItem *parent) + : QGraphicsObject(parent) + , d_ptr(new QGraphicsVideoItemPrivate) +{ + d_ptr->q_ptr = this; + d_ptr->surface = new QPainterVideoSurface; + + qRegisterMetaType(); + + connect(d_ptr->surface, SIGNAL(frameChanged()), this, SLOT(_q_present())); + connect(d_ptr->surface, SIGNAL(surfaceFormatChanged(QVideoSurfaceFormat)), + this, SLOT(_q_updateNativeSize()), Qt::QueuedConnection); +} + +/*! + Destroys a video graphics item. +*/ +QGraphicsVideoItem::~QGraphicsVideoItem() +{ + if (d_ptr->rendererControl) { + d_ptr->rendererControl->setSurface(0); + d_ptr->service->releaseControl(d_ptr->rendererControl); + } + + delete d_ptr->surface; + delete d_ptr; +} + +/*! + \property QGraphicsVideoItem::mediaObject + \brief the media object which provides the video displayed by a graphics + item. + \since 1.0 +*/ + +QMediaObject *QGraphicsVideoItem::mediaObject() const +{ + return d_func()->mediaObject; +} + +/*! + \internal + \since 1.0 +*/ +bool QGraphicsVideoItem::setMediaObject(QMediaObject *object) +{ + Q_D(QGraphicsVideoItem); + + if (object == d->mediaObject) + return true; + + d->clearService(); + + d->mediaObject = object; + + if (d->mediaObject) { + d->service = d->mediaObject->service(); + + if (d->service) { + QMediaControl *control = d->service->requestControl(QVideoRendererControl_iid); + if (control) { + d->rendererControl = qobject_cast(control); + + if (d->rendererControl) { + //don't set the surface untill the item is painted + //at least once and the surface is configured + if (!d->updatePaintDevice) + d->rendererControl->setSurface(d->surface); + else + update(boundingRect()); + + connect(d->service, SIGNAL(destroyed()), this, SLOT(_q_serviceDestroyed())); + + return true; + } + if (control) + d->service->releaseControl(control); + } + } + } + + d->mediaObject = 0; + return false; +} + +/*! + \property QGraphicsVideoItem::aspectRatioMode + \brief how a video is scaled to fit the graphics item's size. + \since 1.0 +*/ + +Qt::AspectRatioMode QGraphicsVideoItem::aspectRatioMode() const +{ + return d_func()->aspectRatioMode; +} + +void QGraphicsVideoItem::setAspectRatioMode(Qt::AspectRatioMode mode) +{ + Q_D(QGraphicsVideoItem); + + d->aspectRatioMode = mode; + d->updateRects(); +} + +/*! + \property QGraphicsVideoItem::offset + \brief the video item's offset. + + QGraphicsVideoItem will draw video using the offset for its top left + corner. + \since 1.0 +*/ + +QPointF QGraphicsVideoItem::offset() const +{ + return d_func()->rect.topLeft(); +} + +void QGraphicsVideoItem::setOffset(const QPointF &offset) +{ + Q_D(QGraphicsVideoItem); + + d->rect.moveTo(offset); + d->updateRects(); +} + +/*! + \property QGraphicsVideoItem::size + \brief the video item's size. + + QGraphicsVideoItem will draw video scaled to fit size according to its + fillMode. + \since 1.0 +*/ + +QSizeF QGraphicsVideoItem::size() const +{ + return d_func()->rect.size(); +} + +void QGraphicsVideoItem::setSize(const QSizeF &size) +{ + Q_D(QGraphicsVideoItem); + + d->rect.setSize(size.isValid() ? size : QSizeF(0, 0)); + d->updateRects(); +} + +/*! + \property QGraphicsVideoItem::nativeSize + \brief the native size of the video. + \since 1.0 +*/ + +QSizeF QGraphicsVideoItem::nativeSize() const +{ + return d_func()->nativeSize; +} + +/*! + \fn QGraphicsVideoItem::nativeSizeChanged(const QSizeF &size) + + Signals that the native \a size of the video has changed. + \since 1.0 +*/ + +/*! + \reimp + \since 1.0 +*/ +QRectF QGraphicsVideoItem::boundingRect() const +{ + return d_func()->boundingRect; +} + +/*! + \reimp + \since 1.0 +*/ +void QGraphicsVideoItem::paint( + QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) +{ + Q_D(QGraphicsVideoItem); + + Q_UNUSED(option); + Q_UNUSED(widget); + + if (d->surface && d->updatePaintDevice) { + d->updatePaintDevice = false; +#if !defined(QT_NO_OPENGL) && !defined(QT_OPENGL_ES_1_CL) && !defined(QT_OPENGL_ES_1) + if (widget) + connect(widget, SIGNAL(destroyed()), d->surface, SLOT(viewportDestroyed())); + + d->surface->setGLContext(const_cast(QGLContext::currentContext())); + if (d->surface->supportedShaderTypes() & QPainterVideoSurface::GlslShader) { + d->surface->setShaderType(QPainterVideoSurface::GlslShader); + } else { + d->surface->setShaderType(QPainterVideoSurface::FragmentProgramShader); + } +#endif + if (d->rendererControl && d->rendererControl->surface() != d->surface) + d->rendererControl->setSurface(d->surface); + } + + if (d->surface && d->surface->isActive()) { + d->surface->paint(painter, d->boundingRect, d->sourceRect); + d->surface->setReady(true); + } +} + +/*! + \reimp + + \internal + \since 1.0 +*/ +QVariant QGraphicsVideoItem::itemChange(GraphicsItemChange change, const QVariant &value) +{ + return QGraphicsItem::itemChange(change, value); +} + +/*! + \internal + \since 1.0 +*/ +void QGraphicsVideoItem::timerEvent(QTimerEvent *event) +{ + QGraphicsObject::timerEvent(event); +} + +#include "moc_qgraphicsvideoitem.cpp" +QT_END_NAMESPACE diff --git a/src/multimediawidgets/qgraphicsvideoitem.h b/src/multimediawidgets/qgraphicsvideoitem.h new file mode 100644 index 000000000..cf8913417 --- /dev/null +++ b/src/multimediawidgets/qgraphicsvideoitem.h @@ -0,0 +1,115 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QGRAPHICSVIDEOITEM_H +#define QGRAPHICSVIDEOITEM_H + +#include + +#include +#include + +QT_BEGIN_HEADER + +QT_BEGIN_NAMESPACE + +QT_MODULE(Multimedia) + +class QVideoSurfaceFormat; +QT_END_NAMESPACE + +QT_BEGIN_NAMESPACE + +class QGraphicsVideoItemPrivate; +class Q_MULTIMEDIA_EXPORT QGraphicsVideoItem : public QGraphicsObject, public QMediaBindableInterface +{ + Q_OBJECT + Q_INTERFACES(QMediaBindableInterface) + Q_PROPERTY(QMediaObject* mediaObject READ mediaObject WRITE setMediaObject) + Q_PROPERTY(Qt::AspectRatioMode aspectRatioMode READ aspectRatioMode WRITE setAspectRatioMode) + Q_PROPERTY(QPointF offset READ offset WRITE setOffset) + Q_PROPERTY(QSizeF size READ size WRITE setSize) + Q_PROPERTY(QSizeF nativeSize READ nativeSize NOTIFY nativeSizeChanged) +public: + QGraphicsVideoItem(QGraphicsItem *parent = 0); + ~QGraphicsVideoItem(); + + QMediaObject *mediaObject() const; + + Qt::AspectRatioMode aspectRatioMode() const; + void setAspectRatioMode(Qt::AspectRatioMode mode); + + QPointF offset() const; + void setOffset(const QPointF &offset); + + QSizeF size() const; + void setSize(const QSizeF &size); + + QSizeF nativeSize() const; + + QRectF boundingRect() const; + + void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0); + +Q_SIGNALS: + void nativeSizeChanged(const QSizeF &size); + +protected: + void timerEvent(QTimerEvent *event); + QVariant itemChange(GraphicsItemChange change, const QVariant &value); + + bool setMediaObject(QMediaObject *object); + + QGraphicsVideoItemPrivate *d_ptr; + +private: + Q_DECLARE_PRIVATE(QGraphicsVideoItem) + Q_PRIVATE_SLOT(d_func(), void _q_present()) + Q_PRIVATE_SLOT(d_func(), void _q_updateNativeSize()) + Q_PRIVATE_SLOT(d_func(), void _q_serviceDestroyed()) +}; + +QT_END_NAMESPACE + +QT_END_HEADER + + +#endif diff --git a/src/multimediawidgets/qgraphicsvideoitem_maemo6.cpp b/src/multimediawidgets/qgraphicsvideoitem_maemo6.cpp new file mode 100644 index 000000000..aa55f0420 --- /dev/null +++ b/src/multimediawidgets/qgraphicsvideoitem_maemo6.cpp @@ -0,0 +1,498 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qgraphicsvideoitem.h" + +#include +#include +#include + +#include + +#include +#include +#include +#include +#include + +#include + +#include + +#if !defined(QT_NO_OPENGL) && !defined(QT_OPENGL_ES_1_CL) && !defined(QT_OPENGL_ES_1) +#include +#endif + +//#define ENABLE_OVERLAY + +namespace +{ +//XInitThreads is necessary for gltexturesink element. +//To ensure it's called before main() it's better to link to +//libQtMultimedia.so directly, not when QML multimedia plugin is loaded. +class InitThreads +{ +public: + InitThreads() + { + XInitThreads(); + } +} _initThreads; +} + +Q_DECLARE_METATYPE(QVideoSurfaceFormat) + +QT_BEGIN_NAMESPACE + +class QGraphicsVideoItemPrivate +{ +public: + QGraphicsVideoItemPrivate() + : q_ptr(0) + , surface(0) + , mediaObject(0) + , service(0) + , rendererControl(0) + , aspectRatioMode(Qt::KeepAspectRatio) + , updatePaintDevice(true) + , rect(0.0, 0.0, 320, 240) + { + } + + QGraphicsVideoItem *q_ptr; + + QEglImageTextureSurface *surface; + QPointer mediaObject; + QMediaService *service; + QVideoRendererControl *rendererControl; + Qt::AspectRatioMode aspectRatioMode; + bool updatePaintDevice; + QRectF rect; + QRectF boundingRect; + QRectF sourceRect; + QSizeF nativeSize; + + void clearService(); + void updateRects(); + + void _q_present(); + void _q_formatChanged(const QVideoSurfaceFormat &format); + void _q_updateNativeSize(); + void _q_serviceDestroyed(); +}; + +void QGraphicsVideoItemPrivate::clearService() +{ + if (rendererControl) { + surface->stop(); + rendererControl->setSurface(0); + service->releaseControl(rendererControl); + rendererControl = 0; + } + if (service) { + QObject::disconnect(service, SIGNAL(destroyed()), q_ptr, SLOT(_q_serviceDestroyed())); + service = 0; + } +} + +void QGraphicsVideoItemPrivate::updateRects() +{ + q_ptr->prepareGeometryChange(); + + if (nativeSize.isEmpty()) { + //this is necessary for item to receive the + //first paint event and configure video surface. + boundingRect = rect; + } else if (aspectRatioMode == Qt::IgnoreAspectRatio) { + boundingRect = rect; + sourceRect = QRectF(0, 0, 1, 1); + } else if (aspectRatioMode == Qt::KeepAspectRatio) { + QSizeF size = nativeSize; + size.scale(rect.size(), Qt::KeepAspectRatio); + + boundingRect = QRectF(0, 0, size.width(), size.height()); + boundingRect.moveCenter(rect.center()); + + sourceRect = QRectF(0, 0, 1, 1); + } else if (aspectRatioMode == Qt::KeepAspectRatioByExpanding) { + boundingRect = rect; + + QSizeF size = rect.size(); + size.scale(nativeSize, Qt::KeepAspectRatio); + + sourceRect = QRectF( + 0, 0, size.width() / nativeSize.width(), size.height() / nativeSize.height()); + sourceRect.moveCenter(QPointF(0.5, 0.5)); + } +} + +void QGraphicsVideoItemPrivate::_q_present() +{ + if (q_ptr->isObscured()) { + q_ptr->update(boundingRect); + surface->setReady(true); + } else { + q_ptr->update(boundingRect); + } +} + +void QGraphicsVideoItemPrivate::_q_updateNativeSize() +{ + QSize size = surface->surfaceFormat().sizeHint(); + if (size.isEmpty()) + size = rendererControl->property("nativeSize").toSize(); + + if (nativeSize != size) { + nativeSize = size; + + updateRects(); + emit q_ptr->nativeSizeChanged(nativeSize); + } +} + +void QGraphicsVideoItemPrivate::_q_serviceDestroyed() +{ + rendererControl = 0; + service = 0; + + surface->stop(); +} + + +/*! + \class QGraphicsVideoItem + + \brief The QGraphicsVideoItem class provides a graphics item which display video produced by a QMediaObject. + + \inmodule QtMultimedia + \ingroup multimedia + + Attaching a QGraphicsVideoItem to a QMediaObject allows it to display + the video or image output of that media object. A QGraphicsVideoItem + is attached to a media object by passing a pointer to the QMediaObject + to the setMediaObject() function. + + \code + player = new QMediaPlayer(this); + + QGraphicsVideoItem *item = new QGraphicsVideoItem; + player->setVideoOutput(item); + graphicsView->scene()->addItem(item); + graphicsView->show(); + + player->setMedia(video); + player->play(); + \endcode + + \bold {Note}: Only a single display output can be attached to a media + object at one time. + + \sa QMediaObject, QMediaPlayer, QVideoWidget +*/ + +/*! + Constructs a graphics item that displays video. + + The \a parent is passed to QGraphicsItem. +*/ +QGraphicsVideoItem::QGraphicsVideoItem(QGraphicsItem *parent) + : QGraphicsObject(parent) + , d_ptr(new QGraphicsVideoItemPrivate) +{ + d_ptr->q_ptr = this; + d_ptr->surface = new QEglImageTextureSurface(this); + + qRegisterMetaType(); + + connect(d_ptr->surface, SIGNAL(frameChanged()), this, SLOT(_q_present())); + connect(d_ptr->surface, SIGNAL(surfaceFormatChanged(QVideoSurfaceFormat)), + this, SLOT(_q_updateNativeSize()), Qt::QueuedConnection); +} + +/*! + Destroys a video graphics item. +*/ +QGraphicsVideoItem::~QGraphicsVideoItem() +{ + if (d_ptr->rendererControl) { + d_ptr->rendererControl->setSurface(0); + d_ptr->service->releaseControl(d_ptr->rendererControl); + } + + delete d_ptr->surface; + delete d_ptr; +} + +/*! + \property QGraphicsVideoItem::mediaObject + \brief the media object which provides the video displayed by a graphics + item. +*/ + +QMediaObject *QGraphicsVideoItem::mediaObject() const +{ + return d_func()->mediaObject; +} + +/*! + \internal +*/ +bool QGraphicsVideoItem::setMediaObject(QMediaObject *object) +{ + Q_D(QGraphicsVideoItem); + + if (object == d->mediaObject) + return true; + + d->clearService(); + + d->mediaObject = object; + + if (d->mediaObject) { + d->service = d->mediaObject->service(); + + if (d->service) { + QMediaControl *control = d->service->requestControl(QVideoRendererControl_iid); + if (control) { + d->rendererControl = qobject_cast(control); + + if (d->rendererControl) { + connect(d->rendererControl, SIGNAL(nativeSizeChanged()), + this, SLOT(_q_updateNativeSize()), Qt::QueuedConnection); + d->_q_updateNativeSize(); + //don't set the surface untill the item is painted + //at least once and the surface is configured + if (!d->updatePaintDevice) + d->rendererControl->setSurface(d->surface); + else + update(boundingRect()); + + connect(d->service, SIGNAL(destroyed()), this, SLOT(_q_serviceDestroyed())); + + return true; + } + if (control) + d->service->releaseControl(control); + } + } + } + + d->mediaObject = 0; + return false; +} + +/*! + \property QGraphicsVideoItem::aspectRatioMode + \brief how a video is scaled to fit the graphics item's size. +*/ + +Qt::AspectRatioMode QGraphicsVideoItem::aspectRatioMode() const +{ + return d_func()->aspectRatioMode; +} + +void QGraphicsVideoItem::setAspectRatioMode(Qt::AspectRatioMode mode) +{ + Q_D(QGraphicsVideoItem); + + d->aspectRatioMode = mode; + d->updateRects(); +} + +/*! + \property QGraphicsVideoItem::offset + \brief the video item's offset. + + QGraphicsVideoItem will draw video using the offset for its top left + corner. +*/ + +QPointF QGraphicsVideoItem::offset() const +{ + return d_func()->rect.topLeft(); +} + +void QGraphicsVideoItem::setOffset(const QPointF &offset) +{ + Q_D(QGraphicsVideoItem); + + d->rect.moveTo(offset); + d->updateRects(); +} + +/*! + \property QGraphicsVideoItem::size + \brief the video item's size. + + QGraphicsVideoItem will draw video scaled to fit size according to its + fillMode. +*/ + +QSizeF QGraphicsVideoItem::size() const +{ + return d_func()->rect.size(); +} + +void QGraphicsVideoItem::setSize(const QSizeF &size) +{ + Q_D(QGraphicsVideoItem); + + d->rect.setSize(size.isValid() ? size : QSizeF(0, 0)); + d->updateRects(); +} + +/*! + \property QGraphicsVideoItem::nativeSize + \brief the native size of the video. +*/ + +QSizeF QGraphicsVideoItem::nativeSize() const +{ + return d_func()->nativeSize; +} + +/*! + \fn QGraphicsVideoItem::nativeSizeChanged(const QSizeF &size) + + Signals that the native \a size of the video has changed. +*/ + +/*! + \reimp +*/ +QRectF QGraphicsVideoItem::boundingRect() const +{ + return d_func()->boundingRect; +} + +/*! + \reimp +*/ +void QGraphicsVideoItem::paint( + QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) +{ + Q_D(QGraphicsVideoItem); + + Q_UNUSED(option); + Q_UNUSED(widget); + + if (d->surface && d->rendererControl && d->updatePaintDevice) { + d->updatePaintDevice = false; + + if (widget) + d->rendererControl->setProperty("winId", qulonglong(widget->winId())); + +#if !defined(QT_NO_OPENGL) && !defined(QT_OPENGL_ES_1_CL) && !defined(QT_OPENGL_ES_1) + if (widget) + connect(widget, SIGNAL(destroyed()), d->surface, SLOT(viewportDestroyed())); + + d->surface->setGLContext(const_cast(QGLContext::currentContext())); +#endif + if (d->rendererControl->surface() != d->surface) + d->rendererControl->setSurface(d->surface); + } + + + //overlay doesn't work reliably + + //check if the item is obscured: +#ifdef ENABLE_OVERLAY + if (!isObscured()) { + bool obscured = false; + + if (scene()) { + foreach (QGraphicsItem *item, + scene()->items(mapToScene(boundingRect()), Qt::IntersectsItemBoundingRect) ) { + if (item->flags() & QGraphicsItem::ItemHasNoContents) + continue; + + if (item == this) + break; + + if (collidesWithItem(item)) { + obscured = true; + break; + } + } + } + + d->rendererControl->setProperty("overlayEnabled", !obscured); + } + + if (d->rendererControl->property("overlayEnabled").toBool()) { + QTransform transform = painter->combinedTransform(); + QRect overlayRect = transform.mapRect(d->boundingRect).toRect(); + + d->rendererControl->setProperty("overlayGeometry", overlayRect); + QMetaObject::invokeMethod(d->rendererControl, "repaintOverlay"); + + painter->fillRect(d->boundingRect, + d->rendererControl->property("colorKey").value()); + } else +#endif //ENABLE_OVERLAY + { + if (d->surface && d->surface->isActive()) { + d->surface->paint(painter, d->boundingRect, d->sourceRect); + d->surface->setReady(true); + } + } +} + +/*! + \reimp + + \internal +*/ +QVariant QGraphicsVideoItem::itemChange(GraphicsItemChange change, const QVariant &value) +{ + return QGraphicsItem::itemChange(change, value); +} + +/*! + \internal +*/ +void QGraphicsVideoItem::timerEvent(QTimerEvent *event) +{ + QGraphicsObject::timerEvent(event); +} + +#include "moc_qgraphicsvideoitem.cpp" +QT_END_NAMESPACE diff --git a/src/multimediawidgets/qpaintervideosurface.cpp b/src/multimediawidgets/qpaintervideosurface.cpp new file mode 100644 index 000000000..bd82f7841 --- /dev/null +++ b/src/multimediawidgets/qpaintervideosurface.cpp @@ -0,0 +1,1728 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include +#include + +#include + +#include +#include +#include + +#if !defined(QT_NO_OPENGL) && !defined(QT_OPENGL_ES_1_CL) && !defined(QT_OPENGL_ES_1) +#include +#ifndef GL_CLAMP_TO_EDGE +#define GL_CLAMP_TO_EDGE 0x812F +#endif +#endif + +#include +QT_BEGIN_NAMESPACE + +QVideoSurfacePainter::~QVideoSurfacePainter() +{ +} + +class QVideoSurfaceGenericPainter : public QVideoSurfacePainter +{ +public: + QVideoSurfaceGenericPainter(); + + QList supportedPixelFormats( + QAbstractVideoBuffer::HandleType handleType) const; + + bool isFormatSupported( + const QVideoSurfaceFormat &format, QVideoSurfaceFormat *similar) const; + + QAbstractVideoSurface::Error start(const QVideoSurfaceFormat &format); + void stop(); + + QAbstractVideoSurface::Error setCurrentFrame(const QVideoFrame &frame); + + QAbstractVideoSurface::Error paint( + const QRectF &target, QPainter *painter, const QRectF &source); + + void updateColors(int brightness, int contrast, int hue, int saturation); + +private: + QList m_imagePixelFormats; + QVideoFrame m_frame; + QSize m_imageSize; + QImage::Format m_imageFormat; + QVideoSurfaceFormat::Direction m_scanLineDirection; +}; + +QVideoSurfaceGenericPainter::QVideoSurfaceGenericPainter() + : m_imageFormat(QImage::Format_Invalid) + , m_scanLineDirection(QVideoSurfaceFormat::TopToBottom) +{ + m_imagePixelFormats + << QVideoFrame::Format_RGB32 +#ifndef QT_OPENGL_ES // The raster formats should be a subset of the GL formats. + << QVideoFrame::Format_RGB24 +#endif + << QVideoFrame::Format_ARGB32 + << QVideoFrame::Format_RGB565; +} + +QList QVideoSurfaceGenericPainter::supportedPixelFormats( + QAbstractVideoBuffer::HandleType handleType) const +{ + switch (handleType) { + case QAbstractVideoBuffer::QPixmapHandle: + case QAbstractVideoBuffer::NoHandle: + return m_imagePixelFormats; + default: + ; + } + return QList(); +} + +bool QVideoSurfaceGenericPainter::isFormatSupported( + const QVideoSurfaceFormat &format, QVideoSurfaceFormat *) const +{ + switch (format.handleType()) { + case QAbstractVideoBuffer::QPixmapHandle: + return true; + case QAbstractVideoBuffer::NoHandle: + return m_imagePixelFormats.contains(format.pixelFormat()) + && !format.frameSize().isEmpty(); + default: + ; + } + return false; +} + +QAbstractVideoSurface::Error QVideoSurfaceGenericPainter::start(const QVideoSurfaceFormat &format) +{ + m_frame = QVideoFrame(); + m_imageFormat = QVideoFrame::imageFormatFromPixelFormat(format.pixelFormat()); + m_imageSize = format.frameSize(); + m_scanLineDirection = format.scanLineDirection(); + + const QAbstractVideoBuffer::HandleType t = format.handleType(); + if (t == QAbstractVideoBuffer::NoHandle) { + if (m_imageFormat != QImage::Format_Invalid +#ifdef QT_OPENGL_ES + && format.pixelFormat() != QVideoFrame::Format_RGB24 +#endif + && !m_imageSize.isEmpty()) { + return QAbstractVideoSurface::NoError; + } + } else if (t == QAbstractVideoBuffer::QPixmapHandle) { + return QAbstractVideoSurface::NoError; + } + return QAbstractVideoSurface::UnsupportedFormatError; +} + +void QVideoSurfaceGenericPainter::stop() +{ + m_frame = QVideoFrame(); +} + +QAbstractVideoSurface::Error QVideoSurfaceGenericPainter::setCurrentFrame(const QVideoFrame &frame) +{ + m_frame = frame; + + return QAbstractVideoSurface::NoError; +} + +QAbstractVideoSurface::Error QVideoSurfaceGenericPainter::paint( + const QRectF &target, QPainter *painter, const QRectF &source) +{ + if (!m_frame.isValid()) { + painter->fillRect(target, Qt::black); + return QAbstractVideoSurface::NoError; + } + + if (m_frame.handleType() == QAbstractVideoBuffer::QPixmapHandle) { + painter->drawPixmap(target, m_frame.handle().value(), source); + } else if (m_frame.map(QAbstractVideoBuffer::ReadOnly)) { + QImage image( + m_frame.bits(), + m_imageSize.width(), + m_imageSize.height(), + m_frame.bytesPerLine(), + m_imageFormat); + + if (m_scanLineDirection == QVideoSurfaceFormat::BottomToTop) { + const QTransform oldTransform = painter->transform(); + + painter->scale(1, -1); + painter->translate(0, -target.bottom()); + painter->drawImage( + QRectF(target.x(), 0, target.width(), target.height()), image, source); + painter->setTransform(oldTransform); + } else { + painter->drawImage(target, image, source); + } + + m_frame.unmap(); + } else if (m_frame.isValid()) { + return QAbstractVideoSurface::IncorrectFormatError; + } else { + painter->fillRect(target, Qt::black); + } + return QAbstractVideoSurface::NoError; +} + +void QVideoSurfaceGenericPainter::updateColors(int, int, int, int) +{ +} + +#if !defined(QT_NO_OPENGL) && !defined(QT_OPENGL_ES_1_CL) && !defined(QT_OPENGL_ES_1) + +#ifndef Q_WS_MAC +# ifndef APIENTRYP +# ifdef APIENTRY +# define APIENTRYP APIENTRY * +# else +# define APIENTRY +# define APIENTRYP * +# endif +# endif +#else +# define APIENTRY +# define APIENTRYP * +#endif + +#ifndef GL_TEXTURE0 +# define GL_TEXTURE0 0x84C0 +# define GL_TEXTURE1 0x84C1 +# define GL_TEXTURE2 0x84C2 +#endif +#ifndef GL_PROGRAM_ERROR_STRING_ARB +# define GL_PROGRAM_ERROR_STRING_ARB 0x8874 +#endif + +#ifndef GL_UNSIGNED_SHORT_5_6_5 +# define GL_UNSIGNED_SHORT_5_6_5 33635 +#endif + +class QVideoSurfaceGLPainter : public QVideoSurfacePainter +{ +public: + QVideoSurfaceGLPainter(QGLContext *context); + ~QVideoSurfaceGLPainter(); + QList supportedPixelFormats( + QAbstractVideoBuffer::HandleType handleType) const; + + bool isFormatSupported( + const QVideoSurfaceFormat &format, QVideoSurfaceFormat *similar) const; + + QAbstractVideoSurface::Error setCurrentFrame(const QVideoFrame &frame); + + QAbstractVideoSurface::Error paint( + const QRectF &target, QPainter *painter, const QRectF &source); + + void updateColors(int brightness, int contrast, int hue, int saturation); + void viewportDestroyed(); + +protected: + void initRgbTextureInfo(GLenum internalFormat, GLuint format, GLenum type, const QSize &size); + void initYuv420PTextureInfo(const QSize &size); + void initYv12TextureInfo(const QSize &size); + +#ifndef QT_OPENGL_ES + typedef void (APIENTRY *_glActiveTexture) (GLenum); + _glActiveTexture glActiveTexture; +#endif + + QList m_imagePixelFormats; + QList m_glPixelFormats; + QMatrix4x4 m_colorMatrix; + QVideoFrame m_frame; + + QGLContext *m_context; + QAbstractVideoBuffer::HandleType m_handleType; + QVideoSurfaceFormat::Direction m_scanLineDirection; + QVideoSurfaceFormat::YCbCrColorSpace m_colorSpace; + GLenum m_textureFormat; + GLuint m_textureInternalFormat; + GLenum m_textureType; + int m_textureCount; + GLuint m_textureIds[3]; + int m_textureWidths[3]; + int m_textureHeights[3]; + int m_textureOffsets[3]; + bool m_yuv; +}; + +QVideoSurfaceGLPainter::QVideoSurfaceGLPainter(QGLContext *context) + : m_context(context) + , m_handleType(QAbstractVideoBuffer::NoHandle) + , m_scanLineDirection(QVideoSurfaceFormat::TopToBottom) + , m_colorSpace(QVideoSurfaceFormat::YCbCr_BT601) + , m_textureFormat(0) + , m_textureInternalFormat(0) + , m_textureType(0) + , m_textureCount(0) + , m_yuv(false) +{ +#ifndef QT_OPENGL_ES + glActiveTexture = (_glActiveTexture)m_context->getProcAddress(QLatin1String("glActiveTexture")); +#endif +} + +QVideoSurfaceGLPainter::~QVideoSurfaceGLPainter() +{ +} + +void QVideoSurfaceGLPainter::viewportDestroyed() +{ + m_context = 0; +} + +QList QVideoSurfaceGLPainter::supportedPixelFormats( + QAbstractVideoBuffer::HandleType handleType) const +{ + switch (handleType) { + case QAbstractVideoBuffer::NoHandle: + return m_imagePixelFormats; + case QAbstractVideoBuffer::QPixmapHandle: + case QAbstractVideoBuffer::GLTextureHandle: + return m_glPixelFormats; + default: + ; + } + return QList(); +} + +bool QVideoSurfaceGLPainter::isFormatSupported( + const QVideoSurfaceFormat &format, QVideoSurfaceFormat *) const +{ + if (format.frameSize().isEmpty()) { + return false; + } else { + switch (format.handleType()) { + case QAbstractVideoBuffer::NoHandle: + return m_imagePixelFormats.contains(format.pixelFormat()); + case QAbstractVideoBuffer::QPixmapHandle: + case QAbstractVideoBuffer::GLTextureHandle: + return m_glPixelFormats.contains(format.pixelFormat()); + default: + ; + } + } + return false; +} + +QAbstractVideoSurface::Error QVideoSurfaceGLPainter::setCurrentFrame(const QVideoFrame &frame) +{ + m_frame = frame; + + if (m_handleType == QAbstractVideoBuffer::GLTextureHandle) { + m_textureIds[0] = frame.handle().toInt(); + } else if (m_frame.map(QAbstractVideoBuffer::ReadOnly)) { + m_context->makeCurrent(); + + for (int i = 0; i < m_textureCount; ++i) { + glBindTexture(GL_TEXTURE_2D, m_textureIds[i]); + glTexImage2D( + GL_TEXTURE_2D, + 0, + m_textureInternalFormat, + m_textureWidths[i], + m_textureHeights[i], + 0, + m_textureFormat, + m_textureType, + m_frame.bits() + m_textureOffsets[i]); + glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); + glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); + glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); + glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); + } + m_frame.unmap(); + } else if (m_handleType != QAbstractVideoBuffer::QPixmapHandle && m_frame.isValid()) { + return QAbstractVideoSurface::IncorrectFormatError; + } + + return QAbstractVideoSurface::NoError; +} + +QAbstractVideoSurface::Error QVideoSurfaceGLPainter::paint( + const QRectF &target, QPainter *painter, const QRectF &source) +{ + if (!m_frame.isValid()) { + painter->fillRect(target, Qt::black); + return QAbstractVideoSurface::NoError; + } + + if (m_frame.handleType() == QAbstractVideoBuffer::QPixmapHandle) { + painter->drawPixmap(target, m_frame.handle().value(), source); + } else if (m_frame.isValid()) { + return QAbstractVideoSurface::IncorrectFormatError; + } else { + painter->fillRect(target, Qt::black); + } + return QAbstractVideoSurface::NoError; +} + +void QVideoSurfaceGLPainter::updateColors(int brightness, int contrast, int hue, int saturation) +{ + const qreal b = brightness / 200.0; + const qreal c = contrast / 100.0 + 1.0; + const qreal h = hue / 100.0; + const qreal s = saturation / 100.0 + 1.0; + + const qreal cosH = qCos(M_PI * h); + const qreal sinH = qSin(M_PI * h); + + const qreal h11 = 0.787 * cosH - 0.213 * sinH + 0.213; + const qreal h21 = -0.213 * cosH + 0.143 * sinH + 0.213; + const qreal h31 = -0.213 * cosH - 0.787 * sinH + 0.213; + + const qreal h12 = -0.715 * cosH - 0.715 * sinH + 0.715; + const qreal h22 = 0.285 * cosH + 0.140 * sinH + 0.715; + const qreal h32 = -0.715 * cosH + 0.715 * sinH + 0.715; + + const qreal h13 = -0.072 * cosH + 0.928 * sinH + 0.072; + const qreal h23 = -0.072 * cosH - 0.283 * sinH + 0.072; + const qreal h33 = 0.928 * cosH + 0.072 * sinH + 0.072; + + const qreal sr = (1.0 - s) * 0.3086; + const qreal sg = (1.0 - s) * 0.6094; + const qreal sb = (1.0 - s) * 0.0820; + + const qreal sr_s = sr + s; + const qreal sg_s = sg + s; + const qreal sb_s = sr + s; + + const float m4 = (s + sr + sg + sb) * (0.5 - 0.5 * c + b); + + m_colorMatrix(0, 0) = c * (sr_s * h11 + sg * h21 + sb * h31); + m_colorMatrix(0, 1) = c * (sr_s * h12 + sg * h22 + sb * h32); + m_colorMatrix(0, 2) = c * (sr_s * h13 + sg * h23 + sb * h33); + m_colorMatrix(0, 3) = m4; + + m_colorMatrix(1, 0) = c * (sr * h11 + sg_s * h21 + sb * h31); + m_colorMatrix(1, 1) = c * (sr * h12 + sg_s * h22 + sb * h32); + m_colorMatrix(1, 2) = c * (sr * h13 + sg_s * h23 + sb * h33); + m_colorMatrix(1, 3) = m4; + + m_colorMatrix(2, 0) = c * (sr * h11 + sg * h21 + sb_s * h31); + m_colorMatrix(2, 1) = c * (sr * h12 + sg * h22 + sb_s * h32); + m_colorMatrix(2, 2) = c * (sr * h13 + sg * h23 + sb_s * h33); + m_colorMatrix(2, 3) = m4; + + m_colorMatrix(3, 0) = 0.0; + m_colorMatrix(3, 1) = 0.0; + m_colorMatrix(3, 2) = 0.0; + m_colorMatrix(3, 3) = 1.0; + + if (m_yuv) { + QMatrix4x4 colorSpaceMatrix; + + switch (m_colorSpace) { + case QVideoSurfaceFormat::YCbCr_JPEG: + colorSpaceMatrix = QMatrix4x4( + 1.0, 0.000, 1.402, -0.701, + 1.0, -0.344, -0.714, 0.529, + 1.0, 1.772, 0.000, -0.886, + 0.0, 0.000, 0.000, 1.0000); + break; + case QVideoSurfaceFormat::YCbCr_BT709: + case QVideoSurfaceFormat::YCbCr_xvYCC709: + colorSpaceMatrix = QMatrix4x4( + 1.164, 0.000, 1.793, -0.5727, + 1.164, -0.534, -0.213, 0.3007, + 1.164, 2.115, 0.000, -1.1302, + 0.0, 0.000, 0.000, 1.0000); + break; + default: //BT 601: + colorSpaceMatrix = QMatrix4x4( + 1.164, 0.000, 1.596, -0.8708, + 1.164, -0.392, -0.813, 0.5296, + 1.164, 2.017, 0.000, -1.081, + 0.0, 0.000, 0.000, 1.0000); + } + + m_colorMatrix = m_colorMatrix * colorSpaceMatrix; + } +} + +void QVideoSurfaceGLPainter::initRgbTextureInfo( + GLenum internalFormat, GLuint format, GLenum type, const QSize &size) +{ + m_yuv = false; + m_textureInternalFormat = internalFormat; + m_textureFormat = format; + m_textureType = type; + m_textureCount = 1; + m_textureWidths[0] = size.width(); + m_textureHeights[0] = size.height(); + m_textureOffsets[0] = 0; +} + +void QVideoSurfaceGLPainter::initYuv420PTextureInfo(const QSize &size) +{ + int bytesPerLine = (size.width() + 3) & ~3; + int bytesPerLine2 = (size.width() / 2 + 3) & ~3; + + m_yuv = true; + m_textureInternalFormat = GL_LUMINANCE; + m_textureFormat = GL_LUMINANCE; + m_textureType = GL_UNSIGNED_BYTE; + m_textureCount = 3; + m_textureWidths[0] = bytesPerLine; + m_textureHeights[0] = size.height(); + m_textureOffsets[0] = 0; + m_textureWidths[1] = bytesPerLine2; + m_textureHeights[1] = size.height() / 2; + m_textureOffsets[1] = bytesPerLine * size.height(); + m_textureWidths[2] = bytesPerLine2; + m_textureHeights[2] = size.height() / 2; + m_textureOffsets[2] = bytesPerLine * size.height() + bytesPerLine2 * size.height()/2; +} + +void QVideoSurfaceGLPainter::initYv12TextureInfo(const QSize &size) +{ + int bytesPerLine = (size.width() + 3) & ~3; + int bytesPerLine2 = (size.width() / 2 + 3) & ~3; + + m_yuv = true; + m_textureInternalFormat = GL_LUMINANCE; + m_textureFormat = GL_LUMINANCE; + m_textureType = GL_UNSIGNED_BYTE; + m_textureCount = 3; + m_textureWidths[0] = bytesPerLine; + m_textureHeights[0] = size.height(); + m_textureOffsets[0] = 0; + m_textureWidths[1] = bytesPerLine2; + m_textureHeights[1] = size.height() / 2; + m_textureOffsets[1] = bytesPerLine * size.height() + bytesPerLine2 * size.height()/2; + m_textureWidths[2] = bytesPerLine2; + m_textureHeights[2] = size.height() / 2; + m_textureOffsets[2] = bytesPerLine * size.height(); +} + +#ifndef QT_OPENGL_ES + +# ifndef GL_FRAGMENT_PROGRAM_ARB +# define GL_FRAGMENT_PROGRAM_ARB 0x8804 +# define GL_PROGRAM_FORMAT_ASCII_ARB 0x8875 +# endif + +// Paints an RGB32 frame +static const char *qt_arbfp_xrgbShaderProgram = + "!!ARBfp1.0\n" + "PARAM matrix[4] = { program.local[0..2]," + "{ 0.0, 0.0, 0.0, 1.0 } };\n" + "TEMP xrgb;\n" + "TEX xrgb.xyz, fragment.texcoord[0], texture[0], 2D;\n" + "MOV xrgb.w, matrix[3].w;\n" + "DP4 result.color.x, xrgb.zyxw, matrix[0];\n" + "DP4 result.color.y, xrgb.zyxw, matrix[1];\n" + "DP4 result.color.z, xrgb.zyxw, matrix[2];\n" + "END"; + +// Paints an ARGB frame. +static const char *qt_arbfp_argbShaderProgram = + "!!ARBfp1.0\n" + "PARAM matrix[4] = { program.local[0..2]," + "{ 0.0, 0.0, 0.0, 1.0 } };\n" + "TEMP argb;\n" + "TEX argb, fragment.texcoord[0], texture[0], 2D;\n" + "MOV argb.w, matrix[3].w;\n" + "DP4 result.color.x, argb.zyxw, matrix[0];\n" + "DP4 result.color.y, argb.zyxw, matrix[1];\n" + "DP4 result.color.z, argb.zyxw, matrix[2];\n" + "TEX result.color.w, fragment.texcoord[0], texture, 2D;\n" + "END"; + +// Paints an RGB(A) frame. +static const char *qt_arbfp_rgbShaderProgram = + "!!ARBfp1.0\n" + "PARAM matrix[4] = { program.local[0..2]," + "{ 0.0, 0.0, 0.0, 1.0 } };\n" + "TEMP rgb;\n" + "TEX rgb, fragment.texcoord[0], texture[0], 2D;\n" + "MOV rgb.w, matrix[3].w;\n" + "DP4 result.color.x, rgb, matrix[0];\n" + "DP4 result.color.y, rgb, matrix[1];\n" + "DP4 result.color.z, rgb, matrix[2];\n" + "TEX result.color.w, fragment.texcoord[0], texture, 2D;\n" + "END"; + +// Paints a YUV420P or YV12 frame. +static const char *qt_arbfp_yuvPlanarShaderProgram = + "!!ARBfp1.0\n" + "PARAM matrix[4] = { program.local[0..2]," + "{ 0.0, 0.0, 0.0, 1.0 } };\n" + "TEMP yuv;\n" + "TEX yuv.x, fragment.texcoord[0], texture[0], 2D;\n" + "TEX yuv.y, fragment.texcoord[0], texture[1], 2D;\n" + "TEX yuv.z, fragment.texcoord[0], texture[2], 2D;\n" + "MOV yuv.w, matrix[3].w;\n" + "DP4 result.color.x, yuv, matrix[0];\n" + "DP4 result.color.y, yuv, matrix[1];\n" + "DP4 result.color.z, yuv, matrix[2];\n" + "END"; + +// Paints a YUV444 frame. +static const char *qt_arbfp_xyuvShaderProgram = + "!!ARBfp1.0\n" + "PARAM matrix[4] = { program.local[0..2]," + "{ 0.0, 0.0, 0.0, 1.0 } };\n" + "TEMP ayuv;\n" + "TEX ayuv, fragment.texcoord[0], texture[0], 2D;\n" + "MOV ayuv.x, matrix[3].w;\n" + "DP4 result.color.x, ayuv.yzwx, matrix[0];\n" + "DP4 result.color.y, ayuv.yzwx, matrix[1];\n" + "DP4 result.color.z, ayuv.yzwx, matrix[2];\n" + "END"; + +// Paints a AYUV444 frame. +static const char *qt_arbfp_ayuvShaderProgram = + "!!ARBfp1.0\n" + "PARAM matrix[4] = { program.local[0..2]," + "{ 0.0, 0.0, 0.0, 1.0 } };\n" + "TEMP ayuv;\n" + "TEX ayuv, fragment.texcoord[0], texture[0], 2D;\n" + "MOV ayuv.x, matrix[3].w;\n" + "DP4 result.color.x, ayuv.yzwx, matrix[0];\n" + "DP4 result.color.y, ayuv.yzwx, matrix[1];\n" + "DP4 result.color.z, ayuv.yzwx, matrix[2];\n" + "TEX result.color.w, fragment.texcoord[0], texture, 2D;\n" + "END"; + +class QVideoSurfaceArbFpPainter : public QVideoSurfaceGLPainter +{ +public: + QVideoSurfaceArbFpPainter(QGLContext *context); + + QAbstractVideoSurface::Error start(const QVideoSurfaceFormat &format); + void stop(); + + QAbstractVideoSurface::Error paint( + const QRectF &target, QPainter *painter, const QRectF &source); + +private: + typedef void (APIENTRY *_glProgramStringARB) (GLenum, GLenum, GLsizei, const GLvoid *); + typedef void (APIENTRY *_glBindProgramARB) (GLenum, GLuint); + typedef void (APIENTRY *_glDeleteProgramsARB) (GLsizei, const GLuint *); + typedef void (APIENTRY *_glGenProgramsARB) (GLsizei, GLuint *); + typedef void (APIENTRY *_glProgramLocalParameter4fARB) ( + GLenum, GLuint, GLfloat, GLfloat, GLfloat, GLfloat); + typedef void (APIENTRY *_glActiveTexture) (GLenum); + + _glProgramStringARB glProgramStringARB; + _glBindProgramARB glBindProgramARB; + _glDeleteProgramsARB glDeleteProgramsARB; + _glGenProgramsARB glGenProgramsARB; + _glProgramLocalParameter4fARB glProgramLocalParameter4fARB; + + GLuint m_programId; + QSize m_frameSize; +}; + +QVideoSurfaceArbFpPainter::QVideoSurfaceArbFpPainter(QGLContext *context) + : QVideoSurfaceGLPainter(context) + , m_programId(0) +{ + glProgramStringARB = (_glProgramStringARB) m_context->getProcAddress( + QLatin1String("glProgramStringARB")); + glBindProgramARB = (_glBindProgramARB) m_context->getProcAddress( + QLatin1String("glBindProgramARB")); + glDeleteProgramsARB = (_glDeleteProgramsARB) m_context->getProcAddress( + QLatin1String("glDeleteProgramsARB")); + glGenProgramsARB = (_glGenProgramsARB) m_context->getProcAddress( + QLatin1String("glGenProgramsARB")); + glProgramLocalParameter4fARB = (_glProgramLocalParameter4fARB) m_context->getProcAddress( + QLatin1String("glProgramLocalParameter4fARB")); + + m_imagePixelFormats + << QVideoFrame::Format_RGB32 + << QVideoFrame::Format_BGR32 + << QVideoFrame::Format_ARGB32 + << QVideoFrame::Format_RGB24 + << QVideoFrame::Format_BGR24 + << QVideoFrame::Format_RGB565 + << QVideoFrame::Format_AYUV444 + << QVideoFrame::Format_YUV444 + << QVideoFrame::Format_YV12 + << QVideoFrame::Format_YUV420P; + m_glPixelFormats + << QVideoFrame::Format_RGB32 + << QVideoFrame::Format_ARGB32; +} + +QAbstractVideoSurface::Error QVideoSurfaceArbFpPainter::start(const QVideoSurfaceFormat &format) +{ + Q_ASSERT(m_textureCount == 0); + + QAbstractVideoSurface::Error error = QAbstractVideoSurface::NoError; + + m_context->makeCurrent(); + + const char *program = 0; + + if (format.handleType() == QAbstractVideoBuffer::NoHandle) { + switch (format.pixelFormat()) { + case QVideoFrame::Format_RGB32: + initRgbTextureInfo(GL_RGBA, GL_RGBA, GL_UNSIGNED_BYTE, format.frameSize()); + program = qt_arbfp_xrgbShaderProgram; + break; + case QVideoFrame::Format_BGR32: + initRgbTextureInfo(GL_RGBA, GL_RGBA, GL_UNSIGNED_BYTE, format.frameSize()); + program = qt_arbfp_rgbShaderProgram; + break; + case QVideoFrame::Format_ARGB32: + initRgbTextureInfo(GL_RGBA, GL_RGBA, GL_UNSIGNED_BYTE, format.frameSize()); + program = qt_arbfp_argbShaderProgram; + break; + case QVideoFrame::Format_RGB24: + initRgbTextureInfo(GL_RGB8, GL_RGBA, GL_UNSIGNED_BYTE, format.frameSize()); + program = qt_arbfp_rgbShaderProgram; + break; + case QVideoFrame::Format_BGR24: + initRgbTextureInfo(GL_RGB8, GL_RGBA, GL_UNSIGNED_BYTE, format.frameSize()); + program = qt_arbfp_xrgbShaderProgram; + break; + case QVideoFrame::Format_RGB565: + initRgbTextureInfo(GL_RGB, GL_RGB, GL_UNSIGNED_SHORT_5_6_5, format.frameSize()); + program = qt_arbfp_rgbShaderProgram; + break; + case QVideoFrame::Format_YUV444: + initRgbTextureInfo(GL_RGB, GL_RGB, GL_UNSIGNED_BYTE, format.frameSize()); + program = qt_arbfp_xyuvShaderProgram; + m_yuv = true; + break; + case QVideoFrame::Format_AYUV444: + initRgbTextureInfo(GL_RGBA, GL_RGBA, GL_UNSIGNED_BYTE, format.frameSize()); + program = qt_arbfp_ayuvShaderProgram; + m_yuv = true; + break; + case QVideoFrame::Format_YV12: + initYv12TextureInfo(format.frameSize()); + program = qt_arbfp_yuvPlanarShaderProgram; + break; + case QVideoFrame::Format_YUV420P: + initYuv420PTextureInfo(format.frameSize()); + program = qt_arbfp_yuvPlanarShaderProgram; + break; + default: + break; + } + } else if (format.handleType() == QAbstractVideoBuffer::GLTextureHandle) { + switch (format.pixelFormat()) { + case QVideoFrame::Format_RGB32: + case QVideoFrame::Format_ARGB32: + m_yuv = false; + m_textureCount = 1; + program = qt_arbfp_rgbShaderProgram; + break; + default: + break; + } + } else if (format.handleType() == QAbstractVideoBuffer::QPixmapHandle) { + m_handleType = QAbstractVideoBuffer::QPixmapHandle; + return QAbstractVideoSurface::NoError; + } + + if (!program) { + error = QAbstractVideoSurface::UnsupportedFormatError; + } else { + glGenProgramsARB(1, &m_programId); + + GLenum glError = glGetError(); + if (glError != GL_NO_ERROR) { + qWarning("QPainterVideoSurface: ARBfb Shader allocation error %x", int(glError)); + m_textureCount = 0; + m_programId = 0; + + error = QAbstractVideoSurface::ResourceError; + } else { + glBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, m_programId); + glProgramStringARB( + GL_FRAGMENT_PROGRAM_ARB, + GL_PROGRAM_FORMAT_ASCII_ARB, + qstrlen(program), + reinterpret_cast(program)); + + if ((glError = glGetError()) != GL_NO_ERROR) { + const GLubyte* errorString = glGetString(GL_PROGRAM_ERROR_STRING_ARB); + + qWarning("QPainterVideoSurface: ARBfp Shader compile error %x, %s", + int(glError), + reinterpret_cast(errorString)); + glDeleteProgramsARB(1, &m_programId); + + m_textureCount = 0; + m_programId = 0; + + error = QAbstractVideoSurface::ResourceError; + } else { + m_handleType = format.handleType(); + m_scanLineDirection = format.scanLineDirection(); + m_frameSize = format.frameSize(); + m_colorSpace = format.yCbCrColorSpace(); + + if (m_handleType == QAbstractVideoBuffer::NoHandle) + glGenTextures(m_textureCount, m_textureIds); + } + } + } + + return error; +} + +void QVideoSurfaceArbFpPainter::stop() +{ + if (m_context) { + m_context->makeCurrent(); + + if (m_handleType != QAbstractVideoBuffer::GLTextureHandle) + glDeleteTextures(m_textureCount, m_textureIds); + glDeleteProgramsARB(1, &m_programId); + } + + m_textureCount = 0; + m_programId = 0; + m_handleType = QAbstractVideoBuffer::NoHandle; +} + +QAbstractVideoSurface::Error QVideoSurfaceArbFpPainter::paint( + const QRectF &target, QPainter *painter, const QRectF &source) +{ + if (!m_frame.isValid()) { + painter->fillRect(target, Qt::black); + return QAbstractVideoSurface::NoError; + } + + const QAbstractVideoBuffer::HandleType h = m_frame.handleType(); + if (h == QAbstractVideoBuffer::NoHandle || h == QAbstractVideoBuffer::GLTextureHandle) { + bool stencilTestEnabled = glIsEnabled(GL_STENCIL_TEST); + bool scissorTestEnabled = glIsEnabled(GL_SCISSOR_TEST); + + painter->beginNativePainting(); + + if (stencilTestEnabled) + glEnable(GL_STENCIL_TEST); + if (scissorTestEnabled) + glEnable(GL_SCISSOR_TEST); + + const float txLeft = source.left() / m_frameSize.width(); + const float txRight = source.right() / m_frameSize.width(); + const float txTop = m_scanLineDirection == QVideoSurfaceFormat::TopToBottom + ? source.top() / m_frameSize.height() + : source.bottom() / m_frameSize.height(); + const float txBottom = m_scanLineDirection == QVideoSurfaceFormat::TopToBottom + ? source.bottom() / m_frameSize.height() + : source.top() / m_frameSize.height(); + + const float tx_array[] = + { + txLeft , txBottom, + txRight, txBottom, + txLeft , txTop, + txRight, txTop + }; + + const GLfloat vTop = m_scanLineDirection == QVideoSurfaceFormat::TopToBottom + ? target.top() + : target.bottom() + 1; + const GLfloat vBottom = m_scanLineDirection == QVideoSurfaceFormat::TopToBottom + ? target.bottom() + 1 + : target.top(); + + const GLfloat v_array[] = + { + GLfloat(target.left()) , GLfloat(vBottom), + GLfloat(target.right() + 1), GLfloat(vBottom), + GLfloat(target.left()) , GLfloat(vTop), + GLfloat(target.right() + 1), GLfloat(vTop) + }; + + glEnable(GL_FRAGMENT_PROGRAM_ARB); + glBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, m_programId); + + glProgramLocalParameter4fARB( + GL_FRAGMENT_PROGRAM_ARB, + 0, + m_colorMatrix(0, 0), + m_colorMatrix(0, 1), + m_colorMatrix(0, 2), + m_colorMatrix(0, 3)); + glProgramLocalParameter4fARB( + GL_FRAGMENT_PROGRAM_ARB, + 1, + m_colorMatrix(1, 0), + m_colorMatrix(1, 1), + m_colorMatrix(1, 2), + m_colorMatrix(1, 3)); + glProgramLocalParameter4fARB( + GL_FRAGMENT_PROGRAM_ARB, + 2, + m_colorMatrix(2, 0), + m_colorMatrix(2, 1), + m_colorMatrix(2, 2), + m_colorMatrix(2, 3)); + + glActiveTexture(GL_TEXTURE0); + glBindTexture(GL_TEXTURE_2D, m_textureIds[0]); + + if (m_textureCount == 3) { + glActiveTexture(GL_TEXTURE1); + glBindTexture(GL_TEXTURE_2D, m_textureIds[1]); + glActiveTexture(GL_TEXTURE2); + glBindTexture(GL_TEXTURE_2D, m_textureIds[2]); + glActiveTexture(GL_TEXTURE0); + } + + glVertexPointer(2, GL_FLOAT, 0, v_array); + glTexCoordPointer(2, GL_FLOAT, 0, tx_array); + + glEnableClientState(GL_VERTEX_ARRAY); + glEnableClientState(GL_TEXTURE_COORD_ARRAY); + + glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); + + glDisableClientState(GL_TEXTURE_COORD_ARRAY); + glDisableClientState(GL_VERTEX_ARRAY); + glDisable(GL_FRAGMENT_PROGRAM_ARB); + + painter->endNativePainting(); + + return QAbstractVideoSurface::NoError; + } + + return QVideoSurfaceGLPainter::paint(target, painter, source); +} + +#endif + +static const char *qt_glsl_vertexShaderProgram = + "attribute highp vec4 vertexCoordArray;\n" + "attribute highp vec2 textureCoordArray;\n" + "uniform highp mat4 positionMatrix;\n" + "varying highp vec2 textureCoord;\n" + "void main(void)\n" + "{\n" + " gl_Position = positionMatrix * vertexCoordArray;\n" + " textureCoord = textureCoordArray;\n" + "}\n"; + +// Paints an RGB32 frame +static const char *qt_glsl_xrgbShaderProgram = + "uniform sampler2D texRgb;\n" + "uniform mediump mat4 colorMatrix;\n" + "varying highp vec2 textureCoord;\n" + "void main(void)\n" + "{\n" + " highp vec4 color = vec4(texture2D(texRgb, textureCoord.st).bgr, 1.0);\n" + " gl_FragColor = colorMatrix * color;\n" + "}\n"; + +// Paints an ARGB frame. +static const char *qt_glsl_argbShaderProgram = + "uniform sampler2D texRgb;\n" + "uniform mediump mat4 colorMatrix;\n" + "varying highp vec2 textureCoord;\n" + "void main(void)\n" + "{\n" + " highp vec4 color = vec4(texture2D(texRgb, textureCoord.st).bgr, 1.0);\n" + " color = colorMatrix * color;\n" + " gl_FragColor = vec4(color.rgb, texture2D(texRgb, textureCoord.st).a);\n" + "}\n"; + +// Paints an RGB(A) frame. +static const char *qt_glsl_rgbShaderProgram = + "uniform sampler2D texRgb;\n" + "uniform mediump mat4 colorMatrix;\n" + "varying highp vec2 textureCoord;\n" + "void main(void)\n" + "{\n" + " highp vec4 color = vec4(texture2D(texRgb, textureCoord.st).rgb, 1.0);\n" + " color = colorMatrix * color;\n" + " gl_FragColor = vec4(color.rgb, texture2D(texRgb, textureCoord.st).a);\n" + "}\n"; + +// Paints a YUV420P or YV12 frame. +static const char *qt_glsl_yuvPlanarShaderProgram = + "uniform sampler2D texY;\n" + "uniform sampler2D texU;\n" + "uniform sampler2D texV;\n" + "uniform mediump mat4 colorMatrix;\n" + "varying highp vec2 textureCoord;\n" + "void main(void)\n" + "{\n" + " highp vec4 color = vec4(\n" + " texture2D(texY, textureCoord.st).r,\n" + " texture2D(texU, textureCoord.st).r,\n" + " texture2D(texV, textureCoord.st).r,\n" + " 1.0);\n" + " gl_FragColor = colorMatrix * color;\n" + "}\n"; + +// Paints a YUV444 frame. +static const char *qt_glsl_xyuvShaderProgram = + "uniform sampler2D texRgb;\n" + "uniform mediump mat4 colorMatrix;\n" + "varying highp vec2 textureCoord;\n" + "void main(void)\n" + "{\n" + " highp vec4 color = vec4(texture2D(texRgb, textureCoord.st).gba, 1.0);\n" + " gl_FragColor = colorMatrix * color;\n" + "}\n"; + +// Paints a AYUV444 frame. +static const char *qt_glsl_ayuvShaderProgram = + "uniform sampler2D texRgb;\n" + "uniform mediump mat4 colorMatrix;\n" + "varying highp vec2 textureCoord;\n" + "void main(void)\n" + "{\n" + " highp vec4 color = vec4(texture2D(texRgb, textureCoord.st).gba, 1.0);\n" + " color = colorMatrix * color;\n" + " gl_FragColor = vec4(color.rgb, texture2D(texRgb, textureCoord.st).r);\n" + "}\n"; + +class QVideoSurfaceGlslPainter : public QVideoSurfaceGLPainter +{ +public: + QVideoSurfaceGlslPainter(QGLContext *context); + + QAbstractVideoSurface::Error start(const QVideoSurfaceFormat &format); + void stop(); + + QAbstractVideoSurface::Error paint( + const QRectF &target, QPainter *painter, const QRectF &source); + +private: + QGLShaderProgram m_program; + QSize m_frameSize; +}; + +QVideoSurfaceGlslPainter::QVideoSurfaceGlslPainter(QGLContext *context) + : QVideoSurfaceGLPainter(context) + , m_program(context) +{ + m_imagePixelFormats + << QVideoFrame::Format_RGB32 + << QVideoFrame::Format_BGR32 + << QVideoFrame::Format_ARGB32 +#ifndef QT_OPENGL_ES + << QVideoFrame::Format_RGB24 + << QVideoFrame::Format_BGR24 +#endif + << QVideoFrame::Format_RGB565 + << QVideoFrame::Format_YUV444 + << QVideoFrame::Format_AYUV444 + << QVideoFrame::Format_YV12 + << QVideoFrame::Format_YUV420P; + m_glPixelFormats + << QVideoFrame::Format_RGB32 + << QVideoFrame::Format_ARGB32; +} + +QAbstractVideoSurface::Error QVideoSurfaceGlslPainter::start(const QVideoSurfaceFormat &format) +{ + Q_ASSERT(m_textureCount == 0); + + QAbstractVideoSurface::Error error = QAbstractVideoSurface::NoError; + + m_context->makeCurrent(); + + const char *fragmentProgram = 0; + + if (format.handleType() == QAbstractVideoBuffer::NoHandle) { + switch (format.pixelFormat()) { + case QVideoFrame::Format_RGB32: + initRgbTextureInfo(GL_RGBA, GL_RGBA, GL_UNSIGNED_BYTE, format.frameSize()); + fragmentProgram = qt_glsl_xrgbShaderProgram; + break; + case QVideoFrame::Format_BGR32: + initRgbTextureInfo(GL_RGB, GL_RGBA, GL_UNSIGNED_BYTE, format.frameSize()); + fragmentProgram = qt_glsl_rgbShaderProgram; + break; + case QVideoFrame::Format_ARGB32: + initRgbTextureInfo(GL_RGBA, GL_RGBA, GL_UNSIGNED_BYTE, format.frameSize()); + fragmentProgram = qt_glsl_argbShaderProgram; + break; +#ifndef QT_OPENGL_ES + case QVideoFrame::Format_RGB24: + initRgbTextureInfo(GL_RGB8, GL_RGB, GL_UNSIGNED_BYTE, format.frameSize()); + fragmentProgram = qt_glsl_rgbShaderProgram; + break; + case QVideoFrame::Format_BGR24: + initRgbTextureInfo(GL_RGB8, GL_RGB, GL_UNSIGNED_BYTE, format.frameSize()); + fragmentProgram = qt_glsl_argbShaderProgram; + break; +#endif + case QVideoFrame::Format_RGB565: + initRgbTextureInfo(GL_RGB, GL_RGB, GL_UNSIGNED_SHORT_5_6_5, format.frameSize()); + fragmentProgram = qt_glsl_rgbShaderProgram; + break; + case QVideoFrame::Format_YUV444: + initRgbTextureInfo(GL_RGB, GL_RGB, GL_UNSIGNED_BYTE, format.frameSize()); + fragmentProgram = qt_glsl_xyuvShaderProgram; + m_yuv = true; + break; + case QVideoFrame::Format_AYUV444: + initRgbTextureInfo(GL_RGBA, GL_RGBA, GL_UNSIGNED_BYTE, format.frameSize()); + fragmentProgram = qt_glsl_ayuvShaderProgram; + m_yuv = true; + break; + case QVideoFrame::Format_YV12: + initYv12TextureInfo(format.frameSize()); + fragmentProgram = qt_glsl_yuvPlanarShaderProgram; + break; + case QVideoFrame::Format_YUV420P: + initYuv420PTextureInfo(format.frameSize()); + fragmentProgram = qt_glsl_yuvPlanarShaderProgram; + break; + default: + break; + } + } else if (format.handleType() == QAbstractVideoBuffer::GLTextureHandle) { + switch (format.pixelFormat()) { + case QVideoFrame::Format_RGB32: + case QVideoFrame::Format_ARGB32: + m_yuv = false; + m_textureCount = 1; + fragmentProgram = qt_glsl_rgbShaderProgram; + break; + default: + break; + } + } else if (format.handleType() == QAbstractVideoBuffer::QPixmapHandle) { + m_handleType = QAbstractVideoBuffer::QPixmapHandle; + return QAbstractVideoSurface::NoError; + } + + if (!fragmentProgram) { + error = QAbstractVideoSurface::UnsupportedFormatError; + } else if (!m_program.addShaderFromSourceCode(QGLShader::Vertex, qt_glsl_vertexShaderProgram)) { + qWarning("QPainterVideoSurface: Vertex shader compile error %s", + qPrintable(m_program.log())); + error = QAbstractVideoSurface::ResourceError; + } else if (!m_program.addShaderFromSourceCode(QGLShader::Fragment, fragmentProgram)) { + qWarning("QPainterVideoSurface: Shader compile error %s", qPrintable(m_program.log())); + error = QAbstractVideoSurface::ResourceError; + m_program.removeAllShaders(); + } else if(!m_program.link()) { + qWarning("QPainterVideoSurface: Shader link error %s", qPrintable(m_program.log())); + m_program.removeAllShaders(); + error = QAbstractVideoSurface::ResourceError; + } else { + m_handleType = format.handleType(); + m_scanLineDirection = format.scanLineDirection(); + m_frameSize = format.frameSize(); + m_colorSpace = format.yCbCrColorSpace(); + + if (m_handleType == QAbstractVideoBuffer::NoHandle) + glGenTextures(m_textureCount, m_textureIds); + } + + return error; +} + +void QVideoSurfaceGlslPainter::stop() +{ + if (m_context) { + m_context->makeCurrent(); + + if (m_handleType != QAbstractVideoBuffer::GLTextureHandle) + glDeleteTextures(m_textureCount, m_textureIds); + } + + m_program.removeAllShaders(); + + m_textureCount = 0; + m_handleType = QAbstractVideoBuffer::NoHandle; +} + +QAbstractVideoSurface::Error QVideoSurfaceGlslPainter::paint( + const QRectF &target, QPainter *painter, const QRectF &source) +{ + if (!m_frame.isValid()) { + painter->fillRect(target, Qt::black); + return QAbstractVideoSurface::NoError; + } + + const QAbstractVideoBuffer::HandleType h = m_frame.handleType(); + if (h == QAbstractVideoBuffer::NoHandle || h == QAbstractVideoBuffer::GLTextureHandle) { + bool stencilTestEnabled = glIsEnabled(GL_STENCIL_TEST); + bool scissorTestEnabled = glIsEnabled(GL_SCISSOR_TEST); + + painter->beginNativePainting(); + + if (stencilTestEnabled) + glEnable(GL_STENCIL_TEST); + if (scissorTestEnabled) + glEnable(GL_SCISSOR_TEST); + + const int width = QGLContext::currentContext()->device()->width(); + const int height = QGLContext::currentContext()->device()->height(); + + const QTransform transform = painter->deviceTransform(); + + const GLfloat wfactor = 2.0 / width; + const GLfloat hfactor = -2.0 / height; + + const GLfloat positionMatrix[4][4] = + { + { + /*(0,0)*/ GLfloat(wfactor * transform.m11() - transform.m13()), + /*(0,1)*/ GLfloat(hfactor * transform.m12() + transform.m13()), + /*(0,2)*/ 0.0, + /*(0,3)*/ GLfloat(transform.m13()) + }, { + /*(1,0)*/ GLfloat(wfactor * transform.m21() - transform.m23()), + /*(1,1)*/ GLfloat(hfactor * transform.m22() + transform.m23()), + /*(1,2)*/ 0.0, + /*(1,3)*/ GLfloat(transform.m23()) + }, { + /*(2,0)*/ 0.0, + /*(2,1)*/ 0.0, + /*(2,2)*/ -1.0, + /*(2,3)*/ 0.0 + }, { + /*(3,0)*/ GLfloat(wfactor * transform.dx() - transform.m33()), + /*(3,1)*/ GLfloat(hfactor * transform.dy() + transform.m33()), + /*(3,2)*/ 0.0, + /*(3,3)*/ GLfloat(transform.m33()) + } + }; + + const GLfloat vTop = m_scanLineDirection == QVideoSurfaceFormat::TopToBottom + ? target.top() + : target.bottom() + 1; + const GLfloat vBottom = m_scanLineDirection == QVideoSurfaceFormat::TopToBottom + ? target.bottom() + 1 + : target.top(); + + + const GLfloat vertexCoordArray[] = + { + GLfloat(target.left()) , GLfloat(vBottom), + GLfloat(target.right() + 1), GLfloat(vBottom), + GLfloat(target.left()) , GLfloat(vTop), + GLfloat(target.right() + 1), GLfloat(vTop) + }; + + const GLfloat txLeft = source.left() / m_frameSize.width(); + const GLfloat txRight = source.right() / m_frameSize.width(); + const GLfloat txTop = m_scanLineDirection == QVideoSurfaceFormat::TopToBottom + ? source.top() / m_frameSize.height() + : source.bottom() / m_frameSize.height(); + const GLfloat txBottom = m_scanLineDirection == QVideoSurfaceFormat::TopToBottom + ? source.bottom() / m_frameSize.height() + : source.top() / m_frameSize.height(); + + const GLfloat textureCoordArray[] = + { + txLeft , txBottom, + txRight, txBottom, + txLeft , txTop, + txRight, txTop + }; + + m_program.bind(); + + m_program.enableAttributeArray("vertexCoordArray"); + m_program.enableAttributeArray("textureCoordArray"); + m_program.setAttributeArray("vertexCoordArray", vertexCoordArray, 2); + m_program.setAttributeArray("textureCoordArray", textureCoordArray, 2); + m_program.setUniformValue("positionMatrix", positionMatrix); + + if (m_textureCount == 3) { + glActiveTexture(GL_TEXTURE0); + glBindTexture(GL_TEXTURE_2D, m_textureIds[0]); + glActiveTexture(GL_TEXTURE1); + glBindTexture(GL_TEXTURE_2D, m_textureIds[1]); + glActiveTexture(GL_TEXTURE2); + glBindTexture(GL_TEXTURE_2D, m_textureIds[2]); + glActiveTexture(GL_TEXTURE0); + + m_program.setUniformValue("texY", 0); + m_program.setUniformValue("texU", 1); + m_program.setUniformValue("texV", 2); + } else { + glActiveTexture(GL_TEXTURE0); + glBindTexture(GL_TEXTURE_2D, m_textureIds[0]); + + m_program.setUniformValue("texRgb", 0); + } + m_program.setUniformValue("colorMatrix", m_colorMatrix); + + glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); + + m_program.release(); + + painter->endNativePainting(); + + return QAbstractVideoSurface::NoError; + } + + return QVideoSurfaceGLPainter::paint(target, painter, source); +} + +#endif + +/*! + \class QPainterVideoSurface + \since 1.0 + \internal +*/ + +/*! +*/ +QPainterVideoSurface::QPainterVideoSurface(QObject *parent) + : QAbstractVideoSurface(parent) + , m_painter(0) +#if !defined(QT_NO_OPENGL) && !defined(QT_OPENGL_ES_1_CL) && !defined(QT_OPENGL_ES_1) + , m_glContext(0) + , m_shaderTypes(NoShaders) + , m_shaderType(NoShaders) +#endif + , m_brightness(0) + , m_contrast(0) + , m_hue(0) + , m_saturation(0) + , m_pixelFormat(QVideoFrame::Format_Invalid) + , m_colorsDirty(true) + , m_ready(false) +{ +} + +/*! +*/ +QPainterVideoSurface::~QPainterVideoSurface() +{ + if (isActive()) + m_painter->stop(); + + delete m_painter; +} + +/*! + \since 1.0 +*/ +QList QPainterVideoSurface::supportedPixelFormats( + QAbstractVideoBuffer::HandleType handleType) const +{ + if (!m_painter) + const_cast(this)->createPainter(); + + return m_painter->supportedPixelFormats(handleType); +} + +/*! + \since 1.0 +*/ +bool QPainterVideoSurface::isFormatSupported( + const QVideoSurfaceFormat &format, QVideoSurfaceFormat *similar) const +{ + if (!m_painter) + const_cast(this)->createPainter(); + + return m_painter->isFormatSupported(format, similar); +} + +/*! + \since 1.0 +*/ +bool QPainterVideoSurface::start(const QVideoSurfaceFormat &format) +{ + if (isActive()) + m_painter->stop(); + + if (!m_painter) + createPainter(); + + if (format.frameSize().isEmpty()) { + setError(UnsupportedFormatError); + } else { + QAbstractVideoSurface::Error error = m_painter->start(format); + + if (error != QAbstractVideoSurface::NoError) { + setError(error); + } else { + m_pixelFormat = format.pixelFormat(); + m_frameSize = format.frameSize(); + m_sourceRect = format.viewport(); + m_colorsDirty = true; + m_ready = true; + + return QAbstractVideoSurface::start(format); + } + } + + QAbstractVideoSurface::stop(); + + return false; +} + +/*! + \since 1.0 +*/ +void QPainterVideoSurface::stop() +{ + if (isActive()) { + m_painter->stop(); + m_ready = false; + + QAbstractVideoSurface::stop(); + } +} + +/*! + \since 1.0 +*/ +bool QPainterVideoSurface::present(const QVideoFrame &frame) +{ + if (!m_ready) { + if (!isActive()) + setError(StoppedError); + } else if (frame.isValid() + && (frame.pixelFormat() != m_pixelFormat || frame.size() != m_frameSize)) { + setError(IncorrectFormatError); + + stop(); + } else { + QAbstractVideoSurface::Error error = m_painter->setCurrentFrame(frame); + + if (error != QAbstractVideoSurface::NoError) { + setError(error); + + stop(); + } else { + m_ready = false; + + emit frameChanged(); + + return true; + } + } + return false; +} + +/*! + \since 1.0 +*/ +int QPainterVideoSurface::brightness() const +{ + return m_brightness; +} + +/*! + \since 1.0 +*/ +void QPainterVideoSurface::setBrightness(int brightness) +{ + m_brightness = brightness; + + m_colorsDirty = true; +} + +/*! + \since 1.0 +*/ +int QPainterVideoSurface::contrast() const +{ + return m_contrast; +} + +/*! + \since 1.0 +*/ +void QPainterVideoSurface::setContrast(int contrast) +{ + m_contrast = contrast; + + m_colorsDirty = true; +} + +/*! + \since 1.0 +*/ +int QPainterVideoSurface::hue() const +{ + return m_hue; +} + +/*! + \since 1.0 +*/ +void QPainterVideoSurface::setHue(int hue) +{ + m_hue = hue; + + m_colorsDirty = true; +} + +/*! + \since 1.0 +*/ +int QPainterVideoSurface::saturation() const +{ + return m_saturation; +} + +/*! + \since 1.0 +*/ +void QPainterVideoSurface::setSaturation(int saturation) +{ + m_saturation = saturation; + + m_colorsDirty = true; +} + +/*! + \since 1.0 +*/ +bool QPainterVideoSurface::isReady() const +{ + return m_ready; +} + +/*! + \since 1.0 +*/ +void QPainterVideoSurface::setReady(bool ready) +{ + m_ready = ready; +} + +/*! + \since 1.0 +*/ +void QPainterVideoSurface::paint(QPainter *painter, const QRectF &target, const QRectF &source) +{ + if (!isActive()) { + painter->fillRect(target, QBrush(Qt::black)); + } else { + if (m_colorsDirty) { + m_painter->updateColors(m_brightness, m_contrast, m_hue, m_saturation); + m_colorsDirty = false; + } + + const QRectF sourceRect( + m_sourceRect.x() + m_sourceRect.width() * source.x(), + m_sourceRect.y() + m_sourceRect.height() * source.y(), + m_sourceRect.width() * source.width(), + m_sourceRect.height() * source.height()); + + QAbstractVideoSurface::Error error = m_painter->paint(target, painter, sourceRect); + + if (error != QAbstractVideoSurface::NoError) { + setError(error); + + stop(); + } + } +} + +/*! + \fn QPainterVideoSurface::frameChanged() + \since 1.0 +*/ + +#if !defined(QT_NO_OPENGL) && !defined(QT_OPENGL_ES_1_CL) && !defined(QT_OPENGL_ES_1) + +/*! +*/ +const QGLContext *QPainterVideoSurface::glContext() const +{ + return m_glContext; +} + +/*! +*/ +void QPainterVideoSurface::setGLContext(QGLContext *context) +{ + if (m_glContext == context) + return; + + m_glContext = context; + + m_shaderTypes = NoShaders; + + if (m_glContext) { + m_glContext->makeCurrent(); + + const QByteArray extensions(reinterpret_cast(glGetString(GL_EXTENSIONS))); +#ifndef QT_OPENGL_ES + + if (extensions.contains("ARB_fragment_program")) + m_shaderTypes |= FragmentProgramShader; +#endif + if (QGLShaderProgram::hasOpenGLShaderPrograms(m_glContext) +#ifndef QT_OPENGL_ES_2 + && extensions.contains("ARB_shader_objects") +#endif + ) + m_shaderTypes |= GlslShader; + } + + ShaderType type = (m_shaderType & m_shaderTypes) + ? m_shaderType + : NoShaders; + + if (type != m_shaderType || type != NoShaders) { + m_shaderType = type; + + if (isActive()) { + m_painter->stop(); + delete m_painter; + m_painter = 0; + m_ready = false; + + setError(ResourceError); + QAbstractVideoSurface::stop(); + } + emit supportedFormatsChanged(); + } +} + +/*! + \enum QPainterVideoSurface::ShaderType + + \value NoShaders + \value FragmentProgramShader + \value HlslShader +*/ + +/*! + \typedef QPainterVideoSurface::ShaderTypes +*/ + +/*! + \since 1.0 +*/ +QPainterVideoSurface::ShaderTypes QPainterVideoSurface::supportedShaderTypes() const +{ + return m_shaderTypes; +} + +/*! + \since 1.0 +*/ +QPainterVideoSurface::ShaderType QPainterVideoSurface::shaderType() const +{ + return m_shaderType; +} + +/*! + \since 1.0 +*/ +void QPainterVideoSurface::setShaderType(ShaderType type) +{ + if (!(type & m_shaderTypes)) + type = NoShaders; + + if (type != m_shaderType) { + m_shaderType = type; + + if (isActive()) { + m_painter->stop(); + delete m_painter; + m_painter = 0; + m_ready = false; + + setError(ResourceError); + QAbstractVideoSurface::stop(); + } else { + delete m_painter; + m_painter = 0; + } + emit supportedFormatsChanged(); + } +} + +#endif + +void QPainterVideoSurface::viewportDestroyed() +{ + if (m_painter) { + m_painter->viewportDestroyed(); + + setError(ResourceError); + stop(); + delete m_painter; + m_painter = 0; + } +} + +void QPainterVideoSurface::createPainter() +{ + Q_ASSERT(!m_painter); + +#ifdef Q_WS_MAC + if (m_glContext) + m_glContext->makeCurrent(); + + m_painter = new QVideoSurfaceCoreGraphicsPainter(m_glContext != 0); + return; +#endif + +#if !defined(QT_NO_OPENGL) && !defined(QT_OPENGL_ES_1_CL) && !defined(QT_OPENGL_ES_1) + switch (m_shaderType) { +#ifndef QT_OPENGL_ES + case FragmentProgramShader: + Q_ASSERT(m_glContext); + m_glContext->makeCurrent(); + m_painter = new QVideoSurfaceArbFpPainter(m_glContext); + break; +#endif + case GlslShader: + Q_ASSERT(m_glContext); + m_glContext->makeCurrent(); + m_painter = new QVideoSurfaceGlslPainter(m_glContext); + break; + default: + m_painter = new QVideoSurfaceGenericPainter; + break; + } +#else + m_painter = new QVideoSurfaceGenericPainter; +#endif +} + +#include "moc_qpaintervideosurface_p.cpp" +QT_END_NAMESPACE + + diff --git a/src/multimediawidgets/qpaintervideosurface_mac.mm b/src/multimediawidgets/qpaintervideosurface_mac.mm new file mode 100644 index 000000000..02eabfe7d --- /dev/null +++ b/src/multimediawidgets/qpaintervideosurface_mac.mm @@ -0,0 +1,285 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include +#include +#include +#include + +#include "qpaintervideosurface_mac_p.h" + +#include + +#include + +#include +#include +#include + +#include + +QT_BEGIN_NAMESPACE + +extern CGContextRef qt_mac_cg_context(const QPaintDevice *pdev); //qpaintdevice_mac.cpp + +QVideoSurfaceCoreGraphicsPainter::QVideoSurfaceCoreGraphicsPainter(bool glSupported) + : ciContext(0) + , m_imageFormat(QImage::Format_Invalid) + , m_scanLineDirection(QVideoSurfaceFormat::TopToBottom) +{ + //qDebug() << "QVideoSurfaceCoreGraphicsPainter, GL supported:" << glSupported; + ciContext = 0; + m_imagePixelFormats + << QVideoFrame::Format_RGB32 + << QVideoFrame::Format_ARGB32 + << QVideoFrame::Format_ARGB32_Premultiplied + << QVideoFrame::Format_RGB24 + << QVideoFrame::Format_RGB565 + << QVideoFrame::Format_RGB555 + << QVideoFrame::Format_ARGB8565_Premultiplied; + + m_supportedHandles + << QAbstractVideoBuffer::NoHandle + << QAbstractVideoBuffer::CoreImageHandle; + + if (glSupported) + m_supportedHandles << QAbstractVideoBuffer::GLTextureHandle; +} + +QVideoSurfaceCoreGraphicsPainter::~QVideoSurfaceCoreGraphicsPainter() +{ + [(CIContext*)ciContext release]; +} + +QList QVideoSurfaceCoreGraphicsPainter::supportedPixelFormats( + QAbstractVideoBuffer::HandleType handleType) const +{ + return m_supportedHandles.contains(handleType) + ? m_imagePixelFormats + : QList(); +} + +bool QVideoSurfaceCoreGraphicsPainter::isFormatSupported( + const QVideoSurfaceFormat &format, QVideoSurfaceFormat *) const +{ + return m_supportedHandles.contains(format.handleType()) + && m_imagePixelFormats.contains(format.pixelFormat()) + && !format.frameSize().isEmpty(); +} + +QAbstractVideoSurface::Error QVideoSurfaceCoreGraphicsPainter::start(const QVideoSurfaceFormat &format) +{ + m_frame = QVideoFrame(); + m_imageFormat = QVideoFrame::imageFormatFromPixelFormat(format.pixelFormat()); + m_imageSize = format.frameSize(); + m_scanLineDirection = format.scanLineDirection(); + + return m_supportedHandles.contains(format.handleType()) + && m_imageFormat != QImage::Format_Invalid + && !m_imageSize.isEmpty() + ? QAbstractVideoSurface::NoError + : QAbstractVideoSurface::UnsupportedFormatError; +} + +void QVideoSurfaceCoreGraphicsPainter::stop() +{ + m_frame = QVideoFrame(); +} + +QAbstractVideoSurface::Error QVideoSurfaceCoreGraphicsPainter::setCurrentFrame(const QVideoFrame &frame) +{ + m_frame = frame; + + return QAbstractVideoSurface::NoError; +} + +QAbstractVideoSurface::Error QVideoSurfaceCoreGraphicsPainter::paint( + const QRectF &target, QPainter *painter, const QRectF &source) +{ + if (m_frame.handleType() == QAbstractVideoBuffer::CoreImageHandle) { + if (painter->paintEngine()->type() == QPaintEngine::CoreGraphics ) { + + CIImage *img = (CIImage*)(m_frame.handle().value()); + + if (img) { + CGContextRef cgContext = qt_mac_cg_context(painter->device()); + + if (cgContext) { + painter->beginNativePainting(); + + CGRect sRect = CGRectMake(source.x(), source.y(), source.width(), source.height()); + CGRect dRect = CGRectMake(target.x(), target.y(), target.width(), target.height()); + + NSBitmapImageRep *bitmap = [[NSBitmapImageRep alloc] initWithCIImage:img]; + + if (m_scanLineDirection == QVideoSurfaceFormat::TopToBottom) { + CGContextSaveGState( cgContext ); + CGContextTranslateCTM(cgContext, 0, dRect.origin.y + CGRectGetMaxY(dRect)); + CGContextScaleCTM(cgContext, 1, -1); + + CGContextDrawImage(cgContext, dRect, [bitmap CGImage]); + + CGContextRestoreGState(cgContext); + } else { + CGContextDrawImage(cgContext, dRect, [bitmap CGImage]); + } + + [bitmap release]; + + painter->endNativePainting(); + + return QAbstractVideoSurface::NoError; + } + } + } else if (painter->paintEngine()->type() == QPaintEngine::OpenGL2 || + painter->paintEngine()->type() == QPaintEngine::OpenGL) { + CIImage *img = (CIImage*)(m_frame.handle().value()); + + if (img) { + CGLContextObj cglContext = CGLGetCurrentContext(); + + if (cglContext) { + + if (!ciContext) { + CGLContextObj cglContext = CGLGetCurrentContext(); + NSOpenGLPixelFormat *nsglPixelFormat = [NSOpenGLView defaultPixelFormat]; + CGLPixelFormatObj cglPixelFormat = static_cast([nsglPixelFormat CGLPixelFormatObj]); + + ciContext = [CIContext contextWithCGLContext:cglContext + pixelFormat:cglPixelFormat + options:nil]; + + [(CIContext*)ciContext retain]; + } + + CGRect sRect = CGRectMake(source.x(), source.y(), source.width(), source.height()); + CGRect dRect = m_scanLineDirection == QVideoSurfaceFormat::TopToBottom ? + CGRectMake(target.x(), target.y()+target.height(), target.width(), -target.height()) : + CGRectMake(target.x(), target.y(), target.width(), target.height()); + + + painter->beginNativePainting(); + + [(CIContext*)ciContext drawImage:img inRect:dRect fromRect:sRect]; + + painter->endNativePainting(); + + return QAbstractVideoSurface::NoError; + } + } + } + } + + if (m_frame.handleType() == QAbstractVideoBuffer::GLTextureHandle && + (painter->paintEngine()->type() == QPaintEngine::OpenGL2 || + painter->paintEngine()->type() == QPaintEngine::OpenGL)) { + + painter->beginNativePainting(); + GLuint texture = m_frame.handle().toUInt(); + + glDisable(GL_CULL_FACE); + glEnable(GL_TEXTURE_2D); + + glBindTexture(GL_TEXTURE_2D, texture); + glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); + glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); + + const float txLeft = source.left() / m_frame.width(); + const float txRight = source.right() / m_frame.width(); + const float txTop = m_scanLineDirection == QVideoSurfaceFormat::TopToBottom + ? source.top() / m_frame.height() + : source.bottom() / m_frame.height(); + const float txBottom = m_scanLineDirection == QVideoSurfaceFormat::TopToBottom + ? source.bottom() / m_frame.height() + : source.top() / m_frame.height(); + + glBegin(GL_QUADS); + QRectF rect = target; + glTexCoord2f(txLeft, txBottom); + glVertex2f(rect.topLeft().x(), rect.topLeft().y()); + glTexCoord2f(txRight, txBottom); + glVertex2f(rect.topRight().x() + 1, rect.topRight().y()); + glTexCoord2f(txRight, txTop); + glVertex2f(rect.bottomRight().x() + 1, rect.bottomRight().y() + 1); + glTexCoord2f(txLeft, txTop); + glVertex2f(rect.bottomLeft().x(), rect.bottomLeft().y() + 1); + glEnd(); + painter->endNativePainting(); + + return QAbstractVideoSurface::NoError; + } + + //fallback case, software rendering + if (m_frame.map(QAbstractVideoBuffer::ReadOnly)) { + QImage image( + m_frame.bits(), + m_imageSize.width(), + m_imageSize.height(), + m_frame.bytesPerLine(), + m_imageFormat); + + if (m_scanLineDirection == QVideoSurfaceFormat::BottomToTop) { + const QTransform oldTransform = painter->transform(); + + painter->scale(1, -1); + painter->translate(0, -target.bottom()); + painter->drawImage( + QRectF(target.x(), 0, target.width(), target.height()), image, source); + painter->setTransform(oldTransform); + } else { + painter->drawImage(target, image, source); + } + + m_frame.unmap(); + } else if (m_frame.isValid()) { + return QAbstractVideoSurface::IncorrectFormatError; + } else { + painter->fillRect(target, Qt::black); + } + + return QAbstractVideoSurface::NoError; +} + +void QVideoSurfaceCoreGraphicsPainter::updateColors(int, int, int, int) +{ +} + +QT_END_NAMESPACE diff --git a/src/multimediawidgets/qpaintervideosurface_mac_p.h b/src/multimediawidgets/qpaintervideosurface_mac_p.h new file mode 100644 index 000000000..d650d9ad7 --- /dev/null +++ b/src/multimediawidgets/qpaintervideosurface_mac_p.h @@ -0,0 +1,103 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QPAINTERVIDEOSURFACE_MAC_P_H +#define QPAINTERVIDEOSURFACE_MAC_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 "qpaintervideosurface_p.h" +#include +#include + +QT_BEGIN_HEADER + +QT_BEGIN_NAMESPACE + +QT_MODULE(Multimedia) + + +class QVideoSurfaceCoreGraphicsPainter : public QVideoSurfacePainter +{ +public: + QVideoSurfaceCoreGraphicsPainter(bool glSupported); + ~QVideoSurfaceCoreGraphicsPainter(); + + QList supportedPixelFormats( + QAbstractVideoBuffer::HandleType handleType) const; + + bool isFormatSupported( + const QVideoSurfaceFormat &format, QVideoSurfaceFormat *similar) const; + + QAbstractVideoSurface::Error start(const QVideoSurfaceFormat &format); + void stop(); + + QAbstractVideoSurface::Error setCurrentFrame(const QVideoFrame &frame); + + QAbstractVideoSurface::Error paint( + const QRectF &target, QPainter *painter, const QRectF &source); + + void updateColors(int brightness, int contrast, int hue, int saturation); + +private: + void* ciContext; + QList m_imagePixelFormats; + QVideoFrame m_frame; + QSize m_imageSize; + QImage::Format m_imageFormat; + QVector m_supportedHandles; + QVideoSurfaceFormat::Direction m_scanLineDirection; +}; + +QT_END_NAMESPACE + +QT_END_HEADER + +#endif diff --git a/src/multimediawidgets/qpaintervideosurface_p.h b/src/multimediawidgets/qpaintervideosurface_p.h new file mode 100644 index 000000000..a8b535b59 --- /dev/null +++ b/src/multimediawidgets/qpaintervideosurface_p.h @@ -0,0 +1,191 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QPAINTERVIDEOSURFACE_P_H +#define QPAINTERVIDEOSURFACE_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 +#include +#include +#include +#include +#include +#include + +QT_BEGIN_HEADER + +QT_BEGIN_NAMESPACE + +QT_MODULE(Multimedia) + +class QGLContext; +QT_END_NAMESPACE + +QT_USE_NAMESPACE + +QT_BEGIN_NAMESPACE + +class QVideoSurfacePainter +{ +public: + virtual ~QVideoSurfacePainter(); + + virtual QList supportedPixelFormats( + QAbstractVideoBuffer::HandleType handleType) const = 0; + + virtual bool isFormatSupported( + const QVideoSurfaceFormat &format, QVideoSurfaceFormat *similar) const = 0; + + virtual QAbstractVideoSurface::Error start(const QVideoSurfaceFormat &format) = 0; + virtual void stop() = 0; + + virtual QAbstractVideoSurface::Error setCurrentFrame(const QVideoFrame &frame) = 0; + + virtual QAbstractVideoSurface::Error paint( + const QRectF &target, QPainter *painter, const QRectF &source) = 0; + + virtual void updateColors(int brightness, int contrast, int hue, int saturation) = 0; + virtual void viewportDestroyed() {} +}; + + +class Q_AUTOTEST_EXPORT QPainterVideoSurface : public QAbstractVideoSurface +{ + Q_OBJECT +public: + explicit QPainterVideoSurface(QObject *parent = 0); + ~QPainterVideoSurface(); + + QList supportedPixelFormats( + QAbstractVideoBuffer::HandleType handleType = QAbstractVideoBuffer::NoHandle) const; + + bool isFormatSupported( + const QVideoSurfaceFormat &format, QVideoSurfaceFormat *similar = 0) const; + + bool start(const QVideoSurfaceFormat &format); + void stop(); + + bool present(const QVideoFrame &frame); + + int brightness() const; + void setBrightness(int brightness); + + int contrast() const; + void setContrast(int contrast); + + int hue() const; + void setHue(int hue); + + int saturation() const; + void setSaturation(int saturation); + + bool isReady() const; + void setReady(bool ready); + + void paint(QPainter *painter, const QRectF &target, const QRectF &source = QRectF(0, 0, 1, 1)); + +#if !defined(QT_NO_OPENGL) && !defined(QT_OPENGL_ES_1_CL) && !defined(QT_OPENGL_ES_1) + const QGLContext *glContext() const; + void setGLContext(QGLContext *context); + + enum ShaderType + { + NoShaders = 0x00, + FragmentProgramShader = 0x01, + GlslShader = 0x02 + }; + + Q_DECLARE_FLAGS(ShaderTypes, ShaderType) + + ShaderTypes supportedShaderTypes() const; + + ShaderType shaderType() const; + void setShaderType(ShaderType type); +#endif + +public Q_SLOTS: + void viewportDestroyed(); + +Q_SIGNALS: + void frameChanged(); + +private: + void createPainter(); + + QVideoSurfacePainter *m_painter; +#if !defined(QT_NO_OPENGL) && !defined(QT_OPENGL_ES_1_CL) && !defined(QT_OPENGL_ES_1) + QGLContext *m_glContext; + ShaderTypes m_shaderTypes; + ShaderType m_shaderType; +#endif + int m_brightness; + int m_contrast; + int m_hue; + int m_saturation; + + QVideoFrame::PixelFormat m_pixelFormat; + QSize m_frameSize; + QRect m_sourceRect; + bool m_colorsDirty; + bool m_ready; +}; + +#if !defined(QT_NO_OPENGL) && !defined(QT_OPENGL_ES_1_CL) && !defined(QT_OPENGL_ES_1) +Q_DECLARE_OPERATORS_FOR_FLAGS(QPainterVideoSurface::ShaderTypes) +#endif + +QT_END_NAMESPACE + +QT_END_HEADER + + +#endif diff --git a/src/multimediawidgets/qtmultimediawidgetdefs.h b/src/multimediawidgets/qtmultimediawidgetdefs.h new file mode 100644 index 000000000..57ce226a1 --- /dev/null +++ b/src/multimediawidgets/qtmultimediawidgetdefs.h @@ -0,0 +1,89 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +// +// 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. +// + +#ifndef QTMULTIMEDIAWIDGETS_P_H +#define QTMULTIMEDIAWIDGETS_P_H + +#include + +QT_BEGIN_HEADER + +#if defined(Q_OS_WIN) +# if defined(QT_NODLL) +# undef QT_MAKEDLL +# undef QT_DLL +# elif defined(QT_MAKEDLL) +# if defined(QT_DLL) +# undef QT_DLL +# endif +# if defined(QT_BUILD_MULTIMEDIA_LIB) +# define Q_MULTIMEDIAWIDGETS_EXPORT Q_DECL_EXPORT +# else +# define Q_MULTIMEDIAWIDGETS_EXPORT Q_DECL_IMPORT +# endif +# elif defined(QT_DLL) /* use a Qt DLL library */ +# define Q_MULTIMEDIAWIDGETS_EXPORT Q_DECL_IMPORT +# endif +#endif + +#if !defined(Q_MULTIMEDIAWIDGETS_EXPORT) +# if defined(QT_SHARED) +# define Q_MULTIMEDIAWIDGETS_EXPORT Q_DECL_EXPORT +# else +# define Q_MULTIMEDIAWIDGETS_EXPORT +# endif +#endif + +QT_END_HEADER + +#endif // QMULTIMEDIAWIDGETS_P_H + diff --git a/src/multimediawidgets/qvideowidget.cpp b/src/multimediawidgets/qvideowidget.cpp new file mode 100644 index 000000000..f31144cb0 --- /dev/null +++ b/src/multimediawidgets/qvideowidget.cpp @@ -0,0 +1,1043 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qvideowidget_p.h" + +#include +#include +#include +#include + +#include +#include +#include +#include + +#include +#include +#include +#include +#include + +using namespace Qt; + +QT_BEGIN_NAMESPACE + +QVideoWidgetControlBackend::QVideoWidgetControlBackend( + QMediaService *service, QVideoWidgetControl *control, QWidget *widget) + : m_service(service) + , m_widgetControl(control) +{ + connect(control, SIGNAL(brightnessChanged(int)), widget, SLOT(_q_brightnessChanged(int))); + connect(control, SIGNAL(contrastChanged(int)), widget, SLOT(_q_contrastChanged(int))); + connect(control, SIGNAL(hueChanged(int)), widget, SLOT(_q_hueChanged(int))); + connect(control, SIGNAL(saturationChanged(int)), widget, SLOT(_q_saturationChanged(int))); + connect(control, SIGNAL(fullScreenChanged(bool)), widget, SLOT(_q_fullScreenChanged(bool))); + + QBoxLayout *layout = new QVBoxLayout; + layout->setMargin(0); + layout->setSpacing(0); + + layout->addWidget(control->videoWidget()); + + widget->setLayout(layout); +} + +void QVideoWidgetControlBackend::releaseControl() +{ + m_service->releaseControl(m_widgetControl); +} + +void QVideoWidgetControlBackend::setBrightness(int brightness) +{ + m_widgetControl->setBrightness(brightness); +} + +void QVideoWidgetControlBackend::setContrast(int contrast) +{ + m_widgetControl->setContrast(contrast); +} + +void QVideoWidgetControlBackend::setHue(int hue) +{ + m_widgetControl->setHue(hue); +} + +void QVideoWidgetControlBackend::setSaturation(int saturation) +{ + m_widgetControl->setSaturation(saturation); +} + +void QVideoWidgetControlBackend::setFullScreen(bool fullScreen) +{ + m_widgetControl->setFullScreen(fullScreen); +} + + +Qt::AspectRatioMode QVideoWidgetControlBackend::aspectRatioMode() const +{ + return m_widgetControl->aspectRatioMode(); +} + +void QVideoWidgetControlBackend::setAspectRatioMode(Qt::AspectRatioMode mode) +{ + m_widgetControl->setAspectRatioMode(mode); +} + +QRendererVideoWidgetBackend::QRendererVideoWidgetBackend( + QMediaService *service, QVideoRendererControl *control, QWidget *widget) + : m_service(service) + , m_rendererControl(control) + , m_widget(widget) + , m_surface(new QPainterVideoSurface) + , m_aspectRatioMode(Qt::KeepAspectRatio) + , m_updatePaintDevice(true) +{ + connect(this, SIGNAL(brightnessChanged(int)), m_widget, SLOT(_q_brightnessChanged(int))); + connect(this, SIGNAL(contrastChanged(int)), m_widget, SLOT(_q_contrastChanged(int))); + connect(this, SIGNAL(hueChanged(int)), m_widget, SLOT(_q_hueChanged(int))); + connect(this, SIGNAL(saturationChanged(int)), m_widget, SLOT(_q_saturationChanged(int))); + connect(m_surface, SIGNAL(frameChanged()), this, SLOT(frameChanged())); + connect(m_surface, SIGNAL(surfaceFormatChanged(QVideoSurfaceFormat)), + this, SLOT(formatChanged(QVideoSurfaceFormat))); + + m_rendererControl->setSurface(m_surface); +} + +QRendererVideoWidgetBackend::~QRendererVideoWidgetBackend() +{ + delete m_surface; +} + +void QRendererVideoWidgetBackend::releaseControl() +{ + m_service->releaseControl(m_rendererControl); +} + +void QRendererVideoWidgetBackend::clearSurface() +{ + m_rendererControl->setSurface(0); +} + +void QRendererVideoWidgetBackend::setBrightness(int brightness) +{ + m_surface->setBrightness(brightness); + + emit brightnessChanged(brightness); +} + +void QRendererVideoWidgetBackend::setContrast(int contrast) +{ + m_surface->setContrast(contrast); + + emit contrastChanged(contrast); +} + +void QRendererVideoWidgetBackend::setHue(int hue) +{ + m_surface->setHue(hue); + + emit hueChanged(hue); +} + +void QRendererVideoWidgetBackend::setSaturation(int saturation) +{ + m_surface->setSaturation(saturation); + + emit saturationChanged(saturation); +} + +Qt::AspectRatioMode QRendererVideoWidgetBackend::aspectRatioMode() const +{ + return m_aspectRatioMode; +} + +void QRendererVideoWidgetBackend::setAspectRatioMode(Qt::AspectRatioMode mode) +{ + m_aspectRatioMode = mode; + + m_widget->updateGeometry(); +} + +void QRendererVideoWidgetBackend::setFullScreen(bool) +{ +} + +QSize QRendererVideoWidgetBackend::sizeHint() const +{ + return m_surface->surfaceFormat().sizeHint(); +} + +void QRendererVideoWidgetBackend::showEvent() +{ +} + +void QRendererVideoWidgetBackend::hideEvent(QHideEvent *) +{ +#if !defined(QT_NO_OPENGL) && !defined(QT_OPENGL_ES_1_CL) && !defined(QT_OPENGL_ES_1) + m_updatePaintDevice = true; + m_surface->setGLContext(0); +#endif +} + +void QRendererVideoWidgetBackend::resizeEvent(QResizeEvent *) +{ + updateRects(); +} + +void QRendererVideoWidgetBackend::moveEvent(QMoveEvent *) +{ +} + +void QRendererVideoWidgetBackend::paintEvent(QPaintEvent *event) +{ + QPainter painter(m_widget); + + if (m_widget->testAttribute(Qt::WA_OpaquePaintEvent)) { + QRegion borderRegion = event->region(); + borderRegion = borderRegion.subtracted(m_boundingRect); + + QBrush brush = m_widget->palette().window(); + + QVector rects = borderRegion.rects(); + for (QVector::iterator it = rects.begin(), end = rects.end(); it != end; ++it) { + painter.fillRect(*it, brush); + } + } + + if (m_surface->isActive() && m_boundingRect.intersects(event->rect())) { + m_surface->paint(&painter, m_boundingRect, m_sourceRect); + + m_surface->setReady(true); + } else { + #if !defined(QT_NO_OPENGL) && !defined(QT_OPENGL_ES_1_CL) && !defined(QT_OPENGL_ES_1) + if (m_updatePaintDevice && (painter.paintEngine()->type() == QPaintEngine::OpenGL + || painter.paintEngine()->type() == QPaintEngine::OpenGL2)) { + m_updatePaintDevice = false; + + m_surface->setGLContext(const_cast(QGLContext::currentContext())); + if (m_surface->supportedShaderTypes() & QPainterVideoSurface::GlslShader) { + m_surface->setShaderType(QPainterVideoSurface::GlslShader); + } else { + m_surface->setShaderType(QPainterVideoSurface::FragmentProgramShader); + } + } +#endif + } + +} + +void QRendererVideoWidgetBackend::formatChanged(const QVideoSurfaceFormat &format) +{ + m_nativeSize = format.sizeHint(); + + updateRects(); + + m_widget->updateGeometry(); + m_widget->update(); +} + +void QRendererVideoWidgetBackend::frameChanged() +{ + m_widget->update(m_boundingRect); +} + +void QRendererVideoWidgetBackend::updateRects() +{ + QRect rect = m_widget->rect(); + + if (m_nativeSize.isEmpty()) { + m_boundingRect = QRect(); + } else if (m_aspectRatioMode == Qt::IgnoreAspectRatio) { + m_boundingRect = rect; + m_sourceRect = QRectF(0, 0, 1, 1); + } else if (m_aspectRatioMode == Qt::KeepAspectRatio) { + QSize size = m_nativeSize; + size.scale(rect.size(), Qt::KeepAspectRatio); + + m_boundingRect = QRect(0, 0, size.width(), size.height()); + m_boundingRect.moveCenter(rect.center()); + + m_sourceRect = QRectF(0, 0, 1, 1); + } else if (m_aspectRatioMode == Qt::KeepAspectRatioByExpanding) { + m_boundingRect = rect; + + QSizeF size = rect.size(); + size.scale(m_nativeSize, Qt::KeepAspectRatio); + + m_sourceRect = QRectF( + 0, 0, size.width() / m_nativeSize.width(), size.height() / m_nativeSize.height()); + m_sourceRect.moveCenter(QPointF(0.5, 0.5)); + } +} + +QWindowVideoWidgetBackend::QWindowVideoWidgetBackend( + QMediaService *service, QVideoWindowControl *control, QWidget *widget) + : m_service(service) + , m_windowControl(control) + , m_widget(widget) + , m_aspectRatioMode(Qt::KeepAspectRatio) +{ + connect(control, SIGNAL(brightnessChanged(int)), m_widget, SLOT(_q_brightnessChanged(int))); + connect(control, SIGNAL(contrastChanged(int)), m_widget, SLOT(_q_contrastChanged(int))); + connect(control, SIGNAL(hueChanged(int)), m_widget, SLOT(_q_hueChanged(int))); + connect(control, SIGNAL(saturationChanged(int)), m_widget, SLOT(_q_saturationChanged(int))); + connect(control, SIGNAL(fullScreenChanged(bool)), m_widget, SLOT(_q_fullScreenChanged(bool))); + connect(control, SIGNAL(nativeSizeChanged()), m_widget, SLOT(_q_dimensionsChanged())); + + control->setWinId(widget->winId()); +} + +QWindowVideoWidgetBackend::~QWindowVideoWidgetBackend() +{ +} + +void QWindowVideoWidgetBackend::releaseControl() +{ + m_service->releaseControl(m_windowControl); +} + +void QWindowVideoWidgetBackend::setBrightness(int brightness) +{ + m_windowControl->setBrightness(brightness); +} + +void QWindowVideoWidgetBackend::setContrast(int contrast) +{ + m_windowControl->setContrast(contrast); +} + +void QWindowVideoWidgetBackend::setHue(int hue) +{ + m_windowControl->setHue(hue); +} + +void QWindowVideoWidgetBackend::setSaturation(int saturation) +{ + m_windowControl->setSaturation(saturation); +} + +void QWindowVideoWidgetBackend::setFullScreen(bool fullScreen) +{ + m_windowControl->setFullScreen(fullScreen); +} + +Qt::AspectRatioMode QWindowVideoWidgetBackend::aspectRatioMode() const +{ + return m_windowControl->aspectRatioMode(); +} + +void QWindowVideoWidgetBackend::setAspectRatioMode(Qt::AspectRatioMode mode) +{ + m_windowControl->setAspectRatioMode(mode); +} + +QSize QWindowVideoWidgetBackend::sizeHint() const +{ + return m_windowControl->nativeSize(); +} + +void QWindowVideoWidgetBackend::showEvent() +{ + m_windowControl->setWinId(m_widget->winId()); + + m_windowControl->setDisplayRect(m_widget->rect()); + +#if defined(Q_WS_WIN) + m_widget->setUpdatesEnabled(false); +#endif +} + +void QWindowVideoWidgetBackend::hideEvent(QHideEvent *) +{ +#if defined(Q_WS_WIN) + m_widget->setUpdatesEnabled(true); +#endif +} + +void QWindowVideoWidgetBackend::moveEvent(QMoveEvent *) +{ + m_windowControl->setDisplayRect(m_widget->rect()); +} + +void QWindowVideoWidgetBackend::resizeEvent(QResizeEvent *) +{ + m_windowControl->setDisplayRect(m_widget->rect()); +} + +void QWindowVideoWidgetBackend::paintEvent(QPaintEvent *event) +{ + if (m_widget->testAttribute(Qt::WA_OpaquePaintEvent)) { + QPainter painter(m_widget); + + painter.fillRect(event->rect(), m_widget->palette().window()); + } + + m_windowControl->repaint(); + + event->accept(); +} + +#if defined(Q_WS_WIN) +bool QWindowVideoWidgetBackend::winEvent(MSG *message, long *) +{ + if (message->message == WM_PAINT) + m_windowControl->repaint(); + + return false; +} +#endif + +void QVideoWidgetPrivate::setCurrentControl(QVideoWidgetControlInterface *control) +{ + if (currentControl != control) { + currentControl = control; + + currentControl->setBrightness(brightness); + currentControl->setContrast(contrast); + currentControl->setHue(hue); + currentControl->setSaturation(saturation); + currentControl->setAspectRatioMode(aspectRatioMode); + } +} + +void QVideoWidgetPrivate::clearService() +{ + if (service) { + QObject::disconnect(service, SIGNAL(destroyed()), q_func(), SLOT(_q_serviceDestroyed())); + + if (widgetBackend) { + QLayout *layout = q_func()->layout(); + + for (QLayoutItem *item = layout->takeAt(0); item; item = layout->takeAt(0)) { + item->widget()->setParent(0); + delete item; + } + delete layout; + + widgetBackend->releaseControl(); + + delete widgetBackend; + widgetBackend = 0; + } else if (rendererBackend) { + rendererBackend->clearSurface(); + rendererBackend->releaseControl(); + + delete rendererBackend; + rendererBackend = 0; + } else { + windowBackend->releaseControl(); + + delete windowBackend; + windowBackend = 0; + } + + currentBackend = 0; + currentControl = 0; + service = 0; + } +} + +bool QVideoWidgetPrivate::createWidgetBackend() +{ + if (QMediaControl *control = service->requestControl(QVideoWidgetControl_iid)) { + if (QVideoWidgetControl *widgetControl = qobject_cast(control)) { + widgetBackend = new QVideoWidgetControlBackend(service, widgetControl, q_func()); + + setCurrentControl(widgetBackend); + + return true; + } + service->releaseControl(control); + } + return false; +} + +bool QVideoWidgetPrivate::createWindowBackend() +{ + if (QMediaControl *control = service->requestControl(QVideoWindowControl_iid)) { + if (QVideoWindowControl *windowControl = qobject_cast(control)) { + windowBackend = new QWindowVideoWidgetBackend(service, windowControl, q_func()); + currentBackend = windowBackend; + + setCurrentControl(windowBackend); + + return true; + } + service->releaseControl(control); + } + return false; +} + +bool QVideoWidgetPrivate::createRendererBackend() +{ + if (QMediaControl *control = service->requestControl(QVideoRendererControl_iid)) { + if (QVideoRendererControl *rendererControl = qobject_cast(control)) { + rendererBackend = new QRendererVideoWidgetBackend(service, rendererControl, q_func()); + currentBackend = rendererBackend; + + setCurrentControl(rendererBackend); + + return true; + } + service->releaseControl(control); + } + return false; +} + +void QVideoWidgetPrivate::_q_serviceDestroyed() +{ + if (widgetBackend) + delete q_func()->layout(); + + delete widgetBackend; + delete windowBackend; + delete rendererBackend; + + widgetBackend = 0; + windowBackend = 0; + rendererBackend = 0; + currentControl = 0; + currentBackend = 0; + service = 0; +} + +void QVideoWidgetPrivate::_q_brightnessChanged(int b) +{ + if (b != brightness) + emit q_func()->brightnessChanged(brightness = b); +} + +void QVideoWidgetPrivate::_q_contrastChanged(int c) +{ + if (c != contrast) + emit q_func()->contrastChanged(contrast = c); +} + +void QVideoWidgetPrivate::_q_hueChanged(int h) +{ + if (h != hue) + emit q_func()->hueChanged(hue = h); +} + +void QVideoWidgetPrivate::_q_saturationChanged(int s) +{ + if (s != saturation) + emit q_func()->saturationChanged(saturation = s); +} + + +void QVideoWidgetPrivate::_q_fullScreenChanged(bool fullScreen) +{ + if (!fullScreen && q_func()->isFullScreen()) + q_func()->showNormal(); +} + +void QVideoWidgetPrivate::_q_dimensionsChanged() +{ + q_func()->updateGeometry(); + q_func()->update(); +} + +/*! + \class QVideoWidget + + + \brief The QVideoWidget class provides a widget which presents video + produced by a media object. + \ingroup multimedia + \inmodule QtMultimedia + \since 1.0 + + \inmodule QtMultimedia + + Attaching a QVideoWidget to a QMediaObject allows it to display the + video or image output of that media object. A QVideoWidget is attached + to media object by passing a pointer to the QMediaObject in its + constructor, and detached by destroying the QVideoWidget. + + \snippet doc/src/snippets/multimedia-snippets/video.cpp Video widget + + \bold {Note}: Only a single display output can be attached to a media + object at one time. + + \sa QMediaObject, QMediaPlayer, QGraphicsVideoItem +*/ + +/*! + Constructs a new video widget. + + The \a parent is passed to QWidget. +*/ +QVideoWidget::QVideoWidget(QWidget *parent) + : QWidget(parent, 0) + , d_ptr(new QVideoWidgetPrivate) +{ + d_ptr->q_ptr = this; +} + +/*! + \internal +*/ +QVideoWidget::QVideoWidget(QVideoWidgetPrivate &dd, QWidget *parent) + : QWidget(parent, 0) + , d_ptr(&dd) +{ + d_ptr->q_ptr = this; + + QPalette palette = QWidget::palette(); + palette.setColor(QPalette::Background, Qt::black); + setPalette(palette); +} + +/*! + Destroys a video widget. +*/ +QVideoWidget::~QVideoWidget() +{ + d_ptr->clearService(); + + delete d_ptr; +} + +/*! + \property QVideoWidget::mediaObject + \brief the media object which provides the video displayed by a widget. + \since 1.0 +*/ + +QMediaObject *QVideoWidget::mediaObject() const +{ + return d_func()->mediaObject; +} + +/*! + \internal + \since 1.0 +*/ +bool QVideoWidget::setMediaObject(QMediaObject *object) +{ + Q_D(QVideoWidget); + + if (object == d->mediaObject) + return true; + + d->clearService(); + + d->mediaObject = object; + + if (d->mediaObject) + d->service = d->mediaObject->service(); + + if (d->service) { + if (d->createWidgetBackend()) { + // Nothing to do here. + } else if ((!window() || !window()->testAttribute(Qt::WA_DontShowOnScreen)) + && d->createWindowBackend()) { + if (isVisible()) + d->windowBackend->showEvent(); + } else if (d->createRendererBackend()) { + if (isVisible()) + d->rendererBackend->showEvent(); + } else { + d->service = 0; + d->mediaObject = 0; + + return false; + } + + connect(d->service, SIGNAL(destroyed()), SLOT(_q_serviceDestroyed())); + } else { + d->mediaObject = 0; + + return false; + } + + return true; +} + +/*! + \property QVideoWidget::aspectRatioMode + \brief how video is scaled with respect to its aspect ratio. + \since 1.0 +*/ + +Qt::AspectRatioMode QVideoWidget::aspectRatioMode() const +{ + return d_func()->aspectRatioMode; +} + +void QVideoWidget::setAspectRatioMode(Qt::AspectRatioMode mode) +{ + Q_D(QVideoWidget); + + if (d->currentControl) { + d->currentControl->setAspectRatioMode(mode); + d->aspectRatioMode = d->currentControl->aspectRatioMode(); + } else { + d->aspectRatioMode = mode; + } +} + +/*! + \property QVideoWidget::fullScreen + \brief whether video display is confined to a window or is fullScreen. + \since 1.0 +*/ + +void QVideoWidget::setFullScreen(bool fullScreen) +{ + Q_D(QVideoWidget); + + if (fullScreen) { + Qt::WindowFlags flags = windowFlags(); + + d->nonFullScreenFlags = flags & (Qt::Window | Qt::SubWindow); + flags |= Qt::Window; + flags &= ~Qt::SubWindow; + setWindowFlags(flags); + + showFullScreen(); + } else { + showNormal(); + } +} + +/*! + \fn QVideoWidget::fullScreenChanged(bool fullScreen) + + Signals that the \a fullScreen mode of a video widget has changed. + + \since 1.0 + \sa fullScreen +*/ + +/*! + \property QVideoWidget::brightness + \brief an adjustment to the brightness of displayed video. + + Valid brightness values range between -100 and 100, the default is 0. + \since 1.0 +*/ + +int QVideoWidget::brightness() const +{ + return d_func()->brightness; +} + +void QVideoWidget::setBrightness(int brightness) +{ + Q_D(QVideoWidget); + + int boundedBrightness = qBound(-100, brightness, 100); + + if (d->currentControl) + d->currentControl->setBrightness(boundedBrightness); + else if (d->brightness != boundedBrightness) + emit brightnessChanged(d->brightness = boundedBrightness); +} + +/*! + \fn QVideoWidget::brightnessChanged(int brightness) + + Signals that a video widgets's \a brightness adjustment has changed. + + \since 1.0 + \sa brightness +*/ + +/*! + \property QVideoWidget::contrast + \brief an adjustment to the contrast of displayed video. + + Valid contrast values range between -100 and 100, the default is 0. + + \since 1.0 +*/ + +int QVideoWidget::contrast() const +{ + return d_func()->contrast; +} + +void QVideoWidget::setContrast(int contrast) +{ + Q_D(QVideoWidget); + + int boundedContrast = qBound(-100, contrast, 100); + + if (d->currentControl) + d->currentControl->setContrast(boundedContrast); + else if (d->contrast != boundedContrast) + emit contrastChanged(d->contrast = boundedContrast); +} + +/*! + \fn QVideoWidget::contrastChanged(int contrast) + + Signals that a video widgets's \a contrast adjustment has changed. + + \since 1.0 + \sa contrast +*/ + +/*! + \property QVideoWidget::hue + \brief an adjustment to the hue of displayed video. + + Valid hue values range between -100 and 100, the default is 0. + \since 1.0 +*/ + +int QVideoWidget::hue() const +{ + return d_func()->hue; +} + +void QVideoWidget::setHue(int hue) +{ + Q_D(QVideoWidget); + + int boundedHue = qBound(-100, hue, 100); + + if (d->currentControl) + d->currentControl->setHue(boundedHue); + else if (d->hue != boundedHue) + emit hueChanged(d->hue = boundedHue); +} + +/*! + \fn QVideoWidget::hueChanged(int hue) + + Signals that a video widgets's \a hue has changed. + + \since 1.0 + \sa hue +*/ + +/*! + \property QVideoWidget::saturation + \brief an adjustment to the saturation of displayed video. + + Valid saturation values range between -100 and 100, the default is 0. + \since 1.0 +*/ + +int QVideoWidget::saturation() const +{ + return d_func()->saturation; +} + +void QVideoWidget::setSaturation(int saturation) +{ + Q_D(QVideoWidget); + + int boundedSaturation = qBound(-100, saturation, 100); + + if (d->currentControl) + d->currentControl->setSaturation(boundedSaturation); + else if (d->saturation != boundedSaturation) + emit saturationChanged(d->saturation = boundedSaturation); + +} + +/*! + \fn QVideoWidget::saturationChanged(int saturation) + + Signals that a video widgets's \a saturation has changed. + + \since 1.0 + \sa saturation +*/ + +/*! + Returns the size hint for the current back end, + if there is one, or else the size hint from QWidget. + \since 1.0 + */ +QSize QVideoWidget::sizeHint() const +{ + Q_D(const QVideoWidget); + + if (d->currentBackend) + return d->currentBackend->sizeHint(); + else + return QWidget::sizeHint(); + + +} + +/*! + Current event \a event. + Returns the value of the baseclass QWidget::event(QEvent *event) function. + \since 1.0 +*/ +bool QVideoWidget::event(QEvent *event) +{ + Q_D(QVideoWidget); + + if (event->type() == QEvent::WindowStateChange) { + Qt::WindowFlags flags = windowFlags(); + + if (windowState() & Qt::WindowFullScreen) { + if (d->currentControl) + d->currentControl->setFullScreen(true); + + if (!d->wasFullScreen) + emit fullScreenChanged(d->wasFullScreen = true); + } else { + if (d->currentControl) + d->currentControl->setFullScreen(false); + + if (d->wasFullScreen) { + flags &= ~(Qt::Window | Qt::SubWindow); //clear the flags... + flags |= d->nonFullScreenFlags; //then we reset the flags (window and subwindow) + setWindowFlags(flags); + + emit fullScreenChanged(d->wasFullScreen = false); + } + } + } + return QWidget::event(event); +} + +/*! + Handles the show \a event. + \since 1.0 + */ +void QVideoWidget::showEvent(QShowEvent *event) +{ + Q_D(QVideoWidget); + + QWidget::showEvent(event); + + // The window backend won't work for re-directed windows so use the renderer backend instead. + if (d->windowBackend && window()->testAttribute(Qt::WA_DontShowOnScreen)) { + d->windowBackend->releaseControl(); + + delete d->windowBackend; + d->windowBackend = 0; + + d->createRendererBackend(); + } + + if (d->currentBackend) + d->currentBackend->showEvent(); +} + +/*! + + Handles the hide \a event. + \since 1.0 +*/ +void QVideoWidget::hideEvent(QHideEvent *event) +{ + Q_D(QVideoWidget); + + if (d->currentBackend) + d->currentBackend->hideEvent(event); + + QWidget::hideEvent(event); +} + +/*! + Handles the resize \a event. + \since 1.0 + */ +void QVideoWidget::resizeEvent(QResizeEvent *event) +{ + Q_D(QVideoWidget); + + QWidget::resizeEvent(event); + + if (d->currentBackend) + d->currentBackend->resizeEvent(event); +} + +/*! + Handles the move \a event. + \since 1.0 + */ +void QVideoWidget::moveEvent(QMoveEvent *event) +{ + Q_D(QVideoWidget); + + if (d->currentBackend) + d->currentBackend->moveEvent(event); +} + +/*! + Handles the paint \a event. + \since 1.0 + */ +void QVideoWidget::paintEvent(QPaintEvent *event) +{ + Q_D(QVideoWidget); + + if (d->currentBackend) { + d->currentBackend->paintEvent(event); + } else if (testAttribute(Qt::WA_OpaquePaintEvent)) { + QPainter painter(this); + + painter.fillRect(event->rect(), palette().window()); + } +} + + +#if defined(Q_WS_WIN) +/*! + \reimp + \internal + \since 1.1 +*/ +bool QVideoWidget::winEvent(MSG *message, long *result) +{ + return d_func()->windowBackend && d_func()->windowBackend->winEvent(message, result) + ? true + : QWidget::winEvent(message, result); +} +#endif + + +#include "moc_qvideowidget.cpp" +#include "moc_qvideowidget_p.cpp" +QT_END_NAMESPACE + diff --git a/src/multimediawidgets/qvideowidget.h b/src/multimediawidgets/qvideowidget.h new file mode 100644 index 000000000..c4c6f8d3f --- /dev/null +++ b/src/multimediawidgets/qvideowidget.h @@ -0,0 +1,139 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QVIDEOWIDGET_H +#define QVIDEOWIDGET_H + +#include + +#include +#include + +QT_BEGIN_HEADER + +QT_BEGIN_NAMESPACE + +QT_MODULE(Multimedia) + + +class QMediaObject; + +class QVideoWidgetPrivate; +class Q_MULTIMEDIA_EXPORT QVideoWidget : public QWidget, public QMediaBindableInterface +{ + Q_OBJECT + Q_INTERFACES(QMediaBindableInterface) + Q_PROPERTY(QMediaObject* mediaObject READ mediaObject WRITE setMediaObject) + Q_PROPERTY(bool fullScreen READ isFullScreen WRITE setFullScreen NOTIFY fullScreenChanged) + Q_PROPERTY(Qt::AspectRatioMode aspectRatioMode READ aspectRatioMode WRITE setAspectRatioMode) + Q_PROPERTY(int brightness READ brightness WRITE setBrightness NOTIFY brightnessChanged) + Q_PROPERTY(int contrast READ contrast WRITE setContrast NOTIFY contrastChanged) + Q_PROPERTY(int hue READ hue WRITE setHue NOTIFY hueChanged) + Q_PROPERTY(int saturation READ saturation WRITE setSaturation NOTIFY saturationChanged) + +public: + QVideoWidget(QWidget *parent = 0); + ~QVideoWidget(); + + QMediaObject *mediaObject() const; + +#ifdef Q_QDOC + bool isFullScreen() const; +#endif + + Qt::AspectRatioMode aspectRatioMode() const; + + int brightness() const; + int contrast() const; + int hue() const; + int saturation() const; + + QSize sizeHint() const; + +public Q_SLOTS: + void setFullScreen(bool fullScreen); + void setAspectRatioMode(Qt::AspectRatioMode mode); + void setBrightness(int brightness); + void setContrast(int contrast); + void setHue(int hue); + void setSaturation(int saturation); + +Q_SIGNALS: + void fullScreenChanged(bool fullScreen); + void brightnessChanged(int brightness); + void contrastChanged(int contrast); + void hueChanged(int hue); + void saturationChanged(int saturation); + +protected: + bool event(QEvent *event); + void showEvent(QShowEvent *event); + void hideEvent(QHideEvent *event); + void resizeEvent(QResizeEvent *event); + void moveEvent(QMoveEvent *event); + void paintEvent(QPaintEvent *event); + + bool setMediaObject(QMediaObject *object); + +#if defined(Q_WS_WIN) + bool winEvent(MSG *message, long *result); +#endif + + QVideoWidget(QVideoWidgetPrivate &dd, QWidget *parent); + QVideoWidgetPrivate *d_ptr; + +private: + Q_DECLARE_PRIVATE(QVideoWidget) + Q_PRIVATE_SLOT(d_func(), void _q_serviceDestroyed()) + Q_PRIVATE_SLOT(d_func(), void _q_brightnessChanged(int)) + Q_PRIVATE_SLOT(d_func(), void _q_contrastChanged(int)) + Q_PRIVATE_SLOT(d_func(), void _q_hueChanged(int)) + Q_PRIVATE_SLOT(d_func(), void _q_saturationChanged(int)) + Q_PRIVATE_SLOT(d_func(), void _q_fullScreenChanged(bool)) + Q_PRIVATE_SLOT(d_func(), void _q_dimensionsChanged()) +}; + +QT_END_NAMESPACE + +QT_END_HEADER + + +#endif diff --git a/src/multimediawidgets/qvideowidget_p.h b/src/multimediawidgets/qvideowidget_p.h new file mode 100644 index 000000000..df1d86df0 --- /dev/null +++ b/src/multimediawidgets/qvideowidget_p.h @@ -0,0 +1,290 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QVIDEOWIDGET_P_H +#define QVIDEOWIDGET_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 +#include "qvideowidget.h" + +#ifndef QT_NO_OPENGL +#include +#endif + +#include "qpaintervideosurface_p.h" + +#include + +QT_BEGIN_HEADER + +QT_BEGIN_NAMESPACE + +QT_MODULE(Multimedia) + + +class QMediaService; + +class QVideoWidgetControlInterface +{ +public: + virtual ~QVideoWidgetControlInterface() {} + + virtual void setBrightness(int brightness) = 0; + virtual void setContrast(int contrast) = 0; + virtual void setHue(int hue) = 0; + virtual void setSaturation(int saturation) = 0; + + virtual void setFullScreen(bool fullScreen) = 0; + + virtual Qt::AspectRatioMode aspectRatioMode() const = 0; + virtual void setAspectRatioMode(Qt::AspectRatioMode mode) = 0; +}; + +class QVideoWidgetBackend : public QObject, public QVideoWidgetControlInterface +{ + Q_OBJECT +public: + virtual QSize sizeHint() const = 0; + + virtual void showEvent() = 0; + virtual void hideEvent(QHideEvent *event) = 0; + virtual void resizeEvent(QResizeEvent *event) = 0; + virtual void moveEvent(QMoveEvent *event) = 0; + virtual void paintEvent(QPaintEvent *event) = 0; +}; + +class QVideoWidgetControl; + +class QVideoWidgetControlBackend : public QObject, public QVideoWidgetControlInterface +{ + Q_OBJECT +public: + QVideoWidgetControlBackend(QMediaService *service, QVideoWidgetControl *control, QWidget *widget); + + void releaseControl(); + + void setBrightness(int brightness); + void setContrast(int contrast); + void setHue(int hue); + void setSaturation(int saturation); + + void setFullScreen(bool fullScreen); + + Qt::AspectRatioMode aspectRatioMode() const; + void setAspectRatioMode(Qt::AspectRatioMode mode); + +private: + QMediaService *m_service; + QVideoWidgetControl *m_widgetControl; +}; + + +class QVideoRendererControl; + +class QRendererVideoWidgetBackend : public QVideoWidgetBackend +{ + Q_OBJECT +public: + QRendererVideoWidgetBackend(QMediaService *service, QVideoRendererControl *control, QWidget *widget); + ~QRendererVideoWidgetBackend(); + + void releaseControl(); + void clearSurface(); + + void setBrightness(int brightness); + void setContrast(int contrast); + void setHue(int hue); + void setSaturation(int saturation); + + void setFullScreen(bool fullScreen); + + Qt::AspectRatioMode aspectRatioMode() const; + void setAspectRatioMode(Qt::AspectRatioMode mode); + + QSize sizeHint() const; + + void showEvent(); + void hideEvent(QHideEvent *event); + void resizeEvent(QResizeEvent *event); + void moveEvent(QMoveEvent *event); + void paintEvent(QPaintEvent *event); + +Q_SIGNALS: + void fullScreenChanged(bool fullScreen); + void brightnessChanged(int brightness); + void contrastChanged(int contrast); + void hueChanged(int hue); + void saturationChanged(int saturation); + +private Q_SLOTS: + void formatChanged(const QVideoSurfaceFormat &format); + void frameChanged(); + +private: + void updateRects(); + + QMediaService *m_service; + QVideoRendererControl *m_rendererControl; + QWidget *m_widget; + QPainterVideoSurface *m_surface; + Qt::AspectRatioMode m_aspectRatioMode; + QRect m_boundingRect; + QRectF m_sourceRect; + QSize m_nativeSize; + bool m_updatePaintDevice; +}; + +class QVideoWindowControl; + +class QWindowVideoWidgetBackend : public QVideoWidgetBackend +{ + Q_OBJECT +public: + QWindowVideoWidgetBackend(QMediaService *service, QVideoWindowControl *control, QWidget *widget); + ~QWindowVideoWidgetBackend(); + + void releaseControl(); + + void setBrightness(int brightness); + void setContrast(int contrast); + void setHue(int hue); + void setSaturation(int saturation); + + void setFullScreen(bool fullScreen); + + Qt::AspectRatioMode aspectRatioMode() const; + void setAspectRatioMode(Qt::AspectRatioMode mode); + + QSize sizeHint() const; + + void showEvent(); + void hideEvent(QHideEvent *event); + void resizeEvent(QResizeEvent *event); + void moveEvent(QMoveEvent *event); + void paintEvent(QPaintEvent *event); + +#if defined(Q_WS_WIN) + bool winEvent(MSG *message, long *result); +#endif + +private: + QMediaService *m_service; + QVideoWindowControl *m_windowControl; + QWidget *m_widget; + Qt::AspectRatioMode m_aspectRatioMode; + QSize m_pixelAspectRatio; +}; + +class QMediaService; +class QVideoOutputControl; + +class QVideoWidgetPrivate +{ + Q_DECLARE_PUBLIC(QVideoWidget) +public: + QVideoWidgetPrivate() + : q_ptr(0) + , mediaObject(0) + , service(0) + , widgetBackend(0) + , windowBackend(0) + , rendererBackend(0) + , currentControl(0) + , currentBackend(0) + , brightness(0) + , contrast(0) + , hue(0) + , saturation(0) + , aspectRatioMode(Qt::KeepAspectRatio) + , nonFullScreenFlags(0) + , wasFullScreen(false) + { + } + + QVideoWidget *q_ptr; + QPointer mediaObject; + QMediaService *service; + QVideoWidgetControlBackend *widgetBackend; + QWindowVideoWidgetBackend *windowBackend; + QRendererVideoWidgetBackend *rendererBackend; + QVideoWidgetControlInterface *currentControl; + QVideoWidgetBackend *currentBackend; + int brightness; + int contrast; + int hue; + int saturation; + Qt::AspectRatioMode aspectRatioMode; + Qt::WindowFlags nonFullScreenFlags; + bool wasFullScreen; + + bool createWidgetBackend(); + bool createWindowBackend(); + bool createRendererBackend(); + + void setCurrentControl(QVideoWidgetControlInterface *control); + void clearService(); + + void _q_serviceDestroyed(); + void _q_brightnessChanged(int brightness); + void _q_contrastChanged(int contrast); + void _q_hueChanged(int hue); + void _q_saturationChanged(int saturation); + void _q_fullScreenChanged(bool fullScreen); + void _q_dimensionsChanged(); +}; + +QT_END_NAMESPACE + +QT_END_HEADER + + +#endif diff --git a/src/multimediawidgets/qvideowidgetcontrol.cpp b/src/multimediawidgets/qvideowidgetcontrol.cpp new file mode 100644 index 000000000..e153030f2 --- /dev/null +++ b/src/multimediawidgets/qvideowidgetcontrol.cpp @@ -0,0 +1,245 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qvideowidgetcontrol.h" +#include "private/qmediacontrol_p.h" + +QT_BEGIN_NAMESPACE + +/*! + \class QVideoWidgetControl + + + \brief The QVideoWidgetControl class provides a media control which + implements a video widget. + + \inmodule QtMultimedia + \ingroup multimedia-serv + \since 1.0 + + The videoWidget() property of QVideoWidgetControl provides a pointer to a + video widget implemented by the control's media service. This widget is + owned by the media service and so care should be taken not to delete it. + + \snippet doc/src/snippets/multimedia-snippets/video.cpp Video widget control + + QVideoWidgetControl is one of number of possible video output controls. + + The interface name of QVideoWidgetControl is \c com.nokia.Qt.QVideoWidgetControl/1.0 as + defined in QVideoWidgetControl_iid. + + \sa QMediaService::requestControl(), QVideoWidget +*/ + +/*! + \macro QVideoWidgetControl_iid + + \c com.nokia.Qt.QVideoWidgetControl/1.0 + + Defines the interface name of the QVideoWidgetControl class. + + \relates QVideoWidgetControl +*/ + +/*! + Constructs a new video widget control with the given \a parent. +*/ +QVideoWidgetControl::QVideoWidgetControl(QObject *parent) + :QMediaControl(parent) +{ +} + +/*! + Destroys a video widget control. +*/ +QVideoWidgetControl::~QVideoWidgetControl() +{ +} + +/*! + \fn QVideoWidgetControl::isFullScreen() const + + Returns true if the video is shown using the complete screen. + \since 1.0 +*/ + +/*! + \fn QVideoWidgetControl::setFullScreen(bool fullScreen) + + Sets whether a video widget is in \a fullScreen mode. + \since 1.0 +*/ + +/*! + \fn QVideoWidgetControl::fullScreenChanged(bool fullScreen) + + Signals that the \a fullScreen state of a video widget has changed. + \since 1.0 +*/ + +/*! + \fn QVideoWidgetControl::aspectRatioMode() const + + Returns how video is scaled to fit the widget with respect to its aspect ratio. + \since 1.0 +*/ + +/*! + \fn QVideoWidgetControl::setAspectRatioMode(Qt::AspectRatioMode mode) + + Sets the aspect ratio \a mode which determines how video is scaled to the fit the widget with + respect to its aspect ratio. + \since 1.0 +*/ + +/*! + \fn QVideoWidgetControl::brightness() const + + Returns the brightness adjustment applied to a video. + + Valid brightness values range between -100 and 100, the default is 0. + \since 1.0 +*/ + +/*! + \fn QVideoWidgetControl::setBrightness(int brightness) + + Sets a \a brightness adjustment for a video. + + Valid brightness values range between -100 and 100, the default is 0. + \since 1.0 +*/ + +/*! + \fn QVideoWidgetControl::brightnessChanged(int brightness) + + Signals that a video widget's \a brightness adjustment has changed. + \since 1.0 +*/ + +/*! + \fn QVideoWidgetControl::contrast() const + + Returns the contrast adjustment applied to a video. + + Valid contrast values range between -100 and 100, the default is 0. + \since 1.0 +*/ + +/*! + \fn QVideoWidgetControl::setContrast(int contrast) + + Sets the contrast adjustment for a video widget to \a contrast. + + Valid contrast values range between -100 and 100, the default is 0. + \since 1.0 +*/ + + +/*! + \fn QVideoWidgetControl::contrastChanged(int contrast) + + Signals that a video widget's \a contrast adjustment has changed. + \since 1.0 +*/ + +/*! + \fn QVideoWidgetControl::hue() const + + Returns the hue adjustment applied to a video widget. + + Value hue values range between -100 and 100, the default is 0. + \since 1.0 +*/ + +/*! + \fn QVideoWidgetControl::setHue(int hue) + + Sets a \a hue adjustment for a video widget. + + Valid hue values range between -100 and 100, the default is 0. + \since 1.0 +*/ + + +/*! + \fn QVideoWidgetControl::hueChanged(int hue) + + Signals that a video widget's \a hue adjustment has changed. + \since 1.0 +*/ + +/*! + \fn QVideoWidgetControl::saturation() const + + Returns the saturation adjustment applied to a video widget. + + Value saturation values range between -100 and 100, the default is 0. + \since 1.0 +*/ + + +/*! + \fn QVideoWidgetControl::setSaturation(int saturation) + + Sets a \a saturation adjustment for a video widget. + + Valid saturation values range between -100 and 100, the default is 0. + \since 1.0 +*/ + +/*! + \fn QVideoWidgetControl::saturationChanged(int saturation) + + Signals that a video widget's \a saturation adjustment has changed. + \since 1.0 +*/ + +/*! + \fn QVideoWidgetControl::videoWidget() + + Returns the QWidget. + \since 1.0 +*/ + +#include "moc_qvideowidgetcontrol.cpp" +QT_END_NAMESPACE + diff --git a/src/multimediawidgets/qvideowidgetcontrol.h b/src/multimediawidgets/qvideowidgetcontrol.h new file mode 100644 index 000000000..c5ac880fa --- /dev/null +++ b/src/multimediawidgets/qvideowidgetcontrol.h @@ -0,0 +1,105 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QVIDEOWIDGETCONTROL_H +#define QVIDEOWIDGETCONTROL_H + +#include "qvideowidget.h" +#include "qmediacontrol.h" + +#include + +QT_BEGIN_HEADER + +QT_BEGIN_NAMESPACE + +QT_MODULE(Multimedia) + + +class QVideoWidgetControlPrivate; + +class Q_MULTIMEDIA_EXPORT QVideoWidgetControl : public QMediaControl +{ + Q_OBJECT + +public: + virtual ~QVideoWidgetControl(); + + virtual QWidget *videoWidget() = 0; + + virtual Qt::AspectRatioMode aspectRatioMode() const = 0; + virtual void setAspectRatioMode(Qt::AspectRatioMode mode) = 0; + + virtual bool isFullScreen() const = 0; + virtual void setFullScreen(bool fullScreen) = 0; + + virtual int brightness() const = 0; + virtual void setBrightness(int brightness) = 0; + + virtual int contrast() const = 0; + virtual void setContrast(int contrast) = 0; + + virtual int hue() const = 0; + virtual void setHue(int hue) = 0; + + virtual int saturation() const = 0; + virtual void setSaturation(int saturation) = 0; + +Q_SIGNALS: + void fullScreenChanged(bool fullScreen); + void brightnessChanged(int brightness); + void contrastChanged(int contrast); + void hueChanged(int hue); + void saturationChanged(int saturation); + +protected: + QVideoWidgetControl(QObject *parent = 0); +}; + +#define QVideoWidgetControl_iid "com.nokia.Qt.QVideoWidgetControl/1.0" +Q_MEDIA_DECLARE_CONTROL(QVideoWidgetControl, QVideoWidgetControl_iid) + +QT_END_NAMESPACE + +QT_END_HEADER + + +#endif diff --git a/src/multimediawidgets/qvideowindowcontrol.cpp b/src/multimediawidgets/qvideowindowcontrol.cpp new file mode 100644 index 000000000..d96391947 --- /dev/null +++ b/src/multimediawidgets/qvideowindowcontrol.cpp @@ -0,0 +1,284 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qvideowindowcontrol.h" + +QT_BEGIN_NAMESPACE + +/*! + \class QVideoWindowControl + + \inmodule QtMultimedia + \ingroup multimedia-serv + \brief The QVideoWindowControl class provides a media control for rendering video to a window. + \since 1.0 + + + The winId() property QVideoWindowControl allows a platform specific window + ID to be set as the video render target of a QMediaService. The + displayRect() property is used to set the region of the window the video + should be rendered to, and the aspectRatioMode() property indicates how the + video should be scaled to fit the displayRect(). + + \snippet doc/src/snippets/multimedia-snippets/video.cpp Video window control + + QVideoWindowControl is one of a number of possible video output controls. + + The interface name of QVideoWindowControl is \c com.nokia.Qt.QVideoWindowControl/1.0 as + defined in QVideoWindowControl_iid. + + \sa QMediaService::requestControl(), QVideoWidget +*/ + +/*! + \macro QVideoWindowControl_iid + + \c com.nokia.Qt.QVideoWindowControl/1.0 + + Defines the interface name of the QVideoWindowControl class. + + \relates QVideoWindowControl +*/ + +/*! + Constructs a new video window control with the given \a parent. +*/ +QVideoWindowControl::QVideoWindowControl(QObject *parent) + : QMediaControl(parent) +{ +} + +/*! + Destroys a video window control. +*/ +QVideoWindowControl::~QVideoWindowControl() +{ +} + +/*! + \fn QVideoWindowControl::winId() const + + Returns the ID of the window a video overlay end point renders to. + \since 1.0 +*/ + +/*! + \fn QVideoWindowControl::setWinId(WId id) + + Sets the \a id of the window a video overlay end point renders to. + \since 1.0 +*/ + +/*! + \fn QVideoWindowControl::displayRect() const + Returns the sub-rect of a window where video is displayed. + \since 1.0 +*/ + +/*! + \fn QVideoWindowControl::setDisplayRect(const QRect &rect) + Sets the sub-\a rect of a window where video is displayed. + \since 1.0 +*/ + +/*! + \fn QVideoWindowControl::isFullScreen() const + + Identifies if a video overlay is a fullScreen overlay. + + Returns true if the video overlay is fullScreen, and false otherwise. + \since 1.0 +*/ + +/*! + \fn QVideoWindowControl::setFullScreen(bool fullScreen) + + Sets whether a video overlay is a \a fullScreen overlay. + \since 1.0 +*/ + +/*! + \fn QVideoWindowControl::fullScreenChanged(bool fullScreen) + + Signals that the \a fullScreen state of a video overlay has changed. + \since 1.0 +*/ + +/*! + \fn QVideoWindowControl::repaint() + + Repaints the last frame. + \since 1.0 +*/ + +/*! + \fn QVideoWindowControl::nativeSize() const + + Returns a suggested size for the video display based on the resolution and aspect ratio of the + video. + \since 1.0 +*/ + +/*! + \fn QVideoWindowControl::nativeSizeChanged() + + Signals that the native dimensions of the video have changed. + \since 1.0 +*/ + + +/*! + \fn QVideoWindowControl::aspectRatioMode() const + + Returns how video is scaled to fit the display region with respect to its aspect ratio. + \since 1.0 +*/ + +/*! + \fn QVideoWindowControl::setAspectRatioMode(Qt::AspectRatioMode mode) + + Sets the aspect ratio \a mode which determines how video is scaled to the fit the display region + with respect to its aspect ratio. + \since 1.0 +*/ + +/*! + \fn QVideoWindowControl::brightness() const + + Returns the brightness adjustment applied to a video overlay. + + Valid brightness values range between -100 and 100, the default is 0. + \since 1.0 +*/ + +/*! + \fn QVideoWindowControl::setBrightness(int brightness) + + Sets a \a brightness adjustment for a video overlay. + + Valid brightness values range between -100 and 100, the default is 0. + \since 1.0 +*/ + +/*! + \fn QVideoWindowControl::brightnessChanged(int brightness) + + Signals that a video overlay's \a brightness adjustment has changed. + \since 1.0 +*/ + +/*! + \fn QVideoWindowControl::contrast() const + + Returns the contrast adjustment applied to a video overlay. + + Valid contrast values range between -100 and 100, the default is 0. + \since 1.0 +*/ + +/*! + \fn QVideoWindowControl::setContrast(int contrast) + + Sets the \a contrast adjustment for a video overlay. + + Valid contrast values range between -100 and 100, the default is 0. + \since 1.0 +*/ + +/*! + \fn QVideoWindowControl::contrastChanged(int contrast) + + Signals that a video overlay's \a contrast adjustment has changed. + \since 1.0 +*/ + +/*! + \fn QVideoWindowControl::hue() const + + Returns the hue adjustment applied to a video overlay. + + Value hue values range between -100 and 100, the default is 0. + \since 1.0 +*/ + +/*! + \fn QVideoWindowControl::setHue(int hue) + + Sets a \a hue adjustment for a video overlay. + + Valid hue values range between -100 and 100, the default is 0. + \since 1.0 +*/ + +/*! + \fn QVideoWindowControl::hueChanged(int hue) + + Signals that a video overlay's \a hue adjustment has changed. + \since 1.0 +*/ + +/*! + \fn QVideoWindowControl::saturation() const + + Returns the saturation adjustment applied to a video overlay. + + Value saturation values range between -100 and 100, the default is 0. + \since 1.0 +*/ + +/*! + \fn QVideoWindowControl::setSaturation(int saturation) + Sets a \a saturation adjustment for a video overlay. + + Valid saturation values range between -100 and 100, the default is 0. + \since 1.0 +*/ + +/*! + \fn QVideoWindowControl::saturationChanged(int saturation) + + Signals that a video overlay's \a saturation adjustment has changed. + \since 1.0 +*/ + +#include "moc_qvideowindowcontrol.cpp" +QT_END_NAMESPACE + diff --git a/src/multimediawidgets/qvideowindowcontrol.h b/src/multimediawidgets/qvideowindowcontrol.h new file mode 100644 index 000000000..590ce64be --- /dev/null +++ b/src/multimediawidgets/qvideowindowcontrol.h @@ -0,0 +1,112 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QVIDEOWINDOWCONTROL_H +#define QVIDEOWINDOWCONTROL_H + +#include "qmediacontrol.h" +#include "qvideowidget.h" + +#include + +QT_BEGIN_HEADER + +QT_BEGIN_NAMESPACE + +QT_MODULE(Multimedia) + + +class Q_MULTIMEDIA_EXPORT QVideoWindowControl : public QMediaControl +{ + Q_OBJECT + +public: + ~QVideoWindowControl(); + + virtual WId winId() const = 0; + virtual void setWinId(WId id) = 0; + + virtual QRect displayRect() const = 0; + virtual void setDisplayRect(const QRect &rect) = 0; + + virtual bool isFullScreen() const = 0; + virtual void setFullScreen(bool fullScreen) = 0; + + virtual void repaint() = 0; + + virtual QSize nativeSize() const = 0; + + virtual Qt::AspectRatioMode aspectRatioMode() const = 0; + virtual void setAspectRatioMode(Qt::AspectRatioMode mode) = 0; + + virtual int brightness() const = 0; + virtual void setBrightness(int brightness) = 0; + + virtual int contrast() const = 0; + virtual void setContrast(int contrast) = 0; + + virtual int hue() const = 0; + virtual void setHue(int hue) = 0; + + virtual int saturation() const = 0; + virtual void setSaturation(int saturation) = 0; + +Q_SIGNALS: + void fullScreenChanged(bool fullScreen); + void brightnessChanged(int brightness); + void contrastChanged(int contrast); + void hueChanged(int hue); + void saturationChanged(int saturation); + void nativeSizeChanged(); + +protected: + QVideoWindowControl(QObject *parent = 0); +}; + +#define QVideoWindowControl_iid "com.nokia.Qt.QVideoWindowControl/1.0" +Q_MEDIA_DECLARE_CONTROL(QVideoWindowControl, QVideoWindowControl_iid) + +QT_END_NAMESPACE + +QT_END_HEADER + + +#endif diff --git a/src/plugins/audiocapture/audiocapture.pro b/src/plugins/audiocapture/audiocapture.pro index a776b7e22..8b30b2aa7 100644 --- a/src/plugins/audiocapture/audiocapture.pro +++ b/src/plugins/audiocapture/audiocapture.pro @@ -1,11 +1,11 @@ load(qt_module) TARGET = qtmedia_audioengine -QT += multimediakit-private +QT += multimedia-private PLUGIN_TYPE=mediaservice load(qt_plugin) -DESTDIR = $$QT.multimediakit.plugins/$${PLUGIN_TYPE} +DESTDIR = $$QT.multimedia.plugins/$${PLUGIN_TYPE} # Input HEADERS += audioencodercontrol.h \ diff --git a/src/plugins/audiocapture/audioencodercontrol.cpp b/src/plugins/audiocapture/audioencodercontrol.cpp index df8526694..ce2ab42e8 100644 --- a/src/plugins/audiocapture/audioencodercontrol.cpp +++ b/src/plugins/audiocapture/audioencodercontrol.cpp @@ -60,12 +60,12 @@ AudioEncoderControl::AudioEncoderControl(QObject *parent) fmt.setByteOrder(QAudioFormat::LittleEndian); m_session->setFormat(fmt); - m_settings.setEncodingMode(QtMultimediaKit::ConstantQualityEncoding); + m_settings.setEncodingMode(QtMultimedia::ConstantQualityEncoding); m_settings.setCodec("audio/pcm"); m_settings.setBitRate(8000); m_settings.setChannelCount(1); m_settings.setSampleRate(8000); - m_settings.setQuality(QtMultimediaKit::LowQuality); + m_settings.setQuality(QtMultimedia::LowQuality); } AudioEncoderControl::~AudioEncoderControl() @@ -130,14 +130,14 @@ void AudioEncoderControl::setAudioSettings(const QAudioEncoderSettings &settings { QAudioFormat fmt = m_session->format(); - if (settings.encodingMode() == QtMultimediaKit::ConstantQualityEncoding) { - if (settings.quality() == QtMultimediaKit::LowQuality) { + if (settings.encodingMode() == QtMultimedia::ConstantQualityEncoding) { + if (settings.quality() == QtMultimedia::LowQuality) { fmt.setSampleSize(8); fmt.setChannels(1); fmt.setFrequency(8000); fmt.setSampleType(QAudioFormat::UnSignedInt); - } else if (settings.quality() == QtMultimediaKit::NormalQuality) { + } else if (settings.quality() == QtMultimedia::NormalQuality) { fmt.setSampleSize(16); fmt.setChannels(1); fmt.setFrequency(22050); diff --git a/src/plugins/directshow/directshow.pro b/src/plugins/directshow/directshow.pro index e2a37e612..80d588fd9 100644 --- a/src/plugins/directshow/directshow.pro +++ b/src/plugins/directshow/directshow.pro @@ -6,11 +6,8 @@ TARGET = $$qtLibraryTarget(dsengine) PLUGIN_TYPE=mediaservice include (../../../common.pri) -INCLUDEPATH+=../../multimediakit \ - ../../multimediakit/audio \ - ../../multimediakit/video -qtAddLibrary(QtMultimediaKit) +QT += multimedia DEPENDPATH += . diff --git a/src/plugins/directshow/player/directshowmetadatacontrol.cpp b/src/plugins/directshow/player/directshowmetadatacontrol.cpp index 7d7b3cef5..3bf2a32a3 100644 --- a/src/plugins/directshow/player/directshowmetadatacontrol.cpp +++ b/src/plugins/directshow/player/directshowmetadatacontrol.cpp @@ -54,76 +54,76 @@ namespace { struct QWMMetaDataKeyLookup { - QtMultimediaKit::MetaData key; + QtMultimedia::MetaData key; const wchar_t *token; }; } static const QWMMetaDataKeyLookup qt_wmMetaDataKeys[] = { - { QtMultimediaKit::Title, L"Title" }, - { QtMultimediaKit::SubTitle, L"WM/SubTitle" }, - { QtMultimediaKit::Author, L"Author" }, - { QtMultimediaKit::Comment, L"Comment" }, - { QtMultimediaKit::Description, L"Description" }, - { QtMultimediaKit::Category, L"WM/Category" }, - { QtMultimediaKit::Genre, L"WM/Genre" }, - //{ QtMultimediaKit::Date, 0 }, - { QtMultimediaKit::Year, L"WM/Year" }, - { QtMultimediaKit::UserRating, L"UserRating" }, - //{ QtMultimediaKit::MetaDatawords, 0 }, - { QtMultimediaKit::Language, L"Language" }, - { QtMultimediaKit::Publisher, L"WM/Publisher" }, - { QtMultimediaKit::Copyright, L"Copyright" }, - { QtMultimediaKit::ParentalRating, L"ParentalRating" }, - { QtMultimediaKit::RatingOrganisation, L"RatingOrganisation" }, + { QtMultimedia::Title, L"Title" }, + { QtMultimedia::SubTitle, L"WM/SubTitle" }, + { QtMultimedia::Author, L"Author" }, + { QtMultimedia::Comment, L"Comment" }, + { QtMultimedia::Description, L"Description" }, + { QtMultimedia::Category, L"WM/Category" }, + { QtMultimedia::Genre, L"WM/Genre" }, + //{ QtMultimedia::Date, 0 }, + { QtMultimedia::Year, L"WM/Year" }, + { QtMultimedia::UserRating, L"UserRating" }, + //{ QtMultimedia::MetaDatawords, 0 }, + { QtMultimedia::Language, L"Language" }, + { QtMultimedia::Publisher, L"WM/Publisher" }, + { QtMultimedia::Copyright, L"Copyright" }, + { QtMultimedia::ParentalRating, L"ParentalRating" }, + { QtMultimedia::RatingOrganisation, L"RatingOrganisation" }, // Media - { QtMultimediaKit::Size, L"FileSize" }, - { QtMultimediaKit::MediaType, L"MediaType" }, - { QtMultimediaKit::Duration, L"Duration" }, + { QtMultimedia::Size, L"FileSize" }, + { QtMultimedia::MediaType, L"MediaType" }, + { QtMultimedia::Duration, L"Duration" }, // Audio - { QtMultimediaKit::AudioBitRate, L"AudioBitRate" }, - { QtMultimediaKit::AudioCodec, L"AudioCodec" }, - { QtMultimediaKit::ChannelCount, L"ChannelCount" }, - { QtMultimediaKit::SampleRate, L"Frequency" }, + { QtMultimedia::AudioBitRate, L"AudioBitRate" }, + { QtMultimedia::AudioCodec, L"AudioCodec" }, + { QtMultimedia::ChannelCount, L"ChannelCount" }, + { QtMultimedia::SampleRate, L"Frequency" }, // Music - { QtMultimediaKit::AlbumTitle, L"WM/AlbumTitle" }, - { QtMultimediaKit::AlbumArtist, L"WM/AlbumArtist" }, - { QtMultimediaKit::ContributingArtist, L"Author" }, - { QtMultimediaKit::Composer, L"WM/Composer" }, - { QtMultimediaKit::Conductor, L"WM/Conductor" }, - { QtMultimediaKit::Lyrics, L"WM/Lyrics" }, - { QtMultimediaKit::Mood, L"WM/Mood" }, - { QtMultimediaKit::TrackNumber, L"WM/TrackNumber" }, - //{ QtMultimediaKit::TrackCount, 0 }, - //{ QtMultimediaKit::CoverArtUriSmall, 0 }, - //{ QtMultimediaKit::CoverArtUriLarge, 0 }, + { QtMultimedia::AlbumTitle, L"WM/AlbumTitle" }, + { QtMultimedia::AlbumArtist, L"WM/AlbumArtist" }, + { QtMultimedia::ContributingArtist, L"Author" }, + { QtMultimedia::Composer, L"WM/Composer" }, + { QtMultimedia::Conductor, L"WM/Conductor" }, + { QtMultimedia::Lyrics, L"WM/Lyrics" }, + { QtMultimedia::Mood, L"WM/Mood" }, + { QtMultimedia::TrackNumber, L"WM/TrackNumber" }, + //{ QtMultimedia::TrackCount, 0 }, + //{ QtMultimedia::CoverArtUriSmall, 0 }, + //{ QtMultimedia::CoverArtUriLarge, 0 }, // Image/Video - //{ QtMultimediaKit::Resolution, 0 }, - //{ QtMultimediaKit::PixelAspectRatio, 0 }, + //{ QtMultimedia::Resolution, 0 }, + //{ QtMultimedia::PixelAspectRatio, 0 }, // Video - //{ QtMultimediaKit::FrameRate, 0 }, - { QtMultimediaKit::VideoBitRate, L"VideoBitRate" }, - { QtMultimediaKit::VideoCodec, L"VideoCodec" }, + //{ QtMultimedia::FrameRate, 0 }, + { QtMultimedia::VideoBitRate, L"VideoBitRate" }, + { QtMultimedia::VideoCodec, L"VideoCodec" }, - //{ QtMultimediaKit::PosterUri, 0 }, + //{ QtMultimedia::PosterUri, 0 }, // Movie - { QtMultimediaKit::ChapterNumber, L"ChapterNumber" }, - { QtMultimediaKit::Director, L"WM/Director" }, - { QtMultimediaKit::LeadPerformer, L"LeadPerformer" }, - { QtMultimediaKit::Writer, L"WM/Writer" }, + { QtMultimedia::ChapterNumber, L"ChapterNumber" }, + { QtMultimedia::Director, L"WM/Director" }, + { QtMultimedia::LeadPerformer, L"LeadPerformer" }, + { QtMultimedia::Writer, L"WM/Writer" }, // Photos - { QtMultimediaKit::CameraManufacturer, L"CameraManufacturer" }, - { QtMultimediaKit::CameraModel, L"CameraModel" }, - { QtMultimediaKit::Event, L"Event" }, - { QtMultimediaKit::Subject, L"Subject" } + { QtMultimedia::CameraManufacturer, L"CameraManufacturer" }, + { QtMultimedia::CameraModel, L"CameraModel" }, + { QtMultimedia::Event, L"Event" }, + { QtMultimedia::Subject, L"Subject" } }; static QVariant getValue(IWMHeaderInfo *header, const wchar_t *key) @@ -249,7 +249,7 @@ bool DirectShowMetaDataControl::isMetaDataAvailable() const #endif } -QVariant DirectShowMetaDataControl::metaData(QtMultimediaKit::MetaData key) const +QVariant DirectShowMetaDataControl::metaData(QtMultimedia::MetaData key) const { QVariant value; @@ -269,19 +269,19 @@ QVariant DirectShowMetaDataControl::metaData(QtMultimediaKit::MetaData key) cons BSTR string = 0; switch (key) { - case QtMultimediaKit::Author: + case QtMultimedia::Author: m_content->get_AuthorName(&string); break; - case QtMultimediaKit::Title: + case QtMultimedia::Title: m_content->get_Title(&string); break; - case QtMultimediaKit::ParentalRating: + case QtMultimedia::ParentalRating: m_content->get_Rating(&string); break; - case QtMultimediaKit::Description: + case QtMultimedia::Description: m_content->get_Description(&string); break; - case QtMultimediaKit::Copyright: + case QtMultimedia::Copyright: m_content->get_Copyright(&string); break; default: @@ -297,9 +297,9 @@ QVariant DirectShowMetaDataControl::metaData(QtMultimediaKit::MetaData key) cons return value; } -QList DirectShowMetaDataControl::availableMetaData() const +QList DirectShowMetaDataControl::availableMetaData() const { - return QList(); + return QList(); } QVariant DirectShowMetaDataControl::extendedMetaData(const QString &) const diff --git a/src/plugins/directshow/player/directshowmetadatacontrol.h b/src/plugins/directshow/player/directshowmetadatacontrol.h index d7b046510..f5c65f12c 100644 --- a/src/plugins/directshow/player/directshowmetadatacontrol.h +++ b/src/plugins/directshow/player/directshowmetadatacontrol.h @@ -67,8 +67,8 @@ public: bool isMetaDataAvailable() const; - QVariant metaData(QtMultimediaKit::MetaData key) const; - QList availableMetaData() const; + QVariant metaData(QtMultimedia::MetaData key) const; + QList availableMetaData() const; QVariant extendedMetaData(const QString &key) const; QStringList availableExtendedMetaData() const; diff --git a/src/plugins/fakeradio/fakeradio.pro b/src/plugins/fakeradio/fakeradio.pro index f6a495aac..a91ebb927 100644 --- a/src/plugins/fakeradio/fakeradio.pro +++ b/src/plugins/fakeradio/fakeradio.pro @@ -1,11 +1,11 @@ load(qt_module) TARGET = qtmedia_fakeradio -QT += multimediakit-private +QT += multimedia-private PLUGIN_TYPE = mediaservice load(qt_plugin) -DESTDIR = $$QT.multimediakit.plugins/$${PLUGIN_TYPE} +DESTDIR = $$QT.multimedia.plugins/$${PLUGIN_TYPE} HEADERS += \ fakeradioserviceplugin.h \ diff --git a/src/plugins/fakeradio/fakeradiotunercontrol.cpp b/src/plugins/fakeradio/fakeradiotunercontrol.cpp index e36d816b0..d88d90ce6 100644 --- a/src/plugins/fakeradio/fakeradiotunercontrol.cpp +++ b/src/plugins/fakeradio/fakeradiotunercontrol.cpp @@ -79,9 +79,9 @@ bool FakeRadioTunerControl::isAvailable() const return true; } -QtMultimediaKit::AvailabilityError FakeRadioTunerControl::availabilityError() const +QtMultimedia::AvailabilityError FakeRadioTunerControl::availabilityError() const { - return QtMultimediaKit::NoError; + return QtMultimedia::NoError; } QRadioTuner::State FakeRadioTunerControl::state() const diff --git a/src/plugins/fakeradio/fakeradiotunercontrol.h b/src/plugins/fakeradio/fakeradiotunercontrol.h index a2faf2c02..abb45cf53 100644 --- a/src/plugins/fakeradio/fakeradiotunercontrol.h +++ b/src/plugins/fakeradio/fakeradiotunercontrol.h @@ -60,7 +60,7 @@ public: ~FakeRadioTunerControl(); bool isAvailable() const; - QtMultimediaKit::AvailabilityError availabilityError() const; + QtMultimedia::AvailabilityError availabilityError() const; QRadioTuner::State state() const; diff --git a/src/plugins/gstreamer/camerabin/camerabinimagecapture.cpp b/src/plugins/gstreamer/camerabin/camerabinimagecapture.cpp index f22b2642a..a73ec4bc7 100644 --- a/src/plugins/gstreamer/camerabin/camerabinimagecapture.cpp +++ b/src/plugins/gstreamer/camerabin/camerabinimagecapture.cpp @@ -55,7 +55,7 @@ #define IMAGE_DONE_SIGNAL "image-done" Q_DECLARE_METATYPE(QVideoFrame) -Q_DECLARE_METATYPE(QtMultimediaKit::MetaData) +Q_DECLARE_METATYPE(QtMultimedia::MetaData) namespace { @@ -65,7 +65,7 @@ public: CameraRegisterMetaTypes() { qRegisterMetaType("QVideoFrame"); - qRegisterMetaType("QtMultimediaKit::MetaData"); + qRegisterMetaType("QtMultimedia::MetaData"); } } _registerCameraMetaTypes; } @@ -140,26 +140,26 @@ gboolean CameraBinImageCapture::metadataEventProbe(GstPad *pad, GstEvent *event, qDebug() << "Capture event probe" << extendedTags; #endif - QMap tags; - tags[QtMultimediaKit::ISOSpeedRatings] = extendedTags.value("capturing-iso-speed"); - tags[QtMultimediaKit::DigitalZoomRatio] = extendedTags.value("capturing-digital-zoom-ratio"); - tags[QtMultimediaKit::ExposureTime] = extendedTags.value("capturing-shutter-speed"); - tags[QtMultimediaKit::WhiteBalance] = extendedTags.value("capturing-white-balance"); - tags[QtMultimediaKit::Flash] = extendedTags.value("capturing-flash-fired"); - tags[QtMultimediaKit::FocalLengthIn35mmFilm] = extendedTags.value("capturing-focal-length"); - tags[QtMultimediaKit::MeteringMode] = extendedTags.value("capturing-metering-mode"); - tags[QtMultimediaKit::ExposureMode] = extendedTags.value("capturing-exposure-mode"); - tags[QtMultimediaKit::FNumber] = extendedTags.value("capturing-focal-ratio"); - tags[QtMultimediaKit::ExposureMode] = extendedTags.value("capturing-exposure-mode"); - - QMapIterator i(tags); + QMap tags; + tags[QtMultimedia::ISOSpeedRatings] = extendedTags.value("capturing-iso-speed"); + tags[QtMultimedia::DigitalZoomRatio] = extendedTags.value("capturing-digital-zoom-ratio"); + tags[QtMultimedia::ExposureTime] = extendedTags.value("capturing-shutter-speed"); + tags[QtMultimedia::WhiteBalance] = extendedTags.value("capturing-white-balance"); + tags[QtMultimedia::Flash] = extendedTags.value("capturing-flash-fired"); + tags[QtMultimedia::FocalLengthIn35mmFilm] = extendedTags.value("capturing-focal-length"); + tags[QtMultimedia::MeteringMode] = extendedTags.value("capturing-metering-mode"); + tags[QtMultimedia::ExposureMode] = extendedTags.value("capturing-exposure-mode"); + tags[QtMultimedia::FNumber] = extendedTags.value("capturing-focal-ratio"); + tags[QtMultimedia::ExposureMode] = extendedTags.value("capturing-exposure-mode"); + + QMapIterator i(tags); while (i.hasNext()) { i.next(); if (i.value().isValid()) { QMetaObject::invokeMethod(self, "imageMetadataAvailable", Qt::QueuedConnection, Q_ARG(int, self->m_requestId), - Q_ARG(QtMultimediaKit::MetaData, i.key()), + Q_ARG(QtMultimedia::MetaData, i.key()), Q_ARG(QVariant, i.value())); } } diff --git a/src/plugins/gstreamer/camerabin/camerabinmetadata.cpp b/src/plugins/gstreamer/camerabin/camerabinmetadata.cpp index 9cfcde4e1..235f5b08e 100644 --- a/src/plugins/gstreamer/camerabin/camerabinmetadata.cpp +++ b/src/plugins/gstreamer/camerabin/camerabinmetadata.cpp @@ -46,77 +46,77 @@ struct QGstreamerMetaDataKeyLookup { - QtMultimediaKit::MetaData key; + QtMultimedia::MetaData key; const char *token; }; static const QGstreamerMetaDataKeyLookup qt_gstreamerMetaDataKeys[] = { - { QtMultimediaKit::Title, GST_TAG_TITLE }, - //{ QtMultimediaKit::SubTitle, 0 }, - //{ QtMultimediaKit::Author, 0 }, - { QtMultimediaKit::Comment, GST_TAG_COMMENT }, - { QtMultimediaKit::Description, GST_TAG_DESCRIPTION }, - //{ QtMultimediaKit::Category, 0 }, - { QtMultimediaKit::Genre, GST_TAG_GENRE }, - //{ QtMultimediaKit::Year, 0 }, - //{ QtMultimediaKit::UserRating, 0 }, - - { QtMultimediaKit::Language, GST_TAG_LANGUAGE_CODE }, - - { QtMultimediaKit::Publisher, GST_TAG_ORGANIZATION }, - { QtMultimediaKit::Copyright, GST_TAG_COPYRIGHT }, - //{ QtMultimediaKit::ParentalRating, 0 }, - //{ QtMultimediaKit::RatingOrganisation, 0 }, + { QtMultimedia::Title, GST_TAG_TITLE }, + //{ QtMultimedia::SubTitle, 0 }, + //{ QtMultimedia::Author, 0 }, + { QtMultimedia::Comment, GST_TAG_COMMENT }, + { QtMultimedia::Description, GST_TAG_DESCRIPTION }, + //{ QtMultimedia::Category, 0 }, + { QtMultimedia::Genre, GST_TAG_GENRE }, + //{ QtMultimedia::Year, 0 }, + //{ QtMultimedia::UserRating, 0 }, + + { QtMultimedia::Language, GST_TAG_LANGUAGE_CODE }, + + { QtMultimedia::Publisher, GST_TAG_ORGANIZATION }, + { QtMultimedia::Copyright, GST_TAG_COPYRIGHT }, + //{ QtMultimedia::ParentalRating, 0 }, + //{ QtMultimedia::RatingOrganisation, 0 }, // Media - //{ QtMultimediaKit::Size, 0 }, - //{ QtMultimediaKit::MediaType, 0 }, - { QtMultimediaKit::Duration, GST_TAG_DURATION }, + //{ QtMultimedia::Size, 0 }, + //{ QtMultimedia::MediaType, 0 }, + { QtMultimedia::Duration, GST_TAG_DURATION }, // Audio - { QtMultimediaKit::AudioBitRate, GST_TAG_BITRATE }, - { QtMultimediaKit::AudioCodec, GST_TAG_AUDIO_CODEC }, - //{ QtMultimediaKit::ChannelCount, 0 }, - //{ QtMultimediaKit::SampleRate, 0 }, + { QtMultimedia::AudioBitRate, GST_TAG_BITRATE }, + { QtMultimedia::AudioCodec, GST_TAG_AUDIO_CODEC }, + //{ QtMultimedia::ChannelCount, 0 }, + //{ QtMultimedia::SampleRate, 0 }, // Music - { QtMultimediaKit::AlbumTitle, GST_TAG_ALBUM }, - { QtMultimediaKit::AlbumArtist, GST_TAG_ARTIST}, - { QtMultimediaKit::ContributingArtist, GST_TAG_PERFORMER }, + { QtMultimedia::AlbumTitle, GST_TAG_ALBUM }, + { QtMultimedia::AlbumArtist, GST_TAG_ARTIST}, + { QtMultimedia::ContributingArtist, GST_TAG_PERFORMER }, #if (GST_VERSION_MAJOR >= 0) && (GST_VERSION_MINOR >= 10) && (GST_VERSION_MICRO >= 19) - { QtMultimediaKit::Composer, GST_TAG_COMPOSER }, + { QtMultimedia::Composer, GST_TAG_COMPOSER }, #endif - //{ QtMultimediaKit::Conductor, 0 }, - //{ QtMultimediaKit::Lyrics, 0 }, - //{ QtMultimediaKit::Mood, 0 }, - { QtMultimediaKit::TrackNumber, GST_TAG_TRACK_NUMBER }, + //{ QtMultimedia::Conductor, 0 }, + //{ QtMultimedia::Lyrics, 0 }, + //{ QtMultimedia::Mood, 0 }, + { QtMultimedia::TrackNumber, GST_TAG_TRACK_NUMBER }, - //{ QtMultimediaKit::CoverArtUrlSmall, 0 }, - //{ QtMultimediaKit::CoverArtUrlLarge, 0 }, + //{ QtMultimedia::CoverArtUrlSmall, 0 }, + //{ QtMultimedia::CoverArtUrlLarge, 0 }, // Image/Video - //{ QtMultimediaKit::Resolution, 0 }, - //{ QtMultimediaKit::PixelAspectRatio, 0 }, + //{ QtMultimedia::Resolution, 0 }, + //{ QtMultimedia::PixelAspectRatio, 0 }, // Video - //{ QtMultimediaKit::VideoFrameRate, 0 }, - //{ QtMultimediaKit::VideoBitRate, 0 }, - { QtMultimediaKit::VideoCodec, GST_TAG_VIDEO_CODEC }, + //{ QtMultimedia::VideoFrameRate, 0 }, + //{ QtMultimedia::VideoBitRate, 0 }, + { QtMultimedia::VideoCodec, GST_TAG_VIDEO_CODEC }, - //{ QtMultimediaKit::PosterUrl, 0 }, + //{ QtMultimedia::PosterUrl, 0 }, // Movie - //{ QtMultimediaKit::ChapterNumber, 0 }, - //{ QtMultimediaKit::Director, 0 }, - { QtMultimediaKit::LeadPerformer, GST_TAG_PERFORMER }, - //{ QtMultimediaKit::Writer, 0 }, + //{ QtMultimedia::ChapterNumber, 0 }, + //{ QtMultimedia::Director, 0 }, + { QtMultimedia::LeadPerformer, GST_TAG_PERFORMER }, + //{ QtMultimedia::Writer, 0 }, // Photos - //{ QtMultimediaKit::CameraManufacturer, 0 }, - //{ QtMultimediaKit::CameraModel, 0 }, - //{ QtMultimediaKit::Event, 0 }, - //{ QtMultimediaKit::Subject, 0 } + //{ QtMultimedia::CameraManufacturer, 0 }, + //{ QtMultimedia::CameraModel, 0 }, + //{ QtMultimedia::Event, 0 }, + //{ QtMultimedia::Subject, 0 } }; CameraBinMetaData::CameraBinMetaData(QObject *parent) @@ -124,7 +124,7 @@ CameraBinMetaData::CameraBinMetaData(QObject *parent) { } -QVariant CameraBinMetaData::metaData(QtMultimediaKit::MetaData key) const +QVariant CameraBinMetaData::metaData(QtMultimedia::MetaData key) const { static const int count = sizeof(qt_gstreamerMetaDataKeys) / sizeof(QGstreamerMetaDataKeyLookup); @@ -138,7 +138,7 @@ QVariant CameraBinMetaData::metaData(QtMultimediaKit::MetaData key) const return QVariant(); } -void CameraBinMetaData::setMetaData(QtMultimediaKit::MetaData key, const QVariant &value) +void CameraBinMetaData::setMetaData(QtMultimedia::MetaData key, const QVariant &value) { static const int count = sizeof(qt_gstreamerMetaDataKeys) / sizeof(QGstreamerMetaDataKeyLookup); @@ -156,9 +156,9 @@ void CameraBinMetaData::setMetaData(QtMultimediaKit::MetaData key, const QVarian } } -QList CameraBinMetaData::availableMetaData() const +QList CameraBinMetaData::availableMetaData() const { - static QMap keysMap; + static QMap keysMap; if (keysMap.isEmpty()) { const int count = sizeof(qt_gstreamerMetaDataKeys) / sizeof(QGstreamerMetaDataKeyLookup); for (int i = 0; i < count; ++i) { @@ -166,9 +166,9 @@ QList CameraBinMetaData::availableMetaData() const } } - QList res; + QList res; foreach (const QByteArray &key, m_values.keys()) { - QtMultimediaKit::MetaData tag = keysMap.value(key, QtMultimediaKit::MetaData(-1)); + QtMultimedia::MetaData tag = keysMap.value(key, QtMultimedia::MetaData(-1)); if (tag != -1) res.append(tag); } diff --git a/src/plugins/gstreamer/camerabin/camerabinmetadata.h b/src/plugins/gstreamer/camerabin/camerabinmetadata.h index 710d2bf0d..16a86a626 100644 --- a/src/plugins/gstreamer/camerabin/camerabinmetadata.h +++ b/src/plugins/gstreamer/camerabin/camerabinmetadata.h @@ -57,9 +57,9 @@ public: bool isMetaDataAvailable() const { return true; } bool isWritable() const { return true; } - QVariant metaData(QtMultimediaKit::MetaData key) const; - void setMetaData(QtMultimediaKit::MetaData key, const QVariant &value); - QList availableMetaData() const; + QVariant metaData(QtMultimedia::MetaData key) const; + void setMetaData(QtMultimedia::MetaData key, const QVariant &value); + QList availableMetaData() const; QVariant extendedMetaData(QString const &name) const; void setExtendedMetaData(QString const &name, QVariant const &value); diff --git a/src/plugins/gstreamer/gstreamer.pro b/src/plugins/gstreamer/gstreamer.pro index 550040ecf..baec7175c 100644 --- a/src/plugins/gstreamer/gstreamer.pro +++ b/src/plugins/gstreamer/gstreamer.pro @@ -2,11 +2,11 @@ load(qt_module) TARGET = qgstengine -QT += multimediakit-private network multimediakitwidgets-private +QT += multimedia-private network multimediawidgets-private PLUGIN_TYPE=mediaservice load(qt_plugin) -DESTDIR = $$QT.multimediakit.plugins/$${PLUGIN_TYPE} +DESTDIR = $$QT.multimedia.plugins/$${PLUGIN_TYPE} unix:!maemo*:contains(QT_CONFIG, alsa) { DEFINES += HAVE_ALSA diff --git a/src/plugins/gstreamer/mediacapture/qgstreameraudioencode.cpp b/src/plugins/gstreamer/mediacapture/qgstreameraudioencode.cpp index e69494d00..2f7c6a8c8 100644 --- a/src/plugins/gstreamer/mediacapture/qgstreameraudioencode.cpp +++ b/src/plugins/gstreamer/mediacapture/qgstreameraudioencode.cpp @@ -199,8 +199,8 @@ GstElement *QGstreamerAudioEncode::createEncoder() } if (encoderElement) { - if (m_audioSettings.encodingMode() == QtMultimediaKit::ConstantQualityEncoding) { - QtMultimediaKit::EncodingQuality qualityValue = m_audioSettings.quality(); + if (m_audioSettings.encodingMode() == QtMultimedia::ConstantQualityEncoding) { + QtMultimedia::EncodingQuality qualityValue = m_audioSettings.quality(); if (codec == QLatin1String("audio/vorbis")) { double qualityTable[] = { diff --git a/src/plugins/gstreamer/mediacapture/qgstreamercapturemetadatacontrol.cpp b/src/plugins/gstreamer/mediacapture/qgstreamercapturemetadatacontrol.cpp index cc8bdeee1..b874afc7f 100644 --- a/src/plugins/gstreamer/mediacapture/qgstreamercapturemetadatacontrol.cpp +++ b/src/plugins/gstreamer/mediacapture/qgstreamercapturemetadatacontrol.cpp @@ -46,77 +46,77 @@ struct QGstreamerMetaDataKeyLookup { - QtMultimediaKit::MetaData key; + QtMultimedia::MetaData key; const char *token; }; static const QGstreamerMetaDataKeyLookup qt_gstreamerMetaDataKeys[] = { - { QtMultimediaKit::Title, GST_TAG_TITLE }, - //{ QtMultimediaKit::SubTitle, 0 }, - //{ QtMultimediaKit::Author, 0 }, - { QtMultimediaKit::Comment, GST_TAG_COMMENT }, - { QtMultimediaKit::Description, GST_TAG_DESCRIPTION }, - //{ QtMultimediaKit::Category, 0 }, - { QtMultimediaKit::Genre, GST_TAG_GENRE }, - //{ QtMultimediaKit::Year, 0 }, - //{ QtMultimediaKit::UserRating, 0 }, - - { QtMultimediaKit::Language, GST_TAG_LANGUAGE_CODE }, - - { QtMultimediaKit::Publisher, GST_TAG_ORGANIZATION }, - { QtMultimediaKit::Copyright, GST_TAG_COPYRIGHT }, - //{ QtMultimediaKit::ParentalRating, 0 }, - //{ QtMultimediaKit::RatingOrganisation, 0 }, + { QtMultimedia::Title, GST_TAG_TITLE }, + //{ QtMultimedia::SubTitle, 0 }, + //{ QtMultimedia::Author, 0 }, + { QtMultimedia::Comment, GST_TAG_COMMENT }, + { QtMultimedia::Description, GST_TAG_DESCRIPTION }, + //{ QtMultimedia::Category, 0 }, + { QtMultimedia::Genre, GST_TAG_GENRE }, + //{ QtMultimedia::Year, 0 }, + //{ QtMultimedia::UserRating, 0 }, + + { QtMultimedia::Language, GST_TAG_LANGUAGE_CODE }, + + { QtMultimedia::Publisher, GST_TAG_ORGANIZATION }, + { QtMultimedia::Copyright, GST_TAG_COPYRIGHT }, + //{ QtMultimedia::ParentalRating, 0 }, + //{ QtMultimedia::RatingOrganisation, 0 }, // Media - //{ QtMultimediaKit::Size, 0 }, - //{ QtMultimediaKit::MediaType, 0 }, - { QtMultimediaKit::Duration, GST_TAG_DURATION }, + //{ QtMultimedia::Size, 0 }, + //{ QtMultimedia::MediaType, 0 }, + { QtMultimedia::Duration, GST_TAG_DURATION }, // Audio - { QtMultimediaKit::AudioBitRate, GST_TAG_BITRATE }, - { QtMultimediaKit::AudioCodec, GST_TAG_AUDIO_CODEC }, - //{ QtMultimediaKit::ChannelCount, 0 }, - //{ QtMultimediaKit::SampleRate, 0 }, + { QtMultimedia::AudioBitRate, GST_TAG_BITRATE }, + { QtMultimedia::AudioCodec, GST_TAG_AUDIO_CODEC }, + //{ QtMultimedia::ChannelCount, 0 }, + //{ QtMultimedia::SampleRate, 0 }, // Music - { QtMultimediaKit::AlbumTitle, GST_TAG_ALBUM }, - { QtMultimediaKit::AlbumArtist, GST_TAG_ARTIST}, - { QtMultimediaKit::ContributingArtist, GST_TAG_PERFORMER }, + { QtMultimedia::AlbumTitle, GST_TAG_ALBUM }, + { QtMultimedia::AlbumArtist, GST_TAG_ARTIST}, + { QtMultimedia::ContributingArtist, GST_TAG_PERFORMER }, #if (GST_VERSION_MAJOR >= 0) && (GST_VERSION_MINOR >= 10) && (GST_VERSION_MICRO >= 19) - { QtMultimediaKit::Composer, GST_TAG_COMPOSER }, + { QtMultimedia::Composer, GST_TAG_COMPOSER }, #endif - //{ QtMultimediaKit::Conductor, 0 }, - //{ QtMultimediaKit::Lyrics, 0 }, - //{ QtMultimediaKit::Mood, 0 }, - { QtMultimediaKit::TrackNumber, GST_TAG_TRACK_NUMBER }, + //{ QtMultimedia::Conductor, 0 }, + //{ QtMultimedia::Lyrics, 0 }, + //{ QtMultimedia::Mood, 0 }, + { QtMultimedia::TrackNumber, GST_TAG_TRACK_NUMBER }, - //{ QtMultimediaKit::CoverArtUrlSmall, 0 }, - //{ QtMultimediaKit::CoverArtUrlLarge, 0 }, + //{ QtMultimedia::CoverArtUrlSmall, 0 }, + //{ QtMultimedia::CoverArtUrlLarge, 0 }, // Image/Video - //{ QtMultimediaKit::Resolution, 0 }, - //{ QtMultimediaKit::PixelAspectRatio, 0 }, + //{ QtMultimedia::Resolution, 0 }, + //{ QtMultimedia::PixelAspectRatio, 0 }, // Video - //{ QtMultimediaKit::VideoFrameRate, 0 }, - //{ QtMultimediaKit::VideoBitRate, 0 }, - { QtMultimediaKit::VideoCodec, GST_TAG_VIDEO_CODEC }, + //{ QtMultimedia::VideoFrameRate, 0 }, + //{ QtMultimedia::VideoBitRate, 0 }, + { QtMultimedia::VideoCodec, GST_TAG_VIDEO_CODEC }, - //{ QtMultimediaKit::PosterUrl, 0 }, + //{ QtMultimedia::PosterUrl, 0 }, // Movie - //{ QtMultimediaKit::ChapterNumber, 0 }, - //{ QtMultimediaKit::Director, 0 }, - { QtMultimediaKit::LeadPerformer, GST_TAG_PERFORMER }, - //{ QtMultimediaKit::Writer, 0 }, + //{ QtMultimedia::ChapterNumber, 0 }, + //{ QtMultimedia::Director, 0 }, + { QtMultimedia::LeadPerformer, GST_TAG_PERFORMER }, + //{ QtMultimedia::Writer, 0 }, // Photos - //{ QtMultimediaKit::CameraManufacturer, 0 }, - //{ QtMultimediaKit::CameraModel, 0 }, - //{ QtMultimediaKit::Event, 0 }, - //{ QtMultimediaKit::Subject, 0 } + //{ QtMultimedia::CameraManufacturer, 0 }, + //{ QtMultimedia::CameraModel, 0 }, + //{ QtMultimedia::Event, 0 }, + //{ QtMultimedia::Subject, 0 } }; QGstreamerCaptureMetaDataControl::QGstreamerCaptureMetaDataControl(QObject *parent) @@ -124,7 +124,7 @@ QGstreamerCaptureMetaDataControl::QGstreamerCaptureMetaDataControl(QObject *pare { } -QVariant QGstreamerCaptureMetaDataControl::metaData(QtMultimediaKit::MetaData key) const +QVariant QGstreamerCaptureMetaDataControl::metaData(QtMultimedia::MetaData key) const { static const int count = sizeof(qt_gstreamerMetaDataKeys) / sizeof(QGstreamerMetaDataKeyLookup); @@ -138,7 +138,7 @@ QVariant QGstreamerCaptureMetaDataControl::metaData(QtMultimediaKit::MetaData ke return QVariant(); } -void QGstreamerCaptureMetaDataControl::setMetaData(QtMultimediaKit::MetaData key, const QVariant &value) +void QGstreamerCaptureMetaDataControl::setMetaData(QtMultimedia::MetaData key, const QVariant &value) { static const int count = sizeof(qt_gstreamerMetaDataKeys) / sizeof(QGstreamerMetaDataKeyLookup); @@ -156,9 +156,9 @@ void QGstreamerCaptureMetaDataControl::setMetaData(QtMultimediaKit::MetaData key } } -QList QGstreamerCaptureMetaDataControl::availableMetaData() const +QList QGstreamerCaptureMetaDataControl::availableMetaData() const { - static QMap keysMap; + static QMap keysMap; if (keysMap.isEmpty()) { const int count = sizeof(qt_gstreamerMetaDataKeys) / sizeof(QGstreamerMetaDataKeyLookup); for (int i = 0; i < count; ++i) { @@ -166,9 +166,9 @@ QList QGstreamerCaptureMetaDataControl::availableMeta } } - QList res; + QList res; foreach (const QByteArray &key, m_values.keys()) { - QtMultimediaKit::MetaData tag = keysMap.value(key, QtMultimediaKit::MetaData(-1)); + QtMultimedia::MetaData tag = keysMap.value(key, QtMultimedia::MetaData(-1)); if (tag != -1) res.append(tag); } diff --git a/src/plugins/gstreamer/mediacapture/qgstreamercapturemetadatacontrol.h b/src/plugins/gstreamer/mediacapture/qgstreamercapturemetadatacontrol.h index 4ee46eaa5..031f630d5 100644 --- a/src/plugins/gstreamer/mediacapture/qgstreamercapturemetadatacontrol.h +++ b/src/plugins/gstreamer/mediacapture/qgstreamercapturemetadatacontrol.h @@ -57,9 +57,9 @@ public: bool isMetaDataAvailable() const { return true; } bool isWritable() const { return true; } - QVariant metaData(QtMultimediaKit::MetaData key) const; - void setMetaData(QtMultimediaKit::MetaData key, const QVariant &value); - QList availableMetaData() const; + QVariant metaData(QtMultimedia::MetaData key) const; + void setMetaData(QtMultimedia::MetaData key, const QVariant &value); + QList availableMetaData() const; QVariant extendedMetaData(QString const &name) const; void setExtendedMetaData(QString const &name, QVariant const &value); diff --git a/src/plugins/gstreamer/mediacapture/qgstreamervideoencode.cpp b/src/plugins/gstreamer/mediacapture/qgstreamervideoencode.cpp index a3c724347..a2f139e90 100644 --- a/src/plugins/gstreamer/mediacapture/qgstreamervideoencode.cpp +++ b/src/plugins/gstreamer/mediacapture/qgstreamervideoencode.cpp @@ -171,8 +171,8 @@ GstElement *QGstreamerVideoEncode::createEncoder() gst_object_unref(GST_OBJECT(pad)); if (encoderElement) { - if (m_videoSettings.encodingMode() == QtMultimediaKit::ConstantQualityEncoding) { - QtMultimediaKit::EncodingQuality qualityValue = m_videoSettings.quality(); + if (m_videoSettings.encodingMode() == QtMultimedia::ConstantQualityEncoding) { + QtMultimedia::EncodingQuality qualityValue = m_videoSettings.quality(); if (codec == QLatin1String("video/h264")) { //constant quantizer mode diff --git a/src/plugins/gstreamer/mediaplayer/qgstreamermetadataprovider.cpp b/src/plugins/gstreamer/mediaplayer/qgstreamermetadataprovider.cpp index 00d766bd6..667067234 100644 --- a/src/plugins/gstreamer/mediaplayer/qgstreamermetadataprovider.cpp +++ b/src/plugins/gstreamer/mediaplayer/qgstreamermetadataprovider.cpp @@ -47,77 +47,77 @@ struct QGstreamerMetaDataKeyLookup { - QtMultimediaKit::MetaData key; + QtMultimedia::MetaData key; const char *token; }; static const QGstreamerMetaDataKeyLookup qt_gstreamerMetaDataKeys[] = { - { QtMultimediaKit::Title, GST_TAG_TITLE }, - //{ QtMultimediaKit::SubTitle, 0 }, - //{ QtMultimediaKit::Author, 0 }, - { QtMultimediaKit::Comment, GST_TAG_COMMENT }, - { QtMultimediaKit::Description, GST_TAG_DESCRIPTION }, - //{ QtMultimediaKit::Category, 0 }, - { QtMultimediaKit::Genre, GST_TAG_GENRE }, - { QtMultimediaKit::Year, "year" }, - //{ QtMultimediaKit::UserRating, 0 }, - - { QtMultimediaKit::Language, GST_TAG_LANGUAGE_CODE }, - - { QtMultimediaKit::Publisher, GST_TAG_ORGANIZATION }, - { QtMultimediaKit::Copyright, GST_TAG_COPYRIGHT }, - //{ QtMultimediaKit::ParentalRating, 0 }, - //{ QtMultimediaKit::RatingOrganisation, 0 }, + { QtMultimedia::Title, GST_TAG_TITLE }, + //{ QtMultimedia::SubTitle, 0 }, + //{ QtMultimedia::Author, 0 }, + { QtMultimedia::Comment, GST_TAG_COMMENT }, + { QtMultimedia::Description, GST_TAG_DESCRIPTION }, + //{ QtMultimedia::Category, 0 }, + { QtMultimedia::Genre, GST_TAG_GENRE }, + { QtMultimedia::Year, "year" }, + //{ QtMultimedia::UserRating, 0 }, + + { QtMultimedia::Language, GST_TAG_LANGUAGE_CODE }, + + { QtMultimedia::Publisher, GST_TAG_ORGANIZATION }, + { QtMultimedia::Copyright, GST_TAG_COPYRIGHT }, + //{ QtMultimedia::ParentalRating, 0 }, + //{ QtMultimedia::RatingOrganisation, 0 }, // Media - //{ QtMultimediaKit::Size, 0 }, - //{ QtMultimediaKit::MediaType, 0 }, - { QtMultimediaKit::Duration, GST_TAG_DURATION }, + //{ QtMultimedia::Size, 0 }, + //{ QtMultimedia::MediaType, 0 }, + { QtMultimedia::Duration, GST_TAG_DURATION }, // Audio - { QtMultimediaKit::AudioBitRate, GST_TAG_BITRATE }, - { QtMultimediaKit::AudioCodec, GST_TAG_AUDIO_CODEC }, - //{ QtMultimediaKit::ChannelCount, 0 }, - //{ QtMultimediaKit::SampleRate, 0 }, + { QtMultimedia::AudioBitRate, GST_TAG_BITRATE }, + { QtMultimedia::AudioCodec, GST_TAG_AUDIO_CODEC }, + //{ QtMultimedia::ChannelCount, 0 }, + //{ QtMultimedia::SampleRate, 0 }, // Music - { QtMultimediaKit::AlbumTitle, GST_TAG_ALBUM }, - { QtMultimediaKit::AlbumArtist, GST_TAG_ARTIST}, - { QtMultimediaKit::ContributingArtist, GST_TAG_PERFORMER }, + { QtMultimedia::AlbumTitle, GST_TAG_ALBUM }, + { QtMultimedia::AlbumArtist, GST_TAG_ARTIST}, + { QtMultimedia::ContributingArtist, GST_TAG_PERFORMER }, #if (GST_VERSION_MAJOR >= 0) && (GST_VERSION_MINOR >= 10) && (GST_VERSION_MICRO >= 19) - { QtMultimediaKit::Composer, GST_TAG_COMPOSER }, + { QtMultimedia::Composer, GST_TAG_COMPOSER }, #endif - //{ QtMultimediaKit::Conductor, 0 }, - //{ QtMultimediaKit::Lyrics, 0 }, - //{ QtMultimediaKit::Mood, 0 }, - { QtMultimediaKit::TrackNumber, GST_TAG_TRACK_NUMBER }, + //{ QtMultimedia::Conductor, 0 }, + //{ QtMultimedia::Lyrics, 0 }, + //{ QtMultimedia::Mood, 0 }, + { QtMultimedia::TrackNumber, GST_TAG_TRACK_NUMBER }, - //{ QtMultimediaKit::CoverArtUrlSmall, 0 }, - //{ QtMultimediaKit::CoverArtUrlLarge, 0 }, + //{ QtMultimedia::CoverArtUrlSmall, 0 }, + //{ QtMultimedia::CoverArtUrlLarge, 0 }, // Image/Video - { QtMultimediaKit::Resolution, "resolution" }, - { QtMultimediaKit::PixelAspectRatio, "pixel-aspect-ratio" }, + { QtMultimedia::Resolution, "resolution" }, + { QtMultimedia::PixelAspectRatio, "pixel-aspect-ratio" }, // Video - //{ QtMultimediaKit::VideoFrameRate, 0 }, - //{ QtMultimediaKit::VideoBitRate, 0 }, - { QtMultimediaKit::VideoCodec, GST_TAG_VIDEO_CODEC }, + //{ QtMultimedia::VideoFrameRate, 0 }, + //{ QtMultimedia::VideoBitRate, 0 }, + { QtMultimedia::VideoCodec, GST_TAG_VIDEO_CODEC }, - //{ QtMultimediaKit::PosterUrl, 0 }, + //{ QtMultimedia::PosterUrl, 0 }, // Movie - //{ QtMultimediaKit::ChapterNumber, 0 }, - //{ QtMultimediaKit::Director, 0 }, - { QtMultimediaKit::LeadPerformer, GST_TAG_PERFORMER }, - //{ QtMultimediaKit::Writer, 0 }, + //{ QtMultimedia::ChapterNumber, 0 }, + //{ QtMultimedia::Director, 0 }, + { QtMultimedia::LeadPerformer, GST_TAG_PERFORMER }, + //{ QtMultimedia::Writer, 0 }, // Photos - //{ QtMultimediaKit::CameraManufacturer, 0 }, - //{ QtMultimediaKit::CameraModel, 0 }, - //{ QtMultimediaKit::Event, 0 }, - //{ QtMultimediaKit::Subject, 0 } + //{ QtMultimedia::CameraManufacturer, 0 }, + //{ QtMultimedia::CameraModel, 0 }, + //{ QtMultimedia::Event, 0 }, + //{ QtMultimedia::Subject, 0 } }; QGstreamerMetaDataProvider::QGstreamerMetaDataProvider(QGstreamerPlayerSession *session, QObject *parent) @@ -140,7 +140,7 @@ bool QGstreamerMetaDataProvider::isWritable() const return false; } -QVariant QGstreamerMetaDataProvider::metaData(QtMultimediaKit::MetaData key) const +QVariant QGstreamerMetaDataProvider::metaData(QtMultimedia::MetaData key) const { static const int count = sizeof(qt_gstreamerMetaDataKeys) / sizeof(QGstreamerMetaDataKeyLookup); @@ -152,9 +152,9 @@ QVariant QGstreamerMetaDataProvider::metaData(QtMultimediaKit::MetaData key) con return QVariant(); } -QList QGstreamerMetaDataProvider::availableMetaData() const +QList QGstreamerMetaDataProvider::availableMetaData() const { - static QMap keysMap; + static QMap keysMap; if (keysMap.isEmpty()) { const int count = sizeof(qt_gstreamerMetaDataKeys) / sizeof(QGstreamerMetaDataKeyLookup); for (int i = 0; i < count; ++i) { @@ -162,9 +162,9 @@ QList QGstreamerMetaDataProvider::availableMetaData() } } - QList res; + QList res; foreach (const QByteArray &key, m_session->tags().keys()) { - QtMultimediaKit::MetaData tag = keysMap.value(key, QtMultimediaKit::MetaData(-1)); + QtMultimedia::MetaData tag = keysMap.value(key, QtMultimedia::MetaData(-1)); if (tag != -1) res.append(tag); } diff --git a/src/plugins/gstreamer/mediaplayer/qgstreamermetadataprovider.h b/src/plugins/gstreamer/mediaplayer/qgstreamermetadataprovider.h index aac44f5a2..efba79c6b 100644 --- a/src/plugins/gstreamer/mediaplayer/qgstreamermetadataprovider.h +++ b/src/plugins/gstreamer/mediaplayer/qgstreamermetadataprovider.h @@ -58,8 +58,8 @@ public: bool isMetaDataAvailable() const; bool isWritable() const; - QVariant metaData(QtMultimediaKit::MetaData key) const; - QList availableMetaData() const; + QVariant metaData(QtMultimedia::MetaData key) const; + QList availableMetaData() const; QVariant extendedMetaData(const QString &key) const ; QStringList availableExtendedMetaData() const; diff --git a/src/plugins/gstreamer/mediaplayer/qgstreamerplayersession.cpp b/src/plugins/gstreamer/mediaplayer/qgstreamerplayersession.cpp index 7fb5599c2..7aef9065e 100644 --- a/src/plugins/gstreamer/mediaplayer/qgstreamerplayersession.cpp +++ b/src/plugins/gstreamer/mediaplayer/qgstreamerplayersession.cpp @@ -1219,7 +1219,7 @@ void QGstreamerPlayerSession::getStreamsInfo() for (int i=0; i streamProperties; + QMap streamProperties; int streamIndex = i - m_playbin2StreamOffset[streamType]; @@ -1241,7 +1241,7 @@ void QGstreamerPlayerSession::getStreamsInfo() if (tags && gst_is_tag_list(tags)) { gchar *languageCode = 0; if (gst_tag_list_get_string(tags, GST_TAG_LANGUAGE_CODE, &languageCode)) - streamProperties[QtMultimediaKit::Language] = QString::fromUtf8(languageCode); + streamProperties[QtMultimedia::Language] = QString::fromUtf8(languageCode); //qDebug() << "language for setream" << i << QString::fromUtf8(languageCode); g_free (languageCode); @@ -1301,8 +1301,8 @@ void QGstreamerPlayerSession::getStreamsInfo() break; } - QMap streamProperties; - streamProperties[QtMultimediaKit::Language] = QString::fromUtf8(languageCode); + QMap streamProperties; + streamProperties[QtMultimedia::Language] = QString::fromUtf8(languageCode); m_streamProperties.append(streamProperties); m_streamTypes.append(streamType); diff --git a/src/plugins/gstreamer/mediaplayer/qgstreamerplayersession.h b/src/plugins/gstreamer/mediaplayer/qgstreamerplayersession.h index e89c1521c..208f0b5de 100644 --- a/src/plugins/gstreamer/mediaplayer/qgstreamerplayersession.h +++ b/src/plugins/gstreamer/mediaplayer/qgstreamerplayersession.h @@ -103,7 +103,7 @@ public: QMediaTimeRange availablePlaybackRanges() const; QMap tags() const { return m_tags; } - QMap streamProperties(int streamNumber) const { return m_streamProperties[streamNumber]; } + QMap streamProperties(int streamNumber) const { return m_streamProperties[streamNumber]; } int streamCount() const { return m_streamProperties.count(); } QMediaStreamsControl::StreamType streamType(int streamNumber) { return m_streamTypes.value(streamNumber, QMediaStreamsControl::UnknownStream); } @@ -195,7 +195,7 @@ private: #endif QMap m_tags; - QList< QMap > m_streamProperties; + QList< QMap > m_streamProperties; QList m_streamTypes; QMap m_playbin2StreamOffset; diff --git a/src/plugins/gstreamer/mediaplayer/qgstreamerstreamscontrol.cpp b/src/plugins/gstreamer/mediaplayer/qgstreamerstreamscontrol.cpp index 0b594bd42..a5ba87192 100644 --- a/src/plugins/gstreamer/mediaplayer/qgstreamerstreamscontrol.cpp +++ b/src/plugins/gstreamer/mediaplayer/qgstreamerstreamscontrol.cpp @@ -62,7 +62,7 @@ QMediaStreamsControl::StreamType QGstreamerStreamsControl::streamType(int stream return m_session->streamType(streamNumber); } -QVariant QGstreamerStreamsControl::metaData(int streamNumber, QtMultimediaKit::MetaData key) +QVariant QGstreamerStreamsControl::metaData(int streamNumber, QtMultimedia::MetaData key) { return m_session->streamProperties(streamNumber).value(key); } diff --git a/src/plugins/gstreamer/mediaplayer/qgstreamerstreamscontrol.h b/src/plugins/gstreamer/mediaplayer/qgstreamerstreamscontrol.h index c46709e91..77f0f2d93 100644 --- a/src/plugins/gstreamer/mediaplayer/qgstreamerstreamscontrol.h +++ b/src/plugins/gstreamer/mediaplayer/qgstreamerstreamscontrol.h @@ -58,7 +58,7 @@ public: virtual int streamCount(); virtual StreamType streamType(int streamNumber); - virtual QVariant metaData(int streamNumber, QtMultimediaKit::MetaData key); + virtual QVariant metaData(int streamNumber, QtMultimedia::MetaData key); virtual bool isActive(int streamNumber); virtual void setActive(int streamNumber, bool state); diff --git a/src/plugins/gstreamer/qgstreamerserviceplugin.cpp b/src/plugins/gstreamer/qgstreamerserviceplugin.cpp index baa5bae06..64d71c550 100644 --- a/src/plugins/gstreamer/qgstreamerserviceplugin.cpp +++ b/src/plugins/gstreamer/qgstreamerserviceplugin.cpp @@ -260,7 +260,7 @@ namespace { } } -QtMultimediaKit::SupportEstimate QGstreamerServicePlugin::hasSupport(const QString &mimeType, +QtMultimedia::SupportEstimate QGstreamerServicePlugin::hasSupport(const QString &mimeType, const QStringList& codecs) const { if (m_supportedMimeTypeSet.isEmpty()) @@ -294,12 +294,12 @@ QtMultimediaKit::SupportEstimate QGstreamerServicePlugin::hasSupport(const QStri } } if (supportedCodecCount > 0 && supportedCodecCount == codecs.size()) - return QtMultimediaKit::ProbablySupported; + return QtMultimedia::ProbablySupported; if (supportedCodecCount == 0 && !containsMimeType) - return QtMultimediaKit::NotSupported; + return QtMultimedia::NotSupported; - return QtMultimediaKit::MaybeSupported; + return QtMultimedia::MaybeSupported; } void QGstreamerServicePlugin::updateSupportedMimeTypes() const diff --git a/src/plugins/gstreamer/qgstreamerserviceplugin.h b/src/plugins/gstreamer/qgstreamerserviceplugin.h index 5c0cf0075..ddb5dc124 100644 --- a/src/plugins/gstreamer/qgstreamerserviceplugin.h +++ b/src/plugins/gstreamer/qgstreamerserviceplugin.h @@ -70,7 +70,7 @@ public: QString deviceDescription(const QByteArray &service, const QByteArray &device); QVariant deviceProperty(const QByteArray &service, const QByteArray &device, const QByteArray &property); - QtMultimediaKit::SupportEstimate hasSupport(const QString &mimeType, const QStringList& codecs) const; + QtMultimedia::SupportEstimate hasSupport(const QString &mimeType, const QStringList& codecs) const; QStringList supportedMimeTypes() const; private: diff --git a/src/plugins/m3u/m3u.pro b/src/plugins/m3u/m3u.pro index c66f10b7d..cd73b1405 100644 --- a/src/plugins/m3u/m3u.pro +++ b/src/plugins/m3u/m3u.pro @@ -1,11 +1,11 @@ load(qt_module) -TARGET = qtmultimediakit_m3u -QT += multimediakit-private +TARGET = qtmultimedia_m3u +QT += multimedia-private PLUGIN_TYPE=playlistformats load(qt_plugin) -DESTDIR = $$QT.multimediakit.plugins/$${PLUGIN_TYPE} +DESTDIR = $$QT.multimedia.plugins/$${PLUGIN_TYPE} HEADERS += qm3uhandler.h diff --git a/src/plugins/m3u/main.cpp b/src/plugins/m3u/main.cpp index b098050c2..f322001a6 100644 --- a/src/plugins/m3u/main.cpp +++ b/src/plugins/m3u/main.cpp @@ -44,4 +44,4 @@ Q_EXPORT_STATIC_PLUGIN(QM3uPlaylistPlugin) -Q_EXPORT_PLUGIN2(qtmultimediakit_m3u, QM3uPlaylistPlugin) +Q_EXPORT_PLUGIN2(qtmultimedia_m3u, QM3uPlaylistPlugin) diff --git a/src/plugins/plugins.pro b/src/plugins/plugins.pro index 15a25b3d5..67cc6b701 100644 --- a/src/plugins/plugins.pro +++ b/src/plugins/plugins.pro @@ -1,6 +1,6 @@ ###################################################################### # -# QtMultimediaKit +# QtMultimedia # ###################################################################### diff --git a/src/plugins/pulseaudio/pulseaudio.pro b/src/plugins/pulseaudio/pulseaudio.pro index b5db8f690..9b786b43d 100644 --- a/src/plugins/pulseaudio/pulseaudio.pro +++ b/src/plugins/pulseaudio/pulseaudio.pro @@ -1,11 +1,11 @@ load(qt_module) TARGET = qtmedia_pulse -QT += multimediakit-private +QT += multimedia-private PLUGIN_TYPE = audio load(qt_plugin) -DESTDIR = $$QT.multimediakit.plugins/$${PLUGIN_TYPE} +DESTDIR = $$QT.multimedia.plugins/$${PLUGIN_TYPE} CONFIG += link_pkgconfig PKGCONFIG += libpulse diff --git a/src/plugins/qt7/mediaplayer/qt7playermetadata.h b/src/plugins/qt7/mediaplayer/qt7playermetadata.h index 49d9b8e01..c5984a425 100644 --- a/src/plugins/qt7/mediaplayer/qt7playermetadata.h +++ b/src/plugins/qt7/mediaplayer/qt7playermetadata.h @@ -58,8 +58,8 @@ public: bool isMetaDataAvailable() const; bool isWritable() const; - QVariant metaData(QtMultimediaKit::MetaData key) const; - QList availableMetaData() const; + QVariant metaData(QtMultimedia::MetaData key) const; + QList availableMetaData() const; QVariant extendedMetaData(const QString &key) const ; QStringList availableExtendedMetaData() const; @@ -69,7 +69,7 @@ private slots: private: QT7PlayerSession *m_session; - QMap m_tags; + QMap m_tags; }; QT_END_NAMESPACE diff --git a/src/plugins/qt7/mediaplayer/qt7playermetadata.mm b/src/plugins/qt7/mediaplayer/qt7playermetadata.mm index 313a009ed..743243113 100644 --- a/src/plugins/qt7/mediaplayer/qt7playermetadata.mm +++ b/src/plugins/qt7/mediaplayer/qt7playermetadata.mm @@ -72,12 +72,12 @@ bool QT7PlayerMetaDataControl::isWritable() const return false; } -QVariant QT7PlayerMetaDataControl::metaData(QtMultimediaKit::MetaData key) const +QVariant QT7PlayerMetaDataControl::metaData(QtMultimedia::MetaData key) const { return m_tags.value(key); } -QList QT7PlayerMetaDataControl::availableMetaData() const +QList QT7PlayerMetaDataControl::availableMetaData() const { return m_tags.keys(); } @@ -244,13 +244,13 @@ void QT7PlayerMetaDataControl::updateTags() metaMap.insert(QLatin1String("nam"), QString::fromUtf8([name UTF8String])); #endif // QUICKTIME_C_API_AVAILABLE - m_tags.insert(QtMultimediaKit::AlbumArtist, metaMap.value(QLatin1String("ART"))); - m_tags.insert(QtMultimediaKit::AlbumTitle, metaMap.value(QLatin1String("alb"))); - m_tags.insert(QtMultimediaKit::Title, metaMap.value(QLatin1String("nam"))); - m_tags.insert(QtMultimediaKit::Date, metaMap.value(QLatin1String("day"))); - m_tags.insert(QtMultimediaKit::Genre, metaMap.value(QLatin1String("gnre"))); - m_tags.insert(QtMultimediaKit::TrackNumber, metaMap.value(QLatin1String("trk"))); - m_tags.insert(QtMultimediaKit::Description, metaMap.value(QLatin1String("des"))); + m_tags.insert(QtMultimedia::AlbumArtist, metaMap.value(QLatin1String("ART"))); + m_tags.insert(QtMultimedia::AlbumTitle, metaMap.value(QLatin1String("alb"))); + m_tags.insert(QtMultimedia::Title, metaMap.value(QLatin1String("nam"))); + m_tags.insert(QtMultimedia::Date, metaMap.value(QLatin1String("day"))); + m_tags.insert(QtMultimedia::Genre, metaMap.value(QLatin1String("gnre"))); + m_tags.insert(QtMultimedia::TrackNumber, metaMap.value(QLatin1String("trk"))); + m_tags.insert(QtMultimedia::Description, metaMap.value(QLatin1String("des"))); } if (!wasEmpty || !m_tags.isEmpty()) diff --git a/src/plugins/qt7/qcvdisplaylink.h b/src/plugins/qt7/qcvdisplaylink.h index aa71f4cc3..46462eccb 100644 --- a/src/plugins/qt7/qcvdisplaylink.h +++ b/src/plugins/qt7/qcvdisplaylink.h @@ -45,7 +45,7 @@ #include #include -#include +#include #include diff --git a/src/plugins/qt7/qt7.pro b/src/plugins/qt7/qt7.pro index 5be085eb2..34e54cfc5 100644 --- a/src/plugins/qt7/qt7.pro +++ b/src/plugins/qt7/qt7.pro @@ -1,11 +1,11 @@ load(qt_module) TARGET = qqt7engine -QT += multimediakit-private multimediakitwidgets-private network +QT += multimedia-private multimediawidgets-private network PLUGIN_TYPE = mediaservice load(qt_plugin) -DESTDIR = $$QT.multimediakit.plugins/$${PLUGIN_TYPE} +DESTDIR = $$QT.multimedia.plugins/$${PLUGIN_TYPE} !simulator { QT += opengl diff --git a/src/plugins/qt7/qt7backend.h b/src/plugins/qt7/qt7backend.h index 0c2c5d8cf..67ff53abb 100644 --- a/src/plugins/qt7/qt7backend.h +++ b/src/plugins/qt7/qt7backend.h @@ -42,7 +42,7 @@ #ifndef QT7BACKEND_H #define QT7BACKEND_H -#include "qtmultimediakitdefs.h" +#include "qtmultimediadefs.h" #include diff --git a/src/plugins/qt7/qt7serviceplugin.h b/src/plugins/qt7/qt7serviceplugin.h index 36077c703..7ff1249eb 100644 --- a/src/plugins/qt7/qt7serviceplugin.h +++ b/src/plugins/qt7/qt7serviceplugin.h @@ -61,7 +61,7 @@ public: void release(QMediaService *service); QMediaServiceProviderHint::Features supportedFeatures(const QByteArray &service) const; - QtMultimediaKit::SupportEstimate hasSupport(const QString &mimeType, const QStringList& codecs) const; + QtMultimedia::SupportEstimate hasSupport(const QString &mimeType, const QStringList& codecs) const; QStringList supportedMimeTypes() const; private: diff --git a/src/plugins/qt7/qt7serviceplugin.mm b/src/plugins/qt7/qt7serviceplugin.mm index b2941100b..843ab41b2 100644 --- a/src/plugins/qt7/qt7serviceplugin.mm +++ b/src/plugins/qt7/qt7serviceplugin.mm @@ -96,14 +96,14 @@ QMediaServiceProviderHint::Features QT7ServicePlugin::supportedFeatures( return QMediaServiceProviderHint::Features(); } -QtMultimediaKit::SupportEstimate QT7ServicePlugin::hasSupport(const QString &mimeType, const QStringList& codecs) const +QtMultimedia::SupportEstimate QT7ServicePlugin::hasSupport(const QString &mimeType, const QStringList& codecs) const { Q_UNUSED(codecs); if (m_supportedMimeTypes.contains(mimeType)) - return QtMultimediaKit::ProbablySupported; + return QtMultimedia::ProbablySupported; - return QtMultimediaKit::MaybeSupported; + return QtMultimedia::MaybeSupported; } QStringList QT7ServicePlugin::supportedMimeTypes() const diff --git a/src/plugins/simulator/qsimulatormultimediadata_p.h b/src/plugins/simulator/qsimulatormultimediadata_p.h index 22b0d73a0..b814f5c37 100644 --- a/src/plugins/simulator/qsimulatormultimediadata_p.h +++ b/src/plugins/simulator/qsimulatormultimediadata_p.h @@ -53,7 +53,7 @@ // We mean it. // -#include "qtmultimediakitdefs.h" +#include "qtmultimediadefs.h" #include #include #include diff --git a/src/plugins/v4l/radio/v4lradiocontrol.cpp b/src/plugins/v4l/radio/v4lradiocontrol.cpp index fe5357ec9..49182d50b 100644 --- a/src/plugins/v4l/radio/v4lradiocontrol.cpp +++ b/src/plugins/v4l/radio/v4lradiocontrol.cpp @@ -88,12 +88,12 @@ bool V4LRadioControl::isAvailable() const return available; } -QtMultimediaKit::AvailabilityError V4LRadioControl::availabilityError() const +QtMultimedia::AvailabilityError V4LRadioControl::availabilityError() const { if (fd > 0) - return QtMultimediaKit::NoError; + return QtMultimedia::NoError; else - return QtMultimediaKit::ResourceError; + return QtMultimedia::ResourceError; } QRadioTuner::State V4LRadioControl::state() const diff --git a/src/plugins/v4l/radio/v4lradiocontrol.h b/src/plugins/v4l/radio/v4lradiocontrol.h index 36e86f960..4e9f6eb57 100644 --- a/src/plugins/v4l/radio/v4lradiocontrol.h +++ b/src/plugins/v4l/radio/v4lradiocontrol.h @@ -65,7 +65,7 @@ public: ~V4LRadioControl(); bool isAvailable() const; - QtMultimediaKit::AvailabilityError availabilityError() const; + QtMultimedia::AvailabilityError availabilityError() const; QRadioTuner::State state() const; diff --git a/src/plugins/v4l/v4l.pro b/src/plugins/v4l/v4l.pro index 063a4c7ac..bc5c3d4a0 100644 --- a/src/plugins/v4l/v4l.pro +++ b/src/plugins/v4l/v4l.pro @@ -1,11 +1,11 @@ load(qt_module) TARGET = qtmedia_v4lengine -QT += multimediakit-private +QT += multimedia-private PLUGIN_TYPE = mediaservice load(qt_plugin) -DESTDIR = $$QT.multimediakit.plugins/$${PLUGIN_TYPE} +DESTDIR = $$QT.multimedia.plugins/$${PLUGIN_TYPE} HEADERS += v4lserviceplugin.h SOURCES += v4lserviceplugin.cpp diff --git a/src/plugins/wmf/player/mfmetadatacontrol.cpp b/src/plugins/wmf/player/mfmetadatacontrol.cpp index 4d62b9091..4e6270606 100644 --- a/src/plugins/wmf/player/mfmetadatacontrol.cpp +++ b/src/plugins/wmf/player/mfmetadatacontrol.cpp @@ -65,7 +65,7 @@ bool MFMetaDataControl::isMetaDataAvailable() const return m_content || m_metaData; } -QVariant MFMetaDataControl::metaData(QtMultimediaKit::MetaData key) const +QVariant MFMetaDataControl::metaData(QtMultimedia::MetaData key) const { QVariant value; if (!isMetaDataAvailable()) @@ -113,7 +113,7 @@ QVariant MFMetaDataControl::convertValue(const PROPVARIANT& var) const return value; } -QList MFMetaDataControl::availableMetaData() const +QList MFMetaDataControl::availableMetaData() const { return m_availableMetaDatas; } @@ -173,15 +173,15 @@ void MFMetaDataControl::updateSource(IMFPresentationDescriptor* sourcePD, IMFMed continue; bool common = true; if (key == PKEY_Author) { - m_availableMetaDatas.push_back(QtMultimediaKit::Author); + m_availableMetaDatas.push_back(QtMultimedia::Author); } else if (key == PKEY_Title) { - m_availableMetaDatas.push_back(QtMultimediaKit::Title); + m_availableMetaDatas.push_back(QtMultimedia::Title); } else if (key == PKEY_ParentalRating) { - m_availableMetaDatas.push_back(QtMultimediaKit::ParentalRating); + m_availableMetaDatas.push_back(QtMultimedia::ParentalRating); } else if (key == PKEY_Comment) { - m_availableMetaDatas.push_back(QtMultimediaKit::Description); + m_availableMetaDatas.push_back(QtMultimedia::Description); } else if (key == PKEY_Copyright) { - m_availableMetaDatas.push_back(QtMultimediaKit::Copyright); + m_availableMetaDatas.push_back(QtMultimedia::Copyright); //TODO: add more common keys } else { common = false; @@ -213,15 +213,15 @@ void MFMetaDataControl::updateSource(IMFPresentationDescriptor* sourcePD, IMFMed #endif bool common = true; if (wcscmp(sName, L"Author") == 0) { - m_availableMetaDatas.push_back(QtMultimediaKit::Author); + m_availableMetaDatas.push_back(QtMultimedia::Author); } else if (wcscmp(sName, L"Title") == 0) { - m_availableMetaDatas.push_back(QtMultimediaKit::Title); + m_availableMetaDatas.push_back(QtMultimedia::Title); } else if (wcscmp(sName, L"Rating") == 0) { - m_availableMetaDatas.push_back(QtMultimediaKit::ParentalRating); + m_availableMetaDatas.push_back(QtMultimedia::ParentalRating); } else if (wcscmp(sName, L"Description") == 0) { - m_availableMetaDatas.push_back(QtMultimediaKit::Description); + m_availableMetaDatas.push_back(QtMultimedia::Description); } else if (wcscmp(sName, L"Copyright") == 0) { - m_availableMetaDatas.push_back(QtMultimediaKit::Copyright); + m_availableMetaDatas.push_back(QtMultimedia::Copyright); //TODO: add more common keys } else { common = false; diff --git a/src/plugins/wmf/player/mfmetadatacontrol.h b/src/plugins/wmf/player/mfmetadatacontrol.h index c666aaf5b..a73b7788d 100644 --- a/src/plugins/wmf/player/mfmetadatacontrol.h +++ b/src/plugins/wmf/player/mfmetadatacontrol.h @@ -56,8 +56,8 @@ public: bool isMetaDataAvailable() const; - QVariant metaData(QtMultimediaKit::MetaData key) const; - QList availableMetaData() const; + QVariant metaData(QtMultimedia::MetaData key) const; + QList availableMetaData() const; QVariant extendedMetaData(const QString &key) const; QStringList availableExtendedMetaData() const; @@ -69,7 +69,7 @@ private: IPropertyStore *m_content; //for Windows7 IMFMetadata *m_metaData; //for Vista - QList m_availableMetaDatas; + QList m_availableMetaDatas; QList m_commonKeys; //for Windows7 QStringList m_commonNames; //for Vista diff --git a/src/plugins/wmf/wmf.pro b/src/plugins/wmf/wmf.pro index 0bb1743a7..d0b4ec347 100644 --- a/src/plugins/wmf/wmf.pro +++ b/src/plugins/wmf/wmf.pro @@ -1,12 +1,12 @@ load(qt_module) TARGET = wmfengine -QT += multimediakit-private network multimediakitwidgets-private +QT += multimedia-private network multimediawidgets-private PLUGIN_TYPE=mediaservice load(qt_plugin) -DESTDIR = $$QT.multimediakit.plugins/$${PLUGIN_TYPE} +DESTDIR = $$QT.multimedia.plugins/$${PLUGIN_TYPE} DEPENDPATH += . diff --git a/src/src.pro b/src/src.pro index cad13103e..735967f2b 100644 --- a/src/src.pro +++ b/src/src.pro @@ -2,11 +2,11 @@ TEMPLATE = subdirs CONFIG += ordered -library_qtmmkwidgets.subdir = $$IN_PWD/multimediakitwidgets -library_qtmmkwidgets.depends = multimediakit +library_qtmmwidgets.subdir = $$IN_PWD/multimediawidgets +library_qtmmwidgets.depends = multimedia -SUBDIRS += multimediakit -SUBDIRS += library_qtmmkwidgets +SUBDIRS += multimedia +SUBDIRS += library_qtmmwidgets SUBDIRS += imports SUBDIRS += plugins diff --git a/sync.profile b/sync.profile index 57945b1b2..6e444dcdf 100644 --- a/sync.profile +++ b/sync.profile @@ -1,14 +1,14 @@ %modules = ( # path to module name map - "QtMultimediaKit" => "$basedir/src/multimediakit", - "QtMultimediaKitWidgets" => "$basedir/src/multimediakitwidgets", + "QtMultimedia" => "$basedir/src/multimedia", + "QtMultimediaWidgets" => "$basedir/src/multimediawidgets", ); %moduleheaders = ( # restrict the module headers to those found in relative path ); %classnames = ( - "qtmultimediakitversion.h" => "QtMultimediaKitVersion", - "qtmultimediakitwidgetsversion.h" => "QtMultimediaKitWidgetsVersion", + "qtmultimediaversion.h" => "QtMultimediaVersion", + "qtmultimediawidgetsversion.h" => "QtMultimediaWidgetsVersion", ); %mastercontent = ( @@ -18,8 +18,8 @@ ); %modulepris = ( - "QtMultimediaKit" => "$basedir/modules/qt_multimediakit.pri", - "QtMultimediaKitWidgets" => "$basedir/modules/qt_multimediakitwidgets.pri", + "QtMultimedia" => "$basedir/modules/qt_multimedia.pri", + "QtMultimediaWidgets" => "$basedir/modules/qt_multimediawidgets.pri", ); # Module dependencies. @@ -31,7 +31,6 @@ %dependencies = ( "qtbase" => "refs/heads/master", "qtsvg" => "refs/heads/master", - "qtscript" => "refs/heads/master", "qtxmlpatterns" => "refs/heads/master", "qtdeclarative" => "refs/heads/master", ); diff --git a/tests/auto/auto.pro b/tests/auto/auto.pro index a8160c376..affd4e3d2 100644 --- a/tests/auto/auto.pro +++ b/tests/auto/auto.pro @@ -1,7 +1,7 @@ TEMPLATE = subdirs SUBDIRS += multimedia.pro -contains(QT_CONFIG,multimediakitwidgets): SUBDIRS += multimediawidgets.pro +contains(QT_CONFIG,multimediawidgets): SUBDIRS += multimediawidgets.pro # These autotests consist of things such as static code checks # which require that the autotest is run on the same machine diff --git a/tests/auto/qabstractvideobuffer/qabstractvideobuffer.pro b/tests/auto/qabstractvideobuffer/qabstractvideobuffer.pro index 9bc5bbebc..d6c7a0766 100644 --- a/tests/auto/qabstractvideobuffer/qabstractvideobuffer.pro +++ b/tests/auto/qabstractvideobuffer/qabstractvideobuffer.pro @@ -1,6 +1,6 @@ load(qttest_p4) -QT += core multimediakit-private +QT += core multimedia-private CONFIG += no_private_qt_headers_warning SOURCES += tst_qabstractvideobuffer.cpp diff --git a/tests/auto/qabstractvideosurface/qabstractvideosurface.pro b/tests/auto/qabstractvideosurface/qabstractvideosurface.pro index 49461d385..d580a0e8a 100644 --- a/tests/auto/qabstractvideosurface/qabstractvideosurface.pro +++ b/tests/auto/qabstractvideosurface/qabstractvideosurface.pro @@ -1,6 +1,6 @@ load(qttest_p4) -QT += core multimediakit-private +QT += core multimedia-private CONFIG += no_private_qt_headers_warning SOURCES += tst_qabstractvideosurface.cpp diff --git a/tests/auto/qaudiocapturesource/qaudiocapturesource.pro b/tests/auto/qaudiocapturesource/qaudiocapturesource.pro index 9addb194c..9a53b54a1 100644 --- a/tests/auto/qaudiocapturesource/qaudiocapturesource.pro +++ b/tests/auto/qaudiocapturesource/qaudiocapturesource.pro @@ -1,6 +1,6 @@ load(qttest_p4) -QT += multimediakit-private +QT += multimedia-private CONFIG += no_private_qt_headers_warning SOURCES += tst_qaudiocapturesource.cpp diff --git a/tests/auto/qaudiocapturesource/tst_qaudiocapturesource.cpp b/tests/auto/qaudiocapturesource/tst_qaudiocapturesource.cpp index f798d8f2c..d2620b8eb 100644 --- a/tests/auto/qaudiocapturesource/tst_qaudiocapturesource.cpp +++ b/tests/auto/qaudiocapturesource/tst_qaudiocapturesource.cpp @@ -167,14 +167,14 @@ void tst_QAudioCaptureSource::testAvailability() QAudioCaptureSource source(0, &provider); QVERIFY(source.isAvailable() == false); - QVERIFY(source.availabilityError() == QtMultimediaKit::ServiceMissingError); + QVERIFY(source.availabilityError() == QtMultimedia::ServiceMissingError); service.hasControls = true; MockMediaServiceProvider provider2(&service); QAudioCaptureSource source2(0, &provider2); QVERIFY(source2.isAvailable() == true); - QVERIFY(source2.availabilityError() == QtMultimediaKit::NoError); + QVERIFY(source2.availabilityError() == QtMultimedia::NoError); } void tst_QAudioCaptureSource::testAvailableAudioInputChangedSignal() diff --git a/tests/auto/qaudiodeviceinfo/qaudiodeviceinfo.pro b/tests/auto/qaudiodeviceinfo/qaudiodeviceinfo.pro index bca2f3edd..0d66771fe 100644 --- a/tests/auto/qaudiodeviceinfo/qaudiodeviceinfo.pro +++ b/tests/auto/qaudiodeviceinfo/qaudiodeviceinfo.pro @@ -1,6 +1,6 @@ load(qttest_p4) -QT += core multimediakit-private +QT += core multimedia-private CONFIG += no_private_qt_headers_warning # This is more of a system test diff --git a/tests/auto/qaudioformat/qaudioformat.pro b/tests/auto/qaudioformat/qaudioformat.pro index 60fd74a4f..10b962ed2 100644 --- a/tests/auto/qaudioformat/qaudioformat.pro +++ b/tests/auto/qaudioformat/qaudioformat.pro @@ -1,6 +1,6 @@ load(qttest_p4) -QT += core multimediakit-private +QT += core multimedia-private CONFIG += no_private_qt_headers_warning SOURCES += tst_qaudioformat.cpp diff --git a/tests/auto/qaudioinput/qaudioinput.pro b/tests/auto/qaudioinput/qaudioinput.pro index c5a952bf8..446315f07 100644 --- a/tests/auto/qaudioinput/qaudioinput.pro +++ b/tests/auto/qaudioinput/qaudioinput.pro @@ -1,6 +1,6 @@ load(qttest_p4) -QT += core multimediakit-private +QT += core multimedia-private CONFIG += no_private_qt_headers_warning # This is more of a system test diff --git a/tests/auto/qaudiooutput/qaudiooutput.pro b/tests/auto/qaudiooutput/qaudiooutput.pro index 3693dbbef..4a0267286 100644 --- a/tests/auto/qaudiooutput/qaudiooutput.pro +++ b/tests/auto/qaudiooutput/qaudiooutput.pro @@ -1,6 +1,6 @@ load(qttest_p4) -QT += core multimediakit-private +QT += core multimedia-private CONFIG += no_private_qt_headers_warning # This is more of a system test diff --git a/tests/auto/qcamera/qcamera.pro b/tests/auto/qcamera/qcamera.pro index 9e4a7e8ae..75a9200e9 100644 --- a/tests/auto/qcamera/qcamera.pro +++ b/tests/auto/qcamera/qcamera.pro @@ -1,6 +1,6 @@ load(qttest_p4) -QT += multimediakit-private +QT += multimedia-private CONFIG += no_private_qt_headers_warning include (../qmultimedia_common/mock.pri) diff --git a/tests/auto/qcamera/tst_qcamera.cpp b/tests/auto/qcamera/tst_qcamera.cpp index f0962394a..c9093e239 100644 --- a/tests/auto/qcamera/tst_qcamera.cpp +++ b/tests/auto/qcamera/tst_qcamera.cpp @@ -69,7 +69,7 @@ QT_USE_NAMESPACE -Q_DECLARE_METATYPE(QtMultimediaKit::MetaData) +Q_DECLARE_METATYPE(QtMultimedia::MetaData) class tst_QCamera: public QObject { @@ -175,7 +175,7 @@ void tst_QCamera::initTestCase() provider = new MockMediaServiceProvider; mockSimpleCameraService = new MockSimpleCameraService; provider->service = mockSimpleCameraService; - qRegisterMetaType("QtMultimediaKit::MetaData"); + qRegisterMetaType("QtMultimedia::MetaData"); } void tst_QCamera::cleanupTestCase() @@ -515,7 +515,7 @@ void tst_QCamera::testCameraCaptureMetadata() QCamera camera(0, provider); QCameraImageCapture imageCapture(&camera); - QSignalSpy metadataSignal(&imageCapture, SIGNAL(imageMetadataAvailable(int,QtMultimediaKit::MetaData,QVariant))); + QSignalSpy metadataSignal(&imageCapture, SIGNAL(imageMetadataAvailable(int,QtMultimedia::MetaData,QVariant))); QSignalSpy extendedMetadataSignal(&imageCapture, SIGNAL(imageMetadataAvailable(int,QString,QVariant))); QSignalSpy savedSignal(&imageCapture, SIGNAL(imageSaved(int,QString))); @@ -531,12 +531,12 @@ void tst_QCamera::testCameraCaptureMetadata() QVariantList metadata = metadataSignal[0]; QCOMPARE(metadata[0].toInt(), id); - QCOMPARE(metadata[1].value(), QtMultimediaKit::FocalLengthIn35mmFilm); + QCOMPARE(metadata[1].value(), QtMultimedia::FocalLengthIn35mmFilm); QCOMPARE(metadata[2].value().toInt(), 50); metadata = metadataSignal[1]; QCOMPARE(metadata[0].toInt(), id); - QCOMPARE(metadata[1].value(), QtMultimediaKit::DateTimeOriginal); + QCOMPARE(metadata[1].value(), QtMultimedia::DateTimeOriginal); QDateTime captureTime = metadata[2].value().value(); QVERIFY(qAbs(captureTime.secsTo(QDateTime::currentDateTime()) < 5)); //it should not takes more than 5 seconds for signal to arrive here @@ -785,9 +785,9 @@ void tst_QCamera::testImageSettings() QVERIFY(settings != QImageEncoderSettings()); settings = QImageEncoderSettings(); - QCOMPARE(settings.quality(), QtMultimediaKit::NormalQuality); - settings.setQuality(QtMultimediaKit::HighQuality); - QCOMPARE(settings.quality(), QtMultimediaKit::HighQuality); + QCOMPARE(settings.quality(), QtMultimedia::NormalQuality); + settings.setQuality(QtMultimedia::HighQuality); + QCOMPARE(settings.quality(), QtMultimedia::HighQuality); QVERIFY(!settings.isNull()); settings = QImageEncoderSettings(); @@ -801,7 +801,7 @@ void tst_QCamera::testImageSettings() settings = QImageEncoderSettings(); QVERIFY(settings.isNull()); QCOMPARE(settings.codec(), QString()); - QCOMPARE(settings.quality(), QtMultimediaKit::NormalQuality); + QCOMPARE(settings.quality(), QtMultimedia::NormalQuality); QCOMPARE(settings.resolution(), QSize()); { @@ -813,7 +813,7 @@ void tst_QCamera::testImageSettings() QCOMPARE(settings2, settings1); QVERIFY(settings2.isNull()); - settings1.setQuality(QtMultimediaKit::HighQuality); + settings1.setQuality(QtMultimedia::HighQuality); QVERIFY(settings2.isNull()); QVERIFY(!settings1.isNull()); @@ -829,7 +829,7 @@ void tst_QCamera::testImageSettings() QCOMPARE(settings2, settings1); QVERIFY(settings2.isNull()); - settings1.setQuality(QtMultimediaKit::HighQuality); + settings1.setQuality(QtMultimedia::HighQuality); QVERIFY(settings2.isNull()); QVERIFY(!settings1.isNull()); @@ -856,11 +856,11 @@ void tst_QCamera::testImageSettings() QVERIFY(settings1 != settings2); settings1 = QImageEncoderSettings(); - settings1.setQuality(QtMultimediaKit::NormalQuality); + settings1.setQuality(QtMultimedia::NormalQuality); settings2 = QImageEncoderSettings(); - settings2.setQuality(QtMultimediaKit::NormalQuality); + settings2.setQuality(QtMultimedia::NormalQuality); QVERIFY(settings1 == settings2); - settings2.setQuality(QtMultimediaKit::LowQuality); + settings2.setQuality(QtMultimedia::LowQuality); QVERIFY(settings1 != settings2); } @@ -1246,10 +1246,10 @@ void tst_QCamera::testAvailabilityError() MockCameraService service; provider->service = &service; QCamera camera(0, provider); - QVERIFY(camera.availabilityError() == QtMultimediaKit::NoError); + QVERIFY(camera.availabilityError() == QtMultimedia::NoError); QCamera *camera1 = new QCamera("random"); - QVERIFY(camera1->availabilityError() == QtMultimediaKit::ServiceMissingError); + QVERIFY(camera1->availabilityError() == QtMultimedia::ServiceMissingError); delete camera1; } diff --git a/tests/auto/qcamerabackend/qcamerabackend.pro b/tests/auto/qcamerabackend/qcamerabackend.pro index 638c2c368..70206b229 100644 --- a/tests/auto/qcamerabackend/qcamerabackend.pro +++ b/tests/auto/qcamerabackend/qcamerabackend.pro @@ -1,6 +1,6 @@ load(qttest_p4) -QT += multimediakit-private multimediakitwidgets-private +QT += multimedia-private multimediawidgets-private CONFIG += no_private_qt_headers_warning # This is more of a system test diff --git a/tests/auto/qcamerabackend/tst_qcamerabackend.cpp b/tests/auto/qcamerabackend/tst_qcamerabackend.cpp index 523a8e290..a6399f5c6 100644 --- a/tests/auto/qcamerabackend/tst_qcamerabackend.cpp +++ b/tests/auto/qcamerabackend/tst_qcamerabackend.cpp @@ -121,7 +121,7 @@ QT_USE_NAMESPACE */ -Q_DECLARE_METATYPE(QtMultimediaKit::MetaData) +Q_DECLARE_METATYPE(QtMultimedia::MetaData) Q_DECLARE_METATYPE(QVideoFrame) class tst_QCameraBackend: public QObject @@ -149,7 +149,7 @@ private: void tst_QCameraBackend::initTestCase() { - qRegisterMetaType("QtMultimediaKit::MetaData"); + qRegisterMetaType("QtMultimedia::MetaData"); QCamera camera; if (!camera.isAvailable()) @@ -523,7 +523,7 @@ void tst_QCameraBackend::testCameraCaptureMetadata() QCameraImageCapture imageCapture(&camera); camera.exposure()->setFlashMode(QCameraExposure::FlashOff); - QSignalSpy metadataSignal(&imageCapture, SIGNAL(imageMetadataAvailable(int,QtMultimediaKit::MetaData,QVariant))); + QSignalSpy metadataSignal(&imageCapture, SIGNAL(imageMetadataAvailable(int,QtMultimedia::MetaData,QVariant))); QSignalSpy savedSignal(&imageCapture, SIGNAL(imageSaved(int,QString))); camera.start(); diff --git a/tests/auto/qcameraimagecapture/qcameraimagecapture.pro b/tests/auto/qcameraimagecapture/qcameraimagecapture.pro index a69d2f342..7f37061fa 100644 --- a/tests/auto/qcameraimagecapture/qcameraimagecapture.pro +++ b/tests/auto/qcameraimagecapture/qcameraimagecapture.pro @@ -1,6 +1,6 @@ load(qttest_p4) -QT += multimediakit-private +QT += multimedia-private CONFIG += no_private_qt_headers_warning SOURCES += \ diff --git a/tests/auto/qcameraimagecapture/tst_qcameraimagecapture.cpp b/tests/auto/qcameraimagecapture/tst_qcameraimagecapture.cpp index 312def45e..e842cbb83 100644 --- a/tests/auto/qcameraimagecapture/tst_qcameraimagecapture.cpp +++ b/tests/auto/qcameraimagecapture/tst_qcameraimagecapture.cpp @@ -254,11 +254,11 @@ void tst_QCameraImageCapture::encodingSettings() QVERIFY(imageCapture.encodingSettings() == QImageEncoderSettings()); QImageEncoderSettings settings; settings.setCodec("JPEG"); - settings.setQuality(QtMultimediaKit::NormalQuality); + settings.setQuality(QtMultimedia::NormalQuality); imageCapture.setEncodingSettings(settings); QVERIFY(!imageCapture.encodingSettings().isNull()); QVERIFY(imageCapture.encodingSettings().codec() == "JPEG"); - QVERIFY(imageCapture.encodingSettings().quality() == QtMultimediaKit::NormalQuality); + QVERIFY(imageCapture.encodingSettings().quality() == QtMultimedia::NormalQuality); } //MaemoAPI-1838:test supportedImageCodecs @@ -307,7 +307,7 @@ void tst_QCameraImageCapture::errors() imageCapture1.capture(QString::fromLatin1("/dev/null")); QVERIFY(imageCapture1.error() == QCameraImageCapture::NotSupportedFeatureError); QVERIFY2(!imageCapture1.errorString().isEmpty(), "Device does not support images capture"); - QVERIFY(imageCapture1.availabilityError() == QtMultimediaKit::ServiceMissingError); + QVERIFY(imageCapture1.availabilityError() == QtMultimedia::ServiceMissingError); QCamera camera(0, provider); @@ -315,12 +315,12 @@ void tst_QCameraImageCapture::errors() QVERIFY(imageCapture.isAvailable() == true); QVERIFY(imageCapture.error() == QCameraImageCapture::NoError); QVERIFY(imageCapture.errorString().isEmpty()); - QVERIFY(imageCapture.availabilityError() == QtMultimediaKit::NoError); + QVERIFY(imageCapture.availabilityError() == QtMultimedia::NoError); imageCapture.capture(); QVERIFY(imageCapture.error() == QCameraImageCapture::NotReadyError); QVERIFY2(!imageCapture.errorString().isEmpty(), "Could not capture in stopped state"); - QVERIFY(imageCapture.availabilityError() == QtMultimediaKit::NoError); + QVERIFY(imageCapture.availabilityError() == QtMultimedia::NoError); } //MaemoAPI-1831:test error diff --git a/tests/auto/qcameraviewfinder/qcameraviewfinder.pro b/tests/auto/qcameraviewfinder/qcameraviewfinder.pro index 3f751ac95..2543b3ffd 100644 --- a/tests/auto/qcameraviewfinder/qcameraviewfinder.pro +++ b/tests/auto/qcameraviewfinder/qcameraviewfinder.pro @@ -1,6 +1,6 @@ load(qttest_p4) -QT += multimediakit-private multimediakitwidgets-private +QT += multimedia-private multimediawidgets-private CONFIG += no_private_qt_headers_warning include (../qmultimedia_common/mock.pri) diff --git a/tests/auto/qcamerawidgets/qcamerawidgets.pro b/tests/auto/qcamerawidgets/qcamerawidgets.pro index 220e16d6b..b97232ab3 100644 --- a/tests/auto/qcamerawidgets/qcamerawidgets.pro +++ b/tests/auto/qcamerawidgets/qcamerawidgets.pro @@ -1,6 +1,6 @@ load(qttest_p4) -QT += multimediakit-private multimediakitwidgets-private +QT += multimedia-private multimediawidgets-private CONFIG += no_private_qt_headers_warning include (../qmultimedia_common/mock.pri) diff --git a/tests/auto/qcamerawidgets/tst_qcamerawidgets.cpp b/tests/auto/qcamerawidgets/tst_qcamerawidgets.cpp index c6b448225..dc29b949d 100644 --- a/tests/auto/qcamerawidgets/tst_qcamerawidgets.cpp +++ b/tests/auto/qcamerawidgets/tst_qcamerawidgets.cpp @@ -72,7 +72,7 @@ QT_USE_NAMESPACE -Q_DECLARE_METATYPE(QtMultimediaKit::MetaData) +Q_DECLARE_METATYPE(QtMultimedia::MetaData) class tst_QCameraWidgets: public QObject { @@ -98,7 +98,7 @@ void tst_QCameraWidgets::initTestCase() provider = new MockMediaServiceProvider; mockSimpleCameraService = new MockSimpleCameraService; provider->service = mockSimpleCameraService; - qRegisterMetaType("QtMultimediaKit::MetaData"); + qRegisterMetaType("QtMultimedia::MetaData"); } void tst_QCameraWidgets::cleanupTestCase() diff --git a/tests/auto/qdeclarativeaudio/qdeclarativeaudio.pro b/tests/auto/qdeclarativeaudio/qdeclarativeaudio.pro index 0b9b5e295..923e3bad3 100644 --- a/tests/auto/qdeclarativeaudio/qdeclarativeaudio.pro +++ b/tests/auto/qdeclarativeaudio/qdeclarativeaudio.pro @@ -1,16 +1,16 @@ load(qttest_p4) -QT += multimediakit-private declarative +QT += multimedia-private declarative CONFIG += no_private_qt_headers_warning HEADERS += \ - $$QT.multimediakit.sources/../imports/multimedia/qdeclarativeaudio_p.h \ - $$QT.multimediakit.sources/../imports/multimedia/qdeclarativemediabase_p.h \ - $$QT.multimediakit.sources/../imports/multimedia/qdeclarativemediametadata_p.h + $$QT.multimedia.sources/../imports/multimedia/qdeclarativeaudio_p.h \ + $$QT.multimedia.sources/../imports/multimedia/qdeclarativemediabase_p.h \ + $$QT.multimedia.sources/../imports/multimedia/qdeclarativemediametadata_p.h SOURCES += \ tst_qdeclarativeaudio.cpp \ - $$QT.multimediakit.sources/../imports/multimedia/qdeclarativeaudio.cpp \ - $$QT.multimediakit.sources/../imports/multimedia/qdeclarativemediabase.cpp + $$QT.multimedia.sources/../imports/multimedia/qdeclarativeaudio.cpp \ + $$QT.multimedia.sources/../imports/multimedia/qdeclarativemediabase.cpp -INCLUDEPATH += $$QT.multimediakit.sources/../imports/multimedia +INCLUDEPATH += $$QT.multimedia.sources/../imports/multimedia diff --git a/tests/auto/qdeclarativeaudio/tst_qdeclarativeaudio.cpp b/tests/auto/qdeclarativeaudio/tst_qdeclarativeaudio.cpp index ddf3fce13..01d14f3c9 100644 --- a/tests/auto/qdeclarativeaudio/tst_qdeclarativeaudio.cpp +++ b/tests/auto/qdeclarativeaudio/tst_qdeclarativeaudio.cpp @@ -82,7 +82,7 @@ private slots: void loops(); }; -Q_DECLARE_METATYPE(QtMultimediaKit::MetaData); +Q_DECLARE_METATYPE(QtMultimedia::MetaData); Q_DECLARE_METATYPE(QDeclarativeAudio::Error); class QtTestMediaPlayerControl : public QMediaPlayerControl @@ -203,17 +203,17 @@ public: bool isMetaDataAvailable() const { return true; } - QVariant metaData(QtMultimediaKit::MetaData key) const { return m_metaData.value(key); } - void setMetaData(QtMultimediaKit::MetaData key, const QVariant &value) { + QVariant metaData(QtMultimedia::MetaData key) const { return m_metaData.value(key); } + void setMetaData(QtMultimedia::MetaData key, const QVariant &value) { m_metaData.insert(key, value); emit metaDataChanged(); } - QList availableMetaData() const { return m_metaData.keys(); } + QList availableMetaData() const { return m_metaData.keys(); } QVariant extendedMetaData(const QString &) const { return QVariant(); } QStringList availableExtendedMetaData() const { return QStringList(); } private: - QMap m_metaData; + QMap m_metaData; }; class QtTestMediaService : public QMediaService @@ -1123,29 +1123,29 @@ void tst_QDeclarativeAudio::status() void tst_QDeclarativeAudio::metaData_data() { QTest::addColumn("propertyName"); - QTest::addColumn("propertyKey"); + QTest::addColumn("propertyKey"); QTest::addColumn("value"); QTest::newRow("title") << QByteArray("title") - << QtMultimediaKit::Title + << QtMultimedia::Title << QVariant(QString::fromLatin1("This is a title")); QTest::newRow("genre") << QByteArray("genre") - << QtMultimediaKit::Genre + << QtMultimedia::Genre << QVariant(QString::fromLatin1("rock")); QTest::newRow("trackNumber") << QByteArray("trackNumber") - << QtMultimediaKit::TrackNumber + << QtMultimedia::TrackNumber << QVariant(8); } void tst_QDeclarativeAudio::metaData() { QFETCH(QByteArray, propertyName); - QFETCH(QtMultimediaKit::MetaData, propertyKey); + QFETCH(QtMultimedia::MetaData, propertyKey); QFETCH(QVariant, value); QtTestMediaServiceProvider provider; diff --git a/tests/auto/qdeclarativevideo/qdeclarativevideo.pro b/tests/auto/qdeclarativevideo/qdeclarativevideo.pro index 35d7b14cf..02afacee9 100644 --- a/tests/auto/qdeclarativevideo/qdeclarativevideo.pro +++ b/tests/auto/qdeclarativevideo/qdeclarativevideo.pro @@ -1,17 +1,17 @@ load(qttest_p4) -QT += multimediakit-private declarative +QT += multimedia-private declarative CONFIG += no_private_qt_headers_warning HEADERS += \ - $$QT.multimediakit.sources/../imports/multimedia/qdeclarativevideo_p.h \ - $$QT.multimediakit.sources/../imports/multimedia/qdeclarativemediabase_p.h \ - $$QT.multimediakit.sources/../imports/multimedia/qdeclarativemediametadata_p.h + $$QT.multimedia.sources/../imports/multimedia/qdeclarativevideo_p.h \ + $$QT.multimedia.sources/../imports/multimedia/qdeclarativemediabase_p.h \ + $$QT.multimedia.sources/../imports/multimedia/qdeclarativemediametadata_p.h SOURCES += \ tst_qdeclarativevideo.cpp \ - $$QT.multimediakit.sources/../imports/multimedia/qdeclarativevideo.cpp \ - $$QT.multimediakit.sources/../imports/multimedia/qdeclarativemediabase.cpp + $$QT.multimedia.sources/../imports/multimedia/qdeclarativevideo.cpp \ + $$QT.multimedia.sources/../imports/multimedia/qdeclarativemediabase.cpp -INCLUDEPATH += $$QT.multimediakit.sources/../imports/multimedia +INCLUDEPATH += $$QT.multimedia.sources/../imports/multimedia QT+=widgets diff --git a/tests/auto/qdeclarativevideo/tst_qdeclarativevideo.cpp b/tests/auto/qdeclarativevideo/tst_qdeclarativevideo.cpp index 035310079..750cd9320 100644 --- a/tests/auto/qdeclarativevideo/tst_qdeclarativevideo.cpp +++ b/tests/auto/qdeclarativevideo/tst_qdeclarativevideo.cpp @@ -78,7 +78,7 @@ private slots: void geometry(); }; -Q_DECLARE_METATYPE(QtMultimediaKit::MetaData); +Q_DECLARE_METATYPE(QtMultimedia::MetaData); Q_DECLARE_METATYPE(QDeclarativeVideo::Error); class QtTestMediaPlayerControl : public QMediaPlayerControl diff --git a/tests/auto/qgraphicsvideoitem/qgraphicsvideoitem.pro b/tests/auto/qgraphicsvideoitem/qgraphicsvideoitem.pro index 25ebe0ff2..cd88f4ba0 100644 --- a/tests/auto/qgraphicsvideoitem/qgraphicsvideoitem.pro +++ b/tests/auto/qgraphicsvideoitem/qgraphicsvideoitem.pro @@ -1,6 +1,6 @@ load(qttest_p4) -QT += multimediakit-private multimediakitwidgets-private +QT += multimedia-private multimediawidgets-private CONFIG += no_private_qt_headers_warning SOURCES += tst_qgraphicsvideoitem.cpp diff --git a/tests/auto/qgraphicsvideoitem/tst_qgraphicsvideoitem.cpp b/tests/auto/qgraphicsvideoitem/tst_qgraphicsvideoitem.cpp index 79b3a0ab3..393ac7a49 100644 --- a/tests/auto/qgraphicsvideoitem/tst_qgraphicsvideoitem.cpp +++ b/tests/auto/qgraphicsvideoitem/tst_qgraphicsvideoitem.cpp @@ -41,7 +41,7 @@ //TESTED_COMPONENT=src/multimedia -#include +#include #include "qgraphicsvideoitem.h" #include #include "qmediaobject.h" diff --git a/tests/auto/qmediabindableinterface/qmediabindableinterface.pro b/tests/auto/qmediabindableinterface/qmediabindableinterface.pro index 95e9f24a7..530d55039 100644 --- a/tests/auto/qmediabindableinterface/qmediabindableinterface.pro +++ b/tests/auto/qmediabindableinterface/qmediabindableinterface.pro @@ -1,6 +1,6 @@ load(qttest_p4) -QT += multimediakit-private +QT += multimedia-private CONFIG += no_private_qt_headers_warning SOURCES += \ diff --git a/tests/auto/qmediacontainercontrol/qmediacontainercontrol.pro b/tests/auto/qmediacontainercontrol/qmediacontainercontrol.pro index c9e94711e..54088400f 100644 --- a/tests/auto/qmediacontainercontrol/qmediacontainercontrol.pro +++ b/tests/auto/qmediacontainercontrol/qmediacontainercontrol.pro @@ -1,6 +1,6 @@ load(qttest_p4) -QT += multimediakit-private +QT += multimedia-private CONFIG += no_private_qt_headers_warning SOURCES += tst_qmediacontainercontrol.cpp diff --git a/tests/auto/qmediacontent/qmediacontent.pro b/tests/auto/qmediacontent/qmediacontent.pro index a843c30e4..493a1d977 100644 --- a/tests/auto/qmediacontent/qmediacontent.pro +++ b/tests/auto/qmediacontent/qmediacontent.pro @@ -1,6 +1,6 @@ load(qttest_p4) -QT += multimediakit-private network +QT += multimedia-private network CONFIG += no_private_qt_headers_warning SOURCES += tst_qmediacontent.cpp diff --git a/tests/auto/qmediaimageviewer/qmediaimageviewer.pro b/tests/auto/qmediaimageviewer/qmediaimageviewer.pro index 5372a19d6..50b01f1b6 100644 --- a/tests/auto/qmediaimageviewer/qmediaimageviewer.pro +++ b/tests/auto/qmediaimageviewer/qmediaimageviewer.pro @@ -1,6 +1,6 @@ load(qttest_p4) -QT += multimediakit-private network +QT += multimedia-private network CONFIG += no_private_qt_headers_warning SOURCES += tst_qmediaimageviewer.cpp diff --git a/tests/auto/qmediaimageviewer/tst_qmediaimageviewer.cpp b/tests/auto/qmediaimageviewer/tst_qmediaimageviewer.cpp index e1de92a05..00cfe8549 100644 --- a/tests/auto/qmediaimageviewer/tst_qmediaimageviewer.cpp +++ b/tests/auto/qmediaimageviewer/tst_qmediaimageviewer.cpp @@ -41,7 +41,7 @@ //TESTED_COMPONENT=src/multimedia -#include +#include #include #include diff --git a/tests/auto/qmediaimageviewerwidgets/qmediaimageviewerwidgets.pro b/tests/auto/qmediaimageviewerwidgets/qmediaimageviewerwidgets.pro index f3493685c..95cb87568 100644 --- a/tests/auto/qmediaimageviewerwidgets/qmediaimageviewerwidgets.pro +++ b/tests/auto/qmediaimageviewerwidgets/qmediaimageviewerwidgets.pro @@ -1,6 +1,6 @@ load(qttest_p4) -QT += multimediakit-private multimediakitwidgets-private network +QT += multimedia-private multimediawidgets-private network CONFIG += no_private_qt_headers_warning SOURCES += tst_qmediaimageviewerwidgets.cpp diff --git a/tests/auto/qmediaimageviewerwidgets/tst_qmediaimageviewerwidgets.cpp b/tests/auto/qmediaimageviewerwidgets/tst_qmediaimageviewerwidgets.cpp index fd51b0063..80c745fe0 100644 --- a/tests/auto/qmediaimageviewerwidgets/tst_qmediaimageviewerwidgets.cpp +++ b/tests/auto/qmediaimageviewerwidgets/tst_qmediaimageviewerwidgets.cpp @@ -41,7 +41,7 @@ //TESTED_COMPONENT=src/multimedia -#include +#include #include #include diff --git a/tests/auto/qmediaobject/qmediaobject.pro b/tests/auto/qmediaobject/qmediaobject.pro index 66f60e1d5..b164adbb6 100644 --- a/tests/auto/qmediaobject/qmediaobject.pro +++ b/tests/auto/qmediaobject/qmediaobject.pro @@ -1,6 +1,6 @@ load(qttest_p4) -QT += multimediakit-private +QT += multimedia-private CONFIG += no_private_qt_headers_warning include (../qmultimedia_common/mockrecorder.pri) diff --git a/tests/auto/qmediaobject/tst_qmediaobject.cpp b/tests/auto/qmediaobject/tst_qmediaobject.cpp index 6a337ac50..dde293634 100644 --- a/tests/auto/qmediaobject/tst_qmediaobject.cpp +++ b/tests/auto/qmediaobject/tst_qmediaobject.cpp @@ -244,9 +244,9 @@ void tst_QMediaObject::nullMetaDataControl() QCOMPARE(object.isMetaDataAvailable(), false); - QCOMPARE(object.metaData(QtMultimediaKit::Title).toString(), QString()); + QCOMPARE(object.metaData(QtMultimedia::Title).toString(), QString()); QCOMPARE(object.extendedMetaData(titleKey).toString(), QString()); - QCOMPARE(object.availableMetaData(), QList()); + QCOMPARE(object.availableMetaData(), QList()); QCOMPARE(object.availableExtendedMetaData(), QStringList()); QCOMPARE(spy.count(), 0); } @@ -311,18 +311,18 @@ void tst_QMediaObject::metaData() QtTestMediaObject object(&service); QVERIFY(object.availableMetaData().isEmpty()); - service.metaData.m_data.insert(QtMultimediaKit::AlbumArtist, artist); - service.metaData.m_data.insert(QtMultimediaKit::Title, title); - service.metaData.m_data.insert(QtMultimediaKit::Genre, genre); + service.metaData.m_data.insert(QtMultimedia::AlbumArtist, artist); + service.metaData.m_data.insert(QtMultimedia::Title, title); + service.metaData.m_data.insert(QtMultimedia::Genre, genre); - QCOMPARE(object.metaData(QtMultimediaKit::AlbumArtist).toString(), artist); - QCOMPARE(object.metaData(QtMultimediaKit::Title).toString(), title); + QCOMPARE(object.metaData(QtMultimedia::AlbumArtist).toString(), artist); + QCOMPARE(object.metaData(QtMultimedia::Title).toString(), title); - QList metaDataKeys = object.availableMetaData(); + QList metaDataKeys = object.availableMetaData(); QCOMPARE(metaDataKeys.size(), 3); - QVERIFY(metaDataKeys.contains(QtMultimediaKit::AlbumArtist)); - QVERIFY(metaDataKeys.contains(QtMultimediaKit::Title)); - QVERIFY(metaDataKeys.contains(QtMultimediaKit::Genre)); + QVERIFY(metaDataKeys.contains(QtMultimedia::AlbumArtist)); + QVERIFY(metaDataKeys.contains(QtMultimedia::Title)); + QVERIFY(metaDataKeys.contains(QtMultimedia::Genre)); } void tst_QMediaObject::extendedMetaData() @@ -353,12 +353,12 @@ void tst_QMediaObject::availability() { QtTestMediaObject nullObject(0); QCOMPARE(nullObject.isAvailable(), false); - QCOMPARE(nullObject.availabilityError(), QtMultimediaKit::ServiceMissingError); + QCOMPARE(nullObject.availabilityError(), QtMultimedia::ServiceMissingError); QtTestMetaDataService service; QtTestMediaObject object(&service); QCOMPARE(object.isAvailable(), true); - QCOMPARE(object.availabilityError(), QtMultimediaKit::NoError); + QCOMPARE(object.availabilityError(), QtMultimedia::NoError); } void tst_QMediaObject::service() diff --git a/tests/auto/qmediaplayer/qmediaplayer.pro b/tests/auto/qmediaplayer/qmediaplayer.pro index bdb616a27..dae3ddebd 100644 --- a/tests/auto/qmediaplayer/qmediaplayer.pro +++ b/tests/auto/qmediaplayer/qmediaplayer.pro @@ -1,6 +1,6 @@ load(qttest_p4) -QT += network multimediakit-private +QT += network multimedia-private CONFIG += no_private_qt_headers_warning HEADERS += tst_qmediaplayer.h diff --git a/tests/auto/qmediaplayer/tst_qmediaplayer.cpp b/tests/auto/qmediaplayer/tst_qmediaplayer.cpp index 8117ae1aa..383a4c4f3 100644 --- a/tests/auto/qmediaplayer/tst_qmediaplayer.cpp +++ b/tests/auto/qmediaplayer/tst_qmediaplayer.cpp @@ -167,7 +167,7 @@ void tst_QMediaPlayer::testNullService() QCOMPARE(player.playbackRate(), qreal(0)); QCOMPARE(player.error(), QMediaPlayer::ServiceMissingError); QCOMPARE(player.isAvailable(), false); - QCOMPARE(player.availabilityError(), QtMultimediaKit::ServiceMissingError); + QCOMPARE(player.availabilityError(), QtMultimedia::ServiceMissingError); { QFETCH_GLOBAL(QMediaContent, mediaContent); @@ -448,7 +448,7 @@ void tst_QMediaPlayer::testErrorString() void tst_QMediaPlayer::testIsAvailable() { QCOMPARE(player->isAvailable(), true); - QCOMPARE(player->availabilityError(), QtMultimediaKit::NoError); + QCOMPARE(player->availabilityError(), QtMultimedia::NoError); } void tst_QMediaPlayer::testService() diff --git a/tests/auto/qmediaplayerbackend/qmediaplayerbackend.pro b/tests/auto/qmediaplayerbackend/qmediaplayerbackend.pro index c89a30f31..c86afc44b 100644 --- a/tests/auto/qmediaplayerbackend/qmediaplayerbackend.pro +++ b/tests/auto/qmediaplayerbackend/qmediaplayerbackend.pro @@ -1,6 +1,6 @@ load(qttest_p4) -QT += multimediakit-private +QT += multimedia-private CONFIG += no_private_qt_headers_warning # This is more of a system test diff --git a/tests/auto/qmediaplayerwidgets/qmediaplayerwidgets.pro b/tests/auto/qmediaplayerwidgets/qmediaplayerwidgets.pro index a750ca9fa..61c9c2bcc 100644 --- a/tests/auto/qmediaplayerwidgets/qmediaplayerwidgets.pro +++ b/tests/auto/qmediaplayerwidgets/qmediaplayerwidgets.pro @@ -1,6 +1,6 @@ load(qttest_p4) -QT += network multimediakit-private multimediakitwidgets-private +QT += network multimedia-private multimediawidgets-private CONFIG += no_private_qt_headers_warning HEADERS += tst_qmediaplayerwidgets.h diff --git a/tests/auto/qmediaplaylist/qmediaplaylist.pro b/tests/auto/qmediaplaylist/qmediaplaylist.pro index 38bac95ae..346251a31 100644 --- a/tests/auto/qmediaplaylist/qmediaplaylist.pro +++ b/tests/auto/qmediaplaylist/qmediaplaylist.pro @@ -5,18 +5,18 @@ CONFIG += insignificant_test include (../qmultimedia_common/mockplaylist.pri) -QT += multimediakit-private +QT += multimedia-private CONFIG += no_private_qt_headers_warning DEFINES += TESTDATA_DIR=\\\"$$PWD/\\\" HEADERS += \ - $$QT.multimediakit.sources/../plugins/m3u/qm3uhandler.h + $$QT.multimedia.sources/../plugins/m3u/qm3uhandler.h SOURCES += \ tst_qmediaplaylist.cpp \ - $$QT.multimediakit.sources/../plugins/m3u/qm3uhandler.cpp + $$QT.multimedia.sources/../plugins/m3u/qm3uhandler.cpp -INCLUDEPATH += $$QT.multimediakit.sources/../plugins/m3u +INCLUDEPATH += $$QT.multimedia.sources/../plugins/m3u maemo*:CONFIG += insignificant_test diff --git a/tests/auto/qmediaplaylistnavigator/qmediaplaylistnavigator.pro b/tests/auto/qmediaplaylistnavigator/qmediaplaylistnavigator.pro index 488249177..33c4336e5 100644 --- a/tests/auto/qmediaplaylistnavigator/qmediaplaylistnavigator.pro +++ b/tests/auto/qmediaplaylistnavigator/qmediaplaylistnavigator.pro @@ -1,6 +1,6 @@ load(qttest_p4) -QT += multimediakit-private +QT += multimedia-private CONFIG += no_private_qt_headers_warning SOURCES += tst_qmediaplaylistnavigator.cpp diff --git a/tests/auto/qmediapluginloader/qmediapluginloader.pro b/tests/auto/qmediapluginloader/qmediapluginloader.pro index 3299d50e5..eb1fd96e9 100644 --- a/tests/auto/qmediapluginloader/qmediapluginloader.pro +++ b/tests/auto/qmediapluginloader/qmediapluginloader.pro @@ -1,6 +1,6 @@ load(qttest_p4) -QT += multimediakit-private +QT += multimedia-private CONFIG += no_private_qt_headers_warning SOURCES += tst_qmediapluginloader.cpp diff --git a/tests/auto/qmediarecorder/qmediarecorder.pro b/tests/auto/qmediarecorder/qmediarecorder.pro index 5243a8206..b7ca93df1 100644 --- a/tests/auto/qmediarecorder/qmediarecorder.pro +++ b/tests/auto/qmediarecorder/qmediarecorder.pro @@ -1,6 +1,6 @@ load(qttest_p4) -QT += multimediakit-private +QT += multimedia-private CONFIG += no_private_qt_headers_warning include (../qmultimedia_common/mock.pri) diff --git a/tests/auto/qmediarecorder/tst_qmediarecorder.cpp b/tests/auto/qmediarecorder/tst_qmediarecorder.cpp index 4f46f54f5..d99d73cfb 100644 --- a/tests/auto/qmediarecorder/tst_qmediarecorder.cpp +++ b/tests/auto/qmediarecorder/tst_qmediarecorder.cpp @@ -135,7 +135,7 @@ void tst_QMediaRecorder::testNullControls() QAudioEncoderSettings audio; audio.setCodec(id); - audio.setQuality(QtMultimediaKit::LowQuality); + audio.setQuality(QtMultimedia::LowQuality); QVideoEncoderSettings video; video.setCodec(id); @@ -320,18 +320,18 @@ void tst_QMediaRecorder::testEncodingSettings() QCOMPARE(audioSettings.codec(), QString("audio/pcm")); QCOMPARE(audioSettings.bitRate(), 128*1024); QCOMPARE(audioSettings.sampleRate(), 8000); - QCOMPARE(audioSettings.quality(), QtMultimediaKit::NormalQuality); + QCOMPARE(audioSettings.quality(), QtMultimedia::NormalQuality); QCOMPARE(audioSettings.channelCount(), -1); - QCOMPARE(audioSettings.encodingMode(), QtMultimediaKit::ConstantQualityEncoding); + QCOMPARE(audioSettings.encodingMode(), QtMultimedia::ConstantQualityEncoding); QVideoEncoderSettings videoSettings = capture->videoSettings(); QCOMPARE(videoSettings.codec(), QString()); QCOMPARE(videoSettings.bitRate(), -1); QCOMPARE(videoSettings.resolution(), QSize()); QCOMPARE(videoSettings.frameRate(), 0.0); - QCOMPARE(videoSettings.quality(), QtMultimediaKit::NormalQuality); - QCOMPARE(videoSettings.encodingMode(), QtMultimediaKit::ConstantQualityEncoding); + QCOMPARE(videoSettings.quality(), QtMultimedia::NormalQuality); + QCOMPARE(videoSettings.encodingMode(), QtMultimedia::ConstantQualityEncoding); QString format = capture->containerMimeType(); QCOMPARE(format, QString()); @@ -339,15 +339,15 @@ void tst_QMediaRecorder::testEncodingSettings() audioSettings.setCodec("audio/mpeg"); audioSettings.setSampleRate(44100); audioSettings.setBitRate(256*1024); - audioSettings.setQuality(QtMultimediaKit::HighQuality); - audioSettings.setEncodingMode(QtMultimediaKit::AverageBitRateEncoding); + audioSettings.setQuality(QtMultimedia::HighQuality); + audioSettings.setEncodingMode(QtMultimedia::AverageBitRateEncoding); videoSettings.setCodec("video/3gpp"); videoSettings.setBitRate(800); videoSettings.setFrameRate(24*1024); videoSettings.setResolution(QSize(800,600)); - videoSettings.setQuality(QtMultimediaKit::HighQuality); - audioSettings.setEncodingMode(QtMultimediaKit::TwoPassEncoding); + videoSettings.setQuality(QtMultimedia::HighQuality); + audioSettings.setEncodingMode(QtMultimedia::TwoPassEncoding); format = QString("mov"); @@ -377,9 +377,9 @@ void tst_QMediaRecorder::testAudioSettings() QVERIFY(!settings.isNull()); settings = QAudioEncoderSettings(); - QCOMPARE(settings.quality(), QtMultimediaKit::NormalQuality); - settings.setQuality(QtMultimediaKit::HighQuality); - QCOMPARE(settings.quality(), QtMultimediaKit::HighQuality); + QCOMPARE(settings.quality(), QtMultimedia::NormalQuality); + settings.setQuality(QtMultimedia::HighQuality); + QCOMPARE(settings.quality(), QtMultimedia::HighQuality); QVERIFY(!settings.isNull()); settings = QAudioEncoderSettings(); @@ -398,7 +398,7 @@ void tst_QMediaRecorder::testAudioSettings() QVERIFY(settings.isNull()); QCOMPARE(settings.codec(), QString()); QCOMPARE(settings.bitRate(), -1); - QCOMPARE(settings.quality(), QtMultimediaKit::NormalQuality); + QCOMPARE(settings.quality(), QtMultimedia::NormalQuality); QCOMPARE(settings.sampleRate(), -1); { @@ -410,7 +410,7 @@ void tst_QMediaRecorder::testAudioSettings() QCOMPARE(settings2, settings1); QVERIFY(settings2.isNull()); - settings1.setQuality(QtMultimediaKit::HighQuality); + settings1.setQuality(QtMultimedia::HighQuality); QVERIFY(settings2.isNull()); QVERIFY(!settings1.isNull()); @@ -426,7 +426,7 @@ void tst_QMediaRecorder::testAudioSettings() QCOMPARE(settings2, settings1); QVERIFY(settings2.isNull()); - settings1.setQuality(QtMultimediaKit::HighQuality); + settings1.setQuality(QtMultimedia::HighQuality); QVERIFY(settings2.isNull()); QVERIFY(!settings1.isNull()); @@ -458,19 +458,19 @@ void tst_QMediaRecorder::testAudioSettings() QVERIFY(settings1 != settings2); settings1 = QAudioEncoderSettings(); - settings1.setEncodingMode(QtMultimediaKit::ConstantBitRateEncoding); + settings1.setEncodingMode(QtMultimedia::ConstantBitRateEncoding); settings2 = QAudioEncoderSettings(); - settings2.setEncodingMode(QtMultimediaKit::ConstantBitRateEncoding); + settings2.setEncodingMode(QtMultimedia::ConstantBitRateEncoding); QVERIFY(settings1 == settings2); - settings2.setEncodingMode(QtMultimediaKit::TwoPassEncoding); + settings2.setEncodingMode(QtMultimedia::TwoPassEncoding); QVERIFY(settings1 != settings2); settings1 = QAudioEncoderSettings(); - settings1.setQuality(QtMultimediaKit::NormalQuality); + settings1.setQuality(QtMultimedia::NormalQuality); settings2 = QAudioEncoderSettings(); - settings2.setQuality(QtMultimediaKit::NormalQuality); + settings2.setQuality(QtMultimedia::NormalQuality); QVERIFY(settings1 == settings2); - settings2.setQuality(QtMultimediaKit::LowQuality); + settings2.setQuality(QtMultimedia::LowQuality); QVERIFY(settings1 != settings2); settings1 = QAudioEncoderSettings(); @@ -501,9 +501,9 @@ void tst_QMediaRecorder::testVideoSettings() QVERIFY(!settings.isNull()); settings = QVideoEncoderSettings(); - QCOMPARE(settings.quality(), QtMultimediaKit::NormalQuality); - settings.setQuality(QtMultimediaKit::HighQuality); - QCOMPARE(settings.quality(), QtMultimediaKit::HighQuality); + QCOMPARE(settings.quality(), QtMultimedia::NormalQuality); + settings.setQuality(QtMultimedia::HighQuality); + QCOMPARE(settings.quality(), QtMultimedia::HighQuality); QVERIFY(!settings.isNull()); settings = QVideoEncoderSettings(); @@ -526,7 +526,7 @@ void tst_QMediaRecorder::testVideoSettings() QVERIFY(settings.isNull()); QCOMPARE(settings.codec(), QString()); QCOMPARE(settings.bitRate(), -1); - QCOMPARE(settings.quality(), QtMultimediaKit::NormalQuality); + QCOMPARE(settings.quality(), QtMultimedia::NormalQuality); QCOMPARE(settings.frameRate(), qreal()); QCOMPARE(settings.resolution(), QSize()); @@ -539,7 +539,7 @@ void tst_QMediaRecorder::testVideoSettings() QCOMPARE(settings2, settings1); QVERIFY(settings2.isNull()); - settings1.setQuality(QtMultimediaKit::HighQuality); + settings1.setQuality(QtMultimedia::HighQuality); QVERIFY(settings2.isNull()); QVERIFY(!settings1.isNull()); @@ -555,7 +555,7 @@ void tst_QMediaRecorder::testVideoSettings() QCOMPARE(settings2, settings1); QVERIFY(settings2.isNull()); - settings1.setQuality(QtMultimediaKit::HighQuality); + settings1.setQuality(QtMultimedia::HighQuality); QVERIFY(settings2.isNull()); QVERIFY(!settings1.isNull()); @@ -587,19 +587,19 @@ void tst_QMediaRecorder::testVideoSettings() QVERIFY(settings1 != settings2); settings1 = QVideoEncoderSettings(); - settings1.setEncodingMode(QtMultimediaKit::ConstantBitRateEncoding); + settings1.setEncodingMode(QtMultimedia::ConstantBitRateEncoding); settings2 = QVideoEncoderSettings(); - settings2.setEncodingMode(QtMultimediaKit::ConstantBitRateEncoding); + settings2.setEncodingMode(QtMultimedia::ConstantBitRateEncoding); QVERIFY(settings1 == settings2); - settings2.setEncodingMode(QtMultimediaKit::TwoPassEncoding); + settings2.setEncodingMode(QtMultimedia::TwoPassEncoding); QVERIFY(settings1 != settings2); settings1 = QVideoEncoderSettings(); - settings1.setQuality(QtMultimediaKit::NormalQuality); + settings1.setQuality(QtMultimedia::NormalQuality); settings2 = QVideoEncoderSettings(); - settings2.setQuality(QtMultimediaKit::NormalQuality); + settings2.setQuality(QtMultimedia::NormalQuality); QVERIFY(settings1 == settings2); - settings2.setQuality(QtMultimediaKit::LowQuality); + settings2.setQuality(QtMultimedia::LowQuality); QVERIFY(settings1 != settings2); settings1 = QVideoEncoderSettings(); @@ -629,12 +629,12 @@ void tst_QMediaRecorder::nullMetaDataControl() QCOMPARE(recorder.isMetaDataAvailable(), false); QCOMPARE(recorder.isMetaDataWritable(), false); - recorder.setMetaData(QtMultimediaKit::Title, title); + recorder.setMetaData(QtMultimedia::Title, title); recorder.setExtendedMetaData(titleKey, title); - QCOMPARE(recorder.metaData(QtMultimediaKit::Title).toString(), QString()); + QCOMPARE(recorder.metaData(QtMultimedia::Title).toString(), QString()); QCOMPARE(recorder.extendedMetaData(titleKey).toString(), QString()); - QCOMPARE(recorder.availableMetaData(), QList()); + QCOMPARE(recorder.availableMetaData(), QList()); QCOMPARE(recorder.availableExtendedMetaData(), QStringList()); QCOMPARE(spy.count(), 0); } @@ -734,18 +734,18 @@ void tst_QMediaRecorder::metaData() QMediaRecorder recorder(&object); QVERIFY(object.availableMetaData().isEmpty()); - service.mockMetaDataControl->m_data.insert(QtMultimediaKit::AlbumArtist, artist); - service.mockMetaDataControl->m_data.insert(QtMultimediaKit::Title, title); - service.mockMetaDataControl->m_data.insert(QtMultimediaKit::Genre, genre); + service.mockMetaDataControl->m_data.insert(QtMultimedia::AlbumArtist, artist); + service.mockMetaDataControl->m_data.insert(QtMultimedia::Title, title); + service.mockMetaDataControl->m_data.insert(QtMultimedia::Genre, genre); - QCOMPARE(recorder.metaData(QtMultimediaKit::AlbumArtist).toString(), artist); - QCOMPARE(recorder.metaData(QtMultimediaKit::Title).toString(), title); + QCOMPARE(recorder.metaData(QtMultimedia::AlbumArtist).toString(), artist); + QCOMPARE(recorder.metaData(QtMultimedia::Title).toString(), title); - QList metaDataKeys = recorder.availableMetaData(); + QList metaDataKeys = recorder.availableMetaData(); QCOMPARE(metaDataKeys.size(), 3); - QVERIFY(metaDataKeys.contains(QtMultimediaKit::AlbumArtist)); - QVERIFY(metaDataKeys.contains(QtMultimediaKit::Title)); - QVERIFY(metaDataKeys.contains(QtMultimediaKit::Genre)); + QVERIFY(metaDataKeys.contains(QtMultimedia::AlbumArtist)); + QVERIFY(metaDataKeys.contains(QtMultimedia::Title)); + QVERIFY(metaDataKeys.contains(QtMultimedia::Genre)); } void tst_QMediaRecorder::setMetaData_data() @@ -768,9 +768,9 @@ void tst_QMediaRecorder::setMetaData() QMediaRecorder recorder(&object); - recorder.setMetaData(QtMultimediaKit::Title, title); - QCOMPARE(recorder.metaData(QtMultimediaKit::Title).toString(), title); - QCOMPARE(service.mockMetaDataControl->m_data.value(QtMultimediaKit::Title).toString(), title); + recorder.setMetaData(QtMultimedia::Title, title); + QCOMPARE(recorder.metaData(QtMultimedia::Title).toString(), title); + QCOMPARE(service.mockMetaDataControl->m_data.value(QtMultimedia::Title).toString(), title); } void tst_QMediaRecorder::extendedMetaData() @@ -828,8 +828,8 @@ void tst_QMediaRecorder::testAudioSettingsCopyConstructor() audiosettings.setBitRate(128*1000); audiosettings.setChannelCount(4); audiosettings.setCodec("audio/pcm"); - audiosettings.setEncodingMode(QtMultimediaKit::ConstantBitRateEncoding); - audiosettings.setQuality(QtMultimediaKit::LowQuality); + audiosettings.setEncodingMode(QtMultimedia::ConstantBitRateEncoding); + audiosettings.setQuality(QtMultimedia::LowQuality); audiosettings.setSampleRate(44100); /* Copy constructor */ @@ -858,16 +858,16 @@ void tst_QMediaRecorder::testAudioSettingsOperatorNotEqual() audiosettings1.setBitRate(128*1000); audiosettings1.setChannelCount(4); audiosettings1.setCodec("audio/pcm"); - audiosettings1.setEncodingMode(QtMultimediaKit::ConstantBitRateEncoding); - audiosettings1.setQuality(QtMultimediaKit::LowQuality); + audiosettings1.setEncodingMode(QtMultimedia::ConstantBitRateEncoding); + audiosettings1.setQuality(QtMultimedia::LowQuality); audiosettings1.setSampleRate(44100); /* setting the desired properties for the AudioEncoder */ audiosettings2.setBitRate(128*1000); audiosettings2.setChannelCount(4); audiosettings2.setCodec("audio/pcm"); - audiosettings2.setEncodingMode(QtMultimediaKit::ConstantBitRateEncoding); - audiosettings2.setQuality(QtMultimediaKit::LowQuality); + audiosettings2.setEncodingMode(QtMultimedia::ConstantBitRateEncoding); + audiosettings2.setQuality(QtMultimedia::LowQuality); audiosettings2.setSampleRate(44100); /* verify the both are equal or not */ @@ -875,7 +875,7 @@ void tst_QMediaRecorder::testAudioSettingsOperatorNotEqual() /* Modify the settings value for one object */ audiosettings2.setBitRate(64*1000); - audiosettings2.setEncodingMode(QtMultimediaKit::ConstantQualityEncoding); + audiosettings2.setEncodingMode(QtMultimedia::ConstantQualityEncoding); /* verify the not equal opertor */ QVERIFY(audiosettings1 != audiosettings2); @@ -894,8 +894,8 @@ void tst_QMediaRecorder::testAudioSettingsOperatorEqual() audiosettings1.setBitRate(128*1000); audiosettings1.setChannelCount(4); audiosettings1.setCodec("audio/pcm"); - audiosettings1.setEncodingMode(QtMultimediaKit::ConstantBitRateEncoding); - audiosettings1.setQuality(QtMultimediaKit::LowQuality); + audiosettings1.setEncodingMode(QtMultimedia::ConstantBitRateEncoding); + audiosettings1.setQuality(QtMultimedia::LowQuality); audiosettings1.setSampleRate(44100); QAudioEncoderSettings audiosettings2; @@ -905,8 +905,8 @@ void tst_QMediaRecorder::testAudioSettingsOperatorEqual() audiosettings2.setBitRate(128*1000); audiosettings2.setChannelCount(4); audiosettings2.setCodec("audio/pcm"); - audiosettings2.setEncodingMode(QtMultimediaKit::ConstantBitRateEncoding); - audiosettings2.setQuality(QtMultimediaKit::LowQuality); + audiosettings2.setEncodingMode(QtMultimedia::ConstantBitRateEncoding); + audiosettings2.setQuality(QtMultimedia::LowQuality); audiosettings2.setSampleRate(44100); /* verify both the values are same or not */ @@ -926,8 +926,8 @@ void tst_QMediaRecorder::testAudioSettingsOperatorAssign() audiosettings1.setBitRate(128*1000); audiosettings1.setChannelCount(4); audiosettings1.setCodec("audio/pcm"); - audiosettings1.setEncodingMode(QtMultimediaKit::ConstantBitRateEncoding); - audiosettings1.setQuality(QtMultimediaKit::LowQuality); + audiosettings1.setEncodingMode(QtMultimedia::ConstantBitRateEncoding); + audiosettings1.setQuality(QtMultimedia::LowQuality); audiosettings1.setSampleRate(44100); QAudioEncoderSettings audiosettings2; @@ -958,14 +958,14 @@ void tst_QMediaRecorder::testAvailabilityError() MockMediaRecorderService service(0, 0); MockMediaObject object(0, &service); QMediaRecorder recorder(&object); - QCOMPARE(recorder.availabilityError(), QtMultimediaKit::ServiceMissingError); + QCOMPARE(recorder.availabilityError(), QtMultimedia::ServiceMissingError); MockMediaRecorderControl recorderControl(0); MockMediaRecorderService service1(0, &recorderControl); service1.mockMetaDataControl->populateMetaData(); MockMediaObject object1(0, &service1); QMediaRecorder recorder1(&object1); - QCOMPARE(recorder1.availabilityError(), QtMultimediaKit::NoError); + QCOMPARE(recorder1.availabilityError(), QtMultimedia::NoError); } /* isAvailable() API test. */ @@ -1026,21 +1026,21 @@ void tst_QMediaRecorder::testVideoSettingsQuality() QVERIFY(settings == QVideoEncoderSettings()); /* Verify the default value is intialised correctly*/ - QCOMPARE(settings.quality(), QtMultimediaKit::NormalQuality); + QCOMPARE(settings.quality(), QtMultimedia::NormalQuality); /* Set all types of Quality parameter and Verify if it is set correctly*/ - settings.setQuality(QtMultimediaKit::HighQuality); - QCOMPARE(settings.quality(), QtMultimediaKit::HighQuality); + settings.setQuality(QtMultimedia::HighQuality); + QCOMPARE(settings.quality(), QtMultimedia::HighQuality); QVERIFY(!settings.isNull()); - settings.setQuality(QtMultimediaKit::VeryLowQuality); - QCOMPARE(settings.quality(), QtMultimediaKit::VeryLowQuality); + settings.setQuality(QtMultimedia::VeryLowQuality); + QCOMPARE(settings.quality(), QtMultimedia::VeryLowQuality); - settings.setQuality(QtMultimediaKit::LowQuality); - QCOMPARE(settings.quality(), QtMultimediaKit::LowQuality); + settings.setQuality(QtMultimedia::LowQuality); + QCOMPARE(settings.quality(), QtMultimedia::LowQuality); - settings.setQuality(QtMultimediaKit::VeryHighQuality); - QCOMPARE(settings.quality(), QtMultimediaKit::VeryHighQuality); + settings.setQuality(QtMultimedia::VeryHighQuality); + QCOMPARE(settings.quality(), QtMultimedia::VeryHighQuality); } /* Test QVideoEncoderSettings encodingMode */ @@ -1052,19 +1052,19 @@ void tst_QMediaRecorder::testVideoSettingsEncodingMode() QVERIFY(settings == QVideoEncoderSettings()); /* Verify the default values are initialised correctly*/ - QCOMPARE(settings.encodingMode(), QtMultimediaKit::ConstantQualityEncoding); + QCOMPARE(settings.encodingMode(), QtMultimedia::ConstantQualityEncoding); QVERIFY(settings.isNull()); /* Set each type of encoding mode and Verify if it is set correctly*/ - settings.setEncodingMode(QtMultimediaKit::ConstantBitRateEncoding); - QCOMPARE(settings.encodingMode(),QtMultimediaKit::ConstantBitRateEncoding); + settings.setEncodingMode(QtMultimedia::ConstantBitRateEncoding); + QCOMPARE(settings.encodingMode(),QtMultimedia::ConstantBitRateEncoding); QVERIFY(!settings.isNull()); - settings.setEncodingMode(QtMultimediaKit::AverageBitRateEncoding); - QCOMPARE(settings.encodingMode(), QtMultimediaKit::AverageBitRateEncoding); + settings.setEncodingMode(QtMultimedia::AverageBitRateEncoding); + QCOMPARE(settings.encodingMode(), QtMultimedia::AverageBitRateEncoding); - settings.setEncodingMode(QtMultimediaKit::TwoPassEncoding); - QCOMPARE(settings.encodingMode(), QtMultimediaKit::TwoPassEncoding); + settings.setEncodingMode(QtMultimedia::TwoPassEncoding); + QCOMPARE(settings.encodingMode(), QtMultimedia::TwoPassEncoding); } /* Test QVideoEncoderSettings copy constructor */ @@ -1074,8 +1074,8 @@ void tst_QMediaRecorder::testVideoSettingsCopyConstructor() QVideoEncoderSettings settings1; settings1.setCodec(QLatin1String("codecName")); settings1.setBitRate(128000); - settings1.setQuality(QtMultimediaKit::HighQuality); - settings1.setEncodingMode(QtMultimediaKit::ConstantBitRateEncoding); + settings1.setQuality(QtMultimedia::HighQuality); + settings1.setEncodingMode(QtMultimedia::ConstantBitRateEncoding); settings1.setFrameRate(30000.0/10001); settings1.setResolution(QSize(320,240)); @@ -1086,10 +1086,10 @@ void tst_QMediaRecorder::testVideoSettingsCopyConstructor() QCOMPARE(settings2 != settings1, false); QCOMPARE(settings2.codec(), QLatin1String("codecName")); QCOMPARE(settings2.bitRate(), 128000); - QCOMPARE(settings2.encodingMode(), QtMultimediaKit::ConstantBitRateEncoding); + QCOMPARE(settings2.encodingMode(), QtMultimedia::ConstantBitRateEncoding); QVERIFY(qFuzzyCompare(settings2.frameRate(), qreal(30000.0/10001))); QCOMPARE(settings2.resolution(), QSize(320,240)); - QCOMPARE(settings2.quality(), QtMultimediaKit::HighQuality); + QCOMPARE(settings2.quality(), QtMultimedia::HighQuality); /* Verify both the instances are equal*/ QCOMPARE(settings2, settings1); @@ -1108,10 +1108,10 @@ void tst_QMediaRecorder::testVideoSettingsOperatorAssignment() /* Initialize all the parameters */ settings1.setCodec(QLatin1String("codecName")); settings1.setBitRate(128000); - settings1.setEncodingMode(QtMultimediaKit::ConstantBitRateEncoding); + settings1.setEncodingMode(QtMultimedia::ConstantBitRateEncoding); settings1.setFrameRate(30000.0/10001); settings1.setResolution(QSize(320,240)); - settings1.setQuality(QtMultimediaKit::HighQuality); + settings1.setQuality(QtMultimedia::HighQuality); /* Assign one object to other*/ settings2 = settings1; @@ -1119,10 +1119,10 @@ void tst_QMediaRecorder::testVideoSettingsOperatorAssignment() QCOMPARE(settings2, settings1); QCOMPARE(settings2.codec(), QLatin1String("codecName")); QCOMPARE(settings2.bitRate(), 128000); - QCOMPARE(settings2.encodingMode(), QtMultimediaKit::ConstantBitRateEncoding); + QCOMPARE(settings2.encodingMode(), QtMultimedia::ConstantBitRateEncoding); QVERIFY(qFuzzyCompare(settings2.frameRate(), qreal(30000.0/10001))); QCOMPARE(settings2.resolution(), QSize(320,240)); - QCOMPARE(settings2.quality(), QtMultimediaKit::HighQuality); + QCOMPARE(settings2.quality(), QtMultimedia::HighQuality); QCOMPARE(settings2, settings1); QVERIFY(!settings2.isNull()); } @@ -1165,23 +1165,23 @@ void tst_QMediaRecorder::testVideoSettingsOperatorNotEqual() /* Verify EncodingMode with not equal operator*/ settings1 = QVideoEncoderSettings(); - settings1.setEncodingMode(QtMultimediaKit::ConstantBitRateEncoding); + settings1.setEncodingMode(QtMultimedia::ConstantBitRateEncoding); settings2 = QVideoEncoderSettings(); - settings2.setEncodingMode(QtMultimediaKit::ConstantBitRateEncoding); + settings2.setEncodingMode(QtMultimedia::ConstantBitRateEncoding); /* OperatorNotEqual returns false when both objects are equal*/ QCOMPARE(settings1 != settings2, false); - settings2.setEncodingMode(QtMultimediaKit::TwoPassEncoding); + settings2.setEncodingMode(QtMultimedia::TwoPassEncoding); /* OperatorNotEqual returns true when both objects are not equal*/ QVERIFY(settings1 != settings2); /* Verify Quality with not equal operator*/ settings1 = QVideoEncoderSettings(); - settings1.setQuality(QtMultimediaKit::NormalQuality); + settings1.setQuality(QtMultimedia::NormalQuality); settings2 = QVideoEncoderSettings(); - settings2.setQuality(QtMultimediaKit::NormalQuality); + settings2.setQuality(QtMultimedia::NormalQuality); /* OperatorNotEqual returns false when both objects are equal*/ QCOMPARE(settings1 != settings2, false); - settings2.setQuality(QtMultimediaKit::LowQuality); + settings2.setQuality(QtMultimedia::LowQuality); /* OperatorNotEqual returns true when both objects are not equal*/ QVERIFY(settings1 != settings2); @@ -1236,23 +1236,23 @@ void tst_QMediaRecorder::testVideoSettingsOperatorComparison() /* Verify EncodingMode with comparison operator*/ settings1 = QVideoEncoderSettings(); - settings1.setEncodingMode(QtMultimediaKit::ConstantBitRateEncoding); + settings1.setEncodingMode(QtMultimedia::ConstantBitRateEncoding); settings2 = QVideoEncoderSettings(); - settings2.setEncodingMode(QtMultimediaKit::ConstantBitRateEncoding); + settings2.setEncodingMode(QtMultimedia::ConstantBitRateEncoding); /* Comparison operator returns true when both objects are equal*/ QVERIFY(settings1 == settings2); - settings2.setEncodingMode(QtMultimediaKit::TwoPassEncoding); + settings2.setEncodingMode(QtMultimedia::TwoPassEncoding); /* Comparison operator returns false when both objects are not equal*/ QCOMPARE(settings1 == settings2, false); /* Verify Quality with comparison operator*/ settings1 = QVideoEncoderSettings(); - settings1.setQuality(QtMultimediaKit::NormalQuality); + settings1.setQuality(QtMultimedia::NormalQuality); settings2 = QVideoEncoderSettings(); - settings2.setQuality(QtMultimediaKit::NormalQuality); + settings2.setQuality(QtMultimedia::NormalQuality); /* Comparison operator returns true when both objects are equal*/ QVERIFY(settings1 == settings2); - settings2.setQuality(QtMultimediaKit::LowQuality); + settings2.setQuality(QtMultimedia::LowQuality); /* Comparison operator returns false when both objects are not equal*/ QCOMPARE(settings1 == settings2, false); diff --git a/tests/auto/qmediaresource/qmediaresource.pro b/tests/auto/qmediaresource/qmediaresource.pro index e003c7a1e..4d8cf5e1b 100644 --- a/tests/auto/qmediaresource/qmediaresource.pro +++ b/tests/auto/qmediaresource/qmediaresource.pro @@ -1,6 +1,6 @@ load(qttest_p4) -QT += network multimediakit-private +QT += network multimedia-private CONFIG += no_private_qt_headers_warning SOURCES += tst_qmediaresource.cpp diff --git a/tests/auto/qmediaservice/qmediaservice.pro b/tests/auto/qmediaservice/qmediaservice.pro index 4d48c4887..7fc2305d5 100644 --- a/tests/auto/qmediaservice/qmediaservice.pro +++ b/tests/auto/qmediaservice/qmediaservice.pro @@ -1,6 +1,6 @@ load(qttest_p4) -QT += multimediakit-private +QT += multimedia-private CONFIG += no_private_qt_headers_warning SOURCES += tst_qmediaservice.cpp diff --git a/tests/auto/qmediaserviceprovider/qmediaserviceprovider.pro b/tests/auto/qmediaserviceprovider/qmediaserviceprovider.pro index f51f84958..f0b00a1dd 100644 --- a/tests/auto/qmediaserviceprovider/qmediaserviceprovider.pro +++ b/tests/auto/qmediaserviceprovider/qmediaserviceprovider.pro @@ -1,6 +1,6 @@ load(qttest_p4) -QT += multimediakit-private +QT += multimedia-private CONFIG += no_private_qt_headers_warning SOURCES += tst_qmediaserviceprovider.cpp diff --git a/tests/auto/qmediaserviceprovider/tst_qmediaserviceprovider.cpp b/tests/auto/qmediaserviceprovider/tst_qmediaserviceprovider.cpp index f6b3ad1cd..c70401f7d 100644 --- a/tests/auto/qmediaserviceprovider/tst_qmediaserviceprovider.cpp +++ b/tests/auto/qmediaserviceprovider/tst_qmediaserviceprovider.cpp @@ -93,16 +93,16 @@ public: delete service; } - QtMultimediaKit::SupportEstimate hasSupport(const QString &mimeType, const QStringList& codecs) const + QtMultimedia::SupportEstimate hasSupport(const QString &mimeType, const QStringList& codecs) const { if (codecs.contains(QLatin1String("mpeg4"))) - return QtMultimediaKit::NotSupported; + return QtMultimedia::NotSupported; if (mimeType == "audio/ogg") { - return QtMultimediaKit::ProbablySupported; + return QtMultimedia::ProbablySupported; } - return QtMultimediaKit::MaybeSupported; + return QtMultimedia::MaybeSupported; } QStringList supportedMimeTypes() const @@ -152,14 +152,14 @@ public: delete service; } - QtMultimediaKit::SupportEstimate hasSupport(const QString &mimeType, const QStringList& codecs) const + QtMultimedia::SupportEstimate hasSupport(const QString &mimeType, const QStringList& codecs) const { Q_UNUSED(codecs); if (mimeType == "audio/wav") - return QtMultimediaKit::PreferredService; + return QtMultimedia::PreferredService; - return QtMultimediaKit::NotSupported; + return QtMultimedia::NotSupported; } QStringList supportedMimeTypes() const @@ -247,15 +247,15 @@ public: delete service; } - QtMultimediaKit::SupportEstimate hasSupport(const QString &mimeType, const QStringList& codecs) const + QtMultimedia::SupportEstimate hasSupport(const QString &mimeType, const QStringList& codecs) const { if (codecs.contains(QLatin1String("jpeg2000"))) - return QtMultimediaKit::NotSupported; + return QtMultimedia::NotSupported; if (supportedMimeTypes().contains(mimeType)) - return QtMultimediaKit::ProbablySupported; + return QtMultimedia::ProbablySupported; - return QtMultimediaKit::MaybeSupported; + return QtMultimedia::MaybeSupported; } QStringList supportedMimeTypes() const @@ -342,7 +342,7 @@ void tst_QMediaServiceProvider::testHasSupport() { MockMediaServiceProvider mockProvider; QCOMPARE(mockProvider.hasSupport(QByteArray(Q_MEDIASERVICE_MEDIAPLAYER), "video/ogv", QStringList()), - QtMultimediaKit::MaybeSupported); + QtMultimedia::MaybeSupported); QMediaServiceProvider *provider = QMediaServiceProvider::defaultServiceProvider(); @@ -350,44 +350,44 @@ void tst_QMediaServiceProvider::testHasSupport() QSKIP("No default provider", SkipSingle); QCOMPARE(provider->hasSupport(QByteArray(Q_MEDIASERVICE_MEDIAPLAYER), "video/ogv", QStringList()), - QtMultimediaKit::MaybeSupported); + QtMultimedia::MaybeSupported); QCOMPARE(provider->hasSupport(QByteArray(Q_MEDIASERVICE_MEDIAPLAYER), "audio/ogg", QStringList()), - QtMultimediaKit::ProbablySupported); + QtMultimedia::ProbablySupported); //while the service returns PreferredService, provider should return ProbablySupported QCOMPARE(provider->hasSupport(QByteArray(Q_MEDIASERVICE_MEDIAPLAYER), "audio/wav", QStringList()), - QtMultimediaKit::ProbablySupported); + QtMultimedia::ProbablySupported); //even while all the plugins with "hasSupport" returned NotSupported, //MockServicePlugin3 has no "hasSupport" interface, so MaybeSupported QCOMPARE(provider->hasSupport(QByteArray(Q_MEDIASERVICE_MEDIAPLAYER), "video/avi", QStringList() << "mpeg4"), - QtMultimediaKit::MaybeSupported); + QtMultimedia::MaybeSupported); QCOMPARE(provider->hasSupport(QByteArray("non existing service"), "video/ogv", QStringList()), - QtMultimediaKit::NotSupported); + QtMultimedia::NotSupported); - QCOMPARE(QMediaPlayer::hasSupport("video/ogv"), QtMultimediaKit::MaybeSupported); - QCOMPARE(QMediaPlayer::hasSupport("audio/ogg"), QtMultimediaKit::ProbablySupported); - QCOMPARE(QMediaPlayer::hasSupport("audio/wav"), QtMultimediaKit::ProbablySupported); + QCOMPARE(QMediaPlayer::hasSupport("video/ogv"), QtMultimedia::MaybeSupported); + QCOMPARE(QMediaPlayer::hasSupport("audio/ogg"), QtMultimedia::ProbablySupported); + QCOMPARE(QMediaPlayer::hasSupport("audio/wav"), QtMultimedia::ProbablySupported); //test low latency flag support QCOMPARE(QMediaPlayer::hasSupport("audio/wav", QStringList(), QMediaPlayer::LowLatency), - QtMultimediaKit::ProbablySupported); + QtMultimedia::ProbablySupported); //plugin1 probably supports audio/ogg, it checked because it doesn't provide features iface QCOMPARE(QMediaPlayer::hasSupport("audio/ogg", QStringList(), QMediaPlayer::LowLatency), - QtMultimediaKit::ProbablySupported); + QtMultimedia::ProbablySupported); //Plugin4 is not checked here, sine it's known not support low latency QCOMPARE(QMediaPlayer::hasSupport("video/quicktime", QStringList(), QMediaPlayer::LowLatency), - QtMultimediaKit::MaybeSupported); + QtMultimedia::MaybeSupported); //test streaming flag support QCOMPARE(QMediaPlayer::hasSupport("video/quicktime", QStringList(), QMediaPlayer::StreamPlayback), - QtMultimediaKit::ProbablySupported); + QtMultimedia::ProbablySupported); //Plugin2 is not checked here, sine it's known not support streaming QCOMPARE(QMediaPlayer::hasSupport("audio/wav", QStringList(), QMediaPlayer::StreamPlayback), - QtMultimediaKit::MaybeSupported); + QtMultimedia::MaybeSupported); //ensure the correct media player plugin is chosen for mime type QMediaPlayer simplePlayer(0, QMediaPlayer::LowLatency); diff --git a/tests/auto/qmediastreamscontrol/qmediastreamscontrol.pro b/tests/auto/qmediastreamscontrol/qmediastreamscontrol.pro index 3ee331104..ddbd37fed 100644 --- a/tests/auto/qmediastreamscontrol/qmediastreamscontrol.pro +++ b/tests/auto/qmediastreamscontrol/qmediastreamscontrol.pro @@ -1,6 +1,6 @@ load(qttest_p4) -QT += multimediakit-private +QT += multimedia-private CONFIG += no_private_qt_headers_warning SOURCES += \ diff --git a/tests/auto/qmediastreamscontrol/tst_qmediastreamscontrol.cpp b/tests/auto/qmediastreamscontrol/tst_qmediastreamscontrol.cpp index 433ee1238..d72869185 100644 --- a/tests/auto/qmediastreamscontrol/tst_qmediastreamscontrol.cpp +++ b/tests/auto/qmediastreamscontrol/tst_qmediastreamscontrol.cpp @@ -126,13 +126,13 @@ public: streams[index].type = type; } - QVariant metaData(int index, QtMultimediaKit::MetaData key) + QVariant metaData(int index, QtMultimedia::MetaData key) { - QtMultimediaKit::MetaData keys = key; + QtMultimedia::MetaData keys = key; return keys; } - void setMetaData(int index, QtMultimediaKit::MetaData key, const QVariant &value) + void setMetaData(int index, QtMultimedia::MetaData key, const QVariant &value) { streams[index].metaData.insert(key, value); } @@ -191,7 +191,7 @@ public: { Stream() : type(UnknownStream), active(false) {} StreamType type; - QMap metaData; + QMap metaData; bool active; }; @@ -400,8 +400,8 @@ void tst_qmediastreamscontrol::streamsChanged() void tst_qmediastreamscontrol::metadata() { QtTestMediaStreamsControl m_metadata; - m_metadata.metaData(1,QtMultimediaKit::AlbumArtist); - qDebug() << m_metadata.metaData(1,QtMultimediaKit::AlbumArtist); + m_metadata.metaData(1,QtMultimedia::AlbumArtist); + qDebug() << m_metadata.metaData(1,QtMultimedia::AlbumArtist); } QTEST_MAIN(tst_qmediastreamscontrol); diff --git a/tests/auto/qmediatimerange/qmediatimerange.pro b/tests/auto/qmediatimerange/qmediatimerange.pro index 25f709fae..a8a36d7ec 100644 --- a/tests/auto/qmediatimerange/qmediatimerange.pro +++ b/tests/auto/qmediatimerange/qmediatimerange.pro @@ -1,6 +1,6 @@ load(qttest_p4) -QT += multimediakit-private +QT += multimedia-private CONFIG += no_private_qt_headers_warning SOURCES += tst_qmediatimerange.cpp diff --git a/tests/auto/qmetadatareadercontrol/qmetadatareadercontrol.pro b/tests/auto/qmetadatareadercontrol/qmetadatareadercontrol.pro index 675f5b0b2..7cf024771 100644 --- a/tests/auto/qmetadatareadercontrol/qmetadatareadercontrol.pro +++ b/tests/auto/qmetadatareadercontrol/qmetadatareadercontrol.pro @@ -1,6 +1,6 @@ load(qttest_p4) -QT += multimediakit-private +QT += multimedia-private CONFIG += no_private_qt_headers_warning SOURCES += tst_qmetadatareadercontrol.cpp diff --git a/tests/auto/qmetadatareadercontrol/tst_qmetadatareadercontrol.cpp b/tests/auto/qmetadatareadercontrol/tst_qmetadatareadercontrol.cpp index d9de33e16..30df40418 100644 --- a/tests/auto/qmetadatareadercontrol/tst_qmetadatareadercontrol.cpp +++ b/tests/auto/qmetadatareadercontrol/tst_qmetadatareadercontrol.cpp @@ -103,7 +103,7 @@ void tst_QMetaDataReaderControl::metaDataReaderControlMetaData () { MockMetaDataReaderControl *metaData = new MockMetaDataReaderControl(); QVERIFY(metaData !=NULL); - metaData->metaData(QtMultimediaKit::Title); + metaData->metaData(QtMultimedia::Title); delete metaData; } diff --git a/tests/auto/qmetadatawritercontrol/qmetadatawritercontrol.pro b/tests/auto/qmetadatawritercontrol/qmetadatawritercontrol.pro index b6da11344..e172d7660 100644 --- a/tests/auto/qmetadatawritercontrol/qmetadatawritercontrol.pro +++ b/tests/auto/qmetadatawritercontrol/qmetadatawritercontrol.pro @@ -1,6 +1,6 @@ load(qttest_p4) -QT += multimediakit-private +QT += multimedia-private CONFIG += no_private_qt_headers_warning SOURCES += tst_qmetadatawritercontrol.cpp diff --git a/tests/auto/qmetadatawritercontrol/tst_qmetadatawritercontrol.cpp b/tests/auto/qmetadatawritercontrol/tst_qmetadatawritercontrol.cpp index 8ce1f27b1..68d428151 100644 --- a/tests/auto/qmetadatawritercontrol/tst_qmetadatawritercontrol.cpp +++ b/tests/auto/qmetadatawritercontrol/tst_qmetadatawritercontrol.cpp @@ -75,10 +75,10 @@ void tst_QMetaDataWriterControl::constructor() mock->availableMetaData(); mock->isMetaDataAvailable(); mock->isWritable(); - mock->metaData((QtMultimediaKit::MetaData) 1 ); + mock->metaData((QtMultimedia::MetaData) 1 ); mock->extendedMetaData(QString("XYZ")); mock->setExtendedMetaData(QString("XYZ"),QVariant()); - mock->setMetaData((QtMultimediaKit::MetaData) 1,QVariant()); + mock->setMetaData((QtMultimedia::MetaData) 1,QVariant()); ((MockMetaDataWriterControl*)mock)->setWritable(); ((MockMetaDataWriterControl*)mock)->setMetaDataAvailable(); delete mock; diff --git a/tests/auto/qmultimedia_common/mockcameraimagecapturecontrol.h b/tests/auto/qmultimedia_common/mockcameraimagecapturecontrol.h index 78681be80..5fb3cb19d 100644 --- a/tests/auto/qmultimedia_common/mockcameraimagecapturecontrol.h +++ b/tests/auto/qmultimedia_common/mockcameraimagecapturecontrol.h @@ -95,11 +95,11 @@ private Q_SLOTS: emit imageCaptured(m_captureRequest, QImage()); emit imageMetadataAvailable(m_captureRequest, - QtMultimediaKit::FocalLengthIn35mmFilm, + QtMultimedia::FocalLengthIn35mmFilm, QVariant(50)); emit imageMetadataAvailable(m_captureRequest, - QtMultimediaKit::DateTimeOriginal, + QtMultimedia::DateTimeOriginal, QVariant(QDateTime::currentDateTime())); emit imageMetadataAvailable(m_captureRequest, diff --git a/tests/auto/qmultimedia_common/mockcameraservice.h b/tests/auto/qmultimedia_common/mockcameraservice.h index c51f75f5e..ea0620a13 100644 --- a/tests/auto/qmultimedia_common/mockcameraservice.h +++ b/tests/auto/qmultimedia_common/mockcameraservice.h @@ -56,7 +56,7 @@ #include "../qmultimedia_common/mockvideosurface.h" #include "../qmultimedia_common/mockvideorenderercontrol.h" -#if defined(QT_MULTIMEDIAKIT_MOCK_WIDGETS) +#if defined(QT_MULTIMEDIA_MOCK_WIDGETS) #include "../qmultimedia_common/mockvideowindowcontrol.h" #endif @@ -105,7 +105,7 @@ public: mockImageProcessingControl = new MockImageProcessingControl(this); mockImageEncoderControl = new MockImageEncoderControl(this); rendererControl = new MockVideoRendererControl(this); -#if defined(QT_MULTIMEDIAKIT_MOCK_WIDGETS) +#if defined(QT_MULTIMEDIA_MOCK_WIDGETS) windowControl = new MockVideoWindowControl(this); #endif rendererRef = 0; @@ -154,7 +154,7 @@ public: return rendererControl; } } -#if defined(QT_MULTIMEDIAKIT_MOCK_WIDGETS) +#if defined(QT_MULTIMEDIA_MOCK_WIDGETS) if (qstrcmp(iid, QVideoWindowControl_iid) == 0) { if (windowRef == 0) { windowRef += 1; @@ -169,7 +169,7 @@ public: { if (control == rendererControl) rendererRef -= 1; -#if defined(QT_MULTIMEDIAKIT_MOCK_WIDGETS) +#if defined(QT_MULTIMEDIA_MOCK_WIDGETS) if (control == windowControl) windowRef -= 1; #endif @@ -186,7 +186,7 @@ public: MockImageProcessingControl *mockImageProcessingControl; MockImageEncoderControl *mockImageEncoderControl; MockVideoRendererControl *rendererControl; -#if defined(QT_MULTIMEDIAKIT_MOCK_WIDGETS) +#if defined(QT_MULTIMEDIA_MOCK_WIDGETS) MockVideoWindowControl *windowControl; #endif int rendererRef; diff --git a/tests/auto/qmultimedia_common/mockimageencodercontrol.h b/tests/auto/qmultimedia_common/mockimageencodercontrol.h index 0e9d7f38f..c63ecd617 100644 --- a/tests/auto/qmultimedia_common/mockimageencodercontrol.h +++ b/tests/auto/qmultimedia_common/mockimageencodercontrol.h @@ -65,12 +65,12 @@ public: settings.resolution() == QSize(320,240)) resolutions << settings.resolution(); - if (settings.quality() == QtMultimediaKit::HighQuality && settings.resolution() == QSize(640,480)) + if (settings.quality() == QtMultimedia::HighQuality && settings.resolution() == QSize(640,480)) resolutions << settings.resolution(); } else { resolutions << QSize(160, 120); resolutions << QSize(320, 240); - if (settings.quality() == QtMultimediaKit::HighQuality) + if (settings.quality() == QtMultimedia::HighQuality) resolutions << QSize(640, 480); } diff --git a/tests/auto/qmultimedia_common/mockmediaplayerservice.h b/tests/auto/qmultimedia_common/mockmediaplayerservice.h index 57697225c..fb0f1b28d 100644 --- a/tests/auto/qmultimedia_common/mockmediaplayerservice.h +++ b/tests/auto/qmultimedia_common/mockmediaplayerservice.h @@ -48,7 +48,7 @@ #include "mockmediastreamscontrol.h" #include "mockmedianetworkaccesscontrol.h" #include "mockvideorenderercontrol.h" -#if defined(QT_MULTIMEDIAKIT_MOCK_WIDGETS) +#if defined(QT_MULTIMEDIA_MOCK_WIDGETS) #include "mockvideowindowcontrol.h" #endif @@ -64,7 +64,7 @@ public: mockNetworkControl = new MockNetworkAccessControl; rendererControl = new MockVideoRendererControl; rendererRef = 0; -#if defined(QT_MULTIMEDIAKIT_MOCK_WIDGETS) +#if defined(QT_MULTIMEDIA_MOCK_WIDGETS) windowControl = new MockVideoWindowControl; windowRef = 0; #endif @@ -76,7 +76,7 @@ public: delete mockStreamsControl; delete mockNetworkControl; delete rendererControl; -#if defined(QT_MULTIMEDIAKIT_MOCK_WIDGETS) +#if defined(QT_MULTIMEDIA_MOCK_WIDGETS) delete windowControl; #endif } @@ -91,7 +91,7 @@ public: return rendererControl; } } -#if defined(QT_MULTIMEDIAKIT_MOCK_WIDGETS) +#if defined(QT_MULTIMEDIA_MOCK_WIDGETS) if (qstrcmp(iid, QVideoWindowControl_iid) == 0) { if (windowRef == 0) { windowRef += 1; @@ -109,7 +109,7 @@ public: { if (control == rendererControl) rendererRef -= 1; -#if defined(QT_MULTIMEDIAKIT_MOCK_WIDGETS) +#if defined(QT_MULTIMEDIA_MOCK_WIDGETS) if (control == windowControl) windowRef -= 1; #endif @@ -164,7 +164,7 @@ public: MockStreamsControl *mockStreamsControl; MockNetworkAccessControl *mockNetworkControl; MockVideoRendererControl *rendererControl; -#if defined(QT_MULTIMEDIAKIT_MOCK_WIDGETS) +#if defined(QT_MULTIMEDIA_MOCK_WIDGETS) MockVideoWindowControl *windowControl; int windowRef; #endif diff --git a/tests/auto/qmultimedia_common/mockmediastreamscontrol.h b/tests/auto/qmultimedia_common/mockmediastreamscontrol.h index 902f4fc12..d1d967df6 100644 --- a/tests/auto/qmultimedia_common/mockmediastreamscontrol.h +++ b/tests/auto/qmultimedia_common/mockmediastreamscontrol.h @@ -55,9 +55,9 @@ public: StreamType streamType(int index) { return _streams.at(index).type; } void setStreamType(int index, StreamType type) { _streams[index].type = type; } - QVariant metaData(int index, QtMultimediaKit::MetaData key) { + QVariant metaData(int index, QtMultimedia::MetaData key) { return _streams.at(index).metaData.value(key); } - void setMetaData(int index, QtMultimediaKit::MetaData key, const QVariant &value) { + void setMetaData(int index, QtMultimedia::MetaData key, const QVariant &value) { _streams[index].metaData.insert(key, value); } bool isActive(int index) { return _streams.at(index).active; } @@ -68,7 +68,7 @@ private: { Stream() : type(UnknownStream), active(false) {} StreamType type; - QMap metaData; + QMap metaData; bool active; }; diff --git a/tests/auto/qmultimedia_common/mockmetadatareadercontrol.h b/tests/auto/qmultimedia_common/mockmetadatareadercontrol.h index 6aa08778b..f0847622f 100644 --- a/tests/auto/qmultimedia_common/mockmetadatareadercontrol.h +++ b/tests/auto/qmultimedia_common/mockmetadatareadercontrol.h @@ -63,12 +63,12 @@ public: if (m_available != available) emit metaDataAvailableChanged(m_available = available); } - QList availableMetaData() const + QList availableMetaData() const { return m_data.keys(); } - QVariant metaData(QtMultimediaKit::MetaData key) const + QVariant metaData(QtMultimedia::MetaData key) const { return m_data.value(key); } @@ -91,7 +91,7 @@ public: } bool m_available; - QMap m_data; + QMap m_data; QMap m_extendedData; }; diff --git a/tests/auto/qmultimedia_common/mockmetadatawritercontrol.h b/tests/auto/qmultimedia_common/mockmetadatawritercontrol.h index dcd9a8e55..e9f7c7573 100644 --- a/tests/auto/qmultimedia_common/mockmetadatawritercontrol.h +++ b/tests/auto/qmultimedia_common/mockmetadatawritercontrol.h @@ -64,13 +64,13 @@ public: if (m_available != available) emit metaDataAvailableChanged(m_available = available); } - QList availableMetaData() const { return m_data.keys(); } + QList availableMetaData() const { return m_data.keys(); } bool isWritable() const { return m_writable; } void setWritable(bool writable) { emit writableChanged(m_writable = writable); } - QVariant metaData(QtMultimediaKit::MetaData key) const { return m_data.value(key); }//Getting the metadata from Multimediakit - void setMetaData(QtMultimediaKit::MetaData key, const QVariant &value) + QVariant metaData(QtMultimedia::MetaData key) const { return m_data.value(key); }//Getting the metadata from Multimediakit + void setMetaData(QtMultimedia::MetaData key, const QVariant &value) { m_data.insert(key, value); } @@ -100,7 +100,7 @@ public: bool m_available; bool m_writable; - QMap m_data; + QMap m_data; QMap m_extendedData; }; diff --git a/tests/auto/qmultimedia_common/mockradiotunercontrol.h b/tests/auto/qmultimedia_common/mockradiotunercontrol.h index aa446074f..5e2d015f9 100644 --- a/tests/auto/qmultimedia_common/mockradiotunercontrol.h +++ b/tests/auto/qmultimedia_common/mockradiotunercontrol.h @@ -70,9 +70,9 @@ public: { return true; } - QtMultimediaKit::AvailabilityError availabilityError() const + QtMultimedia::AvailabilityError availabilityError() const { - return QtMultimediaKit::NoError; + return QtMultimedia::NoError; } QRadioTuner::Band band() const diff --git a/tests/auto/qmultimedia_common/mockvideo.pri b/tests/auto/qmultimedia_common/mockvideo.pri index 6ffa0366a..ea991661f 100644 --- a/tests/auto/qmultimedia_common/mockvideo.pri +++ b/tests/auto/qmultimedia_common/mockvideo.pri @@ -3,9 +3,9 @@ INCLUDEPATH += $$PWD \ ../../../src/multimedia \ ../../../src/multimedia/video -contains(QT,multimediakitwidgets)|contains(QT,multimediakitwidgets-private) { +contains(QT,multimediawidgets)|contains(QT,multimediawidgets-private) { HEADERS *= ../qmultimedia_common/mockvideowindowcontrol.h - DEFINES *= QT_MULTIMEDIAKIT_MOCK_WIDGETS + DEFINES *= QT_MULTIMEDIA_MOCK_WIDGETS } HEADERS *= \ diff --git a/tests/auto/qmultimedia_common/mockvideowindowcontrol.h b/tests/auto/qmultimedia_common/mockvideowindowcontrol.h index 981e266c8..83255e24c 100644 --- a/tests/auto/qmultimedia_common/mockvideowindowcontrol.h +++ b/tests/auto/qmultimedia_common/mockvideowindowcontrol.h @@ -42,7 +42,7 @@ #ifndef MOCKVIDEOWINDOWCONTROL_H #define MOCKVIDEOWINDOWCONTROL_H -#if defined(QT_MULTIMEDIAKIT_MOCK_WIDGETS) +#if defined(QT_MULTIMEDIA_MOCK_WIDGETS) #include "qvideowindowcontrol.h" @@ -70,5 +70,5 @@ public: void setSaturation(int) {} }; -#endif // QT_MULTIMEDIAKIT_MOCK_WIDGETS +#endif // QT_MULTIMEDIA_MOCK_WIDGETS #endif // MOCKVIDEOWINDOWCONTROL_H diff --git a/tests/auto/qpaintervideosurface/qpaintervideosurface.pro b/tests/auto/qpaintervideosurface/qpaintervideosurface.pro index 8c109b20a..7ced1d3d1 100644 --- a/tests/auto/qpaintervideosurface/qpaintervideosurface.pro +++ b/tests/auto/qpaintervideosurface/qpaintervideosurface.pro @@ -1,6 +1,6 @@ load(qttest_p4) -QT += multimediakit-private multimediakitwidgets-private +QT += multimedia-private multimediawidgets-private CONFIG += no_private_qt_headers_warning contains(QT_CONFIG, opengl) | contains(QT_CONFIG, opengles2) { QT += opengl diff --git a/tests/auto/qradiotuner/qradiotuner.pro b/tests/auto/qradiotuner/qradiotuner.pro index b04057ba4..f5c45e63c 100644 --- a/tests/auto/qradiotuner/qradiotuner.pro +++ b/tests/auto/qradiotuner/qradiotuner.pro @@ -1,6 +1,6 @@ load(qttest_p4) -QT += multimediakit-private +QT += multimedia-private CONFIG += no_private_qt_headers_warning HEADERS += tst_qradiotuner.h diff --git a/tests/auto/qradiotuner/tst_qradiotuner.cpp b/tests/auto/qradiotuner/tst_qradiotuner.cpp index 80bac62db..62db50ce1 100644 --- a/tests/auto/qradiotuner/tst_qradiotuner.cpp +++ b/tests/auto/qradiotuner/tst_qradiotuner.cpp @@ -56,13 +56,13 @@ void tst_QRadioTuner::initTestCase() radio = new QRadioTuner(0,provider); QVERIFY(radio->service() != 0); QVERIFY(radio->isAvailable()); - QVERIFY(radio->availabilityError() == QtMultimediaKit::NoError); + QVERIFY(radio->availabilityError() == QtMultimedia::NoError); QSignalSpy stateSpy(radio, SIGNAL(stateChanged(QRadioTuner::State))); QCOMPARE(radio->state(), QRadioTuner::StoppedState); radio->start(); - QVERIFY(radio->availabilityError() == QtMultimediaKit::NoError); + QVERIFY(radio->availabilityError() == QtMultimedia::NoError); QCOMPARE(radio->state(), QRadioTuner::ActiveState); QCOMPARE(stateSpy.count(), 1); @@ -77,7 +77,7 @@ void tst_QRadioTuner::cleanupTestCase() QSignalSpy stateSpy(radio, SIGNAL(stateChanged(QRadioTuner::State))); radio->stop(); - QVERIFY(radio->availabilityError() == QtMultimediaKit::NoError); + QVERIFY(radio->availabilityError() == QtMultimedia::NoError); QCOMPARE(radio->state(), QRadioTuner::StoppedState); QCOMPARE(stateSpy.count(), 1); diff --git a/tests/auto/qsoundeffect/qsoundeffect.pro b/tests/auto/qsoundeffect/qsoundeffect.pro index c1e317893..8c5ef7011 100644 --- a/tests/auto/qsoundeffect/qsoundeffect.pro +++ b/tests/auto/qsoundeffect/qsoundeffect.pro @@ -1,6 +1,6 @@ load(qttest_p4) -QT += core declarative multimediakit-private +QT += core declarative multimedia-private CONFIG += no_private_qt_headers_warning # This is more of a system test diff --git a/tests/auto/qvideodevicecontrol/qvideodevicecontrol.pro b/tests/auto/qvideodevicecontrol/qvideodevicecontrol.pro index e336c6eb9..c0f5b3759 100644 --- a/tests/auto/qvideodevicecontrol/qvideodevicecontrol.pro +++ b/tests/auto/qvideodevicecontrol/qvideodevicecontrol.pro @@ -1,6 +1,6 @@ load(qttest_p4) -QT += multimediakit-private +QT += multimedia-private CONFIG += no_private_qt_headers_warning SOURCES += tst_qvideodevicecontrol.cpp diff --git a/tests/auto/qvideoencodercontrol/qvideoencodercontrol.pro b/tests/auto/qvideoencodercontrol/qvideoencodercontrol.pro index 98b64c17d..e41404c7e 100644 --- a/tests/auto/qvideoencodercontrol/qvideoencodercontrol.pro +++ b/tests/auto/qvideoencodercontrol/qvideoencodercontrol.pro @@ -1,6 +1,6 @@ load(qttest_p4) -QT += multimediakit-private +QT += multimedia-private CONFIG += no_private_qt_headers_warning SOURCES += \ diff --git a/tests/auto/qvideoframe/qvideoframe.pro b/tests/auto/qvideoframe/qvideoframe.pro index 13bcf1ee1..c129025d2 100644 --- a/tests/auto/qvideoframe/qvideoframe.pro +++ b/tests/auto/qvideoframe/qvideoframe.pro @@ -1,6 +1,6 @@ load(qttest_p4) -QT += core multimediakit-private +QT += core multimedia-private CONFIG += no_private_qt_headers_warning SOURCES += tst_qvideoframe.cpp diff --git a/tests/auto/qvideosurfaceformat/qvideosurfaceformat.pro b/tests/auto/qvideosurfaceformat/qvideosurfaceformat.pro index 26ea850fb..97d576f8a 100644 --- a/tests/auto/qvideosurfaceformat/qvideosurfaceformat.pro +++ b/tests/auto/qvideosurfaceformat/qvideosurfaceformat.pro @@ -1,6 +1,6 @@ load(qttest_p4) -QT += core multimediakit-private +QT += core multimedia-private CONFIG += no_private_qt_headers_warning SOURCES += tst_qvideosurfaceformat.cpp diff --git a/tests/auto/qvideowidget/qvideowidget.pro b/tests/auto/qvideowidget/qvideowidget.pro index 4a034c17a..a6f8a660b 100644 --- a/tests/auto/qvideowidget/qvideowidget.pro +++ b/tests/auto/qvideowidget/qvideowidget.pro @@ -1,6 +1,6 @@ load(qttest_p4) -QT += multimediakit-private multimediakitwidgets-private +QT += multimedia-private multimediawidgets-private CONFIG += no_private_qt_headers_warning SOURCES += tst_qvideowidget.cpp diff --git a/tests/auto/qvideowidget/tst_qvideowidget.cpp b/tests/auto/qvideowidget/tst_qvideowidget.cpp index 58ab43eed..9f9bafc50 100644 --- a/tests/auto/qvideowidget/tst_qvideowidget.cpp +++ b/tests/auto/qvideowidget/tst_qvideowidget.cpp @@ -41,7 +41,7 @@ //TESTED_COMPONENT=src/multimedia -#include +#include #include #include "qvideowidget.h" -- cgit v1.2.3