diff --git a/CMakeLists.txt b/CMakeLists.txt index 6ac29cc12..ea5575bc6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -104,9 +104,6 @@ add_feature_info(mysql WITH_MYSQL "the world's most popular open source database option(WITH_SQLITE "Build SQLite database plugin" ON) add_feature_info(sqlite WITH_SQLITE "the world's most popular open source database") -option(WITH_VLC "Build VLC Phonon backend" ON) -add_feature_info(sqlite WITH_VLC "VLC C API Library") - option(WITH_X11 "Build X11/X.Org support" ON) add_feature_info(x11 WITH_X11 "an open source something") @@ -420,15 +417,6 @@ set_package_properties(Sqlite PROPERTIES TYPE RECOMMENDED ) -set(VLC_MIN_VERSION "2.1.0") -find_package(VLC) -set_package_properties(VLC PROPERTIES - PURPOSE "Required for VLC Phonon backend" - DESCRIPTION "VLC C API Library" - URL "http://www.videolan.org/vlc/" - TYPE RECOMMENDED -) - find_package(Threads) set_package_properties(Threads PROPERTIES PURPOSE "Required for threads support" @@ -559,7 +547,6 @@ if(NOT KATIE_BOOTSTRAP) if(WITH_OPENGL AND OPENGL_FOUND) add_subdirectory(src/opengl) endif() - add_subdirectory(src/phonon) add_subdirectory(src/plugins) add_subdirectory(src/script) add_subdirectory(src/scripttools) @@ -601,7 +588,6 @@ katie_generate_obsolete(qhboxlayout.h QtGui qboxlayout.h) katie_generate_obsolete(qvboxlayout.h QtGui qboxlayout.h) katie_generate_obsolete(qspaceritem.h QtGui qlayoutitem.h) katie_generate_obsolete(qdoublespinbox.h QtGui qspinbox.h) -katie_generate_obsolete(global.h Phonon ../phonon/phononnamespace.h) katie_generate_obsolete(qxmlstream.h QtXml ../QtCore/qxmlstream.h) katie_generate_obsolete(qxmlstreamwriter.h QtXml ../QtCore/qxmlstream.h) katie_generate_obsolete(qxmlstreamreader.h QtXml ../QtCore/qxmlstream.h) diff --git a/README b/README index a7d441287..98ef7122b 100644 --- a/README +++ b/README @@ -7,7 +7,7 @@ There are several things you should be aware before considering Katie: - some components and tools have been removed: - QMake, D-Bus viewer, Linguist, Assistant, checksdk, macdeployqt, pixeltool, qconfig, qdoc, qev, qvfb, runonphone and other non-essential - - Qt3Support, QtWebKit and ActiveQt + - Qt3Support, QtWebKit, ActiveQt and Phonon - some things have changed: - QMake build system replaced with CMake @@ -16,8 +16,6 @@ There are several things you should be aware before considering Katie: - OpenSSL and D-Bus cannot be runtime dependencies, they must be linked to during build - QtUiTools is build as shared library by default - - Phonon has been updated to 4.8.51 - - Phonon backends (GStreamer, DS9, MMF, QT7, WaveOut) replaced with VLC - updated bundled Harfbuzz from upstream (not Harfbuzz-NG) - Symbian, QWS and QPA are no longer supported platforms - OpenVG is no longer supported graphics output diff --git a/TODO b/TODO index c1ff39763..a86bf3a16 100644 --- a/TODO +++ b/TODO @@ -2,8 +2,6 @@ finish plugins porting to cmake deal with obsolete headers, besides those mentioned in the CMake files use system harfbuzz and clucene (optionally) and unbundle make use of qstandarddirs and qcommandlineparser trought the codebase, e.g. moc -move phonon sources to 3rdparty, still, generate docs for it -do not rebuild phonon on prefix change QT_MOC_CPP seems unused but checked for in two headers manual pages for lconvert, qcollectiongenerator, qhelpgenerator, rcc and uic new logo, branding, copyright header changes, etc. diff --git a/cmake/KatieConfig.cmake b/cmake/KatieConfig.cmake index c0a926fe7..d33fe22a3 100644 --- a/cmake/KatieConfig.cmake +++ b/cmake/KatieConfig.cmake @@ -34,15 +34,6 @@ foreach(component ${KATIE_COMPONENTS}) if(uppercomp STREQUAL "MAIN") set(KATIE_INCLUDES ${KATIE_INCLUDES} "@QT_HEADERS_PATH@") set(KATIE_${uppercomp}_INCLUDES "@QT_HEADERS_PATH@") - elseif(uppercomp STREQUAL "PHONON") - set(KATIE_INCLUDES ${KATIE_INCLUDES} - "@QT_HEADERS_PATH@/phonon" - "@QT_HEADERS_PATH@/Phonon" - ) - set(KATIE_${uppercomp}_INCLUDES - "@QT_HEADERS_PATH@/phonon" - "@QT_HEADERS_PATH@/Phonon" - ) else() set(KATIE_INCLUDES ${KATIE_INCLUDES} "@QT_HEADERS_PATH@/Qt${component}") set(KATIE_${uppercomp}_INCLUDES "@QT_HEADERS_PATH@/Qt${component}") diff --git a/cmake/modules/FindVLC.cmake b/cmake/modules/FindVLC.cmake deleted file mode 100644 index 5716ca535..000000000 --- a/cmake/modules/FindVLC.cmake +++ /dev/null @@ -1,62 +0,0 @@ -# - Try to find the VLC -# Once done this will define -# -# VLC_FOUND - system has VLC -# VLC_INCLUDES - the VLC include directory -# VLC_LIBRARIES - The libraries needed to use VLC -# -# Copyright (c) 2015, Ivailo Monev, -# -# Redistribution and use is allowed according to the terms of the BSD license. - -if(VLC_INCLUDES AND VLC_LIBRARIES) - set(VLC_FIND_QUIETLY TRUE) -endif() - -if(NOT WIN32) - include(FindPkgConfig) - pkg_check_modules(PC_VLC QUIET libvlc) - - set(VLC_VERSION ${PC_VLC_VERSION}) -endif() - -find_path(VLC_INCLUDES - NAMES - vlc/vlc.h - HINTS - $ENV{VLCDIR}/include - ${PC_VLC_INCLUDEDIR} - /usr/include - /usr/local/include - ${INCLUDE_INSTALL_DIR} -) - -find_library(VLC_LIBRARIES - vlc - HINTS - $ENV{VLCDIR}/lib - ${PC_VLC_LIBDIR} - /usr/lib - /usr/local/lib - ${LIB_INSTALL_DIR} -) - -find_library(VLC_CORE_LIBRARIES - vlccore - HINTS - $ENV{VLCDIR}/lib - ${PC_VLC_LIBDIR} - /usr/lib - /usr/local/lib - ${LIB_INSTALL_DIR} -) - -if(VLC_LIBRARIES AND VLC_CORE_LIBRARIES) - set(VLC_LIBRARIES ${VLC_LIBRARIES} ${VLC_CORE_LIBRARIES}) -endif() - - -include(FindPackageHandleStandardArgs) -find_package_handle_standard_args(VLC DEFAULT_MSG VLC_INCLUDES VLC_LIBRARIES VLC_CORE_LIBRARIES) - -mark_as_advanced(VLC_INCLUDES VLC_LIBRARIES) diff --git a/doxygen.conf b/doxygen.conf index 3411e51b3..4bc5a60aa 100644 --- a/doxygen.conf +++ b/doxygen.conf @@ -38,7 +38,7 @@ PROJECT_NAME = "Katie" # could be handy for archiving the generated documentation or if some version # control system is used. -PROJECT_NUMBER = 4.8.7 +PROJECT_NUMBER = 4.9.0 # Using the PROJECT_BRIEF tag one can provide an optional one line description # for a project that appears at the top of each page and should give viewer a @@ -809,7 +809,7 @@ EXCLUDE_SYMLINKS = NO # Note that the wildcards are matched against the file with absolute path, so to # exclude all test directories for example use the pattern */test/* -EXCLUDE_PATTERNS = */src/3rdparty/* */tests/* */src/tools/* */src/phonon/phonon-vlc/* +EXCLUDE_PATTERNS = */src/3rdparty/* */tests/* */src/tools/* # The EXCLUDE_SYMBOLS tag can be used to specify one or more symbol names # (namespaces, classes, functions, etc.) that should be excluded from the diff --git a/mkspecs/mkspecs.cmake b/mkspecs/mkspecs.cmake index 858cdd9c4..8fdfc05ef 100644 --- a/mkspecs/mkspecs.cmake +++ b/mkspecs/mkspecs.cmake @@ -8,7 +8,7 @@ set(KATIE_VERSION "${KATIE_MAJOR}.${KATIE_MINOR}.${KATIE_MICRO}") set(KATIE_STRING "katie ${KATIE_MAJOR}.${KATIE_MINOR}.${KATIE_MICRO}") set(KATIE_BUGREPORT "xakepa10@gmail.com") set(KATIE_URL "http://github.com/fluxer/katie") -set(KATIE_COMPONENTS "Core Gui DBus Declarative Designer DesignerComponents Help Multimedia Network OpenGL Phonon Sql Svg Xml XmlPatterns Script ScriptTools Test UiTools") +set(KATIE_COMPONENTS "Core Gui DBus Declarative Designer DesignerComponents Help Multimedia Network OpenGL Sql Svg Xml XmlPatterns Script ScriptTools Test UiTools") # TODO: make dbus tools optional set(KATIE_TOOLS "moc uic rcc qdbusxml2cpp qdbuscpp2xml qhelpgenerator qcollectiongenerator lupdate lrelease lconvert designer") set(QT_LICENSE "Open Source") @@ -98,7 +98,6 @@ include(${KATIE_MKSPECS_DIR}/tests/tests.cmake) set(LDCONF_INSTALL_DIR "etc/ld.so.conf.d") set(PROFILE_INSTALL_DIR "etc/profile.d") set(DBUS_INTERFACES_INSTALL_DIR "etc/dbus-1/interfaces") -set(KDE4_SERVICES_INSTALL_DIR "share/kde4/services/phononbackends") set(MAN_INSTALL_DIR "share/man") set(CMAKE_INSTALL_DIR "cmake") diff --git a/package/archlinux-mingw/PKGBUILD b/package/archlinux-mingw/PKGBUILD index a71868328..1672ece9b 100644 --- a/package/archlinux-mingw/PKGBUILD +++ b/package/archlinux-mingw/PKGBUILD @@ -8,10 +8,8 @@ pkgdesc='C++ toolkit derived from the Qt 4.8 framework (mingw-w64)' arch=('i686' 'x86_64') url='https://github.com/fluxer/katie' license=('LGPL' 'FDL' 'custom') -# FIXME: depend on mingw-w64-vlc depends=('mingw-w64-openssl' 'mingw-w64-zlib' 'mingw-w64-crt') -makedepends=('cmake' 'git' 'python' 'vlc' 'unifdef' 'mingw-w64-gcc') -optdepends=('vlc: Phonon VLC backend') +makedepends=('cmake' 'git' 'python' 'unifdef' 'mingw-w64-gcc') source=("git+https://github.com/fluxer/katie") sha1sums=('SKIP') conflicts=('mingw-w64-katie') @@ -27,8 +25,6 @@ pkgver() { prepare() { mkdir -p build - echo "set(DBUS_INTERFACES_INSTALL_DIR /usr/${_arch}/etc/dbus-1/interfaces)" \ - >> katie/mkspecs/win32/vendor.cmake echo "set(CMAKE_INSTALL_DIR /usr/${_arch}/share/cmake)" \ >> katie/mkspecs/win32/vendor.cmake echo 'set(QT_LIBRARIES_PATH "${QT_PREFIX_PATH}/lib/katie")' \ diff --git a/package/archlinux/PKGBUILD b/package/archlinux/PKGBUILD index fb8711737..1e28f6378 100644 --- a/package/archlinux/PKGBUILD +++ b/package/archlinux/PKGBUILD @@ -13,11 +13,10 @@ depends=('openssl' 'zlib' 'cups' 'alsa-lib' 'gtk2' 'libgl' 'libice' 'libsm' 'libxcursor' 'libxext' 'libxfixes' 'libxi' 'libxinerama' 'libxrandr' 'libxrender' 'libx11' 'fontconfig' 'freetype2' 'glib2') makedepends=('cmake' 'git' 'python' 'postgresql' 'mariadb' 'unixodbc' 'mesa' - 'vlc' 'unifdef') + 'unifdef') optdepends=('postgresql-libs: PostgreSQL driver' 'libmariadbclient: MariaDB driver' - 'unixodbc: ODBC driver' - 'vlc: Phonon VLC backend') + 'unixodbc: ODBC driver') source=("git+https://github.com/fluxer/katie") sha1sums=('SKIP') conflicts=('katie') @@ -35,8 +34,6 @@ prepare() { >> katie/mkspecs/linux/vendor.cmake echo 'set(PROFILE_INSTALL_DIR /etc/profile.d)' \ >> katie/mkspecs/linux/vendor.cmake - echo 'set(DBUS_INTERFACES_INSTALL_DIR /etc/dbus-1/interfaces)' \ - >> katie/mkspecs/linux/vendor.cmake echo 'set(CMAKE_INSTALL_DIR /usr/share/cmake)' \ >> katie/mkspecs/linux/vendor.cmake } diff --git a/package/debian/rules b/package/debian/rules index 53f07c26d..3a178ba21 100755 --- a/package/debian/rules +++ b/package/debian/rules @@ -8,8 +8,6 @@ override_dh_auto_configure: > mkspecs/linux/vendor.cmake echo 'set(PROFILE_INSTALL_DIR /etc/profile.d)' \ >> mkspecs/linux/vendor.cmake - echo 'set(DBUS_INTERFACES_INSTALL_DIR /etc/dbus-1/interfaces)' \ - >> mkspecs/linux/vendor.cmake echo 'set(CMAKE_INSTALL_DIR /usr/share/cmake)' \ >> mkspecs/linux/vendor.cmake diff --git a/src/gui/image/qmovie.cpp b/src/gui/image/qmovie.cpp index c5e37594c..e13aae96c 100644 --- a/src/gui/image/qmovie.cpp +++ b/src/gui/image/qmovie.cpp @@ -48,8 +48,7 @@ \ingroup painting This class is used to show simple animations without sound. If you want - to display video and media content, use the \l{Phonon Module}{Phonon} - multimedia framework instead. + to display video and media content, use other multimedia framework. First, create a QMovie object by passing either the name of a file or a pointer to a QIODevice containing an animated image format to QMovie's diff --git a/src/phonon/CMakeLists.txt b/src/phonon/CMakeLists.txt deleted file mode 100644 index 66cc54707..000000000 --- a/src/phonon/CMakeLists.txt +++ /dev/null @@ -1,386 +0,0 @@ -add_definitions( - -DQT_BUILD_PHONON_LIB - -DMAKE_PHONON_LIB - -DPHONON_LIBRARY_PATH="${QT_PLUGINS_PATH}" - -DPHONON_BACKEND_DIR_SUFFIX="/phonon_backend/" - # do not use any platform plugin - # -DQT_NO_PHONON_PLATFORMPLUGIN - # -DPHONON_NO_CAPTURE -) -set(EXTRA_PHONON_LIBS KtCore KtGui) - -# TODO: aliases -set(PHONON_PUBLIC_HEADERS - ${PHONON_PUBLIC_HEADERS} - AbstractAudioOutput - AbstractMediaStream - AbstractVideoOutput - AddonInterface - AudioCaptureDevice - AudioCaptureDeviceModel - AudioChannelDescription - AudioChannelDescriptionModel - AudioDataOutput - AudioOutput - AudioOutputDevice - AudioOutputDeviceModel - AudioOutputInterface - AudioOutputInterface40 - AudioOutputInterface42 - AvCapture - BackendCapabilities - BackendInterface - Effect - EffectDescription - EffectDescriptionModel - EffectInterface - EffectParameter - EffectWidget - Global - GlobalDescriptionContainer - MediaController - MediaNode - MediaObject - MediaObjectInterface - MediaSource - Mrl - ObjectDescription - ObjectDescriptionData - ObjectDescriptionModel - ObjectDescriptionModelData - Path - PlatformPlugin - SeekSlider - StreamInterface - SubtitleDescription - SubtitleDescriptionModel - VideoCaptureDevice - VideoCaptureDeviceModel - VideoPlayer - VideoWidget - VideoWidgetInterface - VideoWidgetInterface44 - VideoWidgetInterfaceLatest - VolumeFaderEffect - VolumeFaderInterface - VolumeSlider -) - -set(PHONON_LIB_MAJOR_VERSION ${KATIE_MAJOR}) -set(PHONON_LIB_MINOR_VERSION ${KATIE_MINOR}) -set(PHONON_LIB_PATCH_VERSION ${KATIE_MICRO}) -set(PHONON_EXPERIMENTAL TRUE) -set(PHONON_GRAPHICS TRUE) -set(BACKEND_INSTALL_DIR "${QT_PLUGINS_PATH_INST}/phonon_backend/") - -set_source_files_properties( - ${CMAKE_CURRENT_SOURCE_DIR}/experimental/factory.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/experimental/globalconfig.h - PROPERTIES SKIP_RESOURCE TRUE -) - -set(PHONON_HEADERS - ${PHONON_HEADERS} - ${CMAKE_CURRENT_SOURCE_DIR}/abstractaudiooutput.h - ${CMAKE_CURRENT_SOURCE_DIR}/abstractmediastream.h - ${CMAKE_CURRENT_SOURCE_DIR}/abstractvideooutput.h - ${CMAKE_CURRENT_SOURCE_DIR}/addoninterface.h - ${CMAKE_CURRENT_SOURCE_DIR}/audiodataoutput.h - ${CMAKE_CURRENT_SOURCE_DIR}/audiodataoutputinterface.h - ${CMAKE_CURRENT_SOURCE_DIR}/audiooutput.h - ${CMAKE_CURRENT_SOURCE_DIR}/audiooutputinterface.h - ${CMAKE_CURRENT_SOURCE_DIR}/backendcapabilities.h - ${CMAKE_CURRENT_SOURCE_DIR}/backendinterface.h - ${CMAKE_CURRENT_SOURCE_DIR}/effect.h - ${CMAKE_CURRENT_SOURCE_DIR}/effectinterface.h - ${CMAKE_CURRENT_SOURCE_DIR}/effectparameter.h - ${CMAKE_CURRENT_SOURCE_DIR}/effectwidget.h - ${CMAKE_CURRENT_SOURCE_DIR}/globalconfig.h - ${CMAKE_CURRENT_SOURCE_DIR}/globaldescriptioncontainer.h - ${CMAKE_CURRENT_SOURCE_DIR}/mediacontroller.h - ${CMAKE_CURRENT_SOURCE_DIR}/medianode.h - ${CMAKE_CURRENT_SOURCE_DIR}/mediaobject.h - ${CMAKE_CURRENT_SOURCE_DIR}/mediaobjectinterface.h - ${CMAKE_CURRENT_SOURCE_DIR}/mediasource.h - ${CMAKE_CURRENT_SOURCE_DIR}/mrl.h - ${CMAKE_CURRENT_SOURCE_DIR}/objectdescription.h - ${CMAKE_CURRENT_SOURCE_DIR}/objectdescriptionmodel.h - ${CMAKE_CURRENT_SOURCE_DIR}/path.h - ${CMAKE_CURRENT_SOURCE_DIR}/phonon_export.h - ${CMAKE_CURRENT_SOURCE_DIR}/phonondefs.h - ${CMAKE_CURRENT_SOURCE_DIR}/platformplugin.h - ${CMAKE_CURRENT_SOURCE_DIR}/seekslider.h - ${CMAKE_CURRENT_SOURCE_DIR}/streaminterface.h - ${CMAKE_CURRENT_SOURCE_DIR}/videoplayer.h - ${CMAKE_CURRENT_SOURCE_DIR}/videowidget.h - ${CMAKE_CURRENT_SOURCE_DIR}/videowidgetinterface.h - ${CMAKE_CURRENT_SOURCE_DIR}/volumefadereffect.h - ${CMAKE_CURRENT_SOURCE_DIR}/volumefaderinterface.h - ${CMAKE_CURRENT_SOURCE_DIR}/volumeslider.h - ${CMAKE_CURRENT_SOURCE_DIR}/abstractaudiooutput_p.h - ${CMAKE_CURRENT_SOURCE_DIR}/abstractmediastream_p.h - ${CMAKE_CURRENT_SOURCE_DIR}/abstractvideooutput_p.h - ${CMAKE_CURRENT_SOURCE_DIR}/audiodataoutput_p.h - ${CMAKE_CURRENT_SOURCE_DIR}/audiooutputadaptor_p.h - ${CMAKE_CURRENT_SOURCE_DIR}/audiooutput_p.h - ${CMAKE_CURRENT_SOURCE_DIR}/backendcapabilities_p.h - ${CMAKE_CURRENT_SOURCE_DIR}/effectparameter_p.h - ${CMAKE_CURRENT_SOURCE_DIR}/effect_p.h - ${CMAKE_CURRENT_SOURCE_DIR}/effectwidget_p.h - ${CMAKE_CURRENT_SOURCE_DIR}/factory_p.h - ${CMAKE_CURRENT_SOURCE_DIR}/frontendinterface_p.h - ${CMAKE_CURRENT_SOURCE_DIR}/globalconfig_p.h - ${CMAKE_CURRENT_SOURCE_DIR}/globalstatic_p.h - ${CMAKE_CURRENT_SOURCE_DIR}/iodevicestream_p.h - ${CMAKE_CURRENT_SOURCE_DIR}/medianodedestructionhandler_p.h - ${CMAKE_CURRENT_SOURCE_DIR}/medianode_p.h - ${CMAKE_CURRENT_SOURCE_DIR}/mediaobject_p.h - ${CMAKE_CURRENT_SOURCE_DIR}/mediasource_p.h - ${CMAKE_CURRENT_SOURCE_DIR}/objectdescriptionmodel_p.h - ${CMAKE_CURRENT_SOURCE_DIR}/objectdescription_p.h - ${CMAKE_CURRENT_SOURCE_DIR}/path_p.h - ${CMAKE_CURRENT_SOURCE_DIR}/phonondefs_p.h - ${CMAKE_CURRENT_SOURCE_DIR}/phononnamespace_p.h - ${CMAKE_CURRENT_SOURCE_DIR}/phononpimpl_p.h - ${CMAKE_CURRENT_SOURCE_DIR}/platform_p.h - ${CMAKE_CURRENT_SOURCE_DIR}/qsettingsgroup_p.h - ${CMAKE_CURRENT_SOURCE_DIR}/seekslider_p.h - ${CMAKE_CURRENT_SOURCE_DIR}/statesvalidator_p.h - ${CMAKE_CURRENT_SOURCE_DIR}/streaminterface_p.h - ${CMAKE_CURRENT_SOURCE_DIR}/swiftslider_p.h - ${CMAKE_CURRENT_SOURCE_DIR}/videowidget_p.h - ${CMAKE_CURRENT_SOURCE_DIR}/volumefadereffect_p.h - ${CMAKE_CURRENT_SOURCE_DIR}/volumeslider_p.h -) - -set(PHONON_SOURCES - ${PHONON_SOURCES} - ${CMAKE_CURRENT_SOURCE_DIR}/abstractaudiooutput.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/abstractaudiooutput_p.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/abstractmediastream.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/abstractvideooutput.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/abstractvideooutput_p.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/audiodataoutput.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/audiooutput.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/audiooutputinterface.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/backendcapabilities.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/effect.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/effectparameter.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/effectwidget.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/factory.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/globalconfig.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/iodevicestream.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/mediacontroller.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/mediaobject.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/medianode.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/mediasource.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/mrl.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/objectdescription.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/objectdescriptionmodel.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/path.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/phononnamespace.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/platform.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/seekslider.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/statesvalidator.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/streaminterface.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/swiftslider.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/volumefadereffect.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/volumeslider.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/videoplayer.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/videowidget.cpp -) - -if(WITH_OPENGL AND OPENGL_FOUND AND PHONON_GRAPHICS) - set(PHONON_HEADERS - ${PHONON_HEADERS} - ${CMAKE_CURRENT_SOURCE_DIR}/graphicsview/abstractvideographicspainter.h - ${CMAKE_CURRENT_SOURCE_DIR}/graphicsview/glpainter.h - ${CMAKE_CURRENT_SOURCE_DIR}/graphicsview/videoframe.h - ${CMAKE_CURRENT_SOURCE_DIR}/graphicsview/videographicsobjectinterface.h - ${CMAKE_CURRENT_SOURCE_DIR}/graphicsview/videoframe.h - # VGO does not need to be public, as there is only pull but no push behavior. - ${CMAKE_CURRENT_SOURCE_DIR}/graphicsview/videographicsobject.h - ${CMAKE_CURRENT_SOURCE_DIR}/graphicsview/videographicsobjectinterface.h - ) - - set(PHONON_SOURCES - ${PHONON_SOURCES} - ${CMAKE_CURRENT_SOURCE_DIR}/graphicsview/glpainter.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/graphicsview/glslpainter.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/graphicsview/qpainterpainter.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/graphicsview/videographicsobject.cpp - ) - set(EXTRA_PHONON_LIBS - ${EXTRA_PHONON_LIBS} - KtOpenGL - ) - include_directories(${OPENGL_INCLUDE_DIR}) -else() - set(PHONON_GRAPHICS FALSE) - katie_definition(-DPHONON_NO_GRAPHICSVIEW) -endif() - -if(WITH_DBUS AND DBUS_FOUND) - set(PHONON_SOURCES - ${PHONON_SOURCES} - ${CMAKE_CURRENT_SOURCE_DIR}/audiooutputadaptor.cpp - ) - set(EXTRA_PHONON_LIBS - ${EXTRA_PHONON_LIBS} - KtDBus - ) - - configure_file( - ${CMAKE_CURRENT_SOURCE_DIR}/org.kde.Phonon.AudioOutput.xml - ${CMAKE_CURRENT_BINARY_DIR}/org.kde.Phonon.AudioOutput.xml - @ONLY - ) - install( - FILES ${CMAKE_CURRENT_BINARY_DIR}/org.kde.Phonon.AudioOutput.xml - DESTINATION ${DBUS_INTERFACES_INSTALL_DIR} - ) -endif() - -configure_file( - ${CMAKE_CURRENT_SOURCE_DIR}/phononconfig_p.h.in - ${CMAKE_CURRENT_BINARY_DIR}/phononconfig_p.h -) - -configure_file( - ${CMAKE_CURRENT_SOURCE_DIR}/phononnamespace.h.in - ${CMAKE_CURRENT_BINARY_DIR}/phononnamespace.h -) - -set(PHONON_HEADERS - ${PHONON_HEADERS} - ${CMAKE_CURRENT_BINARY_DIR}/phononconfig_p.h - ${CMAKE_CURRENT_BINARY_DIR}/phononnamespace.h -) - -if(PHONON_EXPERIMENTAL) - set(PHONON_EXPERIMENTAL_HEADERS - ${PHONON_EXPERIMENTAL_HEADERS} - ${CMAKE_CURRENT_SOURCE_DIR}/experimental/abstractaudiodataoutput.h - ${CMAKE_CURRENT_SOURCE_DIR}/experimental/abstractvideodataoutput.h - ${CMAKE_CURRENT_SOURCE_DIR}/experimental/audiodataoutput.h - ${CMAKE_CURRENT_SOURCE_DIR}/experimental/audiodataoutputinterface.h - ${CMAKE_CURRENT_SOURCE_DIR}/experimental/audioformat.h - ${CMAKE_CURRENT_SOURCE_DIR}/experimental/avcapture.h - ${CMAKE_CURRENT_SOURCE_DIR}/experimental/avcaptureinterface.h - ${CMAKE_CURRENT_SOURCE_DIR}/experimental/backendcapabilities.h - ${CMAKE_CURRENT_SOURCE_DIR}/experimental/backendinterface.h - ${CMAKE_CURRENT_SOURCE_DIR}/experimental/export.h - ${CMAKE_CURRENT_SOURCE_DIR}/experimental/mediasource.h - ${CMAKE_CURRENT_SOURCE_DIR}/experimental/objectdescription.h - ${CMAKE_CURRENT_SOURCE_DIR}/experimental/snapshotinterface.h - ${CMAKE_CURRENT_SOURCE_DIR}/experimental/packet.h - ${CMAKE_CURRENT_SOURCE_DIR}/experimental/packetpool.h - ${CMAKE_CURRENT_SOURCE_DIR}/experimental/phononnamespace.h - ${CMAKE_CURRENT_SOURCE_DIR}/experimental/videodataoutput.h - ${CMAKE_CURRENT_SOURCE_DIR}/experimental/videodataoutput2.h - ${CMAKE_CURRENT_SOURCE_DIR}/experimental/videodataoutputinterface.h - ${CMAKE_CURRENT_SOURCE_DIR}/experimental/videoframe.h - ${CMAKE_CURRENT_SOURCE_DIR}/experimental/videoframe2.h - ${CMAKE_CURRENT_SOURCE_DIR}/experimental/videowidget.h - ${CMAKE_CURRENT_SOURCE_DIR}/experimental/visualization.h - ${CMAKE_CURRENT_SOURCE_DIR}/experimental/globalconfig.h - ${CMAKE_CURRENT_SOURCE_DIR}/experimental/factory_p.h - ) - set(PHONON_SOURCES - ${PHONON_SOURCES} - ${CMAKE_CURRENT_SOURCE_DIR}/experimental/abstractaudiodataoutput.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/experimental/abstractvideodataoutput.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/experimental/audiodataoutput.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/experimental/audioformat.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/experimental/avcapture.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/experimental/backendcapabilities.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/experimental/factory.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/experimental/globalconfig.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/experimental/mediasource.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/experimental/objectdescription.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/experimental/packet.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/experimental/packetpool.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/experimental/videodataoutput.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/experimental/videodataoutput2.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/experimental/videowidget.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/experimental/visualization.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/abstractaudiooutput_p.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/abstractvideooutput_p.cpp - ) - add_definitions(-DMAKE_PHONONEXPERIMENTAL_LIB) -endif() - -include_directories( - ${CMAKE_BINARY_DIR}/include - ${CMAKE_BINARY_DIR}/privateinclude - ${CMAKE_BINARY_DIR}/include/QtCore - ${CMAKE_BINARY_DIR}/privateinclude/QtCore - ${CMAKE_BINARY_DIR}/include/QtGui - ${CMAKE_BINARY_DIR}/privateinclude/QtGui - ${CMAKE_BINARY_DIR}/include/QtOpenGL - ${CMAKE_BINARY_DIR}/privateinclude/QtOpenGL - ${CMAKE_BINARY_DIR}/include/phonon - ${CMAKE_BINARY_DIR}/privateinclude/phonon - ${CMAKE_BINARY_DIR}/include/phonon/experimental - ${CMAKE_BINARY_DIR}/privateinclude/phonon/experimental - ${CMAKE_CURRENT_SOURCE_DIR} - ${CMAKE_CURRENT_BINARY_DIR} - ${CMAKE_CURRENT_BINARY_DIR}/experimental - ${CMAKE_CURRENT_BINARY_DIR}/graphicsview -) - -katie_generate_misc("${PHONON_HEADERS}" phonon) -katie_generate_misc("${PHONON_EXPERIMENTAL_HEADERS}" phonon/experimental) -# for Qt Phonon and KDE Phonon compat do it for both -# TODO: migrate the vlc backend from Phonon, Katana is happy with phonon -katie_generate_public("${PHONON_PUBLIC_HEADERS}" Phonon) -katie_generate_public("${PHONON_PUBLIC_HEADERS}" phonon) -if(PHONON_EXPERIMENTAL) - katie_generate_map(Phonon "PHONON_EXPORT|PHONONEXPERIMENTAL_EXPORT") - katie_generate_map(phonon "PHONON_EXPORT|PHONONEXPERIMENTAL_EXPORT") -else() - katie_generate_map(Phonon PHONON_EXPORT) - katie_generate_map(phonon PHONON_EXPORT) -endif() -katie_resources(${PHONON_SOURCES} ${PHONON_HEADERS}) -if(PHONON_EXPERIMENTAL) - katie_resources(${PHONON_EXPERIMENTAL_HEADERS}) -endif() -katie_setup_flags() - -add_library(KtPhonon ${KATIE_TYPE} ${PHONON_SOURCES} ${PHONON_HEADERS} ${PHONON_EXPERIMENTAL_HEADERS}) -target_link_libraries(KtPhonon ${EXTRA_PHONON_LIBS}) -set_target_properties(KtPhonon PROPERTIES - VERSION ${KATIE_MAJOR}.${KATIE_MINOR} - SOVERSION ${KATIE_VERSION} - EXPORT_NAME Phonon -) - -set(PHONON_REQUIRES KtCore) -if(WITH_OPENGL AND OPENGL_FOUND AND PHONON_GRAPHICS) - set(PHONON_REQUIRES "${PHONON_REQUIRES} KtOpenGL") -endif() -if(WITH_DBUS AND DBUS_FOUND) - set(PHONON_REQUIRES "${PHONON_REQUIRES} KtDBus") -endif() -katie_generate_package(KtPhonon "" "${EXTRA_PHONON_LIBS}" "${PHONON_REQUIRES}") - -if(WITH_VLC AND VLC_FOUND) - add_subdirectory(phonon-vlc) -endif() - -install( - TARGETS KtPhonon - EXPORT KatieLibraryTargets ${INSTALL_TARGETS_DEFAULT_ARGS} - DESTINATION ${QT_LIBRARIES_PATH_INST} -) - -install( - DIRECTORY - ${CMAKE_BINARY_DIR}/include/phonon - ${CMAKE_BINARY_DIR}/include/Phonon - DESTINATION ${QT_HEADERS_PATH_INST} - COMPONENT Devel -) - -katie_optimize_headers(${QT_HEADERS_PATH}/phonon) diff --git a/src/phonon/COPYING.LIB b/src/phonon/COPYING.LIB deleted file mode 100644 index 2d2d780e6..000000000 --- a/src/phonon/COPYING.LIB +++ /dev/null @@ -1,510 +0,0 @@ - - GNU LESSER GENERAL PUBLIC LICENSE - Version 2.1, February 1999 - - Copyright (C) 1991, 1999 Free Software Foundation, Inc. - 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - -[This is the first released version of the Lesser GPL. It also counts - as the successor of the GNU Library Public License, version 2, hence - the version number 2.1.] - - Preamble - - The licenses for most software are designed to take away your -freedom to share and change it. By contrast, the GNU General Public -Licenses are intended to guarantee your freedom to share and change -free software--to make sure the software is free for all its users. - - This license, the Lesser General Public License, applies to some -specially designated software packages--typically libraries--of the -Free Software Foundation and other authors who decide to use it. You -can use it too, but we suggest you first think carefully about whether -this license or the ordinary General Public License is the better -strategy to use in any particular case, based on the explanations -below. - - When we speak of free software, we are referring to freedom of use, -not price. Our General Public Licenses are designed to make sure that -you have the freedom to distribute copies of free software (and charge -for this service if you wish); that you receive source code or can get -it if you want it; that you can change the software and use pieces of -it in new free programs; and that you are informed that you can do -these things. - - To protect your rights, we need to make restrictions that forbid -distributors to deny you these rights or to ask you to surrender these -rights. These restrictions translate to certain responsibilities for -you if you distribute copies of the library or if you modify it. - - For example, if you distribute copies of the library, whether gratis -or for a fee, you must give the recipients all the rights that we gave -you. You must make sure that they, too, receive or can get the source -code. If you link other code with the library, you must provide -complete object files to the recipients, so that they can relink them -with the library after making changes to the library and recompiling -it. And you must show them these terms so they know their rights. - - We protect your rights with a two-step method: (1) we copyright the -library, and (2) we offer you this license, which gives you legal -permission to copy, distribute and/or modify the library. - - To protect each distributor, we want to make it very clear that -there is no warranty for the free library. Also, if the library is -modified by someone else and passed on, the recipients should know -that what they have is not the original version, so that the original -author's reputation will not be affected by problems that might be -introduced by others. - - Finally, software patents pose a constant threat to the existence of -any free program. We wish to make sure that a company cannot -effectively restrict the users of a free program by obtaining a -restrictive license from a patent holder. Therefore, we insist that -any patent license obtained for a version of the library must be -consistent with the full freedom of use specified in this license. - - Most GNU software, including some libraries, is covered by the -ordinary GNU General Public License. This license, the GNU Lesser -General Public License, applies to certain designated libraries, and -is quite different from the ordinary General Public License. We use -this license for certain libraries in order to permit linking those -libraries into non-free programs. - - When a program is linked with a library, whether statically or using -a shared library, the combination of the two is legally speaking a -combined work, a derivative of the original library. The ordinary -General Public License therefore permits such linking only if the -entire combination fits its criteria of freedom. The Lesser General -Public License permits more lax criteria for linking other code with -the library. - - We call this license the "Lesser" General Public License because it -does Less to protect the user's freedom than the ordinary General -Public License. It also provides other free software developers Less -of an advantage over competing non-free programs. These disadvantages -are the reason we use the ordinary General Public License for many -libraries. However, the Lesser license provides advantages in certain -special circumstances. - - For example, on rare occasions, there may be a special need to -encourage the widest possible use of a certain library, so that it -becomes a de-facto standard. To achieve this, non-free programs must -be allowed to use the library. A more frequent case is that a free -library does the same job as widely used non-free libraries. In this -case, there is little to gain by limiting the free library to free -software only, so we use the Lesser General Public License. - - In other cases, permission to use a particular library in non-free -programs enables a greater number of people to use a large body of -free software. For example, permission to use the GNU C Library in -non-free programs enables many more people to use the whole GNU -operating system, as well as its variant, the GNU/Linux operating -system. - - Although the Lesser General Public License is Less protective of the -users' freedom, it does ensure that the user of a program that is -linked with the Library has the freedom and the wherewithal to run -that program using a modified version of the Library. - - The precise terms and conditions for copying, distribution and -modification follow. Pay close attention to the difference between a -"work based on the library" and a "work that uses the library". The -former contains code derived from the library, whereas the latter must -be combined with the library in order to run. - - GNU LESSER GENERAL PUBLIC LICENSE - TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION - - 0. This License Agreement applies to any software library or other -program which contains a notice placed by the copyright holder or -other authorized party saying it may be distributed under the terms of -this Lesser General Public License (also called "this License"). -Each licensee is addressed as "you". - - A "library" means a collection of software functions and/or data -prepared so as to be conveniently linked with application programs -(which use some of those functions and data) to form executables. - - The "Library", below, refers to any such software library or work -which has been distributed under these terms. A "work based on the -Library" means either the Library or any derivative work under -copyright law: that is to say, a work containing the Library or a -portion of it, either verbatim or with modifications and/or translated -straightforwardly into another language. (Hereinafter, translation is -included without limitation in the term "modification".) - - "Source code" for a work means the preferred form of the work for -making modifications to it. For a library, complete source code means -all the source code for all modules it contains, plus any associated -interface definition files, plus the scripts used to control -compilation and installation of the library. - - Activities other than copying, distribution and modification are not -covered by this License; they are outside its scope. The act of -running a program using the Library is not restricted, and output from -such a program is covered only if its contents constitute a work based -on the Library (independent of the use of the Library in a tool for -writing it). Whether that is true depends on what the Library does -and what the program that uses the Library does. - - 1. You may copy and distribute verbatim copies of the Library's -complete source code as you receive it, in any medium, provided that -you conspicuously and appropriately publish on each copy an -appropriate copyright notice and disclaimer of warranty; keep intact -all the notices that refer to this License and to the absence of any -warranty; and distribute a copy of this License along with the -Library. - - You may charge a fee for the physical act of transferring a copy, -and you may at your option offer warranty protection in exchange for a -fee. - - 2. You may modify your copy or copies of the Library or any portion -of it, thus forming a work based on the Library, and copy and -distribute such modifications or work under the terms of Section 1 -above, provided that you also meet all of these conditions: - - a) The modified work must itself be a software library. - - b) You must cause the files modified to carry prominent notices - stating that you changed the files and the date of any change. - - c) You must cause the whole of the work to be licensed at no - charge to all third parties under the terms of this License. - - d) If a facility in the modified Library refers to a function or a - table of data to be supplied by an application program that uses - the facility, other than as an argument passed when the facility - is invoked, then you must make a good faith effort to ensure that, - in the event an application does not supply such function or - table, the facility still operates, and performs whatever part of - its purpose remains meaningful. - - (For example, a function in a library to compute square roots has - a purpose that is entirely well-defined independent of the - application. Therefore, Subsection 2d requires that any - application-supplied function or table used by this function must - be optional: if the application does not supply it, the square - root function must still compute square roots.) - -These requirements apply to the modified work as a whole. If -identifiable sections of that work are not derived from the Library, -and can be reasonably considered independent and separate works in -themselves, then this License, and its terms, do not apply to those -sections when you distribute them as separate works. But when you -distribute the same sections as part of a whole which is a work based -on the Library, the distribution of the whole must be on the terms of -this License, whose permissions for other licensees extend to the -entire whole, and thus to each and every part regardless of who wrote -it. - -Thus, it is not the intent of this section to claim rights or contest -your rights to work written entirely by you; rather, the intent is to -exercise the right to control the distribution of derivative or -collective works based on the Library. - -In addition, mere aggregation of another work not based on the Library -with the Library (or with a work based on the Library) on a volume of -a storage or distribution medium does not bring the other work under -the scope of this License. - - 3. You may opt to apply the terms of the ordinary GNU General Public -License instead of this License to a given copy of the Library. To do -this, you must alter all the notices that refer to this License, so -that they refer to the ordinary GNU General Public License, version 2, -instead of to this License. (If a newer version than version 2 of the -ordinary GNU General Public License has appeared, then you can specify -that version instead if you wish.) Do not make any other change in -these notices. - - Once this change is made in a given copy, it is irreversible for -that copy, so the ordinary GNU General Public License applies to all -subsequent copies and derivative works made from that copy. - - This option is useful when you wish to copy part of the code of -the Library into a program that is not a library. - - 4. You may copy and distribute the Library (or a portion or -derivative of it, under Section 2) in object code or executable form -under the terms of Sections 1 and 2 above provided that you accompany -it with the complete corresponding machine-readable source code, which -must be distributed under the terms of Sections 1 and 2 above on a -medium customarily used for software interchange. - - If distribution of object code is made by offering access to copy -from a designated place, then offering equivalent access to copy the -source code from the same place satisfies the requirement to -distribute the source code, even though third parties are not -compelled to copy the source along with the object code. - - 5. A program that contains no derivative of any portion of the -Library, but is designed to work with the Library by being compiled or -linked with it, is called a "work that uses the Library". Such a -work, in isolation, is not a derivative work of the Library, and -therefore falls outside the scope of this License. - - However, linking a "work that uses the Library" with the Library -creates an executable that is a derivative of the Library (because it -contains portions of the Library), rather than a "work that uses the -library". The executable is therefore covered by this License. -Section 6 states terms for distribution of such executables. - - When a "work that uses the Library" uses material from a header file -that is part of the Library, the object code for the work may be a -derivative work of the Library even though the source code is not. -Whether this is true is especially significant if the work can be -linked without the Library, or if the work is itself a library. The -threshold for this to be true is not precisely defined by law. - - If such an object file uses only numerical parameters, data -structure layouts and accessors, and small macros and small inline -functions (ten lines or less in length), then the use of the object -file is unrestricted, regardless of whether it is legally a derivative -work. (Executables containing this object code plus portions of the -Library will still fall under Section 6.) - - Otherwise, if the work is a derivative of the Library, you may -distribute the object code for the work under the terms of Section 6. -Any executables containing that work also fall under Section 6, -whether or not they are linked directly with the Library itself. - - 6. As an exception to the Sections above, you may also combine or -link a "work that uses the Library" with the Library to produce a -work containing portions of the Library, and distribute that work -under terms of your choice, provided that the terms permit -modification of the work for the customer's own use and reverse -engineering for debugging such modifications. - - You must give prominent notice with each copy of the work that the -Library is used in it and that the Library and its use are covered by -this License. You must supply a copy of this License. If the work -during execution displays copyright notices, you must include the -copyright notice for the Library among them, as well as a reference -directing the user to the copy of this License. Also, you must do one -of these things: - - a) Accompany the work with the complete corresponding - machine-readable source code for the Library including whatever - changes were used in the work (which must be distributed under - Sections 1 and 2 above); and, if the work is an executable linked - with the Library, with the complete machine-readable "work that - uses the Library", as object code and/or source code, so that the - user can modify the Library and then relink to produce a modified - executable containing the modified Library. (It is understood - that the user who changes the contents of definitions files in the - Library will not necessarily be able to recompile the application - to use the modified definitions.) - - b) Use a suitable shared library mechanism for linking with the - Library. A suitable mechanism is one that (1) uses at run time a - copy of the library already present on the user's computer system, - rather than copying library functions into the executable, and (2) - will operate properly with a modified version of the library, if - the user installs one, as long as the modified version is - interface-compatible with the version that the work was made with. - - c) Accompany the work with a written offer, valid for at least - three years, to give the same user the materials specified in - Subsection 6a, above, for a charge no more than the cost of - performing this distribution. - - d) If distribution of the work is made by offering access to copy - from a designated place, offer equivalent access to copy the above - specified materials from the same place. - - e) Verify that the user has already received a copy of these - materials or that you have already sent this user a copy. - - For an executable, the required form of the "work that uses the -Library" must include any data and utility programs needed for -reproducing the executable from it. However, as a special exception, -the materials to be distributed need not include anything that is -normally distributed (in either source or binary form) with the major -components (compiler, kernel, and so on) of the operating system on -which the executable runs, unless that component itself accompanies -the executable. - - It may happen that this requirement contradicts the license -restrictions of other proprietary libraries that do not normally -accompany the operating system. Such a contradiction means you cannot -use both them and the Library together in an executable that you -distribute. - - 7. You may place library facilities that are a work based on the -Library side-by-side in a single library together with other library -facilities not covered by this License, and distribute such a combined -library, provided that the separate distribution of the work based on -the Library and of the other library facilities is otherwise -permitted, and provided that you do these two things: - - a) Accompany the combined library with a copy of the same work - based on the Library, uncombined with any other library - facilities. This must be distributed under the terms of the - Sections above. - - b) Give prominent notice with the combined library of the fact - that part of it is a work based on the Library, and explaining - where to find the accompanying uncombined form of the same work. - - 8. You may not copy, modify, sublicense, link with, or distribute -the Library except as expressly provided under this License. Any -attempt otherwise to copy, modify, sublicense, link with, or -distribute the Library is void, and will automatically terminate your -rights under this License. However, parties who have received copies, -or rights, from you under this License will not have their licenses -terminated so long as such parties remain in full compliance. - - 9. You are not required to accept this License, since you have not -signed it. However, nothing else grants you permission to modify or -distribute the Library or its derivative works. These actions are -prohibited by law if you do not accept this License. Therefore, by -modifying or distributing the Library (or any work based on the -Library), you indicate your acceptance of this License to do so, and -all its terms and conditions for copying, distributing or modifying -the Library or works based on it. - - 10. Each time you redistribute the Library (or any work based on the -Library), the recipient automatically receives a license from the -original licensor to copy, distribute, link with or modify the Library -subject to these terms and conditions. You may not impose any further -restrictions on the recipients' exercise of the rights granted herein. -You are not responsible for enforcing compliance by third parties with -this License. - - 11. If, as a consequence of a court judgment or allegation of patent -infringement or for any other reason (not limited to patent issues), -conditions are imposed on you (whether by court order, agreement or -otherwise) that contradict the conditions of this License, they do not -excuse you from the conditions of this License. If you cannot -distribute so as to satisfy simultaneously your obligations under this -License and any other pertinent obligations, then as a consequence you -may not distribute the Library at all. For example, if a patent -license would not permit royalty-free redistribution of the Library by -all those who receive copies directly or indirectly through you, then -the only way you could satisfy both it and this License would be to -refrain entirely from distribution of the Library. - -If any portion of this section is held invalid or unenforceable under -any particular circumstance, the balance of the section is intended to -apply, and the section as a whole is intended to apply in other -circumstances. - -It is not the purpose of this section to induce you to infringe any -patents or other property right claims or to contest validity of any -such claims; this section has the sole purpose of protecting the -integrity of the free software distribution system which is -implemented by public license practices. Many people have made -generous contributions to the wide range of software distributed -through that system in reliance on consistent application of that -system; it is up to the author/donor to decide if he or she is willing -to distribute software through any other system and a licensee cannot -impose that choice. - -This section is intended to make thoroughly clear what is believed to -be a consequence of the rest of this License. - - 12. If the distribution and/or use of the Library is restricted in -certain countries either by patents or by copyrighted interfaces, the -original copyright holder who places the Library under this License -may add an explicit geographical distribution limitation excluding those -countries, so that distribution is permitted only in or among -countries not thus excluded. In such case, this License incorporates -the limitation as if written in the body of this License. - - 13. The Free Software Foundation may publish revised and/or new -versions of the Lesser General Public License from time to time. -Such new versions will be similar in spirit to the present version, -but may differ in detail to address new problems or concerns. - -Each version is given a distinguishing version number. If the Library -specifies a version number of this License which applies to it and -"any later version", you have the option of following the terms and -conditions either of that version or of any later version published by -the Free Software Foundation. If the Library does not specify a -license version number, you may choose any version ever published by -the Free Software Foundation. - - 14. If you wish to incorporate parts of the Library into other free -programs whose distribution conditions are incompatible with these, -write to the author to ask for permission. For software which is -copyrighted by the Free Software Foundation, write to the Free -Software Foundation; we sometimes make exceptions for this. Our -decision will be guided by the two goals of preserving the free status -of all derivatives of our free software and of promoting the sharing -and reuse of software generally. - - NO WARRANTY - - 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO -WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. -EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR -OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY -KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE -IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE -LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME -THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. - - 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN -WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY -AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU -FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR -CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE -LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING -RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A -FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF -SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH -DAMAGES. - - END OF TERMS AND CONDITIONS - - How to Apply These Terms to Your New Libraries - - If you develop a new library, and you want it to be of the greatest -possible use to the public, we recommend making it free software that -everyone can redistribute and change. You can do so by permitting -redistribution under these terms (or, alternatively, under the terms -of the ordinary General Public License). - - To apply these terms, attach the following notices to the library. -It is safest to attach them to the start of each source file to most -effectively convey the exclusion of warranty; and each file should -have at least the "copyright" line and a pointer to where the full -notice is found. - - - - Copyright (C) - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - -Also add information on how to contact you by electronic and paper mail. - -You should also get your employer (if you work as a programmer) or -your school, if any, to sign a "copyright disclaimer" for the library, -if necessary. Here is a sample; alter the names: - - Yoyodyne, Inc., hereby disclaims all copyright interest in the - library `Frob' (a library for tweaking knobs) written by James - Random Hacker. - - , 1 April 1990 - Ty Coon, President of Vice - -That's all there is to it! - - diff --git a/src/phonon/NOTE b/src/phonon/NOTE deleted file mode 100644 index acd25a2bd..000000000 --- a/src/phonon/NOTE +++ /dev/null @@ -1,2 +0,0 @@ -This is Git checkout 40cb0c510bed119fc054cb68807e321a584bdaea -from git://anongit.kde.org/phonon.git that has been modified to fit our needs. diff --git a/src/phonon/abstractaudiooutput.cpp b/src/phonon/abstractaudiooutput.cpp deleted file mode 100644 index d88c090c2..000000000 --- a/src/phonon/abstractaudiooutput.cpp +++ /dev/null @@ -1,47 +0,0 @@ -/* This file is part of the KDE project -Copyright (C) 2005-2006 Matthias Kretz - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), Nokia Corporation - (or its successors, if any) and the KDE Free Qt Foundation, which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . - -*/ -#include "abstractaudiooutput.h" -#include "abstractaudiooutput_p.h" -#include "factory_p.h" - -#define PHONON_CLASSNAME AbstractAudioOutput - -namespace Phonon -{ - - AbstractAudioOutput::AbstractAudioOutput(AbstractAudioOutputPrivate &dd, QObject *parent) : QObject(parent), - MediaNode(dd) - { - } - - AbstractAudioOutput::~AbstractAudioOutput() - { - } - -} //namespace Phonon - -#undef PHONON_CLASSNAME - -#include "moc_abstractaudiooutput.cpp" - -// vim: sw=4 ts=4 tw=80 -#include "moc_abstractaudiooutput.h" diff --git a/src/phonon/abstractaudiooutput.h b/src/phonon/abstractaudiooutput.h deleted file mode 100644 index 7e1aa8609..000000000 --- a/src/phonon/abstractaudiooutput.h +++ /dev/null @@ -1,53 +0,0 @@ -/* This file is part of the KDE project -Copyright (C) 2005-2006 Matthias Kretz - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), Nokia Corporation - (or its successors, if any) and the KDE Free Qt Foundation, which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . - -*/ -#ifndef Phonon_ABSTRACTAUDIOOUTPUTBASE_H -#define Phonon_ABSTRACTAUDIOOUTPUTBASE_H - -#include "phonondefs.h" -#include "phonon_export.h" -#include "medianode.h" -#include - - -namespace Phonon -{ - class AbstractAudioOutputPrivate; - - /** \class AbstractAudioOutput abstractaudiooutput.h phonon/AbstractAudioOutput - * Common base class for all audio outputs. - * - * \see AudioOutput - */ - class PHONON_EXPORT AbstractAudioOutput : public QObject, public MediaNode - { - Q_OBJECT - P_DECLARE_PRIVATE(AbstractAudioOutput) - protected: - AbstractAudioOutput(AbstractAudioOutputPrivate &dd, QObject *parent); - public: - ~AbstractAudioOutput(); - }; -} //namespace Phonon - - -// vim: sw=4 ts=4 tw=80 -#endif // Phonon_ABSTRACTAUDIOOUTPUTBASE_H diff --git a/src/phonon/abstractaudiooutput_p.cpp b/src/phonon/abstractaudiooutput_p.cpp deleted file mode 100644 index 5a157f093..000000000 --- a/src/phonon/abstractaudiooutput_p.cpp +++ /dev/null @@ -1,40 +0,0 @@ -/* This file is part of the KDE project - Copyright (C) 2007 Matthias Kretz - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), Nokia Corporation - (or its successors, if any) and the KDE Free Qt Foundation, which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . - -*/ - -#include "abstractaudiooutput_p.h" - -namespace Phonon -{ - -bool AbstractAudioOutputPrivate::aboutToDeleteBackendObject() -{ - return true; -} - -void AbstractAudioOutputPrivate::setupBackendObject() -{ - Q_ASSERT(m_backendObject); - - // set up attributes -} - -} // namespace Phonon diff --git a/src/phonon/abstractaudiooutput_p.h b/src/phonon/abstractaudiooutput_p.h deleted file mode 100644 index 278aa0a23..000000000 --- a/src/phonon/abstractaudiooutput_p.h +++ /dev/null @@ -1,46 +0,0 @@ -/* This file is part of the KDE project - Copyright (C) 2006 Matthias Kretz - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), Nokia Corporation - (or its successors, if any) and the KDE Free Qt Foundation, which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . - -*/ - -#ifndef PHONON_ABSTRACTAUDIOOUTPUT_P_H -#define PHONON_ABSTRACTAUDIOOUTPUT_P_H - -#include "abstractaudiooutput.h" -#include "medianode_p.h" -#include "phonondefs_p.h" - -namespace Phonon -{ -class AbstractAudioOutputPrivate : public MediaNodePrivate -{ - P_DECLARE_PUBLIC(AbstractAudioOutput) - PHONON_PRIVATEABSTRACTCLASS - public: - virtual QObject *qObject() { return q_func(); } - protected: - AbstractAudioOutputPrivate(CastId castId = AbstractAudioOutputPrivateType) - : MediaNodePrivate(castId) - { - } -}; -} //namespace Phonon - -#endif // PHONON_ABSTRACTAUDIOOUTPUT_P_H diff --git a/src/phonon/abstractmediastream.cpp b/src/phonon/abstractmediastream.cpp deleted file mode 100644 index 373f52d9b..000000000 --- a/src/phonon/abstractmediastream.cpp +++ /dev/null @@ -1,195 +0,0 @@ -/* This file is part of the KDE project - Copyright (C) 2007 Matthias Kretz - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), Nokia Corporation - (or its successors, if any) and the KDE Free Qt Foundation, which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . - -*/ - -#include "abstractmediastream.h" -#include "abstractmediastream_p.h" -#include "mediaobjectinterface.h" -#include "mediaobject_p.h" -#include "phonondefs_p.h" -#include "streaminterface_p.h" - -#ifndef QT_NO_PHONON_ABSTRACTMEDIASTREAM - -namespace Phonon -{ - -AbstractMediaStream::AbstractMediaStream(QObject *parent) - : QObject(parent), - d_ptr(new AbstractMediaStreamPrivate) -{ - d_ptr->q_ptr = this; -} - -AbstractMediaStream::AbstractMediaStream(AbstractMediaStreamPrivate &dd, QObject *parent) - : QObject(parent), - d_ptr(&dd) -{ - d_ptr->q_ptr = this; -} - -AbstractMediaStream::~AbstractMediaStream() -{ -} - -qint64 AbstractMediaStream::streamSize() const -{ - return d_ptr->streamSize; -} - -void AbstractMediaStream::setStreamSize(qint64 newSize) -{ - d_ptr->setStreamSize(newSize); -} - -void AbstractMediaStreamPrivate::setStreamSize(qint64 newSize) -{ - streamSize = newSize; - if (streamInterface) { - streamInterface->setStreamSize(newSize); - } -} - -bool AbstractMediaStream::streamSeekable() const -{ - return d_ptr->streamSeekable; -} - -void AbstractMediaStream::setStreamSeekable(bool s) -{ - d_ptr->setStreamSeekable(s); -} - -void AbstractMediaStreamPrivate::setStreamSeekable(bool s) -{ - streamSeekable = s; - if (streamInterface) { - streamInterface->setStreamSeekable(s); - } -} - -void AbstractMediaStream::writeData(const QByteArray &data) -{ - d_ptr->writeData(data); -} - -void AbstractMediaStreamPrivate::writeData(const QByteArray &data) -{ - if (ignoreWrites) { - return; - } - Q_ASSERT(streamInterface); - streamInterface->writeData(data); -} - -void AbstractMediaStream::endOfData() -{ - d_ptr->endOfData(); -} - -void AbstractMediaStreamPrivate::endOfData() -{ - if (streamInterface) { - streamInterface->endOfData(); - } -} - -void AbstractMediaStream::error(Phonon::ErrorType type, const QString &text) -{ - Q_D(AbstractMediaStream); - d->errorType = type; - d->errorText = text; - if (d->mediaObjectPrivate) { - // TODO: MediaObject might be in a different thread - d->mediaObjectPrivate->streamError(type, text); - } -} - -void AbstractMediaStream::enoughData() -{ -} - -void AbstractMediaStream::seekStream(qint64) -{ - Q_ASSERT(!d_ptr->streamSeekable); -} - -AbstractMediaStreamPrivate::~AbstractMediaStreamPrivate() -{ - if (mediaObjectPrivate) { - // TODO: MediaObject might be in a different thread - mediaObjectPrivate->removeDestructionHandler(this); - } - if (streamInterface) { - // TODO: StreamInterface might be in a different thread - streamInterface->d->disconnectMediaStream(); - } -} - -void AbstractMediaStreamPrivate::setStreamInterface(StreamInterface *iface) -{ - P_Q(AbstractMediaStream); - streamInterface = iface; - if (!iface) { - // our subclass might be just about to call writeData, so tell it we have enoughData and - // ignore the next writeData calls - q->enoughData(); - ignoreWrites = true; - return; - } - if (ignoreWrites) { - ignoreWrites = false; - // we had a StreamInterface before. The new StreamInterface expects us to start reading from - // position 0 - q->reset(); - } else { - iface->setStreamSize(streamSize); - iface->setStreamSeekable(streamSeekable); - } -} - -void AbstractMediaStreamPrivate::setMediaObjectPrivate(MediaObjectPrivate *mop) -{ - // TODO: MediaObject might be in a different thread - mediaObjectPrivate = mop; - mediaObjectPrivate->addDestructionHandler(this); - if (!errorText.isEmpty()) { - mediaObjectPrivate->streamError(errorType, errorText); - } -} - -void AbstractMediaStreamPrivate::phononObjectDestroyed(MediaNodePrivate *bp) -{ - // TODO: MediaObject might be in a different thread - Q_ASSERT(bp == mediaObjectPrivate); - Q_UNUSED(bp); - mediaObjectPrivate = 0; -} - -} // namespace Phonon - - -#include "moc_abstractmediastream.cpp" - -#endif //QT_NO_PHONON_ABSTRACTMEDIASTREAM - -// vim: sw=4 sts=4 et tw=100 -#include "moc_abstractmediastream.h" diff --git a/src/phonon/abstractmediastream.h b/src/phonon/abstractmediastream.h deleted file mode 100644 index b964b1183..000000000 --- a/src/phonon/abstractmediastream.h +++ /dev/null @@ -1,223 +0,0 @@ -/* This file is part of the KDE project - Copyright (C) 2007 Matthias Kretz - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), Nokia Corporation - (or its successors, if any) and the KDE Free Qt Foundation, which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . - -*/ - -#ifndef PHONON_ABSTRACTMEDIASTREAM_H -#define PHONON_ABSTRACTMEDIASTREAM_H - -#include "phonon_export.h" -#include "phononnamespace.h" -#include - - -class QByteArray; - -#ifndef QT_NO_PHONON_ABSTRACTMEDIASTREAM - -namespace Phonon -{ -class MediaObject; -class AbstractMediaStreamPrivate; - -/** \class AbstractMediaStream abstractmediastream.h phonon/AbstractMediaStream - * \brief Base class for custom media data streams. - * - * Implement this class to provide a custom data stream to the backend. The class supports both, the - * push and the pull model. - * - * Push: - * \code - * PushStream::PushStream(QObject *parent) - * : AbstractMediaStream(parent), m_timer(new QTimer(this)) - * { - * setStreamSize(getMediaStreamSize()); - * - * connect(m_timer, SIGNAL(timeout()), SLOT(moreData())); - * m_timer->setInterval(0); - * } - * - * void PushStream::moreData() - * { - * const QByteArray data = getMediaData(); - * if (data.isEmpty()) { - * endOfData(); - * } else { - * writeData(data); - * } - * } - * - * void PushStream::needData() - * { - * m_timer->start(); - * moreData(); - * } - * - * void PushStream::enoughData() - * { - * m_timer->stop(); - * } - * \endcode - * - * Pull: - * \code - * PullStream::PullStream(QObject *parent) - * : AbstractMediaStream(parent) - * { - * setStreamSize(getMediaStreamSize()); - * } - * - * void PullStream::needData() - * { - * const QByteArray data = getMediaData(); - * if (data.isEmpty()) { - * endOfData(); - * } else { - * writeData(data); - * } - * } - * \endcode - * - * \ingroup Playback - * \author Matthias Kretz - */ -class PHONON_EXPORT AbstractMediaStream : public QObject -{ - Q_OBJECT - Q_DECLARE_PRIVATE(AbstractMediaStream) - friend class MediaObject; - friend class MediaObjectPrivate; - friend class StreamInterface; - public: - virtual ~AbstractMediaStream(); - - protected: - /** - * Constructs an AbstractMediaStream object with a \p parent. - */ - explicit AbstractMediaStream(QObject *parent = 0); - - /** - * Returns the stream size that was set with \ref setStreamSize. - * - * A negative value means that the length of the stream cannot be known. - * - * Defaults to \c 0. - */ - qint64 streamSize() const; - - /** - * Sets the size of the stream in number of bytes. - * - * A negative value means that the length of the stream cannot be known. - * - * Defaults to 0. - * - * This function has to be called. A backend will not call \ref needData() until the - * stream size is set. - */ - void setStreamSize(qint64); - - /** - * Returns whether your data stream is set as seekable. - * - * Defaults to \c false. - */ - bool streamSeekable() const; - - /** - * Sets whether your data stream is seekable. - * - * Defaults to \c false. - * - * If you set this to \c true you have to implement the \ref seekStream function. - */ - void setStreamSeekable(bool); - - /** - * Sends the media \p data to the backend for decoding. - * - * \warning Don't call this function before the first needData() is emitted. - */ - void writeData(const QByteArray &data); - - /** - * Tells the backend that the media data stream is at its end. - * - * \warning Don't call this function before the first needData() is emitted. - */ - void endOfData(); - - /** - * If an I/O error occurs you should call this function to make MediaObject go into - * ErrorState. - * - * \see MediaObject::errorType() - * \see MediaObject::errorString() - */ - void error(Phonon::ErrorType errorType, const QString &errorString); - - /** - * Reimplement this function to reset the stream. Subsequent calls to writeData should start - * from the first position of the data unless a seek is requested. - * - * The function is necessary for the case where a non-seekable MediaStream is - * played more than once. For a seekable stream the implementation can simply call - * \code - * seekStream(0); - * \endcode. - */ - Q_INVOKABLE virtual void reset() = 0; - - /** - * Reimplement this function to be notified when the backend needs data. - * - * When this function is called you should try to call writeData or endOfData before - * returning. - */ - Q_INVOKABLE virtual void needData() = 0; - - /** - * Reimplement this function to be notified when the backend has enough data and your stream - * object may take a break. This method is important for pushing data to the backend in - * order to not fill the backend buffer unnecessarily. - */ - Q_INVOKABLE virtual void enoughData(); - - /** - * Reimplement this function if your stream is seekable. - * - * When this function is called the next call to writeData has to be at the requested \p - * offset. - * - * \warning Do not call the parent implementation. - */ - Q_INVOKABLE virtual void seekStream(qint64 offset); - - AbstractMediaStream(AbstractMediaStreamPrivate &dd, QObject *parent); - QScopedPointer d_ptr; -}; - -} // namespace Phonon - -#endif //QT_NO_PHONON_ABSTRACTMEDIASTREAM - - -#endif // PHONON_ABSTRACTMEDIASTREAM_H diff --git a/src/phonon/abstractmediastream_p.h b/src/phonon/abstractmediastream_p.h deleted file mode 100644 index 2d0ba0d8c..000000000 --- a/src/phonon/abstractmediastream_p.h +++ /dev/null @@ -1,79 +0,0 @@ -/* This file is part of the KDE project - Copyright (C) 2007 Matthias Kretz - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), Nokia Corporation - (or its successors, if any) and the KDE Free Qt Foundation, which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . - -*/ - -#ifndef ABSTRACTMEDIASTREAM_P_H -#define ABSTRACTMEDIASTREAM_P_H - -#include "phonon_export.h" -#include "abstractmediastream.h" -#include "mediaobject_p.h" -#include "streaminterface.h" - -#include "medianodedestructionhandler_p.h" - -#ifndef QT_NO_PHONON_ABSTRACTMEDIASTREAM - -class MediaObjectPrivate; - -namespace Phonon -{ -class PHONON_EXPORT AbstractMediaStreamPrivate : private MediaNodeDestructionHandler -{ - friend class MediaObject; - P_DECLARE_PUBLIC(AbstractMediaStream) - public: - void setStreamInterface(StreamInterface *); - void setMediaObjectPrivate(MediaObjectPrivate *); - ~AbstractMediaStreamPrivate(); - - protected: - AbstractMediaStreamPrivate() - : streamSize(0), - streamSeekable(false), - ignoreWrites(false), - streamInterface(0), - mediaObjectPrivate(0), - errorType(NoError) - { - } - - virtual void setStreamSize(qint64 newSize); - virtual void setStreamSeekable(bool s); - virtual void writeData(const QByteArray &data); - virtual void endOfData(); - void phononObjectDestroyed(MediaNodePrivate *); - - AbstractMediaStream *q_ptr; - qint64 streamSize; - bool streamSeekable; - bool ignoreWrites; - StreamInterface *streamInterface; - MediaObjectPrivate *mediaObjectPrivate; - Phonon::ErrorType errorType; - QString errorText; -}; -} // namespace Phonon - -#endif //QT_NO_PHONON_ABSTRACTMEDIASTREAM - -#endif // ABSTRACTMEDIASTREAM_P_H -// vim: sw=4 sts=4 et tw=100 diff --git a/src/phonon/abstractvideooutput.cpp b/src/phonon/abstractvideooutput.cpp deleted file mode 100644 index c4a6974cc..000000000 --- a/src/phonon/abstractvideooutput.cpp +++ /dev/null @@ -1,37 +0,0 @@ -/* This file is part of the KDE project - Copyright (C) 2005 Matthias Kretz - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), Nokia Corporation - (or its successors, if any) and the KDE Free Qt Foundation, which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . - -*/ -#include "abstractvideooutput.h" -#include "abstractvideooutput_p.h" - -#ifndef QT_NO_PHONON_VIDEO - -namespace Phonon -{ - -AbstractVideoOutput::AbstractVideoOutput(AbstractVideoOutputPrivate &d) - : MediaNode(d) -{ -} - -} // namespace Phonon - -#endif //QT_NO_PHONON_VIDEO diff --git a/src/phonon/abstractvideooutput.h b/src/phonon/abstractvideooutput.h deleted file mode 100644 index f4f394c38..000000000 --- a/src/phonon/abstractvideooutput.h +++ /dev/null @@ -1,70 +0,0 @@ -/* This file is part of the KDE project - Copyright (C) 2005-2006 Matthias Kretz - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), Nokia Corporation - (or its successors, if any) and the KDE Free Qt Foundation, which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . - -*/ -#ifndef Phonon_ABSTRACTVIDEOOUTPUTBASE_H -#define Phonon_ABSTRACTVIDEOOUTPUTBASE_H - -#include "phonondefs.h" -#include "phonon_export.h" -#include "medianode.h" -#include - - -#ifndef QT_NO_PHONON_VIDEO - -class QString; - -namespace Phonon -{ - -namespace Experimental -{ - class Visualization; - class VisualizationPrivate; -} // namespace Experimental - - class AbstractVideoOutputPrivate; - - /** \class AbstractVideoOutput abstractvideooutput.h phonon/AbstractVideoOutput - * \brief Common base class for all video outputs. - * - * \see VideoWidget - */ - class PHONON_EXPORT AbstractVideoOutput : public MediaNode - { - friend class Experimental::Visualization; - friend class Experimental::VisualizationPrivate; - P_DECLARE_PRIVATE(AbstractVideoOutput) - protected: - /** - * \internal - * Constructor that is called from derived classes. - * - * \param d the private object - */ - AbstractVideoOutput(AbstractVideoOutputPrivate &d); - }; -} //namespace Phonon - -#endif //QT_NO_PHONON_VIDEO - - -#endif // Phonon_ABSTRACTVIDEOOUTPUTBASE_H diff --git a/src/phonon/abstractvideooutput_p.cpp b/src/phonon/abstractvideooutput_p.cpp deleted file mode 100644 index d98a8e155..000000000 --- a/src/phonon/abstractvideooutput_p.cpp +++ /dev/null @@ -1,37 +0,0 @@ -/* This file is part of the KDE project - Copyright (C) 2007 Matthias Kretz - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), Nokia Corporation - (or its successors, if any) and the KDE Free Qt Foundation, which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . - -*/ - -#include "abstractvideooutput_p.h" - -#ifndef QT_NO_PHONON_VIDEO - -namespace Phonon -{ - -bool AbstractVideoOutputPrivate::aboutToDeleteBackendObject() -{ - return true; -} - -} //namespace Phonon - -#endif //QT_NO_PHONON_VIDEO diff --git a/src/phonon/abstractvideooutput_p.h b/src/phonon/abstractvideooutput_p.h deleted file mode 100644 index 2213a3c9a..000000000 --- a/src/phonon/abstractvideooutput_p.h +++ /dev/null @@ -1,44 +0,0 @@ -/* This file is part of the KDE project - Copyright (C) 2006 Matthias Kretz - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), Nokia Corporation - (or its successors, if any) and the KDE Free Qt Foundation, which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . - -*/ - -#ifndef ABSTRACTVIDEOOUTPUT_P_H -#define ABSTRACTVIDEOOUTPUT_P_H - -#include "abstractvideooutput.h" -#include "medianode_p.h" -#include "phonondefs_p.h" - -#ifndef QT_NO_PHONON_VIDEO - -namespace Phonon -{ -class AbstractVideoOutputPrivate : public MediaNodePrivate -{ - P_DECLARE_PUBLIC(AbstractVideoOutput) - PHONON_PRIVATEABSTRACTCLASS -}; -} //namespace Phonon - -#endif //QT_NO_PHONON_VIDEO - -#endif // ABSTRACTVIDEOOUTPUT_P_H -// vim: sw=4 ts=4 tw=80 diff --git a/src/phonon/addoninterface.h b/src/phonon/addoninterface.h deleted file mode 100644 index cc86c3833..000000000 --- a/src/phonon/addoninterface.h +++ /dev/null @@ -1,181 +0,0 @@ -/* This file is part of the KDE project - Copyright (C) 2007-2008 Matthias Kretz - Copyright (C) 2011 Harald Sitter - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), Nokia Corporation - (or its successors, if any) and the KDE Free Qt Foundation, which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . - -*/ - -#ifndef PHONON_ADDONINTERFACE_H -#define PHONON_ADDONINTERFACE_H - -#include "phononnamespace.h" - -#include -#include - - -#ifndef QT_NO_PHONON_MEDIACONTROLLER - -namespace Phonon -{ -/** \class AddonInterface addoninterface.h phonon/AddonInterface - * \short Interface for Menu, Chapter, Angle and Title/Track control. - * - * \author Matthias Kretz - */ -class AddonInterface -{ - public: - virtual ~AddonInterface() {} - - enum Interface { - NavigationInterface = 1, /**< Interface for (menu) navigation */ - ChapterInterface = 2, /**< Interface for chapter control */ - AngleInterface = 3, /**< Interface for angle control */ - TitleInterface = 4, /**< Interface for title control */ - SubtitleInterface = 5, /**< Interface for subtitle control */ - AudioChannelInterface = 6 /**< Interface for audio channel control */ - }; - - enum NavigationCommand { - availableMenus, /**< \returns a QList - containing all supported navigation menu types */ - setMenu /**< Sets the current menu to the first - \c MediaController::NavigationMenu in a QList */ - }; - - enum ChapterCommand { - availableChapters, /**< \returns an \c int representing the amount of - available chapters on the media source */ - chapter, /**< \returns an \c int representing the current chapter */ - setChapter /**< Sets the current chapter to the first \c int in the QList */ - }; - - enum AngleCommand { - availableAngles, /**< \returns \c int representing the amount of - available angles on the media source */ - angle, /**< \returns an \c int representing the current angle */ - setAngle /**< Sets the current angle to the first \c int in the QList */ - }; - - enum TitleCommand { - availableTitles, /**< \returns \c int representing the amount of - available titles on the media source */ - title, /**< \returns \c int representing the current title */ - setTitle, /**< Sets the current tittle to the first \c int in the QList */ - autoplayTitles, /**< \returns \c bool whether autoplay of titles is on */ - setAutoplayTitles /**< Sets autoplay to \c true or \c false as - indicated in the first \c bool in the QList */ - }; - - enum SubtitleCommand { - availableSubtitles, /**< \returns \c int representing the amount of - available subtitles on the media source */ - currentSubtitle, /**< \returns \c int representing the current subtitle */ - setCurrentSubtitle, /**< Sets the current subtitle to the first - \c int in the QList */ - setCurrentSubtitleFile, /**< Sets the current subtitle to the first QUrl \since 4.7.0 */ - subtitleAutodetect, /**< \returns \c bool representing if subtitles - autodetection is enabled \since 4.7.0 */ - setSubtitleAutodetect, /**< Sets/Unsets subtitles autodetection \since 4.7.0 */ - subtitleEncoding, /**< \returns a QString representing the current encoding - used to render subtitles \since 4.7.0 */ - setSubtitleEncoding, /** Sets the current encoding used to render subtitles \since 4.7.0 */ - subtitleFont, /**< \returns a QFont representing the current font used - to render subtitles \since 4.7.0 */ - setSubtitleFont /**< Sets the current font used to render subtitles \since 4.7.0 */ - }; - - enum AudioChannelCommand { - availableAudioChannels, /**< \returns \c int representing the amount - of all available audio channels on the - media source */ - currentAudioChannel, /**< \returns \c int representing the current - audio channel */ - setCurrentAudioChannel /**< Sets the current audio channel to the first - \c int in the QList */ - }; - - /** - * Queries whether the backend supports a specific interface. - * - * \param iface The interface to query support information about - * \returns \c true when the backend supports the interface, \c false otherwise - * - * \ingroup backend - **/ - virtual bool hasInterface(Interface iface) const = 0; - - /** - * Calls an interface on the backend. - * - * \param iface The interface to call. - * \param command The command the interface shall execute. This can be - * any value of the Command enumeration associated with the command. The - * backend casts this appropriately. - * \param arguments The arguments for the command. This list can contain - * a QVariant supported format + additions specific to Phonon. The - * content entirely depends on the command (e.g. a getter may simply use - * an empty list). - * - * \return \c QVariant, as with the arguments this can be anything ranging - * from an empty QVariant to custom types used within Phonon - * - * Setting the chapter of a Media could be done like this: - * \code - * AddonInterface *iface = d->iface(); - * iface->interfaceCall(AddonInterface::ChapterInterface, - * AddonInterface::setChapter, - * QList() << QVariant(titleNumber)); - * \endcode - * - * Handling such a request in the backend is done as follows: - * \code - * switch (iface) { - * case AddonInterface::ChapterInterface: - * switch (static_cast(command)) { - * case setChapter: - * setCurrentChapter(arguments.first().toInt()); - * return QVariant(); - * } - * } - * \endcode - * - * \see Interface - * \see NavigationCommand - * \see ChapterCommand - * \see AngleCommand - * \see TitleCommand - * \see SubtitleCommand - * \see AudioChannelCommand - * - * \ingroup backend - **/ - virtual QVariant interfaceCall(Interface iface, int command, - const QList &arguments = QList()) = 0; -}; - -} // namespace Phonon - -Q_DECLARE_INTERFACE(Phonon::AddonInterface, "AddonInterface0.2.phonon.kde.org") - -#endif //QT_NO_PHONON_MEDIACONTROLLER - - -#endif // PHONON_ADDONINTERFACE_H diff --git a/src/phonon/audiodataoutput.cpp b/src/phonon/audiodataoutput.cpp deleted file mode 100644 index f7b1c05d0..000000000 --- a/src/phonon/audiodataoutput.cpp +++ /dev/null @@ -1,68 +0,0 @@ -/* This file is part of the KDE project - Copyright (C) 2005 Matthias Kretz - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), Nokia Corporation - (or its successors, if any) and the KDE Free Qt Foundation, which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . - -*/ - -#include "audiodataoutput.h" -#include "audiodataoutput_p.h" -#include "factory_p.h" - -#define PHONON_CLASSNAME AudioDataOutput - -namespace Phonon -{ - -PHONON_HEIR_IMPL(AbstractAudioOutput) - -PHONON_GETTER(int, dataSize, d->dataSize) -PHONON_GETTER(int, sampleRate, -1) -PHONON_SETTER(setDataSize, dataSize, int) - -bool AudioDataOutputPrivate::aboutToDeleteBackendObject() -{ - Q_ASSERT(m_backendObject); - pBACKEND_GET(int, dataSize, "dataSize"); - - return AbstractAudioOutputPrivate::aboutToDeleteBackendObject(); -} - -void AudioDataOutputPrivate::setupBackendObject() -{ - P_Q(AudioDataOutput); - Q_ASSERT(m_backendObject); - AbstractAudioOutputPrivate::setupBackendObject(); - - // set up attributes - pBACKEND_CALL1("setDataSize", int, dataSize); - - qRegisterMetaType > >("QMap >"); - - QObject::connect(m_backendObject, - SIGNAL(dataReady(QMap >)), - q, SIGNAL(dataReady(QMap >))); - QObject::connect(m_backendObject, SIGNAL(endOfMedia(int)), q, SIGNAL(endOfMedia(int))); -} - -} // namespace Phonon - -#undef PHONON_CLASSNAME - -// vim: sw=4 ts=4 tw=80 -#include "moc_audiodataoutput.h" diff --git a/src/phonon/audiodataoutput.h b/src/phonon/audiodataoutput.h deleted file mode 100644 index 909261b21..000000000 --- a/src/phonon/audiodataoutput.h +++ /dev/null @@ -1,131 +0,0 @@ -/* This file is part of the KDE project - Copyright (C) 2005-2006 Matthias Kretz - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), Nokia Corporation - (or its successors, if any) and the KDE Free Qt Foundation, which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . - -*/ -#ifndef Phonon_AUDIODATAOUTPUT_H -#define Phonon_AUDIODATAOUTPUT_H - -#include "phonon_export.h" -#include "abstractaudiooutput.h" -#include "phonondefs.h" - - -#ifndef DOXYGEN_SHOULD_SKIP_THIS -template class QVector; -template class QMap; -#endif - -namespace Phonon -{ - class AudioDataOutputPrivate; - - /** - * \short This class gives you the audio data (for visualizations). - * - * This class implements a special AbstractAudioOutput that gives your - * application the audio data. Don't expect realtime performance. But - * the latencies should be low enough to use the audio data for - * visualizations. You can also use the audio data for further processing - * (e.g. encoding and saving to a file). - * - * \author Matthias Kretz - */ - class PHONON_EXPORT AudioDataOutput : public AbstractAudioOutput - { - Q_OBJECT - P_DECLARE_PRIVATE(AudioDataOutput) - Q_ENUMS(Channel) - Q_PROPERTY(int dataSize READ dataSize WRITE setDataSize) - PHONON_HEIR(AudioDataOutput) - public: - /** - * Specifies the channel the audio data belongs to. - */ - enum Channel - { - LeftChannel, - RightChannel, - CenterChannel, - LeftSurroundChannel, - RightSurroundChannel, - SubwooferChannel - }; - - /** - * Returns the currently used number of samples passed through - * the signal. - * - * \see setDataSize - */ - int dataSize() const; - - /** - * Returns the sample rate in Hz. Common sample rates are 44100 Hz - * and 48000 Hz. AudioDataOutput will not do any sample rate - * conversion for you. If you need to convert the sample rate you - * might want to take a look at libsamplerate. For visualizations it - * is often enough to do simple interpolation or even drop/duplicate - * samples. - * - * \return The sample rate as reported by the backend. If the - * backend is unavailable -1 is returned. - */ - int sampleRate() const; - - public Q_SLOTS: - /** - * Sets the number of samples to be passed in one signal emission. - * - * Defaults to 512 samples per emitted signal. - * - * \param size the number of samples - */ - void setDataSize(int size); - - Q_SIGNALS: - /** - * Emitted whenever another dataSize number of samples are ready. - * - * \param data A mapping of Channel to a vector holding the audio data. - */ - void dataReady(const QMap > &data); - - - /** - * This signal is emitted before the last dataReady signal of a - * media is emitted. - * - * If, for example, the playback of a media file has finished and the - * last audio data of that file is going to be passed with the next - * dataReady signal, and only the 28 first samples of the data - * vector are from that media file endOfMedia will be emitted right - * before dataReady with \p remainingSamples = 28. - * - * \param remainingSamples The number of samples in the next - * dataReady vector that belong to the media that was playing to - * this point. - */ - void endOfMedia(int remainingSamples); - }; -} // namespace Phonon - - -// vim: sw=4 ts=4 tw=80 -#endif // Phonon_AUDIODATAOUTPUT_H diff --git a/src/phonon/audiodataoutput_p.h b/src/phonon/audiodataoutput_p.h deleted file mode 100644 index 232a570f7..000000000 --- a/src/phonon/audiodataoutput_p.h +++ /dev/null @@ -1,50 +0,0 @@ -/* This file is part of the KDE project - Copyright (C) 2006 Matthias Kretz - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), Nokia Corporation - (or its successors, if any) and the KDE Free Qt Foundation, which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . - -*/ - -#ifndef AUDIODATAOUTPUT_P_H -#define AUDIODATAOUTPUT_P_H - -#include "audiodataoutput.h" -#include "abstractaudiooutput_p.h" - - -namespace Phonon -{ - -class AudioDataOutputPrivate : public AbstractAudioOutputPrivate -{ - P_DECLARE_PUBLIC(AudioDataOutput) - PHONON_PRIVATECLASS - protected: - AudioDataOutputPrivate() - : dataSize(512) - { - } - - int dataSize; -}; - -} // namespace Phonon - - -#endif // AUDIODATAOUTPUT_P_H -// vim: sw=4 ts=4 tw=80 diff --git a/src/phonon/audiodataoutputinterface.h b/src/phonon/audiodataoutputinterface.h deleted file mode 100644 index 722624827..000000000 --- a/src/phonon/audiodataoutputinterface.h +++ /dev/null @@ -1,46 +0,0 @@ -/* This file is part of the KDE project - Copyright (C) 2008 Matthias Kretz - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), Nokia Corporation - (or its successors, if any) and the KDE Free Qt Foundation, which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . - -*/ - -#ifndef PHONON_AUDIODATAOUTPUTINTERFACE_H -#define PHONON_AUDIODATAOUTPUTINTERFACE_H - - -namespace Phonon -{ - -class AudioDataOutput; - -class AudioDataOutputInterface -{ - public: - virtual ~AudioDataOutputInterface() {} - - virtual AudioDataOutput *frontendObject() const = 0; - virtual void setFrontendObject(AudioDataOutput *) = 0; -}; - -} // namespace Phonon - -Q_DECLARE_INTERFACE(Phonon::AudioDataOutputInterface, "0AudioDataOutputInterface.phonon.kde.org") - - -#endif // PHONON_AUDIODATAOUTPUTINTERFACE_H diff --git a/src/phonon/audiooutput.cpp b/src/phonon/audiooutput.cpp deleted file mode 100644 index adf6e39da..000000000 --- a/src/phonon/audiooutput.cpp +++ /dev/null @@ -1,513 +0,0 @@ -/* This file is part of the KDE project - Copyright (C) 2005-2006 Matthias Kretz - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), Nokia Corporation - (or its successors, if any) and the KDE Free Qt Foundation, which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . -*/ - -#include "audiooutput.h" -#include "audiooutput_p.h" - -#include "audiooutputadaptor_p.h" -#include "audiooutputinterface.h" -#include "factory_p.h" -#include "globalconfig.h" -#include "objectdescription.h" -#include "phononconfig_p.h" -#include "phononnamespace_p.h" -#include "platform_p.h" - -#include -#include - -#define PHONON_CLASSNAME AudioOutput -#define IFACES9 AudioOutputInterface49 -#define IFECES7 AudioOutputInterface47 -#define IFACES2 AudioOutputInterface42 -#define IFACES1 IFACES2 -#define IFACES0 AudioOutputInterface40, IFACES1, IFECES7, IFACES9 -#define PHONON_INTERFACENAME IFACES0 - -namespace Phonon -{ - -static inline bool callSetOutputDevice(AudioOutputPrivate *const d, const AudioOutputDevice &dev) -{ - if (!d->backendObject()) - return false; - - Iface iface(d); - if (iface) { - return iface->setOutputDevice(dev); - } - return Iface::cast(d)->setOutputDevice(dev.index()); -} - -AudioOutput::AudioOutput(Phonon::Category category, QObject *parent) - : AbstractAudioOutput(*new AudioOutputPrivate, parent) -{ - P_D(AudioOutput); - d->init(category); -} - -AudioOutput::AudioOutput(QObject *parent) - : AbstractAudioOutput(*new AudioOutputPrivate, parent) -{ - P_D(AudioOutput); - d->init(NoCategory); -} - -void AudioOutputPrivate::init(Phonon::Category c) -{ - P_Q(AudioOutput); -#ifndef PHONON_NO_DBUS - adaptor = new AudioOutputAdaptor(q); - static unsigned int number = 0; - const QString &path = QLatin1String("/AudioOutputs/") + QString::number(number++); - QDBusConnection con = QDBusConnection::sessionBus(); - con.registerObject(path, q); - emit adaptor->newOutputAvailable(con.baseService(), path); - q->connect(q, SIGNAL(volumeChanged(qreal)), adaptor, SIGNAL(volumeChanged(qreal))); - q->connect(q, SIGNAL(mutedChanged(bool)), adaptor, SIGNAL(mutedChanged(bool))); -#endif - - category = c; -#ifndef QT_NO_QUUID_STRING - streamUuid = QUuid::createUuid().toString(); -#endif - - createBackendObject(); - - q->connect(Factory::sender(), SIGNAL(availableAudioOutputDevicesChanged()), SLOT(_k_deviceListChanged())); -} - -QString AudioOutputPrivate::getStreamUuid() -{ - return streamUuid; -} - -void AudioOutputPrivate::createBackendObject() -{ - if (m_backendObject) - return; - P_Q(AudioOutput); - m_backendObject = Factory::createAudioOutput(q); - // (cg) Is it possible that PulseAudio initialisation means that the device here is not valid? - // User reports seem to suggest this possibility but I can't see how :s. - // See other comment and check for isValid() in handleAutomaticDeviceChange() - device = AudioOutputDevice::fromIndex(GlobalConfig().audioOutputDeviceFor(category, GlobalConfig::AdvancedDevicesFromSettings | GlobalConfig::HideUnavailableDevices)); - if (m_backendObject) { - setupBackendObject(); - } -} - -QString AudioOutput::name() const -{ - P_D(const AudioOutput); - return d->name; -} - -void AudioOutput::setName(const QString &newName) -{ - P_D(AudioOutput); - if (d->name == newName) { - return; - } - d->name = newName; - setVolume(Platform::loadVolume(newName)); -#ifndef PHONON_NO_DBUS - if (d->adaptor) { - emit d->adaptor->nameChanged(newName); - } -#endif -} - -static const qreal LOUDNESS_TO_VOLTAGE_EXPONENT = qreal(0.67); -static const qreal VOLTAGE_TO_LOUDNESS_EXPONENT = qreal(1.0/LOUDNESS_TO_VOLTAGE_EXPONENT); - -void AudioOutput::setVolume(qreal volume) -{ - P_D(AudioOutput); - d->volume = volume; - if (k_ptr->backendObject()) { - if (!d->muted) { - // using Stevens' power law loudness is proportional to (sound pressure)^0.67 - // sound pressure is proportional to voltage: - // p² \prop P \prop V² - // => if a factor for loudness of x is requested - INTERFACE_CALL(setVolume(pow(volume, VOLTAGE_TO_LOUDNESS_EXPONENT))); - } else { - emit volumeChanged(volume); - } - } else { - emit volumeChanged(volume); - } - Platform::saveVolume(d->name, volume); -} - -qreal AudioOutput::volume() const -{ - P_D(const AudioOutput); - if (d->muted || !d->m_backendObject) - return d->volume; - return pow(INTERFACE_CALL(volume()), LOUDNESS_TO_VOLTAGE_EXPONENT); -} - -#ifndef PHONON_LOG10OVER20 -#define PHONON_LOG10OVER20 -static const qreal log10over20 = qreal(0.1151292546497022842); // ln(10) / 20 -#endif // PHONON_LOG10OVER20 - -qreal AudioOutput::volumeDecibel() const -{ - P_D(const AudioOutput); - if (d->muted || !d->m_backendObject) - return log(d->volume) / log10over20; - return 0.67 * log(INTERFACE_CALL(volume())) / log10over20; -} - -void AudioOutput::setVolumeDecibel(qreal newVolumeDecibel) -{ - setVolume(exp(newVolumeDecibel * log10over20)); -} - -bool AudioOutput::isMuted() const -{ - P_D(const AudioOutput); - return d->muted; -} - -void AudioOutput::setMuted(bool mute) -{ - P_D(AudioOutput); - if (d->muted != mute) { - if (mute) { - d->muted = mute; - if (k_ptr->backendObject()) { - INTERFACE_CALL(setVolume(0.0)); - } - } else { - if (k_ptr->backendObject()) { - INTERFACE_CALL(setVolume(pow(d->volume, VOLTAGE_TO_LOUDNESS_EXPONENT))); - } - d->muted = mute; - } - if (!Iface(d)) { - emit mutedChanged(mute); - } - } -} - -Category AudioOutput::category() const -{ - P_D(const AudioOutput); - return d->category; -} - -AudioOutputDevice AudioOutput::outputDevice() const -{ - P_D(const AudioOutput); - return d->device; -} - -bool AudioOutput::setOutputDevice(const AudioOutputDevice &newAudioOutputDevice) -{ - P_D(AudioOutput); - if (!newAudioOutputDevice.isValid()) { - d->outputDeviceOverridden = d->forceMove = false; - const int newIndex = GlobalConfig().audioOutputDeviceFor(d->category); - if (newIndex == d->device.index()) { - return true; - } - d->device = AudioOutputDevice::fromIndex(newIndex); - } else { - d->outputDeviceOverridden = d->forceMove = true; - if (d->device == newAudioOutputDevice) { - return true; - } - d->device = newAudioOutputDevice; - } - if (k_ptr->backendObject()) { - return callSetOutputDevice(d, d->device); - } - return true; -} - -bool AudioOutputPrivate::aboutToDeleteBackendObject() -{ - if (m_backendObject) { - volume = pINTERFACE_CALL(volume()); - } - return AbstractAudioOutputPrivate::aboutToDeleteBackendObject(); -} - -void AudioOutputPrivate::setupBackendObject() -{ - P_Q(AudioOutput); - Q_ASSERT(m_backendObject); - AbstractAudioOutputPrivate::setupBackendObject(); - - QObject::connect(m_backendObject, SIGNAL(volumeChanged(qreal)), q, SLOT(_k_volumeChanged(qreal))); - QObject::connect(m_backendObject, SIGNAL(audioDeviceFailed()), q, SLOT(_k_audioDeviceFailed())); - if (Iface(this)) { - QObject::connect(m_backendObject, SIGNAL(mutedChanged(bool)), - q, SLOT(_k_mutedChanged(bool))); - } - - // set up attributes - pINTERFACE_CALL(setVolume(pow(volume, VOLTAGE_TO_LOUDNESS_EXPONENT))); - -#ifndef QT_NO_PHONON_SETTINGSGROUP - // if the output device is not available and the device was not explicitly set - // There is no need to set the output device initially if PA is used as - // we know it will not work (stream doesn't exist yet) and that this will be - // handled by _k_deviceChanged() - if (!callSetOutputDevice(this, device) && !outputDeviceOverridden) { - // fall back in the preference list of output devices - QList deviceList = GlobalConfig().audioOutputDeviceListFor(category, GlobalConfig::AdvancedDevicesFromSettings | GlobalConfig::HideUnavailableDevices); - if (deviceList.isEmpty()) { - return; - } - for (int i = 0; i < deviceList.count(); ++i) { - const AudioOutputDevice &dev = AudioOutputDevice::fromIndex(deviceList.at(i)); - if (callSetOutputDevice(this, dev)) { - handleAutomaticDeviceChange(dev, AudioOutputPrivate::FallbackChange); - return; // found one that works - } - } - // if we get here there is no working output device. Tell the backend. - const AudioOutputDevice none; - callSetOutputDevice(this, none); - handleAutomaticDeviceChange(none, FallbackChange); - } -#endif //QT_NO_PHONON_SETTINGSGROUP -} - -void AudioOutputPrivate::_k_volumeChanged(qreal newVolume) -{ - volume = pow(newVolume, LOUDNESS_TO_VOLTAGE_EXPONENT); - if (!muted) { - P_Q(AudioOutput); - emit q->volumeChanged(volume); - } -} - -void AudioOutputPrivate::_k_mutedChanged(bool newMuted) -{ - muted = newMuted; - P_Q(AudioOutput); - emit q->mutedChanged(newMuted); -} - -void AudioOutputPrivate::_k_revertFallback() -{ - if (deviceBeforeFallback == -1) { - return; - } - device = AudioOutputDevice::fromIndex(deviceBeforeFallback); - callSetOutputDevice(this, device); - P_Q(AudioOutput); - emit q->outputDeviceChanged(device); -#ifndef PHONON_NO_DBUS - emit adaptor->outputDeviceIndexChanged(device.index()); -#endif -} - -void AudioOutputPrivate::_k_audioDeviceFailed() -{ -#ifndef QT_NO_PHONON_SETTINGSGROUP - - pDebug() << Q_FUNC_INFO; - // outputDeviceIndex identifies a failing device - // fall back in the preference list of output devices - const QList deviceList = GlobalConfig().audioOutputDeviceListFor(category, GlobalConfig::AdvancedDevicesFromSettings | GlobalConfig::HideUnavailableDevices); - for (int i = 0; i < deviceList.count(); ++i) { - const int devIndex = deviceList.at(i); - // if it's the same device as the one that failed, ignore it - if (device.index() != devIndex) { - const AudioOutputDevice &info = AudioOutputDevice::fromIndex(devIndex); - if (callSetOutputDevice(this, info)) { - handleAutomaticDeviceChange(info, FallbackChange); - return; // found one that works - } - } - } -#endif //QT_NO_PHONON_SETTINGSGROUP - // if we get here there is no working output device. Tell the backend. - const AudioOutputDevice none; - callSetOutputDevice(this, none); - handleAutomaticDeviceChange(none, FallbackChange); -} - -void AudioOutputPrivate::_k_deviceListChanged() -{ -#ifndef QT_NO_PHONON_SETTINGSGROUP - pDebug() << Q_FUNC_INFO; - // Check to see if we have an override and do not change to a higher priority device if the overridden device is still present. - if (outputDeviceOverridden && device.property("available").toBool()) { - return; - } - // let's see if there's a usable device higher in the preference list - const QList deviceList = GlobalConfig().audioOutputDeviceListFor(category, GlobalConfig::AdvancedDevicesFromSettings); - DeviceChangeType changeType = HigherPreferenceChange; - for (int i = 0; i < deviceList.count(); ++i) { - const int devIndex = deviceList.at(i); - const AudioOutputDevice &info = AudioOutputDevice::fromIndex(devIndex); - if (!info.property("available").toBool()) { - if (device.index() == devIndex) { - // we've reached the currently used device and it's not available anymore, so we - // fallback to the next available device - changeType = FallbackChange; - } - pDebug() << devIndex << "is not available"; - continue; - } - pDebug() << devIndex << "is available"; - if (device.index() == devIndex) { - // we've reached the currently used device, nothing to change - break; - } - if (callSetOutputDevice(this, info)) { - handleAutomaticDeviceChange(info, changeType); - break; // found one with higher preference that works - } - } -#endif //QT_NO_PHONON_SETTINGSGROUP -} - -void AudioOutputPrivate::_k_deviceChanged(int deviceIndex) -{ - // NB that this method is only used by PulseAudio at present. - - // 1. Check to see if we are overridden. If we are, and devices do not match, - // then try and apply our own device as the output device. - // We only do this the first time - if (outputDeviceOverridden && forceMove) { - forceMove = false; - const AudioOutputDevice ¤tDevice = AudioOutputDevice::fromIndex(deviceIndex); - if (currentDevice != device) { - if (!callSetOutputDevice(this, device)) { - // What to do if we are overridden and cannot change to our preferred device? - } - } - } - // 2. If we are not overridden, then we need to update our perception of what - // device we are using. If the devices do not match, something lower in the - // stack is overriding our preferences (e.g. a per-application stream preference, - // specific application move, priority list changed etc. etc.) - else if (!outputDeviceOverridden) { - const AudioOutputDevice ¤tDevice = AudioOutputDevice::fromIndex(deviceIndex); - if (currentDevice != device) { - // The device is not what we think it is, so lets say what is happening. - handleAutomaticDeviceChange(currentDevice, SoundSystemChange); - } - } -} - -static struct -{ - int first; - int second; -} g_lastFallback = { 0, 0 }; - -void AudioOutputPrivate::handleAutomaticDeviceChange(const AudioOutputDevice &device2, DeviceChangeType type) -{ - P_Q(AudioOutput); - deviceBeforeFallback = device.index(); - device = device2; - emit q->outputDeviceChanged(device2); -#ifndef PHONON_NO_DBUS - emit adaptor->outputDeviceIndexChanged(device.index()); -#endif - const AudioOutputDevice &device1 = AudioOutputDevice::fromIndex(deviceBeforeFallback); - switch (type) { - case FallbackChange: - if (g_lastFallback.first != device1.index() || g_lastFallback.second != device2.index()) { -#ifndef QT_NO_PHONON_PLATFORMPLUGIN - const QString &text = //device2.isValid() ? - AudioOutput::tr("The audio playback device %1 does not work.
" - "Falling back to %2.").arg(device1.name()).arg(device2.name()) /*: - AudioOutput::tr("The audio playback device %1 does not work.
" - "No other device available.").arg(device1.name())*/; - Platform::notification("AudioDeviceFallback", text); -#endif //QT_NO_PHONON_PLATFORMPLUGIN - g_lastFallback.first = device1.index(); - g_lastFallback.second = device2.index(); - } - break; - case HigherPreferenceChange: - { -#ifndef QT_NO_PHONON_PLATFORMPLUGIN - const QString text = AudioOutput::tr("Switching to the audio playback device %1
" - "which just became available and has higher preference.").arg(device2.name()); - Platform::notification("AudioDeviceFallback", text, - QStringList(AudioOutput::tr("Revert back to device '%1'").arg(device1.name())), - q, SLOT(_k_revertFallback())); -#endif //QT_NO_PHONON_PLATFORMPLUGIN - g_lastFallback.first = 0; - g_lastFallback.second = 0; - } - break; - case SoundSystemChange: - { -#ifndef QT_NO_PHONON_PLATFORMPLUGIN - // If device1 is not "valid" this indicates that the preferences used to select - // a device was perhaps not available when this object was created (although - // I can't quite work out how that would be....) - if (device1.isValid()) { - if (device1.property("available").toBool()) { - const QString text = AudioOutput::tr("Switching to the audio playback device %1
" - "which has higher preference or is specifically configured for this stream.").arg(device2.name()); - Platform::notification("AudioDeviceFallback", text, - QStringList(AudioOutput::tr("Revert back to device '%1'").arg(device1.name())), - q, SLOT(_k_revertFallback())); - } else { - const QString &text = - AudioOutput::tr("The audio playback device %1 does not work.
" - "Falling back to %2.").arg(device1.name()).arg(device2.name()); - Platform::notification("AudioDeviceFallback", text); - } - } -#endif //QT_NO_PHONON_PLATFORMPLUGIN - //outputDeviceOverridden = true; - g_lastFallback.first = 0; - g_lastFallback.second = 0; - } - break; - } -} - -AudioOutputPrivate::~AudioOutputPrivate() -{ -#ifndef PHONON_NO_DBUS - if (adaptor) { - emit adaptor->outputDestroyed(); - } -#endif -} - -} //namespace Phonon - -#include "moc_audiooutput.cpp" - -#undef PHONON_CLASSNAME -#undef PHONON_INTERFACENAME -#undef IFECES7 -#undef IFACES2 -#undef IFACES1 -#undef IFACES0 -#include "moc_audiooutput.h" diff --git a/src/phonon/audiooutput.h b/src/phonon/audiooutput.h deleted file mode 100644 index cf5c8088b..000000000 --- a/src/phonon/audiooutput.h +++ /dev/null @@ -1,177 +0,0 @@ -/* This file is part of the KDE project - Copyright (C) 2005-2006 Matthias Kretz - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), Nokia Corporation - (or its successors, if any) and the KDE Free Qt Foundation, which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . - -*/ -#ifndef Phonon_AUDIOOUTPUT_H -#define Phonon_AUDIOOUTPUT_H - -#include "phonon_export.h" -#include "abstractaudiooutput.h" -#include "phonondefs.h" -#include "phononnamespace.h" -#include "objectdescription.h" - - -class QString; - -class AudioOutputAdaptor; -namespace Phonon -{ - class AudioOutputPrivate; - - /** \class AudioOutput audiooutput.h phonon/AudioOutput - * \short Class for audio output to the soundcard. - * - * Use this class to define the audio output. - * - * \ingroup Frontend - * \author Matthias Kretz - * \see Phonon::Ui::VolumeSlider - */ - class PHONON_EXPORT AudioOutput : public AbstractAudioOutput - { - friend class FactoryPrivate; - friend class ::AudioOutputAdaptor; - Q_OBJECT - P_DECLARE_PRIVATE(AudioOutput) - /** - * This is the name that appears in Mixer applications that control - * the volume of this output. - * - * \see category - */ - Q_PROPERTY(QString name READ name WRITE setName) - /** - * This is the current loudness of the output (it is using Stevens' law - * to calculate the change in voltage internally). - * - * \see volumeDecibel - */ - Q_PROPERTY(qreal volume READ volume WRITE setVolume NOTIFY volumeChanged) - /** - * This is the current volume of the output in decibel. - * - * 0 dB means no change in volume, -6dB means an attenuation of the - * voltage to 50% and an attenuation of the power to 25%, -inf dB means - * silence. - * - * \see volume - */ - Q_PROPERTY(qreal volumeDecibel READ volumeDecibel WRITE setVolumeDecibel) - /** - * This property holds the (hardware) destination for the output. - * - * The default device is determined by the category and the global - * configuration for that category of outputs. Normally you don't need - * to override this setting - letting the user change the global - * configuration is the right choice. You can still override the - * device though, if you have good reasons to do so. - * - * \see outputDeviceChanged - */ - Q_PROPERTY(AudioOutputDevice outputDevice READ outputDevice WRITE setOutputDevice) - - /** - * This property tells whether the output is muted. - * - * Muting the output has the same effect as calling setVolume(0.0). - */ - Q_PROPERTY(bool muted READ isMuted WRITE setMuted NOTIFY mutedChanged) - public: - /** - * Creates a new AudioOutput that defines output to a physical - * device. - * - * \param category The category can be used by mixer applications to group volume - * controls of applications into categories. That makes it easier for - * the user to identify the programs. - * The category is also used for the default output device that is - * configured centrally. As an example: often users want to have the - * audio signal of a VoIP application go to their USB headset while - * all other sounds should go to the internal soundcard. - * - * \param parent QObject parent - * - * \see Phonon::categoryToString - * \see outputDevice - */ - explicit AudioOutput(Phonon::Category category, QObject *parent = 0); - explicit AudioOutput(QObject *parent = 0); - - QString name() const; - qreal volume() const; - qreal volumeDecibel() const; - - /** - * Returns the category of this output. - * - * \see AudioOutput(Phonon::Category, QObject *) - */ - Phonon::Category category() const; - AudioOutputDevice outputDevice() const; - bool isMuted() const; - - public Q_SLOTS: - void setName(const QString &newName); - void setVolume(qreal newVolume); - void setVolumeDecibel(qreal newVolumeDecibel); - bool setOutputDevice(const Phonon::AudioOutputDevice &newAudioOutputDevice); - void setMuted(bool mute); - - Q_SIGNALS: - /** - * This signal is emitted whenever the volume has changed. As the - * volume can change without a call to setVolume (calls over dbus) - * this is important - * to keep a widget showing the current volume up to date. - */ - void volumeChanged(qreal newVolume); - - /** - * This signal is emitted when the muted property has changed. As - * this property can change by outside sources, a UI element showing - * the muted property should listen to this signal. - */ - void mutedChanged(bool); - - /** - * This signal is emitted when the (hardware) device for the output - * has changed. - * - * The change can happen either through setOutputDevice or if the - * global configuration for the used category has changed. - * - * \see outputDevice - */ - void outputDeviceChanged(const Phonon::AudioOutputDevice &newAudioOutputDevice); - - private: - Q_PRIVATE_SLOT(k_func(), void _k_volumeChanged(qreal)) - Q_PRIVATE_SLOT(k_func(), void _k_mutedChanged(bool)) - Q_PRIVATE_SLOT(k_func(), void _k_revertFallback()) - Q_PRIVATE_SLOT(k_func(), void _k_audioDeviceFailed()) - Q_PRIVATE_SLOT(k_func(), void _k_deviceListChanged()) - Q_PRIVATE_SLOT(k_func(), void _k_deviceChanged(int device)) - }; -} //namespace Phonon - - -// vim: sw=4 ts=4 tw=80 -#endif // Phonon_AUDIOOUTPUT_H diff --git a/src/phonon/audiooutput_p.h b/src/phonon/audiooutput_p.h deleted file mode 100644 index 0a8694e1b..000000000 --- a/src/phonon/audiooutput_p.h +++ /dev/null @@ -1,99 +0,0 @@ -/* This file is part of the KDE project - Copyright (C) 2006 Matthias Kretz - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), Nokia Corporation - (or its successors, if any) and the KDE Free Qt Foundation, which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . - -*/ - -#ifndef AUDIOOUTPUT_P_H -#define AUDIOOUTPUT_P_H - -#include "audiooutput.h" -#include "abstractaudiooutput_p.h" -#include "phononconfig_p.h" -#include "platform_p.h" - -namespace Phonon -{ -class AudioOutputAdaptor; - -class AudioOutputPrivate : public AbstractAudioOutputPrivate -{ - P_DECLARE_PUBLIC(AudioOutput) - PHONON_PRIVATECLASS - public: - inline static AudioOutputPrivate *cast(MediaNodePrivate *x) - { - if (x && x->castId == MediaNodePrivate::AudioOutputType) { - return static_cast(x); - } - return 0; - } - void init(Phonon::Category c); - QString getStreamUuid(); - - - protected: - AudioOutputPrivate(CastId castId = MediaNodePrivate::AudioOutputType) - : AbstractAudioOutputPrivate(castId), - name(Platform::applicationName()), - volume(Platform::loadVolume(name)), -#ifndef PHONON_NO_DBUS - adaptor(0), -#endif - deviceBeforeFallback(-1), - outputDeviceOverridden(false), - forceMove(false), - muted(false) - { - } - - ~AudioOutputPrivate(); - - enum DeviceChangeType { - FallbackChange, - HigherPreferenceChange, - SoundSystemChange - }; - void handleAutomaticDeviceChange(const AudioOutputDevice &newDev, DeviceChangeType type); - - void _k_volumeChanged(qreal); - void _k_mutedChanged(bool); - void _k_revertFallback(); - void _k_audioDeviceFailed(); - void _k_deviceListChanged(); - void _k_deviceChanged(int deviceIndex); - - private: - QString name; - Phonon::AudioOutputDevice device; - qreal volume; - QString streamUuid; -#ifndef PHONON_NO_DBUS - Phonon::AudioOutputAdaptor *adaptor; -#endif - Category category; - int deviceBeforeFallback; - bool outputDeviceOverridden; - bool forceMove; - bool muted; -}; -} //namespace Phonon - -#endif // AUDIOOUTPUT_P_H -// vim: sw=4 ts=4 tw=80 diff --git a/src/phonon/audiooutputadaptor.cpp b/src/phonon/audiooutputadaptor.cpp deleted file mode 100644 index fc7c55285..000000000 --- a/src/phonon/audiooutputadaptor.cpp +++ /dev/null @@ -1,98 +0,0 @@ -/* - * This file was generated by dbusidl2cpp version 0.4 - * when processing input file org.kde.Phonon.AudioOutput.xml - * - * dbusidl2cpp is Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). - * - * This is an auto-generated file. This file has been hand-edited. - */ - -#include "audiooutputadaptor_p.h" -#include "audiooutput.h" -#include -#include -#include -#include -#include -#include -#include -#include "phononconfig_p.h" -#include "phononnamespace_p.h" -#include "objectdescription.h" - -#ifndef PHONON_NO_DBUS - -/* - * Implementation of adaptor class AudioOutputAdaptor - */ - -namespace Phonon -{ - -AudioOutputAdaptor::AudioOutputAdaptor(QObject *parent) - : QDBusAbstractAdaptor(parent) -{ - // constructor - setAutoRelaySignals(true); -} - -AudioOutputAdaptor::~AudioOutputAdaptor() -{ - // destructor -} - -double AudioOutputAdaptor::volume() const -{ - // get the value of property volume - return qvariant_cast(parent()->property("volume")); -} - -void AudioOutputAdaptor::setVolume(double value) -{ - // set the value of property volume - parent()->setProperty("volume", QVariant::fromValue(static_cast(value))); -} - -bool AudioOutputAdaptor::muted() const -{ - return parent()->property("muted").toBool(); -} - -void AudioOutputAdaptor::setMuted(bool value) -{ - parent()->setProperty("muted", value); -} - -QString AudioOutputAdaptor::category() -{ - // handle method call org.kde.Phonon.AudioOutput.category - return Phonon::categoryToString(static_cast(parent())->category()); -} - -QString AudioOutputAdaptor::name() -{ - // handle method call org.kde.Phonon.AudioOutput.name - QString name; - //QMetaObject::invokeMethod(parent(), "name", Q_RETURN_ARG(QString, name)); - - // Alternative: - name = static_cast(parent())->name(); - return name; -} - -int AudioOutputAdaptor::outputDeviceIndex() const -{ - return static_cast(parent())->outputDevice().index(); -} - -void AudioOutputAdaptor::setOutputDeviceIndex(int newAudioOutputDeviceIndex) -{ - static_cast(parent()) - ->setOutputDevice(Phonon::AudioOutputDevice::fromIndex(newAudioOutputDeviceIndex)); -} - -} // namespace Phonon - -#include "moc_audiooutputadaptor_p.h" - -#endif diff --git a/src/phonon/audiooutputadaptor_p.h b/src/phonon/audiooutputadaptor_p.h deleted file mode 100644 index 4df4635de..000000000 --- a/src/phonon/audiooutputadaptor_p.h +++ /dev/null @@ -1,107 +0,0 @@ -/* - * This file was generated by dbusidl2cpp version 0.4 - * when processing input file org.kde.Phonon.AudioOutput.xml - * - * dbusidl2cpp is Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). - * - * This is an auto-generated file. This file has been hand-edited. - */ - -#ifndef AUDIOOUTPUTADAPTOR_P_H -#define AUDIOOUTPUTADAPTOR_P_H - -#include "phononconfig_p.h" - -#include - -#ifndef PHONON_NO_DBUS -#include - - -class QByteArray; -template class QList; -template class QMap; -class QString; -class QStringList; -class QVariant; - -namespace Phonon -{ - class AudioOutputPrivate; - class AudioOutput; - -/* - * Adaptor class for interface org.kde.Phonon.AudioOutput - */ -class AudioOutputAdaptor: public QDBusAbstractAdaptor -{ - friend class Phonon::AudioOutputPrivate; - friend class Phonon::AudioOutput; - Q_OBJECT - Q_CLASSINFO("D-Bus Interface", "org.kde.Phonon.AudioOutput") - Q_CLASSINFO("D-Bus Introspection", "" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" - "") -public: - AudioOutputAdaptor(QObject *parent); - virtual ~AudioOutputAdaptor(); - -public: // PROPERTIES - Q_PROPERTY(bool muted READ muted WRITE setMuted) - bool muted() const; - void setMuted(bool value); - - Q_PROPERTY(int outputDeviceIndex READ outputDeviceIndex WRITE setOutputDeviceIndex) - int outputDeviceIndex() const; - void setOutputDeviceIndex(int value); - - Q_PROPERTY(double volume READ volume WRITE setVolume) - double volume() const; - void setVolume(double value); - -public Q_SLOTS: // METHODS - QString category(); - QString name(); -Q_SIGNALS: // SIGNALS - void mutedChanged(bool in0); - void nameChanged(const QString &newName); - void newOutputAvailable(const QString &service, const QString &path); - void outputDestroyed(); - void outputDeviceIndexChanged(int in0); - void volumeChanged(qreal in0); -}; - -} // namespace Phonon - - -#endif // PHONON_NO_DBUS - -#endif // AUDIOOUTPUTADAPTOR_P_H diff --git a/src/phonon/audiooutputinterface.cpp b/src/phonon/audiooutputinterface.cpp deleted file mode 100644 index d3e2b9c88..000000000 --- a/src/phonon/audiooutputinterface.cpp +++ /dev/null @@ -1,36 +0,0 @@ -/* This file is part of the KDE project - Copyright (C) 2008 Matthias Kretz - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), Nokia Corporation - (or its successors, if any) and the KDE Free Qt Foundation, which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . - -*/ -#include "audiooutputinterface.h" -#include -#include -#include -#include "platform_p.h" - -namespace Phonon -{ - -QList > AudioOutputInterface42::deviceAccessListFor(const Phonon::AudioOutputDevice &deviceDesc) const -{ - return Platform::deviceAccessListFor(deviceDesc); -} - -} // namespace Phonon diff --git a/src/phonon/audiooutputinterface.h b/src/phonon/audiooutputinterface.h deleted file mode 100644 index 6b5d878ec..000000000 --- a/src/phonon/audiooutputinterface.h +++ /dev/null @@ -1,211 +0,0 @@ -/* - Copyright (C) 2015 Harald Sitter - Copyright (C) 2007-2008 Matthias Kretz - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), Nokia Corporation - (or its successors, if any) and the KDE Free Qt Foundation, which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . - -*/ - -#ifndef PHONON_AUDIOOUTPUTINTERFACE_H -#define PHONON_AUDIOOUTPUTINTERFACE_H - -#include "phononnamespace.h" -#include "objectdescription.h" -#include "phonondefs.h" -#include - - -namespace Phonon -{ -/** \class AudioOutputInterface audiooutputinterface.h phonon/AudioOutputInterface - * \short Interface for AudioOutput objects - * - * The implementation can make use of the signals - * \code - void volumeChanged(qreal newVolume); - void audioDeviceFailed(); - * \endcode - * to notify the frontend whenever the volume has changed or when an audioDeviceFailed (e.g. USB - * unplug or sound server failure). - * - * \author Matthias Kretz - */ -class AudioOutputInterface40 -{ - public: - virtual ~AudioOutputInterface40() {} - - /** - * Returns the current software volume. - * - * A value of 0.0 means muted, 1.0 means unchanged, 2.0 means double voltage (i.e. all - * samples are multiplied by 2). - */ - virtual qreal volume() const = 0; - /** - * Sets the new current software volume. - * - * A value of 0.0 means muted, 1.0 means unchanged, 2.0 means double voltage (i.e. all - * samples are multiplied by 2). - * - * Every time the volume in the backend changes it should emit volumeChanged(qreal), also - * inside this function. - */ - virtual void setVolume(qreal) = 0; - - /** - * Returns the index of the device that is used. The index is the number returned from - * BackendInterface::objectDescriptionIndexes(AudioOutputDeviceType). - */ - virtual int outputDevice() const = 0; - /** - * \deprecated - * - * Requests to change the current output device to the one identified by the passed index. - * - * The index is the number returned from - * BackendInterface::objectDescriptionIndexes(AudioOutputDeviceType). - * - * \returns \c true if the requested device works and is used after this call. - * \returns \c false if something failed and the device is not used after this call. - */ - virtual bool setOutputDevice(int) = 0; -}; - -class AudioOutputInterface42 : public AudioOutputInterface40 -{ - public: - /** - * Requests to change the current output device. - * - * \returns \c true if the requested device works and is used after this call. - * \returns \c false if something failed and the device is not used after this call. - */ - virtual bool setOutputDevice(const Phonon::AudioOutputDevice &) = 0; - - using AudioOutputInterface40::setOutputDevice; - - /** - * Helper function for backends to get a list of (driver, handle) pairs for - * AudioOutputDevice objects that are listed by the platform plugin. - * - * Example: - * \code - typedef QPair PhononDeviceAccess; - const QList &deviceAccessList = deviceAccessListFor(deviceDesc); - foreach (const PhononDeviceAccess &access, deviceAccessList) { - const QByteArray &driver = access.first; - const QString &handle = access.second; - if (openDevice(driver, handle)) { - // we found the first pair in the list that works. done. - return; - } - // continue trying the other (driver, handle) pairs - } - // none of the (driver, handle) pairs worked, that means the whole AudioOutputDevice is - // inaccessible and the frontend needs to know (either by emitting audioDeviceFailed or - // returning false when called from setOutputDevice) - * \endcode - * - * At the time of this writing the following driver strings are known to be in use: - * \li \c alsa: The handle is the string to pass to snd_pcm_open (e.g. "dmix:CARD=0,DEV=1") - * \li \c oss: The handle is the device file (e.g. "/dev/dsp") - * \li \c pulseaudio: The handle contains the server string and the sink/source name - * separated by a newline character. - * (e.g. unix:/tmp/pulse-mkretz/native\nalsa_output.pci_8086_293e_sound_card_0_alsa_playback_0) - */ - PHONON_EXPORT QList > deviceAccessListFor(const Phonon::AudioOutputDevice &) const; -}; - -class AudioOutputInterface47 : public AudioOutputInterface42 -{ -public: - /** - * This function is meant to be used in conjuction with PulseSupport - * to either get the property set for the associated PulseAudio straem or - * to automatically apply them to the envrionment. - * - * If a backend subsystem supports actively setting arbitrary properties - * this method should be preferred and PulseSupport::streamProperties() - * should be used. - * If a backend subsystem does not support setting arbitrary properties - * PulseSupport::setupStreamEnvironment() should be called as close to - * stream creation as possible to manipulate the process envrionment - * such that PulseAudio will pick up the properties. - * - * \param uuid the UUID used by PulseSupport to identify the associated stream - * - * \since 4.7.0 - */ - virtual void setStreamUuid(QString uuid) = 0; -}; - -class AudioOutputInterface49 : public AudioOutputInterface47 -{ -public: - /** - * SIGNAL emitted when the muteness of the output changes. - * - * \warning When implementing the 4.9 interface this signal MUST be emitted - * from all relevant sources. - * - * This signal must be emitted whenever muteness is reached. Presently - * Phonon has a fallback mechanic which for example forces muteness on - * setVolume(0.0) on the frontend side, assuming that the backend enforces - * this. - * Whenever muteness is reached in the backend this signal - * must be emitted, regardless of whether it was reached by - * volume=0.0 or mute=true or device=dead or digital-passthrough=true... - * - * \param mute \c true when the output is mute, \c false if it is not mute - * - * \since 4.9.0 - */ - virtual void mutedChanged(bool mute) = 0; -}; - -} // namespace Phonon - -#ifdef PHONON_BACKEND_VERSION_4_9 -namespace Phonon { typedef AudioOutputInterface49 AudioOutputInterface; } -Q_DECLARE_INTERFACE(Phonon::AudioOutputInterface40, "AudioOutputInterface2.phonon.kde.org") -Q_DECLARE_INTERFACE(Phonon::AudioOutputInterface42, "3AudioOutputInterface.phonon.kde.org") -Q_DECLARE_INTERFACE(Phonon::AudioOutputInterface47, "4AudioOutputInterface.phonon.kde.org") -Q_DECLARE_INTERFACE(Phonon::AudioOutputInterface, "5AudioOutputInterface.phonon.kde.org") -#elif defined PHONON_BACKEND_VERSION_4_7 -namespace Phonon { typedef AudioOutputInterface47 AudioOutputInterface; } -Q_DECLARE_INTERFACE(Phonon::AudioOutputInterface40, "AudioOutputInterface2.phonon.kde.org") -Q_DECLARE_INTERFACE(Phonon::AudioOutputInterface42, "3AudioOutputInterface.phonon.kde.org") -Q_DECLARE_INTERFACE(Phonon::AudioOutputInterface, "4AudioOutputInterface.phonon.kde.org") -Q_DECLARE_INTERFACE(Phonon::AudioOutputInterface49, "5AudioOutputInterface.phonon.kde.org") -#elif defined PHONON_BACKEND_VERSION_4_2 -namespace Phonon { typedef AudioOutputInterface42 AudioOutputInterface; } -Q_DECLARE_INTERFACE(Phonon::AudioOutputInterface40, "AudioOutputInterface2.phonon.kde.org") -Q_DECLARE_INTERFACE(Phonon::AudioOutputInterface, "3AudioOutputInterface.phonon.kde.org") -Q_DECLARE_INTERFACE(Phonon::AudioOutputInterface47, "4AudioOutputInterface.phonon.kde.org") -Q_DECLARE_INTERFACE(Phonon::AudioOutputInterface49, "5AudioOutputInterface.phonon.kde.org") -#else -namespace Phonon { typedef AudioOutputInterface40 AudioOutputInterface; } -Q_DECLARE_INTERFACE(Phonon::AudioOutputInterface, "AudioOutputInterface2.phonon.kde.org") -Q_DECLARE_INTERFACE(Phonon::AudioOutputInterface42, "3AudioOutputInterface.phonon.kde.org") -Q_DECLARE_INTERFACE(Phonon::AudioOutputInterface47, "4AudioOutputInterface.phonon.kde.org") -Q_DECLARE_INTERFACE(Phonon::AudioOutputInterface49, "5AudioOutputInterface.phonon.kde.org") -#endif - - -#endif // PHONON_AUDIOOUTPUTINTERFACE_H diff --git a/src/phonon/backend.dox b/src/phonon/backend.dox deleted file mode 100644 index 8a9c5b252..000000000 --- a/src/phonon/backend.dox +++ /dev/null @@ -1,107 +0,0 @@ -/** -\page phonon_Backend The Backend Class -\ingroup Backend - -\section phonon_Backend_requiredfunctions Required Functions -\li bool \ref phonon_Backend_supportsOSD "supportsOSD()" -\li bool \ref phonon_Backend_supportsFourcc "supportsFourcc( quint32 )" -\li bool \ref phonon_Backend_supportsSubtitles "supportsSubtitles()" -\li bool \ref phonon_Backend_supportsVideo "supportsVideo()" -\li QStringList \ref phonon_Backend_availableMimeTypes "availableMimeTypes()" - -\section Member Function Documentation - -\subsection phonon_Backend_supportsFourcc bool supportsFourcc( quint32 fourcc ) -Tells whether the FOURCC (four character code) is supported for -the \ref phonon_VideoDataOutput "VideoDataOutput" interface. If you return \c true, you have to be -able to return VideoFrame objects accordingly from -\ref phonon_VideoDataOutput "VideoDataOutput". -\param fourcc A four character code defining a video frame format. -\returns \c true if your \ref phonon_VideoDataOutput "VideoDataOutput" can -output video frames in the requested format. -\returns \c false if the video frames can not be converted into the requested -format. - -\subsection phonon_Backend_availableMimeTypes QStringList availableMimeTypes() -Lists the MIME types the backend can read and decode. - -\subsection phonon_Backend_xIndexes QSet Indexes() - Returns a set of indexes that identify the devices/codecs/effects/... the - backend supports. This list needs to be compiled from looking at - available hardware and virtual devices/plugins/... . The implementation - should use cached information, but you need to invalidate the cache - whenever the hardware configuration changes or new virtual devices come - available/new plugins are installed/... . - - \return The indexes of the available devices/codecs/effects/... - - \see \ref phonon_Backend_xName - \see \ref phonon_Backend_xDescription - -\subsection phonon_Backend_xName QString Name( int index ) - Returns the name of the given device/codec/effect/... - - \param index The index of one device/codec/effect/... this is one index - out of \ref phonon_Backend_xIndexes - - \returns A translated user visible string to name the device. - - \see \ref phonon_Backend_xIndexes - \see \ref phonon_Backend_xDescription -\subsection phonon_Backend_xDescription QString Description( int index ) - Returns the description of the given device/codec/effect/... - - \param index The index of one device/codec/effect/... this is one index - out of \ref phonon_Backend_xIndexes - - \returns A translated user visible string to describe the device. - - \see \ref phonon_Backend_xIndexes - \see \ref phonon_Backend_xName - -\subsection phonon_Backend_audioCaptureDeviceVideoIndex qint32 audioCaptureDeviceVideoIndex( int index ) - \param index The index of the device. This is one of the indexes the backend - returned via \ref phonon_Backend_xIndexes - \returns An index of a video capture device that is associated with the given - audio capture device. For example a webcam might have both a video and an audio - capture device, and in order give the user a hint that the audio and video - capture devices belong together this index is used. - \returns If there is no associated video capture device return -1. - -\subsection phonon_Backend_videoCaptureDeviceAudioIndex qint32 videoCaptureDeviceAudioIndex( int index ) - \param index The index of the device. This is one of the indexes the backend - returned via \ref phonon_Backend_xIndexes - \returns An index of a audio capture device that is associated with the given - video capture device. For example a webcam might have both a audio and an video - capture device, and in order give the user a hint that the video and audio - capture devices belong together this index is used. - \returns If there is no associated audio capture device return -1. - -\page phonon_AudioDataOutput The AudioDataOutput Class -\ingroup Backend - -\page phonon_AudioOutput The AudioOutput Class -\ingroup Backend - -\page phonon_VideoDataOutput The VideoDataOutput Class -\ingroup Backend - -\page phonon_VideoWidget The VideoWidget Class -\ingroup Backend - -\page phonon_Effect The Effect Class -\ingroup Backend - -\page phonon_BrightnessControl The BrightnessControl Class -\ingroup Backend - -\page phonon_VideoEffect The VideoEffect Class -\ingroup Backend - -\page phonon_Visualization The Visualization Class -\ingroup Backend - -\page phonon_VolumeFaderEffect The VolumeFaderEffect Class -\ingroup Backend - -*/ diff --git a/src/phonon/backendcapabilities.cpp b/src/phonon/backendcapabilities.cpp deleted file mode 100644 index 931a3fc87..000000000 --- a/src/phonon/backendcapabilities.cpp +++ /dev/null @@ -1,146 +0,0 @@ -/* This file is part of the KDE project - Copyright (C) 2005-2006 Matthias Kretz - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), Nokia Corporation - (or its successors, if any) and the KDE Free Qt Foundation, which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . - -*/ - -#include "backendcapabilities.h" -#include "backendcapabilities_p.h" - -#include "phonondefs_p.h" -#include "backendinterface.h" -#include "factory_p.h" -#include "globalconfig.h" -#include "globalstatic_p.h" -#include "objectdescription.h" - -#include -#include -#include - -PHONON_GLOBAL_STATIC(Phonon::BackendCapabilitiesPrivate, globalBCPrivate) - -namespace Phonon -{ - -BackendCapabilities::Notifier *BackendCapabilities::notifier() -{ - return globalBCPrivate; -} - -QStringList BackendCapabilities::availableMimeTypes() -{ - if (BackendInterface *backendIface = qobject_cast(Factory::backend())) - return backendIface->availableMimeTypes(); - else - return QStringList(); -} - -bool BackendCapabilities::isMimeTypeAvailable(const QString &mimeType) -{ - QObject *m_backendObject = Factory::backend(false); - if (!m_backendObject) { - if (!Factory::isMimeTypeAvailable(mimeType)) { - return false; - } - // without loading the backend we found out that the MIME type might be supported, now we - // want to know for certain. For that we need to load the backend. - m_backendObject = Factory::backend(true); - } - if (!m_backendObject) { - // no backend == no MIME type supported at all - return false; - } - return availableMimeTypes().contains(mimeType); -} - -QList BackendCapabilities::availableAudioOutputDevices() -{ - QList ret; -#ifndef QT_NO_PHONON_SETTINGSGROUP - const QList deviceIndexes = GlobalConfig().audioOutputDeviceListFor(Phonon::NoCategory, GlobalConfig::ShowAdvancedDevices); - for (int i = 0; i < deviceIndexes.count(); ++i) { - ret.append(AudioOutputDevice::fromIndex(deviceIndexes.at(i))); - } -#endif //QT_NO_PHONON_SETTINGSGROUP - return ret; -} - - -#ifndef PHONON_NO_AUDIOCAPTURE -QList BackendCapabilities::availableAudioCaptureDevices() -{ - QList ret; - const QList deviceIndexes = GlobalConfig().audioCaptureDeviceListFor(Phonon::NoCaptureCategory, GlobalConfig::ShowAdvancedDevices); - for (int i = 0; i < deviceIndexes.count(); ++i) { - ret.append(AudioCaptureDevice::fromIndex(deviceIndexes.at(i))); - } - return ret; -} -#endif //PHONON_NO_AUDIOCAPTURE - -#ifndef PHONON_NO_VIDEOCAPTURE -QList BackendCapabilities::availableVideoCaptureDevices() -{ - QList ret; - const QList deviceIndexes = GlobalConfig().videoCaptureDeviceListFor(Phonon::NoCaptureCategory, GlobalConfig::ShowAdvancedDevices); - for (int i = 0; i < deviceIndexes.count(); ++i) { - ret.append(VideoCaptureDevice::fromIndex(deviceIndexes.at(i))); - } - return ret; -} -#endif //PHONON_NO_VIDEOCAPTURE - -#if !defined(PHONON_NO_VIDEOCAPTURE) && !defined(PHONON_NO_AUDIOCAPTURE) -QList BackendCapabilities::availableAVCaptureDevices() -{ - QList ret; - const QList deviceIndexes = GlobalConfig().videoCaptureDeviceListFor(Phonon::NoCaptureCategory, GlobalConfig::ShowAdvancedDevices); - for (int i = 0; i < deviceIndexes.count(); ++i) { - VideoCaptureDevice vcd = VideoCaptureDevice::fromIndex(deviceIndexes.at(i)); - if (vcd.propertyNames().contains("hasaudio") && vcd.property("hasaudio").isValid()) - ret.append(vcd); - } - return ret; -} -#endif // NOT PHONON_NO_VIDEOCAPTURE AND NOT PHONON_NO_AUDIOCAPTURE - -#ifndef QT_NO_PHONON_EFFECT -QList BackendCapabilities::availableAudioEffects() -{ - BackendInterface *backendIface = qobject_cast(Factory::backend()); - QList ret; - if (backendIface) { - const QList deviceIndexes = backendIface->objectDescriptionIndexes(Phonon::EffectType); - for (int i = 0; i < deviceIndexes.count(); ++i) { - ret.append(EffectDescription::fromIndex(deviceIndexes.at(i))); - } - } - return ret; -} -#endif //QT_NO_PHONON_EFFECT - -} // namespace Phonon - -#include "moc_backendcapabilities.cpp" - -// vim: sw=4 ts=4 - - -#include "moc_backendcapabilities.h" diff --git a/src/phonon/backendcapabilities.h b/src/phonon/backendcapabilities.h deleted file mode 100644 index 24a717187..000000000 --- a/src/phonon/backendcapabilities.h +++ /dev/null @@ -1,239 +0,0 @@ -/* This file is part of the KDE project - Copyright (C) 2005-2006 Matthias Kretz - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), Nokia Corporation - (or its successors, if any) and the KDE Free Qt Foundation, which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . - -*/ - -#ifndef Phonon_BACKENDCAPABILITIES_H -#define Phonon_BACKENDCAPABILITIES_H - -#include "phonon_export.h" -#include "objectdescription.h" - -#include - - -template class QList; -class QStringList; - -namespace Phonon -{ - -/** - * Collection of functions describing the capabilities of the Backend. - * - * \ingroup BackendInformation - * \author Matthias Kretz - */ -namespace BackendCapabilities -{ - /** \class Notifier backendcapabilities.h phonon/BackendCapabilities - * Notifications about backend capabilities. - * - * \ingroup BackendInformation - */ - class Notifier : public QObject - { - Q_OBJECT - Q_SIGNALS: - /** - * This signal is emitted if the capabilities have changed. This can - * happen if the user has requested a backend change. - */ - void capabilitiesChanged(); - - /** - * This signal is emitted when audio output devices were plugged or - * unplugged. - * - * Check BackendCapabilities::availableAudioOutputDevices to get the - * current list of available devices. - */ - void availableAudioOutputDevicesChanged(); - -#ifndef PHONON_NO_AUDIOCAPTURE - /** - * This signal is emitted when audio capture devices were plugged or - * unplugged. - * - * Check BackendCapabilities::availableAudioCaptureDevices to get the - * current list of available devices. - */ - void availableAudioCaptureDevicesChanged(); -#endif //PHONON_NO_AUDIOCAPTURE - -#ifndef PHONON_NO_VIDEOCAPTURE - /** - * This signal is emitted when video capture devices were plugged or - * unplugged. - * - * Check BackendCapabilities::availableVideoCaptureDevices to get the - * current list of available devices. - */ - void availableVideoCaptureDevicesChanged(); -#endif //PHONON_NO_VIDEOCAPTURE - }; - - /** - * Use this function to get a QObject pointer to connect to one of the Notifier signals. - * - * \return a pointer to a QObject. - * - * To connect to the signal do the following: - * \code - * QObject::connect(BackendCapabilities::notifier(), SIGNAL(capabilitiesChanged()), ... - * \endcode - * - * \see Notifier::capabilitiesChanged() - * \see Notifier::availableAudioOutputDevicesChanged() - * \see Notifier::availableAudioCaptureDevicesChanged() - * \see Notifier::availableVideoCaptureDevicesChanged() - */ - PHONON_EXPORT Notifier *notifier(); - - /** - * Returns a list of mime types that the Backend can decode. - * - * \see isMimeTypeAvailable() - */ - PHONON_EXPORT QStringList availableMimeTypes(); - - /** - * Often all you want to know is whether one given MIME type can be - * decoded by the backend. Use this method in favor of availableMimeTypes() - * as it can give you a negative answer without having a backend loaded. - * - * \see availableMimeTypes(); - */ - PHONON_EXPORT bool isMimeTypeAvailable(const QString &mimeType); - - /** - * Returns the audio output devices the backend supports. - * - * \return A list of AudioOutputDevice objects that give a name and - * description for every supported audio output device. - */ - PHONON_EXPORT QList availableAudioOutputDevices(); - -#ifndef PHONON_NO_AUDIOCAPTURE - /** - * Returns the audio capture devices the backend supports. - * - * \return A list of AudioCaptureDevice objects that give a name and - * description for every supported audio capture device. - */ - PHONON_EXPORT QList availableAudioCaptureDevices(); -#endif //PHONON_NO_AUDIOCAPTURE - - /** - * Returns the video output devices the backend supports. - * - * \return A list of VideoOutputDevice objects that give a name and - * description for every supported video output device. - */ -// PHONON_EXPORT QList availableVideoOutputDevices(); - -#ifndef PHONON_NO_VIDEOCAPTURE - /** - * Returns the video capture devices the backend supports. - * - * \return A list of VideoCaptureDevice objects that give a name and - * description for every supported video capture device. - */ - PHONON_EXPORT QList availableVideoCaptureDevices(); -#endif //PHONON_NO_VIDEOCAPTURE - - /** - * Returns the video capture devices that have audio capture capabilities - * that the backend supports. In effect, these are both video and audio - * capture devices and one can connect them to both a VideoWidget and an - * AudioOutput, for example. - * - * The resulting VideoCaptureDevices have a "hasaudio" property to true. - * - * \note These devices appear both in availableVideoCaptureDevices() and - * availableAudioCaptureDevices() - * - * \warning Creating two separate MediaObject instances for the same capture - * device, one for video and the other for audio, most probably doesn't work. - * But, if there are two separate devices, use Experimental::AVCapture. - * - * \see availableVideoCaptureDevices() - * \see availableAudioCaptureDevices() - * \see Experimental::AVCapture - */ -#if !defined(PHONON_NO_VIDEOCAPTURE) && !defined(PHONON_NO_AUDIOCAPTURE) - PHONON_EXPORT QList availableAVCaptureDevices(); -#endif // NOT PHONON_NO_VIDEOCAPTURE AND NOT PHONON_NO_AUDIOCAPTURE - - /** - * Returns the visualization effects the backend supports. - * - * \return A list of VisualizationEffect objects that give a name and - * description for every supported visualization effect. - */ -// PHONON_EXPORT QList availableVisualizations(); - -#ifndef QT_NO_PHONON_EFFECT - /** - * Returns descriptions for the audio effects the backend supports. - * - * \return A list of AudioEffectDescription objects that give a name and - * description for every supported audio effect. - */ - PHONON_EXPORT QList availableAudioEffects(); -#endif //QT_NO_PHONON_EFFECT - -//X /** -//X * Returns descriptions for the video effects the backend supports. -//X * -//X * \return A list of VideoEffectDescription objects that give a name and -//X * description for every supported video effect. -//X */ -//X PHONON_EXPORT QList availableVideoEffects(); - - /** - * Returns descriptions for the audio codecs the backend supports. - * - * \return A list of AudioCodec objects that give a name and - * description for every supported audio codec. - */ -// PHONON_EXPORT QList availableAudioCodecs(); - - /** - * Returns descriptions for the video codecs the backend supports. - * - * \return A list of VideoCodec objects that give a name and - * description for every supported video codec. - */ -// PHONON_EXPORT QList availableVideoCodecs(); - - /** - * Returns descriptions for the container formats the backend supports. - * - * \return A list of ContainerFormat objects that give a name and - * description for every supported container format. - */ -// PHONON_EXPORT QList availableContainerFormats(); -} // namespace BackendCapabilities -} // namespace Phonon - - -#endif // Phonon_BACKENDCAPABILITIES_H -// vim: sw=4 ts=4 tw=80 diff --git a/src/phonon/backendcapabilities_p.h b/src/phonon/backendcapabilities_p.h deleted file mode 100644 index b410a9ff3..000000000 --- a/src/phonon/backendcapabilities_p.h +++ /dev/null @@ -1,47 +0,0 @@ -/* This file is part of the KDE project - Copyright (C) 2007 Matthias Kretz - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), Nokia Corporation - (or its successors, if any) and the KDE Free Qt Foundation, which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . - -*/ - -#ifndef PHONON_BACKENDCAPABILITIES_P_H -#define PHONON_BACKENDCAPABILITIES_P_H - -#include "backendcapabilities.h" -#include -#include "factory_p.h" - -namespace Phonon -{ -class BackendCapabilitiesPrivate : public BackendCapabilities::Notifier -{ - public: - BackendCapabilitiesPrivate() - { - connect(Factory::sender(), SIGNAL(backendChanged()), SIGNAL(capabilitiesChanged())); - connect(Factory::sender(), SIGNAL(availableAudioOutputDevicesChanged()), SIGNAL(availableAudioOutputDevicesChanged())); - connect(Factory::sender(), SIGNAL(availableAudioCaptureDevicesChanged()), SIGNAL(availableAudioCaptureDevicesChanged())); - connect(Factory::sender(), SIGNAL(availableVideoCaptureDevicesChanged()), SIGNAL(availableVideoCaptureDevicesChanged())); - } -}; - -} // namespace Phonon - -#endif // PHONON_BACKENDCAPABILITIES_P_H -// vim: sw=4 sts=4 et tw=100 diff --git a/src/phonon/backendinterface.h b/src/phonon/backendinterface.h deleted file mode 100644 index 8be5d06a1..000000000 --- a/src/phonon/backendinterface.h +++ /dev/null @@ -1,284 +0,0 @@ -/* This file is part of the KDE project - Copyright (C) 2006-2007 Matthias Kretz - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), Nokia Corporation - (or its successors, if any) and the KDE Free Qt Foundation, which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . - -*/ - -#ifndef PHONON_BACKENDINTERFACE_H -#define PHONON_BACKENDINTERFACE_H - -#include "phonon_export.h" -#include "objectdescription.h" - -#include -#include - - -class QVariant; - -namespace Phonon -{ - -/** \class BackendInterface backendinterface.h phonon/BackendInterface - * \short Main Backend class interface - * - * This interface defines the main factory of the backend. The createObject function creates all the - * objects needed by the frontend. - * - * The objectDescriptionIndexes and objectDescriptionProperties functions return information about - * available devices, effects and codecs. - * - * An implementation could look like this: - * \code - * QObject *Backend::createObject(BackendInterface::Class c, QObject *parent, const QList &args) - * { - * switch (c) { - * case MediaObjectClass: - * return new MediaObject(parent); - * case VolumeFaderEffectClass: - * return new VolumeFaderEffect(parent); - * case AudioOutputClass: - * return new AudioOutput(parent); - * case AudioDataOutputClass: - * return new AudioDataOutput(parent); - * case VisualizationClass: - * return new Visualization(parent); - * case VideoDataOutputClass: - * return new VideoDataOutput(parent); - * case EffectClass: - * return new Effect(args[0].toInt(), parent); - * case VideoWidgetClass: - * return new VideoWidget(qobject_cast(parent)); - * } - * return 0; - * } - * - * QSet Backend::objectDescriptionIndexes(ObjectDescriptionType type) const - * { - * QSet set; - * switch(type) - * { - * case Phonon::AudioOutputDeviceType: - * // use AudioDeviceEnumerator to list ALSA and OSS devices - * set << 10000 << 10001; - * break; - * case Phonon::AudioCaptureDeviceType: - * set << 20000 << 20001; - * break; - * case Phonon::VideoOutputDeviceType: - * break; - * case Phonon::VideoCaptureDeviceType: - * set << 30000 << 30001; - * break; - * case Phonon::VisualizationType: - * case Phonon::AudioCodecType: - * case Phonon::VideoCodecType: - * case Phonon::ContainerFormatType: - * break; - * case Phonon::EffectType: - * set << 0x7F000001; - * break; - * } - * return set; - * } - * - * QHash Backend::objectDescriptionProperties(ObjectDescriptionType type, int index) const - * { - * QHash ret; - * switch (type) { - * case Phonon::AudioOutputDeviceType: - * switch (index) { - * case 10000: - * ret.insert("name", QLatin1String("internal Soundcard")); - * break; - * case 10001: - * ret.insert("name", QLatin1String("USB Headset")); - * ret.insert("icon", KIcon("usb-headset")); - * ret.insert("available", false); - * break; - * } - * break; - * case Phonon::AudioCaptureDeviceType: - * switch (index) { - * case 20000: - * ret.insert("name", QLatin1String("Soundcard")); - * ret.insert("description", QLatin1String("first description")); - * break; - * case 20001: - * ret.insert("name", QLatin1String("DV")); - * ret.insert("description", QLatin1String("second description")); - * break; - * } - * break; - * case Phonon::VideoOutputDeviceType: - * break; - * case Phonon::VideoCaptureDeviceType: - * switch (index) { - * case 30000: - * ret.insert("name", QLatin1String("USB Webcam")); - * ret.insert("description", QLatin1String("first description")); - * break; - * case 30001: - * ret.insert("name", QLatin1String("DV")); - * ret.insert("description", QLatin1String("second description")); - * break; - * } - * break; - * case Phonon::VisualizationType: - * break; - * case Phonon::AudioCodecType: - * break; - * case Phonon::VideoCodecType: - * break; - * case Phonon::ContainerFormatType: - * break; - * case Phonon::EffectType: - * switch (index) { - * case 0x7F000001: - * ret.insert("name", QLatin1String("Delay")); - * ret.insert("description", QLatin1String("Simple delay effect with time, feedback and level controls.")); - * break; - * } - * break; - * } - * return ret; - * } - * \endcode - * - * \author Matthias Kretz - */ -class BackendInterface -{ - public: - /** - * \internal - * - * Silence gcc's warning. - */ - virtual ~BackendInterface() {} - - /** - * Classes that the createObject function has to handle. - */ - enum Class { - /** - * Request to return a %MediaObject object. - */ - MediaObjectClass, - /** - * Request to return a %VolumeFaderEffect object. - */ - VolumeFaderEffectClass, - /** - * Request to return a %AudioOutput object. - */ - AudioOutputClass, - /** - * Request to return a %AudioDataOutput object. - */ - AudioDataOutputClass, - /** - * Request to return a %Visualization object. - */ - VisualizationClass, - /** - * Request to return a %VideoDataOutput object. - */ - VideoDataOutputClass, - /** - * Request to return a %Effect object. - * - * Takes an additional int that specifies the effect Id. - */ - EffectClass, - /** - * Request to return a %VideoWidget object. - */ - VideoWidgetClass, - VideoGraphicsObjectClass /* < Request to return a %VideoGraphicsObject */ - }; - - /** - * Returns a new instance of the requested class. - * - * \param c The requested class. - * \param parent The parent object. - * \param args Additional arguments (documented in \ref Class). - */ - virtual QObject *createObject(Class c, QObject *parent, const QList &args = QList()) = 0; - - /** - * Returns the unique identifiers for the devices/effects/codecs of the given \p type. - * - * \param type see \ref ObjectDescriptionType - */ - virtual QList objectDescriptionIndexes(ObjectDescriptionType type) const = 0; - - /** - * Given a unique identifier that was returned from objectDescriptionIndexes this function - * returns a hash mapping property names to values. - * - * The property "name" must always be present. All other properties are optional. - * - * List of possible properties: - * \li \c \b name: The name of the device/effect/codec/... - * \li \c \b description: A text explaining what this device/effect/codec/... is/can do - * \li \c \b icon: An icon name (using the freedesktop naming scheme) or a QIcon for this - * device/effect/codec/... - * \li \c \b available: A bool telling whether the device is present or unplugged. - * - * \param type see \ref ObjectDescriptionType - * \param index The unique identifier that is returned from objectDescriptionIndexes - */ - virtual QHash objectDescriptionProperties(ObjectDescriptionType type, int index) const = 0; - - /** - * When this function is called the nodes given in the parameter list should not lose any - * signal data when connections are changed. - */ - virtual bool startConnectionChange(QSet) = 0; - - /** - * Defines a signal connection between the two given nodes. - */ - virtual bool connectNodes(QObject *, QObject *) = 0; - - /** - * Cuts a signal connection between the two given nodes. - */ - virtual bool disconnectNodes(QObject *, QObject *) = 0; - - /** - * When this function is called the nodes given in the parameter list may lose - * signal data when a port is not connected. - */ - virtual bool endConnectionChange(QSet) = 0; - - /** - * gets all available mime types - */ - virtual QStringList availableMimeTypes() const = 0; - -}; -} // namespace Phonon - -Q_DECLARE_INTERFACE(Phonon::BackendInterface, "BackendInterface3.phonon.kde.org") - - -#endif // PHONON_BACKENDINTERFACE_H diff --git a/src/phonon/effect.cpp b/src/phonon/effect.cpp deleted file mode 100644 index b97cf253b..000000000 --- a/src/phonon/effect.cpp +++ /dev/null @@ -1,135 +0,0 @@ -/* This file is part of the KDE project - Copyright (C) 2005-2007 Matthias Kretz - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), Nokia Corporation - (or its successors, if any) and the KDE Free Qt Foundation, which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . - -*/ -#include "effect.h" -#include "effect_p.h" -#include "effectparameter.h" -#include "effectinterface.h" -#include "factory_p.h" - -#define PHONON_INTERFACENAME EffectInterface - -#ifndef QT_NO_PHONON_EFFECT - -namespace Phonon -{ -Effect::~Effect() -{ -} - -Effect::Effect(const EffectDescription &description, QObject *parent) - : QObject(parent), MediaNode(*new EffectPrivate) -{ - P_D(Effect); - d->description = description; - d->createBackendObject(); -} - -Effect::Effect(EffectPrivate &dd, QObject *parent) - : QObject(parent), MediaNode(dd) -{ -} - -void EffectPrivate::createBackendObject() -{ - if (m_backendObject) - return; - P_Q(Effect); - m_backendObject = Factory::createEffect(description.index(), q); - if (m_backendObject) { - setupBackendObject(); - } -} - -//X Effect::Type Effect::type() const -//X { -//X P_D(const Effect); -//X return d->type; -//X } -//X -EffectDescription Effect::description() const -{ - P_D(const Effect); - return d->description; -} - -QList Effect::parameters() const -{ - P_D(const Effect); - // there should be an iface object, but better be safe for those backend - // switching corner-cases: when the backend switches the new backend might - // not support this effect -> no iface object - if (d->m_backendObject) { - return INTERFACE_CALL(parameters()); - } - return QList(); -} - -QVariant Effect::parameterValue(const EffectParameter ¶m) const -{ - P_D(const Effect); - if (!d->m_backendObject) { - return d->parameterValues[param]; - } - return INTERFACE_CALL(parameterValue(param)); -} - -void Effect::setParameterValue(const EffectParameter ¶m, const QVariant &newValue) -{ - P_D(Effect); - d->parameterValues[param] = newValue; - if (d->backendObject()) { - INTERFACE_CALL(setParameterValue(param, newValue)); - } -} - -bool EffectPrivate::aboutToDeleteBackendObject() -{ - if (m_backendObject) { - const QList parameters = pINTERFACE_CALL(parameters()); - for (int i = 0; i < parameters.count(); ++i) { - const EffectParameter &p = parameters.at(i); - parameterValues[p] = pINTERFACE_CALL(parameterValue(p)); - } - } - return true; -} - -void EffectPrivate::setupBackendObject() -{ - Q_ASSERT(m_backendObject); - - // set up attributes - const QList parameters = pINTERFACE_CALL(parameters()); - for (int i = 0; i < parameters.count(); ++i) { - const EffectParameter &p = parameters.at(i); - pINTERFACE_CALL(setParameterValue(p, parameterValues[p])); - } -} - -} //namespace Phonon - -#endif //QT_NO_PHONON_EFFECT - -#include "moc_effect.cpp" - -// vim: sw=4 ts=4 tw=80 -#include "moc_effect.h" diff --git a/src/phonon/effect.h b/src/phonon/effect.h deleted file mode 100644 index 0fd90492b..000000000 --- a/src/phonon/effect.h +++ /dev/null @@ -1,115 +0,0 @@ -/* This file is part of the KDE project - Copyright (C) 2005-2007 Matthias Kretz - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), Nokia Corporation - (or its successors, if any) and the KDE Free Qt Foundation, which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . - -*/ - - -#ifndef PHONON_EFFECT_H -#define PHONON_EFFECT_H - -#include "phonondefs.h" -#include -#include "objectdescription.h" -#include "medianode.h" - - -#ifndef QT_NO_PHONON_EFFECT - -class QString; -template class QList; - -namespace Phonon -{ - class EffectParameter; - class EffectPrivate; - - /** \class Effect effect.h phonon/Effect - * \short Effects that can be inserted into a Path. - * An effect is a special object which can perform - * transformations on the specified path. Examples may include simple - * modifiers such as fading or pitch shifting, or more complex mathematical - * transformations. - * - * In order to use an effect, insert it into the path as follows: - * \code - * Path path = Phonon::createPath(...); - * Effect *effect = new Effect(this); - * path.insertEffect(effect); - * \endcode - * - * The effect will immediately begin applying it's transformations on - * the path. To stop it, remove the Effect from the path. - * - * \ingroup PhononEffects - * \author Matthias Kretz - */ - class PHONON_EXPORT Effect : public QObject, public MediaNode - { - Q_OBJECT - P_DECLARE_PRIVATE(Effect) - - public: - ~Effect(); - -//X enum Type { -//X AudioEffect, -//X VideoEffect -//X }; - - /** - * QObject constructor. - * - * \param description An EffectDescription object to determine the - * type of effect. See BackendCapabilities::availableAudioEffects(). - * \param parent QObject parent - */ - explicit Effect(const EffectDescription &description, QObject *parent = 0); - -//X Type type() const; - - /** - * Returns the description of this effect. This is the same type as was - * passed to the constructor. - */ - EffectDescription description() const; - - /** - * Returns a list of parameters that this effect provides to control - * its behaviour. - * - * \see EffectParameter - * \see EffectWidget - */ - QList parameters() const; - - QVariant parameterValue(const EffectParameter&) const; - void setParameterValue(const EffectParameter&, const QVariant &value); - - protected: - Effect(EffectPrivate &dd, QObject *parent); - }; -} //namespace Phonon - -#endif // QT_NO_EFFECT - - -// vim: sw=4 ts=4 tw=80 -#endif // PHONON_EFFECT_H - diff --git a/src/phonon/effect_p.h b/src/phonon/effect_p.h deleted file mode 100644 index 82ca4885f..000000000 --- a/src/phonon/effect_p.h +++ /dev/null @@ -1,57 +0,0 @@ -/* This file is part of the KDE project - Copyright (C) 2006-2007 Matthias Kretz - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), Nokia Corporation - (or its successors, if any) and the KDE Free Qt Foundation, which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . - -*/ - -#ifndef EFFECT_P_H -#define EFFECT_P_H - -#include "effect.h" -#include "effectparameter.h" -#include "medianode_p.h" -#include -#include -#include "phonondefs_p.h" - -#ifndef QT_NO_PHONON_EFFECT - -namespace Phonon -{ -class EffectPrivate : public MediaNodePrivate -{ - P_DECLARE_PUBLIC(Effect) - PHONON_PRIVATECLASS - public: - virtual QObject *qObject() { return q_func(); } - protected: - EffectPrivate() - { - } - -//X Effect::Type type; - EffectDescription description; - QHash parameterValues; -}; -} //namespace Phonon - -#endif //QT_NO_PHONON_EFFECT - -#endif // EFFECT_P_H -// vim: sw=4 ts=4 tw=80 diff --git a/src/phonon/effectinterface.h b/src/phonon/effectinterface.h deleted file mode 100644 index 491fa0e09..000000000 --- a/src/phonon/effectinterface.h +++ /dev/null @@ -1,64 +0,0 @@ -/* This file is part of the KDE project - Copyright (C) 2006-2008 Matthias Kretz - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), Nokia Corporation - (or its successors, if any) and the KDE Free Qt Foundation, which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . - -*/ - -#ifndef PHONON_EFFECTINTERFACE_H -#define PHONON_EFFECTINTERFACE_H - -#include "phononnamespace.h" -#include - - -#ifndef QT_NO_PHONON_EFFECT - -namespace Phonon -{ - class EffectParameter; - /** \class EffectInterface effectinterface.h phonon/EffectInterface - * \short Interface for Effect objects - * - * \author Matthias Kretz - */ - class EffectInterface - { - public: - virtual ~EffectInterface() {} - /** - * Returns the EffectParameter objects to describe the parameters of this effect. - */ - virtual QList parameters() const = 0; - /** - * Returns the value for the selected parameter. - */ - virtual QVariant parameterValue(const EffectParameter &) const = 0; - /** - * Sets the value for the selected parameter. - */ - virtual void setParameterValue(const EffectParameter &, const QVariant &newValue) = 0; - }; -} //namespace Phonon - -Q_DECLARE_INTERFACE(Phonon::EffectInterface, "EffectInterface0.phonon.kde.org") - -#endif //QT_NO_PHONON_EFFECT - - -#endif // PHONON_EFFECTINTERFACE_H diff --git a/src/phonon/effectparameter.cpp b/src/phonon/effectparameter.cpp deleted file mode 100644 index d8ff3e15c..000000000 --- a/src/phonon/effectparameter.cpp +++ /dev/null @@ -1,138 +0,0 @@ -/* This file is part of the KDE project - Copyright (C) 2006 Matthias Kretz - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), Nokia Corporation - (or its successors, if any) and the KDE Free Qt Foundation, which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . - -*/ - -#include "effectparameter.h" -#include "effectparameter_p.h" - -#ifndef QT_NO_PHONON_EFFECT - -namespace Phonon -{ - -uint qHash(const Phonon::EffectParameter ¶m) -{ - return param.id(); -} - -EffectParameter::EffectParameter() - : d(new EffectParameterPrivate) -{ -} - -EffectParameter::EffectParameter(int parameterId, const QString &name, Hints hints, - const QVariant &defaultValue, const QVariant &min, const QVariant &max, - const QVariantList &values, const QString &description) - : d(new EffectParameterPrivate) -{ - d->parameterId = parameterId; - d->min = min; - d->max = max; - d->defaultValue = defaultValue; - d->name = name; - d->possibleValues = values; - d->description = description; - d->hints = hints; -} - -EffectParameter::~EffectParameter() -{ -} - -EffectParameter::EffectParameter(const EffectParameter &rhs) - : d(rhs.d) -{ -} - -EffectParameter &EffectParameter::operator=(const EffectParameter &rhs) -{ - d = rhs.d; - return *this; -} - -bool EffectParameter::operator<(const EffectParameter &rhs) const -{ - return d->parameterId < rhs.d->parameterId; -} - -bool EffectParameter::operator==(const EffectParameter &rhs) const -{ - return d->parameterId == rhs.d->parameterId; -} - -bool EffectParameter::operator>(const EffectParameter &rhs) const -{ - return d->parameterId > rhs.d->parameterId; -} - -const QString &EffectParameter::name() const -{ - return d->name; -} - -const QString &EffectParameter::description() const -{ - return d->description; -} - -bool EffectParameter::isLogarithmicControl() const -{ - return d->hints & LogarithmicHint; -} - -QVariant::Type EffectParameter::type() const -{ - if (d->possibleValues.isEmpty()) { - return d->defaultValue.type(); - } - return QVariant::String; -} - -QVariantList EffectParameter::possibleValues() const -{ - return d->possibleValues; -} - -QVariant EffectParameter::minimumValue() const -{ - return d->min; -} - -QVariant EffectParameter::maximumValue() const -{ - return d->max; -} - -QVariant EffectParameter::defaultValue() const -{ - return d->defaultValue; -} - -int EffectParameter::id() const -{ - return d->parameterId; -} - -} - -#endif //QT_NO_PHONON_EFFECT - -// vim: sw=4 ts=4 diff --git a/src/phonon/effectparameter.h b/src/phonon/effectparameter.h deleted file mode 100644 index 451b61675..000000000 --- a/src/phonon/effectparameter.h +++ /dev/null @@ -1,233 +0,0 @@ -/* This file is part of the KDE project - Copyright (C) 2006 Matthias Kretz - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), Nokia Corporation - (or its successors, if any) and the KDE Free Qt Foundation, which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . - -*/ - -#ifndef PHONON_EFFECTPARAMETER_H -#define PHONON_EFFECTPARAMETER_H - -#include "phonon_export.h" - -#include -#include - - -#ifndef QT_NO_PHONON_EFFECT - -namespace Phonon -{ - -class Effect; -class EffectParameterPrivate; - -/** \class EffectParameter effectparameter.h phonon/EffectParameter - * \brief This class describes one parameter of an effect. - * - * \ingroup PhononEffects - * \author Matthias Kretz - * \see Effect - */ -class PHONON_EXPORT EffectParameter -{ - friend class BrightnessControl; - public: - /** - * \internal - * - * Creates an invalid effect parameter. - */ - EffectParameter(); - - /** - * The name of the parameter. Can be used as the label. - * - * \return A label for the parameter. - */ - const QString &name() const; - - /** - * The parameter may come with a description (LADSPA doesn't have a - * field for this, so don't expect many effects to provide a - * description). - * - * The description can be used for a tooltip or WhatsThis help. - * - * \return A text describing the parameter. - */ - const QString &description() const; - - /** - * Returns the parameter type. - * - * Common types are QVariant::Int, QVariant::Double, QVariant::Bool and QVariant::String. When - * QVariant::String is returned you get the possible values from possibleValues. - */ - QVariant::Type type() const; - - /** - * Returns whether the parameter should be - * displayed using a logarithmic scale. This is particularly useful for - * frequencies and gains. - */ - bool isLogarithmicControl() const; - - /** - * The minimum value to be used for the control to edit the parameter. - * - * If the returned QVariant is invalid the value is not bounded from - * below. - */ - QVariant minimumValue() const; - - /** - * The maximum value to be used for the control to edit the parameter. - * - * If the returned QVariant is invalid the value is not bounded from - * above. - */ - QVariant maximumValue() const; - - /** - * The default value. - */ - QVariant defaultValue() const; - - /** - * The possible values to be used for the control to edit the parameter. - * - * if the value of this parameter is to be picked from predefined values - * this returns the list (otherwise it returns an empty QVariantList). - */ - QVariantList possibleValues() const; - - /** - * \internal - * compares the ids of the parameters - */ - bool operator<(const EffectParameter &rhs) const; - - /** - * \internal - * compares the ids of the parameters - */ - bool operator>(const EffectParameter &rhs) const; - - /** - * \internal - * compares the ids of the parameters - */ - bool operator==(const EffectParameter &rhs) const; - - /* dtor, cctor and operator= for forward decl of EffectParameterPrivate */ - ~EffectParameter(); - EffectParameter(const EffectParameter &rhs); - EffectParameter &operator=(const EffectParameter &rhs); - - /** - * Only for backend developers: - * - * Flags to set the return values of isToggleControl(), - * isLogarithmicControl(), isIntegerControl(), isBoundedBelow() and - * isBoundedAbove(). The values of the flags correspond to the values - * used for LADSPA effects. - */ - enum Hint { - /** - * If this hint is set it means that - * the control has only two states: zero and non-zero. - * - * \see isToggleControl() - */ - ToggledHint = 0x04, - - /* LADSPA's SAMPLE_RATE hint needs to be translated by the backend - * to normal bounds, as the backend knows the sample rate - and the - * frontend doesn't */ - - /** - * \see isLogarithmicControl() - */ - LogarithmicHint = 0x10, - /** - * \see isIntegerControl - */ - IntegerHint = 0x20 - }; - Q_DECLARE_FLAGS(Hints, Hint) - - /** - * Only to be used by backend implementations: - * - * Creates a new effect parameter. - * - * \param parameterId This is a number to uniquely identify the - * parameter. The id is used for value() and setValue(). - * - * \param name The name/label for this parameter. - * - * \param hints Sets the hints for the type of parameter. - * - * \param defaultValue The value that should be used as a default. - * - * \param min The minimum value allowed for this parameter. You only - * need to set this if the BoundedBelowHint is set. - * - * \param max The maximum value allowed for this parameter. You only - * need to set this if the BoundedAboveHint is set. - * - * \param description A descriptive text for the parameter - * (explaining what it controls) to be used as a tooltip or - * WhatsThis help. - */ - EffectParameter(int parameterId, const QString &name, Hints hints, - const QVariant &defaultValue, const QVariant &min = QVariant(), - const QVariant &max = QVariant(), const QVariantList &values = QVariantList(), - const QString &description = QString()); - - /** - * \internal - * - * Returns the parameter's id. - */ - int id() const; - - protected: - /** - * The data is implicitly shared. - */ - QExplicitlySharedDataPointer d; -}; - -uint PHONON_EXPORT qHash(const Phonon::EffectParameter ¶m); - -} // namespace Phonon - -#if defined(Q_CC_MSVC) && _MSC_VER <= 1300 -//this ensures that code outside Phonon can use the hash function -//it also a workaround for some compilers -inline uint qHash(const Phonon::EffectParameter ¶m) { return Phonon::qHash(param); } //krazy:exclude=inline -#endif -Q_DECLARE_OPERATORS_FOR_FLAGS(Phonon::EffectParameter::Hints) - -#endif //QT_NO_PHONON_EFFECT - - -#endif // PHONON_EFFECTPARAMETER_H -// vim: sw=4 ts=4 tw=80 diff --git a/src/phonon/effectparameter_p.h b/src/phonon/effectparameter_p.h deleted file mode 100644 index ad56d81e6..000000000 --- a/src/phonon/effectparameter_p.h +++ /dev/null @@ -1,52 +0,0 @@ -/* This file is part of the KDE project - Copyright (C) 2006 Matthias Kretz - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), Nokia Corporation - (or its successors, if any) and the KDE Free Qt Foundation, which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . - -*/ - -#ifndef EFFECTPARAMETER_P_H -#define EFFECTPARAMETER_P_H - -#include "effectparameter.h" -#include - -#ifndef QT_NO_PHONON_EFFECT - -namespace Phonon -{ - -class EffectParameterPrivate : public QSharedData -{ - public: - int parameterId; - QVariant min; - QVariant max; - QVariant defaultValue; - QString name; - QString description; - QVariantList possibleValues; - EffectParameter::Hints hints; -}; - -} // namespace Phonon - -#endif //QT_NO_PHONON_EFFECT - -#endif // EFFECTPARAMETER_P_H -// vim: sw=4 ts=4 tw=80 diff --git a/src/phonon/effectwidget.cpp b/src/phonon/effectwidget.cpp deleted file mode 100644 index a62f818d4..000000000 --- a/src/phonon/effectwidget.cpp +++ /dev/null @@ -1,256 +0,0 @@ -/* This file is part of the KDE project - Copyright (C) 2006-2007 Matthias Kretz - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), Nokia Corporation - (or its successors, if any) and the KDE Free Qt Foundation, which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . - -*/ - -#include "effectwidget.h" -#include "effectwidget_p.h" - -#include -#include - -#include "effect.h" -#include "effectparameter.h" -#include "phonondefs_p.h" -#include -#include -#include -#include -#include -#include -#include - -#ifdef min -#undef min -#endif -#ifdef max -#undef max -#endif -static const qreal DEFAULT_MIN = std::numeric_limits::min(); -static const qreal DEFAULT_MAX = std::numeric_limits::max(); -static const int DEFAULT_MIN_INT = std::numeric_limits::min(); -static const int DEFAULT_MAX_INT = std::numeric_limits::max(); -static const int SLIDER_RANGE = 8; -static const int TICKINTERVAL = 4; - - -#ifndef QT_NO_PHONON_EFFECTWIDGET - -namespace Phonon -{ - -EffectWidget::EffectWidget(Effect *effect, QWidget *parent) - : QWidget(parent), - k_ptr(new EffectWidgetPrivate(effect)) -{ - P_D(EffectWidget); - d->q_ptr = this; - d->autogenerateUi(); -} - -EffectWidget::~EffectWidget() -{ - delete k_ptr; -} - -/* -EffectWidget::EffectWidget(EffectWidgetPrivate &dd, QWidget *parent) - : QWidget(parent) - , k_ptr(&dd) -{ - P_D(EffectWidget); - d->q_ptr = this; - d->autogenerateUi(); -} -*/ - -EffectWidgetPrivate::EffectWidgetPrivate(Effect *e) - : effect(e) -{ - //TODO: look up whether there is a specialized widget for this effect. This - //could be a DSO or a Designer ui file found via KTrader. - // - //if no specialized widget is available: -} - -void EffectWidgetPrivate::autogenerateUi() -{ - P_Q(EffectWidget); - QVBoxLayout *mainLayout = new QVBoxLayout(q); - mainLayout->setMargin(0); - const QList parameters = effect->parameters(); - for (int i = 0; i < parameters.count(); ++i) { - const EffectParameter ¶ = parameters.at(i); - QVariant value = effect->parameterValue(para); - QHBoxLayout *pLayout = new QHBoxLayout; - mainLayout->addLayout(pLayout); - - QLabel *label = new QLabel(q); - pLayout->addWidget(label); - label->setText(para.name()); -#ifndef QT_NO_TOOLTIP - label->setToolTip(para.description()); -#endif - - QWidget *control = 0; - switch (int(para.type())) { - case QVariant::String: - { - QComboBox *cb = new QComboBox(q); - control = cb; - if (value.type() == QVariant::Int) { - //value just defines the item index - for (int i = 0; i < para.possibleValues().count(); ++i) { - cb->addItem(para.possibleValues().at(i).toString()); - } - cb->setCurrentIndex(value.toInt()); - QObject::connect(cb, SIGNAL(currentIndexChanged(int)), q, SLOT(_k_setIntParameter(int))); - } else { - for (int i = 0; i < para.possibleValues().count(); ++i) { - const QVariant &item = para.possibleValues().at(i); - cb->addItem(item.toString()); - if (item == value) { - cb->setCurrentIndex(cb->count() - 1); - } - } - QObject::connect(cb, SIGNAL(currentIndexChanged(QString)), q, SLOT(_k_setStringParameter(QString))); - } - } - break; - case QVariant::Bool: - { - QCheckBox *cb = new QCheckBox(q); - control = cb; - cb->setChecked(value.toBool()); - QObject::connect(cb, SIGNAL(toggled(bool)), q, SLOT(_k_setToggleParameter(bool))); - } - break; - case QVariant::Int: - { - QSpinBox *sb = new QSpinBox(q); - control = sb; - bool minValueOk = false; - bool maxValueOk = false; - const int minValue = para.minimumValue().toInt(&minValueOk); - const int maxValue = para.maximumValue().toInt(&maxValueOk); - - sb->setRange(minValueOk ? minValue : DEFAULT_MIN_INT, maxValueOk ? maxValue : DEFAULT_MAX_INT); - sb->setValue(value.toInt()); - QObject::connect(sb, SIGNAL(valueChanged(int)), q, SLOT(_k_setIntParameter(int))); - } - break; - case QMetaType::Float: - case QVariant::Double: - { - const qreal minValue = para.minimumValue().canConvert(QVariant::Double) ? - para.minimumValue().toReal() : DEFAULT_MIN; - const qreal maxValue = para.maximumValue().canConvert(QVariant::Double) ? - para.maximumValue().toReal() : DEFAULT_MAX; - - if (minValue == -1. && maxValue == 1.) { - //Special case values between -1 and 1.0 to use a slider for improved usability - QSlider *slider = new QSlider(Qt::Horizontal, q); - control = slider; - slider->setRange(-SLIDER_RANGE, +SLIDER_RANGE); - slider->setValue(int(SLIDER_RANGE * value.toReal())); - slider->setTickPosition(QSlider::TicksBelow); - slider->setTickInterval(TICKINTERVAL); - QObject::connect(slider, SIGNAL(valueChanged(int)), q, SLOT(_k_setSliderParameter(int))); - } else { - double step = 0.1; - if (qAbs(maxValue - minValue) > 50) - step = 1.0; - QDoubleSpinBox *sb = new QDoubleSpinBox(q); - control = sb; - sb->setRange(minValue, maxValue); - sb->setValue(value.toDouble()); - sb->setSingleStep(step); - QObject::connect(sb, SIGNAL(valueChanged(double)), q, - SLOT(_k_setDoubleParameter(double))); - } - } - break; - default: - break; - } - - if (control) { -#ifndef QT_NO_TOOLTIP - control->setToolTip(para.description()); -#endif -#ifndef QT_NO_SHORTCUT - label->setBuddy(control); -#endif - pLayout->addWidget(control); - parameterForObject.insert(control, para); - } - } -} - -void EffectWidgetPrivate::_k_setToggleParameter(bool checked) -{ - P_Q(EffectWidget); - if (parameterForObject.contains(q->sender())) { - effect->setParameterValue(parameterForObject[q->sender()], checked); - } -} - -void EffectWidgetPrivate::_k_setIntParameter(int value) -{ - P_Q(EffectWidget); - if (parameterForObject.contains(q->sender())) { - effect->setParameterValue(parameterForObject[q->sender()], value); - } -} - -void EffectWidgetPrivate::_k_setDoubleParameter(double value) -{ - P_Q(EffectWidget); - if (parameterForObject.contains(q->sender())) { - effect->setParameterValue(parameterForObject[q->sender()], value); - } -} - -void EffectWidgetPrivate::_k_setStringParameter(const QString &value) -{ - P_Q(EffectWidget); - if (parameterForObject.contains(q->sender())) { - effect->setParameterValue(parameterForObject[q->sender()], value); - } -} - -void EffectWidgetPrivate::_k_setSliderParameter(int value) -{ - P_Q(EffectWidget); - if (parameterForObject.contains(q->sender())) { - effect->setParameterValue(parameterForObject[q->sender()], double(value) / double(SLIDER_RANGE)); - } -} - - -} // namespace Phonon - - -#endif // QT_NO_PHONON_EFFECTWIDGET - -#include "moc_effectwidget.cpp" - -// vim: sw=4 ts=4 -#include "moc_effectwidget.h" diff --git a/src/phonon/effectwidget.h b/src/phonon/effectwidget.h deleted file mode 100644 index 2d33ce0f1..000000000 --- a/src/phonon/effectwidget.h +++ /dev/null @@ -1,72 +0,0 @@ -/* This file is part of the KDE project - Copyright (C) 2006-2007 Matthias Kretz - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), Nokia Corporation - (or its successors, if any) and the KDE Free Qt Foundation, which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . - -*/ - -#ifndef PHONON_UI_EFFECTWIDGET_H -#define PHONON_UI_EFFECTWIDGET_H - -#include "phonon_export.h" -#include "phonondefs.h" -#include - - -#ifndef QT_NO_PHONON_EFFECTWIDGET - -namespace Phonon -{ -class Effect; - - class EffectWidgetPrivate; - - /** \class EffectWidget effectwidget.h phonon/EffectWidget - * \brief Widget to control the parameters of an Effect. - * - * \ingroup PhononWidgets - * \ingroup PhononEffects - * \author Matthias Kretz - */ - class PHONON_EXPORT EffectWidget : public QWidget - { - Q_OBJECT - P_DECLARE_PRIVATE(EffectWidget) - public: - explicit EffectWidget(Effect *effect, QWidget *parent = 0); - ~EffectWidget(); - - protected: - //EffectWidget(EffectWidgetPrivate &dd, QWidget *parent); - EffectWidgetPrivate *const k_ptr; - - private: - Q_PRIVATE_SLOT(k_func(), void _k_setToggleParameter(bool checked)) - Q_PRIVATE_SLOT(k_func(), void _k_setIntParameter(int value)) - Q_PRIVATE_SLOT(k_func(), void _k_setDoubleParameter(double value)) - Q_PRIVATE_SLOT(k_func(), void _k_setStringParameter(const QString &)) - Q_PRIVATE_SLOT(k_func(), void _k_setSliderParameter(int)) - }; -} // namespace Phonon - -#endif //QT_NO_PHONON_EFFECTWIDGET - - -#endif // PHONON_UI_EFFECTWIDGET_H - -// vim: sw=4 ts=4 tw=100 diff --git a/src/phonon/effectwidget_p.h b/src/phonon/effectwidget_p.h deleted file mode 100644 index 6bff912b8..000000000 --- a/src/phonon/effectwidget_p.h +++ /dev/null @@ -1,62 +0,0 @@ -/* This file is part of the KDE project - Copyright (C) 2006-2007 Matthias Kretz - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), Nokia Corporation - (or its successors, if any) and the KDE Free Qt Foundation, which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . - -*/ - -#ifndef PHONON_UI_EFFECTWIDGET_P_H -#define PHONON_UI_EFFECTWIDGET_P_H - -#include - -#include "effectparameter.h" -#include "effectwidget.h" -#include "phonondefs_p.h" - -#ifndef QT_NO_PHONON_EFFECTWIDGET - -namespace Phonon -{ - class EffectWidgetPrivate - { - P_DECLARE_PUBLIC(EffectWidget) - protected: - EffectWidgetPrivate(Effect *effect); - - EffectWidget *q_ptr; - - private: - Effect *effect; - QHash parameterForObject; - - void _k_setToggleParameter(bool checked); - void _k_setIntParameter(int value); - void _k_setDoubleParameter(double value); - void _k_setStringParameter(const QString &); - void _k_setSliderParameter(int); - - void autogenerateUi(); - }; -} // namespace Phonon - -#endif //QT_NO_PHONON_EFFECTWIDGET - -#endif // PHONON_UI_EFFECTWIDGET_P_H - -// vim: sw=4 ts=4 tw=80 diff --git a/src/phonon/experimental/abstractaudiodataoutput.cpp b/src/phonon/experimental/abstractaudiodataoutput.cpp deleted file mode 100644 index af7bad15d..000000000 --- a/src/phonon/experimental/abstractaudiodataoutput.cpp +++ /dev/null @@ -1,113 +0,0 @@ -/* This file is part of the KDE project - Copyright (C) 2008 Matthias Kretz - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), Nokia Corporation - (or its successors, if any) and the KDE Free Qt Foundation, which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . - -*/ - -#include "abstractaudiodataoutput.h" -#include "abstractaudiodataoutput_p.h" -#include "audiodataoutputinterface.h" -#include "factory_p.h" -#include "../phonondefs_p.h" - -namespace Phonon -{ -namespace Experimental -{ - -AbstractAudioDataOutput::AbstractAudioDataOutput() - : MediaNode(*new AbstractAudioDataOutputPrivate) -{ - P_D(AbstractAudioDataOutput); - d->isRunning = false; - d->allowedFormats << AudioFormat(); -} - -AbstractAudioDataOutput::~AbstractAudioDataOutput() -{ - setRunning(false); -} - -QSet AbstractAudioDataOutput::allowedFormats() const -{ - P_D(const AbstractAudioDataOutput); - return d->allowedFormats; -} - -void AbstractAudioDataOutput::setAllowedFormats(const QSet &allowedFormats) -{ - P_D(AbstractAudioDataOutput); - d->allowedFormats = allowedFormats; -} - -bool AbstractAudioDataOutput::isRunning() const -{ - P_D(const AbstractAudioDataOutput); - return d->isRunning; -} - -void AbstractAudioDataOutput::setRunning(bool running) -{ - P_D(AbstractAudioDataOutput); - Iface iface(d); - if (iface) { - if (running) { - iface->setFrontendObject(this); - } else { - iface->setFrontendObject(0); - } - } -} - -void AbstractAudioDataOutput::start() -{ - setRunning(true); -} - -void AbstractAudioDataOutput::stop() -{ - setRunning(false); -} - -void AbstractAudioDataOutputPrivate::setupBackendObject() -{ - P_Q(AbstractAudioDataOutput); - Q_ASSERT(m_backendObject); - //AbstractAudioOutputPrivate::setupBackendObject(); - if (isRunning) { - Iface iface(this); - if (iface) { - iface->setFrontendObject(q); - } - } -} - -void AbstractAudioDataOutputPrivate::createBackendObject() -{ - if (m_backendObject) - return; - //P_Q(AbstractAudioDataOutput); - m_backendObject = Factory::createAudioDataOutput(0); - if (m_backendObject) { - setupBackendObject(); - } -} - -} // namespace Experimental -} // namespace Phonon diff --git a/src/phonon/experimental/abstractaudiodataoutput.h b/src/phonon/experimental/abstractaudiodataoutput.h deleted file mode 100644 index 600f63679..000000000 --- a/src/phonon/experimental/abstractaudiodataoutput.h +++ /dev/null @@ -1,100 +0,0 @@ -/* This file is part of the KDE project - Copyright (C) 2005-2006,2008 Matthias Kretz - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), Nokia Corporation - (or its successors, if any) and the KDE Free Qt Foundation, which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . - -*/ -#ifndef PHONON_X_ABSTRACTAUDIODATAOUTPUT_H -#define PHONON_X_ABSTRACTAUDIODATAOUTPUT_H - -#include "export.h" -#include "../medianode.h" -#include "../phonondefs.h" -#include "audioformat.h" - -#ifndef DOXYGEN_SHOULD_SKIP_THIS -template class QSet; -#endif - -namespace Phonon -{ -namespace Experimental -{ - -class Packet; -class AbstractAudioDataOutputPrivate; - -/** - * \short This class gives you the audio data. - * - * This class implements a special AbstractAudioOutput that gives your - * application the audio data. This class is usable for realtime performance. - * - * \author Matthias Kretz - */ -class PHONONEXPERIMENTAL_EXPORT AbstractAudioDataOutput : public Phonon::MediaNode -{ - P_DECLARE_PRIVATE(AbstractAudioDataOutput) - public: - /** - * Constructs an AbstractAudioDataOutput - */ - AbstractAudioDataOutput(); - ~AbstractAudioDataOutput(); - - /** - * Lists the formats this output is allowed to pass via frameReady. - */ - virtual QSet allowedFormats() const; - - // TODO: consider to remove the following function and make the above pure virtual - /** - * Defaults to AudioFormat(). - * I.e. 16 bit, stereo, 48000 kHz PCM data. - */ - void setAllowedFormats(const QSet &); - - bool isRunning() const; - - /** - * This function is called whenever an audio packet is ready for - * processing. - * - * \warning packetReady can get called from any thread (other than the - * main thread or the thread affinity of this QObject). - */ - virtual void packetReady(const Packet &) = 0; - - /** - * This function is called after the last packetReady of a media was - * called. - */ - void endOfMedia(); - - void setRunning(bool running); - void start(); - void stop(); - - protected: - AbstractAudioDataOutput(AbstractAudioDataOutputPrivate &dd); -}; - -} // namespace Experimental -} // namespace Phonon - -#endif // PHONON_X_ABSTRACTAUDIODATAOUTPUT_H diff --git a/src/phonon/experimental/abstractaudiodataoutput_p.h b/src/phonon/experimental/abstractaudiodataoutput_p.h deleted file mode 100644 index 14430cfca..000000000 --- a/src/phonon/experimental/abstractaudiodataoutput_p.h +++ /dev/null @@ -1,51 +0,0 @@ -/* This file is part of the KDE project - Copyright (C) 2008 Matthias Kretz - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), Nokia Corporation - (or its successors, if any) and the KDE Free Qt Foundation, which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . - -*/ - -#ifndef PHONON_X_ABSTRACTAUDIODATAOUTPUT_P_H -#define PHONON_X_ABSTRACTAUDIODATAOUTPUT_P_H - -#include "abstractaudiodataoutput.h" -#include "../medianode_p.h" -#include "phonondefs_p.h" - -namespace Phonon -{ -namespace Experimental -{ - -class AbstractAudioDataOutputPrivate : public Phonon::MediaNodePrivate -{ - P_DECLARE_PUBLIC(AbstractAudioDataOutput) - protected: - virtual bool aboutToDeleteBackendObject() { return true; } - virtual void createBackendObject(); - void setupBackendObject(); - - private: - bool isRunning; - QSet allowedFormats; -}; - -} // namespace Experimental -} // namespace Phonon - -#endif // PHONON_X_ABSTRACTAUDIODATAOUTPUT_P_H diff --git a/src/phonon/experimental/abstractmediastream2.cpp b/src/phonon/experimental/abstractmediastream2.cpp deleted file mode 100644 index 19b095c5a..000000000 --- a/src/phonon/experimental/abstractmediastream2.cpp +++ /dev/null @@ -1,188 +0,0 @@ -/* This file is part of the KDE project - Copyright (C) 2007-2008 Matthias Kretz - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), Nokia Corporation - (or its successors, if any) and the KDE Free Qt Foundation, which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . - -*/ - -#include "abstractmediastream2.h" -#include "abstractmediastream2_p.h" -#include "mediaobjectinterface.h" -#include "mediaobject_p.h" -#include "phononnamespace_p.h" - -#include -#include - -namespace Phonon -{ - -bool AbstractMediaStream2::event(QEvent *e) -{ - if (e->type() == QEvent::ThreadChange) { - Q_D(AbstractMediaStream2); - if (d->eventDispatcher) { - pWarning() << "Do not call moveToThread on an AbstractMediaStream2 object when it is in use."; - QObject::disconnect(d->eventDispatcher, SIGNAL(awake()), this, SLOT(_k_handleStreamEvent())); - d->eventDispatcher = 0; - } - } - return AbstractMediaStream::event(e); -} - -void AbstractMediaStream2Private::dataReady() -{ - Q_Q(AbstractMediaStream2); - if (!eventDispatcher) { - eventDispatcher = QAbstractEventDispatcher::instance(q->thread()); - if (!eventDispatcher) { - pError() << "AbstractMediaStream2 needs to run in a thread with QEventLoop"; - return; - } else { - QObject::connect(eventDispatcher, SIGNAL(awake()), q, SLOT(_k_handleStreamEvent()), Qt::DirectConnection); - } - } - eventDispatcher->wakeUp(); -} - -void AbstractMediaStream2Private::_k_handleStreamEvent() -{ - Q_ASSERT(streamEventQueue); - Q_Q(AbstractMediaStream2); - StreamEventQueue::Command c; - while (streamEventQueue->nextCommandForFrontend(&c)) { - switch (c.command) { - case StreamEventQueue::SetStreamSize: - case StreamEventQueue::SetSeekable: - case StreamEventQueue::Write: - case StreamEventQueue::EndOfData: - case StreamEventQueue::SeekDone: - case StreamEventQueue::ResetDone: - case StreamEventQueue::ConnectDone: - pFatal("AbstractMediaStream2 received wrong Command"); - break; - case StreamEventQueue::NeedData: - q->needData(qvariant_cast(c.data)); - break; - case StreamEventQueue::EnoughData: - q->enoughData(); - break; - case StreamEventQueue::Seek: - q->seekStream(qvariant_cast(c.data)); - break; - case StreamEventQueue::Reset: - q->reset(); - break; - case StreamEventQueue::Connect: - if (firstConnect) { - firstConnect = false; - streamEventQueue->sendToBackend(StreamEventQueue::ConnectDone); - streamEventQueue->sendToBackend(StreamEventQueue::SetSeekable, streamSeekable); - if (streamSize != 0) { - streamEventQueue->sendToBackend(StreamEventQueue::SetStreamSize, streamSize); - } - } else { - ++connectReset; - q->reset(); - } - break; - } - } -} - -AbstractMediaStream2::AbstractMediaStream2(QObject *parent) - : AbstractMediaStream(*new AbstractMediaStream2Private, parent) -{ -} - -AbstractMediaStream2::AbstractMediaStream2(AbstractMediaStream2Private &dd, QObject *parent) - : AbstractMediaStream(dd, parent) -{ -} - -void AbstractMediaStream2Private::setStreamSize(qint64 newSize) -{ - streamSize = newSize; - streamEventQueue->sendToBackend(StreamEventQueue::SetStreamSize, newSize); -} - -void AbstractMediaStream2Private::setStreamSeekable(bool s) -{ - streamSeekable = s; - streamEventQueue->sendToBackend(StreamEventQueue::SetSeekable, s); -} - -void AbstractMediaStream2Private::writeData(const QByteArray &data) -{ - streamEventQueue->sendToBackend(StreamEventQueue::Write, data); -} - -void AbstractMediaStream2Private::endOfData() -{ - streamEventQueue->sendToBackend(StreamEventQueue::EndOfData); -} - -void AbstractMediaStream2::resetDone() -{ - Q_D(AbstractMediaStream2); - if (d->connectReset > 0) { - --d->connectReset; - d->streamEventQueue->sendToBackend(StreamEventQueue::ConnectDone); - } else { - d->streamEventQueue->sendToBackend(StreamEventQueue::ResetDone); - } - d->streamEventQueue->sendToBackend(StreamEventQueue::SetSeekable, d->streamSeekable); - if (d->streamSize != 0) { - d->streamEventQueue->sendToBackend(StreamEventQueue::SetStreamSize, d->streamSize); - } -} - -void AbstractMediaStream2::seekStreamDone() -{ - d_func()->streamEventQueue->sendToBackend(StreamEventQueue::SeekDone); -} - -AbstractMediaStream2Private::AbstractMediaStream2Private() - : streamEventQueue(new StreamEventQueue), - eventDispatcher(0), - connectReset(0), - firstConnect(true) -{ - streamEventQueue->ref(); - streamEventQueue->setFrontendCommandHandler(this); -} - -AbstractMediaStream2Private::~AbstractMediaStream2Private() -{ - // setFrontendCommandHandler blocks internally until a handler that might be called right now is - // done. That means AbstractMediaStream2Private::dataReady will either not run again or it will - // be done before this object and our q object are deleted. - streamEventQueue->setFrontendCommandHandler(0); - streamEventQueue->deref(); - streamEventQueue = 0; - // if eventDispatcher->wakeUp() was called and we are now still connected to its awake() signal - // then the QObject will be deleted until execution reaches the event loop again and - // _k_handleStreamEvent will not get called -} - -} // namespace Phonon - -#include "experimental/moc_abstractmediastream2.cpp" - -// vim: sw=4 sts=4 et tw=100 -#include "experimental/moc_abstractmediastream2.h" diff --git a/src/phonon/experimental/abstractmediastream2.h b/src/phonon/experimental/abstractmediastream2.h deleted file mode 100644 index d0012e235..000000000 --- a/src/phonon/experimental/abstractmediastream2.h +++ /dev/null @@ -1,149 +0,0 @@ -/* This file is part of the KDE project - Copyright (C) 2007-2008 Matthias Kretz - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), Nokia Corporation - (or its successors, if any) and the KDE Free Qt Foundation, which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . - -*/ - -#ifndef PHONON_ABSTRACTMEDIASTREAM2_H -#define PHONON_ABSTRACTMEDIASTREAM2_H - -#include "abstractmediastream.h" - - -class QByteArray; - -namespace Phonon -{ -class MediaObject; -class AbstractMediaStream2Private; - -/** \class AbstractMediaStream2 abstractmediastream2.h phonon/AbstractMediaStream2 - * \brief Base class for custom media data streams. - * - * Implement this class to provide a custom data stream to the backend. The class supports both, the - * push and the pull model. - * - * Push: - * \code - * PushStream::PushStream(QObject *parent) - * : AbstractMediaStream2(parent), m_timer(new QTimer(this)) - * { - * setStreamSize(getMediaStreamSize()); - * - * connect(m_timer, SIGNAL(timeout()), SLOT(moreData())); - * m_timer->setInterval(0); - * } - * - * void PushStream::moreData() - * { - * const QByteArray data = getMediaData(); - * if (data.isEmpty()) { - * endOfData(); - * } else { - * writeData(data); - * } - * } - * - * void PushStream::needData() - * { - * m_timer->start(); - * moreData(); - * } - * - * void PushStream::enoughData() - * { - * m_timer->stop(); - * } - * \endcode - * - * Pull: - * \code - * PullStream::PullStream(QObject *parent) - * : AbstractMediaStream2(parent) - * { - * setStreamSize(getMediaStreamSize()); - * } - * - * void PullStream::needData() - * { - * const QByteArray data = getMediaData(); - * if (data.isEmpty()) { - * endOfData(); - * } else { - * writeData(data); - * } - * } - * \endcode - * - * \ingroup Playback - * \author Matthias Kretz - */ -class PHONON_EXPORT AbstractMediaStream2 : public AbstractMediaStream -{ - Q_OBJECT - Q_DECLARE_PRIVATE(AbstractMediaStream2) - friend class MediaObject; - friend class MediaObjectPrivate; - friend class MediaSourcePrivate; - protected: - ///////////////////////////////////////////////////////////// - // functions an implementation will call: - ///////////////////////////////////////////////////////////// - - /** - * Constructs an AbstractMediaStream2 object with a \p parent. - */ - explicit AbstractMediaStream2(QObject *parent = 0); - - void resetDone(); - void seekStreamDone(); - - ///////////////////////////////////////////////////////////// - // functions to implement: - ///////////////////////////////////////////////////////////// - - /** - * Reimplement this function to be notified when the backend needs data. - * - * When this function is called you should try to call writeData or endOfData before - * returning. - * - * \param size The number of bytes that are needed. If possible, pass \p size bytes of media - * data in the next writeData call. - */ - virtual void needData(quint32 size) = 0; - - ///////////////////////////////////////////////////////////// - // internal - ///////////////////////////////////////////////////////////// - - bool event(QEvent *e); - AbstractMediaStream2(AbstractMediaStream2Private &dd, QObject *parent); - - private: - // hide needData() explicitly - virtual void needData() {} - - Q_PRIVATE_SLOT(d_func(), void _k_handleStreamEvent()) -}; - -} // namespace Phonon - - -#endif // PHONON_ABSTRACTMEDIASTREAM2_H diff --git a/src/phonon/experimental/abstractmediastream2_p.h b/src/phonon/experimental/abstractmediastream2_p.h deleted file mode 100644 index deaa8605f..000000000 --- a/src/phonon/experimental/abstractmediastream2_p.h +++ /dev/null @@ -1,63 +0,0 @@ -/* This file is part of the KDE project - Copyright (C) 2007 Matthias Kretz - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), Nokia Corporation - (or its successors, if any) and the KDE Free Qt Foundation, which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . - -*/ - -#ifndef ABSTRACTMEDIASTREAM2_P_H -#define ABSTRACTMEDIASTREAM2_P_H - -#include "phonon_export.h" -#include "abstractmediastream2.h" -#include "abstractmediastream_p.h" -#include "mediaobject_p.h" - -#include "medianodedestructionhandler_p.h" -#include "streameventqueue_p.h" - -class MediaObjectPrivate; -class QAbstractEventDispatcher; - -namespace Phonon -{ -class PHONON_EXPORT AbstractMediaStream2Private : public AbstractMediaStreamPrivate, private LockFreeQueueBase::DataReadyHandler -{ - friend class MediaObject; - friend class MediaSourcePrivate; - Q_DECLARE_PUBLIC(AbstractMediaStream2) - protected: - AbstractMediaStream2Private(); - ~AbstractMediaStream2Private(); - - virtual void setStreamSize(qint64 newSize); - virtual void setStreamSeekable(bool s); - virtual void writeData(const QByteArray &data); - virtual void endOfData(); - virtual void dataReady(); - void _k_handleStreamEvent(); - - StreamEventQueue *streamEventQueue; - QAbstractEventDispatcher *eventDispatcher; - int connectReset; - bool firstConnect; -}; -} // namespace Phonon - -#endif // ABSTRACTMEDIASTREAM2_P_H -// vim: sw=4 sts=4 et tw=100 diff --git a/src/phonon/experimental/abstractvideodataoutput.cpp b/src/phonon/experimental/abstractvideodataoutput.cpp deleted file mode 100644 index 9dc532125..000000000 --- a/src/phonon/experimental/abstractvideodataoutput.cpp +++ /dev/null @@ -1,122 +0,0 @@ -/* This file is part of the KDE project - Copyright (C) 2008 Matthias Kretz - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2 of - the License or (at your option) version 3 or any later version - accepted by the membership of KDE e.V. (or its successor approved - by the membership of KDE e.V.), Nokia Corporation (or its successors, - if any) and the KDE Free Qt Foundation, which shall act as a proxy - defined in Section 14 of version 3 of the license. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . - -*/ -#include "abstractvideodataoutput.h" -#include "abstractvideodataoutput_p.h" -#include "videodataoutputinterface.h" -#include "factory_p.h" - -namespace Phonon -{ -namespace Experimental -{ - -AbstractVideoDataOutput::AbstractVideoDataOutput() - : AbstractVideoOutput(*new AbstractVideoDataOutputPrivate) -{ - P_D(AbstractVideoDataOutput); - d->isRunning = false; - d->allowedFormats << VideoFrame2::Format_RGB888; -} - -AbstractVideoDataOutput::AbstractVideoDataOutput(AbstractVideoDataOutputPrivate &dd) - : AbstractVideoOutput(dd) -{ -} - -AbstractVideoDataOutput::~AbstractVideoDataOutput() -{ - setRunning(false); -} - -QSet AbstractVideoDataOutput::allowedFormats() const -{ - P_D(const AbstractVideoDataOutput); - return d->allowedFormats; -} - -void AbstractVideoDataOutput::setAllowedFormats(const QSet &allowedFormats) -{ - P_D(AbstractVideoDataOutput); - d->allowedFormats = allowedFormats; -} - -bool AbstractVideoDataOutput::isRunning() const -{ - P_D(const AbstractVideoDataOutput); - return d->isRunning; -} - -void AbstractVideoDataOutput::setRunning(bool running) -{ - P_D(AbstractVideoDataOutput); - d->isRunning = running; - Iface iface(d); - if (iface) { - if (running) { - iface->setFrontendObject(this); - } else { - iface->setFrontendObject(0); - } - } -} - -void AbstractVideoDataOutput::start() -{ - setRunning(true); -} - -void AbstractVideoDataOutput::stop() -{ - setRunning(false); -} - -bool AbstractVideoDataOutputPrivate::aboutToDeleteBackendObject() -{ - return AbstractVideoOutputPrivate::aboutToDeleteBackendObject(); -} - -void AbstractVideoDataOutputPrivate::setupBackendObject() -{ - P_Q(AbstractVideoDataOutput); - Q_ASSERT(m_backendObject); - //AbstractVideoOutputPrivate::setupBackendObject(); - if (isRunning) { - Iface iface(this); - if (iface) { - iface->setFrontendObject(q); - } - } -} - -void AbstractVideoDataOutputPrivate::createBackendObject() -{ - if (m_backendObject) - return; - //P_Q(AbstractVideoDataOutput); - m_backendObject = Factory::createVideoDataOutput(0); - if (m_backendObject) { - setupBackendObject(); - } -} - -} // namespace Experimental -} // namespace Phonon diff --git a/src/phonon/experimental/abstractvideodataoutput.h b/src/phonon/experimental/abstractvideodataoutput.h deleted file mode 100644 index 0f1ce84e4..000000000 --- a/src/phonon/experimental/abstractvideodataoutput.h +++ /dev/null @@ -1,107 +0,0 @@ -/* This file is part of the KDE project - Copyright (C) 2005-2008 Matthias Kretz - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), Nokia Corporation - (or its successors, if any) and the KDE Free Qt Foundation, which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . - -*/ - -#ifndef PHONON_X_ABSTRACTVIDEODATAOUTPUT_H -#define PHONON_X_ABSTRACTVIDEODATAOUTPUT_H - -#include "export.h" -#include "../abstractvideooutput.h" -#include "../phonondefs.h" -#include -#include "videoframe2.h" - -#ifndef DOXYGEN_SHOULD_SKIP_THIS -template class QSet; -#endif - -namespace Phonon -{ -namespace Experimental -{ - -class AbstractVideoDataOutputPrivate; - -/** - * \short This class gives you the video data. - * - * This class implements a special AbstractVideoOutput that gives your - * application the video data. - * - * You can also use the video data for further processing (e.g. encoding and - * saving to a file). - * - * \author Matthias Kretz - * - * \see VideoDataOutput2 - */ -class PHONONEXPERIMENTAL_EXPORT AbstractVideoDataOutput : public AbstractVideoOutput -{ - P_DECLARE_PRIVATE(AbstractVideoDataOutput) - - public: - /** - * Constructs an AbstractVideoDataOutput - */ - AbstractVideoDataOutput(); - ~AbstractVideoDataOutput(); - - /** - * Lists the formats this output is allowed to pass via frameReady. - */ - virtual QSet allowedFormats() const; - - // TODO: consider to remove the following function and make the above pure virtual - /** - * Defaults to VideoFrame2::Format_RGB888. - */ - void setAllowedFormats(const QSet &); - - bool isRunning() const; - - /** - * This function is called whenever a frame should be displayed. - * - * \warning frameReady can get called from any thread (other than the - * main thread or the thread affinity of this QObject). A common error to create a deadlock - * situation is to block the thread this function is called from, until the main thread - * has found time to handle the frame. If it is blocking while the main thread decides to - * stop/delete the MediaObject you might get a deadlock. - */ - virtual void frameReady(const VideoFrame2 &) = 0; - - /** - * This function is called after the last frameReady of a MediaObject was called. - */ - virtual void endOfMedia() = 0; - - void setRunning(bool running); - void start(); - void stop(); - - protected: - AbstractVideoDataOutput(AbstractVideoDataOutputPrivate &dd); -}; - -} // namespace Experimental -} //namespace Phonon - -#endif // PHONON_X_ABSTRACTVIDEODATAOUTPUT_H diff --git a/src/phonon/experimental/abstractvideodataoutput_p.h b/src/phonon/experimental/abstractvideodataoutput_p.h deleted file mode 100644 index 0c2a659d0..000000000 --- a/src/phonon/experimental/abstractvideodataoutput_p.h +++ /dev/null @@ -1,50 +0,0 @@ -/* This file is part of the KDE project - Copyright (C) 2008 Matthias Kretz - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), Nokia Corporation - (or its successors, if any) and the KDE Free Qt Foundation, which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . - -*/ -#ifndef PHONON_X_ABSTRACTVIDEODATAOUTPUT_P_H -#define PHONON_X_ABSTRACTVIDEODATAOUTPUT_P_H - -#include "abstractvideodataoutput.h" -#include "../abstractvideooutput_p.h" -#include - -namespace Phonon -{ -namespace Experimental -{ - -class AbstractVideoDataOutputPrivate : public Phonon::AbstractVideoOutputPrivate -{ - P_DECLARE_PUBLIC(AbstractVideoDataOutput) - protected: - virtual bool aboutToDeleteBackendObject(); - virtual void createBackendObject(); - void setupBackendObject(); - - private: - bool isRunning; - QSet allowedFormats; -}; - -} // namespace Experimental -} // namespace Phonon - -#endif // PHONON_X_ABSTRACTVIDEODATAOUTPUT_P_H diff --git a/src/phonon/experimental/audiodataoutput.cpp b/src/phonon/experimental/audiodataoutput.cpp deleted file mode 100644 index d1b8dab51..000000000 --- a/src/phonon/experimental/audiodataoutput.cpp +++ /dev/null @@ -1,73 +0,0 @@ -/* This file is part of the KDE project - Copyright (C) 2005 Matthias Kretz - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), Nokia Corporation - (or its successors, if any) and the KDE Free Qt Foundation, which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . - -*/ -#include "audiodataoutput.h" -#include "audiodataoutput_p.h" -#include "factory_p.h" - -#define PHONON_CLASSNAME AudioDataOutput - -namespace Phonon -{ -namespace Experimental -{ - -PHONON_HEIR_IMPL(AbstractAudioOutput) - -PHONON_GETTER(Phonon::Experimental::AudioDataOutput::Format, format, d->format) -PHONON_GETTER(int, dataSize, d->dataSize) -PHONON_GETTER(int, sampleRate, -1) -PHONON_SETTER(setFormat, format, Phonon::Experimental::AudioDataOutput::Format) -PHONON_SETTER(setDataSize, dataSize, int) - -bool AudioDataOutputPrivate::aboutToDeleteBackendObject() -{ - Q_ASSERT(m_backendObject); - pBACKEND_GET(Phonon::Experimental::AudioDataOutput::Format, format, "format"); - pBACKEND_GET(int, dataSize, "dataSize"); - - return AbstractAudioOutputPrivate::aboutToDeleteBackendObject(); -} - -void AudioDataOutputPrivate::setupBackendObject() -{ - P_Q(AudioDataOutput); - Q_ASSERT(m_backendObject); - AbstractAudioOutputPrivate::setupBackendObject(); - - // set up attributes - pBACKEND_CALL1("setFormat", Phonon::Experimental::AudioDataOutput::Format, format); - pBACKEND_CALL1("setDataSize", int, dataSize); - QObject::connect(m_backendObject, - SIGNAL(dataReady(QMap >)), - q, SIGNAL(dataReady(QMap >))); - QObject::connect(m_backendObject, - SIGNAL(dataReady(QMap >)), - q, SIGNAL(dataReady(QMap >))); - QObject::connect(m_backendObject, SIGNAL(endOfMedia(int)), q, SIGNAL(endOfMedia(int))); -} - -} // namespace Experimental -} // namespace Phonon - -#undef PHONON_CLASSNAME -// vim: sw=4 ts=4 tw=80 -#include "experimental/moc_audiodataoutput.h" diff --git a/src/phonon/experimental/audiodataoutput.h b/src/phonon/experimental/audiodataoutput.h deleted file mode 100644 index 2c8db050f..000000000 --- a/src/phonon/experimental/audiodataoutput.h +++ /dev/null @@ -1,189 +0,0 @@ -/* This file is part of the KDE project - Copyright (C) 2005-2006 Matthias Kretz - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), Nokia Corporation - (or its successors, if any) and the KDE Free Qt Foundation, which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . - -*/ -#ifndef Phonon_AUDIODATAOUTPUT_H -#define Phonon_AUDIODATAOUTPUT_H - -#include "export.h" -#include "../abstractaudiooutput.h" -#include "../phonondefs.h" - -#ifndef DOXYGEN_SHOULD_SKIP_THIS -template class QVector; -template class QMap; -#endif - -namespace Phonon -{ -namespace Experimental -{ - class AudioDataOutputPrivate; - - /** - * \short This class gives you the audio data (for visualizations). - * - * This class implements a special AbstractAudioOutput that gives your - * application the audio data. Don't expect realtime performance. But - * the latencies should be low enough to use the audio data for - * visualizations. You can also use the audio data for further processing - * (e.g. encoding and saving to a file). - * - * The class supports different data formats. One of the most common formats - * is to read vectors of integers (which will only use 16 Bit), but you can - * also request floats which some backends use internally. - * - * \author Matthias Kretz - */ - class PHONONEXPERIMENTAL_EXPORT AudioDataOutput : public AbstractAudioOutput - { - Q_OBJECT - P_DECLARE_PRIVATE(AudioDataOutput) - Q_ENUMS(Channel Format) - Q_PROPERTY(Format format READ format WRITE setFormat) - Q_PROPERTY(int dataSize READ dataSize WRITE setDataSize) - PHONON_HEIR(AudioDataOutput) - public: - /** - * Specifies the channel the audio data belongs to. - */ - enum Channel - { - LeftChannel, - RightChannel, - CenterChannel, - LeftSurroundChannel, - RightSurroundChannel, - SubwooferChannel - }; - - /** - * Used for telling the object whether you want 16 bit Integers or - * 32 bit floats. - * - * \see requestFormat - */ - enum Format - { - /** - * Requests 16 bit signed integers. - * - * \see dataReady(const QVector &) - */ - IntegerFormat = 1, - /** - * Requests 32 bit floating point: signed, zero centered, and - * normalized to the unit value (-1.0 to 1.0). - * - * \see dataReady(const QVector &) - */ - FloatFormat = 2 - }; - - /** - * Returns the currently used format. - * - * \see setFormat - */ - Format format() const; - - /** - * Returns the currently used number of samples passed through - * the signal. - * - * \see setDataSize - */ - int dataSize() const; - - /** - * Returns the sample rate in Hz. Common sample rates are 44100 Hz - * and 48000 Hz. AudioDataOutput will not do any sample rate - * conversion for you. If you need to convert the sample rate you - * might want to take a look at libsamplerate. For visualizations it - * is often enough to do simple interpolation or even drop/duplicate - * samples. - * - * \return The sample rate as reported by the backend. If the - * backend is unavailable -1 is returned. - */ - int sampleRate() const; - - public Q_SLOTS: - /** - * Requests the dataformat you'd like to receive. Only one of the - * signals of this class will be emitted when new data is ready. - * - * The default format is IntegerFormat. - * - * \see format() - */ - void setFormat(Format format); - - /** - * Sets the number of samples to be passed in one signal emission. - * - * Defaults to 512 samples per emitted signal. - * - * \param size the number of samples - */ - void setDataSize(int size); - - Q_SIGNALS: - /** - * Emitted whenever another dataSize number of samples are ready and - * format is set to IntegerFormat. - * - * If format is set to FloatFormat the signal is not emitted at all. - * - * \param data A mapping of Channel to a vector holding the audio data. - */ - void dataReady(const QMap > &data); - - /** - * Emitted whenever another dataSize number of samples are ready and - * format is set to FloatFormat. - * - * If format is set to IntegerFormat the signal is not emitted at all. - * - * \param data A mapping of Channel to a vector holding the audio data. - */ - void dataReady(const QMap > &data); - - /** - * This signal is emitted before the last dataReady signal of a - * media is emitted. - * - * If, for example, the playback of a media file has finished and the - * last audio data of that file is going to be passed with the next - * dataReady signal, and only the 28 first samples of the data - * vector are from that media file endOfMedia will be emitted right - * before dataReady with \p remainingSamples = 28. - * - * \param remainingSamples The number of samples in the next - * dataReady vector that belong to the media that was playing to - * this point. - */ - void endOfMedia(int remainingSamples); - }; -} // namespace Experimental -} // namespace Phonon - -// vim: sw=4 ts=4 tw=80 -#endif // Phonon_AUDIODATAOUTPUT_H diff --git a/src/phonon/experimental/audiodataoutput_p.h b/src/phonon/experimental/audiodataoutput_p.h deleted file mode 100644 index aeb70d41c..000000000 --- a/src/phonon/experimental/audiodataoutput_p.h +++ /dev/null @@ -1,53 +0,0 @@ -/* This file is part of the KDE project - Copyright (C) 2006 Matthias Kretz - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), Nokia Corporation - (or its successors, if any) and the KDE Free Qt Foundation, which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . - -*/ - -#ifndef AUDIODATAOUTPUT_P_H -#define AUDIODATAOUTPUT_P_H - -#include "audiodataoutput.h" -#include "../abstractaudiooutput_p.h" - -namespace Phonon -{ -namespace Experimental -{ - -class AudioDataOutputPrivate : public AbstractAudioOutputPrivate -{ - P_DECLARE_PUBLIC(AudioDataOutput) - PHONON_PRIVATECLASS - protected: - AudioDataOutputPrivate() - : format(AudioDataOutput::IntegerFormat) - , dataSize(512) - { - } - - AudioDataOutput::Format format; - int dataSize; -}; - -} // namespace Experimental -} // namespace Phonon - -#endif // AUDIODATAOUTPUT_P_H -// vim: sw=4 ts=4 tw=80 diff --git a/src/phonon/experimental/audiodataoutputinterface.h b/src/phonon/experimental/audiodataoutputinterface.h deleted file mode 100644 index 866c7a243..000000000 --- a/src/phonon/experimental/audiodataoutputinterface.h +++ /dev/null @@ -1,47 +0,0 @@ -/* This file is part of the KDE project - Copyright (C) 2008 Matthias Kretz - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), Nokia Corporation - (or its successors, if any) and the KDE Free Qt Foundation, which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . - -*/ - -#ifndef PHONON_X_AUDIODATAOUTPUTINTERFACE_H -#define PHONON_X_AUDIODATAOUTPUTINTERFACE_H - -namespace Phonon -{ -namespace Experimental -{ - -class AbstractAudioDataOutput; - -class AudioDataOutputInterface -{ - public: - virtual ~AudioDataOutputInterface() {} - - virtual AbstractAudioDataOutput *frontendObject() const = 0; - virtual void setFrontendObject(AbstractAudioDataOutput *) = 0; -}; - -} // namespace Experimental -} // namespace Phonon - -Q_DECLARE_INTERFACE(Phonon::Experimental::AudioDataOutputInterface, "0AudioDataOutputInterface.phonon.kde.org") - -#endif // PHONON_X_AUDIODATAOUTPUTINTERFACE_H diff --git a/src/phonon/experimental/audioformat.cpp b/src/phonon/experimental/audioformat.cpp deleted file mode 100644 index bad19e496..000000000 --- a/src/phonon/experimental/audioformat.cpp +++ /dev/null @@ -1,112 +0,0 @@ -/* This file is part of the KDE project - Copyright (C) 2008 Matthias Kretz - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), Nokia Corporation - (or its successors, if any) and the KDE Free Qt Foundation, which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . - -*/ - -#include "audioformat.h" -#include "phonondefs_p.h" - -namespace Phonon -{ -namespace Experimental -{ - -class AudioFormatPrivate -{ - P_DECLARE_PUBLIC(AudioFormat) - protected: - AudioFormat *q_ptr; -}; - -AudioFormat::AudioFormat(int sampleRate, int channelCount, Phonon::Experimental::BitRate bitRate, QSysInfo::Endian byteOrder) -{ - s.m_sampleRate = sampleRate; - s.m_channelCount = channelCount; - s.m_bitRate = bitRate; - s.m_byteOrder = byteOrder; -} - -AudioFormat::~AudioFormat() -{ -} - -int AudioFormat::sampleRate() const -{ - return s.m_sampleRate; -} - -int AudioFormat::channelCount() const -{ - return s.m_channelCount; -} - -Phonon::Experimental::BitRate AudioFormat::bitRate() const -{ - return s.m_bitRate; -} - -QSysInfo::Endian AudioFormat::byteOrder() const -{ - return s.m_byteOrder; -} - -AudioFormat::AudioFormat(const AudioFormat &f) -{ - s.m_sampleRate = f.sampleRate(); - s.m_channelCount = f.channelCount(); - s.m_bitRate = f.bitRate(); - s.m_byteOrder = f.byteOrder(); -} - -AudioFormat &AudioFormat::operator=(const AudioFormat &f) -{ - s.m_sampleRate = f.sampleRate(); - s.m_channelCount = f.channelCount(); - s.m_bitRate = f.bitRate(); - s.m_byteOrder = f.byteOrder(); - return *this; -} - -bool AudioFormat::operator==(const AudioFormat &f) const -{ - return s.m_sampleRate == f.sampleRate() && - s.m_channelCount == f.channelCount() && - s.m_bitRate == f.bitRate() && - s.m_byteOrder == f.byteOrder(); -} - -bool AudioFormat::operator<(const AudioFormat &f) const -{ - return s.m_bitRate < f.bitRate() || - (s.m_bitRate == f.bitRate() && (s.m_sampleRate < f.sampleRate() || - (s.m_sampleRate == f.sampleRate() && (s.m_channelCount < f.channelCount() || - (s.m_channelCount == f.channelCount() && s.m_byteOrder != QSysInfo::ByteOrder && f.byteOrder() == QSysInfo::ByteOrder))))); -} - -quint32 AudioFormat::key() const -{ - return (s.m_byteOrder == QSysInfo::ByteOrder ? 1 : 0) + // 1 bit least significant - (s.m_channelCount << 1) + // give it 8 bits - (s.m_sampleRate) + // 192kHz ~ 18 bits (let the (unimportant) lower 9 bits overlap with channels + byteOrder) - (s.m_bitRate << 18); // most significant -} - -} // namespace Experimental -} // namespace Phonon diff --git a/src/phonon/experimental/audioformat.h b/src/phonon/experimental/audioformat.h deleted file mode 100644 index 56180f5f7..000000000 --- a/src/phonon/experimental/audioformat.h +++ /dev/null @@ -1,95 +0,0 @@ -/* This file is part of the KDE project - Copyright (C) 2008 Matthias Kretz - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), Nokia Corporation - (or its successors, if any) and the KDE Free Qt Foundation, which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . - -*/ - -#ifndef PHONON_X_AUDIOFORMAT_H -#define PHONON_X_AUDIOFORMAT_H - -#include -#include "phononnamespace.h" - -namespace Phonon -{ -namespace Experimental -{ - -class AudioFormatPrivate; -class AudioFormat -{ - //Q_DECLARE_PRIVATE(AudioFormat) - public: - AudioFormat(int sampleRate = 48000, int channelCount = 2, Phonon::Experimental::BitRate bitRate = Phonon::Experimental::Signed16Bit, QSysInfo::Endian byteOrder = QSysInfo::ByteOrder); - AudioFormat(const AudioFormat &); - ~AudioFormat(); - - AudioFormat &operator=(const AudioFormat &); - - int sampleRate() const; - int channelCount() const; - Phonon::Experimental::BitRate bitRate() const; - QSysInfo::Endian byteOrder() const; - - bool operator==(const AudioFormat &) const; - inline bool operator!=(const AudioFormat &f) const { return !operator==(f); } - - /** - * ess than operator for sorting: - * A Format is considered smaller if - * - smaller bit rate - * - smaller sample rate - * - less channels - * - non-native byte order - */ - bool operator<(const AudioFormat &) const; - - quint32 key() const; - - private: - union - { - struct - { - int m_sampleRate; - int m_channelCount; - Phonon::Experimental::BitRate m_bitRate; - QSysInfo::Endian m_byteOrder; - } s; - // for future use: - AudioFormatPrivate *d_ptr; - }; -}; - -inline uint qHash(const AudioFormat &p) -{ - return p.key(); -} - -} // namespace Experimental -} // namespace Phonon - -#if defined(Q_CC_MSVC) && _MSC_VER <= 1300 -//this ensures that code outside Phonon can use the hash function -//it also a workaround for some compilers -inline uint qHash(const Phonon::Experimental::AudioFormat &p) { return Phonon::Experimental::qHash(p); } //krazy:exclude=inline -#endif - - -#endif // PHONON_X_AUDIOFORMAT_H diff --git a/src/phonon/experimental/audiowriter.h b/src/phonon/experimental/audiowriter.h deleted file mode 100644 index 36c44c478..000000000 --- a/src/phonon/experimental/audiowriter.h +++ /dev/null @@ -1,61 +0,0 @@ -/* This file is part of the KDE project - Copyright (C) 2006 Matthias Kretz - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), Nokia Corporation - (or its successors, if any) and the KDE Free Qt Foundation, which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . - -*/ - -#ifndef PHONON_AUDIOWRITER_H -#define PHONON_AUDIOWRITER_H - -#include "export.h" -#include "../abstractaudiooutput.h" -#include "../phonondefs.h" - -namespace Phonon -{ -namespace Experimental -{ - -class AudioWriterPrivate; -class PHONONEXPERIMENTAL_EXPORT AudioWriter : public AbstractAudioOutput -{ - Q_OBJECT - K_DECLARE_PRIVATE(AudioWriter) - PHONON_HEIR(AudioWriter) - /** - * This property defines the codec to be used for encoding the audio signal. - * Possible codecs can be retrieved from BackendCapabilities using the - * availableAudioCodecs() function. - * - * The default codec is an invalid codec (audioCodec().isValid() == false) - */ - Q_PROPERTY(AudioCodec audioCodec READ audioCodec WRITE setAudioCodec) - public: - AudioCodec audioCodec() const; - - public Q_SLOTS: - setAudioCodec(AudioCodec audioCodec); - // codec parameters? reuse EffectParameter class? -}; - -} // namespace Experimental -} // namespace Phonon - -#endif // PHONON_AUDIOWRITER_H -// vim: sw=4 ts=4 tw=80 diff --git a/src/phonon/experimental/avcapture.cpp b/src/phonon/experimental/avcapture.cpp deleted file mode 100644 index 23a2de389..000000000 --- a/src/phonon/experimental/avcapture.cpp +++ /dev/null @@ -1,189 +0,0 @@ -/* This file is part of the KDE project - Copyright (C) 2005-2006, 2008 Matthias Kretz - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), Nokia Corporation - (or its successors, if any) and the KDE Free Qt Foundation, which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . - -*/ - -#include "phononnamespace_p.h" - -#if defined(PHONON_NO_VIDEOCAPTURE) || defined(PHONON_NO_AUDIOCAPTURE) -#define NO_PHONON_AVCAPTURE -#endif - -#ifndef NO_PHONON_AVCAPTURE - -#include "avcapture.h" -#include "avcapture_p.h" - -#include "avcaptureinterface.h" -#include "factory_p.h" -#include "globalconfig.h" - -#define PHONON_CLASSNAME AvCapture -#define PHONON_INTERFACENAME AvCaptureInterface - -namespace Phonon -{ -namespace Experimental -{ -PHONON_OBJECT_IMPL - -AvCapture::AvCapture(Phonon::CaptureCategory category, QObject *parent) - : QObject(parent), MediaNode(*new AvCapturePrivate()) -{ - setCaptureDevices(category); -} - -Phonon::State AvCapture::state() const -{ - P_D(const AvCapture); - if (d->m_backendObject) { - return INTERFACE_CALL(state()); - } - return Phonon::StoppedState; -} - -void AvCapture::start() -{ - P_D(AvCapture); - if (d->backendObject()) { - INTERFACE_CALL(start()); - } -} - -void AvCapture::pause() -{ - P_D(AvCapture); - if (d->backendObject()) { - INTERFACE_CALL(pause()); - } -} - -void AvCapture::stop() -{ - P_D(AvCapture); - if (d->backendObject()) { - INTERFACE_CALL(stop()); - } -} - -void AvCapture::setCaptureDevices(Phonon::CaptureCategory category) -{ - setAudioCaptureDevice(category); - setVideoCaptureDevice(category); -} - -Phonon::AudioCaptureDevice AvCapture::audioCaptureDevice() const -{ - P_D(const AvCapture); - if (d->m_backendObject) { - return INTERFACE_CALL(audioCaptureDevice()); - } - return d->audioCaptureDevice; -} - -void AvCapture::setAudioCaptureDevice(const Phonon::AudioCaptureDevice &audioCaptureDevice) -{ - P_D(AvCapture); - d->audioCaptureDevice = audioCaptureDevice; - if (d->m_backendObject) { - INTERFACE_CALL(setAudioCaptureDevice(d->audioCaptureDevice)); - } -} - -void AvCapture::setAudioCaptureDevice(Phonon::CaptureCategory category) -{ - P_D(AvCapture); - d->audioCaptureDevice = AudioCaptureDevice::fromIndex(Phonon::GlobalConfig().audioCaptureDeviceFor(category)); - if (d->m_backendObject) { - INTERFACE_CALL(setAudioCaptureDevice(d->audioCaptureDevice)); - } -} - -PHONON_DEPRECATED void AvCapture::setAudioCaptureDevice(Phonon::Category category) -{ - setAudioCaptureDevice(Phonon::categoryToCaptureCategory(category)); -} - -Phonon::VideoCaptureDevice AvCapture::videoCaptureDevice() const -{ - P_D(const AvCapture); - if (d->m_backendObject) { - return INTERFACE_CALL(videoCaptureDevice()); - } - return d->videoCaptureDevice; -} - -void AvCapture::setVideoCaptureDevice(const Phonon::Experimental::VideoCaptureDevice &videoCaptureDevice) -{ - setVideoCaptureDevice(phononExperimentalVcdToVcd(videoCaptureDevice)); -} - -void AvCapture::setVideoCaptureDevice(const Phonon::VideoCaptureDevice &videoCaptureDevice) -{ - P_D(AvCapture); - d->videoCaptureDevice = videoCaptureDevice; - if (d->m_backendObject) { - INTERFACE_CALL(setVideoCaptureDevice(d->videoCaptureDevice)); - } -} - -void AvCapture::setVideoCaptureDevice(Phonon::CaptureCategory category) -{ - P_D(AvCapture); - d->videoCaptureDevice = Phonon::VideoCaptureDevice::fromIndex(Phonon::GlobalConfig().videoCaptureDeviceFor(category)); - if (d->m_backendObject) { - INTERFACE_CALL(setVideoCaptureDevice(d->videoCaptureDevice)); - } -} - -void AvCapture::setVideoCaptureDevice(Phonon::Category category) -{ - setVideoCaptureDevice(Phonon::categoryToCaptureCategory(category)); -} - -bool AvCapturePrivate::aboutToDeleteBackendObject() -{ - audioCaptureDevice = pINTERFACE_CALL(audioCaptureDevice()); - videoCaptureDevice = pINTERFACE_CALL(videoCaptureDevice()); - return true; -} - -void AvCapturePrivate::setupBackendObject() -{ - P_Q(AvCapture); - Q_ASSERT(m_backendObject); - - QObject::connect(m_backendObject, SIGNAL(stateChanged(Phonon::State,Phonon::State)), q, SIGNAL(stateChanged(Phonon::State,Phonon::State)), Qt::QueuedConnection); - - // set up attributes - pINTERFACE_CALL(setAudioCaptureDevice(audioCaptureDevice)); - pINTERFACE_CALL(setVideoCaptureDevice(videoCaptureDevice)); -} - -} // namespace Experimental -} // namespace Phonon - -#include "experimental/moc_avcapture.cpp" - -#undef PHONON_CLASSNAME -#undef PHONON_INTERFACENAME - -#endif // NO_PHONON_AVCAPTURE -#include "experimental/moc_avcapture.h" diff --git a/src/phonon/experimental/avcapture.h b/src/phonon/experimental/avcapture.h deleted file mode 100644 index 1a57528f5..000000000 --- a/src/phonon/experimental/avcapture.h +++ /dev/null @@ -1,191 +0,0 @@ -/* This file is part of the KDE project - Copyright (C) 2005-2006, 2008 Matthias Kretz - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), Nokia Corporation - (or its successors, if any) and the KDE Free Qt Foundation, which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . - -*/ -#ifndef PHONON_EXPERIMENTAL_AVCAPTURE_H -#define PHONON_EXPERIMENTAL_AVCAPTURE_H - -#if defined(PHONON_NO_VIDEOCAPTURE) || defined(PHONON_NO_AUDIOCAPTURE) -#define NO_PHONON_AVCAPTURE -#endif - -#ifndef NO_PHONON_AVCAPTURE - -#include "export.h" -#include "../medianode.h" -#include "../phonondefs.h" -#include "objectdescription.h" - -#if defined(MAKE_PHONONEXPERIMENTAL_LIB) -#include "../phononnamespace.h" -#else -#include "phonon/phononnamespace.h" -#endif - -class QString; -class QStringList; - -namespace Phonon -{ -namespace Experimental -{ - - class AvCapturePrivate; - - /** - * @short Media data from a soundcard, soundserver, camera or any other - * hardware device supported by the backend. - * - * This class gives you access to the capture capabilities of the backend. - * There might be more than only one possible capture source, for audio, as - * well as for video. A prefferable device may easily be obtained by providing - * a capture category. - * - * @ingroup Recording - * @author Matthias Kretz - * @see BackendCapabilities::availableAudioCaptureDevices - * @see BackendCapabilities::availableVideoCaptureDevices - */ - class PHONONEXPERIMENTAL_EXPORT AvCapture : public QObject, public Phonon::MediaNode - { - Q_OBJECT - P_DECLARE_PRIVATE(AvCapture) - PHONON_OBJECT(AvCapture) - Q_PROPERTY(Phonon::AudioCaptureDevice audioCaptureDevice READ audioCaptureDevice WRITE setAudioCaptureDevice) - Q_PROPERTY(Phonon::VideoCaptureDevice videoCaptureDevice READ videoCaptureDevice WRITE setVideoCaptureDevice) - public: - /** - * Constructs an AvCapture with the devices preferred for the specified - * capture category. - * - * @param category Used to determine what devices are most suited for - * the AvCapture. - * - * @see CaptureCategory - */ - AvCapture(Phonon::CaptureCategory category, QObject *parent = NULL); - - /** - * Returns the current state of the capture. - * - * @li If only the audio capture device is valid, it returns the audio capture state. - * @li If only the video capture device is valid, it returns the video capture state. - * @li If both the audio and video capture devices are valid, it only returns the - * video capture state. - */ - State state() const; - - /** - * Returns the currently used capture source for the audio signal. - */ - Phonon::AudioCaptureDevice audioCaptureDevice() const; - - /** - * Returns the currently used capture source for the video signal. - */ - Phonon::VideoCaptureDevice videoCaptureDevice() const; - - /** - * Sets both the video and audio devices to the ones most suited for the - * specified category - * - * @param category Used to determine what devices are most suited for - * the AvCapture. - */ - void setCaptureDevices(Phonon::CaptureCategory category); - - /** - * Sets the audio capture source to use. - * - * @param source An object of class AudioCaptureDevice. - * - */ - void setAudioCaptureDevice(const Phonon::AudioCaptureDevice &source); - - /** - * Sets the audio capture device by using a capture category to get - * the appropriate device. - * - * @param category Capture category to use for getting a device - */ - void setAudioCaptureDevice(Phonon::CaptureCategory category); - - PHONON_DEPRECATED void setAudioCaptureDevice(Phonon::Category category); - - /** - * Sets the video capture source to use. - * - * @param source An object of class VideoCaptureDevice. - * - * @see videoCaptureDevice - * @see setVideoCaptureDevice(int) - */ - void setVideoCaptureDevice(const Phonon::VideoCaptureDevice &source); - - /** - * Sets the audio capture device by using a capture category to get - * the appropriate device. - * - * @param category Capture category to use for getting a device - */ - void setVideoCaptureDevice(Phonon::CaptureCategory category); - - PHONON_DEPRECATED void setVideoCaptureDevice(Phonon::Category category); - - /** - * @deprecated since 4.4.3, use - * setVideoCaptureDevice(const Phonon::VideoCaptureDevice &source) instead - */ - PHONON_DEPRECATED void setVideoCaptureDevice(const Phonon::Experimental::VideoCaptureDevice &source); - - public Q_SLOTS: - /** - * Start capture. - */ - void start(); - - /** - * Pause capture. - */ - void pause(); - - /** - * Stop capture. - */ - void stop(); - - Q_SIGNALS: - /** - * Emitted when the state of the video or audio capture device has been changed. - * - * \li If only the audio capture device is valid, it notifies about the audio capture state. - * \li If only the video capture device is valid, it notifies about the video capture state. - * \li If both the audio and video capture devices are valid, it only notifies about the - * video capture state. - */ - void stateChanged(Phonon::State newstate, Phonon::State oldstate); - }; - -} // namespace Experimental -} // namespace Phonon - -#endif // NO_PHONON_AVCAPTURE - -#endif // PHONON_EXPERIMENTAL_AVCAPTURE_H diff --git a/src/phonon/experimental/avcapture_p.h b/src/phonon/experimental/avcapture_p.h deleted file mode 100644 index 55d0df47a..000000000 --- a/src/phonon/experimental/avcapture_p.h +++ /dev/null @@ -1,54 +0,0 @@ -/* This file is part of the KDE project - Copyright (C) 2006 Matthias Kretz - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), Nokia Corporation - (or its successors, if any) and the KDE Free Qt Foundation, which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . - -*/ - -#ifndef AVCAPTURE_P_H -#define AVCAPTURE_P_H - -#ifndef NO_PHONON_AVCAPTURE - -#include "avcapture.h" -#include "../phonondefs_p.h" - -namespace Phonon -{ -namespace Experimental -{ - -class AvCapturePrivate : public MediaNodePrivate -{ - P_DECLARE_PUBLIC(AvCapture) - PHONON_PRIVATECLASS - public: - protected: - PHONON_EXPORT void _k_stateChanged(Phonon::State, Phonon::State); - protected: - Phonon::AudioCaptureDevice audioCaptureDevice; - Phonon::VideoCaptureDevice videoCaptureDevice; -}; - -} // namespace Experimental -} // namespace Phonon - -#endif // NO_PHONON_AVCAPTURE - -#endif // AVCAPTURE_P_H -// vim: sw=4 ts=4 tw=80 diff --git a/src/phonon/experimental/avcaptureinterface.h b/src/phonon/experimental/avcaptureinterface.h deleted file mode 100644 index ad38edab1..000000000 --- a/src/phonon/experimental/avcaptureinterface.h +++ /dev/null @@ -1,52 +0,0 @@ -/* This file is part of the KDE project - Copyright (C) 2008 Matthias Kretz - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), Nokia Corporation - (or its successors, if any) and the KDE Free Qt Foundation, which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . - -*/ - -#ifndef PHONON_EXPERIMENTAL_AVCAPTUREINTERFACE_H -#define PHONON_EXPERIMENTAL_AVCAPTUREINTERFACE_H - -namespace Phonon -{ -namespace Experimental -{ - -class AvCaptureInterface -{ - public: - virtual ~AvCaptureInterface() {} - - virtual Phonon::State state() const = 0; - virtual void start() = 0; - virtual void pause() = 0; - virtual void stop() = 0; - - virtual Phonon::AudioCaptureDevice audioCaptureDevice() const = 0; - virtual Phonon::VideoCaptureDevice videoCaptureDevice() const = 0; - virtual void setAudioCaptureDevice(const Phonon::AudioCaptureDevice &) = 0; - virtual void setVideoCaptureDevice(const Phonon::VideoCaptureDevice &) = 0; -}; - -} // namespace Experimental -} // namespace Phonon - -Q_DECLARE_INTERFACE(Phonon::Experimental::AvCaptureInterface, "0AvCaptureInterface.Phonon.kde.org") - -#endif // PHONON_EXPERIMENTAL_AVCAPTUREINTERFACE_H diff --git a/src/phonon/experimental/avwriter.cpp b/src/phonon/experimental/avwriter.cpp deleted file mode 100644 index f3adbc0dd..000000000 --- a/src/phonon/experimental/avwriter.cpp +++ /dev/null @@ -1,44 +0,0 @@ -/* This file is part of the KDE project - Copyright (C) 2006 Matthias Kretz - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), Nokia Corporation - (or its successors, if any) and the KDE Free Qt Foundation, which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . - -*/ - -#include "avwriter.h" -#include "avwriter_p.h" - -namespace Phonon -{ -namespace Experimental -{ - -AvWriter::AvWriter(QObject *parent) - : QObject(parent) - , k_ptr(new AvWriterPrivate) -{ - K_D(AvWriter); - d->q_ptr = this; -} - -} // namespace Experimental -} // namespace Phonon - -#include "experimental/moc_avwriter.cpp" -// vim: sw=4 ts=4 -#include "experimental/moc_avwriter.h" diff --git a/src/phonon/experimental/avwriter.h b/src/phonon/experimental/avwriter.h deleted file mode 100644 index 3f0facf01..000000000 --- a/src/phonon/experimental/avwriter.h +++ /dev/null @@ -1,86 +0,0 @@ -/* This file is part of the KDE project - Copyright (C) 2006 Matthias Kretz - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), Nokia Corporation - (or its successors, if any) and the KDE Free Qt Foundation, which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . - -*/ - -#ifndef PHONON_AVWRITER_H -#define PHONON_AVWRITER_H - -#include "export.h" -#include "../phonondefs.h" -#include "../abstractaudiooutput.h" -#include "../abstractvideooutput.h" - -namespace Phonon -{ -namespace Experimental -{ - -class AvWriterPrivate; - -//TODO: -// Container formats can support multiple audio, video and subtitle streams, a -// control track (menus) and chapters. Anything else? -// How should those features be mapped to this API? Multiple audio and video -// streams should be covered already. Are the subtitle streams implicit -// depending on the source material? -// Chapters: call a method when to add a chapter? How does that map to a -// specific frame/sample? Chapter support is probably overkill for Phonon. -class PHONONEXPERIMENTAL_EXPORT AvWriter : public QObject -{ - Q_OBJECT - K_DECLARE_PRIVATE(AvWriter) - Q_PROPERTY(ContainerFormat containerFormat READ containerFormat WRITE setContainerFormat) - Q_PROPERTY(KUrl url READ url WRITE setUrl) - public: - /** - * Standard QObject constructor. - * - * \param parent QObject parent - */ - AvWriter(QObject *parent); - - KUrl url() const; - setUrl(const KUrl &url); - - /** - * Creates a new AudioWriter object to be used for sending the audio - * data to this file - * - * \param streamName A name identifying the stream. Often this name is - * used for the language identifier. - * - * \return Returns the new AudioWriter object or 0 if the container - * format does not support multiple audio streams. - */ - AudioWriter *addAudioStream(const QString &streamName); - VideoWriter *addVideoStream(const QString &streamName); - - ContainerFormat containerFormat() const; - - public Q_SLOTS: - void setContainerFormat(ContainerFormat format); -}; - -} // namespace Experimental -} // namespace Phonon - -#endif // PHONON_AVWRITER_H -// vim: sw=4 ts=4 tw=80 diff --git a/src/phonon/experimental/avwriter_p.h b/src/phonon/experimental/avwriter_p.h deleted file mode 100644 index 8f42479e4..000000000 --- a/src/phonon/experimental/avwriter_p.h +++ /dev/null @@ -1,44 +0,0 @@ -/* This file is part of the KDE project - Copyright (C) 2006 Matthias Kretz - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), Nokia Corporation - (or its successors, if any) and the KDE Free Qt Foundation, which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . - -*/ - -#ifndef PHONON_AVWRITER_P_H -#define PHONON_AVWRITER_P_H - -#include "rtpsender.h" - -namespace Phonon -{ -namespace Experimental -{ - -class AvWriterPrivate -{ - Q_DECLARE_PUBLIC(AvWriter) - protected: - AvWriter *q_ptr; -}; - -} // namespace Experimental -} // namespace Phonon - -#endif // PHONON_AVWRITER_P_H -// vim: sw=4 ts=4 tw=80 diff --git a/src/phonon/experimental/backendcapabilities.cpp b/src/phonon/experimental/backendcapabilities.cpp deleted file mode 100644 index 56cd367ae..000000000 --- a/src/phonon/experimental/backendcapabilities.cpp +++ /dev/null @@ -1,47 +0,0 @@ -/* This file is part of the KDE project - Copyright (C) 2008 Matthias Kretz - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2 of - the License or (at your option) version 3 or any later version - accepted by the membership of KDE e.V. (or its successor approved - by the membership of KDE e.V.), Nokia Corporation (or its successors, - if any) and the KDE Free Qt Foundation, which shall act as a proxy - defined in Section 14 of version 3 of the license. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . - -*/ -#include "backendcapabilities.h" -#include "../backendcapabilities.h" -#include "globalconfig.h" - -namespace Phonon -{ -namespace Experimental -{ - -#ifndef PHONON_NO_VIDEOCAPTURE -QList BackendCapabilities::availableVideoCaptureDevices() -{ - QList phononList; - QList experimentalList; - - phononList = Phonon::BackendCapabilities::availableVideoCaptureDevices(); - foreach (const Phonon::VideoCaptureDevice &vcd, phononList) { - experimentalList << phononVcdToExperimentalVcd(vcd); - } - - return experimentalList; -} -#endif - -} // namespace Experimental -} // namespace Phonon diff --git a/src/phonon/experimental/backendcapabilities.h b/src/phonon/experimental/backendcapabilities.h deleted file mode 100644 index 226d60c0e..000000000 --- a/src/phonon/experimental/backendcapabilities.h +++ /dev/null @@ -1,43 +0,0 @@ -/* This file is part of the KDE project - Copyright (C) 2008 Matthias Kretz - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), Nokia Corporation - (or its successors, if any) and the KDE Free Qt Foundation, which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . - -*/ -#ifndef PHONON_EXPERIMENTAL_BACKENDCAPABILITIES_H -#define PHONON_EXPERIMENTAL_BACKENDCAPABILITIES_H - -#include "export.h" -#include "objectdescription.h" -#include "../backendcapabilities.h" - -namespace Phonon -{ -namespace Experimental -{ -namespace BackendCapabilities -{ - -#ifndef PHONON_NO_VIDEOCAPTURE -PHONONEXPERIMENTAL_EXPORT QList availableVideoCaptureDevices(); -#endif - -} // namespace BackendCapabilities -} // namespace Experimental -} // namespace Phonon -#endif // PHONON_EXPERIMENTAL_BACKENDCAPABILITIES_H diff --git a/src/phonon/experimental/backendinterface.h b/src/phonon/experimental/backendinterface.h deleted file mode 100644 index 1590dc18d..000000000 --- a/src/phonon/experimental/backendinterface.h +++ /dev/null @@ -1,41 +0,0 @@ -/* This file is part of the KDE project - Copyright (C) 2008 Matthias Kretz - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), Nokia Corporation - (or its successors, if any) and the KDE Free Qt Foundation, which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . - -*/ -#ifndef PHONON_EXPERIMENTAL_BACKENDINTERFACE_H -#define PHONON_EXPERIMENTAL_BACKENDINTERFACE_H - -namespace Phonon -{ -namespace Experimental -{ -namespace BackendInterface -{ -enum Class { - VideoDataOutputClass = 0x10000, - AudioDataOutputClass, - VisualizationClass, - AvCaptureClass -}; -} // namespace BackendInterface -} // namespace Experimental -} // namespace Phonon - -#endif // PHONON_EXPERIMENTAL_BACKENDINTERFACE_H diff --git a/src/phonon/experimental/export.h b/src/phonon/experimental/export.h deleted file mode 100644 index 2ca8fba6a..000000000 --- a/src/phonon/experimental/export.h +++ /dev/null @@ -1,39 +0,0 @@ -/* This file is part of the KDE project - Copyright (C) 2007 Matthias Kretz - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), Nokia Corporation - (or its successors, if any) and the KDE Free Qt Foundation, which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . - -*/ - -#ifndef PHONON_EXPERIMENTAL_EXPORT_H -#define PHONON_EXPERIMENTAL_EXPORT_H - -/* needed for KDE_EXPORT and KDE_IMPORT macros */ -#include - -#ifndef PHONONEXPERIMENTAL_EXPORT -# if defined(MAKE_PHONONEXPERIMENTAL_LIB) - /* We are building this library */ -# define PHONONEXPERIMENTAL_EXPORT Q_DECL_EXPORT -# else - /* We are using this library */ -# define PHONONEXPERIMENTAL_EXPORT Q_DECL_IMPORT -# endif -#endif - -#endif diff --git a/src/phonon/experimental/factory.cpp b/src/phonon/experimental/factory.cpp deleted file mode 100644 index e40066f0f..000000000 --- a/src/phonon/experimental/factory.cpp +++ /dev/null @@ -1,129 +0,0 @@ -/* This file is part of the KDE project - Copyright (C) 2008 Matthias Kretz - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2 of - the License or (at your option) version 3 or any later version - accepted by the membership of KDE e.V. (or its successor approved - by the membership of KDE e.V.), Nokia Corporation (or its successors, - if any) and the KDE Free Qt Foundation, which shall act as a proxy - defined in Section 14 of version 3 of the license. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . - -*/ - -#include "factory_p.h" -#include "objectdescription.h" -#include "../factory_p.h" -#include "../globalstatic_p.h" -#include "../backendinterface.h" -#include "backendinterface.h" -#include - -namespace Phonon -{ -namespace Experimental -{ - -class FactoryPrivate : public Phonon::Experimental::Factory::Sender -{ - public: - FactoryPrivate(); - ~FactoryPrivate(); - //QPointer m_backendObject; - - private Q_SLOTS: - void objectDescriptionChanged(ObjectDescriptionType); -}; - -PHONON_GLOBAL_STATIC(Phonon::Experimental::FactoryPrivate, globalFactory) - -FactoryPrivate::FactoryPrivate() -{ - QObject *backendObj = Phonon::Factory::backend(); - Q_ASSERT(backendObj); - //QMetaObject::invokeMethod(backendObj, "experimentalBackend", Qt::DirectConnection, - //Q_RETURN_ARG(QObject *, m_backendObject)); - //if (!m_backendObject) { - //qDebug() << "The backend does not support Phonon::Experimental"; - //return; - //} - connect(backendObj, SIGNAL(objectDescriptionChanged(ObjectDescriptionType)), - SLOT(objectDescriptionChanged(ObjectDescriptionType))); - connect(Phonon::Factory::sender(), SIGNAL(availableVideoCaptureDevicesChanged()), Factory::sender(), - SLOT(availableVideoCaptureDevicesChanged())); -} - -FactoryPrivate::~FactoryPrivate() -{ -} - -void FactoryPrivate::objectDescriptionChanged(ObjectDescriptionType type) -{ - qDebug() << Q_FUNC_INFO << type; - switch (type) { - default: - break; - } -} - -Factory::Sender *Factory::sender() -{ - return globalFactory; -} - -QObject *Factory::createAudioDataOutput(QObject *parent) -{ - Phonon::BackendInterface *b = qobject_cast(Phonon::Factory::backend()); - if (b) { - return Phonon::Factory::registerQObject(b->createObject( - static_cast(Phonon::BackendInterface::AudioDataOutputClass), - parent)); - } - return 0; -} - -QObject *Factory::createVideoDataOutput(QObject *parent) -{ - Phonon::BackendInterface *b = qobject_cast(Phonon::Factory::backend()); - if (b) { - return Phonon::Factory::registerQObject(b->createObject( - static_cast(Phonon::BackendInterface::VideoDataOutputClass), - parent)); - } - return 0; -} - -QObject *Factory::createAvCapture(QObject *parent) -{ - Phonon::BackendInterface *b = qobject_cast(Phonon::Factory::backend()); - if (b) { - return Phonon::Factory::registerQObject(b->createObject( - static_cast(Phonon::Experimental::BackendInterface::AvCaptureClass), - parent)); - } - return 0; -} - -QObject *Factory::createVisualization(QObject *parent) -{ - Phonon::BackendInterface *b = qobject_cast(Phonon::Factory::backend()); - if (b) { - return Phonon::Factory::registerQObject(b->createObject( - static_cast(Phonon::Experimental::BackendInterface::VisualizationClass), - parent)); - } - return 0; -} - -} // namespace Experimental -} // namespace Phonon -#include "experimental/moc_factory_p.h" diff --git a/src/phonon/experimental/factory_p.h b/src/phonon/experimental/factory_p.h deleted file mode 100644 index 54c387665..000000000 --- a/src/phonon/experimental/factory_p.h +++ /dev/null @@ -1,74 +0,0 @@ -/* This file is part of the KDE project - Copyright (C) 2008 Matthias Kretz - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), Nokia Corporation - (or its successors, if any) and the KDE Free Qt Foundation, which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . - -*/ -#ifndef PHONON_EXPERIMENTAL_FACTORY_P_H -#define PHONON_EXPERIMENTAL_FACTORY_P_H - -#include -#include "export.h" - -namespace Phonon -{ -namespace Experimental -{ -namespace Factory -{ - /** - * Emits signals for Phonon::Experimental::Factory. - */ - class Sender : public QObject - { - Q_OBJECT - - Q_SIGNALS: - void availableVideoCaptureDevicesChanged(); - }; - - PHONONEXPERIMENTAL_EXPORT Sender *sender(); - - /** - * Create a new backend object for a AudioDataOutput. - * - * \return a pointer to the AudioDataOutput the backend provides. - */ - PHONONEXPERIMENTAL_EXPORT QObject *createAudioDataOutput(QObject *parent = 0); - - /** - * Create a new backend object for a VideoDataOutput. - * - * \return a pointer to the VideoDataOutput the backend provides. - */ - QObject *createVideoDataOutput(QObject *parent = 0); - - QObject *createAvCapture(QObject *parent = 0); - - /** - * Create a new backend object for a Visualization. - * - * \return a pointer to the Visualization the backend provides. - */ - PHONONEXPERIMENTAL_EXPORT QObject *createVisualization(QObject *parent = 0); - -} // namespace Factory -} // namespace Experimental -} // namespace Phonon - -#endif // PHONON_EXPERIMENTAL_FACTORY_P_H diff --git a/src/phonon/experimental/globalconfig.cpp b/src/phonon/experimental/globalconfig.cpp deleted file mode 100644 index a6f4ea887..000000000 --- a/src/phonon/experimental/globalconfig.cpp +++ /dev/null @@ -1,66 +0,0 @@ -/* This file is part of the KDE project - Copyright (C) 2006-2008 Matthias Kretz - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), Nokia Corporation - (or its successors, if any) and the KDE Free Qt Foundation, which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . - -*/ - -#include "globalconfig.h" -#include "../globalconfig_p.h" - -#include "../factory_p.h" -#include "../phonondefs_p.h" -#include "../backendinterface.h" -#include "../qsettingsgroup_p.h" -#include "../platformplugin.h" - -#include -#include - -namespace Phonon -{ -namespace Experimental -{ - -#ifndef PHONON_NO_VIDEOCAPTURE -QList GlobalConfig::videoCaptureDeviceListFor(Category category, int override) const -{ - Q_UNUSED(category); - return Phonon::GlobalConfig::videoCaptureDeviceListFor(Phonon::NoCaptureCategory, override); -} - -int GlobalConfig::videoCaptureDeviceFor(Category category, int override) const -{ - Q_UNUSED(category); - return Phonon::GlobalConfig::videoCaptureDeviceFor(Phonon::NoCaptureCategory, override); -} - -QList< int > GlobalConfig::videoCaptureDeviceListFor(CaptureCategory category, int override) const -{ - return Phonon::GlobalConfig::videoCaptureDeviceListFor(category, override); -} - -int Experimental::GlobalConfig::videoCaptureDeviceFor(CaptureCategory category, int override) const -{ - return Phonon::GlobalConfig::videoCaptureDeviceFor(category, override); -} - -#endif // PHONON_NO_VIDEOCAPTURE - -} // namespace Experimental -} // namespace Phonon diff --git a/src/phonon/experimental/globalconfig.h b/src/phonon/experimental/globalconfig.h deleted file mode 100644 index f8549b51b..000000000 --- a/src/phonon/experimental/globalconfig.h +++ /dev/null @@ -1,59 +0,0 @@ -/* This file is part of the KDE project -Copyright (C) 2006-2008 Matthias Kretz - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), Nokia Corporation - (or its successors, if any) and the KDE Free Qt Foundation, which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . - -*/ - -#ifndef PHONON_EXPERIMENTAL_GLOBALCONFIG_P_H -#define PHONON_EXPERIMENTAL_GLOBALCONFIG_P_H - -#include -#include - -#include "export.h" -#include "../globalconfig.h" - - -namespace Phonon -{ -namespace Experimental -{ - -class PHONONEXPERIMENTAL_EXPORT GlobalConfig : public Phonon::GlobalConfig -{ - P_DECLARE_PRIVATE(Phonon::GlobalConfig) - -#ifndef PHONON_NO_VIDEOCAPTURE -public: - PHONON_DEPRECATED QList videoCaptureDeviceListFor(Phonon::Category category, int override = AdvancedDevicesFromSettings) const; - PHONON_DEPRECATED int videoCaptureDeviceFor(Phonon::Category category, int override = AdvancedDevicesFromSettings) const; - QList videoCaptureDeviceListFor(Phonon::CaptureCategory category, int override = AdvancedDevicesFromSettings) const; - int videoCaptureDeviceFor(Phonon::CaptureCategory category, int override = AdvancedDevicesFromSettings) const; - -Q_SIGNALS: - void videoCaptureDeviceConfigChanged(); -#endif // PHONON_NO_VIDEOCAPTURE - -}; // GlobalConfig class - -} // namespace Experimental -} // namespace Phonon - - -#endif // PHONON_EXPERIMENTAL_GLOBALCONFIG_P_H diff --git a/src/phonon/experimental/lockfreequeue.cpp b/src/phonon/experimental/lockfreequeue.cpp deleted file mode 100644 index 6153697dc..000000000 --- a/src/phonon/experimental/lockfreequeue.cpp +++ /dev/null @@ -1,309 +0,0 @@ -/* This file is part of the KDE project - Copyright (C) 2008 Matthias Kretz - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), Nokia Corporation - (or its successors, if any) and the KDE Free Qt Foundation, which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . - -*/ - -#include "lockfreequeue_p.h" -#include -#include -#include -#include -#include "globalstatic_p.h" - -struct MemoryPool -{ - ~MemoryPool(); - // Stack structure: - QAtomicPointer stack; - QAtomicInt count; - QAtomicInt size; - - void clear(); -}; - -void MemoryPool::clear() -{ - LockFreeQueueBase::NodeBase *node = stack; - while (node) { - if (stack.testAndSetAcquire(node, const_cast(node->next))) { - count.deref(); - free(node); - } - node = stack; - } -} - -MemoryPool::~MemoryPool() -{ - LockFreeQueueBase::NodeBase *node = stack; - while (node) { - void *toDelete = node; - node = const_cast(node->next); - ::free(toDelete); - } -} - -struct MemoryPoolVector -{ - static const int POOL_COUNT = 16; - ~MemoryPoolVector() { delete next; } - inline MemoryPool &operator[](size_t s) - { - for (int i = 0; i < POOL_COUNT; ++i) { - if (m_pools[i].size == static_cast(s)) { - return m_pools[i]; - } else if (m_pools[i].size == 0) { - if (m_pools[i].size.testAndSetRelaxed(0, static_cast(s))) { - return m_pools[i]; - } - if (m_pools[i].size == static_cast(s)) { - return m_pools[i]; - } - } - } - if (!next) { - MemoryPoolVector *newPoolVector = new MemoryPoolVector; - if (!next.testAndSetRelaxed(0, newPoolVector)) { - delete newPoolVector; - } - } - return (*next)[s]; - } - - void clearAllPools() - { - for (int i = 0; i < POOL_COUNT; ++i) { - if (0 == m_pools[i].size) { - return; - } - m_pools[i].clear(); - } - if (next) { - next->clearAllPools(); - } - } - - MemoryPool m_pools[POOL_COUNT]; - QAtomicPointer next; -}; - -static int s_poolSize = 128; -PHONON_GLOBAL_STATIC(MemoryPoolVector, s_memoryPool) - -void *LockFreeQueueBase::NodeBaseKeepNodePool::operator new(size_t s) -{ - MemoryPool &p = (*s_memoryPool)[s]; - NodeBase *node = p.stack; - if (node) { - if (!p.stack.testAndSetAcquire(node, const_cast(node->next))) { - return ::malloc(s); - } - p.count.deref(); - return node; - } - return ::malloc(s); -} - -void LockFreeQueueBase::NodeBaseKeepNodePool::operator delete(void *ptr, size_t s) -{ - MemoryPool &p = (*s_memoryPool)[s]; - if (p.count > s_poolSize) { - ::free(ptr); - return; - } - NodeBase *node = static_cast(ptr); - NodeBase *next = p.stack; - node->next = next; - if (!p.stack.testAndSetOrdered(next, node)) { - ::free(ptr); - return; - } - p.count.ref(); -} - -void LockFreeQueueBase::NodeBaseKeepNodePool::clear() -{ - s_memoryPool->clearAllPools(); -} - -void LockFreeQueueBase::NodeBaseKeepNodePool::setPoolSize(int s) -{ - s_poolSize = s; -} - -int LockFreeQueueBase::NodeBaseKeepNodePool::poolSize() -{ - return s_poolSize; -} - -class LockFreeQueueBasePrivate -{ - public: - LockFreeQueueBasePrivate(); - ~LockFreeQueueBasePrivate(); - QReadWriteLock dataReadyHandlerMutex; - LockFreeQueueBase::NodeBase *sentinel; // end marker - LockFreeQueueBase::NodeBase *lastHeadNode; - QAtomicPointer queueHead; - QAtomicPointer queueTail; - QAtomicInt size; - LockFreeQueueBase::DataReadyHandler *dataReadyHandler; -}; - -LockFreeQueueBasePrivate::LockFreeQueueBasePrivate() - : sentinel(new LockFreeQueueBase::NodeBase(0)), - lastHeadNode(new LockFreeQueueBase::NodeBase(sentinel)), - queueHead(&lastHeadNode->next), - queueTail(&lastHeadNode->next), - size(0), - dataReadyHandler(0) -{ - // let d->sentinel point to itself so that we can use d->sentinel->next as - // QAtomicPointer for d->queueHead and d->queueTail - sentinel->next = sentinel; -} - -LockFreeQueueBasePrivate::~LockFreeQueueBasePrivate() -{ - Q_ASSERT(queueHead); - LockFreeQueueBase::NodeBase *node = lastHeadNode; - while (node != sentinel) { - LockFreeQueueBase::NodeBase *toDelete = node; - node = const_cast(node->next); - toDelete->deref(); - } -} - -LockFreeQueueBase::LockFreeQueueBase() - : d(new LockFreeQueueBasePrivate) -{ -} - -LockFreeQueueBase::~LockFreeQueueBase() -{ - delete d; -} - -void LockFreeQueueBase::setDataReadyHandler(DataReadyHandler *h) -{ - QWriteLocker lock(&d->dataReadyHandlerMutex); - d->dataReadyHandler = h; -} - -void LockFreeQueueBase::_enqueue(NodeBase *newNode) -{ - newNode->ref(); - newNode->next = d->sentinel; - /*if (d->size > 0 && newNode->priority > std::numeric_limits::min()) { - NodeBasePointer *node = d->queueHead.fetchAndStoreRelaxed(&d->sentinel->next); - if (node == &d->sentinel->next) { - // Another thread got the real node, we just got the placeholder telling us to not touch - // anything. As we replaced &d->sentinel->next with &d->sentinel->next in - // d->queueHead we don't have to reset anything. - } - // node is a pointer to a Node::next member pointing to the first entry in - // the list - if (*node == d->sentinel) { - // the list is empty, good - } - } else {*/ - // just append - NodeBasePointer &lastNextPointer = *d->queueTail.fetchAndStoreAcquire(&newNode->next); - lastNextPointer = newNode; - d->size.ref(); - - if (d->dataReadyHandler) { - QReadLocker lock(&d->dataReadyHandlerMutex); - if (d->dataReadyHandler) { - d->dataReadyHandler->dataReady(); - } - } - //} -} - -LockFreeQueueBase::NodeBase *LockFreeQueueBase::_acquireHeadNodeBlocking() -{ - NodeBasePointer *node = 0; - while (d->size > 0) { - if ((node = d->queueHead.fetchAndStoreRelaxed(&d->sentinel->next)) != &d->sentinel->next) { - // node is a pointer to a Node::next member pointing to the first entry in the list - if (*node != d->sentinel) { - d->size.deref(); - NodeBase *_node = const_cast(*node); // cast volatile away - _node->ref(); - - NodeBase *toDeref = d->lastHeadNode; - d->lastHeadNode = _node; - const bool check = d->queueHead.testAndSetRelease(&d->sentinel->next, &_node->next); - Q_ASSERT(check); Q_UNUSED(check); - toDeref->deref(); - - return _node; - } - // empty (d->size == 0), put it back - const bool check = d->queueHead.testAndSetRelaxed(&d->sentinel->next, node); - Q_ASSERT(check); Q_UNUSED(check); - // try again, with some luck d->size is > 0 again - } - } - return 0; -} - -LockFreeQueueBase::NodeBase *LockFreeQueueBase::_acquireHeadNode() -{ - if (*d->queueHead == d->sentinel || d->queueHead == &d->sentinel->next) { - return 0; - } - // setting d->queueHead to &d->sentinel->next makes the above check fail (i.e. all - // other threads in a dequeue function will exit). Also enqueue will not modify - // this as d->queueTail references d->lastHeadNode->next which != d->sentinel->next - NodeBasePointer *node = d->queueHead.fetchAndStoreRelaxed(&d->sentinel->next); - if (node == &d->sentinel->next) { - // Another thread got the real node, we just got the placeholder telling us to not touch - // anything. As we replaced &d->sentinel->next with &d->sentinel->next in - // d->queueHead we don't have to reset anything. - return 0; - } - // node is a pointer to a Node::next member pointing to the first entry in - // the list - if (*node == d->sentinel) { - //qDebug() << "empty, put it back"; - const bool check = d->queueHead.testAndSetRelaxed(&d->sentinel->next, node); - Q_ASSERT(check); Q_UNUSED(check); - return 0; - } - d->size.deref(); - - NodeBase *_node = const_cast(*node); - _node->ref(); - - NodeBase *toDeref = d->lastHeadNode; - d->lastHeadNode = _node; - const bool check = d->queueHead.testAndSetRelease(&d->sentinel->next, &_node->next); - Q_ASSERT(check); Q_UNUSED(check); - toDeref->deref(); - - return _node; -} - -int LockFreeQueueBase::size() const -{ - return d->size; -} diff --git a/src/phonon/experimental/lockfreequeue_p.h b/src/phonon/experimental/lockfreequeue_p.h deleted file mode 100644 index dace7f04a..000000000 --- a/src/phonon/experimental/lockfreequeue_p.h +++ /dev/null @@ -1,156 +0,0 @@ -/* This file is part of the KDE project - Copyright (C) 2008 Matthias Kretz - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), Nokia Corporation - (or its successors, if any) and the KDE Free Qt Foundation, which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . - -*/ - -#ifndef LOCKFREEQUEUE_P_H -#define LOCKFREEQUEUE_P_H - -#include - -class LockFreeQueueBasePrivate; -struct MemoryPool; -class LockFreeQueueBase -{ - friend class LockFreeQueueBasePrivate; - public: - struct DataReadyHandler - { - virtual ~DataReadyHandler() {} - virtual void dataReady() = 0; - }; - - void setDataReadyHandler(DataReadyHandler *); - - int size() const; - bool isEmpty() const { return 0 == size(); } - - protected: - friend struct MemoryPool; - LockFreeQueueBase(); - ~LockFreeQueueBase(); - - public: - class NodeBase; - typedef volatile NodeBase * NodeBasePointer; - class NodeBase - { - public: - inline NodeBase(int p) : priority(p) {} - inline NodeBase(NodeBase *n) : next(n), priority(0) {} - NodeBasePointer next; - int priority; - - inline void ref() { refCount.ref(); } - inline void deref() { if (!refCount.deref()) delete this; } - - protected: - ~NodeBase() { Q_ASSERT(refCount == 0); } - private: - QAtomicInt refCount; - }; - - struct NodeBaseKeepNodePool : public NodeBase - { - inline NodeBaseKeepNodePool(int priority) : NodeBase(priority) {} - // allocation is a bottleneck in _enqueue - void *operator new(size_t s); - void operator delete(void *p, size_t s); - - static void clear(); - static void setPoolSize(int); - static int poolSize(); - }; - - typedef NodeBase StdNewDeleteMemoryManagement; - typedef NodeBaseKeepNodePool KeepNodePoolMemoryManagement; - protected: - - void _enqueue(NodeBase *); - NodeBase *_acquireHeadNode(); - NodeBase *_acquireHeadNodeBlocking(); - - LockFreeQueueBasePrivate *const d; - -}; - -template -class LockFreeQueue : public LockFreeQueueBase -{ - public: - enum BlockingSwitch { - BlockUnlessEmpty, - NeverBlock - }; - - struct Node : public MemoryManagementNodeBase - { - inline Node(const T &d, int priority) : MemoryManagementNodeBase(priority), data(d) {} - T data; - }; - - inline void enqueue(const T &data, int priority = 0) - { - _enqueue(new Node(data, 0)); - } - - inline void dequeue(QVector &data, BlockingSwitch block = BlockUnlessEmpty) - { - int count = 0; - while (count < data.capacity()) { - NodeBase *node = (block == NeverBlock) ? _acquireHeadNode() : _acquireHeadNodeBlocking(); - if (!node) { - break; - } - if (count < data.size()) { - data[count] = static_cast(node)->data; - } else { - data << static_cast(node)->data; - } - ++count; - node->deref(); - } - data.resize(count); - } - - inline bool dequeue(T *data, BlockingSwitch block = BlockUnlessEmpty) - { - NodeBase *node = (block == NeverBlock) ? _acquireHeadNode() : _acquireHeadNodeBlocking(); - if (node) { - *data = static_cast(node)->data; - node->deref(); - return true; - } - return false; - } - - inline LockFreeQueue &operator<<(const T &data) { enqueue(data); return *this; } - inline LockFreeQueue &operator>>(T &data) - { - NodeBase *node = _acquireHeadNodeBlocking(); - if (node) { - data = static_cast(node)->data; - node->deref(); - } - return *this; - } -}; - -#endif // LOCKFREEQUEUE_P_H diff --git a/src/phonon/experimental/mediasource.cpp b/src/phonon/experimental/mediasource.cpp deleted file mode 100644 index 24230676e..000000000 --- a/src/phonon/experimental/mediasource.cpp +++ /dev/null @@ -1,82 +0,0 @@ -/* This file is part of the KDE project - Copyright (C) 2008 Matthias Kretz - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2 of - the License or (at your option) version 3 or any later version - accepted by the membership of KDE e.V. (or its successor approved - by the membership of KDE e.V.), Nokia Corporation (or its successors, - if any) and the KDE Free Qt Foundation, which shall act as a proxy - defined in Section 14 of version 3 of the license. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . - -*/ - -#include "mediasource.h" -#include "mediasource_p.h" - -#define S_D(Class) Class##Private *d = reinterpret_cast(Phonon::MediaSource::d.data()) - -namespace Phonon -{ -namespace Experimental -{ - -MediaSource::MediaSource(const MediaSource &rhs) - : Phonon::MediaSource(rhs) -{ -} - -MediaSource::MediaSource(const QList &mediaList) - : Phonon::MediaSource(*new MediaSourcePrivate(Link)) -{ - S_D(MediaSource); - d->linkedSources = mediaList; - foreach (const Phonon::MediaSource &ms, mediaList) { - Q_ASSERT(static_cast(ms.type()) != Link); - Q_UNUSED(ms); - } -} - -#ifndef PHONON_NO_VIDEOCAPTURE -MediaSource::MediaSource(const VideoCaptureDevice &videoDevice) - : Phonon::MediaSource(*new MediaSourcePrivate(VideoCaptureDeviceSource)) -{ - Q_UNUSED(videoDevice); -} -#endif // PHONON_NO_VIDEOCAPTURE - -MediaSource &MediaSource::operator=(const MediaSource &rhs) -{ - d = rhs.d; - return *this; -} - -bool MediaSource::operator==(const MediaSource &rhs) const -{ - return d == rhs.d; -} - -#ifndef PHONON_NO_VIDEOCAPTURE -VideoCaptureDevice MediaSource::videoCaptureDevice() const -{ - return phononVcdToExperimentalVcd(Phonon::MediaSource::videoCaptureDevice()); -} -#endif // PHONON_NO_VIDEOCAPTURE - -QList MediaSource::substreams() const -{ - S_D(MediaSource); - return d->linkedSources; -} - -} // namespace Experimental -} // namespace Phonon diff --git a/src/phonon/experimental/mediasource.h b/src/phonon/experimental/mediasource.h deleted file mode 100644 index da76146db..000000000 --- a/src/phonon/experimental/mediasource.h +++ /dev/null @@ -1,79 +0,0 @@ -/* This file is part of the KDE project - Copyright (C) 2008 Matthias Kretz - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), Nokia Corporation - (or its successors, if any) and the KDE Free Qt Foundation, which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . - -*/ - -#ifndef PHONON_EXPERIMENTAL_MEDIASOURCE_H -#define PHONON_EXPERIMENTAL_MEDIASOURCE_H - -#include "../mediasource.h" -#include "export.h" -#include "objectdescription.h" - -namespace Phonon -{ -namespace Experimental -{ - -class PHONONEXPERIMENTAL_EXPORT MediaSource : public Phonon::MediaSource -{ - public: - enum Type { - Link = 0xffff, - VideoCaptureDeviceSource - }; - - /** - * Constructs a copy of \p rhs. - * - * This constructor is fast thanks to explicit sharing. - */ - MediaSource(const MediaSource &rhs); - - MediaSource(const QList &mediaList); - -#ifndef PHONON_NO_VIDEOCAPTURE - MediaSource(const VideoCaptureDevice &videoDevice); -#endif // PHONON_NO_VIDEOCAPTURE - - - /** - * Assigns \p rhs to this MediaSource and returns a reference to this MediaSource. - * - * This operation is fast thanks to explicit sharing. - */ - MediaSource &operator=(const MediaSource &rhs); - - /** - * Returns \p true if this MediaSource is equal to \p rhs; otherwise returns \p false. - */ - bool operator==(const MediaSource &rhs) const; - -#ifndef PHONON_NO_VIDEOCAPTURE - VideoCaptureDevice videoCaptureDevice() const; -#endif // PHONON_NO_VIDEOCAPTURE - - QList substreams() const; -}; - -} // namespace Experimental -} // namespace Phonon - -#endif // PHONON_EXPERIMENTAL_MEDIASOURCE_H diff --git a/src/phonon/experimental/mediasource_p.h b/src/phonon/experimental/mediasource_p.h deleted file mode 100644 index 12a8eac86..000000000 --- a/src/phonon/experimental/mediasource_p.h +++ /dev/null @@ -1,49 +0,0 @@ -/* This file is part of the KDE project - Copyright (C) 2008 Matthias Kretz - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), Nokia Corporation - (or its successors, if any) and the KDE Free Qt Foundation, which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . - -*/ - -#ifndef PHONON_EXPERIMENTAL_MEDIASOURCE_P_H -#define PHONON_EXPERIMENTAL_MEDIASOURCE_P_H - -#include "mediasource.h" -#include "../mediasource_p.h" -#include "objectdescription.h" - -namespace Phonon -{ -namespace Experimental -{ - -class MediaSourcePrivate : public Phonon::MediaSourcePrivate -{ - public: - MediaSourcePrivate(MediaSource::Type t) - : Phonon::MediaSourcePrivate(static_cast(t)) - { - } - - QList linkedSources; -}; - -} // namespace Experimental -} // namespace Phonon - -#endif // PHONON_EXPERIMENTAL_MEDIASOURCE_P_H diff --git a/src/phonon/experimental/objectdescription.cpp b/src/phonon/experimental/objectdescription.cpp deleted file mode 100644 index d4bebff5d..000000000 --- a/src/phonon/experimental/objectdescription.cpp +++ /dev/null @@ -1,59 +0,0 @@ -/* This file is part of the KDE project - * Copyright © 2010 Casian Andrei - * Copyright © 2010 Harald Sitter - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) version 3, or any - * later version accepted by the membership of KDE e.V. (or its - * successor approved by the membership of KDE e.V.), Nokia Corporation - * (or its successors, if any) and the KDE Free Qt Foundation, which shall - * act as a proxy defined in Section 6 of version 3 of the license. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library. If not, see . - * - */ - -#include "objectdescription.h" - -namespace Phonon -{ - -namespace Experimental -{ - -#ifndef PHONON_NO_VIDEOCAPTURE - -VideoCaptureDevice phononVcdToExperimentalVcd(const Phonon::VideoCaptureDevice &vcd) -{ - QHash properties; - const QList &propertyNames = vcd.propertyNames(); - int pi, pn = propertyNames.count(); - for (pi = 0; pi < pn; ++ pi) - properties[propertyNames[pi]] = vcd.property(propertyNames[pi].constData()); - - return VideoCaptureDevice(vcd.index(), properties); -} - -Phonon::VideoCaptureDevice phononExperimentalVcdToVcd(const Phonon::Experimental::VideoCaptureDevice &vcd) -{ - QHash properties; - const QList &propertyNames = vcd.propertyNames(); - int pi, pn = propertyNames.count(); - for (pi = 0; pi < pn; ++ pi) - properties[propertyNames[pi]] = vcd.property(propertyNames[pi].constData()); - - return Phonon::VideoCaptureDevice(vcd.index(), properties); -} - -#endif // PHONON_NO_VIDEOCAPTURE - -} // Experimental namespace -} // Phonon namespace diff --git a/src/phonon/experimental/objectdescription.h b/src/phonon/experimental/objectdescription.h deleted file mode 100644 index 66322d0d7..000000000 --- a/src/phonon/experimental/objectdescription.h +++ /dev/null @@ -1,58 +0,0 @@ -/* This file is part of the KDE project - Copyright © 2008 Matthias Kretz - Copyright © 2010 Harald Sitter - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), Nokia Corporation - (or its successors, if any) and the KDE Free Qt Foundation, which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . - -*/ -#ifndef PHONON_EXPERIMENTAL_OBJECTDESCRIPTION_H -#define PHONON_EXPERIMENTAL_OBJECTDESCRIPTION_H - -#include "../objectdescription.h" - -namespace Phonon -{ -namespace Experimental -{ - -#ifndef PHONON_NO_VIDEOCAPTURE - -enum ObjectDescriptionType -{ - VideoCaptureDeviceType = 0x10000 -}; - -typedef Phonon::ObjectDescription(Phonon::Experimental::VideoCaptureDeviceType)> VideoCaptureDevice; - -VideoCaptureDevice phononVcdToExperimentalVcd(const Phonon::VideoCaptureDevice &vcd); - -/** - * Generates a Phonon::VideoCaptureDevice from an equal object of - * the Phonon::Experimental namespace. - * - * @arg vcd the VideoCaptureDevice to take as reference - * @return a Phonon::VideoCaptureDevice instance with the same properties as the incoming vcd - */ -Phonon::VideoCaptureDevice phononExperimentalVcdToVcd(const Phonon::Experimental::VideoCaptureDevice &vcd); - -#endif // PHONON_NO_VIDEOCAPTURE - -} // namespace Experimental -} // namespace Phonon - -#endif // PHONON_EXPERIMENTAL_OBJECTDESCRIPTION_H diff --git a/src/phonon/experimental/packet.cpp b/src/phonon/experimental/packet.cpp deleted file mode 100644 index d60e624f8..000000000 --- a/src/phonon/experimental/packet.cpp +++ /dev/null @@ -1,60 +0,0 @@ -/* This file is part of the KDE project - Copyright (C) 2007-2008 Matthias Kretz - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License version 2 as published by the Free Software Foundation. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; see the file COPYING.LIB. If not, write to - the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. - -*/ - -#include "packet.h" -#include "packet_p.h" -#include "packetpool.h" -#include "packetpool_p.h" - -namespace Phonon -{ - -Q_GLOBAL_STATIC(PacketPrivate, shared_null_packet) - -Packet::Packet() : d_ptr(shared_null_packet()) { d_ptr->ref.ref(); } -Packet::Packet(PacketPool &pool) : d_ptr(pool.d_ptr->acquirePacket().d_ptr) { d_ptr->ref.ref(); } -Packet::Packet(const Packet &rhs) : d_ptr(rhs.d_ptr) { d_ptr->ref.ref(); } -Packet::Packet(PacketPrivate &dd) : d_ptr(&dd) { d_ptr->ref.ref(); } -Packet &Packet::operator=(const Packet &rhs) -{ - if (!d_ptr->ref.deref()) { - Q_ASSERT(d_ptr->m_pool); - d_ptr->m_pool->releasePacket(*this); - } - d_ptr = rhs.d_ptr; - d_ptr->ref.ref(); - return *this; -} -Packet::~Packet() -{ - if (!d_ptr->ref.deref()) { - Q_ASSERT(d_ptr->m_pool); - d_ptr->m_pool->releasePacket(*this); - } -} -bool Packet::operator==(const Packet &rhs) const { return d_ptr == rhs.d_ptr; } -bool Packet::operator!=(const Packet &rhs) const { return d_ptr != rhs.d_ptr; } -bool Packet::isNull() const { return d_ptr->m_pool == 0; } -const char *Packet::data() const { return d_ptr->m_data; } -char *Packet::data() { return d_ptr->m_data; } -int Packet::size() const { return d_ptr->m_size; } -void Packet::setSize(int size) { d_ptr->m_size = size; } -int Packet::capacity() const { return d_ptr->m_pool ? d_ptr->m_pool->packetSize : 0; } - -} // namespace Phonon diff --git a/src/phonon/experimental/packet.h b/src/phonon/experimental/packet.h deleted file mode 100644 index 7f4a7a8f3..000000000 --- a/src/phonon/experimental/packet.h +++ /dev/null @@ -1,129 +0,0 @@ -/* This file is part of the KDE project - Copyright (C) 2007-2008 Matthias Kretz - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License version 2 as published by the Free Software Foundation. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; see the file COPYING.LIB. If not, write to - the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. - -*/ - -#ifndef PHONON_PACKET_H -#define PHONON_PACKET_H - -#include "export.h" - -namespace Phonon -{ - -class PacketPool; - -struct PacketPrivate; -/** \class Packet packetpool.h phonon/Packet - * \brief Class to access memory preallocated by PacketPool - * - * \note PacketPool and Packet are threadsafe. - * - * \author Matthias Kretz - */ -class PHONONEXPERIMENTAL_EXPORT Packet -{ - friend class PacketPoolPrivate; - Q_DECLARE_PRIVATE(Packet) - public: - /** - * Constructs a null packet. - * - * \see isNull - */ - Packet(); - /** - * Returns a packet with a capacity of pool.packetSize if there is still free data in the - * PacketPool. Returns a null packet otherwise. The size will initially be set to 0. - */ - explicit Packet(PacketPool &pool); - /** - * Returns a shared copy of the object. Note that Packet will not detach (and it can not - * detach as there's a fixed amount of memory preallocated. If you want to copy the actual - * memory data you have to request another packet from the pool and copy the memory - * yourself.) - */ - Packet(const Packet &rhs); - /** - * Assigns a shared copy of the object. Note that Packet will not detach (and it can not - * detach as there's a fixed amount of memory preallocated. If you want to copy the actual - * memory data you have to request another packet from the pool and copy the memory - * yourself.) - */ - Packet &operator=(const Packet &rhs); - - /** - * Dereferences the packet data. If this is the last reference that gets released the packet - * becomes available in the PacketPool again automatically. - */ - ~Packet(); - - /** - * Returns whether the packets reference the same data. - */ - bool operator==(const Packet &rhs) const; - - /** - * Returns whether the packets reference different data. - */ - bool operator!=(const Packet &rhs) const; - - /** - * Returns whether this object is a null packet. - * - * \see Packet() - */ - bool isNull() const; - - /** - * Returns a pointer to read the data this packet references. - * - * You may read size() bytes. - */ - const char *data() const; - - /** - * Returns a pointer to read and write the data this packet references. - * - * You may read size() bytes. - * You may write capacity() bytes. - * If you write to this pointer do not forget to adjust the size by calling setSize(). - */ - char *data(); - - /** - * Returns the number of bytes that have a defined value. - */ - int size() const; - - /** - * Sets how many bytes in the data pointer have a defined value. - */ - void setSize(int size); - - /** - * Returns the number of bytes that may be accessed. - */ - int capacity() const; - - protected: - explicit Packet(PacketPrivate &dd); - PacketPrivate *d_ptr; -}; - -} // namespace Phonon -#endif // PHONON_PACKET_H diff --git a/src/phonon/experimental/packet_p.h b/src/phonon/experimental/packet_p.h deleted file mode 100644 index b37112fee..000000000 --- a/src/phonon/experimental/packet_p.h +++ /dev/null @@ -1,45 +0,0 @@ -/* This file is part of the KDE project - Copyright (C) 2008 Matthias Kretz - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) version 3. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; see the file COPYING.LIB. If not, write to - the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. - -*/ - -#ifndef PHONON_PACKET_P_H -#define PHONON_PACKET_P_H - -#include - -namespace Phonon -{ - -class PacketPoolPrivate; -struct PacketPrivate -{ - inline PacketPrivate(char *_data, PacketPoolPrivate *_pool) - : ref(0), m_size(0), m_data(_data), m_pool(_pool) {} - inline PacketPrivate() : ref(1), m_size(0), m_data(0), m_pool(0) {} - - QAtomicInt ref; - - int m_size; - char *const m_data; - PacketPoolPrivate *const m_pool; -}; - -} // namespace Phonon - -#endif // PHONON_PACKET_P_H diff --git a/src/phonon/experimental/packetpool.cpp b/src/phonon/experimental/packetpool.cpp deleted file mode 100644 index fd226d205..000000000 --- a/src/phonon/experimental/packetpool.cpp +++ /dev/null @@ -1,115 +0,0 @@ -/* This file is part of the KDE project - Copyright (C) 2007-2008 Matthias Kretz - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License version 2 as published by the Free Software Foundation. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; see the file COPYING.LIB. If not, write to - the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. - -*/ - -#include "packetpool.h" -#include "packetpool_p.h" -#include "packet.h" -#include "packet_p.h" - -namespace Phonon -{ - -int PacketPool::packetSize() const { return d_ptr->packetSize; } -int PacketPool::poolSize() const { return d_ptr->poolSize; } -int PacketPool::unusedPackets() const { return d_ptr->ringBufferSize; } - -PacketPoolPrivate::PacketPoolPrivate(int _packetSize, int _poolSize) - : freePackets(new PacketPrivate *[_poolSize]), - packetMemory(new char[_packetSize * _poolSize]), - readPosition(0), writePosition(0), - ringBufferSize(_poolSize), - packetSize(_packetSize), - poolSize(_poolSize) -{ - for (int i = 0; i < _poolSize; ++i) { - freePackets[i] = new PacketPrivate(&packetMemory[i * packetSize], this); - } -} - -PacketPoolPrivate::~PacketPoolPrivate() -{ - Q_ASSERT(poolSize == ringBufferSize); - for (int i = 0; i < poolSize; ++i) { - delete freePackets[i]; - } - delete[] freePackets; - delete[] packetMemory; -} - -void PacketPoolPrivate::releasePacket(const Packet &packet) -{ - const int _writePos = writePosition.fetchAndAddAcquire(1); - int pos = _writePos; - while (pos >= poolSize) { - pos -= poolSize; - } - writePosition.testAndSetRelease(_writePos, pos); - freePackets[pos] = packet.d_ptr; - ringBufferSize.ref(); -} - -Packet PacketPoolPrivate::acquirePacket() -{ - const int s = ringBufferSize.fetchAndAddRelaxed(-1); - if (s <= 0) { - ringBufferSize.fetchAndAddRelaxed(1); - return Packet(); - } - const int _readPos = readPosition.fetchAndAddRelaxed(1); - int pos = _readPos; - while (pos >= poolSize) { - pos -= poolSize; - } - readPosition.testAndSetRelease(_readPos, pos); - freePackets[pos]->m_size = 0; - return Packet(*freePackets[pos]); -} - -PacketPool::PacketPool(int packetSize, int _poolSize) - : d_ptr(new PacketPoolPrivate(packetSize, _poolSize)) -{ - d_ptr->ref.ref(); -} - -PacketPool::PacketPool(const PacketPool &rhs) - : d_ptr(rhs.d_ptr) -{ - d_ptr->ref.ref(); -} - -PacketPool &PacketPool::operator=(const PacketPool &rhs) -{ - if (d_ptr != rhs.d_ptr) { - if (!d_ptr->ref.deref()) { - delete d_ptr; - } - d_ptr = rhs.d_ptr; - d_ptr->ref.ref(); - } - return *this; -} - -PacketPool::~PacketPool() -{ - if (!d_ptr->ref.deref()) { - delete d_ptr; - } -} - -} // namespace Phonon diff --git a/src/phonon/experimental/packetpool.h b/src/phonon/experimental/packetpool.h deleted file mode 100644 index db8628e1d..000000000 --- a/src/phonon/experimental/packetpool.h +++ /dev/null @@ -1,79 +0,0 @@ -/* This file is part of the KDE project - Copyright (C) 2007-2008 Matthias Kretz - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License version 2 as published by the Free Software Foundation. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; see the file COPYING.LIB. If not, write to - the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. - -*/ - -#ifndef PHONON_PACKETPOOL_H -#define PHONON_PACKETPOOL_H - -#include "export.h" - -namespace Phonon -{ - -class Packet; -class PacketPoolPrivate; -/** \class PacketPool packetpool.h phonon/PacketPool - * \brief Class to preallocate memory. - * - * \note PacketPool and Packet are threadsafe. - * - * \author Matthias Kretz - */ -class PHONONEXPERIMENTAL_EXPORT PacketPool -{ - Q_DECLARE_PRIVATE(PacketPool) - friend class Packet; - public: - /** - * Allocates \p numberOfPackets packets of \p packetSize bytes each. The memory can be - * accessed through Packet objects. - */ - PacketPool(int packetSize, int numberOfPackets); - /** - * Copy constructor. Copying is fast since the class is explicitly shared. - */ - PacketPool(const PacketPool &); - /** - * Destructs this object. If this is the last reference to the pool the memory will be - * freed. - */ - ~PacketPool(); - /** - * Assignmen operator. Copying is fast since the class is explicitly shared. - */ - PacketPool &operator=(const PacketPool &); - - /** - * Returns the packet size that was set in the constructor. - */ - int packetSize() const; - /** - * Returns the number of packets that was requested in the constructor. - */ - int poolSize() const; - /** - * Returns the number of packets that are still available for use. - */ - int unusedPackets() const; - - private: - PacketPoolPrivate *d_ptr; -}; - -} // namespace Phonon -#endif // PHONON_PACKETPOOL_H diff --git a/src/phonon/experimental/packetpool_p.h b/src/phonon/experimental/packetpool_p.h deleted file mode 100644 index a9b1863a9..000000000 --- a/src/phonon/experimental/packetpool_p.h +++ /dev/null @@ -1,61 +0,0 @@ -/* This file is part of the KDE project - Copyright (C) 2008 Matthias Kretz - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) version 3. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; see the file COPYING.LIB. If not, write to - the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. - -*/ - - -#ifndef PHONON_PACKETPOOL_P_H -#define PHONON_PACKETPOOL_P_H - -#include - -namespace Phonon -{ - -struct PacketPrivate; -class PacketPoolPrivate -{ - friend class PacketPool; - friend class Packet; - public: - ~PacketPoolPrivate(); - - Packet acquirePacket(); - void releasePacket(const Packet &); - - protected: - QAtomicInt ref; - - private: - PacketPoolPrivate(int packetSize, int _poolSize); - - // C-array of PacketPrivate* - PacketPrivate **freePackets; - char *const packetMemory; - - QAtomicInt readPosition; - QAtomicInt writePosition; - QAtomicInt ringBufferSize; - - const int packetSize; - const int poolSize; -}; - -} // namespace Phonon - -#endif // PHONON_PACKETPOOL_P_H diff --git a/src/phonon/experimental/phononnamespace.h b/src/phonon/experimental/phononnamespace.h deleted file mode 100644 index d727238ad..000000000 --- a/src/phonon/experimental/phononnamespace.h +++ /dev/null @@ -1,67 +0,0 @@ -/* This file is part of the KDE project - Copyright (C) 2008 Matthias Kretz - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), Nokia Corporation - (or its successors, if any) and the KDE Free Qt Foundation, which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . - -*/ - -#ifndef PHONON_X_PHONONNAMESPACE_H -#define PHONON_X_PHONONNAMESPACE_H - -#include "../phononnamespace.h" - -namespace Phonon -{ -namespace Experimental -{ - - enum BitRate { - UnknownBitRate = -1, - /** - * Audio Data is transported as values from -128 to 127. - */ - Signed8Bit = 100, - /** - * Audio Data is transported as values from 0 to 255 - */ - Unsigned8Bit = 200, - /** - * Audio Data is transported as values from -2^15 to 2^15-1 - */ - Signed16Bit = 300, - Signed18Bit = 400, - Signed20Bit = 500, - /** - * Audio Data is transported as values from -2^23 to 2^23-1. The data is packed in 3 - * Bytes and not padded with a 0 Byte. - */ - Signed24Bit = 600, - /** - * Audio Data is transported as values from -2^31 to 2^31-1 - */ - Signed32Bit = 700, - /** - * Audio Data is transported as values from -1.0 to 1.0 - */ - Float32Bit = 800 - }; - -} // namespace Experimental -} // namespace Phonon - -#endif // PHONON_X_PHONONNAMESPACE_H diff --git a/src/phonon/experimental/rtpreceiver.h b/src/phonon/experimental/rtpreceiver.h deleted file mode 100644 index 34238e7d9..000000000 --- a/src/phonon/experimental/rtpreceiver.h +++ /dev/null @@ -1,47 +0,0 @@ -/* This file is part of the KDE project - Copyright (C) 2006 Matthias Kretz - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), Nokia Corporation - (or its successors, if any) and the KDE Free Qt Foundation, which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . - -*/ - -#ifndef PHONON_RTPRECEIVER_H -#define PHONON_RTPRECEIVER_H - -#include "../mediaobject.h" -#include "../phonondefs.h" - -namespace Phonon -{ -namespace Experimental -{ - -class RtpReceiver : public MediaProducer -{ - Q_OBJECT - K_DECLARE_PRIVATE(RtpReceiver) - PHONON_HEIR(VideoDataOutput) - public: - setUrl(const KUrl &); - setBandwidth(int kiloBitPerSecond); -}; - -} // namespace Experimental -} // namespace Phonon - -#endif // PHONON_RTPRECEIVER_H diff --git a/src/phonon/experimental/snapshotinterface.h b/src/phonon/experimental/snapshotinterface.h deleted file mode 100644 index 950fbdb1c..000000000 --- a/src/phonon/experimental/snapshotinterface.h +++ /dev/null @@ -1,44 +0,0 @@ -/* This file is part of the KDE project - Copyright (C) 2008 Matthias Kretz - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), Nokia Corporation - (or its successors, if any) and the KDE Free Qt Foundation, which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . - -*/ - -#ifndef PHONON_EXPERIMENTAL_SNAPSHOTINTERFACE_H -#define PHONON_EXPERIMENTAL_SNAPSHOTINTERFACE_H - -namespace Phonon -{ -namespace Experimental -{ - -class SnapshotInterface -{ - public: - virtual ~SnapshotInterface() {} - - virtual QImage snapshot() const = 0; -}; - -} // namespace Experimental -} // namespace Phonon - -Q_DECLARE_INTERFACE(Phonon::Experimental::SnapshotInterface, "0SnapshotInterface.Phonon.kde.org") - -#endif // PHONON_EXPERIMENTAL_SNAPSHOTINTERFACE_H diff --git a/src/phonon/experimental/streameventqueue.cpp b/src/phonon/experimental/streameventqueue.cpp deleted file mode 100644 index 6c8738f29..000000000 --- a/src/phonon/experimental/streameventqueue.cpp +++ /dev/null @@ -1,123 +0,0 @@ -/* This file is part of the KDE project - Copyright (C) 2008 Matthias Kretz - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), Nokia Corporation - (or its successors, if any) and the KDE Free Qt Foundation, which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . - -*/ - -#include "streameventqueue_p.h" -#include "phononnamespace_p.h" -#include - -namespace Phonon -{ - -////////////////////////////////////////// -// any thread - -StreamEventQueue::StreamEventQueue() - : m_dropWriteCommands(0), - m_connecting(0) -{ -} - -StreamEventQueue::~StreamEventQueue() -{ -} - -void StreamEventQueue::setBackendCommandHandler(LockFreeQueueBase::DataReadyHandler *h) -{ - m_forBackend.setDataReadyHandler(h); -} - -void StreamEventQueue::setFrontendCommandHandler(LockFreeQueueBase::DataReadyHandler *h) -{ - m_forFrontend.setDataReadyHandler(h); -} - - -////////////////////////////////////////// -// frontend thread - -void StreamEventQueue::sendToBackend(CommandType command, const QVariant &data) -{ - m_forBackend.enqueue(Command(command, data)); -} - -bool StreamEventQueue::nextCommandForFrontend(Command *command) -{ - Q_ASSERT(command); - return m_forFrontend.dequeue(command); -} - - -////////////////////////////////////////// -// backend thread - -void StreamEventQueue::sendToFrontend(CommandType command, const QVariant &data) -{ - switch (command) { - case Seek: - case Reset: - ++m_dropWriteCommands; - break; - case Connect: - ++m_connecting; - m_dropWriteCommands = 0; - break; - default: - break; - } - m_forFrontend.enqueue(Command(command, data)); -} - -bool StreamEventQueue::nextCommandForBackend(Command *command) -{ - Q_ASSERT(command); - bool valid = m_forBackend.dequeue(command); - while (valid) { - if (m_connecting) { - if (command->command == ConnectDone) { - --m_connecting; - } - // drop all other commands until m_connecting == 0 - } else if (m_dropWriteCommands) { - switch (command->command) { - case Write: - case EndOfData: - // drop until m_dropWriteCommands == 0 - break; - case SeekDone: - case ResetDone: - --m_dropWriteCommands; - break; - case ConnectDone: - pFatal("received a ConnectDone, but there was no Connect request"); - break; - default: - return valid; - } - } else { - return valid; - } - valid = m_forBackend.dequeue(command); - } - return valid; -} - -} // namespace Phonon diff --git a/src/phonon/experimental/streameventqueue_p.h b/src/phonon/experimental/streameventqueue_p.h deleted file mode 100644 index c87d42c2c..000000000 --- a/src/phonon/experimental/streameventqueue_p.h +++ /dev/null @@ -1,88 +0,0 @@ -/* This file is part of the KDE project - Copyright (C) 2008 Matthias Kretz - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), Nokia Corporation - (or its successors, if any) and the KDE Free Qt Foundation, which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . - -*/ - -#ifndef PHONON_STREAMEVENTQUEUE_P_H -#define PHONON_STREAMEVENTQUEUE_P_H - -#include -#include "lockfreequeue_p.h" - -namespace Phonon -{ - -class StreamEventQueue -{ - public: - StreamEventQueue(); - ~StreamEventQueue(); - - void setBackendCommandHandler(LockFreeQueueBase::DataReadyHandler *); - void setFrontendCommandHandler(LockFreeQueueBase::DataReadyHandler *); - - enum CommandType { - // Frontend -> Backend - SetStreamSize, - SetSeekable, - Write, - EndOfData, - SeekDone, - ResetDone, - ConnectDone, - - // Backend -> Frontend - NeedData, - EnoughData, - Seek, - Reset, - Connect - }; - - struct Command - { - inline Command(CommandType &c, const QVariant &d) : data(d), command(c) {} - inline Command() {} - QVariant data; - CommandType command; - }; - - // called from AbstractMediaStream thread - void sendToBackend(CommandType, const QVariant & = QVariant()); - bool nextCommandForFrontend(Command *); - - // called from StreamInterface thread - void sendToFrontend(CommandType, const QVariant & = QVariant()); - bool nextCommandForBackend(Command *); - - void ref() { m_references.ref(); } - void deref() { if (!m_references.deref()) delete this; } - - private: - LockFreeQueue m_forBackend; - LockFreeQueue m_forFrontend; - int m_dropWriteCommands; - int m_connecting; - QAtomicInt m_references; -}; - -} // namespace Phonon - -#endif // PHONON_STREAMEVENTQUEUE_P_H diff --git a/src/phonon/experimental/videodataoutput.cpp b/src/phonon/experimental/videodataoutput.cpp deleted file mode 100644 index 385f8a3a9..000000000 --- a/src/phonon/experimental/videodataoutput.cpp +++ /dev/null @@ -1,115 +0,0 @@ -/* This file is part of the KDE project - Copyright (C) 2005-2007 Matthias Kretz - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), Nokia Corporation - (or its successors, if any) and the KDE Free Qt Foundation, which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . - -*/ -#include "videodataoutput.h" -#include "videodataoutput_p.h" -#include "factory_p.h" -#include -#include "videoframe2.h" - -#define PHONON_CLASSNAME VideoDataOutput - -namespace Phonon -{ -namespace Experimental -{ - -VideoDataOutput::VideoDataOutput(QObject *parent) - : QObject(parent) - , AbstractVideoOutput(*new VideoDataOutputPrivate) -{ - P_D(VideoDataOutput); - d->createBackendObject(); -} - -void VideoDataOutputPrivate::createBackendObject() -{ - if (m_backendObject) - return; - P_Q(VideoDataOutput); - m_backendObject = Factory::createVideoDataOutput(q); - if (m_backendObject) { - setupBackendObject(); - } -} - - -PHONON_GETTER(int, latency, d->latency) - -bool VideoDataOutputPrivate::aboutToDeleteBackendObject() -{ - Q_ASSERT(m_backendObject); - - return AbstractVideoOutputPrivate::aboutToDeleteBackendObject(); -} - -void VideoDataOutputPrivate::setupBackendObject() -{ - P_Q(VideoDataOutput); - Q_ASSERT(m_backendObject); - //AbstractVideoOutputPrivate::setupBackendObject(); - - //QObject::connect(m_backendObject, SIGNAL(frameReady(Phonon::Experimental::VideoFrame)), - // q, SIGNAL(frameReady(Phonon::Experimental::VideoFrame))); - - QObject::connect(m_backendObject, SIGNAL(displayFrame(qint64,qint64)), - q, SIGNAL(displayFrame(qint64,qint64))); - QObject::connect(m_backendObject, SIGNAL(endOfMedia()), q, SIGNAL(endOfMedia())); -} - -bool VideoDataOutput::isRunning() const -{ - //P_D(const VideoDataOutput); - //return d->m_backendObject->isRunning(); - return false; -} - -VideoFrame VideoDataOutput::frameForTime(qint64 timestamp) -{ - Q_UNUSED(timestamp); - - //return d->m_backendObject->frameForTime(timestamp); - return VideoFrame(); -} - -void VideoDataOutput::setRunning(bool running) -{ - Q_UNUSED(running); - - //return d->m_backendObject->setRunning(running); -} - -void VideoDataOutput::start() -{ - //return d->m_backendObject->setRunning(true); -} - -void VideoDataOutput::stop() -{ - //return d->m_backendObject->setRunning(false); -} - -} // namespace Experimental -} // namespace Phonon - -#undef PHONON_CLASSNAME -// vim: sw=4 ts=4 tw=80 -#include "experimental/moc_videodataoutput.h" diff --git a/src/phonon/experimental/videodataoutput.h b/src/phonon/experimental/videodataoutput.h deleted file mode 100644 index 81ad3206d..000000000 --- a/src/phonon/experimental/videodataoutput.h +++ /dev/null @@ -1,114 +0,0 @@ -/* This file is part of the KDE project - Copyright (C) 2005-2007 Matthias Kretz - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), Nokia Corporation - (or its successors, if any) and the KDE Free Qt Foundation, which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . - -*/ - -#ifndef PHONON_VIDEODATAOUTPUT_H -#define PHONON_VIDEODATAOUTPUT_H - -#include "export.h" -#include "../abstractvideooutput.h" -#include "../phonondefs.h" -#include - -#ifndef DOXYGEN_SHOULD_SKIP_THIS -template class QVector; -template class QMap; -#endif -class QSize; - -namespace Phonon -{ -namespace Experimental -{ - class VideoDataOutputPrivate; - struct VideoFrame; - - /** - * \short This class gives you nothing. ;-) - * \deprecated - * - * \author Matthias Kretz - */ - class PHONONEXPERIMENTAL_EXPORT VideoDataOutput : public QObject, public AbstractVideoOutput - { - Q_OBJECT - P_DECLARE_PRIVATE(VideoDataOutput) - /** - * This property retrieves the nominal latency of the - * backend. - */ - Q_PROPERTY(int latency READ latency) - - /** - * This property indicates the state of the data output. - */ - Q_PROPERTY(bool running READ isRunning WRITE setRunning) - - PHONON_HEIR(VideoDataOutput) - public: - int latency() const; - - bool isRunning() const; - - Phonon::Experimental::VideoFrame frameForTime(qint64 timestamp); - - public Q_SLOTS: - void setRunning(bool running); - void start(); - void stop(); - - Q_SIGNALS: - /* FIXME: disabled this piece of documentation - add another * to enable - * Fixme: I don't think this makes sense, but I've been wrong before. - * - * Emitted whenever another dataSize number of samples are ready and - * format is set to IntegerFormat. - * - * If format is set to FloatFormat the signal is not emitted at all. - * - * \param frame An object of class VideoFrame holding the video data - * and some additional information. - * void frameReady(const Phonon::Experimental::VideoFrame &frame); - */ - - /** - * The signal is emitted whenever a frame should be displayed. - * - * The relevant frames should be fetched and displayed using frameForTime - * method. - * - * \param nowStamp the current time - * \param outStamp the time the frame should be displayed with - */ - void displayFrame(qint64 nowStamp, qint64 outStamp); - - /** - * This signal is emitted after the last frameReady signal of a - * media is emitted. - */ - void endOfMedia(); - }; - -} // namespace Experimental -} //namespace Phonon - -// vim: sw=4 ts=4 tw=80 -#endif // PHONON_VIDEODATAOUTPUT_H diff --git a/src/phonon/experimental/videodataoutput2.cpp b/src/phonon/experimental/videodataoutput2.cpp deleted file mode 100644 index eefdcfbee..000000000 --- a/src/phonon/experimental/videodataoutput2.cpp +++ /dev/null @@ -1,72 +0,0 @@ -/* This file is part of the KDE project - Copyright (C) 2008 Matthias Kretz - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), Nokia Corporation - (or its successors, if any) and the KDE Free Qt Foundation, which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . - -*/ - -#include "videodataoutput2.h" -#include "videodataoutput2_p.h" -#include "../factory_p.h" -#include -#include - -#define PHONON_CLASSNAME VideoDataOutput2 - -namespace Phonon -{ -namespace Experimental -{ - -VideoDataOutput2::VideoDataOutput2(QObject *parent) - : QObject(parent), - AbstractVideoDataOutput(*new VideoDataOutput2Private) -{ -} - -void VideoDataOutput2::frameReady(const VideoFrame2 &frame) -{ - QMetaObject::invokeMethod(this, "frameReadySignal", Qt::QueuedConnection, Q_ARG(Phonon::Experimental::VideoFrame2, frame)); -} - -void VideoDataOutput2::endOfMedia() -{ - QMetaObject::invokeMethod(this, "endOfMediaSignal", Qt::QueuedConnection); -} - -void VideoDataOutput2Private::createBackendObject() -{ - AbstractVideoDataOutputPrivate::createBackendObject(); -} - -bool VideoDataOutput2Private::aboutToDeleteBackendObject() -{ - return AbstractVideoDataOutputPrivate::aboutToDeleteBackendObject(); -} - -void VideoDataOutput2Private::setupBackendObject() -{ - AbstractVideoDataOutputPrivate::setupBackendObject(); -} - -} // namespace Experimental -} // namespace Phonon - -#undef PHONON_CLASSNAME -// vim: sw=4 ts=4 tw=80 -#include "experimental/moc_videodataoutput2.h" diff --git a/src/phonon/experimental/videodataoutput2.h b/src/phonon/experimental/videodataoutput2.h deleted file mode 100644 index f46a0e4ad..000000000 --- a/src/phonon/experimental/videodataoutput2.h +++ /dev/null @@ -1,80 +0,0 @@ -/* This file is part of the KDE project - Copyright (C) 2008 Matthias Kretz - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), Nokia Corporation - (or its successors, if any) and the KDE Free Qt Foundation, which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . - -*/ - -#ifndef PHONON_VIDEODATAOUTPUT2_H -#define PHONON_VIDEODATAOUTPUT2_H - -#include "export.h" -#include -#include "abstractvideodataoutput.h" - -namespace Phonon -{ -namespace Experimental -{ - -class VideoDataOutput2Private; - -/** - * \short This class gives you the video data. - * - * This class implements a special AbstractVideoOutput that gives your - * application the video data. - * - * You can also use the video data for further processing (e.g. encoding and - * saving to a file). - * - * \author Matthias Kretz - */ -class PHONONEXPERIMENTAL_EXPORT VideoDataOutput2 : public QObject, public AbstractVideoDataOutput -{ - Q_OBJECT - P_DECLARE_PRIVATE(VideoDataOutput2) - PHONON_HEIR(VideoDataOutput2) - - protected: - virtual void frameReady(const VideoFrame2 &); - - virtual void endOfMedia(); - - Q_SIGNALS: - /** - * The signal is emitted whenever a frame should be displayed. - * nowStamp is the current time, outStamp tells the users - * what time the frame should be displayed with. - * - * The relevant frames should be fetched and displayed using frameForTime - * method. - */ - void frameReadySignal(const Phonon::Experimental::VideoFrame2 &); - - /** - * This signal is emitted after the last frameReady signal of a - * media is emitted. - */ - void endOfMediaSignal(); -}; - -} // namespace Experimental -} //namespace Phonon - -#endif // PHONON_VIDEODATAOUTPUT2_H diff --git a/src/phonon/experimental/videodataoutput2_p.h b/src/phonon/experimental/videodataoutput2_p.h deleted file mode 100644 index 45ed4b68c..000000000 --- a/src/phonon/experimental/videodataoutput2_p.h +++ /dev/null @@ -1,45 +0,0 @@ -/* This file is part of the KDE project - Copyright (C) 2008 Matthias Kretz - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), Nokia Corporation - (or its successors, if any) and the KDE Free Qt Foundation, which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . - -*/ - -#ifndef PHONON_VIDEODATAOUTPUT2_P_H -#define PHONON_VIDEODATAOUTPUT2_P_H - -#include "videodataoutput2.h" -#include "abstractvideodataoutput_p.h" - -namespace Phonon -{ -namespace Experimental -{ - -class VideoDataOutput2Private : public AbstractVideoDataOutputPrivate -{ - P_DECLARE_PUBLIC(VideoDataOutput2) - PHONON_PRIVATECLASS - public: - virtual QObject *qObject() { return q_func(); } -}; - -} // namespace Experimental -} // namespace Phonon - -#endif // PHONON_VIDEODATAOUTPUT2_P_H diff --git a/src/phonon/experimental/videodataoutput_p.h b/src/phonon/experimental/videodataoutput_p.h deleted file mode 100644 index 41694a134..000000000 --- a/src/phonon/experimental/videodataoutput_p.h +++ /dev/null @@ -1,54 +0,0 @@ -/* This file is part of the KDE project - Copyright (C) 2006 Matthias Kretz - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), Nokia Corporation - (or its successors, if any) and the KDE Free Qt Foundation, which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . - -*/ - -#ifndef PHONON_VIDEODATAOUTPUT_P_H -#define PHONON_VIDEODATAOUTPUT_P_H - -#include "videodataoutput.h" -#include "../abstractvideooutput_p.h" -#include "videoframe.h" -#include - -namespace Phonon -{ -namespace Experimental -{ -class VideoDataOutputPrivate : public AbstractVideoOutputPrivate -{ - P_DECLARE_PUBLIC(VideoDataOutput) - PHONON_PRIVATECLASS - public: - virtual QObject *qObject() { return q_func(); } - protected: - VideoDataOutputPrivate() - : latency(0) - { - } - - int latency; -}; - -} // namespace Experimental -} // namespace Phonon - -#endif // PHONON_VIDEODATAOUTPUT_P_H -// vim: sw=4 ts=4 tw=80 diff --git a/src/phonon/experimental/videodataoutputinterface.h b/src/phonon/experimental/videodataoutputinterface.h deleted file mode 100644 index 241121255..000000000 --- a/src/phonon/experimental/videodataoutputinterface.h +++ /dev/null @@ -1,47 +0,0 @@ -/* This file is part of the KDE project - Copyright (C) 2008 Matthias Kretz - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), Nokia Corporation - (or its successors, if any) and the KDE Free Qt Foundation, which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . - -*/ - -#ifndef PHONON_X_VIDEODATAOUTPUTINTERFACE_H -#define PHONON_X_VIDEODATAOUTPUTINTERFACE_H - -namespace Phonon -{ -namespace Experimental -{ - -class AbstractVideoDataOutput; - -class VideoDataOutputInterface -{ - public: - virtual ~VideoDataOutputInterface() {} - - virtual AbstractVideoDataOutput *frontendObject() const = 0; - virtual void setFrontendObject(AbstractVideoDataOutput *) = 0; -}; - -} // namespace Experimental -} // namespace Phonon - -Q_DECLARE_INTERFACE(Phonon::Experimental::VideoDataOutputInterface, "0VideoDataOutputInterface.phonon.kde.org") - -#endif // PHONON_X_VIDEODATAOUTPUTINTERFACE_H diff --git a/src/phonon/experimental/videoframe.h b/src/phonon/experimental/videoframe.h deleted file mode 100644 index e156684b4..000000000 --- a/src/phonon/experimental/videoframe.h +++ /dev/null @@ -1,73 +0,0 @@ -/* This file is part of the KDE project - Copyright (C) 2006 Matthias Kretz - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), Nokia Corporation - (or its successors, if any) and the KDE Free Qt Foundation, which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . - -*/ - -#ifndef PHONON_EXPERIMENTAL_VIDEOFRAME_H -#define PHONON_EXPERIMENTAL_VIDEOFRAME_H - -#include "export.h" -#include "videodataoutput.h" -#include - -namespace Phonon -{ -namespace Experimental -{ - /** - * \brief A single video frame. - * - * This simple class contains the data of a frame and metadata describing - * how to interpret the data. - * - * \author Matthias Kretz - */ - struct PHONONEXPERIMENTAL_EXPORT VideoFrame - { - enum Format { - Format_YUV422, - Format_YUV420, - Format_RGBA8 - //Format_RGBA8_Premultiplied, - //Format_RGBA16F, - //Format_RGBA32F, - //Colorspace_XVYCC - }; - //Qt::HANDLE handle() const; - - QByteArray data; - /** - * The width of the video frame in pixels. - */ - int width; - /** - * The height of the video frame in pixels. - */ - int height; - /** - * Colorspace of the frame - */ - Format colorspace; - }; -} // namespace Experimental -} // namespace Phonon - -// vim: sw=4 ts=4 tw=80 -#endif // PHONON_EXPERIMENTAL_VIDEOFRAME_H diff --git a/src/phonon/experimental/videoframe2.h b/src/phonon/experimental/videoframe2.h deleted file mode 100644 index ade8e3503..000000000 --- a/src/phonon/experimental/videoframe2.h +++ /dev/null @@ -1,161 +0,0 @@ -/* This file is part of the KDE project - Copyright (C) 2006,2008 Matthias Kretz - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), Nokia Corporation - (or its successors, if any) and the KDE Free Qt Foundation, which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . - -*/ - -#ifndef PHONON_EXPERIMENTAL_VIDEOFRAME2_H -#define PHONON_EXPERIMENTAL_VIDEOFRAME2_H - -#include "export.h" -#include "videodataoutput.h" -#include -#include - -namespace Phonon -{ -namespace Experimental -{ - /** - * \brief A single video frame. - * - * This simple class contains the data of a frame and metadata describing - * how to interpret the data. - * - * \author Matthias Kretz - */ - struct VideoFrame2 - { - /** - * Video frames come in a variety of formats. Depending on the format - * you have to process it differently to convert it for displaying or - * encoding. - */ - enum Format { - /** - * The frame is invalid. - */ - Format_Invalid = QImage::Format_Invalid, - /** - * The frame is stored in data0 using a 24-bit RGB format (8-8-8). - */ - Format_RGB888 = QImage::Format_RGB888, - Format_RGB32 = QImage::Format_RGB32, - /** - * The frame is stored in data0, data1 and data2 using data0 for the - * Y data, data1 for the Cb data and data2 for the Cr data. - * - * data1 and data2 contain one byte per for adjacent pixels whereas data0 - * has one byte per pixel. - */ - Format_YCbCr420 = 0x10000, - Format_YV12 = Format_YCbCr420, - /** - * The frame is stored in data0 using a 32-bit Y0-Cb-Y1-Cr format (8-8-8-8). - */ - Format_YCbCr422 = 0x10001, - Format_YUY2 = Format_YCbCr422 - }; - - /** - * The width of the video frame in number of pixels. - */ - int width; - - /** - * The height of the video frame in number of pixels. - */ - int height; - - /** - * The aspect ratio the frame should be displayed with. - * - * Common values are 4/3, 16/9. - */ - double aspectRatio; - - /** - * Convenience function to calculate the aspect corrected width from the - * aspectRatio and height values. - * - * It is recommended to display video frames with aspectCorrectedWidth x height - */ - inline int aspectCorrectedWidth() const { return qRound(aspectRatio * height); } - - /** - * Convenience function to calculate the aspect corrected height from the - * aspectRatio and width values. - * - * It is recommended to display video frames with aspectCorrectedWidth x height - */ - inline int aspectCorrectedHeight() const { return qRound(width / aspectRatio); } - - /** - * Format of the frame. - * - * \see Format - */ - Format format; - - /** - * RGB8, YUY2 or Y-plane - * - * If format is Format_RGB888 then the data contains each pixel as three - * consecutive bytes for red, green and blue. - * - * If format is Format_YUY2 the data contains every two pixels as four - * consecutive bytes for Y0, Cb, Y1, Cr - * - * If format is Format_YV12 the data contains one byte per pixel with - * the Y value. - */ - QByteArray data0; - - /** - * YV12 U-plane - * - * If format is Format_YV12 the data contains one byte per four adjacent - * pixels with the Cb value. - */ - QByteArray data1; - - /** - * YV12 V-plane - * - * If format is Format_YV12 the data contains one byte per four adjacent - * pixels with the Cr value. - */ - QByteArray data2; - - inline QImage qImage() const - { - if (format == Format_RGB888) { - return QImage(reinterpret_cast(data0.constData()), - width, height, QImage::Format_RGB888); - } - return QImage(); - } - }; -} // namespace Experimental -} // namespace Phonon - -Q_DECLARE_METATYPE(Phonon::Experimental::VideoFrame2) - -// vim: sw=4 ts=4 tw=80 -#endif // PHONON_EXPERIMENTAL_VIDEOFRAME2_H diff --git a/src/phonon/experimental/videowidget.cpp b/src/phonon/experimental/videowidget.cpp deleted file mode 100644 index d66f4ecc6..000000000 --- a/src/phonon/experimental/videowidget.cpp +++ /dev/null @@ -1,50 +0,0 @@ -/* This file is part of the KDE project - Copyright (C) 2008 Matthias Kretz - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), Nokia Corporation - (or its successors, if any) and the KDE Free Qt Foundation, which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . - -*/ - -#include "videowidget.h" -#include "videowidget_p.h" - -#include "snapshotinterface.h" - -namespace Phonon -{ -namespace Experimental -{ - -VideoWidget::VideoWidget(QWidget *w) - : Phonon::VideoWidget(w) -{ -} - -QImage VideoWidget::snapshot() const -{ - P_D(const Phonon::VideoWidget); - SnapshotInterface *iface = qobject_cast(d->m_backendObject); - if (iface) { - return iface->snapshot(); - } - return QImage(); -} - -} // namespace Experimental -} // namespace Phonon -#include "experimental/moc_videowidget.h" diff --git a/src/phonon/experimental/videowidget.h b/src/phonon/experimental/videowidget.h deleted file mode 100644 index 91a8c690d..000000000 --- a/src/phonon/experimental/videowidget.h +++ /dev/null @@ -1,46 +0,0 @@ -/* This file is part of the KDE project - Copyright (C) 2008 Matthias Kretz - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), Nokia Corporation - (or its successors, if any) and the KDE Free Qt Foundation, which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . - -*/ - -#ifndef PHONON_EXPERIMENTAL_VIDEOWIDGET_H -#define PHONON_EXPERIMENTAL_VIDEOWIDGET_H - -#include "../videowidget.h" -namespace Phonon -{ -namespace Experimental -{ - -class VideoWidgetPrivate; -class VideoWidget : public Phonon::VideoWidget -{ - P_DECLARE_PRIVATE(VideoWidget) - Q_OBJECT - public: - VideoWidget(QWidget *parent = 0); - - QImage snapshot() const; -}; - -} // namespace Experimental -} // namespace Phonon - -#endif // PHONON_EXPERIMENTAL_VIDEOWIDGET_H diff --git a/src/phonon/experimental/videowidget_p.h b/src/phonon/experimental/videowidget_p.h deleted file mode 100644 index 47da941b9..000000000 --- a/src/phonon/experimental/videowidget_p.h +++ /dev/null @@ -1,46 +0,0 @@ -/* This file is part of the KDE project - Copyright (C) 2008 Matthias Kretz - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), Nokia Corporation - (or its successors, if any) and the KDE Free Qt Foundation, which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . - -*/ -#ifndef PHONON_EXPERIMENTAL_VIDEOWIDGET_P_H -#define PHONON_EXPERIMENTAL_VIDEOWIDGET_P_H - -#include "videowidget.h" -#include "../videowidget_p.h" - -namespace Phonon -{ -namespace Experimental -{ - -class VideoWidgetPrivate : public Phonon::VideoWidgetPrivate -{ - P_DECLARE_PUBLIC(VideoWidget) - protected: - VideoWidgetPrivate(VideoWidget *parent) - : Phonon::VideoWidgetPrivate(parent) - { - } -}; - -} // namespace Experimental -} // namespace Phonon - -#endif // PHONON_EXPERIMENTAL_VIDEOWIDGET_P_H diff --git a/src/phonon/experimental/visualization.cpp b/src/phonon/experimental/visualization.cpp deleted file mode 100644 index f4ff131f7..000000000 --- a/src/phonon/experimental/visualization.cpp +++ /dev/null @@ -1,130 +0,0 @@ -/* This file is part of the KDE project - Copyright (C) 2006 Matthias Kretz - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), Nokia Corporation - (or its successors, if any) and the KDE Free Qt Foundation, which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . - -*/ - -#include "visualization.h" -#include "visualization_p.h" -#include "../objectdescription.h" -#include "../path.h" -#include "factory_p.h" - -#define PHONON_CLASSNAME Visualization - -namespace Phonon -{ -namespace Experimental -{ -PHONON_OBJECT_IMPL - -Visualization::~Visualization() -{ -} - -VisualizationDescription Visualization::visualization() const -{ - P_D(const Visualization); - if (!d->m_backendObject) { - return d->description; - } - int index; - BACKEND_GET(int, index, "visualization"); - return VisualizationDescription::fromIndex(index); -} - -void Visualization::setVisualization(const VisualizationDescription &newVisualization) -{ - P_D(Visualization); - d->description = newVisualization; - if (k_ptr->backendObject()) { - BACKEND_CALL1("setVisualization", int, newVisualization.index()); - } -} - -/* -bool Visualization::hasParameterWidget() const -{ - P_D(const Visualization); - if (d->m_backendObject) - { - bool ret; - BACKEND_GET(bool, ret, "hasParameterWidget"); - return ret; - } - return false; -} - -QWidget *Visualization::createParameterWidget(QWidget *parent) -{ - P_D(Visualization); - if (k_ptr->backendObject()) - { - QWidget *ret; - BACKEND_GET1(QWidget *, ret, "createParameterWidget", QWidget *, parent); - return ret; - } - return 0; -} -*/ - -void VisualizationPrivate::phononObjectDestroyed(MediaNodePrivate *bp) -{ - Q_UNUSED(bp); - // this method is called from Phonon::MediaNodePrivate::~MediaNodePrivate(), meaning the AudioEffect - // dtor has already been called and the private class is down to MediaNodePrivate - /* - Q_ASSERT(bp); - if (audioPath->k_ptr == bp) - { - pBACKEND_CALL1("setAudioPath", QObject *, static_cast(0)); - audioPath = 0; - } - else if (videoOutput->k_ptr == bp) - { - pBACKEND_CALL1("setVideoOutput", QObject *, static_cast(0)); - videoOutput = 0; - } - */ -} - -bool VisualizationPrivate::aboutToDeleteBackendObject() -{ - return true; -} - -void VisualizationPrivate::setupBackendObject() -{ - Q_ASSERT(m_backendObject); - - pBACKEND_CALL1("setVisualization", int, description.index()); - /* - if (audioPath) - pBACKEND_CALL1("setAudioPath", QObject *, audioPath->k_ptr->backendObject()); - if (videoOutput) - pBACKEND_CALL1("setVideoOutput", QObject *, videoOutput->k_ptr->backendObject()); - */ -} - -} // namespace Experimental -} // namespace Phonon - -#undef PHONON_CLASSNAME -// vim: sw=4 ts=4 -#include "experimental/moc_visualization.h" diff --git a/src/phonon/experimental/visualization.h b/src/phonon/experimental/visualization.h deleted file mode 100644 index b4f82d676..000000000 --- a/src/phonon/experimental/visualization.h +++ /dev/null @@ -1,107 +0,0 @@ -/* This file is part of the KDE project - Copyright (C) 2006-2007 Matthias Kretz - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), Nokia Corporation - (or its successors, if any) and the KDE Free Qt Foundation, which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . - -*/ - -#ifndef PHONON_VISUALIZATION_H -#define PHONON_VISUALIZATION_H - -#include "export.h" -#include "../phonondefs.h" -#include -#include "../objectdescription.h" -#include "../objectdescriptionmodel.h" -#include "../medianode.h" - -namespace Phonon -{ -class AudioPath; -class AbstractVideoOutput; - -namespace Experimental -{ - class VisualizationPrivate; - -enum { - VisualizationType = 0xfffffffe -}; -typedef ObjectDescription(VisualizationType)> VisualizationDescription; -typedef ObjectDescriptionModel(VisualizationType)> VisualizationDescriptionModel; - -/** - * \short A class to create visual effects from an audio signal. - * - * This class is used to define how an audio signal from an AudioPath object - * should be visualized. What visualization effects are available depends solely - * on the backend. You can list the available visualization effects using - * BackendCapabilities::availableVisualizationEffects(). - * - * The following example code takes the first effect from the list and uses that - * to display a visualization on a new VideoWidget. - * \code - * QList list = BackendCapabilities::availableVisualizationEffects(); - * if (list.size() > 0) - * { - * VideoWidget *visWidget = new VideoWidget(parent); - * Visualization *vis = new Visualization(visWidget); - * vis->setAudioPath(audioPath); - * vis->setVideoOutput(visWidget); - * vis->setVisualization(list.first()); - * } - * \endcode - * - * \author Matthias Kretz - * \see AudioDataOutput - * \see BackendCapabilities::availableVisualizationEffects() - */ -class PHONONEXPERIMENTAL_EXPORT Visualization : public QObject, public MediaNode -{ - Q_OBJECT - P_DECLARE_PRIVATE(Visualization) - PHONON_OBJECT(Visualization) - Q_PROPERTY(VisualizationDescription visualization READ visualization WRITE setVisualization) - - public: - ~Visualization(); - - VisualizationDescription visualization() const; - void setVisualization(const VisualizationDescription &newVisualization); - - /** - * Returns whether the selected visualization effect can be configured - * by the user with a widget returned by createParameterWidget(). In - * short it tells you whether createParameterWidget() will return 0 or - * not. - */ - //bool hasParameterWidget() const; - - /** - * Returns a widget that displays effect parameter controls to the user. - * - * \param parent The parent widget for the new widget. - */ - //QWidget *createParameterWidget(QWidget *parent = 0); -}; - -} // namespace Experimental -} // namespace Phonon - -#endif // PHONON_VISUALIZATION_H -// vim: sw=4 ts=4 tw=80 diff --git a/src/phonon/experimental/visualization_p.h b/src/phonon/experimental/visualization_p.h deleted file mode 100644 index f7ea53c75..000000000 --- a/src/phonon/experimental/visualization_p.h +++ /dev/null @@ -1,51 +0,0 @@ -/* This file is part of the KDE project - Copyright (C) 2006 Matthias Kretz - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), Nokia Corporation - (or its successors, if any) and the KDE Free Qt Foundation, which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . - -*/ - -#ifndef PHONON_VISUALIZATION_P_H -#define PHONON_VISUALIZATION_P_H - -#include "visualization.h" -#include "../medianode_p.h" -#include "../medianodedestructionhandler_p.h" -#include "../phonondefs_p.h" - -namespace Phonon -{ -namespace Experimental -{ -class VisualizationPrivate : public MediaNodePrivate, private MediaNodeDestructionHandler -{ - P_DECLARE_PUBLIC(Visualization) - PHONON_PRIVATECLASS - public: - virtual QObject *qObject() { return q_func(); } - protected: - VisualizationDescription description; - - private: - void phononObjectDestroyed(MediaNodePrivate *); -}; -} // namespace Experimental -} // namespace Phonon - -#endif // PHONON_VISUALIZATION_P_H -// vim: sw=4 ts=4 tw=80 diff --git a/src/phonon/factory.cpp b/src/phonon/factory.cpp deleted file mode 100644 index 7d8549d3b..000000000 --- a/src/phonon/factory.cpp +++ /dev/null @@ -1,505 +0,0 @@ -/* - Copyright (C) 2004-2007 Matthias Kretz - Copyright (C) 2011 Harald Sitter - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), Nokia Corporation - (or its successors, if any) and the KDE Free Qt Foundation, which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . -*/ - -#include "factory_p.h" - -#include "backendinterface.h" -#include "medianode_p.h" -#include "mediaobject.h" -#include "audiooutput.h" -#include "globalstatic_p.h" -#include "objectdescription.h" -#include "platformplugin.h" -#include "phononconfig_p.h" -#include "phononnamespace_p.h" - -#include -#include -#include -#include -#include -#include -#ifndef PHONON_NO_DBUS -#include -#endif -#include -#include -#include - -namespace Phonon -{ - -class PlatformPlugin; -class FactoryPrivate : public Phonon::Factory::Sender -{ - friend QObject *Factory::backend(bool); - Q_OBJECT - public: - FactoryPrivate(); - ~FactoryPrivate(); - bool tryCreateBackend(const QString &path); - // Implementation depends on Qt version. - bool createSuitableBackend(const QString &libPath, const QList &plugins); - bool createBackend(); -#ifndef QT_NO_PHONON_PLATFORMPLUGIN - PlatformPlugin *platformPlugin(); - - PlatformPlugin *m_platformPlugin; - bool m_noPlatformPlugin; -#endif //QT_NO_PHONON_PLATFORMPLUGIN - QPointer m_backendObject; - - QList objects; - QList mediaNodePrivateList; - - private Q_SLOTS: - /** - * This is called via DBUS when the user changes the Phonon Backend. - */ -#ifndef PHONON_NO_DBUS - void phononBackendChanged(); -#endif //PHONON_NO_DBUS - - /** - * unregisters the backend object - */ - void objectDestroyed(QObject *); - - void objectDescriptionChanged(ObjectDescriptionType); -}; - -PHONON_GLOBAL_STATIC(Phonon::FactoryPrivate, globalFactory) - -static inline void ensureLibraryPathSet() -{ -#ifdef PHONON_LIBRARY_PATH - static bool done = false; - if (!done) { - done = true; - QCoreApplication::addLibraryPath(QLatin1String(PHONON_LIBRARY_PATH)); - } -#endif // PHONON_LIBRARY_PATH -} - -void Factory::setBackend(QObject *b) -{ - Q_ASSERT(globalFactory->m_backendObject == 0); - globalFactory->m_backendObject = b; -} - -bool FactoryPrivate::tryCreateBackend(const QString &path) -{ - QPluginLoader pluginLoader(path); - - pDebug() << "attempting to load" << path; - if (!pluginLoader.load()) { - pDebug() << Q_FUNC_INFO << " load failed:" << pluginLoader.errorString(); - return false; - } - pDebug() << pluginLoader.instance(); - m_backendObject = pluginLoader.instance(); - if (m_backendObject) { - return true; - } - - // no backend found, don't leave an unused plugin in memory - pluginLoader.unload(); - return false; -} - -bool FactoryPrivate::createSuitableBackend(const QString &libPath, const QList &plugins) -{ - foreach (const QString &plugin, plugins) { - if (tryCreateBackend(libPath + plugin)) - return true; - } - return false; -} - -// This entire function is so terrible to read I hope it implodes some day. -bool FactoryPrivate::createBackend() -{ - pDebug() << Q_FUNC_INFO << "Phonon" << PHONON_VERSION_STR << "trying to create backend..."; -#ifndef QT_NO_LIBRARY - Q_ASSERT(m_backendObject == 0); - - // If the user defines a backend with PHONON_BACKEND this overrides the - // platform plugin (because we cannot influence its lookup priority) and - // consequently will try to find/load the defined backend manually. - const QByteArray backendEnv = qgetenv("PHONON_BACKEND"); - -#ifndef QT_NO_PHONON_PLATFORMPLUGIN - PlatformPlugin *f = globalFactory->platformPlugin(); - if (f && backendEnv.isEmpty()) { - // TODO: it would be very groovy if we could add a param, so that the - // platform could also try to load the defined backend as preferred choice. - m_backendObject = f->createBackend(); - } -#endif //QT_NO_PHONON_PLATFORMPLUGIN - if (!m_backendObject) { - ensureLibraryPathSet(); - - // could not load a backend through the platform plugin. Falling back to the default - // (finding the first loadable backend). - const QStringList paths = QCoreApplication::libraryPaths(); - for (int i = 0; i < paths.count(); ++i) { -#ifndef PHONON_BACKEND_DIR_SUFFIX -#ifdef __GNUC__ -#error PHONON_BACKEND_DIR_SUFFIX must be defined. -#endif -#endif - const QString libPath = paths.at(i) + PHONON_BACKEND_DIR_SUFFIX; - const QDir dir(libPath); - if (!dir.exists()) { - pDebug() << Q_FUNC_INFO << dir.absolutePath() << "does not exist"; - continue; - } - - QStringList plugins(dir.entryList(QDir::Files)); - - if (!backendEnv.isEmpty()) { - pDebug() << "trying to load:" << backendEnv << "as first choice"; - const int backendIndex = plugins.indexOf(QRegExp(backendEnv + ".*")); - if (backendIndex != -1) - plugins.move(backendIndex, 0); - } - - // This function implements a very simple trial-and-error loader for - // Qt 4 and on top of that a preference system for Qt 5. Therefore - // in Qt 5 we have backend preference independent of a platform - // plugin. - createSuitableBackend(libPath, plugins); - - if (m_backendObject) { - break; - } - } - if (!m_backendObject) { - pWarning() << Q_FUNC_INFO << "phonon backend plugin could not be loaded"; - return false; - } - } - - pDebug() << Q_FUNC_INFO - << "Phonon backend" - << m_backendObject->property("backendName").toString() - << "version" - << m_backendObject->property("backendVersion").toString() - << "loaded"; - - connect(m_backendObject, SIGNAL(objectDescriptionChanged(ObjectDescriptionType)), - SLOT(objectDescriptionChanged(ObjectDescriptionType))); - - return true; -#else //QT_NO_LIBRARY - pWarning() << Q_FUNC_INFO << "Trying to use Phonon with QT_NO_LIBRARY defined. " - "That is currently not supported"; - return false; -#endif -} - -FactoryPrivate::FactoryPrivate() - : -#ifndef QT_NO_PHONON_PLATFORMPLUGIN - m_platformPlugin(0), - m_noPlatformPlugin(false), -#endif //QT_NO_PHONON_PLATFORMPLUGIN - m_backendObject(0) -{ - // Add the post routine to make sure that all other global statics (especially the ones from Qt) - // are still available. If the FactoryPrivate dtor is called too late many bad things can happen - // as the whole backend might still be alive. - qAddPostRoutine(globalFactory.destroy); -#ifndef PHONON_NO_DBUS - QDBusConnection::sessionBus().connect(QString(), QString(), QLatin1String("org.kde.Phonon.Factory"), - QLatin1String("phononBackendChanged"), this, SLOT(phononBackendChanged())); -#endif -} - -FactoryPrivate::~FactoryPrivate() -{ - for (int i = 0; i < mediaNodePrivateList.count(); ++i) { - mediaNodePrivateList.at(i)->deleteBackendObject(); - } - if (objects.size() > 0) { - pError() << "The backend objects are not deleted as was requested."; - qDeleteAll(objects); - } - delete m_backendObject; -#ifndef QT_NO_PHONON_PLATFORMPLUGIN - delete m_platformPlugin; -#endif //QT_NO_PHONON_PLATFORMPLUGIN -} - -void FactoryPrivate::objectDescriptionChanged(ObjectDescriptionType type) -{ -#ifdef PHONON_METHODTEST - Q_UNUSED(type); -#else - pDebug() << Q_FUNC_INFO << type; - switch (type) { - case AudioOutputDeviceType: - emit availableAudioOutputDevicesChanged(); - break; - case AudioCaptureDeviceType: - emit availableAudioCaptureDevicesChanged(); - break; - case VideoCaptureDeviceType: - emit availableVideoCaptureDevicesChanged(); - break; - default: - break; - } - //emit capabilitiesChanged(); -#endif // PHONON_METHODTEST -} - -Factory::Sender *Factory::sender() -{ - return globalFactory; -} - -bool Factory::isMimeTypeAvailable(const QString &mimeType) -{ -#ifndef QT_NO_PHONON_PLATFORMPLUGIN - PlatformPlugin *f = globalFactory->platformPlugin(); - if (f) { - return f->isMimeTypeAvailable(mimeType); - } -#else - Q_UNUSED(mimeType); -#endif //QT_NO_PHONON_PLATFORMPLUGIN - return true; // the MIME type might be supported, let BackendCapabilities find out -} - -void Factory::registerFrontendObject(MediaNodePrivate *bp) -{ - globalFactory->mediaNodePrivateList.prepend(bp); // inserted last => deleted first -} - -void Factory::deregisterFrontendObject(MediaNodePrivate *bp) -{ - // The Factory can already be cleaned up while there are other frontend objects still alive. - // When those are deleted they'll call deregisterFrontendObject through ~BasePrivate - if (!globalFactory.isDestroyed()) { - globalFactory->mediaNodePrivateList.removeAll(bp); - } -} - -#ifndef PHONON_NO_DBUS -void FactoryPrivate::phononBackendChanged() -{ - QMessageBox::information(qApp->activeWindow(), - tr("Restart Application"), - tr("You changed the backend of the Phonon multimedia system.\n\n" - "To apply this change you will need to" - " restart '%1'.").arg(qAppName())); - emit backendChanged(); -} -#endif //PHONON_NO_DBUS - -//X void Factory::freeSoundcardDevices() -//X { -//X if (globalFactory->backend) { -//X globalFactory->backend->freeSoundcardDevices(); -//X } -//X } - -void FactoryPrivate::objectDestroyed(QObject * obj) -{ - //pDebug() << Q_FUNC_INFO << obj; - objects.removeAll(obj); -} - -#define FACTORY_IMPL(classname) \ -QObject *Factory::create ## classname(QObject *parent) \ -{ \ - if (backend()) { \ - return registerQObject(qobject_cast(backend())->createObject(BackendInterface::classname##Class, parent)); \ - } \ - return 0; \ -} -#define FACTORY_IMPL_1ARG(classname) \ -QObject *Factory::create ## classname(int arg1, QObject *parent) \ -{ \ - if (backend()) { \ - return registerQObject(qobject_cast(backend())->createObject(BackendInterface::classname##Class, parent, QList() << arg1)); \ - } \ - return 0; \ -} - -FACTORY_IMPL(MediaObject) -#ifndef QT_NO_PHONON_EFFECT -FACTORY_IMPL_1ARG(Effect) -#endif //QT_NO_PHONON_EFFECT -#ifndef QT_NO_PHONON_VOLUMEFADEREFFECT -FACTORY_IMPL(VolumeFaderEffect) -#endif //QT_NO_PHONON_VOLUMEFADEREFFECT -FACTORY_IMPL(AudioOutput) -#ifndef QT_NO_PHONON_VIDEO -FACTORY_IMPL(VideoWidget) -FACTORY_IMPL(VideoGraphicsObject) -#endif //QT_NO_PHONON_VIDEO -FACTORY_IMPL(AudioDataOutput) - -#undef FACTORY_IMPL - -#ifndef QT_NO_PHONON_PLATFORMPLUGIN -PlatformPlugin *FactoryPrivate::platformPlugin() -{ - if (m_platformPlugin) { - return m_platformPlugin; - } - if (m_noPlatformPlugin) { - return 0; - } -#ifndef PHONON_NO_DBUS - if (!QCoreApplication::instance() || QCoreApplication::applicationName().isEmpty()) { - pWarning() << "Phonon needs QCoreApplication::applicationName to be set to export audio output names through the DBUS interface"; - } -#endif - Q_ASSERT(QCoreApplication::instance()); - const QByteArray platform_plugin_env = qgetenv("PHONON_PLATFORMPLUGIN"); - if (!platform_plugin_env.isEmpty()) { - pDebug() << Q_FUNC_INFO << "platform plugin path:" << platform_plugin_env; - QPluginLoader pluginLoader(QString::fromLocal8Bit(platform_plugin_env.constData())); - if (pluginLoader.load()) { - QObject *plInstance = pluginLoader.instance(); - if (!plInstance) { - pDebug() << Q_FUNC_INFO << "unable to grab root component object for the platform plugin"; - } - - m_platformPlugin = qobject_cast(plInstance); - if (m_platformPlugin) { - pDebug() << Q_FUNC_INFO << "platform plugin" << m_platformPlugin->applicationName(); - return m_platformPlugin; - } else { - pDebug() << Q_FUNC_INFO << "platform plugin cast fail" << plInstance; - } - } - } - const QString suffix(QLatin1String("/phonon_platform/")); - ensureLibraryPathSet(); - QDir dir; - dir.setNameFilters( - !qgetenv("KDE_FULL_SESSION").isEmpty() ? QStringList(QLatin1String("kde.*")) : - (!qgetenv("GNOME_DESKTOP_SESSION_ID").isEmpty() ? QStringList(QLatin1String("gnome.*")) : - QStringList()) - ); - dir.setFilter(QDir::Files); - const QStringList libPaths = QCoreApplication::libraryPaths(); - forever { - for (int i = 0; i < libPaths.count(); ++i) { - const QString libPath = libPaths.at(i) + suffix; - dir.setPath(libPath); - if (!dir.exists()) { - continue; - } - const QStringList files = dir.entryList(QDir::Files); - for (int i = 0; i < files.count(); ++i) { - pDebug() << "attempting to load" << libPath + files.at(i); - QPluginLoader pluginLoader(libPath + files.at(i)); - if (!pluginLoader.load()) { - pDebug() << Q_FUNC_INFO << " platform plugin load failed:" - << pluginLoader.errorString(); - continue; - } - pDebug() << pluginLoader.instance(); - QObject *qobj = pluginLoader.instance(); - m_platformPlugin = qobject_cast(qobj); - pDebug() << m_platformPlugin; - if (m_platformPlugin) { - connect(qobj, SIGNAL(objectDescriptionChanged(ObjectDescriptionType)), - SLOT(objectDescriptionChanged(ObjectDescriptionType))); - return m_platformPlugin; - } else { - delete qobj; - pDebug() << Q_FUNC_INFO << dir.absolutePath() << "exists but the platform plugin was not loadable:" << pluginLoader.errorString(); - pluginLoader.unload(); - } - } - } - if (dir.nameFilters().isEmpty()) { - break; - } - dir.setNameFilters(QStringList()); - } - pDebug() << Q_FUNC_INFO << "platform plugin could not be loaded"; - m_noPlatformPlugin = true; - return 0; -} - -PlatformPlugin *Factory::platformPlugin() -{ - return globalFactory->platformPlugin(); -} -#endif // QT_NO_PHONON_PLATFORMPLUGIN - -QObject *Factory::backend(bool createWhenNull) -{ - if (globalFactory.isDestroyed()) { - return 0; - } - if (createWhenNull && globalFactory->m_backendObject == 0) { - globalFactory->createBackend(); - // XXX: might create "reentrancy" problems: - // a method calls this method and is called again because the - // backendChanged signal is emitted - if (globalFactory->m_backendObject) { - emit globalFactory->backendChanged(); - } - } - return globalFactory->m_backendObject; -} - -#ifndef QT_NO_PROPERTIES -#define GET_STRING_PROPERTY(name) \ -QString Factory::name() \ -{ \ - if (globalFactory->m_backendObject) { \ - return globalFactory->m_backendObject->property(#name).toString(); \ - } \ - return QString(); \ -} \ - -GET_STRING_PROPERTY(identifier) -GET_STRING_PROPERTY(backendName) -GET_STRING_PROPERTY(backendComment) -GET_STRING_PROPERTY(backendVersion) -GET_STRING_PROPERTY(backendIcon) -GET_STRING_PROPERTY(backendWebsite) -#endif //QT_NO_PROPERTIES -QObject *Factory::registerQObject(QObject *o) -{ - if (o) { - QObject::connect(o, SIGNAL(destroyed(QObject*)), globalFactory, SLOT(objectDestroyed(QObject*)), Qt::DirectConnection); - globalFactory->objects.append(o); - } - return o; -} - -} //namespace Phonon - -#include "moc_factory.cpp" -#include "moc_factory_p.h" - -// vim: sw=4 ts=4 diff --git a/src/phonon/factory_p.h b/src/phonon/factory_p.h deleted file mode 100644 index 970a5c818..000000000 --- a/src/phonon/factory_p.h +++ /dev/null @@ -1,205 +0,0 @@ -/* This file is part of the KDE project - Copyright (C) 2004-2007 Matthias Kretz - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), Nokia Corporation - (or its successors, if any) and the KDE Free Qt Foundation, which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . - -*/ - -#ifndef PHONON_FACTORY_P_H -#define PHONON_FACTORY_P_H - -#include "phonon_export.h" - -#include -#include - - -class QUrl; -class QIcon; - -namespace Phonon -{ - class PlatformPlugin; - class MediaNodePrivate; - class AbstractMediaStream; - -/** - * \internal - * \brief Factory to access the preferred Backend. - * - * This class is used internally to get the backend's implementation. - * It keeps track of the objects that were created. When a - * request for a backend change comes, it asks all frontend objects to delete - * their backend objects and then checks whether they were all deleted. Only - * then the old backend is unloaded and the new backend is loaded. - * - * \author Matthias Kretz - */ -namespace Factory -{ - /** - * Emits signals for Phonon::Factory. - */ - class Sender : public QObject - { - Q_OBJECT - Q_SIGNALS: - /** - * Emitted after the backend has successfully been changed. - */ - void backendChanged(); - - /** - * \copydoc BackendCapabilities::Notifier::availableAudioOutputDevicesChanged - */ - void availableAudioOutputDevicesChanged(); - - /** - * \copydoc BackendCapabilities::Notifier::availableAudioCaptureDevicesChanged - */ - void availableAudioCaptureDevicesChanged(); - - /** - * \copydoc BackendCapabilities::Notifier::availableVideoCaptureDevicesChanged - */ - void availableVideoCaptureDevicesChanged(); - }; - - /** - * Returns a pointer to the object emitting the signals. - * - * \see Sender::backendChanged() - */ - PHONON_EXPORT Sender *sender(); - - /** - * Create a new backend object for a MediaObject. - * - * \return a pointer to the MediaObject the backend provides. - */ - QObject *createMediaObject(QObject *parent = 0); - /** - * Create a new backend object for a Effect. - * - * \return a pointer to the Effect the backend provides. - */ -#ifndef QT_NO_PHONON_EFFECT - QObject *createEffect(int effectId, QObject *parent = 0); -#endif //QT_NO_PHONON_EFFECT - /** - * Create a new backend object for a VolumeFaderEffect. - * - * \return a pointer to the VolumeFaderEffect the backend provides. - */ -#ifndef QT_NO_PHONON_VOLUMEFADEREFFECT - QObject *createVolumeFaderEffect(QObject *parent = 0); -#endif //QT_NO_PHONON_VOLUMEFADEREFFECT - /** - * Create a new backend object for a AudioOutput. - * - * \return a pointer to the AudioOutput the backend provides. - */ - QObject *createAudioOutput(QObject *parent = 0); - /** - * Create a new backend object for a VideoWidget. - * - * \return a pointer to the VideoWidget the backend provides. - */ -#ifndef QT_NO_PHONON_VIDEO - QObject *createVideoWidget(QObject *parent = 0); - QObject *createVideoGraphicsObject(QObject *parent = 0); -#endif //QT_NO_PHONON_VIDEO - - /** - * Create a new backend object for a AudioDataOutput. - * - * \return a pointer to the AudioDataOutput the backend provides. - */ - PHONON_EXPORT QObject *createAudioDataOutput(QObject *parent = 0); - - /** - * \return a pointer to the backend interface. - */ - PHONON_EXPORT QObject *backend(bool createWhenNull = true); - - /** - * Unique identifier for the Backend. Can be used in configuration files - * for example. - */ - QString identifier(); - - /** - * Get the name of the Backend. It's the name from the .desktop file. - */ - PHONON_EXPORT QString backendName(); - - /** - * Get the comment of the Backend. It's the comment from the .desktop file. - */ - QString backendComment(); - - /** - * Get the version of the Backend. It's the version from the .desktop file. - * - * The version is especially interesting if there are several versions - * available for binary incompatible versions of the backend's media - * framework. - */ - QString backendVersion(); - - /** - * Get the icon (name) of the Backend. It's the icon from the .desktop file. - */ - QString backendIcon(); - - /** - * Get the website of the Backend. It's the website from the .desktop file. - */ - QString backendWebsite(); - - /** - * registers the backend object - */ - PHONON_EXPORT QObject *registerQObject(QObject *o); - - bool isMimeTypeAvailable(const QString &mimeType); - - PHONON_EXPORT void registerFrontendObject(MediaNodePrivate *); - PHONON_EXPORT void deregisterFrontendObject(MediaNodePrivate *); - - PHONON_EXPORT void setBackend(QObject *); - //PHONON_EXPORT void createBackend(const QString &library, const QString &version = QString()); - - PHONON_EXPORT PlatformPlugin *platformPlugin(); - -//X It is probably better if we can get away with internal handling of -//X freeing the soundcard device when it's not needed anymore and -//X providing an IPC method to stop all MediaObjects -> free all -//X devices -//X /** -//X * \internal -//X * This is called when the application needs to free the soundcard -//X * device(s). -//X */ -//X void freeSoundcardDevices(); -} // namespace Factory -} // namespace Phonon - - -#endif // PHONON_FACTORY_P_H -// vim: sw=4 ts=4 diff --git a/src/phonon/frontendinterface_p.h b/src/phonon/frontendinterface_p.h deleted file mode 100644 index d1fe7b10c..000000000 --- a/src/phonon/frontendinterface_p.h +++ /dev/null @@ -1,64 +0,0 @@ -/* This file is part of the KDE project - Copyright (C) 2007 Matthias Kretz - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), Nokia Corporation - (or its successors, if any) and the KDE Free Qt Foundation, which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . - -*/ - -#ifndef PHONON_FRONTENDINTERFACEPRIVATE_H -#define PHONON_FRONTENDINTERFACEPRIVATE_H - -#include "addoninterface.h" -#include "mediaobject_p.h" -#include "phononnamespace_p.h" -#include - -#ifndef QT_NO_PHONON_MEDIACONTROLLER - -namespace Phonon -{ -class FrontendInterfacePrivate -{ - public: - FrontendInterfacePrivate(MediaObject *mp) : media(mp) { - Q_ASSERT(media); - MediaObjectPrivate *d = media->k_func(); - d->interfaceList << this; - } - virtual ~FrontendInterfacePrivate() { - if (media) { - MediaObjectPrivate *d = media->k_func(); - d->interfaceList << this; - } - } - virtual void backendObjectChanged(QObject *iface) = 0; - void _backendObjectChanged() { - pDebug() << Q_FUNC_INFO; - QObject *x = media->k_ptr->backendObject(); - if (x) { - backendObjectChanged(x); - } - } - AddonInterface *iface() { return qobject_cast(media->k_ptr->backendObject()); } - QPointer media; -}; -} // namespace Phonon - -#endif //QT_NO_PHONON_MEDIACONTROLLER - -#endif // PHONON_FRONTENDINTERFACEPRIVATE_H diff --git a/src/phonon/globalconfig.cpp b/src/phonon/globalconfig.cpp deleted file mode 100644 index 053300770..000000000 --- a/src/phonon/globalconfig.cpp +++ /dev/null @@ -1,711 +0,0 @@ -/* This file is part of the KDE project - Copyright (C) 2006-2008 Matthias Kretz - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), Nokia Corporation - (or its successors, if any) and the KDE Free Qt Foundation, which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . - -*/ - -#include "globalconfig.h" -#include "globalconfig_p.h" - -#include "factory_p.h" -#include "phonondefs_p.h" -#include "platformplugin.h" -#include "backendinterface.h" -#include "qsettingsgroup_p.h" -#include "phononnamespace_p.h" -#include "phononnamespace.h" - -#include -#include - -namespace Phonon -{ - -GlobalConfigPrivate::GlobalConfigPrivate() : config(QLatin1String("kde.org"), QLatin1String("libphonon")) -{ -} - -GlobalConfig::GlobalConfig() - : k_ptr(new GlobalConfigPrivate) -{ -} - -GlobalConfig::~GlobalConfig() -{ - delete k_ptr; -} - -enum WhatToFilter { - FilterAdvancedDevices = 1, - FilterHardwareDevices = 2, - FilterUnavailableDevices = 4 -}; - -static void filter(ObjectDescriptionType type, BackendInterface *backendIface, QList *list, int whatToFilter) -{ - QMutableListIterator it(*list); - while (it.hasNext()) { - QHash properties; - if (backendIface) - properties = backendIface->objectDescriptionProperties(type, it.next()); - QVariant var; - if (whatToFilter & FilterAdvancedDevices) { - var = properties.value("isAdvanced"); - if (var.isValid() && var.toBool()) { - it.remove(); - continue; - } - } - if (whatToFilter & FilterHardwareDevices) { - var = properties.value("isHardwareDevice"); - if (var.isValid() && var.toBool()) { - it.remove(); - continue; - } - } - if (whatToFilter & FilterUnavailableDevices) { - var = properties.value("available"); - if (var.isValid() && !var.toBool()) { - it.remove(); - continue; - } - } - } -} - -#ifndef QT_NO_PHONON_SETTINGSGROUP -static QList sortDevicesByCategoryPriority(const GlobalConfig *config, const QSettingsGroup *backendConfig, ObjectDescriptionType type, Category category, QList &defaultList) -{ - Q_ASSERT(config); Q_UNUSED(config); - Q_ASSERT(backendConfig); - Q_ASSERT(type == AudioOutputDeviceType); - - if (defaultList.size() <= 1) { - // nothing to sort - return defaultList; - } else { - // make entries unique - QSet seen; - QMutableListIterator it(defaultList); - while (it.hasNext()) { - if (seen.contains(it.next())) { - it.remove(); - } else { - seen.insert(it.value()); - } - } - } - - QList deviceList; - QString categoryKey = QLatin1String("Category_") + QString::number(static_cast(category)); - if (!backendConfig->hasKey(categoryKey)) { - // no list in config for the given category - categoryKey = QLatin1String("Category_") + QString::number(static_cast(NoCategory)); - if (!backendConfig->hasKey(categoryKey)) { - // no list in config for NoCategory - return defaultList; - } - } - - //Now the list from d->config - deviceList = backendConfig->value(categoryKey, QList()); - - //if there are devices in d->config that the backend doesn't report, remove them from the list - QMutableListIterator i(deviceList); - while (i.hasNext()) { - if (0 == defaultList.removeAll(i.next())) { - i.remove(); - } - } - - //if the backend reports more devices that are not in d->config append them to the list - deviceList += defaultList; - - return deviceList; -} - -static QList sortDevicesByCategoryPriority(const GlobalConfig *config, const QSettingsGroup *backendConfig, ObjectDescriptionType type, CaptureCategory category, QList &defaultList) -{ - Q_ASSERT(config); Q_UNUSED(config); - Q_ASSERT(backendConfig); - Q_ASSERT(type == AudioCaptureDeviceType || type == VideoCaptureDeviceType); - - if (defaultList.size() <= 1) { - // nothing to sort - return defaultList; - } else { - // make entries unique - QSet seen; - QMutableListIterator it(defaultList); - while (it.hasNext()) { - if (seen.contains(it.next())) { - it.remove(); - } else { - seen.insert(it.value()); - } - } - } - - QList deviceList; - QString categoryKey = QLatin1String("Category_") + QString::number(static_cast(category)); - if (!backendConfig->hasKey(categoryKey)) { - // no list in config for the given category - categoryKey = QLatin1String("Category_") + QString::number(static_cast(NoCategory)); - if (!backendConfig->hasKey(categoryKey)) { - // no list in config for NoCategory - return defaultList; - } - } - - //Now the list from d->config - deviceList = backendConfig->value(categoryKey, QList()); - - //if there are devices in d->config that the backend doesn't report, remove them from the list - QMutableListIterator i(deviceList); - while (i.hasNext()) { - if (0 == defaultList.removeAll(i.next())) { - i.remove(); - } - } - - //if the backend reports more devices that are not in d->config append them to the list - deviceList += defaultList; - - return deviceList; -} - -bool GlobalConfig::hideAdvancedDevices() const -{ - P_D(const GlobalConfig); - //The devices need to be stored independently for every backend - const QSettingsGroup generalGroup(&d->config, QLatin1String("General")); - return generalGroup.value(QLatin1String("HideAdvancedDevices"), true); -} - -void GlobalConfig::setHideAdvancedDevices(bool hide) -{ - P_D(GlobalConfig); - QSettingsGroup generalGroup(&d->config, QLatin1String("General")); - generalGroup.setValue(QLatin1String("HideAdvancedDevices"), hide); -} -#endif // QT_NO_PHONON_SETTINGSGROUP - -static bool isHiddenAudioOutputDevice(const GlobalConfig *config, int i) -{ - Q_ASSERT(config); - -#ifndef QT_NO_PHONON_SETTINGSGROUP - if (!config->hideAdvancedDevices()) - return false; -#endif // QT_NO_PHONON_SETTINGSGROUP - - AudioOutputDevice ad = AudioOutputDevice::fromIndex(i); - const QVariant var = ad.property("isAdvanced"); - return (var.isValid() && var.toBool()); -} - -#ifndef PHONON_NO_AUDIOCAPTURE -static bool isHiddenAudioCaptureDevice(const GlobalConfig *config, int i) -{ - Q_ASSERT(config); - -#ifndef QT_NO_PHONON_SETTINGSGROUP - if (!config->hideAdvancedDevices()) - return false; -#endif // QT_NO_PHONON_SETTINGSGROUP - - AudioCaptureDevice ad = AudioCaptureDevice::fromIndex(i); - const QVariant var = ad.property("isAdvanced"); - return (var.isValid() && var.toBool()); -} -#endif - -#ifndef PHONON_NO_VIDEOCAPTURE -static bool isHiddenVideoCaptureDevice(const GlobalConfig *config, int i) -{ - Q_ASSERT(config); - -#ifndef QT_NO_PHONON_SETTINGSGROUP - if (!config->hideAdvancedDevices()) - return false; -#endif // QT_NO_PHONON_SETTINGSGROUP - - VideoCaptureDevice vd = VideoCaptureDevice::fromIndex(i); - const QVariant var = vd.property("isAdvanced"); - return (var.isValid() && var.toBool()); -} -#endif - -static QList reindexList(const GlobalConfig *config, ObjectDescriptionType type, Category category, QListnewOrder) -{ - Q_ASSERT(config); - Q_ASSERT(type == AudioOutputDeviceType); - Q_UNUSED(type); - - /*QString sb; - sb = QString("(Size %1)").arg(currentList.size()); - foreach (int i, currentList) - sb += QString("%1, ").arg(i); - fprintf(stderr, "=== Reindex Current: %s\n", sb.toUtf8().constData()); - sb = QString("(Size %1)").arg(newOrder.size()); - foreach (int i, newOrder) - sb += QString("%1, ").arg(i); - fprintf(stderr, "=== Reindex Before : %s\n", sb.toUtf8().constData());*/ - - int override = GlobalConfig::ShowUnavailableDevices | GlobalConfig::ShowAdvancedDevices; - QList currentList = config->audioOutputDeviceListFor(category, override); - - - QList newList; - - foreach (int i, newOrder) { - int found = currentList.indexOf(i); - if (found < 0) { - // It's not in the list, so something is odd (e.g. client error). Ignore it. - continue; - } - - // Iterate through the list from this point onward. If there are hidden devices - // immediately following, take them too. - newList.append(currentList.takeAt(found)); - - while (found < currentList.size()) { - bool hidden = isHiddenAudioOutputDevice(config, currentList.at(found)); - if (!hidden) - break; - - newList.append(currentList.takeAt(found)); - } - } - - // If there are any devices left in.. just tack them on the end. - if (currentList.size() > 0) - newList += currentList; - - /*sb = QString("(Size %1)").arg(newList.size()); - foreach (int i, newList) - sb += QString("%1, ").arg(i); - fprintf(stderr, "=== Reindex After : %s\n", sb.toUtf8().constData());*/ - return newList; -} - -static QList reindexList(const GlobalConfig *config, ObjectDescriptionType type, CaptureCategory category, QListnewOrder) -{ - Q_ASSERT(config); - Q_ASSERT(type == AudioCaptureDeviceType || type == VideoCaptureDeviceType); - - QList currentList; - int override = GlobalConfig::ShowUnavailableDevices | GlobalConfig::ShowAdvancedDevices; - - switch (type) { -#ifndef PHONON_NO_AUDIOCAPTURE - case AudioCaptureDeviceType: - currentList = config->audioCaptureDeviceListFor(category, override); - break; -#endif - -#ifndef PHONON_NO_VIDEOCAPTURE - case VideoCaptureDeviceType: - currentList = config->videoCaptureDeviceListFor(category, override); - break; -#endif - - default: ; - } - - QList newList; - - foreach (int i, newOrder) { - int found = currentList.indexOf(i); - if (found < 0) { - // It's not in the list, so something is odd (e.g. client error). Ignore it. - continue; - } - - // Iterate through the list from this point onward. If there are hidden devices - // immediately following, take them too. - newList.append(currentList.takeAt(found)); - - while (found < currentList.size()) { - bool hidden = true; - - switch (type) { -#ifndef PHONON_NO_AUDIOCAPTURE - case AudioCaptureDeviceType: - hidden = isHiddenAudioCaptureDevice(config, currentList.at(found)); - break; -#endif - -#ifndef PHONON_NO_VIDEOCAPTURE - case VideoCaptureDeviceType: - hidden = isHiddenVideoCaptureDevice(config, currentList.at(found)); - break; -#endif - - default: ; - } - - if (!hidden) - break; - - newList.append(currentList.takeAt(found)); - } - } - - // If there are any devices left in.. just tack them on the end. - if (currentList.size() > 0) - newList += currentList; - - return newList; -} - -void GlobalConfig::setAudioOutputDeviceListFor(Category category, QList order) -{ -#ifndef QT_NO_PHONON_SETTINGSGROUP - P_D(GlobalConfig); - QSettingsGroup backendConfig(&d->config, QLatin1String("AudioOutputDevice")); // + Factory::identifier()); - - order = reindexList(this, AudioOutputDeviceType, category, order); - - const QList noCategoryOrder = audioOutputDeviceListFor(NoCategory, ShowUnavailableDevices|ShowAdvancedDevices); - if (category != NoCategory && order == noCategoryOrder) { - backendConfig.removeEntry(QLatin1String("Category_") + QString::number(category)); - } else { - backendConfig.setValue(QLatin1String("Category_") + QString::number(category), order); - } -#endif //QT_NO_PHONON_SETTINGSGROUP -} - -QList GlobalConfig::audioOutputDeviceListFor(Category category, int override) const -{ - P_D(const GlobalConfig); - -#ifndef QT_NO_PHONON_SETTINGSGROUP - const bool hide = ((override & AdvancedDevicesFromSettings) - ? hideAdvancedDevices() - : static_cast(override & HideAdvancedDevices)); -#else - const bool hide = !((override & AdvancedDevicesFromSettings) && static_cast(override & HideAdvancedDevices)); -#endif - - QList defaultList; - BackendInterface *backendIface = qobject_cast(Factory::backend()); - -#ifndef QT_NO_PHONON_PLATFORMPLUGIN - if (PlatformPlugin *platformPlugin = Factory::platformPlugin()) { - // the platform plugin lists the audio devices for the platform - // this list already is in default order (as defined by the platform plugin) - defaultList = platformPlugin->objectDescriptionIndexes(AudioOutputDeviceType); - if (hide) { - QMutableListIterator it(defaultList); - while (it.hasNext()) { - AudioOutputDevice objDesc = AudioOutputDevice::fromIndex(it.next()); - const QVariant var = objDesc.property("isAdvanced"); - if (var.isValid() && var.toBool()) { - it.remove(); - } - } - } - } -#endif //QT_NO_PHONON_PLATFORMPLUGIN - - // lookup the available devices directly from the backend - if (backendIface) { - // this list already is in default order (as defined by the backend) - QList list = backendIface->objectDescriptionIndexes(AudioOutputDeviceType); - if (hide || !defaultList.isEmpty() || (override & HideUnavailableDevices)) { - filter(AudioOutputDeviceType, backendIface, &list, - (hide ? FilterAdvancedDevices : 0) - // the platform plugin maybe already provided the hardware devices? - | (defaultList.isEmpty() ? 0 : FilterHardwareDevices) - | ((override & HideUnavailableDevices) ? FilterUnavailableDevices : 0) - ); - } - defaultList += list; - } - -#ifndef QT_NO_PHONON_SETTINGSGROUP - const QSettingsGroup backendConfig(&d->config, QLatin1String("AudioOutputDevice")); // + Factory::identifier()); - return sortDevicesByCategoryPriority(this, &backendConfig, AudioOutputDeviceType, category, defaultList); -#else //QT_NO_PHONON_SETTINGSGROUP - return defaultList; -#endif //QT_NO_PHONON_SETTINGSGROUP -} - - -int GlobalConfig::audioOutputDeviceFor(Category category, int override) const -{ -#ifndef QT_NO_PHONON_SETTINGSGROUP - QList ret = audioOutputDeviceListFor(category, override); - if (!ret.isEmpty()) - return ret.first(); -#endif //QT_NO_PHONON_SETTINGSGROUP - return -1; -} - -QHash GlobalConfig::audioOutputDeviceProperties(int index) const -{ - return deviceProperties(AudioOutputDeviceType, index); -} - - -#ifndef PHONON_NO_AUDIOCAPTURE -void GlobalConfig::setAudioCaptureDeviceListFor(CaptureCategory category, QList order) -{ -#ifndef QT_NO_PHONON_SETTINGSGROUP - P_D(GlobalConfig); - QSettingsGroup backendConfig(&d->config, QLatin1String("AudioCaptureDevice")); // + Factory::identifier()); - - order = reindexList(this, AudioCaptureDeviceType, category, order); - - const QList noCategoryOrder = audioCaptureDeviceListFor(NoCaptureCategory, ShowUnavailableDevices|ShowAdvancedDevices); - if (category != NoCaptureCategory && order == noCategoryOrder) { - backendConfig.removeEntry(QLatin1String("Category_") + QString::number(category)); - } else { - backendConfig.setValue(QLatin1String("Category_") + QString::number(category), order); - } -#endif //QT_NO_PHONON_SETTINGSGROUP -} - -QList GlobalConfig::audioCaptureDeviceListFor(CaptureCategory category, int override) const -{ - P_D(const GlobalConfig); - -#ifndef QT_NO_PHONON_SETTINGSGROUP - const bool hide = ((override & AdvancedDevicesFromSettings) - ? hideAdvancedDevices() - : static_cast(override & HideAdvancedDevices)); -#else - const bool hide = !((override & AdvancedDevicesFromSettings) && static_cast(override & HideAdvancedDevices)); -#endif - - QList defaultList; - - BackendInterface *backendIface = qobject_cast(Factory::backend()); - -#ifndef QT_NO_PHONON_PLATFORMPLUGIN - if (PlatformPlugin *platformPlugin = Factory::platformPlugin()) { - // the platform plugin lists the audio devices for the platform - // this list already is in default order (as defined by the platform plugin) - defaultList += platformPlugin->objectDescriptionIndexes(AudioCaptureDeviceType); - if (hide) { - QMutableListIterator it(defaultList); - while (it.hasNext()) { - AudioCaptureDevice objDesc = AudioCaptureDevice::fromIndex(it.next()); - const QVariant var = objDesc.property("isAdvanced"); - if (var.isValid() && var.toBool()) { - it.remove(); - } - } - } - } -#endif //QT_NO_PHONON_PLATFORMPLUGIN - - // lookup the available devices directly from the backend - if (backendIface) { - // this list already is in default order (as defined by the backend) - QList list = backendIface->objectDescriptionIndexes(AudioCaptureDeviceType); - if (hide || !defaultList.isEmpty() || (override & HideUnavailableDevices)) { - filter(AudioCaptureDeviceType, backendIface, &list, - (hide ? FilterAdvancedDevices : 0) - // the platform plugin maybe already provided the hardware devices? - | (defaultList.isEmpty() ? 0 : FilterHardwareDevices) - | ((override & HideUnavailableDevices) ? FilterUnavailableDevices : 0) - ); - } - defaultList += list; - } - -#ifndef QT_NO_PHONON_SETTINGSGROUP - const QSettingsGroup backendConfig(&d->config, QLatin1String("AudioCaptureDevice")); // + Factory::identifier()); - return sortDevicesByCategoryPriority(this, &backendConfig, AudioCaptureDeviceType, category, defaultList); -#else //QT_NO_PHONON_SETTINGSGROUP -#ifndef QT_NO_PHONON_PLATFORMPLUGIN - return defaultList; -#else //QT_NO_PHONON_PLATFORMPLUGIN - return QList(); -#endif //QT_NO_PHONON_PLATFORMPLUGIN -#endif //QT_NO_PHONON_SETTINGSGROUP -} - -int GlobalConfig::audioCaptureDeviceFor(CaptureCategory category, int override) const -{ - QList ret = audioCaptureDeviceListFor(category, override); - if (ret.isEmpty()) - return -1; - return ret.first(); -} - -QHash GlobalConfig::audioCaptureDeviceProperties(int index) const -{ - return deviceProperties(AudioCaptureDeviceType, index); -} - -void GlobalConfig::setAudioCaptureDeviceListFor(Category category, QList order) -{ - CaptureCategory cat = categoryToCaptureCategory(category); - setAudioCaptureDeviceListFor(cat, order); -} - -QList GlobalConfig::audioCaptureDeviceListFor(Category category, int override) const -{ - CaptureCategory cat = categoryToCaptureCategory(category); - return audioCaptureDeviceListFor(cat, override); -} - -int GlobalConfig::audioCaptureDeviceFor(Category category, int override) const -{ - CaptureCategory cat = categoryToCaptureCategory(category); - return audioCaptureDeviceFor(cat, override); -} - -#endif //PHONON_NO_AUDIOCAPTURE - - -#ifndef PHONON_NO_VIDEOCAPTURE -void GlobalConfig::setVideoCaptureDeviceListFor(CaptureCategory category, QList order) -{ -#ifndef QT_NO_PHONON_SETTINGSGROUP - P_D(GlobalConfig); - QSettingsGroup backendConfig(&d->config, QLatin1String("VideoCaptureDevice")); // + Factory::identifier()); - - order = reindexList(this, VideoCaptureDeviceType, category, order); - - const QList noCategoryOrder = videoCaptureDeviceListFor(NoCaptureCategory, ShowUnavailableDevices|ShowAdvancedDevices); - if (category != NoCaptureCategory && order == noCategoryOrder) { - backendConfig.removeEntry(QLatin1String("Category_") + QString::number(category)); - } else { - backendConfig.setValue(QLatin1String("Category_") + QString::number(category), order); - } -#endif //QT_NO_PHONON_SETTINGSGROUP -} - -QList GlobalConfig::videoCaptureDeviceListFor(CaptureCategory category, int override) const -{ - P_D(const GlobalConfig); - -#ifndef QT_NO_PHONON_SETTINGSGROUP - const bool hide = ((override & AdvancedDevicesFromSettings) - ? hideAdvancedDevices() - : static_cast(override & HideAdvancedDevices)); -#else - const bool hide = !((override & AdvancedDevicesFromSettings) && static_cast(override & HideAdvancedDevices)); -#endif - - //First we lookup the available devices directly from the backend - BackendInterface *backendIface = qobject_cast(Factory::backend()); - if (!backendIface) { - return QList(); - } - - // this list already is in default order (as defined by the backend) - QList defaultList = backendIface->objectDescriptionIndexes(VideoCaptureDeviceType); - -#ifndef QT_NO_PHONON_PLATFORMPLUGIN - if (PlatformPlugin *platformPlugin = Factory::platformPlugin()) { - // the platform plugin lists the video devices for the platform - // this list already is in default order (as defined by the platform plugin) - defaultList += platformPlugin->objectDescriptionIndexes(VideoCaptureDeviceType); - if (hide) { - QMutableListIterator it(defaultList); - while (it.hasNext()) { - VideoCaptureDevice objDesc = VideoCaptureDevice::fromIndex(it.next()); - const QVariant var = objDesc.property("isAdvanced"); - if (var.isValid() && var.toBool()) { - it.remove(); - } - } - } - } -#endif //QT_NO_PHONON_PLATFORMPLUGIN - -#ifndef QT_NO_PHONON_SETTINGSGROUP - if (hideAdvancedDevices() || (override & HideUnavailableDevices)) { - filter(VideoCaptureDeviceType, backendIface, &defaultList, - (hideAdvancedDevices() ? FilterAdvancedDevices : 0) | - ((override & HideUnavailableDevices) ? FilterUnavailableDevices : 0) - ); - } - - //The devices need to be stored independently for every backend - const QSettingsGroup backendConfig(&d->config, QLatin1String("VideoCaptureDevice")); // + Factory::identifier()); - return sortDevicesByCategoryPriority(this, &backendConfig, VideoCaptureDeviceType, category, defaultList); -#else // QT_NO_PHONON_SETTINGSGROUP - return defaultList; -#endif // QT_NO_PHONON_SETTINGSGROUP -} - -int GlobalConfig::videoCaptureDeviceFor(CaptureCategory category, int override) const -{ - QList ret = videoCaptureDeviceListFor(category, override); - if (ret.isEmpty()) - return -1; - return ret.first(); -} - -QHash GlobalConfig::videoCaptureDeviceProperties(int index) const -{ - return deviceProperties(VideoCaptureDeviceType, index); -} - -void GlobalConfig::setVideoCaptureDeviceListFor(Category category, QList order) -{ - CaptureCategory cat = categoryToCaptureCategory(category); - setVideoCaptureDeviceListFor(cat, order); -} - -QList GlobalConfig::videoCaptureDeviceListFor(Category category, int override) const -{ - CaptureCategory cat = categoryToCaptureCategory(category); - return videoCaptureDeviceListFor(cat, override); -} - -int GlobalConfig::videoCaptureDeviceFor(Category category, int override) const -{ - CaptureCategory cat = categoryToCaptureCategory(category); - return videoCaptureDeviceFor(cat, override); -} - -#endif // PHONON_NO_VIDEOCAPTURE - -QHash GlobalConfig::deviceProperties(ObjectDescriptionType deviceType, int index) const -{ - QList indices; - QHash props; - - #ifndef QT_NO_PHONON_PLATFORMPLUGIN - // Try a device from the platform - if (PlatformPlugin *platformPlugin = Factory::platformPlugin()) - props = platformPlugin->objectDescriptionProperties(deviceType, index); - if (!props.isEmpty()) - return props; - #endif //QT_NO_PHONON_PLATFORMPLUGIN - - // Try a device from the backend - BackendInterface *backendIface = qobject_cast(Factory::backend()); - if (backendIface) - props = backendIface->objectDescriptionProperties(deviceType, index); - if (!props.isEmpty()) - return props; - - return props; -} - - -} // namespace Phonon diff --git a/src/phonon/globalconfig.h b/src/phonon/globalconfig.h deleted file mode 100644 index 79119568e..000000000 --- a/src/phonon/globalconfig.h +++ /dev/null @@ -1,88 +0,0 @@ -/* This file is part of the KDE project -Copyright (C) 2006-2008 Matthias Kretz - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), Nokia Corporation - (or its successors, if any) and the KDE Free Qt Foundation, which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . - -*/ - -#ifndef PHONON_GLOBALCONFIG_H -#define PHONON_GLOBALCONFIG_H - -#include "phonon_export.h" -#include "phononnamespace.h" -#include "phonondefs.h" -#include "objectdescription.h" - - -namespace Phonon -{ - class GlobalConfigPrivate; - - class PHONON_EXPORT GlobalConfig - { - P_DECLARE_PRIVATE(GlobalConfig) - public: - GlobalConfig(); - virtual ~GlobalConfig(); - - enum DevicesToHideFlag { - ShowUnavailableDevices = 0, - ShowAdvancedDevices = 0, - HideAdvancedDevices = 1, - AdvancedDevicesFromSettings = 2, - HideUnavailableDevices = 4 - }; - bool hideAdvancedDevices() const; - void setHideAdvancedDevices(bool hide = true); - - QHash deviceProperties(ObjectDescriptionType deviceType, int index) const; - - void setAudioOutputDeviceListFor(Category category, QList order); - QList audioOutputDeviceListFor(Category category, int override = AdvancedDevicesFromSettings) const; - int audioOutputDeviceFor(Category category, int override = AdvancedDevicesFromSettings) const; - QHash audioOutputDeviceProperties(int index) const; - -#ifndef PHONON_NO_VIDEOCAPTURE - void setVideoCaptureDeviceListFor(CaptureCategory category, QList order); - QList videoCaptureDeviceListFor(CaptureCategory category, int override = AdvancedDevicesFromSettings) const; - int videoCaptureDeviceFor(CaptureCategory category, int override = AdvancedDevicesFromSettings) const; - QHash videoCaptureDeviceProperties(int index) const; - - PHONON_DEPRECATED void setVideoCaptureDeviceListFor(Category category, QList order); - PHONON_DEPRECATED QList videoCaptureDeviceListFor(Category category, int override = AdvancedDevicesFromSettings) const; - PHONON_DEPRECATED int videoCaptureDeviceFor(Category category, int override = AdvancedDevicesFromSettings) const; -#endif //PHONON_NO_VIDEOCAPTURE - -#ifndef PHONON_NO_AUDIOCAPTURE - void setAudioCaptureDeviceListFor(CaptureCategory category, QList order); - QList audioCaptureDeviceListFor(CaptureCategory category, int override = AdvancedDevicesFromSettings) const; - int audioCaptureDeviceFor(CaptureCategory category, int override = AdvancedDevicesFromSettings) const; - QHash audioCaptureDeviceProperties(int index) const; - - PHONON_DEPRECATED void setAudioCaptureDeviceListFor(Category category, QList order); - PHONON_DEPRECATED QList audioCaptureDeviceListFor(Category category, int override = AdvancedDevicesFromSettings) const; - PHONON_DEPRECATED int audioCaptureDeviceFor(Category category, int override = AdvancedDevicesFromSettings) const; -#endif //PHONON_NO_AUDIOCAPTURE - - protected: - GlobalConfigPrivate *const k_ptr; - }; -} // namespace Phonon - - -#endif // PHONON_GLOBALCONFIG_H diff --git a/src/phonon/globalconfig_p.h b/src/phonon/globalconfig_p.h deleted file mode 100644 index f0c2bb211..000000000 --- a/src/phonon/globalconfig_p.h +++ /dev/null @@ -1,44 +0,0 @@ -/* This file is part of the KDE project -Copyright (C) 2006-2008 Matthias Kretz - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), Nokia Corporation - (or its successors, if any) and the KDE Free Qt Foundation, which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . - -*/ - -#ifndef PHONON_GLOBALCONFIG_P_H -#define PHONON_GLOBALCONFIG_P_H - -#include - -#include "phonon_export.h" - - -namespace Phonon -{ - class GlobalConfigPrivate - { - public: - GlobalConfigPrivate(); - virtual ~GlobalConfigPrivate() {} - - QSettings config; - }; -} // namespace Phonon - - -#endif // PHONON_GLOBALCONFIG_P_H diff --git a/src/phonon/globaldescriptioncontainer.h b/src/phonon/globaldescriptioncontainer.h deleted file mode 100644 index dde7e7a2e..000000000 --- a/src/phonon/globaldescriptioncontainer.h +++ /dev/null @@ -1,289 +0,0 @@ -/* - Copyright (C) 2011 Harald Sitter - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), Nokia Corporation - (or its successors, if any) and the KDE Free Qt Foundation, which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . -*/ - -#ifndef PHONON_GLOBALDESCRIPTIONCONTAINER_H -#define PHONON_GLOBALDESCRIPTIONCONTAINER_H - -#include -#include -#include - -#include - -namespace Phonon -{ - -class MediaController; - -/** - * \internal - * - * A container for object descriptions. - * The primary use of this container is to turn ObjectDescriptions with unique - * id scope smaller than backend into globally unique ones. - * - * For example a MediaController enhances a MediaObject, you may have multiple - * MediaObjects and thus MediaControllers in one application. The interface - * to query all subtitles is only available on the backend class itself though, - * so the index/id of the descriptions handed to a Phonon API user must be - * unique with global scope. - * This is where the GlobalDescriptionContainer comes in. It allows arbitrary - * objects to register (using object address) with the container (which is a - * singleton). - * The object hands its locally unique ObjectDescriptions to the container, which - * turns it into a globally unqiue description and maps the global id to the - * local id. - * - * That way it is possible to easily map local to global description objects. - * - * \author Harald Sitter - */ -template -class GlobalDescriptionContainer -{ -public: - typedef int global_id_t; - typedef int local_id_t; - - typedef QMap GlobalDescriptorMap; - typedef QMapIterator GlobalDescriptorMapIterator; - - typedef QMap LocalIdMap; - typedef QMapIterator LocaIdMapIterator; - -public: - static GlobalDescriptionContainer *self; - - static GlobalDescriptionContainer *instance() - { - if (!self) - self = new GlobalDescriptionContainer; - return self; - } - - virtual ~GlobalDescriptionContainer() {} - - /** - * \returns a list of all global unique IDs of all stored ObjectDescriptions - */ - QList globalIndexes() - { - QList list; - GlobalDescriptorMapIterator it(m_globalDescriptors); - while (it.hasNext()) { - it.next(); - list << it.key(); - } - return list; - } - - /** - * \param key the global ID of the ObjectDescription - * - * \returns ObjectDescriptions associated with a given ID - */ - D fromIndex(global_id_t key) - { - return m_globalDescriptors.value(key, D()); - } - - // ----------- MediaController Specific ----------- // - - /** - * Registers a new object within the container. - * This essentially creates a new empty ID map. - * - * \param obj The reference object - */ - void register_(void *obj) - { - Q_ASSERT(obj); - Q_ASSERT(m_localIds.find(obj) == m_localIds.end()); - m_localIds[obj] = LocalIdMap(); - } - - /** - * Unregisters a object from the container. - * This essentially clears the ID map and removes all traces of the - * object. - * - * \param obj The object - */ - void unregister_(void *obj) - { - // TODO: remove all descriptions that are *only* associated with this MC - Q_ASSERT(obj); - Q_ASSERT(m_localIds.find(obj) != m_localIds.end()); - m_localIds[obj].clear(); - m_localIds.remove(obj); - } - - /** - * Clear the internal mapping of global to local id for a given object. - * - * \param obj The object - */ - void clearListFor(void *obj) - { - Q_ASSERT(obj); - Q_ASSERT_X(m_localIds.find(obj) != m_localIds.end(), - "clearing list", - "the object is not registered!"); - m_localIds[obj].clear(); - } - - /** - * Adds a new description object for a specific object. - * A description object *must* have a global unique id, which is ensured - * by using this function, which will either reuse an existing equal - * ObjectDescription or use the next free unique ID. - * Using the provided index the unique ID is then mapped to the one of the - * specific object. - * - * \param obj The object - * \param index local ID (i.e. within the object @obj) - * \param name Name of the description - * \param type Type of the description (e.g. file) - */ - void add(void *obj, - local_id_t index, const QString &name, const QString &type = QString()) - { - Q_ASSERT(obj); - Q_ASSERT(m_localIds.find(obj) != m_localIds.end()); - - QHash properties; - properties.insert("name", name); - properties.insert("description", ""); - properties.insert("type", type); - - // Empty lists will start at 0. - global_id_t id = 0; - { - // Find id, either a descriptor with name and type is already present - // or get the next available index. - GlobalDescriptorMapIterator it(m_globalDescriptors); - while (it.hasNext()) { - it.next(); - if (it.value().property("name") == name && - it.value().property("type") == type) { - id = it.value().index(); - } - } - if (id == 0) - id = nextFreeIndex(); - } - D descriptor = D(id, properties); - - m_globalDescriptors.insert(id, descriptor); - m_localIds[obj].insert(id, index); - } - - /** - * Overload function. - * The index of the provided descriptor *must* be unique within the - * context of the container. - * - * \param obj The object - * \param descriptor the DescriptionObject with unique index - */ - void add(void *obj, - D descriptor) - { - Q_ASSERT(obj); - Q_ASSERT(m_localIds.find(obj) != m_localIds.end()); - Q_ASSERT(m_globalDescriptors.find(descriptor.index()) == m_globalDescriptors.end()); - - m_globalDescriptors.insert(descriptor.index(), descriptor); - m_localIds[obj].insert(descriptor.index(), descriptor.index()); - } - - /** - * List of ObjectDescriptions for a given object, the - * descriptions are limied by the scope of the type (obviously), so you only - * get ObjectDescription from the container. - * - * \param obj The object - * - * \returns the list of ObjectDescriptions for a given object, the - * descriptions are limied by the scope of the type (obviously), so you only - * get subtitle descriptions from a subtitle container. - */ - QList listFor(const void *obj) const - { - Q_ASSERT(obj); - Q_ASSERT(m_localIds.find(obj) != m_localIds.end()); - - QList list; - LocaIdMapIterator it(m_localIds.value(obj)); - while (it.hasNext()) { - it.next(); - Q_ASSERT(m_globalDescriptors.find(it.key()) != m_globalDescriptors.end()); - list << m_globalDescriptors[it.key()]; - } - return list; - } - - /** - * \param obj The object - * \param key the global ID (i.e. index of an ObjectDescription) - * - * \returns the local ID associated with the description object - */ - int localIdFor(const void *obj, global_id_t key) const - { - Q_ASSERT(obj); - Q_ASSERT(m_localIds.find(obj) != m_localIds.end()); - if (m_localIds[obj].find(key) == m_localIds[obj].end()) - qWarning() << "WARNING:" << Q_FUNC_INFO - << ": supplied global ID is unknown for the object (" - << obj << ")"; - return m_localIds[obj].value(key, 0); - } - -protected: - GlobalDescriptionContainer() : - m_peak(0) - { - } - - /** - * \returns next free unique index to be used as global ID for an ObjectDescription - */ - global_id_t nextFreeIndex() - { - return ++m_peak; - } - - GlobalDescriptorMap m_globalDescriptors; - QMap m_localIds; - - global_id_t m_peak; -}; - -template -GlobalDescriptionContainer *GlobalDescriptionContainer::self = 0; - -typedef GlobalDescriptionContainer GlobalAudioChannels; -typedef GlobalDescriptionContainer GlobalSubtitles; - -} // Namespace Phonon - -#endif // PHONON_GLOBALDESCRIPTIONCONTAINER_H diff --git a/src/phonon/globalstatic_p.h b/src/phonon/globalstatic_p.h deleted file mode 100644 index 65201a384..000000000 --- a/src/phonon/globalstatic_p.h +++ /dev/null @@ -1,291 +0,0 @@ -/* This file is part of the KDE libraries - Copyright (C) 2007 Matthias Kretz - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), Nokia Corporation - (or its successors, if any) and the KDE Free Qt Foundation, which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . -*/ - -#ifndef PHONON_GLOBALSTATIC_P_H -#define PHONON_GLOBALSTATIC_P_H - -#include - -// -// WARNING!! -// This code uses undocumented Qt API -// Do not copy it to your application! Use only the functions that are here! -// Otherwise, it could break when a new version of Qt ships. -// - -namespace Phonon -{ - -/** - * @internal - */ -typedef void (*CleanUpFunction)(); - -/** - * @internal - * - * Helper class for PHONON_GLOBAL_STATIC to clean up the object on library unload or application - * shutdown. - */ -class CleanUpGlobalStatic -{ - public: - CleanUpFunction func; - - inline ~CleanUpGlobalStatic() { func(); } -}; - -} // namespace Phonon - -#ifdef Q_CC_MSVC -/** - * @internal - * - * MSVC seems to give anonymous structs the same name which fails at link time. So instead we name - * the struct and hope that by adding the line number to the name it's unique enough to never clash. - */ -# define PHONON_GLOBAL_STATIC_STRUCT_NAME(NAME) _k_##NAME##__LINE__ -#else -/** - * @internal - * - * Make the struct of the PHONON_GLOBAL_STATIC anonymous. - */ -# define PHONON_GLOBAL_STATIC_STRUCT_NAME(NAME) -#endif - -/** - * This macro makes it easy to use non-POD types as global statics. - * The object is created on first use and creation is threadsafe. - * - * The object is destructed on library unload or application exit. - * Be careful with calling other objects in the destructor of the class - * as you have to be sure that they (or objects they depend on) are not already destructed. - * - * @param TYPE The type of the global static object. Do not add a *. - * @param NAME The name of the function to get a pointer to the global static object. - * - * If you have code that might be called after the global object has been destroyed you can check - * for that using the isDestroyed() function. - * - * If needed (If the destructor of the global object calls other functions that depend on other - * global statics (e.g. KConfig::sync) your destructor has to be called before those global statics - * are destroyed. A Qt post routine does that.) you can also install a post routine (@ref qAddPostRoutine) to clean up the object - * using the destroy() method. If you registered a post routine and the object is destroyed because - * of a lib unload you have to call qRemovePostRoutine! - * - * Example: - * @code - * class A { - * public: - * ~A(); - * ... - * }; - * - * PHONON_GLOBAL_STATIC(A, globalA) - * // The above creates a new globally static variable named 'globalA' which you - * // can use as a pointer to an instance of A. - * - * void doSomething() - * { - * // The first time you access globalA a new instance of A will be created automatically. - * A *a = globalA; - * ... - * } - * - * void doSomethingElse() - * { - * if (globalA.isDestroyed()) { - * return; - * } - * A *a = globalA; - * ... - * } - * - * void installPostRoutine() - * { - * // A post routine can be used to delete the object when QCoreApplication destructs, - * // not adding such a post routine will delete the object normally at program unload - * qAddPostRoutine(globalA.destroy); - * } - * - * A::~A() - * { - * // When you install a post routine you have to remove the post routine from the destructor of - * // the class used as global static! - * qRemovePostRoutine(globalA.destroy); - * } - * @endcode - * - * A common case for the need of deletion on lib unload/app shutdown are Singleton classes. Here's - * an example how to do it: - * @code - * class MySingletonPrivate; - * class EXPORT_MACRO MySingleton - * { - * friend class MySingletonPrivate; - * public: - * static MySingleton *self(); - * QString someFunction(); - * - * private: - * MySingleton(); - * ~MySingleton(); - * }; - * @endcode - * in the .cpp file: - * @code - * // This class will be instantiated and referenced as a singleton in this example - * class MySingletonPrivate - * { - * public: - * QString foo; - * MySingleton instance; - * }; - * - * PHONON_GLOBAL_STATIC(MySingletonPrivate, mySingletonPrivate) - * - * MySingleton *MySingleton::self() - * { - * // returns the singleton; automatically creates a new instance if that has not happened yet. - * return &mySingletonPrivate->instance; - * } - * QString MySingleton::someFunction() - * { - * // Refencing the singleton directly is possible for your convenience - * return mySingletonPrivate->foo; - * } - * @endcode - * - * Instead of the above you can use also the following pattern (ignore the name of the namespace): - * @code - * namespace MySingleton - * { - * EXPORT_MACRO QString someFunction(); - * } - * @endcode - * in the .cpp file: - * @code - * class MySingletonPrivate - * { - * public: - * QString foo; - * }; - * - * PHONON_GLOBAL_STATIC(MySingletonPrivate, mySingletonPrivate) - * - * QString MySingleton::someFunction() - * { - * return mySingletonPrivate->foo; - * } - * @endcode - * - * Now code that wants to call someFunction() doesn't have to do - * @code - * MySingleton::self()->someFunction(); - * @endcode - * anymore but instead: - * @code - * MySingleton::someFunction(); - * @endcode - * - * @ingroup KDEMacros - */ -#define PHONON_GLOBAL_STATIC(TYPE, NAME) PHONON_GLOBAL_STATIC_WITH_ARGS(TYPE, NAME, ()) - -/** - * @overload - * This is the same as PHONON_GLOBAL_STATIC, but can take arguments that are passed - * to the object's constructor - * - * @param TYPE The type of the global static object. Do not add a *. - * @param NAME The name of the function to get a pointer to the global static object. - * @param ARGS the list of arguments, between brackets - * - * Example: - * @code - * class A - * { - * public: - * A(const char *s, int i); - * ... - * }; - * - * PHONON_GLOBAL_STATIC_WITH_ARG(A, globalA, ("foo", 0)) - * // The above creates a new globally static variable named 'globalA' which you - * // can use as a pointer to an instance of A. - * - * void doSomething() - * { - * // The first time you access globalA a new instance of A will be created automatically. - * A *a = globalA; - * ... - * } - * @endcode - * - * @ingroup KDEMacros - */ - -#define PHONON_GLOBAL_STATIC_WITH_ARGS(TYPE, NAME, ARGS) \ -static QBasicAtomicPointer _k_static_##NAME = Q_BASIC_ATOMIC_INITIALIZER(0); \ -static bool _k_static_##NAME##_destroyed; \ -static struct PHONON_GLOBAL_STATIC_STRUCT_NAME(NAME) \ -{ \ - bool isDestroyed() \ - { \ - return _k_static_##NAME##_destroyed; \ - } \ - inline operator TYPE*() \ - { \ - return operator->(); \ - } \ - inline TYPE *operator->() \ - { \ - TYPE *p = _k_static_##NAME; \ - if (!p) { \ - if (isDestroyed()) { \ - qFatal("Fatal Error: Accessed global static '%s *%s()' after destruction. " \ - "Defined at %s:%d", #TYPE, #NAME, __FILE__, __LINE__); \ - } \ - p = new TYPE ARGS; \ - if (!_k_static_##NAME.testAndSetOrdered(0, p)) { \ - delete p; \ - p = _k_static_##NAME; \ - } else { \ - static Phonon::CleanUpGlobalStatic cleanUpObject = { destroy }; \ - } \ - } \ - return p; \ - } \ - inline TYPE &operator*() \ - { \ - return *operator->(); \ - } \ - static void destroy() \ - { \ - _k_static_##NAME##_destroyed = true; \ - TYPE *x = _k_static_##NAME; \ - _k_static_##NAME = 0; \ - delete x; \ - } \ -} NAME; - -#endif // PHONON_GLOBALSTATIC_P_H diff --git a/src/phonon/graphicsview/abstractvideographicspainter.h b/src/phonon/graphicsview/abstractvideographicspainter.h deleted file mode 100644 index d8f1b4a3f..000000000 --- a/src/phonon/graphicsview/abstractvideographicspainter.h +++ /dev/null @@ -1,100 +0,0 @@ -/* - Copyright (C) 2011 Harald Sitter - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), Nokia Corporation - (or its successors, if any) and the KDE Free Qt Foundation, which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . -*/ - -#ifndef PHONON_ABSTRACTVIDEOGRAPHICSPAINTER_H -#define PHONON_ABSTRACTVIDEOGRAPHICSPAINTER_H - -#include -#include - -#include "videoframe.h" - -class QPainter; - -namespace Phonon { - -/** - * This class provides a well defined interface to video graphics painter - * implementations. - * - * A video graphics painter is a class that draws onto an arbitrary target - * rectangle within a QGraphicsScene by whatever means it has (e.g. OpenGL ARB, - * GLSL or simply QPainter). - * - * \author Harald Sitter - */ -class AbstractVideoGraphicsPainter -{ -public: - virtual QList supportedFormats() const = 0; - - /** - * Set a new frame on the painter. - * This function should be called before any other function is used. The - * frame can either stay valid throughout the life time of the object (in - * which case you only need to call it once) or you need to set the most - * current frame each paint cycle. - * At any rate there must be a valid frame set before calling anything. - * - * Mind that you will need to drop the painter and reinitialize a new one - * once the frame changed in format, size, and the like. - * - * \param frame is the video frame that the painter is supposed to paint later on. - */ - void setFrame(const VideoFrame *frame) { m_frame = frame; } - - /** - * Implementations of init can prepare the painter for painting. For example - * an OpenGL painter may setup the GLContext and prepare the textures. - * Mind that init will usually be irreversible, so once a painter was - * initialized for a specific frame only the data of this frame may change. - * - * \see setFrame - */ - virtual void init() = 0; - - /** - * The actual paint logic is implemented in this function. - * - * \param painter the QPainter obtained from the paint call on a QGraphicsItem. - * \param target the rectangle to draw in, this will usually be the rectangle calculated for - * a given aspect ratio. - */ - virtual void paint(QPainter *painter, QRectF target) = 0; - - /** Destructor. */ - virtual ~AbstractVideoGraphicsPainter() {} - - bool inited() const { return m_inited; } - -protected: - AbstractVideoGraphicsPainter() : m_frame(0), m_inited(false) {} - - /** The frame an implementatin is supposed to work with. */ - const VideoFrame *m_frame; - - /** Whether or not the painter was inited */ - bool m_inited; -}; - -} // namespace Phonon - -#endif // PHONON_ABSTRACTVIDEOGRAPHICSPAINTER_H diff --git a/src/phonon/graphicsview/glpainter.cpp b/src/phonon/graphicsview/glpainter.cpp deleted file mode 100644 index 92df4b51b..000000000 --- a/src/phonon/graphicsview/glpainter.cpp +++ /dev/null @@ -1,141 +0,0 @@ -/* - Copyright (C) 2011 Harald Sitter - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), Nokia Corporation - (or its successors, if any) and the KDE Free Qt Foundation, which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . -*/ - -#include "glpainter.h" - -#include - -namespace Phonon { - -GlPainter::GlPainter() : - m_context(0) - , m_texturesInited(false) -{ -} - -GlPainter::~GlPainter() -{ -#ifdef __GNUC__ -#warning context may be long gone, leading to crashery -#endif -// if (m_context) { -// m_context->makeCurrent(); -// glDeleteTextures(m_textureCount, m_textureIds); -// } -} - -void GlPainter::setContext(QGLContext *context) -{ - m_context = context; -} - -void GlPainter::initRgb32() -{ - Q_ASSERT(m_frame->planeCount == 1); - m_textureCount = m_frame->planeCount; - - m_texDescriptor.target = GL_TEXTURE_2D; - m_texDescriptor.internalFormat = GL_RGBA; - m_texDescriptor.format = GL_RGBA; - m_texDescriptor.type = GL_UNSIGNED_BYTE; -} - -void GlPainter::initYv12() -{ - Q_ASSERT(m_frame->planeCount == 3); - m_textureCount = m_frame->planeCount; - - m_texDescriptor.target = GL_TEXTURE_2D; - m_texDescriptor.internalFormat = GL_LUMINANCE; - m_texDescriptor.format = GL_LUMINANCE; - m_texDescriptor.type = GL_UNSIGNED_BYTE; -} - -void GlPainter::initColorMatrix() -{ - m_colorMatrix = QMatrix4x4(1.0, 0.0, 0.0, 0.0, - 0.0, 1.0, 0.0, 0.0, - 0.0, 0.0, 1.0, 0.0, - 0.0, 0.0, 0.0, 1.0); - // If the fame has YUV format, apply color correction: - switch (m_frame->format) { - case VideoFrame::Format_YV12: - QMatrix4x4 colorSpaceMatrix; - if (m_frame->height > 576) - colorSpaceMatrix = - QMatrix4x4( - 1.164383561643836, 0.0000, 1.792741071428571, -0.972945075016308, - 1.164383561643836, -0.21324861427373, -0.532909328559444, 0.301482665475862, - 1.164383561643836, 2.112401785714286, 0.0000, -1.133402217873451, - 0.0000, 0.0000, 0.0000, 1.0000 ); - else - colorSpaceMatrix = - QMatrix4x4( - 1.164383561643836, 0.0000, 1.596026785714286, -0.874202217873451, - 1.164383561643836, -0.391762290094914, -0.812967647237771, 0.531667823499146, - 1.164383561643836, 2.017232142857142, 0.0000, -1.085630789302022, - 0.0000, 0.0000, 0.0000, 1.0000 ); - m_colorMatrix = m_colorMatrix * colorSpaceMatrix; - break; - } -} - -void GlPainter::initTextures() -{ - if (!m_texturesInited) { - for (unsigned i = 0; i < m_frame->planeCount; ++i) { - glBindTexture(m_texDescriptor.target, m_textureIds[i]); - glTexImage2D(m_texDescriptor.target, - 0, - m_texDescriptor.internalFormat, - m_frame->visiblePitch[i], - m_frame->visibleLines[i], - 0, - m_texDescriptor.format, - m_texDescriptor.type, - 0); - // Scale appropriately so we can change to target geometry without - // much hassle. - glTexParameterf(m_texDescriptor.target, GL_TEXTURE_MAG_FILTER, GL_LINEAR); - glTexParameterf(m_texDescriptor.target, GL_TEXTURE_MIN_FILTER, GL_LINEAR); - glTexParameterf(m_texDescriptor.target, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); - glTexParameterf(m_texDescriptor.target, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); - glTexParameterf(m_texDescriptor.target, GL_TEXTURE_PRIORITY, 1.0); - glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); - m_texturesInited = true; - } - } - for (unsigned i = 0; i < m_frame->planeCount; ++i) { - glBindTexture(m_texDescriptor.target, m_textureIds[i]); - glPixelStorei(GL_UNPACK_ROW_LENGTH, m_frame->pitch[i]); - glTexSubImage2D(m_texDescriptor.target, 0, - 0, 0, - m_frame->visiblePitch[i], - m_frame->visibleLines[i], - m_texDescriptor.format, - m_texDescriptor.type, - m_frame->plane[i].data()); - glPixelStorei(GL_UNPACK_ROW_LENGTH, 0); // reset to default - } -} - -} // namespace Phonon - diff --git a/src/phonon/graphicsview/glpainter.h b/src/phonon/graphicsview/glpainter.h deleted file mode 100644 index e74679b5b..000000000 --- a/src/phonon/graphicsview/glpainter.h +++ /dev/null @@ -1,88 +0,0 @@ -/* - Copyright (C) 2011 Harald Sitter - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), Nokia Corporation - (or its successors, if any) and the KDE Free Qt Foundation, which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . -*/ - -#ifndef PHONON_GLPAINTER_H -#define PHONON_GLPAINTER_H - -#include -// Not forward included, because we need platform specific GL typedefs for structs. -#include - -#include "abstractvideographicspainter.h" -#include "videoframe.h" - -namespace Phonon { - -class GlPainter : public AbstractVideoGraphicsPainter -{ - typedef struct { - GLenum target; - GLint internalFormat; -// GLint border; - GLenum format; - GLenum type; - } GlTextureDescriptor; - - typedef struct { - GLsizei width; - GLsizei height; - } GlTextureSize; - -public: - /** Destructor. */ - virtual ~GlPainter(); - - /** \param context the QGLContext to use for this painter. */ - void setContext(QGLContext *context); - - /** Initialize for an RGB32/RGBA frame. */ - void initRgb32(); - - /** Initialize for an YV12 frame. */ - void initYv12(); - - /** Initialize the color matrix to be used for YUV->RGB color conversion. */ - void initColorMatrix(); - - /** - * Initialize all textures (amount of texture is dependent on what count was - * decided in the specific init functions. - */ - void initTextures(); - -protected: - GlPainter(); - - QGLContext *m_context; - int m_textureCount; - GLuint m_textureIds[3]; - - GlTextureDescriptor m_texDescriptor; - GlTextureSize m_texSize[3]; - - QMatrix4x4 m_colorMatrix; - - bool m_texturesInited; -}; - -} // namespace Phonon - -#endif // PHONON_GLPAINTER_H diff --git a/src/phonon/graphicsview/glslpainter.cpp b/src/phonon/graphicsview/glslpainter.cpp deleted file mode 100644 index b29be5a20..000000000 --- a/src/phonon/graphicsview/glslpainter.cpp +++ /dev/null @@ -1,284 +0,0 @@ -/* - Copyright (C) 2011-2012 Harald Sitter - Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies) - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), Nokia Corporation - (or its successors, if any) and the KDE Free Qt Foundation, which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . -*/ - -#include "glslpainter.h" -#include "videoframe.h" - -#include - -namespace Phonon { - -void GlslPainter::calculateFPS() -{ - if (m_fps.lastTime.isNull()) - m_fps.lastTime = QTime::currentTime(); - QTime time = QTime::currentTime(); - - int delta = m_fps.lastTime.msecsTo(time); - if (delta > 2000) { - m_fps.value = 1000.0 * m_fps.frames / qreal(delta); - if (m_fps.value < 20.0) - qWarning() << "Drawing less than 20 frames per second!"; - m_fps.lastTime = time; - m_fps.frames = 0; - } - - ++m_fps.frames; -} - -void GlslPainter::addFPSOverlay() -{ - if (m_fps.value != m_fps.imagedValue) { - // Update image - m_fps.img.fill(Qt::blue); - QPainter painter(&(m_fps.img)); - painter.setPen(QColor(Qt::white)); - painter.drawText(0, 16, QString::number((int)m_fps.value)); - painter.end(); - } - - GLuint id = m_context->bindTexture(m_fps.img); - m_context->drawTexture(QPointF(0, 0), id); - m_context->deleteTexture(id); - - m_fps.imagedValue = m_fps.value; -} - -static const char *s_phonon_rgb32Shader = -"uniform sampler2D textureSampler;\n" -"varying highp vec2 textureCoord;\n" -"void main(void)\n" -"{\n" -" gl_FragColor = vec4(texture2D(textureSampler, textureCoord.st).bgr, 1.0);\n" -"}\n"; - -static const char *s_phonon_yv12Shader = -"uniform sampler2D texY;\n" -"uniform sampler2D texU;\n" -"uniform sampler2D texV;\n" -"uniform mediump mat4 colorMatrix;\n" -"varying highp vec2 textureCoord;\n" -"uniform lowp float opacity;" -"void main(void)\n" -"{\n" -" highp vec4 color = vec4(\n" -" texture2D(texY, textureCoord.st).r,\n" -" texture2D(texV, textureCoord.st).r,\n" // !!!! mind the swp -" texture2D(texU, textureCoord.st).r,\n" -" 1.0);\n" -" gl_FragColor = colorMatrix * color * opacity;\n" -"}\n"; - -GlslPainter::GlslPainter() : - m_program(0) -{} - -GlslPainter::~GlslPainter() -{ -#ifdef __GNUC__ -#warning context may be long gone, leading to crashery -#endif - if (m_program) { - m_program->removeAllShaders(); - m_program->deleteLater(); - } -} - -QList GlslPainter::supportedFormats() const -{ - QList formats; - - QGLContext *glContext = const_cast(QGLContext::currentContext()); - if (glContext) { - glContext->makeCurrent(); - - const QByteArray glExtensions(reinterpret_cast(glGetString(GL_EXTENSIONS))); - if (QGLShaderProgram::hasOpenGLShaderPrograms(glContext) - && glExtensions.contains("ARB_shader_objects")) { - // We are usable. - return formats << VideoFrame::Format_YV12 - << VideoFrame::Format_RGB32; - } - } - - return formats; -} - -void GlslPainter::init() -{ - m_context = const_cast(QGLContext::currentContext()); - Q_ASSERT(m_context); - m_context->makeCurrent(); - - if (!m_program) - m_program = new QGLShaderProgram(m_context); - - const char *vertexProgram = - "attribute highp vec4 targetVertex;\n" - "attribute highp vec2 textureCoordinates;\n" - "uniform highp mat4 positionMatrix;\n" - "varying highp vec2 textureCoord;\n" - "void main(void)\n" - "{\n" - " gl_Position = positionMatrix * targetVertex;\n" - " textureCoord = textureCoordinates;\n" - "}\n"; - - const char *program = 0; - switch (m_frame->format) { - case VideoFrame::Format_RGB32://////////////////////////////////////// RGB32 - initRgb32(); - program = s_phonon_rgb32Shader; - break; - case VideoFrame::Format_YV12: ///////////////////////////////////////// YV12 - initYv12(); - program = s_phonon_yv12Shader; - break; - default: /////////////////////////////////////////////////////////// Default - qDebug() << "format: " << m_frame->format; - Q_ASSERT(false); - } - Q_ASSERT(program); - initColorMatrix(); - - if (!m_program->addShaderFromSourceCode(QGLShader::Vertex, vertexProgram)) - qFatal("couldnt add vertex shader"); - else if (!m_program->addShaderFromSourceCode(QGLShader::Fragment, program)) - qFatal("couldnt add fragment shader"); - else if (!m_program->link()) - qFatal("couldnt link shader"); - - glGenTextures(m_textureCount, m_textureIds); - - m_inited = true; -} - -void GlslPainter::paint(QPainter *painter, QRectF target) -{ - // Need to reenable those after native painting has begun, otherwise we might - // not be able to paint anything. - 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); - - ////////////////////////////////////////////////////////////// - initTextures(); - ////////////////////////////////////////////////////////////// - - // As seen on the telly -#ifdef __GNUC__ -#warning DUPLICATED CODE -#endif - - const float textureCoordinates[] = { - 0, 1, // bottom left - 1, 1, // bottom right - 0, 0, // top left - 1, 0, // top right - }; - - const GLfloat targetVertex[] = - { - GLfloat(target.left()), GLfloat(target.bottom()), - GLfloat(target.right()), GLfloat(target.bottom()), - GLfloat(target.left()) , GLfloat(target.top()), - GLfloat(target.right()), GLfloat(target.top()) - }; - // - - 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] = { - { - GLfloat(wfactor * transform.m11() - transform.m13()), - GLfloat(hfactor * transform.m12() + transform.m13()), - 0.0, - GLfloat(transform.m13()) - }, { - GLfloat(wfactor * transform.m21() - transform.m23()), - GLfloat(hfactor * transform.m22() + transform.m23()), - 0.0, - GLfloat(transform.m23()) - }, { - 0.0, - 0.0, - -1.0, - 0.0 - }, { - GLfloat(wfactor * transform.dx() - transform.m33()), - GLfloat(hfactor * transform.dy() + transform.m33()), - 0.0, - GLfloat(transform.m33()) - } - }; - - m_program->bind(); - - m_program->enableAttributeArray("targetVertex"); - m_program->enableAttributeArray("textureCoordinates"); - m_program->setAttributeArray("targetVertex", targetVertex, 2); - m_program->setAttributeArray("textureCoordinates", textureCoordinates, 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); - m_program->setUniformValue("opacity", GLfloat(painter->opacity())); - - glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); - - m_program->release(); - painter->endNativePainting(); - - calculateFPS(); - addFPSOverlay(); -} - -} // namespace Phonon diff --git a/src/phonon/graphicsview/glslpainter.h b/src/phonon/graphicsview/glslpainter.h deleted file mode 100644 index 3fe519a4a..000000000 --- a/src/phonon/graphicsview/glslpainter.h +++ /dev/null @@ -1,71 +0,0 @@ -/* - Copyright (C) 2011 Harald Sitter - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), Nokia Corporation - (or its successors, if any) and the KDE Free Qt Foundation, which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . -*/ - -#ifndef PHONON_GLSLPAINTER_H -#define PHONON_GLSLPAINTER_H - -#include -#include - -#include "glpainter.h" - -class QGLShaderProgram; - -namespace Phonon { - -class GlslPainter : public GlPainter, protected QGLFunctions -{ -public: - GlslPainter(); - virtual ~GlslPainter(); - - virtual QList supportedFormats() const; - - void init(); - void paint(QPainter *painter, QRectF target); - -private: - void calculateFPS(); - void addFPSOverlay(); - - struct FPS { - FPS() - : value(0) - , imagedValue(0) - , frames(0) - , img(32, 32, QImage::Format_ARGB32) - { - } - - qreal value; - qreal imagedValue; - quint64 frames; - QTime lastTime; - QImage img; - }; - - struct FPS m_fps; - QGLShaderProgram *m_program; -}; - -} // namespace Phonon - -#endif // PHONON_GLSLPAINTER_H diff --git a/src/phonon/graphicsview/qpainterpainter.cpp b/src/phonon/graphicsview/qpainterpainter.cpp deleted file mode 100644 index cdbdbeed5..000000000 --- a/src/phonon/graphicsview/qpainterpainter.cpp +++ /dev/null @@ -1,60 +0,0 @@ -/* - Copyright (C) 2012 Harald Sitter - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), Nokia Corporation - (or its successors, if any) and the KDE Free Qt Foundation, which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . -*/ - -#include "qpainterpainter.h" - -#include -#include - -namespace Phonon { - -QPainterPainter::QPainterPainter() -{ -} - -QPainterPainter:: ~QPainterPainter() -{ -} - -QList QPainterPainter::supportedFormats() const -{ - return QList() << VideoFrame::Format_RGB32; -} - -void QPainterPainter::init() -{ - m_inited = true; -} - -void QPainterPainter::paint(QPainter *painter, QRectF target) -{ - // QImage can only handle packed formats. - if (m_frame->planeCount != 1 || m_frame->format != VideoFrame::Format_RGB32) { - painter->drawImage(target, QImage()); - } else { - painter->drawImage(target, - QImage(reinterpret_cast(m_frame->plane[0].constData()), - m_frame->width, m_frame->height, - QImage::Format_RGB32)); - } -} - -} // namespace Phonon diff --git a/src/phonon/graphicsview/qpainterpainter.h b/src/phonon/graphicsview/qpainterpainter.h deleted file mode 100644 index 9e54c7899..000000000 --- a/src/phonon/graphicsview/qpainterpainter.h +++ /dev/null @@ -1,42 +0,0 @@ -/* - Copyright (C) 2012 Harald Sitter - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), Nokia Corporation - (or its successors, if any) and the KDE Free Qt Foundation, which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . -*/ - -#ifndef PHONON_QPAINTERPAINTER_H -#define PHONON_QPAINTERPAINTER_H - -#include "abstractvideographicspainter.h" - -namespace Phonon { - -class QPainterPainter : public AbstractVideoGraphicsPainter -{ -public: - QPainterPainter(); - virtual ~QPainterPainter(); - - virtual QList supportedFormats() const; - void init(); - void paint(QPainter *painter, QRectF target); -}; - -} // namespace Phonon - -#endif // PHONON_QPAINTERPAINTER_H diff --git a/src/phonon/graphicsview/videoframe.h b/src/phonon/graphicsview/videoframe.h deleted file mode 100644 index c7367c101..000000000 --- a/src/phonon/graphicsview/videoframe.h +++ /dev/null @@ -1,116 +0,0 @@ -/* - Copyright (C) 2011-2012 Harald Sitter - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), Nokia Corporation - (or its successors, if any) and the KDE Free Qt Foundation, which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . -*/ - -#ifndef PHONON_VIDEOFRAME_H -#define PHONON_VIDEOFRAME_H - -#include - -namespace Phonon { - -/** - * This struct presents a simple video frame within Phonon. - * It has all the main characteristics of a frame. It has height, width and a - * chroma format. - * The chroma format also decides on how many picture planes one frame may have. - * For example a YV12 frame will have 3 planes, one for Y one for U and one for V. - * An RGB32 frame on the other hand only has one plane (as RGB is a packed format). - * - * \author Harald Sitter - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), Nokia Corporation - (or its successors, if any) and the KDE Free Qt Foundation, which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . -*/ - -#include "videographicsobject.h" - -#include "abstractvideographicspainter.h" -#include "factory_p.h" -#include "glslpainter.h" -#include "medianode_p.h" -#include "phonondefs_p.h" -#include "qpainterpainter.h" -#include "videoframe.h" -#include "videographicsobjectinterface.h" - -#define PHONON_INTERFACENAME VideoGraphicsObjectInterface - -namespace Phonon { - -QMap > VideoGraphicsPainterMetaFactory::detectTypes() -{ - QMap > map; - map.insert(GraphicsPainterGlsl, GlslPainter().supportedFormats()); - map.insert(GraphicsPainterQPainter, QPainterPainter().supportedFormats()); - return map; -} - -class PrivatePainterFactory -{ -public: - AbstractVideoGraphicsPainter *factorize(QList choices, - QMap > formats) - { - // Try to find a matching format. - // Iterate the painters in order glsl>glarb>qpainter, foreach painter check - // if it supports one of the chosen formats in the order from the backend. - // That way we get to choose our most preferred (e.g. reliable) painter, - // while honoring the backends priorization. Painting is weighted more - // because a bad painter in Qt Quick 1 will cause insanely bad quality (QPainter...) - GraphicsPainterType painterType = GraphicsPainterNone; - QMap >::const_iterator it = formats.constBegin(); - while (it != formats.constEnd()) { - foreach (VideoFrame::Format format, choices) { - if (it.value().contains(format)) { - chosenFormat = format; - painterType = it.key(); - break; - } - } - if (painterType != GraphicsPainterNone) - break; - ++it; - } - - switch(painterType) { - case GraphicsPainterNone: - // TODO: what to do what to do? :( - Q_ASSERT(painterType != GraphicsPainterNone); - case GraphicsPainterGlsl: - return new GlslPainter; - case GraphicsPainterQPainter: - return new QPainterPainter; - } - - // Cannot reach. - Q_ASSERT(false); - return 0; - } - - VideoFrame::Format chosenFormat; -}; - -// --------------------------------- PRIVATE -------------------------------- // -class VideoGraphicsObjectPrivate : public MediaNodePrivate -{ - P_DECLARE_PUBLIC(VideoGraphicsObject) -public: - VideoGraphicsObjectPrivate() : - geometry(0, 0, 320, 240), - boundingRect(0, 0, 0, 0), - frameSize(0, 0), - graphicsPainter(0), - paintedOnce(false), - gotSize(false), - ready(false) - {} - - virtual ~VideoGraphicsObjectPrivate() - { - if (graphicsPainter) - delete graphicsPainter; - } - - virtual QObject *qObject() { return q_func(); } - - void updateBoundingRect(); - void _p_negotiateFormat(); - - QRectF geometry; - QRectF boundingRect; - QSize frameSize; - - AbstractVideoGraphicsPainter *graphicsPainter; - - // FIXME: pfui - QMap > spyFormats; - - bool paintedOnce; - bool gotSize; - bool ready; - -protected: - bool aboutToDeleteBackendObject() { return true; } - void createBackendObject() - { - if (m_backendObject) - return; - - P_Q(VideoGraphicsObject); - m_backendObject = Factory::createVideoGraphicsObject(q); - if (m_backendObject) { - QObject::connect(m_backendObject, SIGNAL(frameReady()), - q, SLOT(frameReady()), - Qt::QueuedConnection); - QObject::connect(m_backendObject, SIGNAL(reset()), - q, SLOT(reset()), - Qt::QueuedConnection); - // Frameready triggers an update/paint, within paint we negotiate. - QObject::connect(m_backendObject, SIGNAL(needFormat()), - q, SLOT(_p_negotiateFormat()), - Qt::DirectConnection); - // FIXME: directconnection ... - // this is actually super wrong, as for example with VLC we get a foreign thread - // cb, so for the sake of not having to make this entire thing threadsafe, the backend - // needs to sync their cb with us - } - } -}; - -void VideoGraphicsObjectPrivate::updateBoundingRect() -{ - P_Q(VideoGraphicsObject); - emit q->prepareGeometryChange(); - - // keep aspect - QSizeF scaledFrameSize = frameSize; - scaledFrameSize.scale(geometry.size(), Qt::KeepAspectRatio); - - boundingRect = QRectF(0, 0, scaledFrameSize.width(), scaledFrameSize.height()); - boundingRect.moveCenter(geometry.center()); -} - -/** - * @brief VideoGraphicsObjectPrivate::_p_negotiateFormat - * Super spooky function. There are two ways formats can be known to the VGO: - * * Previously detected by a (QML) Spy - * * This function is called by paint() allowing us to introspect capabilities. - * - * Once the supported painters & formats were detected the actual negotiation starts. - * Currently this function always returns a painter, or it goes down in flames. - * - * @return Painter to use. - */ -void VideoGraphicsObjectPrivate::_p_negotiateFormat() -{ - QMap > formats; - if (spyFormats.empty()) - formats = VideoGraphicsPainterMetaFactory::detectTypes(); - else - formats = spyFormats; - - QList formatList; - QMap >::const_iterator it = formats.constBegin(); - while (it != formats.constEnd()) { - foreach (VideoFrame::Format format, it.value()) { - if (!formatList.contains(format)) - formatList.append(format); - } - ++it; - } - - QList choices; - pBACKEND_GET1(QList, choices, "offering", QList, formatList); - PrivatePainterFactory factory; - graphicsPainter = factory.factorize(choices, formats); - pINTERFACE_CALL(choose(factory.chosenFormat)); -} - -// --------------------------------- PUBLIC --------------------------------- // - -VideoGraphicsObject::VideoGraphicsObject(QGraphicsItem *parent) : - QGraphicsObject(parent), - MediaNode(*new VideoGraphicsObjectPrivate) -{ - setFlag(ItemHasNoContents, false); - - P_D(VideoGraphicsObject); - d->createBackendObject(); -} - -VideoGraphicsObject::~VideoGraphicsObject() -{ -} - -QRectF VideoGraphicsObject::boundingRect() const -{ - P_D(const VideoGraphicsObject); - return d->boundingRect; -} - -void VideoGraphicsObject::paint(QPainter *painter, - const QStyleOptionGraphicsItem *option, - QWidget *widget) -{ - P_D(VideoGraphicsObject); - - INTERFACE_CALL(lock()); - - if (!d->graphicsPainter) - d->_p_negotiateFormat(); - -#ifdef __GNUC__ -#warning what if no painter could be created? -#endif - Q_ASSERT(d->graphicsPainter); - - const VideoFrame *frame = INTERFACE_CALL(frame()); - - if (frame->format != VideoFrame::Format_Invalid && !d->gotSize) { - // TODO: do scaling ourselfs? - d->gotSize = true; - d->frameSize = QSize(frame->width, frame->height); - d->updateBoundingRect(); - } - - if (frame->format == VideoFrame::Format_Invalid || !d->paintedOnce) { - painter->fillRect(d->boundingRect, Qt::black); - if (!d->paintedOnce) // Must not ever block here! - QMetaObject::invokeMethod(this, "gotPaint", Qt::QueuedConnection); - d->paintedOnce = true; - } else { - Q_ASSERT(d->graphicsPainter); - d->graphicsPainter->setFrame(frame); - if (!d->graphicsPainter->inited()) - d->graphicsPainter->init(); - d->graphicsPainter->paint(painter, d->boundingRect); - } - - INTERFACE_CALL(unlock()); -} - -bool VideoGraphicsObject::canNegotiate() const -{ - P_D(const VideoGraphicsObject); - return d->paintedOnce || !d->spyFormats.empty(); -} - -void VideoGraphicsObject::setGeometry(const QRectF &newGeometry) -{ - P_D(VideoGraphicsObject); - d->geometry = newGeometry; - d->updateBoundingRect(); -} - -void VideoGraphicsObject::frameReady() -{ - P_D(const VideoGraphicsObject); - update(d->boundingRect); -} - -void VideoGraphicsObject::reset() -{ - P_D(VideoGraphicsObject); - // Do not reset the spyFormats as they will not change. - d->paintedOnce = false; - d->gotSize = false; - - // The painter is reset because the backend may choose another format for - // another file (better conversion for some codec etc.) - if (d->graphicsPainter) { - delete d->graphicsPainter; - d->graphicsPainter = 0; - } -} - -void VideoGraphicsObject::setSpyFormats(QMap > formats) -{ - P_D(VideoGraphicsObject); - d->spyFormats = formats; - // TODO: fake paint signal to ensure play() is issued? -} - -} // namespace Phonon - -#include "moc_videographicsobject.cpp" -#include "moc_videographicsobject.h" diff --git a/src/phonon/graphicsview/videographicsobject.h b/src/phonon/graphicsview/videographicsobject.h deleted file mode 100644 index d41acf71e..000000000 --- a/src/phonon/graphicsview/videographicsobject.h +++ /dev/null @@ -1,158 +0,0 @@ -/* - Copyright (C) 2011 Harald Sitter - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), Nokia Corporation - (or its successors, if any) and the KDE Free Qt Foundation, which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . -*/ - -#ifndef PHONON_VIDEOGRAPHICSOBJECT_H -#define PHONON_VIDEOGRAPHICSOBJECT_H - -#include -#include - -#include "medianode.h" - -// FIXME: I really do not want a videoframe include :( -#include "videoframe.h" - -// FIXME: review symbol exposure of QGV stuff - -namespace Phonon { - -class VideoFrame; -class VideoGraphicsFormatSpy; -class VideoGraphicsObjectPrivate; - -enum GraphicsPainterType { - GraphicsPainterNone, - GraphicsPainterGlsl, - GraphicsPainterGlArb, - GraphicsPainterQPainter -}; - -class PHONON_EXPORT VideoGraphicsPainterMetaFactory -{ -public: - static QMap > detectTypes(); -}; - -/** - * This class is a video representation implementation for QGraphicsViews/Scenes. - * - * It manually obtaines raw frame data from the Phonon backends using the - * VideoGraphicsObjectInterface and draws them using an implemntation of - * AbstractVideoGraphicsPainter. - * - * The VideoGraphicsObject can be used like any other QGraphicsItem, simply add - * it to a scene and be done with it. - * You should however keep in mind that due to the amount of work involved in - * redrawing an area of screen ~25 times per second that some things possible with - * other VideoGraphicsItems are not possible with a Phonon VideoGraphicsObject. - * Also not every painter can deliver all the functionality required for more complex - * things. - * - * For ultimate performance and user experience you should use a Phonon - * VideoGraphicsObject only in a QGraphicsView with OpenGL viewport. Please take - * a look at the QGraphicsView documentation for information on how to set an - * OpenGL viewport. - * - * As the QGraphicsView system does not provide implicit size hints you can - * explicitly request a target geometry for the VideoGraphicsObject using - * setGeometry(). - * - * \code - * QGraphicsView view; - * QGraphicsScene scene; - * view.setScene(&scene); - * - * Phonon::MediaObject mo; - * Phonon::VideoGraphicsObject vgo; - * Phonon::createPath(&mo, &vgo); - * vgo.setGeometry(QRectF(0,0,320,240)); - * scene.addItem(&vgo); - * mo.setCurrentSource(Phonon::MediaSource("~/video.ogv")); - * mo.play(); - * - * view.show(); - * \endcode - * - * \author Harald Sitter - */ -class PHONON_EXPORT VideoGraphicsObject : public QGraphicsObject, public MediaNode -{ - P_DECLARE_PRIVATE(VideoGraphicsObject) - Q_OBJECT -public: - /** Constructor. \param parent the parent of the object. */ - explicit VideoGraphicsObject(QGraphicsItem *parent = 0); - - /** Destructor. */ - virtual ~VideoGraphicsObject(); - - /** - * \returns the rectangle in which the object will paint, either equal - * or smaller than the set . - */ - virtual QRectF boundingRect() const; - - /** \param newGeometry the geometry this object should at most occupy. */ - void setGeometry(const QRectF &newGeometry); - - /** \reimp */ - void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget); - - - /** - * Whether the VideoGraphicsObject is ready to begin playback. - * Usually it would only be ready when it negotiated the format to use. To do - * this it most of the time requires at least one paint call. Before the VGO - * is ready a connected MediaObject will refuse to start playback! - * - * Should play be called before the VideoGraphicsObject the MediaObject will - * put the command on a pending list and wait for the ready signal to be - * emitted. - * - * \see ready() - */ - bool isReady() const; - - // FIXME: q_invoke? - bool canNegotiate() const; - -public slots: - // FIXME: q_invoke? - void setSpyFormats(QMap > formats); - -signals: - void ready(); - - // FIXME: ew?! - void gotPaint(); - - // TODO: make Q_PRIVATE -private slots: - void frameReady(); - void reset(); - -private: - Q_PRIVATE_SLOT(k_func(), void _p_negotiateFormat()) -}; - -} // namespace Phonon - -#endif // PHONON_VIDEOGRAPHICSOBJECT_H diff --git a/src/phonon/graphicsview/videographicsobjectinterface.h b/src/phonon/graphicsview/videographicsobjectinterface.h deleted file mode 100644 index 40ea8fbcc..000000000 --- a/src/phonon/graphicsview/videographicsobjectinterface.h +++ /dev/null @@ -1,84 +0,0 @@ -/* - Copyright (C) 2011 Harald Sitter - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), Nokia Corporation - (or its successors, if any) and the KDE Free Qt Foundation, which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . -*/ - -#ifndef PHONON_VIDEOGRAPHICSOBJECTINTERFACE_H -#define PHONON_VIDEOGRAPHICSOBJECTINTERFACE_H - -#include "videoframe.h" -namespace Phonon { - - -class VideoGraphicsObjectInterface -{ -public: - /** Destructor. */ - virtual ~VideoGraphicsObjectInterface() {} - - /** Lock video frame. */ - virtual void lock() = 0; - - /** - * Try to lock video frame. - * \returns whether locking was successful. - */ - virtual bool tryLock() = 0; - - /** Unlock video frame. */ - virtual void unlock() = 0; - - /** - * Access the most current video frame. - * Please mind that an internal mutex must be locked/unlocked accordingly. - * \returns the current frame (held in the interface implementation) - */ - virtual const VideoFrame *frame() const = 0; - - /** - * Offers a list of video formats to the backend. - * This function may be called multiple times as part of format negotiation - * usually until the frontend found a painter that supports a format also - * supported by the backend. - * \param offers the possible formats (may be empty) - * \returns the preferred choice or Invalid - */ - virtual QList offering(QList offers) = 0; - - // --------------------------- Q_INVOKABLES ----------------------------- // - /** Chooses \param format as frame format */ - virtual void choose(VideoFrame::Format format) = 0; - - // ------------------------------ Signals ------------------------------- // - /** Signal to be emitted when a new frame is ready for painting. */ - virtual void frameReady() = 0; - - /** Signal to be emitted when the frontend object should reset (Painters for instance). */ - virtual void reset() = 0; - - /** To be emitted when the backend requires the format negotiation now. */ - virtual void needFormat() = 0; -}; - -} // namespace Phonon - -Q_DECLARE_INTERFACE(Phonon::VideoGraphicsObjectInterface, - "org.kde.phonon.VideoGraphicsObjectInterface/1.0") - -#endif // PHONON_VIDEOGRAPHICSOBJECTINTERFACE_H diff --git a/src/phonon/iodevicestream.cpp b/src/phonon/iodevicestream.cpp deleted file mode 100644 index dcacfdffc..000000000 --- a/src/phonon/iodevicestream.cpp +++ /dev/null @@ -1,91 +0,0 @@ -/* - Copyright (C) 2007 Matthias Kretz - Copyright (C) 2011 Harald Sitter - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), Nokia Corporation - (or its successors, if any) and the KDE Free Qt Foundation, which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . -*/ - -#include "iodevicestream_p.h" -#include "abstractmediastream_p.h" - -#ifndef QT_NO_PHONON_ABSTRACTMEDIASTREAM - -namespace Phonon -{ - -class IODeviceStreamPrivate : public AbstractMediaStreamPrivate -{ - P_DECLARE_PUBLIC(IODeviceStream) - protected: - IODeviceStreamPrivate(QIODevice *_ioDevice) - : ioDevice(_ioDevice) - { - if (!ioDevice->isOpen()) { - ioDevice->open(QIODevice::ReadOnly); - } - Q_ASSERT(ioDevice->isOpen()); - Q_ASSERT(ioDevice->isReadable()); - streamSize = ioDevice->size(); - streamSeekable = !ioDevice->isSequential(); - } - - private: - QIODevice *ioDevice; -}; - -IODeviceStream::IODeviceStream(QIODevice *ioDevice, QObject *parent) - : AbstractMediaStream(*new IODeviceStreamPrivate(ioDevice), parent) -{ - Q_D(IODeviceStream); - d->ioDevice->reset(); -} - -IODeviceStream::~IODeviceStream() -{ -} - -void IODeviceStream::reset() -{ - Q_D(IODeviceStream); - d->ioDevice->reset(); -} - -void IODeviceStream::needData() -{ - quint32 size = 4096; - Q_D(IODeviceStream); - const QByteArray data = d->ioDevice->read(size); - writeData(data); - if (d->ioDevice->atEnd()) { - endOfData(); - } -} - -void IODeviceStream::seekStream(qint64 offset) -{ - Q_D(IODeviceStream); - d->ioDevice->seek(offset); -} - -} // namespace Phonon - -#endif //QT_NO_PHONON_ABSTRACTMEDIASTREAM - -#include "moc_iodevicestream_p.h" - -// vim: sw=4 sts=4 et tw=100 diff --git a/src/phonon/iodevicestream_p.h b/src/phonon/iodevicestream_p.h deleted file mode 100644 index 4b7274bed..000000000 --- a/src/phonon/iodevicestream_p.h +++ /dev/null @@ -1,54 +0,0 @@ -/* This file is part of the KDE project - Copyright (C) 2007 Matthias Kretz - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), Nokia Corporation - (or its successors, if any) and the KDE Free Qt Foundation, which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . - -*/ - -#ifndef PHONON_IODEVICESTREAM_P_H -#define PHONON_IODEVICESTREAM_P_H - -#include "abstractmediastream.h" - - -#ifndef QT_NO_PHONON_ABSTRACTMEDIASTREAM - -class QIODevice; - -namespace Phonon -{ - -class IODeviceStreamPrivate; -class IODeviceStream : public AbstractMediaStream -{ - Q_OBJECT - Q_DECLARE_PRIVATE(IODeviceStream) - public: - explicit IODeviceStream(QIODevice *ioDevice, QObject *parent = 0); - ~IODeviceStream(); - - void reset(); - void needData(); - void seekStream(qint64); -}; -} // namespace Phonon - -#endif //QT_NO_PHONON_ABSTRACTMEDIASTREAM - - -#endif // PHONON_IODEVICESTREAM_P_H diff --git a/src/phonon/mediacontroller.cpp b/src/phonon/mediacontroller.cpp deleted file mode 100644 index fa181ef18..000000000 --- a/src/phonon/mediacontroller.cpp +++ /dev/null @@ -1,346 +0,0 @@ -/* - Copyright (C) 2007 Matthias Kretz - Copyright (C) 2008 Ian Monroe - Copyright (C) 2011 Harald Sitter - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), Nokia Corporation - (or its successors, if any) and the KDE Free Qt Foundation, which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . - -*/ - -#include "mediacontroller.h" -#include "mediaobject.h" -#include "addoninterface.h" -#include -#include -#include -#include -#include "frontendinterface_p.h" - -#ifndef QT_NO_PHONON_MEDIACONTROLLER - -namespace Phonon -{ - -class MediaControllerPrivate : public FrontendInterfacePrivate -{ - public: - MediaControllerPrivate(MediaObject *mp) : FrontendInterfacePrivate(mp) {} - - virtual void backendObjectChanged(QObject *); - MediaController *q; -}; - -MediaController::MediaController(MediaObject *mp) - : QObject(mp) - , d(new MediaControllerPrivate(mp)) -{ - d->q = this; - d->_backendObjectChanged(); - setSubtitleAutodetect(true); -} - -void MediaControllerPrivate::backendObjectChanged(QObject *m_backendObject) -{ - QObject::connect(m_backendObject, SIGNAL(availableSubtitlesChanged()), q, SIGNAL(availableSubtitlesChanged())); - QObject::connect(m_backendObject, SIGNAL(availableAudioChannelsChanged()), q, SIGNAL(availableAudioChannelsChanged())); - QObject::connect(m_backendObject, SIGNAL(titleChanged(int)), q, SIGNAL(titleChanged(int))); - QObject::connect(m_backendObject, SIGNAL(availableTitlesChanged(int)), q, SIGNAL(availableTitlesChanged(int))); - QObject::connect(m_backendObject, SIGNAL(chapterChanged(int)), q, SIGNAL(chapterChanged(int))); - QObject::connect(m_backendObject, SIGNAL(availableChaptersChanged(int)), q, SIGNAL(availableChaptersChanged(int))); - QObject::connect(m_backendObject, SIGNAL(angleChanged(int)), q, SIGNAL(angleChanged(int))); - QObject::connect(m_backendObject, SIGNAL(availableAnglesChanged(int)), q, SIGNAL(availableAnglesChanged(int))); -} - -MediaController::~MediaController() -{ - delete d; -} - -#define IFACE \ - AddonInterface *iface = d->iface(); \ - if (!iface) return - -MediaController::Features MediaController::supportedFeatures() const -{ - if (!d || !d->media) { - return Features(); - } - IFACE Features(); - Features ret; - if (iface->hasInterface(AddonInterface::AngleInterface)) { - ret |= Angles; - } - if (iface->hasInterface(AddonInterface::ChapterInterface)) { - ret |= Chapters; - } - if (iface->hasInterface(AddonInterface::NavigationInterface)) { - ret |= Navigations; - } - if (iface->hasInterface(AddonInterface::TitleInterface)) { - ret |= Titles; - } - if (iface->hasInterface(AddonInterface::SubtitleInterface)) { - ret |= Subtitles; - } - if(iface->hasInterface(AddonInterface::AudioChannelInterface)) { - ret |= AudioChannels; - } - return ret; -} - -// -- Angle Control -- // - -int MediaController::availableAngles() const -{ - IFACE 0; - return iface->interfaceCall(AddonInterface::AngleInterface, - AddonInterface::availableAngles).toInt(); -} - -int MediaController::currentAngle() const -{ - IFACE 0; - return iface->interfaceCall(AddonInterface::AngleInterface, - AddonInterface::angle).toInt(); -} - -void MediaController::setCurrentAngle(int titleNumber) -{ - IFACE; - iface->interfaceCall(AddonInterface::AngleInterface, - AddonInterface::setAngle, QList() << QVariant(titleNumber)); -} - -// -- Chapter Control -- // - -int MediaController::availableChapters() const -{ - IFACE 0; - return iface->interfaceCall(AddonInterface::ChapterInterface, - AddonInterface::availableChapters).toInt(); -} - -int MediaController::currentChapter() const -{ - IFACE 0; - return iface->interfaceCall(AddonInterface::ChapterInterface, - AddonInterface::chapter).toInt(); -} - -void MediaController::setCurrentChapter(int titleNumber) -{ - IFACE; - iface->interfaceCall(AddonInterface::ChapterInterface, - AddonInterface::setChapter, QList() << QVariant(titleNumber)); -} - -// -- Navigation Menu Control -- // - -QString MediaController::navigationMenuToString(NavigationMenu menu) -{ - switch (menu) { - case RootMenu: - return tr("Main Menu"); - case TitleMenu : - return tr("Title Menu"); - case AudioMenu: - return tr("Audio Menu"); - case SubtitleMenu: - return tr("Subtitle Menu"); - case ChapterMenu: - return tr("Chapter Menu"); - case AngleMenu: - return tr("Angle Menu"); - } - return QString(); -} - -QList MediaController::availableMenus() const -{ - QList menus; - IFACE menus; - menus = - iface->interfaceCall(AddonInterface::NavigationInterface, - AddonInterface::availableMenus).value< QList >(); - - return menus; -} - -void MediaController::setCurrentMenu(NavigationMenu menu) -{ - IFACE; - iface->interfaceCall(AddonInterface::NavigationInterface, - AddonInterface::setMenu, QList() << QVariant::fromValue(menu)); -} -// -- Title Control -- // - -int MediaController::availableTitles() const -{ - IFACE 0; - return iface->interfaceCall(AddonInterface::TitleInterface, - AddonInterface::availableTitles).toInt(); -} - -int MediaController::currentTitle() const -{ - IFACE 0; - return iface->interfaceCall(AddonInterface::TitleInterface, - AddonInterface::title).toInt(); -} - -void MediaController::setCurrentTitle(int titleNumber) -{ - IFACE; - iface->interfaceCall(AddonInterface::TitleInterface, - AddonInterface::setTitle, QList() << QVariant(titleNumber)); -} - -bool MediaController::autoplayTitles() const -{ - IFACE true; - return iface->interfaceCall(AddonInterface::TitleInterface, - AddonInterface::autoplayTitles).toBool(); -} - -void MediaController::setAutoplayTitles(bool b) -{ - IFACE; - iface->interfaceCall(AddonInterface::TitleInterface, - AddonInterface::setAutoplayTitles, QList() << QVariant(b)); -} - -void MediaController::nextTitle() -{ - setCurrentTitle(currentTitle() + 1); -} - -void MediaController::previousTitle() -{ - setCurrentTitle(currentTitle() - 1); -} - -// -- Audio Channel & Subtitle Control -- // - -AudioChannelDescription MediaController::currentAudioChannel() const -{ - IFACE AudioChannelDescription(); - return iface->interfaceCall(AddonInterface::AudioChannelInterface, - AddonInterface::currentAudioChannel).value(); -} - -bool MediaController::subtitleAutodetect() const -{ - IFACE true; - return iface->interfaceCall(AddonInterface::SubtitleInterface, - AddonInterface::subtitleAutodetect).toBool(); -} - -void MediaController::setSubtitleAutodetect(bool enable) -{ - IFACE; - iface->interfaceCall(AddonInterface::SubtitleInterface, - AddonInterface::setSubtitleAutodetect, QList() << QVariant(enable)); -} - -QString MediaController::subtitleEncoding() const -{ - IFACE QString(); - return iface->interfaceCall(AddonInterface::SubtitleInterface, - AddonInterface::subtitleEncoding).toString(); -} - -void MediaController::setSubtitleEncoding(const QString &encoding) -{ - IFACE; - if (!QTextCodec::availableCodecs().contains(encoding.toLocal8Bit())) - return; - iface->interfaceCall(AddonInterface::SubtitleInterface, - AddonInterface::setSubtitleEncoding, QList() << QVariant(encoding)); -} - -void MediaController::setSubtitleFont(const QFont &font) -{ - IFACE; - iface->interfaceCall(AddonInterface::SubtitleInterface, - AddonInterface::setSubtitleFont, QList() << QVariant(font)); -} - -QFont MediaController::subtitleFont() const -{ - IFACE QFont(); - return iface->interfaceCall(AddonInterface::SubtitleInterface, - AddonInterface::subtitleFont).value(); -} - -SubtitleDescription MediaController::currentSubtitle() const -{ - IFACE SubtitleDescription(); - return iface->interfaceCall(AddonInterface::SubtitleInterface, - AddonInterface::currentSubtitle).value(); -} - -QList MediaController::availableAudioChannels() const -{ - QList retList; - IFACE retList; - retList = iface->interfaceCall(AddonInterface::AudioChannelInterface, - AddonInterface::availableAudioChannels).value< QList >(); - return retList; -} - -QList MediaController::availableSubtitles() const -{ - QList retList; - IFACE retList; - retList = iface->interfaceCall(AddonInterface::SubtitleInterface, - AddonInterface::availableSubtitles) - .value< QList >(); - return retList; -} - -void MediaController::setCurrentAudioChannel(const Phonon::AudioChannelDescription &stream) -{ - IFACE; - iface->interfaceCall(AddonInterface::AudioChannelInterface, - AddonInterface::setCurrentAudioChannel, QList() << qVariantFromValue(stream)); -} - -void MediaController::setCurrentSubtitle(const Phonon::SubtitleDescription &stream) -{ - IFACE; - iface->interfaceCall(AddonInterface::SubtitleInterface, - AddonInterface::setCurrentSubtitle, QList() << qVariantFromValue(stream)); -} - -void MediaController::setCurrentSubtitle(const QUrl &url) -{ - IFACE; - iface->interfaceCall(AddonInterface::SubtitleInterface, - AddonInterface::setCurrentSubtitleFile, QList() << url); -} - -#undef IFACE - -} // namespace Phonon - -#endif //QT_NO_PHONON_MEDIACONTROLLER - -#include "moc_mediacontroller.cpp" - -// vim: sw=4 sts=4 et tw=100 -#include "moc_mediacontroller.h" diff --git a/src/phonon/mediacontroller.h b/src/phonon/mediacontroller.h deleted file mode 100644 index 053e5efcb..000000000 --- a/src/phonon/mediacontroller.h +++ /dev/null @@ -1,385 +0,0 @@ -/* - Copyright (C) 2007 Matthias Kretz - Copyright (C) 2011 Harald Sitter - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), Nokia Corporation - (or its successors, if any) and the KDE Free Qt Foundation, which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . - -*/ - -#ifndef PHONON_MEDIACONTROLLER_H -#define PHONON_MEDIACONTROLLER_H - -#include "phonon_export.h" -#include "objectdescription.h" - -#include -#include - - -#ifndef QT_NO_PHONON_MEDIACONTROLLER - -namespace Phonon -{ -class MediaControllerPrivate; -class MediaObject; - -/** \class MediaController mediacontroller.h phonon/MediaController - * \brief Controls optional features of a media file/device like title, chapter, angle. - * - * \ingroup Playback - * \author Matthias Kretz - */ -class PHONON_EXPORT MediaController : public QObject -{ - Q_OBJECT - Q_FLAGS(Features) - public: - enum Feature { - /** - * In the VOB (DVD) format, it is possible to give several video streams - * of the same scene, each of which displays the scene from a different - * angle. The DVD viewer can then change between these angles. - */ - Angles = 1, - /** - * In the VOB format, chapters are points in a single video stream - * that can be played and seeked to separately. - */ - Chapters = 2, - /** - * In the VOB format, navigations are menus to quickly navigate - * to content. - */ - Navigations = 3, - /** - * On a CD, a title is a separate sound track. On DVD, a title is a - * separate VOB file (i.e. usually a different video entity). - */ - Titles = 4, - /** - * Subtitles for videos. - */ - Subtitles = 5, - /** - * Audio channel/track setting for sources with multiple tracks. - * This can be a DVD or a regular file based container such as MKV or MP4. - */ - AudioChannels = 6 - }; - Q_DECLARE_FLAGS(Features, Feature) - - enum NavigationMenu { - RootMenu, /** < Root/main menu. */ - TitleMenu, /** < Title Menu to access different titles on the media source. - The title menu is usually where one would select - the episode of a TV series DVD. It can be equal to - the main menu but does not need to be. */ - AudioMenu, /** < Audio menu for language (and somtimes also subtitle) - settings etc. */ - SubtitleMenu, /** < Subtitle menu. Usually this represents the same menu - as AudioMenu or is not present at all (in which case - subtitle settings are propably also in the AudioMenu). */ - ChapterMenu, /** < Chapter menu for chapter selection. */ - AngleMenu /** < Angle menu. Rarely supported on any media source. */ - }; - - MediaController(MediaObject *parent); - ~MediaController(); - - Features supportedFeatures() const; - - int availableAngles() const; - int currentAngle() const; - - int availableChapters() const; - int currentChapter() const; - - /** - * Translates a NavigationMenu enum to a string you can use in your GUI. - * Please note that keyboard shortucts will not be present in the returned - * String, therefore it is probably not a good idea to use this function - * if you are providing keyboard shortcuts for every other clickable. - * - * Please note that RootMenu has the string representation "Main Menu" as - * root is a rather technical term when talking about menus. - * - * Example: - * \code - * QString s = Phonon::MediaController::navigationMenuToString(MenuMain); - * // s now contains "Main Menu" - * \endcode - * - * \returns the QString representation of the menu - */ - static QString navigationMenuToString(NavigationMenu menu); - - /** - * Get the list of currently available menus for the present media source. - * - * The list is always ordered by occurrence in the NavgiationMenu enum. - * Should you wish to use a different order in your application you will - * have to make appropriate changes. - * - * \returns list of available menus (supported by backend and media source). - * - * \see navigationMenuToString() - */ - QList availableMenus() const; - - int availableTitles() const; - int currentTitle() const; - - bool autoplayTitles() const; - - /** - * Returns the selected audio stream. - * - * \see availableAudioChannels - * \see setCurrentAudioChannel - */ - AudioChannelDescription currentAudioChannel() const; - - /** - * Returns the selected subtitle stream. - * - * \see availableSubtitles - * \see setCurrentSubtitle - */ - SubtitleDescription currentSubtitle() const; - - /** - * Subtitle auto-detection transparently tries to find a subtitle file - * for the current MediaSource and will automatically select a possible - * match. Detected subtitles are added to the regular subtitle - * descriptions, allowing the user to deactivate it manually or switch - * to another detected file. - * - * Matching method depends on the backend in use and may either be - * driven by a backend or even subsystem implementation. Consequently - * different backends may not give the same results. At any rate all - * algorithms are supposed to give as accurate as possible matches. - * Should you require reproducible matching across backends you should - * deactivate auto-detection entirely and instead do the lookup yourself - * and set the desired file using setCurrentSubtitle(QUrl); the file - * will still be added to the subtitledescriptions model. - * - * \note Auto-detection is always activate so long as the backend supports it. - * - * \returns \c true if subtitles are autodetected, otherwise \c false is - * returned. - * - * \see setSubtitleAutodetect - * \since 4.7.0 - */ - bool subtitleAutodetect() const; - - /** - * Returns the encoding used to render subtitles - * - * \see setSubtitleEncoding - * \since 4.7.0 - */ - QString subtitleEncoding() const; - - /** - * Returns the font used to render subtitles - * - * \see setSubtitleFont - * \see QApplication::setFont - * \since 4.7.0 - */ - QFont subtitleFont() const; - - /** - * Returns the audio streams that can be selected by the user. The - * strings can directly be used in the user interface. - * - * \see selectedAudioChannel - * \see setCurrentAudioChannel - */ - QList availableAudioChannels() const; - - /** - * Returns the subtitle streams that can be selected by the user. The - * strings can directly be used in the user interface. - * - * \see selectedSubtitle - * \see setCurrentSubtitle - */ - QList availableSubtitles() const; - - /** - * Selects an audio stream from the media. - * - * Some media formats allow multiple audio streams to be stored in - * the same file. Normally only one should be played back. - * - * \param stream Description of an audio stream - * - * \see availableAudioChannels() - * \see currentAudioChannel() - */ - void setCurrentAudioChannel(const Phonon::AudioChannelDescription &stream); - - /** - * Switches to a menu (e.g. on a DVD). - * - * \see availableMenus() - */ - void setCurrentMenu(NavigationMenu menu); - - /** - * Selects a subtitle stream from the media. - * - * Some media formats allow multiple subtitle streams to be stored in - * the same file. Normally only one should be displayed. - * - * \param stream description of a subtitle stream - * - * \see availableSubtitles() - * \see currentSubtitle() - */ - void setCurrentSubtitle(const Phonon::SubtitleDescription &stream); - - /** - * \brief Selects a subtitle file as subtitle source for the media. - * - * \note The file will also be added to the model of SubtitleDescriptions, - * so you do not need special handling in the UI. - * - * \see setCurrentSubtitle(const Phonon::SubtitleDescription &stream) - */ - void setCurrentSubtitle(const QUrl &url); - - /** - * Sets/Unsets subtitles autodetection. - * - * Detection is attempted when moving the MediaObject into Playing state. - * In order to enable/disable autodetection it must be set before play() - * is called. Whether a MediaSource is set on the MediaObject does not - * matter, and once detection is set it will remain set that way for - * this exact combination of MediaController and MediaObject. - * - * \note The subtitle autodetection may only be changed in states other - * than Playing | Buffering | Paused. - * - * \see subtitleAutodetect - * \since 4.7.0 - */ - void setSubtitleAutodetect(bool enable); - - /** - * Selects the current encoding used to render subtitles. - * - * The encoding name must respect the - * @link http://www.iana.org/assignments/character-sets - * Link text IANA character-sets encoding file @endlink - * If no encoding is explicitly set, it defaults to UTF-8. - * - * \note The subtitle encoding may only be changed in states other - * than Playing | Buffering | Paused. - * \note Decoding support may vary between backends. - * - * \see subtitleEncoding - * \since 4.7.0 - */ - void setSubtitleEncoding(const QString &encoding); - - /** - * Selects the current font used to render subtitles. - * - * If no font is explicitly set, the system default font is used. - * - * \note The subtitle font may only be changed in states other - * than Playing | Buffering | Paused. - * \note Non-system fonts can not be used. In particular adding - * fonts manually to the QFontDatabase will not make them - * available as render fonts. - * - * \see subtitleFont - * \since 4.7.0 - */ - void setSubtitleFont(const QFont &font); - - public Q_SLOTS: - void setCurrentAngle(int angleNumber); - void setCurrentChapter(int chapterNumber); - - /** - * Skips to the given title \p titleNumber. - * - * If it was playing before the title change it will start playback on the new title if - * autoplayTitles is enabled. - */ - void setCurrentTitle(int titleNumber); - void setAutoplayTitles(bool); - - /** - * Skips to the next title. - * - * If it was playing before the title change it will start playback on the next title if - * autoplayTitles is enabled. - */ - void nextTitle(); - - /** - * Skips to the previous title. - * - * If it was playing before the title change it will start playback on the previous title if - * autoplayTitles is enabled. - */ - void previousTitle(); - - Q_SIGNALS: - void availableAnglesChanged(int availableAngles); - void availableAudioChannelsChanged(); - void availableChaptersChanged(int availableChapters); - - /** - * The available menus changed, this for example emitted when Phonon switches - * from a media source without menus to one with menus (e.g. a DVD). - * - * \param menus is a list of all currently available menus, you should update - * GUI representations of the available menus with the new set. - * - * \see availableMenus() - * \see navigationMenuToString() - */ - void availableMenusChanged(QList menus); - void availableSubtitlesChanged(); - void availableTitlesChanged(int availableTitles); - - void angleChanged(int angleNumber); - void chapterChanged(int chapterNumber); - void titleChanged(int titleNumber); - - protected: - MediaControllerPrivate *const d; -}; - -} // namespace Phonon - -Q_DECLARE_OPERATORS_FOR_FLAGS(Phonon::MediaController::Features) - -Q_DECLARE_METATYPE(Phonon::MediaController::NavigationMenu) -Q_DECLARE_METATYPE(QList) - -#endif //QT_NO_PHONON_MEDIACONTROLLER - - -#endif // PHONON_MEDIACONTROLLER_H diff --git a/src/phonon/medianode.cpp b/src/phonon/medianode.cpp deleted file mode 100644 index cc90632ad..000000000 --- a/src/phonon/medianode.cpp +++ /dev/null @@ -1,126 +0,0 @@ -/* This file is part of the KDE project - Copyright (C) 2007 Matthias Kretz - Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), Nokia Corporation - (or its successors, if any) and the KDE Free Qt Foundation, which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . - -*/ - -#include "medianode.h" -#include "medianode_p.h" -#include "medianodedestructionhandler_p.h" -#include "factory_p.h" - -namespace Phonon -{ - - MediaNode::MediaNode(MediaNodePrivate &dd) - : k_ptr(&dd) - { - k_ptr->q_ptr = this; - } - -bool MediaNode::isValid() const -{ - return const_cast(k_ptr)->backendObject() != 0; -} - - QList MediaNode::inputPaths() const - { - return k_ptr->inputPaths; - } - - QList MediaNode::outputPaths() const - { - return k_ptr->outputPaths; - } - - MediaNode::~MediaNode() - { - delete k_ptr; - } - - QObject *MediaNodePrivate::backendObject() - { - if (!m_backendObject && Factory::backend()) { - createBackendObject(); - } - return m_backendObject; - } - - MediaNodePrivate::~MediaNodePrivate() - { - for (int i = 0 ; i < handlers.count(); ++i) { - handlers.at(i)->phononObjectDestroyed(this); - } - Factory::deregisterFrontendObject(this); - delete m_backendObject; - m_backendObject = 0; - } - -void MediaNodePrivate::deleteBackendObject() -{ - if (m_backendObject && aboutToDeleteBackendObject()) { - delete m_backendObject; - m_backendObject = 0; - } -} - - MediaNodePrivate::MediaNodePrivate(MediaNodePrivate::CastId _castId) : castId(_castId), - m_backendObject(0) - { - Factory::registerFrontendObject(this); - } - - void MediaNodePrivate::addDestructionHandler(MediaNodeDestructionHandler *handler) - { - handlers.append(handler); - } - - void MediaNodePrivate::removeDestructionHandler(MediaNodeDestructionHandler *handler) - { - handlers.removeAll(handler); - } - - void MediaNodePrivate::addOutputPath(const Path &p) - { - outputPaths.append(p); - } - - void MediaNodePrivate::addInputPath(const Path &p) - { - inputPaths.append(p); - } - - void MediaNodePrivate::removeOutputPath(const Path &p) - { - int ret = outputPaths.removeAll(p); - Q_ASSERT(ret == 1); - Q_UNUSED(ret); - } - - void MediaNodePrivate::removeInputPath(const Path &p) - { - int ret = inputPaths.removeAll(p); - Q_ASSERT(ret == 1); - Q_UNUSED(ret); - } - - - -} // namespace Phonon diff --git a/src/phonon/medianode.h b/src/phonon/medianode.h deleted file mode 100644 index 496e6019f..000000000 --- a/src/phonon/medianode.h +++ /dev/null @@ -1,65 +0,0 @@ -/* This file is part of the KDE project - Copyright (C) 2007 Matthias Kretz - Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), Nokia Corporation - (or its successors, if any) and the KDE Free Qt Foundation, which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . - -*/ - -#ifndef PHONON_MEDIANODE_H -#define PHONON_MEDIANODE_H - -#include "phonondefs.h" -#include "phonon_export.h" -#include "path.h" - - -namespace Phonon -{ - - class Path; - class MediaNodePrivate; - class PHONON_EXPORT MediaNode - { - friend class Path; - friend class PathPrivate; - friend PHONON_EXPORT Path createPath(MediaNode *source, MediaNode *sink); - P_DECLARE_PRIVATE(MediaNode) - public: - virtual ~MediaNode(); - /** - * Tells whether the backend provides an implementation of this - * class. - * - * \return \c true if backend provides an implementation - * \return \c false if the object is not implemented by the backend - */ - bool isValid() const; - - QList inputPaths() const; - QList outputPaths() const; - - protected: - MediaNode(MediaNodePrivate &dd); - MediaNodePrivate *const k_ptr; - }; - -} // namespace Phonon - - -#endif // PHONON_MEDIANODE_H diff --git a/src/phonon/medianode_p.h b/src/phonon/medianode_p.h deleted file mode 100644 index c43aa536e..000000000 --- a/src/phonon/medianode_p.h +++ /dev/null @@ -1,143 +0,0 @@ -/* This file is part of the KDE project -Copyright (C) 2007 Matthias Kretz - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), Nokia Corporation - (or its successors, if any) and the KDE Free Qt Foundation, which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . - -*/ - -#ifndef PHONON_MEDIANODE_P_H -#define PHONON_MEDIANODE_P_H - -#include -#include -#include - -#include "path.h" -#include "phononpimpl_p.h" -#include "phonon_export.h" - -class QObject; - -namespace Phonon -{ - class MediaNode; - class MediaNodeDestructionHandler; - - class PHONON_EXPORT MediaNodePrivate - { - P_DECLARE_PUBLIC(MediaNode) - - friend class AudioOutputPrivate; - friend class FactoryPrivate; - - protected: - enum CastId { - MediaNodePrivateType, - AbstractAudioOutputPrivateType, - AudioOutputType - }; - public: - /** - * Returns the backend object. If the object does not exist it tries to - * create it before returning. - * - * \return the Iface object, might return \c 0 - */ - QObject *backendObject(); - - const CastId castId; - - protected: - MediaNodePrivate(CastId _castId = MediaNodePrivateType); - - virtual ~MediaNodePrivate(); - - /** - * \internal - * This method cleanly deletes the Iface object. It is called on - * destruction and before a backend change. - */ - void deleteBackendObject(); - - virtual bool aboutToDeleteBackendObject() = 0; - - /** - * \internal - * Creates the Iface object belonging to this class. For most cases the - * implementation is - * \code - * Q_Q(ClassName); - * m_iface = Factory::createClassName(this); - * return m_iface; - * \endcode - * - * This function should not be called except from slotCreateIface. - * - * \see slotCreateIface - */ - virtual void createBackendObject() = 0; - - public: - /** - * \internal - * This class has its own destroyed signal since some cleanup calls - * need the pointer to the backend object intact. The - * QObject::destroyed signals comes after the backend object was - * deleted. - * - * As this class cannot derive from QObject a simple handler - * interface is used. - */ - void addDestructionHandler(MediaNodeDestructionHandler *handler); - - /** - * \internal - * This class has its own destroyed signal since some cleanup calls - * need the pointer to the backend object intact. The - * QObject::destroyed signals comes after the backend object was - * deleted. - * - * As this class cannot derive from QObject a simple handler - * interface is used. - */ - void removeDestructionHandler(MediaNodeDestructionHandler *handler); - - void addOutputPath(const Path &); - void addInputPath(const Path &); - void removeOutputPath(const Path &); - void removeInputPath(const Path &); - - const QObject *qObject() const { return const_cast(this)->qObject(); } - virtual QObject *qObject() { return 0; } - - protected: - MediaNode *q_ptr; - public: - QObject *m_backendObject; - protected: - QList outputPaths; - QList inputPaths; - - private: - QList handlers; - Q_DISABLE_COPY(MediaNodePrivate) - }; - -} // namespace Phonon - -#endif // PHONON_MEDIANODE_P_H diff --git a/src/phonon/medianodedestructionhandler_p.h b/src/phonon/medianodedestructionhandler_p.h deleted file mode 100644 index 8a3471576..000000000 --- a/src/phonon/medianodedestructionhandler_p.h +++ /dev/null @@ -1,58 +0,0 @@ -/* This file is part of the KDE project - Copyright (C) 2006 Matthias Kretz - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), Nokia Corporation - (or its successors, if any) and the KDE Free Qt Foundation, which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . - -*/ - -#ifndef MEDIANODEDESTRUCTIONHANDLER_P_H -#define MEDIANODEDESTRUCTIONHANDLER_P_H - -#include - - -namespace Phonon -{ -/** - * \internal - * - * Callback interface to keep track of Phonon frontend object destruction. - * - * \author Matthias Kretz - */ - -class MediaNodePrivate; - -class MediaNodeDestructionHandler -{ - friend class MediaNodePrivate; - -public: - virtual ~MediaNodeDestructionHandler() {} -protected: - /** - * \internal - * called from Base::~Base if this object was registered - * using BasePrivate::addDestructionHandler(). - */ - virtual void phononObjectDestroyed(MediaNodePrivate *) = 0; -}; -} - - -#endif // MEDIANODEDESTRUCTIONHANDLER_P_H diff --git a/src/phonon/mediaobject.cpp b/src/phonon/mediaobject.cpp deleted file mode 100644 index d8b858fb6..000000000 --- a/src/phonon/mediaobject.cpp +++ /dev/null @@ -1,787 +0,0 @@ -/* This file is part of the KDE project - Copyright (C) 2005-2007 Matthias Kretz - Copyright (C) 2011 Trever Fischer - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), Nokia Corporation - (or its successors, if any) and the KDE Free Qt Foundation, which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . - -*/ -#include "mediaobject.h" -#include "mediaobject_p.h" - -#include "factory_p.h" -#include "mediaobjectinterface.h" -#include "audiooutput.h" -#include "phonondefs_p.h" -#include "abstractmediastream.h" -#include "abstractmediastream_p.h" -#include "frontendinterface_p.h" - -#include -#include -#include -#include -#include - -#ifdef HAVE_QZEITGEIST -#include -#include -#include -#include -#include -#endif - -#include "phononnamespace_p.h" -#include "platform_p.h" -#include "statesvalidator_p.h" - -#ifndef PHONON_NO_GRAPHICSVIEW -#include -#endif - -#define PHONON_CLASSNAME MediaObject -#define PHONON_INTERFACENAME MediaObjectInterface - -namespace Phonon -{ -PHONON_OBJECT_IMPL - -MediaObject::~MediaObject() -{ - P_D(MediaObject); - if (d->m_backendObject) { - switch (state()) { - case PlayingState: - case BufferingState: - case PausedState: - stop(); - break; - case ErrorState: - case StoppedState: - case LoadingState: - break; - } - } -} - -Phonon::State MediaObject::state() const -{ - P_D(const MediaObject); -#ifndef QT_NO_PHONON_ABSTRACTMEDIASTREAM - if (d->errorOverride) { - return d->state; - } - if (d->ignoreLoadingToBufferingStateChange) { - return BufferingState; - } - if (d->ignoreErrorToLoadingStateChange) { - return LoadingState; - } -#endif // QT_NO_PHONON_ABSTRACTMEDIASTREAM - if (!d->m_backendObject) { - return d->state; - } - return INTERFACE_CALL(state()); -} - -PHONON_INTERFACE_SETTER(setTickInterval, tickInterval, qint32) -PHONON_INTERFACE_GETTER(qint32, tickInterval, d->tickInterval) -PHONON_INTERFACE_GETTER(bool, hasVideo, false) -PHONON_INTERFACE_GETTER(bool, isSeekable, false) -PHONON_INTERFACE_GETTER(qint64, currentTime, d->currentTime) - -static inline bool isPlayable(const MediaSource::Type t) -{ - return t != MediaSource::Invalid && t != MediaSource::Empty; -} - -void MediaObject::play() -{ - P_D(MediaObject); - if (d->backendObject() && isPlayable(d->mediaSource.type())) { - - #ifndef PHONON_NO_GRAPHICSVIEW - VideoGraphicsObject *vgo = 0; - foreach (const Path &path, d->outputPaths) { - if (vgo = dynamic_cast(path.sink())) { - // Play() is delayed until we had a paint event. - if (!vgo->canNegotiate()) { - pWarning() << "VideoGraphicsObject not ready to be played because it has not received a paint() call yet, delaying playback."; - connect(vgo, SIGNAL(gotPaint()), this, SLOT(play())); - return; - } - } - } - #endif - - INTERFACE_CALL(play()); - } -} - -void MediaObject::pause() -{ - P_D(MediaObject); - if (d->backendObject() && isPlayable(d->mediaSource.type())) { - INTERFACE_CALL(pause()); - } -} - -void MediaObject::stop() -{ - P_D(MediaObject); - if (d->backendObject() && isPlayable(d->mediaSource.type())) { - INTERFACE_CALL(stop()); - } -} - -void MediaObject::seek(qint64 time) -{ - P_D(MediaObject); - if (d->backendObject() && isPlayable(d->mediaSource.type())) { - INTERFACE_CALL(seek(time)); - } -} - -QString MediaObject::errorString() const -{ - if (state() == Phonon::ErrorState) { - P_D(const MediaObject); -#ifndef QT_NO_PHONON_ABSTRACTMEDIASTREAM - if (d->errorOverride) { - return d->errorString; - } -#endif // QT_NO_PHONON_ABSTRACTMEDIASTREAM - return INTERFACE_CALL(errorString()); - } - return QString(); -} - -ErrorType MediaObject::errorType() const -{ - if (state() == Phonon::ErrorState) { - P_D(const MediaObject); -#ifndef QT_NO_PHONON_ABSTRACTMEDIASTREAM - if (d->errorOverride) { - return d->errorType; - } -#endif // QT_NO_PHONON_ABSTRACTMEDIASTREAM - return INTERFACE_CALL(errorType()); - } - return Phonon::NoError; -} - -QStringList MediaObject::metaData(Phonon::MetaData f) const -{ - switch (f) { - case ArtistMetaData: - return metaData(QLatin1String("ARTIST")); - case AlbumMetaData: - return metaData(QLatin1String("ALBUM")); - case TitleMetaData: - return metaData(QLatin1String("TITLE")); - case DateMetaData: - return metaData(QLatin1String("DATE")); - case GenreMetaData: - return metaData(QLatin1String("GENRE")); - case TracknumberMetaData: - return metaData(QLatin1String("TRACKNUMBER")); - case DescriptionMetaData: - return metaData(QLatin1String("DESCRIPTION")); - case MusicBrainzDiscIdMetaData: - return metaData(QLatin1String("MUSICBRAINZ_DISCID")); - } - return QStringList(); -} - -QStringList MediaObject::metaData(const QString &key) const -{ - P_D(const MediaObject); - return d->metaData.values(key); -} - -QMultiMap MediaObject::metaData() const -{ - P_D(const MediaObject); - return d->metaData; -} - -PHONON_INTERFACE_GETTER(qint32, prefinishMark, d->prefinishMark) -PHONON_INTERFACE_SETTER(setPrefinishMark, prefinishMark, qint32) - -PHONON_INTERFACE_GETTER(qint32, transitionTime, d->transitionTime) -PHONON_INTERFACE_SETTER(setTransitionTime, transitionTime, qint32) - -qint64 MediaObject::totalTime() const -{ - P_D(const MediaObject); - if (!d->m_backendObject) { - return -1; - } - return INTERFACE_CALL(totalTime()); -} - -qint64 MediaObject::remainingTime() const -{ - P_D(const MediaObject); - if (!d->m_backendObject) { - return -1; - } - qint64 ret = INTERFACE_CALL(remainingTime()); - if (ret < 0) { - return -1; - } - return ret; -} - -MediaSource MediaObject::currentSource() const -{ - P_D(const MediaObject); - return d->mediaSource; -} - -void MediaObject::setCurrentSource(const MediaSource &newSource) -{ - P_D(MediaObject); - if (!k_ptr->backendObject()) { - d->mediaSource = newSource; - return; - } - - pDebug() << Q_FUNC_INFO << newSource.type() << newSource.url() << newSource.deviceName(); - - stop(); // first call stop as that often is the expected state - // for setting a new URL - - d->mediaSource = newSource; - -#ifndef QT_NO_PHONON_ABSTRACTMEDIASTREAM - d->abstractStream = 0; // abstractStream auto-deletes - if (d->mediaSource.type() == MediaSource::Stream) { - Q_ASSERT(d->mediaSource.stream()); - d->mediaSource.stream()->d_func()->setMediaObjectPrivate(d); - } -#endif //QT_NO_PHONON_ABSTRACTMEDIASTREAM - - d->playingQueuedSource = false; - - d->sendToZeitgeist(StoppedState); - INTERFACE_CALL(setSource(d->mediaSource)); - d->sendToZeitgeist(); -} - -void MediaObject::clear() -{ - P_D(MediaObject); - d->sourceQueue.clear(); - setCurrentSource(MediaSource()); -} - -QList MediaObject::queue() const -{ - P_D(const MediaObject); - return d->sourceQueue; -} - -void MediaObject::setQueue(const QList &sources) -{ - P_D(MediaObject); - d->sourceQueue.clear(); - enqueue(sources); -} - -void MediaObject::setQueue(const QList &urls) -{ - P_D(MediaObject); - d->sourceQueue.clear(); - enqueue(urls); -} - -void MediaObject::enqueue(const MediaSource &source) -{ - P_D(MediaObject); - if (!isPlayable(d->mediaSource.type())) { - // the current source is nothing valid so this source needs to become the current one - setCurrentSource(source); - } else { - d->sourceQueue << source; - } -} - -void MediaObject::enqueue(const QList &sources) -{ - for (int i = 0; i < sources.count(); ++i) { - enqueue(sources.at(i)); - } -} - -void MediaObject::enqueue(const QList &urls) -{ - for (int i = 0; i < urls.count(); ++i) { - enqueue(urls.at(i)); - } -} - -void MediaObject::clearQueue() -{ - P_D(MediaObject); - d->sourceQueue.clear(); -} - -void MediaObjectPrivate::sendToZeitgeist(const QString &event_interpretation, - const QString &event_manifestation, - const QString &event_actor, - const QDateTime &subject_timestamp, - const QUrl &subject_uri, - const QString &subject_text, - const QString &subject_interpretation, - const QString &subject_manifestation, - const QString &subject_mimetype) -{ -#ifdef HAVE_QZEITGEIST - QZeitgeist::DataModel::Subject subject; - QString url = subject_uri.toString(); - QString path = url.left(url.lastIndexOf(QLatin1Char('/'))); - subject.setUri(url); - subject.setText(subject_text); - subject.setInterpretation(subject_interpretation); - subject.setManifestation(subject_manifestation); - subject.setOrigin(path); - subject.setMimeType(subject_mimetype); - - QZeitgeist::DataModel::SubjectList subjects; - subjects << subject; - - QZeitgeist::DataModel::Event event; - event.setTimestamp(subject_timestamp); - event.setInterpretation(event_interpretation); - event.setManifestation(event_manifestation); - event.setActor(event_actor); - event.setSubjects(subjects); - - QZeitgeist::DataModel::EventList events; - events << event; - - QDBusPendingReply reply = - log->insertEvents(events); -#else - Q_UNUSED(event_interpretation) - Q_UNUSED(event_manifestation) - Q_UNUSED(event_actor) - Q_UNUSED(subject_timestamp) - Q_UNUSED(subject_uri) - Q_UNUSED(subject_text) - Q_UNUSED(subject_interpretation) - Q_UNUSED(subject_manifestation) - Q_UNUSED(subject_mimetype) -#endif -} - -void MediaObjectPrivate::sendToZeitgeist(State eventState) -{ -#ifdef HAVE_QZEITGEIST - P_Q(MediaObject); - if (readyForZeitgeist && q->property("PlaybackTracking").toBool()) { - pDebug() << "Current state:" << eventState; - QString eventInterpretation; - switch (eventState) { - case PlayingState: - eventInterpretation = QZeitgeist::Interpretation::Event::ZGAccessEvent; - break; - case ErrorState: - case StoppedState: - eventInterpretation = QZeitgeist::Interpretation::Event::ZGLeaveEvent; - break; - //These states are not signifigant events. - case LoadingState: - case BufferingState: - case PausedState: - return; - break; - } - - QStringList titles = q->metaData(TitleMetaData); - QStringList artists = q->metaData(ArtistMetaData); - QString title; - if (titles.empty()) { - QString file = mediaSource.url().toString(); - title = file.right(file.length()-file.lastIndexOf("/")-1); - } else { - if (artists.empty()) { - title = titles[0]; - } else { - title = QString(QObject::tr("%0 by %1")).arg(titles[0]).arg(artists[0]); - } - } - pDebug() << "Sending" << title << "to zeitgeist"; - - QString mime; - QString subjectInterpretation; - if (q->hasVideo()) { - subjectInterpretation = QZeitgeist::Interpretation::Subject::NFOVideo; - mime = "video/raw"; - } else { - subjectInterpretation = QZeitgeist::Interpretation::Subject::NFOAudio; - mime = "audio/raw"; - } - pDebug() << "Zeitgeist mime type:" << mime; - pDebug() << "Zeitgeist URL:" << mediaSource.url(); - pDebug() << "mediasource type:" << mediaSource.type(); - - QString subjectType; - switch (mediaSource.type()) { - case MediaSource::Empty: - case MediaSource::Invalid: - return; - case MediaSource::Url: - subjectType = QZeitgeist::Manifestation::Subject::NFORemoteDataObject; - break; - case MediaSource::CaptureDevice: - case MediaSource::Disc: - case MediaSource::Stream: - subjectType = QZeitgeist::Manifestation::Subject::NFOMediaStream; - break; - case MediaSource::LocalFile: - subjectType = QZeitgeist::Manifestation::Subject::NFOFileDataObject; - break; - } - - QString eventManifestation; - if (playingQueuedSource) - eventManifestation = QZeitgeist::Manifestation::Event::ZGScheduledActivity; - else - eventManifestation = QZeitgeist::Manifestation::Event::ZGUserActivity; - - sendToZeitgeist(eventInterpretation, - eventManifestation, - QLatin1Literal("application://" ) % Platform::applicationName() % QLatin1Literal(".desktop"), - QDateTime::currentDateTime(), - mediaSource.url(), - title, - subjectInterpretation, - subjectType, - mime); - } - // Unset this so we don't send it again after a pause+play - readyForZeitgeist = false; - playingQueuedSource = false; -#else - Q_UNUSED(eventState) -#endif -} - -void MediaObjectPrivate::sendToZeitgeist() -{ - P_Q(MediaObject); - sendToZeitgeist(q->state()); -} - -bool MediaObjectPrivate::aboutToDeleteBackendObject() -{ - //pDebug() << Q_FUNC_INFO; - prefinishMark = pINTERFACE_CALL(prefinishMark()); - transitionTime = pINTERFACE_CALL(transitionTime()); - //pDebug() << Q_FUNC_INFO; - if (m_backendObject) { - state = pINTERFACE_CALL(state()); - currentTime = pINTERFACE_CALL(currentTime()); - tickInterval = pINTERFACE_CALL(tickInterval()); - } - return true; -} - -#ifndef QT_NO_PHONON_ABSTRACTMEDIASTREAM -void MediaObjectPrivate::streamError(Phonon::ErrorType type, const QString &text) -{ - P_Q(MediaObject); - State lastState = q->state(); - errorOverride = true; - errorType = type; - errorString = text; - state = ErrorState; - QMetaObject::invokeMethod(q, "stateChanged", Qt::QueuedConnection, Q_ARG(Phonon::State, Phonon::ErrorState), Q_ARG(Phonon::State, lastState)); - //emit q->stateChanged(ErrorState, lastState); -} -#endif //QT_NO_PHONON_ABSTRACTMEDIASTREAM - -// TODO: this needs serious cleanup... -void MediaObjectPrivate::_k_stateChanged(Phonon::State newstate, Phonon::State oldstate) -{ - P_Q(MediaObject); - - // Zeitgeist --------------------------------------------------------------- - if (newstate == StoppedState) { - readyForZeitgeist = true; - } - pDebug() << "State changed from" << oldstate << "to" << newstate << "-> sending to zeitgeist."; - sendToZeitgeist(newstate); - - // AbstractMediaStream fallback stuff -------------------------------------- - if (errorOverride) { - errorOverride = false; - if (newstate == ErrorState) { - return; - } - oldstate = ErrorState; - } - - if (mediaSource.type() != MediaSource::Url) { - // special handling only necessary for URLs because of the fallback - emit q->stateChanged(newstate, oldstate); - return; - } - - // backend MediaObject reached ErrorState, try a KioMediaSource - if (newstate == Phonon::ErrorState && !abstractStream) { - abstractStream = Platform::createMediaStream(mediaSource.url(), q); - if (!abstractStream) { - pDebug() << "backend MediaObject reached ErrorState, no KIO fallback available"; - emit q->stateChanged(newstate, oldstate); - return; - } - pDebug() << "backend MediaObject reached ErrorState, trying Platform::createMediaStream now"; - ignoreLoadingToBufferingStateChange = false; - ignoreErrorToLoadingStateChange = false; - switch (oldstate) { - case Phonon::BufferingState: - // play() has already been called, we need to make sure it is called - // on the backend with the KioMediaStream MediaSource now, too - ignoreLoadingToBufferingStateChange = true; - break; - case Phonon::LoadingState: - ignoreErrorToLoadingStateChange = true; - // no extras - break; - default: - pError() << "backend MediaObject reached ErrorState after " << oldstate - << ". It seems a KioMediaStream will not help here, trying anyway."; - emit q->stateChanged(Phonon::LoadingState, oldstate); - break; - } - abstractStream->d_func()->setMediaObjectPrivate(this); - MediaSource mediaSource(abstractStream); - mediaSource.setAutoDelete(true); - sendToZeitgeist(StoppedState); - pINTERFACE_CALL(setSource(mediaSource)); - sendToZeitgeist(); - if (oldstate == Phonon::BufferingState) { - q->play(); - } - return; - } else if (ignoreLoadingToBufferingStateChange && - abstractStream && - oldstate == Phonon::LoadingState) { - if (newstate != Phonon::BufferingState) { - emit q->stateChanged(newstate, Phonon::BufferingState); - } - return; - } else if (ignoreErrorToLoadingStateChange && abstractStream && oldstate == ErrorState) { - if (newstate != LoadingState) { - emit q->stateChanged(newstate, Phonon::LoadingState); - } - return; - } - - emit q->stateChanged(newstate, oldstate); -} - -void MediaObjectPrivate::_k_aboutToFinish() -{ - P_Q(MediaObject); - pDebug() << Q_FUNC_INFO; - -#ifndef QT_NO_PHONON_ABSTRACTMEDIASTREAM - abstractStream = 0; // abstractStream auto-deletes -#endif //QT_NO_PHONON_ABSTRACTMEDIASTREAM - - if (sourceQueue.isEmpty()) { - emit q->aboutToFinish(); - if (sourceQueue.isEmpty()) { - return; - } - } - - mediaSource = sourceQueue.head(); - readyForZeitgeist = false; - playingQueuedSource = true; - pINTERFACE_CALL(setNextSource(mediaSource)); - - if (validator) - validator->sourceQueued(); -} - -void MediaObjectPrivate::_k_currentSourceChanged(const MediaSource &source) -{ - P_Q(MediaObject); - pDebug() << Q_FUNC_INFO; - - if (!sourceQueue.isEmpty() && sourceQueue.head() == source) - sourceQueue.dequeue(); - - emit q->currentSourceChanged(source); -} - -void MediaObjectPrivate::setupBackendObject() -{ - P_Q(MediaObject); - Q_ASSERT(m_backendObject); - - // Queue *everything* there is. That way the backend always is in a defined state. - // If the signals were not queued, and the backend emitted something mid-execution - // of whatever it is doing, an API consumer works with an undefined state. - // This causes major headaches. If we must enforce implicit execution stop via - // signals, they ought to be done in private slots. - - qRegisterMetaType("MediaSource"); - qRegisterMetaType >("QMultiMap"); - - if (validateStates) - validator = new StatesValidator(q); // Parented, and non-invasive to MO. - -#ifndef QT_NO_PHONON_ABSTRACTMEDIASTREAM - QObject::connect(m_backendObject, SIGNAL(stateChanged(Phonon::State,Phonon::State)), - q, SLOT(_k_stateChanged(Phonon::State,Phonon::State)), Qt::QueuedConnection); -#else - QObject::connect(m_backendObject, SIGNAL(stateChanged(Phonon::State,Phonon::State)), - q, SIGNAL(stateChanged(Phonon::State,Phonon::State)), Qt::QueuedConnection); -#endif // QT_NO_PHONON_ABSTRACTMEDIASTREAM -#ifndef QT_NO_PHONON_VIDEO - QObject::connect(m_backendObject, SIGNAL(hasVideoChanged(bool)), - q, SIGNAL(hasVideoChanged(bool)), Qt::QueuedConnection); -#endif //QT_NO_PHONON_VIDEO - - QObject::connect(m_backendObject, SIGNAL(tick(qint64)), - q, SIGNAL(tick(qint64)), Qt::QueuedConnection); - QObject::connect(m_backendObject, SIGNAL(seekableChanged(bool)), - q, SIGNAL(seekableChanged(bool)), Qt::QueuedConnection); - QObject::connect(m_backendObject, SIGNAL(bufferStatus(int)), - q, SIGNAL(bufferStatus(int)), Qt::QueuedConnection); - QObject::connect(m_backendObject, SIGNAL(finished()), - q, SIGNAL(finished()), Qt::QueuedConnection); - QObject::connect(m_backendObject, SIGNAL(aboutToFinish()), - q, SLOT(_k_aboutToFinish()), Qt::QueuedConnection); - QObject::connect(m_backendObject, SIGNAL(prefinishMarkReached(qint32)), - q, SIGNAL(prefinishMarkReached(qint32)), Qt::QueuedConnection); - QObject::connect(m_backendObject, SIGNAL(totalTimeChanged(qint64)), - q, SIGNAL(totalTimeChanged(qint64)), Qt::QueuedConnection); - QObject::connect(m_backendObject, SIGNAL(metaDataChanged(QMultiMap)), - q, SLOT(_k_metaDataChanged(QMultiMap)), Qt::QueuedConnection); - QObject::connect(m_backendObject, SIGNAL(currentSourceChanged(MediaSource)), - q, SLOT(_k_currentSourceChanged(MediaSource)), Qt::QueuedConnection); - - // set up attributes - pINTERFACE_CALL(setTickInterval(tickInterval)); - pINTERFACE_CALL(setPrefinishMark(prefinishMark)); - pINTERFACE_CALL(setTransitionTime(transitionTime)); - - switch(state) - { - case LoadingState: - case StoppedState: - case ErrorState: - break; - case PlayingState: - case BufferingState: - QTimer::singleShot(0, q, SLOT(_k_resumePlay())); - break; - case PausedState: - QTimer::singleShot(0, q, SLOT(_k_resumePause())); - break; - } - const State backendState = pINTERFACE_CALL(state()); - if (state != backendState && state != ErrorState) { - // careful: if state is ErrorState we might be switching from a - // MediaObject to a ByteStream for KIO fallback. In that case the state - // change to ErrorState was already suppressed. - pDebug() << "emitting a state change because the backend object has been replaced"; - emit q->stateChanged(backendState, state); - state = backendState; - } - -#ifndef QT_NO_PHONON_MEDIACONTROLLER - for (int i = 0 ; i < interfaceList.count(); ++i) { - interfaceList.at(i)->_backendObjectChanged(); - } -#endif //QT_NO_PHONON_MEDIACONTROLLER - - // set up attributes - if (isPlayable(mediaSource.type())) { - readyForZeitgeist = false; -#ifndef QT_NO_PHONON_ABSTRACTMEDIASTREAM - if (mediaSource.type() == MediaSource::Stream) { - Q_ASSERT(mediaSource.stream()); - mediaSource.stream()->d_func()->setMediaObjectPrivate(this); - } -#endif //QT_NO_PHONON_ABSTRACTMEDIASTREAM - sendToZeitgeist(StoppedState); - pINTERFACE_CALL(setSource(mediaSource)); - sendToZeitgeist(); - } -} - -void MediaObjectPrivate::_k_resumePlay() -{ - qobject_cast(m_backendObject)->play(); - if (currentTime > 0) { - qobject_cast(m_backendObject)->seek(currentTime); - } -} - -void MediaObjectPrivate::_k_resumePause() -{ - pINTERFACE_CALL(pause()); - if (currentTime > 0) { - qobject_cast(m_backendObject)->seek(currentTime); - } -} - -void MediaObjectPrivate::_k_metaDataChanged(const QMultiMap &newMetaData) -{ - metaData = newMetaData; - emit q_func()->metaDataChanged(); - pDebug() << "Metadata ready, sending to zeitgeist"; - readyForZeitgeist = true; - sendToZeitgeist(); -} - -void MediaObjectPrivate::phononObjectDestroyed(MediaNodePrivate *bp) -{ - // this method is called from Phonon::Base::~Base(), meaning the AudioPath - // dtor has already been called, also virtual functions don't work anymore - // (therefore qobject_cast can only downcast from Base) - Q_ASSERT(bp); - Q_UNUSED(bp); -} - -MediaObject *createPlayer(Phonon::Category category, const MediaSource &source) -{ - MediaObject *mo = new MediaObject; - AudioOutput *ao = new AudioOutput(category, mo); - createPath(mo, ao); - if (isPlayable(source.type())) { - mo->setCurrentSource(source); - } - return mo; -} - -} //namespace Phonon - -#include "moc_mediaobject.cpp" - -#undef PHONON_CLASSNAME -#undef PHONON_INTERFACENAME -// vim: sw=4 tw=100 et -#include "moc_mediaobject.h" diff --git a/src/phonon/mediaobject.dox b/src/phonon/mediaobject.dox deleted file mode 100644 index cc6fe5f9f..000000000 --- a/src/phonon/mediaobject.dox +++ /dev/null @@ -1,71 +0,0 @@ -/** -\page phonon_MediaObject The MediaObject class - -\section phonon_MediaObject_derived Media Data Producing Class - -There is the class that produces the media data (often called a source in -media frameworks). - -\section phonon_MediaObject_requiredfunctions Required Functions -\li qint32 \ref phonon_MediaObject_prefinishMark "prefinishMark()" -\li void \ref phonon_MediaObject_setPrefinishMark "setPrefinishMark(qint32)" - -\section phonon_MediaObject_optionalfunctions Optional Functions -\li qint64 \ref phonon_MediaObject_remainingTime "remainingTime()" - -\section phonon_MediaObject_signals Signals -\li void \ref phonon_MediaObject_totalTimeChanged "totalTimeChanged(qint64 totalTime)" -\li void \ref phonon_MediaObject_prefinishMarkReached "prefinishMarkReached(qint32 msec)" -\li void \ref phonon_MediaObject_finished "finished()" - -\section phonon_MediaObject_memberdocs Member Function Documentation - -\see \ref phonon_MediaObject_totalTimeChanged - -\subsection phonon_MediaObject_prefinishMark qint32 prefinishMark() -Returns the time in milliseconds the \ref phonon_MediaObject_prefinishMarkReached -"prefinishMarkReached" signal is emitted before the playback if finished and \ref -phonon_MediaObject_finished "finished" is emitted. - -\subsection phonon_MediaObject_setPrefinishMark void setPrefinishMark(qint32 msec) -Sets the time in milliseconds the \ref phonon_MediaObject_prefinishMarkReached -"prefinishMarkReached" signal is emitted before the playback if finished and \ref -phonon_MediaObject_finished "finished" is emitted. - -\param msec The time in milliseconds. If the value is less than or equal to 0 -the \ref phonon_MediaObject_prefinishMarkReached "prefinishMarkReached" signal is disabled. - -\subsection phonon_MediaObject_remainingTime qint64 remainingTime() -Get the remaining time (in milliseconds) of the file currently being played. If -the method is not implemented in the backend the frontend will use the -difference between \link Phonon::MediaObjectInterface::totalTime() MediaObjectInterface::totalTime() \endlink and -\link Phonon::MediaObjectInterface::currentTime() MediaObjectInterface::currentTime() \endlink. - -\section phonon_MediaObject_signaldocs Signals Documentation -\subsection phonon_MediaObject_prefinishMarkReached void prefinishMarkReached(qint32 msec) -Emitted when the file has finished playing on its own. -I.e. it is not emitted if you call stop(), pause() or -load(), but only on end-of-file or a critical error. -void finished() - -\param msec The remaining time until the playback finishes - -\subsection phonon_MediaObject_totalTimeChanged void totalTimeChanged(qint64 totalTime) -This signal is emitted as soon as the length of the media file is -known or has changed. For most non-local media data the length of -the media can only be known after some time. At that time the -totalTime function can not return useful information. You have -to wait for this signal to know the real length. - -\param totalTimeChanged The total time of the media file in milliseconds. - -\see \link Phonon::MediaObjectInterface::totalTime() MediaObjectInterface::totalTime() \endlink - -\subsection phonon_MediaObject_finished void finished() -This signal is emitted when the playback of the media finished (on its own). -It is not emitted if stop() or pause() are called - only on end-of-file or a -critical error (for example the media data stream is corrupted and playback of -the media has to be finished). - -\see \ref phonon_MediaObject_prefinishMarkReached -*/ diff --git a/src/phonon/mediaobject.h b/src/phonon/mediaobject.h deleted file mode 100644 index ab29fdc38..000000000 --- a/src/phonon/mediaobject.h +++ /dev/null @@ -1,666 +0,0 @@ -/* This file is part of the KDE project - Copyright (C) 2005 Matthias Kretz - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), Nokia Corporation - (or its successors, if any) and the KDE Free Qt Foundation, which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . - -*/ -#ifndef Phonon_MEDIAOBJECT_H -#define Phonon_MEDIAOBJECT_H - -#include "medianode.h" -#include "mediasource.h" -#include "phonon_export.h" -#include "phonondefs.h" -#include "phononnamespace.h" - - -namespace Phonon -{ - class MediaObjectPrivate; - - /** \class MediaObject mediaobject.h phonon/MediaObject - * \short Interface for media playback of a given URL. - * - * This class is the most important class in %Phonon. Use it to open a media - * file at an arbitrary location, a CD or DVD or to stream media data from - * the application to the backend. - * - * This class controls the state (play, pause, stop, seek) - * and you can use it to get a lot of information about the media data. - * - * Notice that most functions of this class are asynchronous. - * That means if you call play() the object only starts playing when the - * stateChanged() signal tells you that the object changed into PlayingState. - * The states you can expect are documented for those methods. - * - * A common usage example is the following: - * \code - * media = new MediaObject(this); - * connect(media, SIGNAL(finished()), SLOT(slotFinished()); - * media->setCurrentSource("/home/username/music/filename.ogg"); - * media->play(); - * \endcode - * - * If you want to play more than one media file (one after another) you can - * either tell MediaObject about all those files - * \code - * media->setCurrentSource(":/sounds/startsound.ogg"); - * media->enqueue("/home/username/music/song.mp3"); - * media->enqueue(":/sounds/endsound.ogg"); - * \endcode - * or provide the next file just in time: - * \code - * media->setCurrentSource(":/sounds/startsound.ogg"); - * connect(media, SIGNAL(aboutToFinish()), SLOT(enqueueNextSource())); - * } - * - * void enqueueNextSource() - * { - * media->enqueue("/home/username/music/song.mp3"); - * } - * \endcode - * - * Some platforms support system-wide tracking of a user's activities. For - * instance, the zeitgeist project (http://zeitgeist-project.com) on Linux. - * - * This integration is opt-in only and can be enabled by setting the - * PlaybackTracking property to true: - * \code - * media->setProperty("PlaybackTracking", true); - * \endcode - * - * This kind of information is normally used to provide a universal history - * view to the user, such as what songs were played when, regardless of the - * media player. This is in addition to any emails read, IM conversations, - * websites viewed, etc. - * - * \ingroup Playback - * \ingroup Recording - * \author Matthias Kretz - */ - class PHONON_EXPORT MediaObject : public QObject, public MediaNode - { - friend class FrontendInterfacePrivate; - Q_OBJECT - P_DECLARE_PRIVATE(MediaObject) - PHONON_OBJECT(MediaObject) - /** - * \brief Defines the time between media sources. - * - * A positive transition time defines a gap of silence between queued - * media sources. - * - * A transition time of 0 ms requests gapless playback (sample precise - * queueing of the next source). - * - * A negative transition time defines a crossfade between the queued - * media sources. - * - * Defaults to 0 (gapless playback). - * - * \warning This feature might not work reliably on every platform. - */ - Q_PROPERTY(qint32 transitionTime READ transitionTime WRITE setTransitionTime) - - /** - * \brief Get a signal before playback finishes. - * - * This property specifies the time in milliseconds the - * prefinishMarkReached signal is - * emitted before the playback finishes. A value of \c 0 disables the - * signal. - * - * Defaults to \c 0 (disabled). - * - * \warning For some media data the total time cannot be determined - * accurately, therefore the accuracy of the prefinishMarkReached signal - * can be bad sometimes. Still, it is better to use this method than to - * look at totalTime() and currentTime() to emulate the behaviour - * because the backend might have more information available than your - * application does through totalTime and currentTime. - * - * \see prefinishMarkReached - */ - Q_PROPERTY(qint32 prefinishMark READ prefinishMark WRITE setPrefinishMark) - - /** - * \brief The time interval in milliseconds between two ticks. - * - * The %tick interval is the time that elapses between the emission of two tick signals. - * If you set the interval to \c 0 the tick signal gets disabled. - * - * Defaults to \c 0 (disabled). - * - * \warning The back-end is free to choose a different tick interval close - * to what you asked for. This means that the following code \em may \em fail: - * \code - * int x = 200; - * media->setTickInterval(x); - * Q_ASSERT(x == producer->tickInterval()); - * \endcode - * On the other hand the following is guaranteed: - * \code - * int x = 200; - * media->setTickInterval(x); - * Q_ASSERT(x >= producer->tickInterval() && - * x <= 2 * producer->tickInterval()); - * \endcode - * - * \see tick - */ - Q_PROPERTY(qint32 tickInterval READ tickInterval WRITE setTickInterval) - public: - /** - * Destroys the MediaObject. - */ - ~MediaObject(); - - /** - * Get the current state. - * - * @return The state of the object. - * - * @see State - * \see stateChanged - */ - State state() const; - - /** - * Check whether the media data includes a video stream. - * - * \warning This information cannot be known immediately. It is best - * to also listen to the hasVideoChanged signal. - * - * \code - * connect(media, SIGNAL(hasVideoChanged(bool)), hasVideoChanged(bool)); - * media->setCurrentSource("somevideo.avi"); - * media->hasVideo(); // returns false; - * } - * - * void hasVideoChanged(bool b) - * { - * // b == true - * media->hasVideo(); // returns true; - * } - * \endcode - * - * \return \c true if the media contains video data. \c false - * otherwise. - * - * \see hasVideoChanged - */ - bool hasVideo() const; - - /** - * Check whether the current media may be seeked. - * - * \warning This information cannot be known immediately. It is best - * to also listen to the seekableChanged signal. - * - * \code - * connect(media, SIGNAL(seekableChanged(bool)), seekableChanged(bool)); - * media->setCurrentSource("somevideo.avi"); - * media->isSeekable(); // returns false; - * } - * - * void seekableChanged(bool b) - * { - * // b == true - * media->isSeekable(); // returns true; - * } - * \endcode - * - * \return \c true when the current media may be seeked. \c false - * otherwise. - * - * \see seekableChanged() - */ - bool isSeekable() const; - - /** - * \brief The time interval in milliseconds between two ticks. - * - * The %tick interval is the time that elapses between the emission - * of two tick signals. - * - * \returns the tick interval in milliseconds - */ - qint32 tickInterval() const; - - /** - * Returns the strings associated with the given \p key. - * - * Backends should use the keys specified in the Ogg Vorbis - * documentation: http://xiph.org/vorbis/doc/v-comment.html - * - * Therefore the following should work with every backend: - * - * A typical usage looks like this: - * \code - * setMetaArtist (media->metaData("ARTIST" )); - * setMetaAlbum (media->metaData("ALBUM" )); - * setMetaTitle (media->metaData("TITLE" )); - * setMetaDate (media->metaData("DATE" )); - * setMetaGenre (media->metaData("GENRE" )); - * setMetaTrack (media->metaData("TRACKNUMBER")); - * setMetaComment(media->metaData("DESCRIPTION")); - * \endcode - * - * For Audio CDs you can query - * \code - * metaData("MUSICBRAINZ_DISCID"); - * \endcode - * to get a DiscID hash that you can use with the MusicBrainz - * service: - * http://musicbrainz.org/doc/ClientHOWTO - */ - QStringList metaData(const QString &key) const; - - /** - * Returns the strings associated with the given \p key. - * - * Same as above except that the keys are defined in the - * Phonon::MetaData enum. - */ - QStringList metaData(Phonon::MetaData key) const; - - /** - * Returns all meta data. - */ - QMultiMap metaData() const; - - /** - * Returns a human-readable description of the last error that occurred. - */ - QString errorString() const; - - /** - * Tells your program what to do about the error. - * - * \see Phonon::ErrorType - */ - ErrorType errorType() const; - - /** - * Returns the current media source. - * - * \see setCurrentSource - */ - MediaSource currentSource() const; - - /** - * Set the media source the MediaObject should use. - * - * \param source The MediaSource object to the media data. You can - * just as well use a QUrl or QString (for a local file) here. - * Setting an empty (invalid) source, will stop and remove the - * current source. - * - * \code - * QUrl url("http://www.example.com/music.ogg"); - * media->setCurrentSource(url); - * \endcode - * - * \see currentSource - */ - void setCurrentSource(const MediaSource &source); - - /** - * Returns the queued media sources. This list does not include - * the current source (returned by currentSource). - */ - QList queue() const; - - /** - * Set the MediaSources to play when the current media has finished. - * - * This function will overwrite the current queue. - * - * \see clearQueue - * \see enqueue - */ - void setQueue(const QList &sources); - - /** - * Set the MediaSources to play when the current media has finished. - * - * This function overwrites the current queue. - * - * \see clearQueue - * \see enqueue - */ - void setQueue(const QList &urls); - - /** - * Appends one source to the queue. Use this function to provide - * the next source just in time after the aboutToFinish signal was - * emitted. - * - * \see aboutToFinish - * \see setQueue - * \see clearQueue - */ - void enqueue(const MediaSource &source); - - /** - * Appends multiple sources to the queue. - * - * \see setQueue - * \see clearQueue - */ - void enqueue(const QList &sources); - - /** - * Appends multiple sources to the queue. - * - * \see setQueue - * \see clearQueue - */ - void enqueue(const QList &urls); - - /** - * Clears the queue of sources. - */ - void clearQueue(); - - /** - * Get the current time (in milliseconds) of the file currently being played. - * - * \return The current time in milliseconds. - * - * \see tick - */ - qint64 currentTime() const; - - /** - * Get the total time (in milliseconds) of the file currently being played. - * - * \return The total time in milliseconds. - * - * \note The total time may change throughout playback as more accurate - * calculations become available, so it is recommended to connect - * and use the totalTimeChanged signal whenever possible unless - * best precision is not of importance. - * - * \warning The total time is undefined until the MediaObject entered - * the PlayingState. A valid total time is always indicated by - * emission of the totalTimeChanged signal. - * \see totalTimeChanged - */ - qint64 totalTime() const; - - /** - * Get the remaining time (in milliseconds) of the file currently being played. - * - * \return The remaining time in milliseconds. - */ - qint64 remainingTime() const; - - qint32 prefinishMark() const; - void setPrefinishMark(qint32 msecToEnd); - - qint32 transitionTime() const; - void setTransitionTime(qint32 msec); - - public Q_SLOTS: - - /** - * Sets the tick interval in milliseconds. - * - * \param newTickInterval the new tick interval in milliseconds. - * - * \see tickInterval - */ - void setTickInterval(qint32 newTickInterval); - - /** - * Requests playback of the media data to start. Playback only - * starts when stateChanged() signals that it goes into PlayingState, - * though. - * - * \par Possible states right after this call: - * \li BufferingState - * \li PlayingState - * \li ErrorState - */ - void play(); - - /** - * Requests playback to pause. If it was paused before nothing changes. - * If the media cannot be paused, some backends will internally call - * stop instead of pause. - * - * \par Possible states right after this call: - * \li PlayingState - * \li PausedState - * \li StoppedState - * \li ErrorState - */ - void pause(); - - /** - * Requests playback to stop. If it was stopped before nothing changes. - * - * \par Possible states right after this call: - * \li the state it was in before (e.g. PlayingState) - * \li StoppedState - * \li ErrorState - */ - void stop(); - - /** - * Requests a seek to the time indicated. - * - * You can only seek if state() == PlayingState, BufferingState or PausedState. - * - * The call is asynchronous, so currentTime can still be the old - * value right after this method was called. If all you need is a - * slider that shows the current position and allows the user to - * seek use the class SeekSlider. - * - * @param time The time in milliseconds where to continue playing. - * - * \par Possible states right after this call: - * \li BufferingState - * \li PlayingState - * \li ErrorState - * - * \see SeekSlider - */ - void seek(qint64 time); - - /** - * Stops and removes all playing and enqueued media sources. - * - * \see setCurrentSource - */ - void clear(); - - Q_SIGNALS: - /** - * Emitted when the state of the MediaObject has changed. - * - * @param newstate The state the Player is in now. - * @param oldstate The state the Player was in before. - */ - void stateChanged(Phonon::State newstate, Phonon::State oldstate); - - /** - * This signal gets emitted every tickInterval milliseconds. - * - * @param time The position of the media file in milliseconds. - * - * @see setTickInterval, tickInterval - */ - void tick(qint64 time); - - /** - * This signal is emitted whenever the audio/video data that is - * being played is associated with new meta data. E.g. for radio - * streams this happens when the next song is played. - * - * You can get the new meta data with the metaData methods. - */ - void metaDataChanged(); - - /** - * Emitted whenever the return value of isSeekable() changes. - * - * Normally you'll check isSeekable() first and then let this signal - * tell you whether seeking is possible now or not. That way you - * don't have to poll isSeekable(). - * - * \param isSeekable \p true if the stream is seekable (i.e. calling - * seek() works) - * \p false if the stream is not seekable (i.e. - * all calls to seek() will be ignored) - */ - void seekableChanged(bool isSeekable); - - /** - * Emitted whenever the return value of hasVideo() changes. - * - * Normally you'll check hasVideo() first and then let this signal - * tell you whether video is available now or not. That way you - * don't have to poll hasVideo(). - * - * \param hasVideo \p true The stream contains video and adding a - * VideoWidget will show a video. - * \p false There is no video data in the stream and - * adding a VideoWidget will show an empty (black) - * VideoWidget. - */ -#ifndef QT_NO_PHONON_VIDEO - void hasVideoChanged(bool hasVideo); -#endif //QT_NO_PHONON_VIDEO - - /** - * Tells about the status of the buffer. - * - * You can use this signal to show a progress bar to the user when - * in BufferingState: - * - * \code - * progressBar->setRange(0, 100); // this is the default - * connect(media, SIGNAL(bufferStatus(int)), progressBar, SLOT(setValue(int))); - * \endcode - * - * \param percentFilled A number between 0 and 100 telling you how - * much the buffer is filled. - */ // other names: bufferingProgress - void bufferStatus(int percentFilled); - - /** - * Emitted when the object has finished playback. - * It is not emitted if you call stop(), pause() or - * load(), but only on end-of-queue or a critical error. - * - * \warning This signal is not emitted when the current source has - * finished and there's another source in the queue. It is only - * emitted when the queue is empty. - * - * \see currentSourceChanged - * \see aboutToFinish - * \see prefinishMarkReached - */ - void finished(); - - /** - * Emitted when the MediaObject makes a transition to the next - * MediaSource in the queue(). - * - * In other words, it is emitted when an individual MediaSource is - * finished. - * - * \param newSource The source that starts to play at the time the - * signal is emitted. - */ - void currentSourceChanged(const Phonon::MediaSource &newSource); - - /** - * Emitted before the playback of the whole queue stops. When this - * signal is emitted you still have time to provide the next - * MediaSource (using enqueue()) so that playback continues. - * - * This signal can be used to provide the next MediaSource just in - * time for the transition still to work. - * - * \see enqueue - */ - void aboutToFinish(); - - /** - * Emitted when there are only \p msecToEnd milliseconds left - * for playback. - * - * \param msecToEnd The remaining time until the playback queue finishes. - * - * \warning This signal is not emitted when there is another source in the queue. - * It is only emitted when the queue is empty. - * - * \see setPrefinishMark - * \see prefinishMark - * \see aboutToFinish - * \see finished - */ - void prefinishMarkReached(qint32 msecToEnd); - - /** - * This signal is emitted as soon as the total time of the media file is - * known or has changed. For most non-local media data the total - * time of the media can only be known after some time. Initially the - * totalTime function can not return useful information. You have - * to wait for this signal to know the real total time. - * - * This signal may appear at any given point after a MediaSource was set. - * Namely in the LoadingState, BufferingState, PlayingState or PausedState. - * - * \note When changing the currentSource there is no signal emission until - * a reasonable value for the new source has been calculated. - * - * \param newTotalTime The length of the media file in milliseconds. - * - * \see totalTime - */ - void totalTimeChanged(qint64 newTotalTime); - - protected: - //MediaObject(Phonon::MediaObjectPrivate &dd, QObject *parent); - - private: - Q_PRIVATE_SLOT(k_func(), void _k_resumePlay()) - Q_PRIVATE_SLOT(k_func(), void _k_resumePause()) - Q_PRIVATE_SLOT(k_func(), void _k_metaDataChanged(const QMultiMap &)) -#ifndef QT_NO_PHONON_ABSTRACTMEDIASTREAM - Q_PRIVATE_SLOT(k_func(), void _k_stateChanged(Phonon::State, Phonon::State)) -#endif //QT_NO_PHONON_ABSTRACTMEDIASTREAM - Q_PRIVATE_SLOT(k_func(), void _k_aboutToFinish()) - Q_PRIVATE_SLOT(k_func(), void _k_currentSourceChanged(const MediaSource &)) - Q_PRIVATE_SLOT(k_func(), void _k_stateChanged(Phonon::State, Phonon::State)) - }; - - /** - * Convenience function to create a MediaObject and AudioOutput connected by - * a path. - */ - PHONON_EXPORT MediaObject *createPlayer(Phonon::Category category, const MediaSource &source = MediaSource()); -} //namespace Phonon - - -// vim: sw=4 ts=4 tw=80 -#endif // Phonon_MEDIAOBJECT_H diff --git a/src/phonon/mediaobject_p.h b/src/phonon/mediaobject_p.h deleted file mode 100644 index 3c90c3eae..000000000 --- a/src/phonon/mediaobject_p.h +++ /dev/null @@ -1,162 +0,0 @@ -/* This file is part of the KDE project - Copyright (C) 2006-2007 Matthias Kretz - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), Nokia Corporation - (or its successors, if any) and the KDE Free Qt Foundation, which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . - -*/ - -#ifndef MEDIAOBJECT_P_H -#define MEDIAOBJECT_P_H - -#include -#include -#ifdef HAVE_QZEITGEIST -#include -#include -#endif - -#include "medianode_p.h" -#include "medianodedestructionhandler_p.h" -#include "mediaobject.h" -#include "mediasource.h" -#include "phonondefs_p.h" - -namespace Phonon -{ -class FrontendInterfacePrivate; -class StatesValidator; - -class MediaObjectPrivate : public MediaNodePrivate, private MediaNodeDestructionHandler -{ - friend class KioFallbackImpl; - friend class AbstractMediaStream; - friend class AbstractMediaStreamPrivate; - P_DECLARE_PUBLIC(MediaObject) - public: - virtual QObject *qObject() { return q_func(); } - - /** - * Sends the metadata for this media file to the Zeitgeist tracker - * - * \param eventInterpretation The interpretation of the event - * \param eventManifestation The manifestation type of the event - * \param eventActor The application or entity responsible for emitting the zeitgeist event - * \param eventTimestamp The time - * \param subjectURI The file's URI - * \param subjectText A free-form annotation - * \param subjectInterpretation The interpretation type - * \param subjectManifestation The manifestation type - * \param subjectMimetype The file's mimetype - */ - void sendToZeitgeist(const QString &event_interpretation, - const QString &event_manifestation, - const QString &event_actor, - const QDateTime &subject_timestamp, - const QUrl &subject_uri, - const QString &subject_text, - const QString &subject_interpretation, - const QString &subject_manifestation, - const QString &subject_mimetype); - - void sendToZeitgeist(State); - void sendToZeitgeist(); - - QList interfaceList; - protected: - virtual bool aboutToDeleteBackendObject(); - virtual void createBackendObject(); - virtual void phononObjectDestroyed(MediaNodePrivate *); - PHONON_EXPORT void setupBackendObject(); - - void _k_resumePlay(); - void _k_resumePause(); - void _k_metaDataChanged(const QMultiMap &); - void _k_aboutToFinish(); - void _k_currentSourceChanged(const MediaSource &); - PHONON_EXPORT void _k_stateChanged(Phonon::State, Phonon::State); -#ifndef QT_NO_PHONON_ABSTRACTMEDIASTREAM - void streamError(Phonon::ErrorType, const QString &); -#endif //QT_NO_PHONON_ABSTRACTMEDIASTREAM - - MediaObjectPrivate() - : currentTime(0), - tickInterval(0), - metaData(), - errorString(), - prefinishMark(0), - transitionTime(0), // gapless playback -#ifndef QT_NO_PHONON_ABSTRACTMEDIASTREAM - abstractStream(0), -#endif //QT_NO_PHONON_ABSTRACTMEDIASTREAM - state(Phonon::LoadingState), - readyForZeitgeist(false), - playingQueuedSource(false) -#ifndef QT_NO_PHONON_ABSTRACTMEDIASTREAM - , errorType(Phonon::NormalError), - errorOverride(false), - ignoreLoadingToBufferingStateChange(false), - ignoreErrorToLoadingStateChange(false), - validateStates(!(qgetenv("PHONON_ASSERT_STATES").isEmpty())), - validator(0) -#endif //QT_NO_PHONON_ABSTRACTMEDIASTREAM - { -#ifdef HAVE_QZEITGEIST - log = new QZeitgeist::Log(); -#endif - } - - ~MediaObjectPrivate() - { -#ifdef HAVE_QZEITGEIST - delete log; -#endif - } - - qint64 currentTime; - qint32 tickInterval; - QMultiMap metaData; - QString errorString; - qint32 prefinishMark; - qint32 transitionTime; -#ifndef QT_NO_PHONON_ABSTRACTMEDIASTREAM - AbstractMediaStream *abstractStream; -#endif //QT_NO_PHONON_ABSTRACTMEDIASTREAM - State state -#ifdef QT_NO_PHONON_ABSTRACTMEDIASTREAM - ; -#else - : 8; - bool readyForZeitgeist; - bool playingQueuedSource; - ErrorType errorType : 4; - bool errorOverride : 1; - bool ignoreLoadingToBufferingStateChange : 1; - bool ignoreErrorToLoadingStateChange : 1; -#endif //QT_NO_PHONON_ABSTRACTMEDIASTREAM - MediaSource mediaSource; - QQueue sourceQueue; -#ifdef HAVE_QZEITGEIST - QZeitgeist::Log *log; -#endif - bool validateStates; - StatesValidator *validator; -}; -} - -#endif // MEDIAOBJECT_P_H -// vim: sw=4 ts=4 tw=80 diff --git a/src/phonon/mediaobjectinterface.h b/src/phonon/mediaobjectinterface.h deleted file mode 100644 index c7ec56b20..000000000 --- a/src/phonon/mediaobjectinterface.h +++ /dev/null @@ -1,238 +0,0 @@ -/* This file is part of the KDE project - Copyright (C) 2006-2007 Matthias Kretz - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), Nokia Corporation - (or its successors, if any) and the KDE Free Qt Foundation, which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . - -*/ - -#ifndef PHONON_MEDIAOBJECTINTERFACE_H -#define PHONON_MEDIAOBJECTINTERFACE_H - -#include "mediaobject.h" -#include - - -namespace Phonon -{ -class StreamInterface; - -/** \class MediaObjectInterface mediaobjectinterface.h phonon/MediaObjectInterface - * \short Backend interface for media sources. - * - * The backend implementation has to provide two signals, that are not defined - * in this interface: - *
    - *
  • \anchor phonon_MediaObjectInterface_stateChanged - * void stateChanged(\ref Phonon::State newstate, \ref Phonon::State oldstate) - * - * Emitted when the state of the MediaObject has changed. - * In case you're not interested in the old state you can also - * connect to a slot that only has one State argument. - * - * \param newstate The state the Player is in now. - * \param oldstate The state the Player was in before. - *
  • - *
  • \anchor phonon_MediaObjectInterface_tick - * void tick(qint64 time) - * - * This signal gets emitted every tickInterval milliseconds. - * - * \param time The position of the media file in milliseconds. - * - * \see setTickInterval() - * \see tickInterval() - *
  • - *
- * - * \author Matthias Kretz - * \see MediaObject - */ -class MediaObjectInterface -{ - public: - virtual ~MediaObjectInterface() {} - - /** - * Requests the playback to start. - * - * This method is only called if the state transition to \ref PlayingState is possible. - * - * The backend should react immediately - * by either going into \ref PlayingState or \ref BufferingState if the - * former is not possible. - */ - virtual void play() = 0; - - /** - * Requests the playback to pause. - * - * This method is only called if the state transition to \ref PausedState is possible. - * - * The backend should react as fast as possible. Go to \ref PausedState - * as soon as playback is paused. - */ - virtual void pause() = 0; - - /** - * Requests the playback to be stopped. - * - * This method is only called if the state transition to \ref StoppedState is possible. - * - * The backend should react as fast as possible. Go to \ref StoppedState - * as soon as playback is stopped. - * - * A subsequent call to play() will start playback at the beginning of - * the media. - */ - virtual void stop() = 0; - - /** - * Requests the playback to be seeked to the given time. - * - * The backend does not have to finish seeking while in this function - * (i.e. the backend does not need to block the thread until the seek is - * finished; even worse it might lead to deadlocks when using a - * ByteStream which gets its data from the thread this function would - * block). - * - * As soon as the seek is done the currentTime() function and - * the tick() signal will report it. - * - * \param milliseconds The time where playback should seek to in - * milliseconds. - */ - virtual void seek(qint64 milliseconds) = 0; - - /** - * Return the time interval in milliseconds between two ticks. - * - * \returns Returns the tick interval that it was set to (might not - * be the same as you asked for). - */ - virtual qint32 tickInterval() const = 0; - /** - * Change the interval the tick signal is emitted. If you set \p - * interval to 0 the signal gets disabled. - * - * \param interval tick interval in milliseconds - * - * \returns Returns the tick interval that it was set to (might not - * be the same as you asked for). - */ - virtual void setTickInterval(qint32 interval) = 0; - - /** - * Check whether the media data includes a video stream. - * - * \return returns \p true if the media contains video data - */ - virtual bool hasVideo() const = 0; - /** - * If the current media may be seeked returns true. - * - * \returns whether the current media may be seeked. - */ - virtual bool isSeekable() const = 0; - /** - * Get the current time (in milliseconds) of the file currently being played. - */ - virtual qint64 currentTime() const = 0; - /** - * Get the current state. - */ - virtual Phonon::State state() const = 0; - - /** - * A translated string describing the error. - */ - virtual QString errorString() const = 0; - - /** - * Tells your program what to do about the error. - * - * \see Phonon::ErrorType - */ - virtual Phonon::ErrorType errorType() const = 0; - - /** - * Returns the total time of the media in milliseconds. - * - * If the total time is not know return -1. Do not block until it is - * known, instead emit the totalTimeChanged signal as soon as the total - * time is known or changes. - */ - virtual qint64 totalTime() const = 0; - - /** - * Returns the current source. - */ - virtual MediaSource source() const = 0; - - /** - * Sets the current source. When this function is called the MediaObject is - * expected to stop all current activity and start loading the new - * source (i.e. go into LoadingState). - * - * It is expected that the - * backend now starts preloading the media data, filling the audio - * and video buffers and making all media meta data available. It - * will also trigger the totalTimeChanged signal. - * - * If the backend does not know how to handle the source it needs to - * change state to Phonon::ErrorState. Don't bother about handling KIO - * URLs. It is enough to handle AbstractMediaStream sources correctly. - * - * \warning Keep the MediaSource object around as long as the backend - * uses the AbstractMediaStream returned by the MediaSource. In case - * that no other reference to the MediaSource exists and it is set to - * MediaSource::autoDelete, the AbstractMediaStream is deleted when the - * last MediaSource ref is deleted. - */ - virtual void setSource(const MediaSource &) = 0; - - /** - * Sets the next source to be used for transitions. When a next source - * is set playback should continue with the new source. In that case - * finished and prefinishMarkReached are not emitted. - * - * \param source The source to transition to (crossfade/gapless/gap). If - * \p source is an invalid MediaSource object then the queue is empty - * and the playback should stop normally. - * - * \warning Keep the MediaSource object around as long as the backend - * uses the AbstractMediaStream returned by the MediaSource. In case - * that no other reference to the MediaSource exists and it is set to - * MediaSource::autoDelete, the AbstractMediaStream is deleted when the - * last MediaSource ref is deleted. - */ - virtual void setNextSource(const MediaSource &source) = 0; - - virtual qint64 remainingTime() const { return totalTime() - currentTime(); } - virtual qint32 prefinishMark() const = 0; - virtual void setPrefinishMark(qint32) = 0; - - virtual qint32 transitionTime() const = 0; - virtual void setTransitionTime(qint32) = 0; -}; -} - -Q_DECLARE_INTERFACE(Phonon::MediaObjectInterface, "MediaObjectInterface3.phonon.kde.org") - - -#endif // PHONON_MEDIAOBJECTINTERFACE_H -// vim: sw=4 ts=4 tw=80 diff --git a/src/phonon/mediasource.cpp b/src/phonon/mediasource.cpp deleted file mode 100644 index 45c27c593..000000000 --- a/src/phonon/mediasource.cpp +++ /dev/null @@ -1,442 +0,0 @@ -/* This file is part of the KDE project - Copyright (C) 2007 Matthias Kretz - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), Nokia Corporation - (or its successors, if any) and the KDE Free Qt Foundation, which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . - -*/ - -#include "mediasource.h" -#include "mediasource_p.h" -#include "iodevicestream_p.h" -#include "abstractmediastream_p.h" -#include "globalconfig.h" - -#include -#include - -namespace Phonon -{ - -MediaSource::MediaSource(MediaSourcePrivate &dd) - : d(&dd) -{ -} - -MediaSource::MediaSource() - : d(new MediaSourcePrivate(Empty)) -{ -} - -MediaSource::MediaSource(const QString &filename) - : d(new MediaSourcePrivate(LocalFile)) -{ - if (filename.startsWith(QLatin1String(":/")) || filename.startsWith(QLatin1String("qrc:///"))) { -#ifndef QT_NO_PHONON_ABSTRACTMEDIASTREAM - d->url.setScheme("qrc"); - d->url.setPath(filename.mid(filename.startsWith(QLatin1Char(':')) ? 1 : 6)); - - // QFile needs :/ syntax - QString path(QLatin1Char(':') + d->url.path()); - - if (QFile::exists(path)) { - d->type = Stream; - d->ioDevice = new QFile(path); - d->setStream(new IODeviceStream(d->ioDevice, d->ioDevice)); - } else { - d->type = Invalid; - } -#else - d->type = Invalid; -#endif //QT_NO_PHONON_ABSTRACTMEDIASTREAM - } else { - const QFileInfo fileinfo(filename); - if (fileinfo.exists()) { - d->url = QUrl::fromLocalFile(fileinfo.absoluteFilePath()); - if (!d->url.host().isEmpty()) { - // filename points to a file on a network share (eg \\host\share\path) - d->type = Url; - } - } else { - d->url = filename; - if (d->url.isValid()) { - d->type = Url; - } else { - d->type = Invalid; - } - } - } -} - -MediaSource::MediaSource(const QUrl &url) - : d(new MediaSourcePrivate(Url)) -{ - if (url.isValid()) { - if (url.scheme() == QLatin1String("qrc")) { -#ifndef QT_NO_PHONON_ABSTRACTMEDIASTREAM - // QFile needs :/ syntax - QString path(QLatin1Char(':') + url.path()); - - if (QFile::exists(path)) { - d->type = Stream; - d->ioDevice = new QFile(path); - d->setStream(new IODeviceStream(d->ioDevice, d->ioDevice)); - } else { - d->type = Invalid; - } -#else - d->type = Invalid; -#endif //QT_NO_PHONON_ABSTRACTMEDIASTREAM - } - d->url = url; - } else { - d->type = Invalid; - } -} - -MediaSource::MediaSource(DiscType dt, const QString &deviceName) - : d(new MediaSourcePrivate(Disc)) -{ - if (dt == NoDisc) { - d->type = Invalid; - return; - } - d->discType = dt; - d->deviceName = deviceName; -} - -// NOTE: this is deprecated -MediaSource::MediaSource(const DeviceAccess &) - : d(new MediaSourcePrivate(Invalid)) -{ -} - -#ifndef PHONON_NO_AUDIOCAPTURE -MediaSource::MediaSource(const AudioCaptureDevice& device) - : d(new MediaSourcePrivate(CaptureDevice)) -{ - d->setCaptureDevices(device, VideoCaptureDevice()); -} -#endif //PHONON_NO_AUDIOCAPTURE - -#ifndef PHONON_NO_VIDEOCAPTURE -MediaSource::MediaSource(const VideoCaptureDevice& device) - : d(new MediaSourcePrivate(CaptureDevice)) -{ - d->setCaptureDevices(AudioCaptureDevice(), device); -} -#endif //PHONON_NO_VIDEOCAPTURE - -#if !defined(PHONON_NO_VIDEOCAPTURE) && !defined(PHONON_NO_AUDIOCAPTURE) -MediaSource::MediaSource(CaptureCategory category) - : d(new MediaSourcePrivate(AudioVideoCapture)) -{ - d->setCaptureDevices(category); -} - -MediaSource::MediaSource(Capture::DeviceType deviceType, CaptureCategory category) - : d(new MediaSourcePrivate(CaptureDevice)) -{ - d->setCaptureDevice(deviceType, category); -} -#endif // !PHONON_NO_VIDEOCAPTURE && !PHONON_NO_AUDIOCAPTURE - -#ifndef QT_NO_PHONON_ABSTRACTMEDIASTREAM -MediaSource::MediaSource(AbstractMediaStream *stream) - : d(new MediaSourcePrivate(Stream)) -{ - if (stream) { - d->setStream(stream); - } else { - d->type = Invalid; - } -} - -MediaSource::MediaSource(QIODevice *ioDevice) - : d(new MediaSourcePrivate(Stream)) -{ - if (ioDevice) { - d->setStream(new IODeviceStream(ioDevice, ioDevice)); - d->ioDevice = ioDevice; - } else { - d->type = Invalid; - } -} -#endif //QT_NO_PHONON_ABSTRACTMEDIASTREAM - -/* post 4.0 -MediaSource::MediaSource(const QList &mediaList) - : d(new MediaSourcePrivate(Link)) -{ - d->linkedSources = mediaList; - foreach (MediaSource ms, mediaList) { - Q_ASSERT(ms.type() != Link); - } -} - -QList MediaSource::substreams() const -{ - return d->linkedSources; -} -*/ - -MediaSource::~MediaSource() -{ -} - -MediaSourcePrivate::~MediaSourcePrivate() -{ -#ifndef QT_NO_PHONON_ABSTRACTMEDIASTREAM - if (autoDelete) { - //here we use deleteLater because this object - //might be destroyed from another thread - if (stream) - stream->deleteLater(); - if (ioDevice) - ioDevice->deleteLater(); - } -#endif //QT_NO_PHONON_ABSTRACTMEDIASTREAM -} - -MediaSource::MediaSource(const MediaSource &rhs) - : d(rhs.d) -{ -} - -MediaSource &MediaSource::operator=(const MediaSource &rhs) -{ - d = rhs.d; - return *this; -} - -bool MediaSource::operator==(const MediaSource &rhs) const -{ - return d == rhs.d; -} - -void MediaSource::setAutoDelete(bool autoDelete) -{ - d->autoDelete = autoDelete; -} - -bool MediaSource::autoDelete() const -{ - return d->autoDelete; -} - -MediaSource::Type MediaSource::type() const -{ -#ifndef QT_NO_PHONON_ABSTRACTMEDIASTREAM - if (d->type == Stream && d->stream == 0) { - return Invalid; - } -#endif //QT_NO_PHONON_ABSTRACTMEDIASTREAM - return d->type; -} - -QString MediaSource::fileName() const -{ - return d->url.toLocalFile(); -} - -Mrl MediaSource::mrl() const -{ - return Mrl(d->url); -} - -QUrl MediaSource::url() const -{ - return d->url; -} - -DiscType MediaSource::discType() const -{ - return d->discType; -} - -const DeviceAccessList& MediaSource::deviceAccessList() const -{ -#ifndef PHONON_NO_AUDIOCAPTURE - if (d->audioCaptureDevice.isValid()) - return d->audioDeviceAccessList; -#endif - -#ifndef PHONON_NO_VIDEOCAPTURE - if (d->videoCaptureDevice.isValid()) - return d->videoDeviceAccessList; -#endif - - return d->audioDeviceAccessList; // It should be invalid -} - -const DeviceAccessList& MediaSource::audioDeviceAccessList() const -{ - return d->audioDeviceAccessList; -} - -const DeviceAccessList& MediaSource::videoDeviceAccessList() const -{ - return d->videoDeviceAccessList; -} - -QString MediaSource::deviceName() const -{ - return d->deviceName; -} - -#ifndef QT_NO_PHONON_ABSTRACTMEDIASTREAM -AbstractMediaStream *MediaSource::stream() const -{ - return d->stream; -} - -void MediaSourcePrivate::setStream(AbstractMediaStream *s) -{ - stream = s; -} -#endif //QT_NO_PHONON_ABSTRACTMEDIASTREAM - -#ifndef PHONON_NO_AUDIOCAPTURE -AudioCaptureDevice MediaSource::audioCaptureDevice() const -{ - return d->audioCaptureDevice; -} -#endif //PHONON_NO_AUDIOCAPTURE - -#ifndef PHONON_NO_VIDEOCAPTURE -VideoCaptureDevice MediaSource::videoCaptureDevice() const -{ - return d->videoCaptureDevice; -} -#endif //PHONON_NO_VIDEOCAPTURE - -#if !defined(PHONON_NO_VIDEOCAPTURE) && !defined(PHONON_NO_AUDIOCAPTURE) -void MediaSourcePrivate::setCaptureDevice(Capture::DeviceType deviceType, CaptureCategory category) -{ - switch (deviceType) { - case Capture::VideoType: { - setCaptureDevices(AudioCaptureDevice(), - VideoCaptureDevice::fromIndex(GlobalConfig().videoCaptureDeviceFor(category))); - break; - } - case Capture::AudioType: { - setCaptureDevices( - AudioCaptureDevice::fromIndex(GlobalConfig().audioCaptureDeviceFor(category)), VideoCaptureDevice()); - break; - } - } -} - -void MediaSourcePrivate::setCaptureDevices(CaptureCategory category) -{ - setCaptureDevices( - AudioCaptureDevice::fromIndex(GlobalConfig().audioCaptureDeviceFor(category)), - VideoCaptureDevice::fromIndex(GlobalConfig().videoCaptureDeviceFor(category))); -} - -void MediaSourcePrivate::setCaptureDevices(const AudioCaptureDevice &audioDevice, const VideoCaptureDevice &videoDevice) -{ - audioCaptureDevice = audioDevice; - videoCaptureDevice = videoDevice; - - if (audioDevice.propertyNames().contains("deviceAccessList") && - !audioDevice.property("deviceAccessList").value().isEmpty()) { - audioDeviceAccessList = audioDevice.property("deviceAccessList").value(); - } - - if (videoDevice.propertyNames().contains("deviceAccessList") && - !videoDevice.property("deviceAccessList").value().isEmpty()) { - videoDeviceAccessList = videoDevice.property("deviceAccessList").value(); - } - - bool validAudio = !audioDeviceAccessList.isEmpty(); - bool validVideo = !videoDeviceAccessList.isEmpty(); - type = MediaSource::Invalid; - if (validAudio && validVideo) - type = MediaSource::AudioVideoCapture; - else if (validAudio || validVideo) - type = MediaSource::CaptureDevice; -} -#endif // !PHONON_NO_VIDEOCAPTURE && !PHONON_NO_AUDIOCAPTURE - -QDebug operator <<(QDebug dbg, const Phonon::MediaSource &source) -{ - switch (source.type()) { - case MediaSource::Invalid: - dbg.nospace() << "Invalid()"; - break; - case MediaSource::LocalFile: - dbg.nospace() << "LocalFile(" << source.url() << ")"; - break; - case MediaSource::Url: - dbg.nospace() << "Url(" << source.url() << ")"; - break; - case MediaSource::Disc: - dbg.nospace() << "Disc("; - switch (source.discType()) { - case NoDisc: - dbg.nospace() << "NoDisc"; - break; - case Cd: - dbg.nospace() << "Cd: " << source.deviceName(); - break; - case Dvd: - dbg.nospace() << "Dvd: " << source.deviceName(); - break; - case Vcd: - dbg.nospace() << "Vcd: " << source.deviceName(); - break; - case BluRay: - dbg.nospace() << "BluRay: " << source.deviceName(); - break; - } - dbg.nospace() << ")"; - break; - case MediaSource::Stream: { - dbg.nospace() << "Stream(IOAddr: " << source.d->ioDevice; - QObject *qiodevice = qobject_cast(source.d->ioDevice); - if (qiodevice) - dbg.nospace() << " IOClass: " << qiodevice->metaObject()->className(); - - dbg.nospace() << "; StreamAddr: " << source.stream(); - QObject *qstream = qobject_cast(source.stream()); - if (qstream) - dbg.nospace() << " StreamClass: " << qstream->metaObject()->className(); - - dbg.nospace() << ")"; - break; - } - case MediaSource::CaptureDevice: - case MediaSource::AudioVideoCapture: -#if !defined(PHONON_NO_VIDEOCAPTURE) && !defined(PHONON_NO_AUDIOCAPTURE) - dbg.nospace() << "AudioVideoCapture(A:" << source.audioCaptureDevice().name() - << "/V: " << source.videoCaptureDevice().name() << ")"; -#else - dbg.nospace() << "AudioVideoCapture(A:/V: )"; -#endif - break; - case MediaSource::Empty: - dbg.nospace() << "Empty()"; - break; - } - - return dbg.maybeSpace(); -} - -} // namespace Phonon - -// vim: sw=4 sts=4 et tw=100 diff --git a/src/phonon/mediasource.h b/src/phonon/mediasource.h deleted file mode 100644 index cbe61124c..000000000 --- a/src/phonon/mediasource.h +++ /dev/null @@ -1,375 +0,0 @@ -/* This file is part of the KDE project - Copyright (C) 2007 Matthias Kretz - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), Nokia Corporation - (or its successors, if any) and the KDE Free Qt Foundation, which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . - -*/ - -#ifndef PHONON_MEDIASOURCE_H -#define PHONON_MEDIASOURCE_H - -#include "phonon_export.h" -#include "phononnamespace.h" - -#include "mrl.h" -#include "objectdescription.h" - -#include -#include - - -class QUrl; -class QIODevice; - -namespace Phonon -{ - -class MediaSourcePrivate; -class AbstractMediaStream; - -/** \class MediaSource mediasource.h phonon/MediaSource - * Note that all constructors of this class are implicit, so that you can simply write - * \code - * MediaObject m; - * QString fileName("/home/foo/bar.ogg"); - * QUrl url("http://www.example.com/stream.mp3"); - * QBuffer *someBuffer; - * m.setCurrentSource(fileName); - * m.setCurrentSource(url); - * m.setCurrentSource(someBuffer); - * m.setCurrentSource(Phonon::Cd); - * \endcode - * - * \ingroup Playback - * \ingroup Recording - * \author Matthias Kretz - */ -class PHONON_EXPORT MediaSource -{ - friend class StreamInterface; - friend PHONON_EXPORT QDebug operator <<(QDebug dbg, const Phonon::MediaSource &); - public: - /** - * Identifies the type of media described by the MediaSource object. - * - * \see MediaSource::type() - */ - enum Type { - /** - * The MediaSource object does not describe any valid source. - */ - Invalid = -1, - /** - * The MediaSource object describes a local file. - */ - LocalFile, - /** - * The MediaSource object describes a URL, which can be both a local file and a file on - * the network. - */ - Url, - /** - * The MediaSource object describes a disc. - */ - Disc, - /** - * The MediaSource object describes a data stream. - * - * This is also the type used for QIODevices. - * - * \see AbstractMediaStream - */ - Stream, - /** - * The MediaSource object describes a single capture device. - * This could be either audio or video. - */ - CaptureDevice, - /** - * An empty MediaSource. - * - * It can be used to unload the current media from a MediaObject. - * - * \see MediaSource() - */ - Empty, - /** - * The MediaSource object describes one device for video capture and one for audio - * capture. Facilitates capturing both audio and video at the same time, from - * different devices. - * It's essentially like two CaptureDevice media sources (one of video type, one - * of audio type) merged together. - */ - AudioVideoCapture -/* post 4.0: - / ** - * Links multiple MediaSource objects together. - * / - Link -*/ - }; - - /** - * Creates an empty MediaSource. - * - * An empty MediaSource is considered valid and can be set on a MediaObject to unload its - * current media. - * - * \see Empty - */ - MediaSource(); - - /** - * Creates a MediaSource object for a local file or a Qt resource. - * - * \deprecated Use MediaSource(QUrl("qrc:///...")) for a Qt resource, MediaSource(QUrl::fromLocalFile("...")) for a local file, or MediaSource(QUrl("...")) for an URL. - * - * \param fileName file name of a local media file or a Qt resource that was compiled in. - */ - PHONON_DEPRECATED MediaSource(const QString &fileName); //krazy:exclude=explicit - - /** - * Creates a MediaSource object for a URL. - * - * A Qt resource can be specified by using an url with a qrc scheme. - * - * \param url URL to a media file or stream. - */ - MediaSource(const QUrl &url); //krazy:exclude=explicit - - /** - * Creates a MediaSource object for discs. - * - * \param discType See \ref DiscType - * \param deviceName A platform dependent device name. This can be useful if the computer - * has more than one CD drive. It is recommended to use Solid to retrieve the device name in - * a portable way. - */ - MediaSource(DiscType discType, const QString &deviceName = QString()); //krazy:exclude=explicit - -#ifndef PHONON_NO_AUDIOCAPTURE - /** - * Creates a MediaSource object for audio capture devices. - * If the device is valid, this creates a 'CaptureDevice' type MediaSource. - */ - MediaSource(const AudioCaptureDevice& device); -#endif - -#ifndef PHONON_NO_VIDEOCAPTURE - /** - * Creates a MediaSource object for video capture devices. - * If the device is valid, this creates a 'CaptureDevice' type MediaSource - */ - MediaSource(const VideoCaptureDevice& device); -#endif - -#if !defined(PHONON_NO_VIDEOCAPTURE) && !defined(PHONON_NO_AUDIOCAPTURE) - /** - * Sets the source to the preferred audio capture device for the specified category - * If a valid device is found, this creates a 'CaptureDevice' type MediaSource - */ - MediaSource(Capture::DeviceType deviceType, CaptureCategory category = NoCaptureCategory); - - /** - * Creates a MediaSource object that tries to describe a video capture device and - * an audio capture device, together. The devices are appropriate for the specified - * category. - * - * If valid devices are found for both audio and video, then the resulting MediaSource - * is of type 'AudioVideoCapture'. If only an audio or a video valid device is found, - * the resulting type is 'CaptureDevice'. If no valid devices are found, the resulting - * type is 'Invalid'. - */ - MediaSource(CaptureCategory category); -#endif - -#ifndef QT_NO_PHONON_ABSTRACTMEDIASTREAM - /** - * Creates a MediaSource object for a data stream. - * - * Your application can provide the media data by subclassing AbstractMediaStream and - * passing a pointer to that object. %Phonon will never delete the \p stream. - * - * \param stream The AbstractMediaStream subclass to provide the media data. - * - * \see setAutoDelete - */ - MediaSource(AbstractMediaStream *stream); //krazy:exclude=explicit - - /** - * Creates a MediaSource object for a QIODevice. - * - * This constructor can be very handy in the combination of QByteArray and QBuffer. - * - * \param ioDevice An arbitrary readable QIODevice subclass. If the device is not opened - * MediaSource will open it as QIODevice::ReadOnly. Sequential I/O devices are possible, - * too. For those MediaObject::isSeekable() will have to return false obviously. - * - * \see setAutoDelete - */ - MediaSource(QIODevice *ioDevice); //krazy:exclude=explicit -#endif - - /** - * Destroys the MediaSource object. - */ - ~MediaSource(); - - /** - * Constructs a copy of \p rhs. - * - * This constructor is fast thanks to explicit sharing. - */ - MediaSource(const MediaSource &rhs); - - /** - * Assigns \p rhs to this MediaSource and returns a reference to this MediaSource. - * - * This operation is fast thanks to explicit sharing. - */ - MediaSource &operator=(const MediaSource &rhs); - - /** - * Returns \p true if this MediaSource is equal to \p rhs; otherwise returns \p false. - */ - bool operator==(const MediaSource &rhs) const; - - /** - * Tell the MediaSource to take ownership of the AbstractMediaStream or QIODevice that was - * passed in the constructor. - * - * The default setting is \p false, for safety. If you turn it on, you should only access - * the AbstractMediaStream/QIODevice object as long as you yourself keep a MediaSource - * object around. As long as you keep the MediaSource object wrapping the stream/device - * the object will not get deleted. - * - * \see autoDelete - */ - void setAutoDelete(bool enable); - - /** - * Returns the setting of the auto-delete option. The default is \p false. - * - * \see setAutoDelete - */ - bool autoDelete() const; - - /** - * Returns the type of the MediaSource (depends on the constructor that was used). - * - * \see Type - */ - Type type() const; - - /** - * Returns the file name of the MediaSource if type() == LocalFile; otherwise returns - * QString(). - */ - QString fileName() const; - - /** - * Returns the MRL of the MediaSource if type() == URL or type() == LocalFile; otherwise - * returns Mrl(). - * Phonon::Mrl is based on QUrl and adds some additional functionality that - * is necessary to ensure proper encoding usage in the Phonon backends. - * - * Usually you will not have to use this in an application. - * - * \since 4.5 - * \ingroup Backend - */ - Mrl mrl() const; - - /** - * Returns the url of the MediaSource if type() == URL or type() == LocalFile; otherwise - * returns QUrl(). - */ - QUrl url() const; - - /** - * Returns the disc type of the MediaSource if type() == Disc; otherwise returns \ref - * NoDisc. - */ - DiscType discType() const; - - /** - * Returns the access list for the device of this media source. Valid for capture devices. - * \warning use only with MediaSource with type() == CaptureDevice - */ - const DeviceAccessList& deviceAccessList() const; - - /** - * Returns the access list for the video device used for capture. - * Valid for type() == CaptureDevice or type() == AudioVideoCapture. - * If used with CaptureDevice, the kind of device should be Video, for a valid result. - */ - const DeviceAccessList& videoDeviceAccessList() const; - - /** - * Returns the access list for the audio device used for capture. - * Valid for type() == CaptureDevice or type() == AudioVideoCapture. - * If used with CaptureDevice, the kind of device should be Audio, for a valid result. - */ - const DeviceAccessList& audioDeviceAccessList() const; - - /** - * Returns the device name of the MediaSource if type() == Disc; otherwise returns - * QString(). - */ - QString deviceName() const; - -#ifndef QT_NO_PHONON_ABSTRACTMEDIASTREAM - /** - * Returns the media stream of the MediaSource if type() == Stream; otherwise returns 0. - * QIODevices are handled as streams, too. - */ - AbstractMediaStream *stream() const; -#endif - -#ifndef PHONON_NO_AUDIOCAPTURE - /** - * Returns the audio capture device for the media source if applicable. - */ - AudioCaptureDevice audioCaptureDevice() const; -#endif - -#ifndef PHONON_NO_VIDEOCAPTURE - /** - * Returns the video capture device for the media source if applicable. - */ - VideoCaptureDevice videoCaptureDevice() const; -#endif - -/* post 4.0: - MediaSource(const QList &mediaList); - QList substreams() const; -*/ - - protected: - QExplicitlySharedDataPointer d; - MediaSource(MediaSourcePrivate &); - - PHONON_DEPRECATED MediaSource(const DeviceAccess &access); -}; - -PHONON_EXPORT QDebug operator <<(QDebug dbg, const Phonon::MediaSource &); - -} // namespace Phonon - - -#endif // PHONON_MEDIASOURCE_H diff --git a/src/phonon/mediasource_p.h b/src/phonon/mediasource_p.h deleted file mode 100644 index 06723696f..000000000 --- a/src/phonon/mediasource_p.h +++ /dev/null @@ -1,100 +0,0 @@ -/* This file is part of the KDE project - Copyright (C) 2007 Matthias Kretz - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), Nokia Corporation - (or its successors, if any) and the KDE Free Qt Foundation, which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . - -*/ - -#ifndef MEDIASOURCE_P_H -#define MEDIASOURCE_P_H - -#include "mediasource.h" -#include "abstractmediastream.h" -#include "objectdescription.h" -#include "mrl.h" - -#include -#include -#include -#include - -class QFile; - -namespace Phonon -{ - -class PHONON_EXPORT MediaSourcePrivate : public QSharedData -{ - public: - MediaSourcePrivate(MediaSource::Type t) - : type(t), discType(NoDisc), -#ifndef QT_NO_PHONON_ABSTRACTMEDIASTREAM - stream(0), - ioDevice(0), -#endif //QT_NO_PHONON_ABSTRACTMEDIASTREAM - autoDelete(false) - { - } - - virtual ~MediaSourcePrivate(); - -#ifndef QT_NO_PHONON_ABSTRACTMEDIASTREAM - void setStream(AbstractMediaStream *s); -#endif - - MediaSource::Type type; - Mrl url; - Phonon::DiscType discType; - QString deviceName; // Used for discs - Phonon::DeviceAccessList audioDeviceAccessList; - Phonon::DeviceAccessList videoDeviceAccessList; - -#ifndef QT_NO_PHONON_ABSTRACTMEDIASTREAM - // The AbstractMediaStream(2) may be deleted at any time by the application. If that happens - // stream will be 0 automatically, but streamEventQueue will stay valid as we hold a - // reference to it. This is necessary to avoid a races when setting the MediaSource while - // another thread deletes the AbstractMediaStream2. StreamInterface(2) will then just get a - // StreamEventQueue where nobody answers. - QPointer stream; - QIODevice *ioDevice; -#endif //QT_NO_PHONON_ABSTRACTMEDIASTREAM - -#if !defined(PHONON_NO_VIDEOCAPTURE) && !defined(PHONON_NO_AUDIOCAPTURE) - void setCaptureDevice(Capture::DeviceType deviceType, CaptureCategory category); - void setCaptureDevices(CaptureCategory category); - void setCaptureDevices(const AudioCaptureDevice &audioDevice, const VideoCaptureDevice &videoDevice); -#endif // !PHONON_NO_VIDEOCAPTURE && !PHONON_NO_AUDIOCAPTURE - -#ifndef PHONON_NO_AUDIOCAPTURE - AudioCaptureDevice audioCaptureDevice; -#endif - -#ifndef PHONON_NO_VIDEOCAPTURE - VideoCaptureDevice videoCaptureDevice; -#endif - - //QList linkedSources; - bool autoDelete; -}; - -} // namespace Phonon - -#endif // MEDIASOURCE_P_H -// vim: sw=4 sts=4 et tw=100 - - diff --git a/src/phonon/mrl.cpp b/src/phonon/mrl.cpp deleted file mode 100644 index afd465588..000000000 --- a/src/phonon/mrl.cpp +++ /dev/null @@ -1,80 +0,0 @@ -/* This file is part of the KDE project - Copyright (C) 2011 Harald Sitter - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), Nokia Corporation - (or its successors, if any) and the KDE Free Qt Foundation, which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . -*/ - -#include "mrl.h" - -#include - -namespace Phonon -{ - -Mrl::Mrl() - : QUrl() -{ -} - -Mrl::Mrl(const Mrl ©) - : QUrl(copy) -{ -} - -Mrl::Mrl(const QUrl &url) - : QUrl(url) -{ -} - -Mrl::Mrl(const QString &url) - : QUrl(url) -{ -} - -Mrl &Mrl::operator =(const Mrl ©) -{ - QUrl::operator =(copy); - return *this; -} - -#ifndef QT_NO_URL_CAST_FROM_STRING -Mrl &Mrl::operator =(const QString &url) -{ - QUrl::operator =(url); - return *this; -} -#endif // QT_NO_URL_CAST_FROM_STRING - -QByteArray Mrl::toEncoded(FormattingOptions options) const -{ - QByteArray encodedMrl; - - QString url = toString(options); - static QByteArray encodingExclude(":/\\?=&,@"); - if (scheme() == QLatin1String("")) { - encodedMrl = QFile::encodeName("file://" + url).toPercentEncoding(encodingExclude); - } else if (scheme() == QLatin1String("file")) { - encodedMrl = QFile::encodeName(url).toPercentEncoding(encodingExclude); - } else { - encodedMrl = QUrl::toEncoded(options); - } - - return encodedMrl; -} - -} // namespace Phonon diff --git a/src/phonon/mrl.h b/src/phonon/mrl.h deleted file mode 100644 index ed8740918..000000000 --- a/src/phonon/mrl.h +++ /dev/null @@ -1,79 +0,0 @@ -/* This file is part of the KDE project - Copyright (C) 2011 Harald Sitter - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), Nokia Corporation - (or its successors, if any) and the KDE Free Qt Foundation, which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . -*/ - -#ifndef PHONON_MRL_H -#define PHONON_MRL_H - -#include - -#include "phonon_export.h" - - -namespace Phonon -{ - -/** \class Mrl mrl.h phonon/Mrl - * Media Resource Locator - A QUrl particularly for MediaSources. - * - * Whenever working with URLs/URIs that actually are referencing a media resource - * a Mrl should be used rather than a QUrl. Mrl has functions particularly - * made for a media related use case and additionally overloads some of QUrl's - * functions to work more reasonable in a Phonon context. - * - * A Mrl can be used just like a QUrl. - * - * \ingroup Playback - * \author Harald Sitter - */ -class PHONON_EXPORT Mrl : public QUrl -{ -public: - Mrl(); - Mrl(const Mrl ©); - - Mrl(const QUrl &url); - Mrl(const QString &url); - - Mrl &operator =(const Mrl ©); -#ifndef QT_NO_URL_CAST_FROM_STRING - Mrl &operator =(const QString &url); -#endif - - /** - * Returns the encoded representation of the MRL if it's valid; otherwise - * an empty QByteArray is returned. The output can be customized by passing - * flags with options. - * - * If the MRL is a local file it will first be encoded using the local encoding, - * otherwise it gets converted to UTF-8, and all non-ASCII characters are - * then percent encoded. - * - * \arg options QUrl::FormattingOptions to manipulate what the output should look like - * - * \returns the encoded MRL or an empty QByteArray if the MRL was invalid - */ - QByteArray toEncoded(FormattingOptions options = None) const; -}; - -} // namespace Phonon - - -#endif // PHONON_MRL_H diff --git a/src/phonon/objectdescription.cpp b/src/phonon/objectdescription.cpp deleted file mode 100644 index 3a6646496..000000000 --- a/src/phonon/objectdescription.cpp +++ /dev/null @@ -1,141 +0,0 @@ -/* This file is part of the KDE project - Copyright (C) 2006-2008 Matthias Kretz - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), Nokia Corporation - (or its successors, if any) and the KDE Free Qt Foundation, which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . - -*/ - -#include "objectdescription.h" -#include "objectdescription_p.h" - -#include -#include -#include "factory_p.h" -#include -#include "backendinterface.h" -#include "platformplugin.h" - -namespace Phonon -{ - -ObjectDescriptionData::ObjectDescriptionData(int index, const QHash &properties) - : d(new ObjectDescriptionPrivate(index, properties)) -{ -} - -ObjectDescriptionData::ObjectDescriptionData(ObjectDescriptionPrivate *dd) - : d(dd) -{ -} - -ObjectDescriptionData::~ObjectDescriptionData() -{ - delete d; -} - -bool ObjectDescriptionData::operator==(const ObjectDescriptionData &otherDescription) const -{ - if (!isValid()) { - return !otherDescription.isValid(); - } - if (!otherDescription.isValid()) { - return false; - } - return *d == *otherDescription.d; -} - -int ObjectDescriptionData::index() const -{ - if (!isValid()) { - return -1; - } - return d->index; -} - -QString ObjectDescriptionData::name() const -{ - if (!isValid()) { - return QString(); - } - return d->name; -} - -QString ObjectDescriptionData::description() const -{ - if (!isValid()) { - return QString(); - } - return d->description; -} - -QVariant ObjectDescriptionData::property(const char *name) const -{ - if (!isValid()) { - return QVariant(); - } - return d->properties.value(name); -} - -QList ObjectDescriptionData::propertyNames() const -{ - if (!isValid()) { - return QList(); - } - return d->properties.keys(); -} - -bool ObjectDescriptionData::isValid() const -{ - return d != 0; -} - -ObjectDescriptionData *ObjectDescriptionData::fromIndex(ObjectDescriptionType type, int index) -{ -#ifndef QT_NO_PHONON_PLATFORMPLUGIN - // prefer to get the ObjectDescriptionData from the platform plugin - PlatformPlugin *platformPlugin = Factory::platformPlugin(); - if (platformPlugin) { - QList indexes = platformPlugin->objectDescriptionIndexes(type); - if (indexes.contains(index)) { - QHash properties = platformPlugin->objectDescriptionProperties(type, index); - return new ObjectDescriptionData(index, properties); - } - } -#endif //QT_NO_PHONON_PLATFORMPLUGIN - - BackendInterface *iface = qobject_cast(Factory::backend()); - if (iface) { - QList indexes = iface->objectDescriptionIndexes(type); - if (indexes.contains(index)) { - QHash properties = iface->objectDescriptionProperties(type, index); - return new ObjectDescriptionData(index, properties); - } - } - - return new ObjectDescriptionData(0); // invalid -} - -} //namespace Phonon - - -void Phonon::registerMetaTypes() -{ - // Deprecated, does nothing -} - -// vim: sw=4 ts=4 diff --git a/src/phonon/objectdescription.h b/src/phonon/objectdescription.h deleted file mode 100644 index 15aa9f1cd..000000000 --- a/src/phonon/objectdescription.h +++ /dev/null @@ -1,390 +0,0 @@ -/* - Copyright (C) 2006-2007 Matthias Kretz - Copyright (C) 2011 Harald Sitter - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), Nokia Corporation - (or its successors, if any) and the KDE Free Qt Foundation, which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . -*/ - -#ifndef PHONON_OBJECTDESCRIPTION_H -#define PHONON_OBJECTDESCRIPTION_H - -#include "phonon_export.h" - -#include -#include -#include -#include -#include -#include - - -namespace Phonon -{ - class ObjectDescriptionPrivate; - - /** - * Defines the type of information that is contained in a ObjectDescription - * object. - * - * \ingroup Backend - */ - enum ObjectDescriptionType - { - /** - * Audio output devices. This can be soundcards (with different drivers), soundservers or - * other virtual outputs like playback on a different computer on the - * network. - * - * For Hardware devices the backend should use libkaudiodevicelist - * (AudioDevice and AudioDeviceEnumerator) which will list removable - * devices even when they are unplugged and provide a unique identifier - * that can make backends use the same identifiers. - */ - AudioOutputDeviceType, - - /** - * Lists all processing effects the backend supports. - */ - EffectType, - AudioChannelType, - SubtitleType, - - /** - * Audio capture devices. This can be soundcards (with different drivers), soundservers or - * other virtual inputs like capture on a different computer on the - * network. - * - * For Hardware devices the backend should use libkaudiodevicelist - * (AudioDevice and AudioDeviceEnumerator) which will list removable - * devices even when they are unplugged and provide a unique identifier - * that can make backends use the same identifiers. - */ - AudioCaptureDeviceType, - - /** - * Video capture devices. Includes webcams. - */ - VideoCaptureDeviceType - - //VideoOutputDeviceType, - //AudioCodecType, - //VideoCodecType, - //ContainerFormatType, - //VisualizationType, - }; - -/** \internal - * \class ObjectDescriptionData objectdescription.h phonon/ObjectDescription - * \brief Data class for objects describing devices or features of the backend. - * - * \author Matthias Kretz - * \see BackendCapabilities - */ -class PHONON_EXPORT ObjectDescriptionData : public QSharedData //krazy:exclude=dpointer (it's protected, which should be fine for this type of class) -{ - public: - /** - * Returns \c true if this ObjectDescription describes the same - * as \p otherDescription; otherwise returns \c false. - */ - bool operator==(const ObjectDescriptionData &otherDescription) const; - - /** - * Returns the name of the capture source. - * - * \return A string that should be presented to the user to - * choose the capture source. - */ - QString name() const; - - /** - * Returns a description of the capture source. This text should - * make clear what sound source this is, which is sometimes hard - * to describe or understand from just the name. - * - * \return A string describing the capture source. - */ - QString description() const; - - /** - * Returns a named property. - * - * If the property is not set an invalid value is returned. - * - * \see propertyNames() - */ - QVariant property(const char *name) const; - - /** - * Returns all names that return valid data when property() is called. - * - * \see property() - */ - QList propertyNames() const; - - /** - * Returns \c true if the Tuple is valid (index != -1); otherwise returns - * \c false. - */ - bool isValid() const; - - /** - * A unique identifier for this device/. Used internally - * to distinguish between the devices/. - * - * \return An integer that uniquely identifies every device/ - */ - int index() const; - - static ObjectDescriptionData *fromIndex(ObjectDescriptionType type, int index); - - ~ObjectDescriptionData(); - - ObjectDescriptionData(ObjectDescriptionPrivate * = 0); - ObjectDescriptionData(int index, const QHash &properties); - - protected: - ObjectDescriptionPrivate *const d; - - private: - ObjectDescriptionData &operator=(const ObjectDescriptionData &rhs); -}; - -template class ObjectDescriptionModel; - -/** \class ObjectDescription objectdescription.h phonon/ObjectDescription - * \short Provides a tuple of enduser visible name and description. - * - * Some parts give the enduser choices, e.g. what source to capture audio from. - * These choices are described by the name and description methods of this class - * and identified with the id method. Subclasses then define additional - * information like which audio and video choices belong together. - * - * \ingroup Frontend - * \author Matthias Kretz - */ -template -class ObjectDescription -{ - public: - /** - * Returns a new description object that describes the - * device/effect/codec/... with the given \p index. - */ - static inline ObjectDescription fromIndex(int index) { //krazy:exclude=inline - return ObjectDescription(QExplicitlySharedDataPointer(ObjectDescriptionData::fromIndex(T, index))); - } - - /** - * Returns \c true if this ObjectDescription describes the same - * as \p otherDescription; otherwise returns \c false. - */ - inline bool operator==(const ObjectDescription &otherDescription) const { //krazy:exclude=inline - return *d == *otherDescription.d; - } - - /** - * Returns \c false if this ObjectDescription describes the same - * as \p otherDescription; otherwise returns \c true. - */ - inline bool operator!=(const ObjectDescription &otherDescription) const { //krazy:exclude=inline - return !operator==(otherDescription); - } - - /** - * Returns the name of the capture source. - * - * \return A string that should be presented to the user to - * choose the capture source. - */ - inline QString name() const { return d->name(); } //krazy:exclude=inline - - /** - * Returns a description of the capture source. This text should - * make clear what sound source this is, which is sometimes hard - * to describe or understand from just the name. - * - * \return A string describing the capture source. - */ - inline QString description() const { return d->description(); } //krazy:exclude=inline - - /** - * Returns a named property. - * - * If the property is not set an invalid value is returned. - * - * \see propertyNames() - */ - inline QVariant property(const char *name) const { return d->property(name); } //krazy:exclude=inline - - /** - * Returns all names that return valid data when property() is called. - * - * \see property() - */ - inline QList propertyNames() const { return d->propertyNames(); } //krazy:exclude=inline - - /** - * Returns \c true if the Tuple is valid (index != -1); otherwise returns - * \c false. - */ - inline bool isValid() const { return d->isValid(); } //krazy:exclude=inline - - /** - * A unique identifier for this device/. Used internally - * to distinguish between the devices/. - * - * \return An integer that uniquely identifies every device/ - */ - inline int index() const { return d->index(); } //krazy:exclude=inline - - ObjectDescription() : d(new ObjectDescriptionData(0)) {} - ObjectDescription(int index, const QHash &properties) : d(new ObjectDescriptionData(index, properties)) {} - - protected: - friend class ObjectDescriptionModel; - ObjectDescription(const QExplicitlySharedDataPointer &dd) : d(dd) {} - QExplicitlySharedDataPointer d; -}; - -template -QDebug operator<<(QDebug dbg, const ObjectDescription &d) -{ - dbg.nospace() << "\n{\n"; - dbg.nospace() << " index: " << d.index() << "\n"; - Q_FOREACH (const QByteArray &propertyName, d.propertyNames()) { - dbg.nospace() << " " << propertyName << ": " << - d.property(propertyName).toString() << "\n"; - } - dbg.nospace() << "}\n"; - - return dbg.space(); -} - -/** - * \ingroup BackendInformation - */ -typedef ObjectDescription AudioOutputDevice; -/** - * \ingroup BackendInformation - */ -#ifndef PHONON_NO_AUDIOCAPTURE -typedef ObjectDescription AudioCaptureDevice; -#endif //PHONON_NO_AUDIOCAPTURE -/** - * \ingroup BackendInformation - */ -//typedef ObjectDescription VideoOutputDevice; -/** - * \ingroup BackendInformation - */ -#ifndef PHONON_NO_VIDEOCAPTURE -typedef ObjectDescription VideoCaptureDevice; -#endif -/** - * \ingroup BackendInformation - */ -#ifndef QT_NO_PHONON_EFFECT -typedef ObjectDescription EffectDescription; -#endif //QT_NO_PHONON_EFFECT - -/** - * \ingroup BackendInformation - */ -//typedef ObjectDescription AudioCodecDescription; -/** - * \ingroup BackendInformation - */ -//typedef ObjectDescription VideoCodecDescription; -/** - * \ingroup BackendInformation - */ -//typedef ObjectDescription ContainerFormatDescription; -/** - * \ingroup BackendInformation - */ -//typedef ObjectDescription VisualizationDescription; -#ifndef QT_NO_PHONON_MEDIACONTROLLER -typedef ObjectDescription AudioChannelDescription; -typedef ObjectDescription SubtitleDescription; -#endif //QT_NO_PHONON_MEDIACONTROLLER - -/** - * \short Information about how to access a device - * \ingroup BackendInformation - * - * To access a device, one needs the driver name (alsa, oss, pulse for example), - * and the device name (dependent on the driver name). This type is a pair of a - * driver and a device name. - * - * \see DeviceAccessList - */ -typedef QPair DeviceAccess; - -/** - * \short Information about methods for accessing a device - * \ingroup BackendInformation - * - * It is used by the platform plugin or the backend to provide information about how - * to access a certain device. To access a device, one needs the driver name (alsa, oss, - * pulse for example), and the device name (dependent on the driver name). This type - * is essentialy a list of pairs of driver and device names. - * - * It can be put in an ObjectDescriptionData property list. - * - * \see DeviceAccess - * \see AudioCaptureDevice - */ -typedef QList DeviceAccessList; - -void PHONON_EXPORT_DEPRECATED registerMetaTypes(); - -} //namespace Phonon - -Q_DECLARE_METATYPE(Phonon::AudioOutputDevice) -Q_DECLARE_METATYPE(QList) - -#ifndef PHONON_NO_AUDIOCAPTURE -Q_DECLARE_METATYPE(Phonon::AudioCaptureDevice) -Q_DECLARE_METATYPE(QList) -#endif //PHONON_NO_AUDIOCAPTURE - -#ifndef PHONON_NO_VIDEOCAPTURE -Q_DECLARE_METATYPE(Phonon::VideoCaptureDevice) -Q_DECLARE_METATYPE(QList) -#endif //PHONON_NO_VIDEOCAPTURE - -#ifndef QT_NO_PHONON_EFFECT -Q_DECLARE_METATYPE(QList) -Q_DECLARE_METATYPE(Phonon::EffectDescription) -#endif //QT_NO_PHONON_EFFECT - - -#ifndef QT_NO_PHONON_MEDIACONTROLLER -Q_DECLARE_METATYPE(Phonon::AudioChannelDescription) -Q_DECLARE_METATYPE(Phonon::SubtitleDescription) -Q_DECLARE_METATYPE(QList) -Q_DECLARE_METATYPE(QList) -#endif //QT_NO_PHONON_MEDIACONTROLLER - -Q_DECLARE_METATYPE(Phonon::DeviceAccess) -Q_DECLARE_METATYPE(Phonon::DeviceAccessList) - - - -#endif // PHONON_OBJECTDESCRIPTION_H diff --git a/src/phonon/objectdescription_p.h b/src/phonon/objectdescription_p.h deleted file mode 100644 index bed82ccf1..000000000 --- a/src/phonon/objectdescription_p.h +++ /dev/null @@ -1,60 +0,0 @@ -/* This file is part of the KDE project - Copyright (C) 2006-2007 Matthias Kretz - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), Nokia Corporation - (or its successors, if any) and the KDE Free Qt Foundation, which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . - -*/ - -#ifndef PHONON_OBJECTDESCRIPTION_P_H -#define PHONON_OBJECTDESCRIPTION_P_H - -#include -#include -#include -#include -#include "phononnamespace_p.h" - -namespace Phonon -{ - class ObjectDescriptionPrivate - { - public: - ObjectDescriptionPrivate(int _index, const QHash &_properties) - : index(_index), - name(_properties["name"].toString()), - description(_properties["description"].toString()), - properties(_properties) - { - } - - bool operator==(const ObjectDescriptionPrivate &rhs) const - { - if (index == rhs.index && (name != rhs.name || description != rhs.description)) - pError() << "Same index (" << index << - "), but different name/description. This is a bug in the Phonon backend."; - return index == rhs.index;// && name == rhs.name && description == rhs.description; - } - - int index; - QString name, description; - QHash properties; - }; -} // namespace Phonon - -#endif // PHONON_OBJECTDESCRIPTION_P_H -// vim: sw=4 ts=4 tw=80 diff --git a/src/phonon/objectdescriptionmodel.cpp b/src/phonon/objectdescriptionmodel.cpp deleted file mode 100644 index 894d56790..000000000 --- a/src/phonon/objectdescriptionmodel.cpp +++ /dev/null @@ -1,380 +0,0 @@ -/* This file is part of the KDE project - Copyright (C) 2006-2007 Matthias Kretz - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), Nokia Corporation - (or its successors, if any) and the KDE Free Qt Foundation, which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . - -*/ - -#include "objectdescriptionmodel.h" -#include "objectdescriptionmodel_p.h" -#include "phonondefs_p.h" -#include "platform_p.h" -#include -#include "objectdescription.h" -#include "phononnamespace_p.h" -#include -#include -#include -#include -#include "factory_p.h" - -#ifndef QT_NO_PHONON_OBJECTDESCRIPTIONMODEL - -// If this wasn't so terrible ... -// ObjectDescriptionModel is a template class. Moc however cannot handle -// templates so the solution done here is to *manually* do whatever moc does. - -static const uint qt_meta_data_Phonon__ObjectDescriptionModel[] = { - - // content: - 6, // revision - 0, // classname - 0, 0, // classinfo - 0, 0, // methods - 0, 0, // properties - 0, 0, // enums/sets - 0, 0, // constructors - 0, // flags - 0, // signalCount - - 0 // eod -}; - - static const char qt_meta_stringdata_Phonon__ObjectDescriptionModel_AudioOutputDeviceType[] = { "Phonon::AudioOutputDevice\0" }; - static const char qt_meta_stringdata_Phonon__ObjectDescriptionModel_AudioCaptureDeviceType[] = { "Phonon::AudioCaptureDevice\0" }; - static const char qt_meta_stringdata_Phonon__ObjectDescriptionModel_VideoCaptureDeviceType[] = { "Phonon::VideoCaptureDevice\0" }; - static const char qt_meta_stringdata_Phonon__ObjectDescriptionModel_EffectType[] = { "Phonon::EffectDescription\0" }; - static const char qt_meta_stringdata_Phonon__ObjectDescriptionModel_AudioChannelType[] = { "Phonon::AudioChannelDescription\0" }; - static const char qt_meta_stringdata_Phonon__ObjectDescriptionModel_SubtitleType[] = { "Phonon::SubtitleDescription\0" }; - -#define OBJECT_DESCRIPTION_MODEL_STATIC_META_OBJECT(X) { \ - &QAbstractListModel::staticMetaObject, \ - qt_meta_stringdata_Phonon__ObjectDescriptionModel_ ## X, \ - qt_meta_data_Phonon__ObjectDescriptionModel, \ - 0, 0 } - -namespace Phonon -{ - -template<> const QMetaObject ObjectDescriptionModel::staticMetaObject = { - OBJECT_DESCRIPTION_MODEL_STATIC_META_OBJECT(AudioOutputDeviceType) -}; -template<> const QMetaObject ObjectDescriptionModel::staticMetaObject = { - OBJECT_DESCRIPTION_MODEL_STATIC_META_OBJECT(AudioCaptureDeviceType) -}; -template<> const QMetaObject ObjectDescriptionModel::staticMetaObject = { - OBJECT_DESCRIPTION_MODEL_STATIC_META_OBJECT(VideoCaptureDeviceType) -}; -template<> const QMetaObject ObjectDescriptionModel::staticMetaObject = { - OBJECT_DESCRIPTION_MODEL_STATIC_META_OBJECT(EffectType) -}; -template<> const QMetaObject ObjectDescriptionModel::staticMetaObject = { - OBJECT_DESCRIPTION_MODEL_STATIC_META_OBJECT(AudioChannelType) -}; -template<> const QMetaObject ObjectDescriptionModel::staticMetaObject = { - OBJECT_DESCRIPTION_MODEL_STATIC_META_OBJECT(SubtitleType) -}; - -template -const QMetaObject *ObjectDescriptionModel::metaObject() const -{ - return &staticMetaObject; -} - -template -void *ObjectDescriptionModel::qt_metacast(const char *_clname) -{ - if (!_clname) { - return 0; - } - if (!strcmp(_clname, ObjectDescriptionModel::staticMetaObject.className())) { - return static_cast(const_cast *>(this)); - } - return QAbstractListModel::qt_metacast(_clname); -} - -/* -template -int ObjectDescriptionModel::qt_metacall(QMetaObject::Call _c, int _id, void **_a) -{ - return QAbstractListModel::qt_metacall(_c, _id, _a); -} -*/ - -int ObjectDescriptionModelData::rowCount(const QModelIndex &parent) const -{ - if (parent.isValid()) - return 0; - - return d->data.size(); -} - -QVariant ObjectDescriptionModelData::data(const QModelIndex &index, int role) const -{ - if (!index.isValid() || index.row() >= d->data.size() || index.column() != 0) - return QVariant(); - - switch(role) - { - case Qt::EditRole: - case Qt::DisplayRole: - return d->data.at(index.row())->name(); - break; - case Qt::ToolTipRole: - return d->data.at(index.row())->description(); - break; - case Qt::DecorationRole: - { - /* Returns an icon if available. Paint a subicon representing the entity (platform - * plugin or backend) which discovered this object, if it is specified */ - QVariant icon = d->data.at(index.row())->property("icon"); - QVariant discovererIcon = d->data.at(index.row())->property("discovererIcon"); - if (icon.isValid()) { - if (icon.type() == QVariant::String) { - icon = Platform::icon(icon.toString()); - } - if (discovererIcon.type() == QVariant::String) { - discovererIcon = Platform::icon(discovererIcon.toString()); - } - if (icon.type() == QVariant::Icon) { - if (discovererIcon.type() == QVariant::Icon) { - // Insert the subicon in the top-right corner of the icon - QPixmap pixmap = icon.value().pixmap(QSize(64, 64)); - QPixmap subPixmap = discovererIcon.value().pixmap(QSize(22, 22)); - QPainter painter(&pixmap); - painter.drawPixmap(42, 0, subPixmap); - return QIcon(pixmap); - } else { - return icon; - } - } - } - } - return QVariant(); - default: - return QVariant(); -} -} - -Qt::ItemFlags ObjectDescriptionModelData::flags(const QModelIndex &index) const -{ - if(!index.isValid() || index.row() >= d->data.size() || index.column() != 0) { - return Qt::ItemIsDropEnabled; - } - - QVariant available = d->data.at(index.row())->property("available"); - if (available.isValid() && available.type() == QVariant::Bool && !available.toBool()) { - return Qt::ItemIsSelectable | Qt::ItemIsDragEnabled; - } - return Qt::ItemIsSelectable | Qt::ItemIsEnabled | Qt::ItemIsDragEnabled; -} - -QList ObjectDescriptionModelData::tupleIndexOrder() const -{ - QList ret; - for (int i = 0; i < d->data.size(); ++i) { - ret.append(d->data.at(i)->index()); - } - return ret; -} - -int ObjectDescriptionModelData::tupleIndexAtPositionIndex(int positionIndex) const -{ - return d->data.at(positionIndex)->index(); -} - -QMimeData *ObjectDescriptionModelData::mimeData(ObjectDescriptionType type, const QModelIndexList &indexes) const -{ - QMimeData *mimeData = new QMimeData; - QByteArray encodedData; - QDataStream stream(&encodedData, QIODevice::WriteOnly); - QModelIndexList::const_iterator end = indexes.constEnd(); - QModelIndexList::const_iterator index = indexes.constBegin(); - for(; index!=end; ++index) { - if ((*index).isValid()) { - stream << d->data.at((*index).row())->index(); - } - } - //pDebug() << Q_FUNC_INFO << "setting mimeData to" << mimeTypes(type).first() << "=>" << encodedData.toHex(); - mimeData->setData(mimeTypes(type).first(), encodedData); - return mimeData; -} - -void ObjectDescriptionModelData::moveUp(const QModelIndex &index) -{ - if (!index.isValid() || index.row() >= d->data.size() || index.row() < 1 || index.column() != 0) - return; - - emit d->model->layoutAboutToBeChanged(); - QModelIndex above = index.sibling(index.row() - 1, index.column()); - d->data.swap(index.row(), above.row()); - QModelIndexList from, to; - from << index << above; - to << above << index; - d->model->changePersistentIndexList(from, to); - emit d->model->layoutChanged(); -} - -void ObjectDescriptionModelData::moveDown(const QModelIndex &index) -{ - if (!index.isValid() || index.row() >= d->data.size() - 1 || index.column() != 0) - return; - - emit d->model->layoutAboutToBeChanged(); - QModelIndex below = index.sibling(index.row() + 1, index.column()); - d->data.swap(index.row(), below.row()); - QModelIndexList from, to; - from << index << below; - to << below << index; - d->model->changePersistentIndexList(from, to); - emit d->model->layoutChanged(); -} - -ObjectDescriptionModelData::ObjectDescriptionModelData(QAbstractListModel *model) - : d(new ObjectDescriptionModelDataPrivate(model)) -{ -} - -ObjectDescriptionModelData::~ObjectDescriptionModelData() -{ - delete d; -} - -void ObjectDescriptionModelData::setModelData(const QList > &newData) -{ - d->model->beginResetModel(); - d->data = newData; - d->model->endResetModel(); -} - -QList > ObjectDescriptionModelData::modelData() const -{ - return d->data; -} - -QExplicitlySharedDataPointer ObjectDescriptionModelData::modelData(const QModelIndex &index) const -{ - if (!index.isValid() || index.row() >= d->data.size() || index.column() != 0) { - return QExplicitlySharedDataPointer(new ObjectDescriptionData(0)); - } - return d->data.at(index.row()); -} - -Qt::DropActions ObjectDescriptionModelData::supportedDropActions() const -{ - //pDebug() << Q_FUNC_INFO; - return Qt::MoveAction; -} - -bool ObjectDescriptionModelData::dropMimeData(ObjectDescriptionType type, const QMimeData *data, Qt::DropAction action, - int row, int column, const QModelIndex &parent) -{ - Q_UNUSED(action); - Q_UNUSED(column); - Q_UNUSED(parent); - //pDebug() << Q_FUNC_INFO << data << action << row << column << parent; - - QString format = mimeTypes(type).first(); - if (!data->hasFormat(format)) { - return false; - } - - if (row == -1) { - row = d->data.size(); - } - - QByteArray encodedData = data->data(format); - QDataStream stream(&encodedData, QIODevice::ReadOnly); - QList > toInsert; - while (!stream.atEnd()) { - int otherIndex; - stream >> otherIndex; - ObjectDescriptionData *obj = ObjectDescriptionData::fromIndex(type, otherIndex); - - if (obj->isValid()) { - toInsert << QExplicitlySharedDataPointer(obj); - } else { - delete obj; - } - } - d->model->beginInsertRows(QModelIndex(), row, row + toInsert.size() - 1); - for (int i = 0 ; i < toInsert.count(); ++i) { - d->data.insert(row, toInsert.at(i)); - } - d->model->endInsertRows(); - return true; -} - - -bool ObjectDescriptionModelData::removeRows(int row, int count, const QModelIndex &parent) -{ - //pDebug() << Q_FUNC_INFO << row << count << parent; - if (parent.isValid() || row + count > d->data.size()) { - return false; - } - d->model->beginRemoveRows(parent, row, row + count - 1); - for (;count > 0; --count) { - d->data.removeAt(row); - } - d->model->endRemoveRows(); - return true; -} - -/* -template -bool ObjectDescriptionModel::insertRows(int row, int count, const QModelIndex &parent) -{ - pDebug() << Q_FUNC_INFO << row << count << parent; - if (parent.isValid() || row < 0 || row > d->data.size()) { - return false; - } - beginInsertRows(parent, row, row + count - 1); - for (;count > 0; --count) { - d->data.insert(row, ObjectDescription()); - } - endInsertRows(); - return true; -} -*/ - -QStringList ObjectDescriptionModelData::mimeTypes(ObjectDescriptionType type) const -{ - return QStringList(QLatin1String("application/x-phonon-objectdescription") + QString::number(static_cast(type))); -} - -#if !defined(Q_CC_MSVC) || _MSC_VER > 1300 || defined(Q_CC_INTEL) || defined(Q_CC_MINGW) -#define INSTANTIATE_META_FUNCTIONS(type) \ -template const QMetaObject *ObjectDescriptionModel::metaObject() const; \ -template void *ObjectDescriptionModel::qt_metacast(const char *) - -INSTANTIATE_META_FUNCTIONS(AudioOutputDeviceType); -INSTANTIATE_META_FUNCTIONS(AudioCaptureDeviceType); -INSTANTIATE_META_FUNCTIONS(VideoCaptureDeviceType); -INSTANTIATE_META_FUNCTIONS(EffectType); -INSTANTIATE_META_FUNCTIONS(AudioChannelType); -INSTANTIATE_META_FUNCTIONS(SubtitleType); -#endif -/*INSTANTIATE_META_FUNCTIONS(VideoOutputDeviceType); -INSTANTIATE_META_FUNCTIONS(AudioCodecType); -INSTANTIATE_META_FUNCTIONS(VideoCodecType); -INSTANTIATE_META_FUNCTIONS(ContainerFormatType); -INSTANTIATE_META_FUNCTIONS(VisualizationType); -*/ -} // namespace Phonon - -#endif //QT_NO_PHONON_OBJECTDESCRIPTIONMODEL diff --git a/src/phonon/objectdescriptionmodel.h b/src/phonon/objectdescriptionmodel.h deleted file mode 100644 index c9a59242c..000000000 --- a/src/phonon/objectdescriptionmodel.h +++ /dev/null @@ -1,373 +0,0 @@ -/* This file is part of the KDE project - Copyright (C) 2006-2007 Matthias Kretz - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), Nokia Corporation - (or its successors, if any) and the KDE Free Qt Foundation, which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . - -*/ - -#ifndef PHONON_OBJECTDESCRIPTIONMODEL_H -#define PHONON_OBJECTDESCRIPTIONMODEL_H - -#include "phonon_export.h" -#include "phonondefs.h" -#include "objectdescription.h" -#include -#include -#include - - -#ifndef QT_NO_PHONON_OBJECTDESCRIPTIONMODEL - -namespace Phonon -{ - class ObjectDescriptionModelDataPrivate; - - /** \internal - * \class ObjectDescriptionModelData objectdescriptionmodel.h phonon/ObjectDescriptionModelData - * \brief Data class for models for ObjectDescription objects. - * - * \author Matthias Kretz - */ - class PHONON_EXPORT ObjectDescriptionModelData - { - public: - /** - * Returns the number of rows in the model. This value corresponds - * to the size of the list passed through setModelData. - * - * \param parent The optional \p parent argument is used in most models to specify - * the parent of the rows to be counted. Because this is a list if a - * valid parent is specified the result will always be 0. - * - * Reimplemented from QAbstractItemModel. - * - * \see QAbstractItemModel::rowCount - */ - int rowCount(const QModelIndex &parent = QModelIndex()) const; - - /** - * Returns data from the item with the given \p index for the specified - * \p role. - * If the view requests an invalid index, an invalid variant is - * returned. - * - * Reimplemented from QAbstractItemModel. - * - * \see QAbstractItemModel::data - * \see Qt::ItemDataRole - */ - QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const; - - /** - * Reimplemented to show unavailable devices as disabled (but still - * selectable). - */ - Qt::ItemFlags flags(const QModelIndex &index) const; - - /** - * Returns a list of indexes in the same order as they are in the - * model. The indexes come from the ObjectDescription::index - * method. - * - * This is useful to let the user define a list of preference. - */ - QList tupleIndexOrder() const; - - /** - * Returns the ObjectDescription::index for the tuple - * at the given position \p positionIndex. For example a - * QComboBox will give you the currentIndex as the - * position in the list. But to select the according - * AudioOutputDevice using AudioOutputDevice::fromIndex - * you can use this method. - * - * \param positionIndex The position in the list. - */ - int tupleIndexAtPositionIndex(int positionIndex) const; - - /** - * Returns the MIME data that dropMimeData() can use to create new - * items. - */ - QMimeData *mimeData(ObjectDescriptionType type, const QModelIndexList &indexes) const; - - /** - * Moves the item at the given \p index up. In the resulting list - * the items at index.row() and index.row() - 1 are swapped. - * - * Connected views are updated automatically. - */ - void moveUp(const QModelIndex &index); - - /** - * Moves the item at the given \p index down. In the resulting list - * the items at index.row() and index.row() + 1 are swapped. - * - * Connected views are updated automatically. - */ - void moveDown(const QModelIndex &index); - - void setModelData(const QList > &data); - QList > modelData() const; - QExplicitlySharedDataPointer modelData(const QModelIndex &index) const; - Qt::DropActions supportedDropActions() const; - bool dropMimeData(ObjectDescriptionType type, const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent); - bool removeRows(int row, int count, const QModelIndex &parent = QModelIndex()); - QStringList mimeTypes(ObjectDescriptionType type) const; - - ObjectDescriptionModelData(QAbstractListModel *); - protected: - ~ObjectDescriptionModelData(); - //ObjectDescriptionModelData(ObjectDescriptionModelDataPrivate *dd); - ObjectDescriptionModelDataPrivate *const d; - }; - -// Windows builds (at least) do not support export declaration on templated class -// But if you export a member function, the vtable is implicitly exported -#define PHONON_TEMPLATE_CLASS_EXPORT -#define PHONON_TEMPLATE_CLASS_MEMBER_EXPORT PHONON_EXPORT - - /** \class ObjectDescriptionModel objectdescriptionmodel.h Phonon/ObjectDescriptionModel - * \short The ObjectDescriptionModel class provides a model from - * a list of ObjectDescription objects. - * - * ObjectDescriptionModel is a readonly model that supplies a list - * using ObjectDescription::name() for the text and - * ObjectDescription::description() for the tooltip. If set the properties - * "icon" and "available" are used to set the decoration and disable the - * item (disabled only visually, you can still select and drag it). - * - * It also provides the methods moveUp() and moveDown() to order the list. - * Additionally drag and drop is possible so that - * QAbstractItemView::InternalMove can be used. - * The resulting order of the ObjectDescription::index() values can then be - * retrieved using tupleIndexOrder(). - * - * An example use case would be to give the user a QComboBox to select - * the output device: - * \code - * QComboBox *cb = new QComboBox(parentWidget); - * ObjectDescriptionModel *model = new ObjectDescriptionModel(cb); - * model->setModelData(BackendCapabilities::availableAudioOutputDevices()); - * cb->setModel(model); - * cb->setCurrentIndex(0); // select first entry - * \endcode - * - * And to retrieve the selected AudioOutputDevice: - * \code - * int cbIndex = cb->currentIndex(); - * AudioOutputDevice selectedDevice = model->modelData(cbIndex); - * \endcode - * - * \ingroup Frontend - * \author Matthias Kretz - */ - template - class PHONON_TEMPLATE_CLASS_EXPORT ObjectDescriptionModel : public QAbstractListModel - { - public: - Q_OBJECT_CHECK - - /** \internal */ - static PHONON_TEMPLATE_CLASS_MEMBER_EXPORT const QMetaObject staticMetaObject; - /** \internal */ - PHONON_TEMPLATE_CLASS_MEMBER_EXPORT const QMetaObject *metaObject() const; - /** \internal */ - PHONON_TEMPLATE_CLASS_MEMBER_EXPORT void *qt_metacast(const char *_clname); - //int qt_metacall(QMetaObject::Call _c, int _id, void **_a); - - /** - * Returns the number of rows in the model. This value corresponds - * to the size of the list passed through setModelData. - * - * \param parent The optional \p parent argument is used in most models to specify - * the parent of the rows to be counted. Because this is a list if a - * valid parent is specified the result will always be 0. - * - * Reimplemented from QAbstractItemModel. - * - * \see QAbstractItemModel::rowCount - */ - inline int rowCount(const QModelIndex &parent = QModelIndex()) const { return d->rowCount(parent); } //krazy:exclude=inline - - /** - * Returns data from the item with the given \p index for the specified - * \p role. - * If the view requests an invalid index, an invalid variant is - * returned. - * - * Reimplemented from QAbstractItemModel. - * - * \see QAbstractItemModel::data - * \see Qt::ItemDataRole - */ - inline QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const { return d->data(index, role); } //krazy:exclude=inline - - /** - * Reimplemented to show unavailable devices as disabled (but still - * selectable). - */ - inline Qt::ItemFlags flags(const QModelIndex &index) const { return d->flags(index); } //krazy:exclude=inline - - /** - * Returns a list of indexes in the same order as they are in the - * model. The indexes come from the ObjectDescription::index - * method. - * - * This is useful to let the user define a list of preference. - */ - inline QList tupleIndexOrder() const { return d->tupleIndexOrder(); } //krazy:exclude=inline - - /** - * Returns the ObjectDescription::index for the tuple - * at the given position \p positionIndex. For example a - * QComboBox will give you the currentIndex as the - * position in the list. But to select the according - * AudioOutputDevice using AudioOutputDevice::fromIndex - * you can use this method. - * - * \param positionIndex The position in the list. - */ - inline int tupleIndexAtPositionIndex(int positionIndex) const { return d->tupleIndexAtPositionIndex(positionIndex); } //krazy:exclude=inline - - /** - * Returns the MIME data that dropMimeData() can use to create new - * items. - */ - inline QMimeData *mimeData(const QModelIndexList &indexes) const { return d->mimeData(type, indexes); } //krazy:exclude=inline - - /** - * Moves the item at the given \p index up. In the resulting list - * the items at index.row() and index.row() - 1 are swapped. - * - * Connected views are updated automatically. - */ - inline void moveUp(const QModelIndex &index) { d->moveUp(index); } //krazy:exclude=inline - - /** - * Moves the item at the given \p index down. In the resulting list - * the items at index.row() and index.row() + 1 are swapped. - * - * Connected views are updated automatically. - */ - inline void moveDown(const QModelIndex &index) { d->moveDown(index); } //krazy:exclude=inline - - /** - * Constructs a ObjectDescription model with the - * given \p parent. - */ - explicit inline ObjectDescriptionModel(QObject *parent = 0) : QAbstractListModel(parent), d(new ObjectDescriptionModelData(this)) {} //krazy:exclude=inline - - /** - * Constructs a ObjectDescription model with the - * given \p parent and the given \p data. - */ - explicit inline ObjectDescriptionModel(const QList > &data, QObject *parent = 0) //krazy:exclude=inline - : QAbstractListModel(parent), d(new ObjectDescriptionModelData(this)) { setModelData(data); } - - /** - * Sets the model data using the list provided by \p data. - * - * All previous model data is cleared. - */ - inline void setModelData(const QList > &data) { //krazy:exclude=inline - QList > list; - for (int i = 0; i < data.count(); ++i) { - list += data.at(i).d; - } - d->setModelData(list); - } - - /** - * Returns the model data. - * - * As the order of the list might have changed this can be different - * to what was set using setModelData(). - */ - inline QList > modelData() const { //krazy:exclude=inline - QList > ret; - QList > list = d->modelData(); - for (int i = 0; i < list.count(); ++i) { - ret << ObjectDescription(list.at(i)); - } - return ret; - } - - /** - * Returns one ObjectDescription of the model data for the given \p index. - */ - inline ObjectDescription modelData(const QModelIndex &index) const { return ObjectDescription(d->modelData(index)); } //krazy:exclude=inline - - /** - * This model supports drag and drop to copy or move - * items. - */ - inline Qt::DropActions supportedDropActions() const { return d->supportedDropActions(); } //krazy:exclude=inline - - /** - * Accept drops from other models of the same ObjectDescriptionType. - * - * If a valid \p parent is given the dropped items will be inserted - * above that item. - */ - inline bool dropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent) { //krazy:exclude=inline - return d->dropMimeData(type, data, action, row, column, parent); - } - - /** - * Removes count rows starting with the given row. - * - * If a valid \p parent is given no rows are removed since this is a - * list model. - * - * Returns true if the rows were successfully removed; otherwise returns false. - */ - inline bool removeRows(int row, int count, const QModelIndex &parent = QModelIndex()) { //krazy:exclude=inline - return d->removeRows(row, count, parent); - } - - /** - * Returns a list of supported drag and drop MIME types. Currently - * it only supports one type used internally. - */ - inline QStringList mimeTypes() const { return d->mimeTypes(type); } //krazy:exclude=inline - - protected: - ObjectDescriptionModelData *const d; - }; - - typedef ObjectDescriptionModel AudioOutputDeviceModel; - typedef ObjectDescriptionModel AudioCaptureDeviceModel; - typedef ObjectDescriptionModel VideoCaptureDeviceModel; - typedef ObjectDescriptionModel EffectDescriptionModel; - typedef ObjectDescriptionModel AudioChannelDescriptionModel; - typedef ObjectDescriptionModel SubtitleDescriptionModel; -/* - typedef ObjectDescriptionModel VideoOutputDeviceModel; - typedef ObjectDescriptionModel AudioCodecDescriptionModel; - typedef ObjectDescriptionModel VideoCodecDescriptionModel; - typedef ObjectDescriptionModel ContainerFormatDescriptionModel; - typedef ObjectDescriptionModel VisualizationDescriptionModel;*/ - -} - -#endif //QT_NO_PHONON_OBJECTDESCRIPTIONMODEL - - -#endif // PHONON_OBJECTDESCRIPTIONMODEL_H -// vim: sw=4 ts=4 tw=80 diff --git a/src/phonon/objectdescriptionmodel_p.h b/src/phonon/objectdescriptionmodel_p.h deleted file mode 100644 index 25981ffbf..000000000 --- a/src/phonon/objectdescriptionmodel_p.h +++ /dev/null @@ -1,62 +0,0 @@ -/* This file is part of the KDE project - Copyright (C) 2006-2007 Matthias Kretz - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), Nokia Corporation - (or its successors, if any) and the KDE Free Qt Foundation, which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . - -*/ - -#ifndef PHONON_OBJECTDESCRIPTIONMODEL_P_H -#define PHONON_OBJECTDESCRIPTIONMODEL_P_H - -#include "objectdescriptionmodel.h" -#include -#include "objectdescription.h" - -#ifndef QT_NO_PHONON_OBJECTDESCRIPTIONMODEL - -namespace Phonon -{ - -class ListModelHelper : public QAbstractListModel -{ - public: - using QAbstractListModel::layoutAboutToBeChanged; - using QAbstractListModel::changePersistentIndexList; - using QAbstractListModel::layoutChanged; - using QAbstractListModel::beginResetModel; - using QAbstractListModel::endResetModel; - using QAbstractListModel::beginInsertRows; - using QAbstractListModel::endInsertRows; - using QAbstractListModel::beginRemoveRows; - using QAbstractListModel::endRemoveRows; -}; - -class ObjectDescriptionModelDataPrivate -{ - public: - ObjectDescriptionModelDataPrivate(QAbstractListModel *m) : model(reinterpret_cast(m)) {} - QList > data; - ListModelHelper *model; -}; - -} - -#endif //QT_NO_PHONON_OBJECTDESCRIPTIONMODEL - -#endif // PHONON_OBJECTDESCRIPTIONMODEL_P_H -// vim: sw=4 ts=4 tw=80 diff --git a/src/phonon/org.kde.Phonon.AudioOutput.xml b/src/phonon/org.kde.Phonon.AudioOutput.xml deleted file mode 100644 index 24983372c..000000000 --- a/src/phonon/org.kde.Phonon.AudioOutput.xml +++ /dev/null @@ -1,32 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/phonon/path.cpp b/src/phonon/path.cpp deleted file mode 100644 index 8f4265638..000000000 --- a/src/phonon/path.cpp +++ /dev/null @@ -1,472 +0,0 @@ -/* This file is part of the KDE project - Copyright (C) 2007 Matthias Kretz - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), Nokia Corporation - (or its successors, if any) and the KDE Free Qt Foundation, which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . - -*/ - -#include "path.h" -#include "path_p.h" - -#include "phononnamespace_p.h" -#include "backendinterface.h" -#include "factory_p.h" -#include "medianode.h" -#include "medianode_p.h" - -namespace Phonon -{ - -class ConnectionTransaction -{ - public: - ConnectionTransaction(BackendInterface *b, const QSet &x) : backend(b), list(x) - { - success = backend->startConnectionChange(list); - } - ~ConnectionTransaction() - { - backend->endConnectionChange(list); - } - operator bool() - { - return success; - } - private: - bool success; - BackendInterface *const backend; - const QSet list; -}; - -PathPrivate::~PathPrivate() -{ -#ifndef QT_NO_PHONON_EFFECT - for (int i = 0; i < effects.count(); ++i) { - effects.at(i)->k_ptr->removeDestructionHandler(this); - } - delete effectsParent; -#endif -} - -Path::~Path() -{ -} - -Path::Path() - : d(new PathPrivate) -{ -} - -Path::Path(const Path &rhs) - : d(rhs.d) -{ -} - -bool Path::isValid() const -{ - return d->sourceNode != 0 && d->sinkNode != 0; -} - -#ifndef QT_NO_PHONON_EFFECT -Effect *Path::insertEffect(const EffectDescription &desc, Effect *insertBefore) -{ - if (!d->effectsParent) { - d->effectsParent = new QObject; - } - Effect *e = new Effect(desc, d->effectsParent); - if (!e->isValid()) { - delete e; - return 0; - } - bool success = insertEffect(e, insertBefore); - if (!success) { - delete e; - return 0; - } - return e; -} - -bool Path::insertEffect(Effect *newEffect, Effect *insertBefore) -{ - QObject *newEffectBackend = newEffect ? newEffect->k_ptr->backendObject() : 0; - if (!isValid() || !newEffectBackend || d->effects.contains(newEffect) || - (insertBefore && (!d->effects.contains(insertBefore) || !insertBefore->k_ptr->backendObject()))) { - return false; - } - QObject *leftNode = 0; - QObject *rightNode = 0; - const int insertIndex = insertBefore ? d->effects.indexOf(insertBefore) : d->effects.size(); - if (insertIndex == 0) { - //prepend - leftNode = d->sourceNode->k_ptr->backendObject(); - } else { - leftNode = d->effects[insertIndex - 1]->k_ptr->backendObject(); - } - - if (insertIndex == d->effects.size()) { - //append - rightNode = d->sinkNode->k_ptr->backendObject(); - } else { - Q_ASSERT(insertBefore); - rightNode = insertBefore->k_ptr->backendObject(); - } - - QList disconnections, connections; - disconnections << QObjectPair(leftNode, rightNode); - connections << QObjectPair(leftNode, newEffectBackend) - << QObjectPair(newEffectBackend, rightNode); - - if (d->executeTransaction(disconnections, connections)) { - newEffect->k_ptr->addDestructionHandler(d.data()); - d->effects.insert(insertIndex, newEffect); - return true; - } else { - return false; - } -} - -bool Path::removeEffect(Effect *effect) -{ - return d->removeEffect(effect); -} - -QList Path::effects() const -{ - return d->effects; -} -#endif //QT_NO_PHONON_EFFECT - -bool Path::reconnect(MediaNode *source, MediaNode *sink) -{ - if (!source || !sink || !source->k_ptr->backendObject() || !sink->k_ptr->backendObject()) { - return false; - } - - QList disconnections, connections; - - //backend objects - QObject *bnewSource = source->k_ptr->backendObject(); - QObject *bnewSink = sink->k_ptr->backendObject(); - QObject *bcurrentSource = d->sourceNode ? d->sourceNode->k_ptr->backendObject() : 0; - QObject *bcurrentSink = d->sinkNode ? d->sinkNode->k_ptr->backendObject() : 0; - - if (bnewSource != bcurrentSource) { - //we need to change the source -#ifndef QT_NO_PHONON_EFFECT - MediaNode *next = d->effects.isEmpty() ? sink : d->effects.first(); -#else - MediaNode *next = sink; -#endif //QT_NO_PHONON_EFFECT - QObject *bnext = next->k_ptr->backendObject(); - if (bcurrentSource) - disconnections << QObjectPair(bcurrentSource, bnext); - connections << QObjectPair(bnewSource, bnext); - } - - if (bnewSink != bcurrentSink) { -#ifndef QT_NO_PHONON_EFFECT - MediaNode *previous = d->effects.isEmpty() ? source : d->effects.last(); -#else - MediaNode *previous = source; -#endif //QT_NO_PHONON_EFFECT - QObject *bprevious = previous->k_ptr->backendObject(); - if (bcurrentSink) - disconnections << QObjectPair(bprevious, bcurrentSink); - QObjectPair pair(bprevious, bnewSink); - if (!connections.contains(pair)) //avoid connecting twice - connections << pair; - } - - if (d->executeTransaction(disconnections, connections)) { - - //everything went well: let's update the path and the sink node - if (d->sinkNode != sink) { - if (d->sinkNode) { - d->sinkNode->k_ptr->removeInputPath(*this); - d->sinkNode->k_ptr->removeDestructionHandler(d.data()); - } - sink->k_ptr->addInputPath(*this); - d->sinkNode = sink; - d->sinkNode->k_ptr->addDestructionHandler(d.data()); - } - - //everything went well: let's update the path and the source node - if (d->sourceNode != source) { - source->k_ptr->addOutputPath(*this); - if (d->sourceNode) { - d->sourceNode->k_ptr->removeOutputPath(*this); - d->sourceNode->k_ptr->removeDestructionHandler(d.data()); - } - d->sourceNode = source; - d->sourceNode->k_ptr->addDestructionHandler(d.data()); - } - return true; - } else { - return false; - } -} - -bool Path::disconnect() -{ - if (!isValid()) { - return false; - } - - QObjectList list; - if (d->sourceNode) - list << d->sourceNode->k_ptr->backendObject(); -#ifndef QT_NO_PHONON_EFFECT - for (int i = 0; i < d->effects.count(); ++i) { - list << d->effects.at(i)->k_ptr->backendObject(); - } -#endif - if (d->sinkNode) { - list << d->sinkNode->k_ptr->backendObject(); - } - - //lets build the disconnection list - QList disco; - if (list.count() >=2 ) { - QObjectList::const_iterator it = list.constBegin(); - for(;it+1 != list.constEnd();++it) { - disco << QObjectPair(*it, *(it+1)); - } - } - - if (d->executeTransaction(disco, QList())) { - //everything went well, let's remove the reference - //to the paths from the source and sink - if (d->sourceNode) { - d->sourceNode->k_ptr->removeOutputPath(*this); - d->sourceNode->k_ptr->removeDestructionHandler(d.data()); - } - d->sourceNode = 0; - -#ifndef QT_NO_PHONON_EFFECT - for (int i = 0; i < d->effects.count(); ++i) { - d->effects.at(i)->k_ptr->removeDestructionHandler(d.data()); - } - d->effects.clear(); -#endif - - if (d->sinkNode) { - d->sinkNode->k_ptr->removeInputPath(*this); - d->sinkNode->k_ptr->removeDestructionHandler(d.data()); - } - d->sinkNode = 0; - return true; - } else { - return false; - } -} - -MediaNode *Path::source() const -{ - return d->sourceNode; -} - -MediaNode *Path::sink() const -{ - return d->sinkNode; -} - - - -bool PathPrivate::executeTransaction( const QList &disconnections, const QList &connections) -{ - QSet nodesForTransaction; - for (int i = 0; i < disconnections.count(); ++i) { - const QObjectPair &pair = disconnections.at(i); - nodesForTransaction << pair.first; - nodesForTransaction << pair.second; - } - for (int i = 0; i < connections.count(); ++i) { - const QObjectPair &pair = connections.at(i); - nodesForTransaction << pair.first; - nodesForTransaction << pair.second; - } - BackendInterface *backend = qobject_cast(Factory::backend()); - if (!backend) - return false; - - ConnectionTransaction transaction(backend, nodesForTransaction); - if (!transaction) - return false; - - QList::const_iterator it = disconnections.begin(); - for(;it != disconnections.end();++it) { - const QObjectPair &pair = *it; - if (!backend->disconnectNodes(pair.first, pair.second)) { - - //Error: a disconnection failed - QList::const_iterator it2 = disconnections.begin(); - for(; it2 != it; ++it2) { - const QObjectPair &pair = *it2; - bool success = backend->connectNodes(pair.first, pair.second); - Q_ASSERT(success); //a failure here means it is impossible to reestablish the connection - Q_UNUSED(success); - } - return false; - } - } - - for(it = connections.begin(); it != connections.end();++it) { - const QObjectPair &pair = *it; - if (!backend->connectNodes(pair.first, pair.second)) { - //Error: a connection failed - QList::const_iterator it2 = connections.begin(); - for(; it2 != it; ++it2) { - const QObjectPair &pair = *it2; - bool success = backend->disconnectNodes(pair.first, pair.second); - Q_ASSERT(success); //a failure here means it is impossible to reestablish the connection - Q_UNUSED(success); - } - - //and now let's reconnect the nodes that were disconnected: rollback - for (int i = 0; i < disconnections.count(); ++i) { - const QObjectPair &pair = disconnections.at(i); - bool success = backend->connectNodes(pair.first, pair.second); - Q_ASSERT(success); //a failure here means it is impossible to reestablish the connection - Q_UNUSED(success); - } - - return false; - - } - } - return true; -} - -#ifndef QT_NO_PHONON_EFFECT -bool PathPrivate::removeEffect(Effect *effect) -{ - if (!effects.contains(effect)) - return false; - - QObject *leftNode = 0; - QObject *rightNode = 0; - const int index = effects.indexOf(effect); - if (index == 0) { - leftNode = sourceNode->k_ptr->backendObject(); //append - } else { - leftNode = effects[index - 1]->k_ptr->backendObject(); - } - if (index == effects.size()-1) { - rightNode = sinkNode->k_ptr->backendObject(); //prepend - } else { - rightNode = effects[index + 1]->k_ptr->backendObject(); - } - - QList disconnections, connections; - QObject *beffect = effect->k_ptr->backendObject(); - disconnections << QObjectPair(leftNode, beffect) << QObjectPair(beffect, rightNode); - connections << QObjectPair(leftNode, rightNode); - - if (executeTransaction(disconnections, connections)) { - effect->k_ptr->removeDestructionHandler(this); - effects.removeAt(index); - return true; - } - return false; -} -#endif //QT_NO_PHONON_EFFECT - - -void PathPrivate::phononObjectDestroyed(MediaNodePrivate *mediaNodePrivate) -{ - Q_ASSERT(mediaNodePrivate); - if (mediaNodePrivate == sinkNode->k_ptr || mediaNodePrivate == sourceNode->k_ptr) { - //let's first disconnectq the path from its source and sink - QObject *bsink = sinkNode->k_ptr->backendObject(); - QObject *bsource = sourceNode->k_ptr->backendObject(); - QList disconnections; -#ifndef QT_NO_PHONON_EFFECT - disconnections << QObjectPair(bsource, effects.isEmpty() ? bsink : effects.first()->k_ptr->backendObject()); - if (!effects.isEmpty()) - disconnections << QObjectPair(effects.last()->k_ptr->backendObject(), bsink); -#else - disconnections << QObjectPair(bsource, bsink); -#endif //QT_NO_PHONON_EFFECT - - executeTransaction(disconnections, QList()); - - Path p; //temporary path - p.d = this; - if (mediaNodePrivate == sinkNode->k_ptr) { - sourceNode->k_ptr->removeOutputPath(p); - sourceNode->k_ptr->removeDestructionHandler(this); - } else { - sinkNode->k_ptr->removeInputPath(p); - sinkNode->k_ptr->removeDestructionHandler(this); - } - sourceNode = 0; - sinkNode = 0; - } else { -#ifndef QT_NO_PHONON_EFFECT - for (int i = 0; i < effects.count(); ++i) { - Effect *e = effects.at(i); - if (e->k_ptr == mediaNodePrivate) { - removeEffect(e); - } - } -#endif //QT_NO_PHONON_EFFECT - } -} - -Path createPath(MediaNode *source, MediaNode *sink) -{ - Path p; - if (!p.reconnect(source, sink)) { - const QObject *const src = source ? (source->k_ptr->qObject() -#ifndef QT_NO_DYNAMIC_CAST - ? source->k_ptr->qObject() : dynamic_cast(source) -#endif - ) : 0; - const QObject *const snk = sink ? (sink->k_ptr->qObject() -#ifndef QT_NO_DYNAMIC_CAST - ? sink->k_ptr->qObject() : dynamic_cast(sink) -#endif - ) : 0; - pWarning() << "Phonon::createPath: Cannot connect " - << (src ? src->metaObject()->className() : "") - << '(' << (src ? (src->objectName().isEmpty() ? "no objectName" : qPrintable(src->objectName())) : "null") << ") to " - << (snk ? snk->metaObject()->className() : "") - << '(' << (snk ? (snk->objectName().isEmpty() ? "no objectName" : qPrintable(snk->objectName())) : "null") - << ")."; - } - return p; -} - - -Path & Path::operator=(const Path &other) -{ - d = other.d; - return *this; -} - -bool Path::operator==(const Path &other) const -{ - return d == other.d; -} - -bool Path::operator!=(const Path &other) const -{ - return !operator==(other); -} - -} // namespace Phonon diff --git a/src/phonon/path.h b/src/phonon/path.h deleted file mode 100644 index fb0c16ff6..000000000 --- a/src/phonon/path.h +++ /dev/null @@ -1,239 +0,0 @@ -/* This file is part of the KDE project - Copyright (C) 2007 Matthias Kretz - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), Nokia Corporation - (or its successors, if any) and the KDE Free Qt Foundation, which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . - -*/ - -#ifndef PHONON_PATH_H -#define PHONON_PATH_H - -#include "phonon_export.h" -#include "objectdescription.h" - -#include - - -template class QList; - -namespace Phonon -{ - -class PathPrivate; -class Effect; -class MediaNode; - -/** \class Path path.h phonon/Path - * \short Connection object providing convenient effect insertion - * - * \code -MediaObject *media = new MediaObject; -AudioOutput *output = new AudioOutput(Phonon::MusicCategory); -Path path = Phonon::createPath(media, output); -Q_ASSERT(path.isValid()); // for this simple case the path should always be - //valid - there are unit tests to ensure it -// insert an effect -QList effectList = BackendCapabilities::availableAudioEffects(); -if (!effectList.isEmpty()) { - Effect *effect = path.insertEffect(effectList.first()); -} - * \endcode - * \ingroup Playback - * \ingroup Recording - * \author Matthias Kretz - * \author Thierry Bastian - */ -class PHONON_EXPORT Path -{ - friend class FactoryPrivate; - public: - /** - * Destroys this reference to the Path. If the path was valid the connection is not broken - * as both the source and the sink MediaNodes still keep a reference to the Path. - * - * \see disconnect - */ - ~Path(); - - /** - * Creates an invalid path. - * - * You can still make it a valid path by calling reconnect. To create a path you should use - * createPath, though. - * - * \see createPath - * \see isValid - */ - Path(); - - /** - * Constructs a copy of the given path. - * - * This constructor is fast thanks to explicit sharing. - */ - Path(const Path &); - - /** - * Returns whether the path object connects two MediaNodes or not. - * - * \return \p true when the path connects two MediaNodes - * \return \p false when the path is disconnected - */ - bool isValid() const; - //MediaStreamTypes mediaStreamTypes() const; - -#ifndef QT_NO_PHONON_EFFECT - /** - * Creates and inserts an effect into the path. - * - * You may insert effects of the same class as often as you like, - * but if you insert the same object, the call will fail. - * - * \param desc The EffectDescription object for the effect to be inserted. - * - * \param insertBefore If you already inserted an effect you can - * tell with this parameter in which order the data gets - * processed. If this is \c 0 the effect is appended at the end of - * the processing list. If the effect has not been inserted before - * the method will do nothing and return \c false. - * - * \return Returns a pointer to the effect object if it could be inserted - * at the specified position. If \c 0 is returned the effect was not - * inserted. - * - * \see removeEffect - * \see effects - */ - Effect *insertEffect(const EffectDescription &desc, Effect *insertBefore = 0); - - /** - * Inserts an effect into the path. - * - * You may insert effects of the same class as often as you like, - * but if you insert the same object, the call will fail. - * - * \param newEffect An Effect object. - * - * \param insertBefore If you already inserted an effect you can - * tell with this parameter in which order the data gets - * processed. If this is \c 0 the effect is appended at the end of - * the processing list. If the effect has not been inserted before - * the method will do nothing and return \c false. - * - * \return Returns whether the effect could be inserted at the - * specified position. If \c false is returned the effect was not - * inserted. - * - * \see removeEffect - * \see effects - */ - bool insertEffect(Effect *newEffect, Effect *insertBefore = 0); - - /** - * Removes an effect from the path. - * - * If the effect gets deleted while it is still connected the effect - * will be removed automatically. - * - * \param effect The effect to be removed. - * - * \return Returns whether the call was successful. If it returns - * \c false the effect could not be found in the path, meaning it - * has not been inserted before. - * - * \see insertEffect - * \see effects - */ - bool removeEffect(Effect *effect); - - /** - * Returns a list of Effect objects that are currently - * used as effects. The order in the list determines the order the - * signal is sent through the effects. - * - * \return A list with all current effects. - * - * \see insertEffect - * \see removeEffect - */ - QList effects() const; -#endif //QT_NO_PHONON_EFFECT - - /** - * Tries to change the MediaNodes the path is connected to. - * - * If reconnect fails the old connection is kept. - */ - bool reconnect(MediaNode *source, MediaNode *sink); - - /** - * Disconnects the path from the MediaNodes it was connected to. This invalidates the path - * (isValid returns \p false then). - */ - bool disconnect(); - - /** - * Assigns \p p to this Path and returns a reference to this Path. - * - * This operation is fast thanks to explicit sharing. - */ - Path &operator=(const Path &p); - - /** - * Returns \p true if this Path is equal to \p p; otherwise returns \p false; - */ - bool operator==(const Path &p) const; - - /** - * Returns \p true if this Path is not equal to \p p; otherwise returns \p false; - */ - bool operator!=(const Path &p) const; - - /** - * Returns the source MediaNode used by the path. - */ - MediaNode *source() const; - - /** - * Returns the sink MediaNode used by the path. - */ - MediaNode *sink() const; - - - protected: - friend class PathPrivate; - QExplicitlySharedDataPointer d; -}; - -/** - * \relates Path - * Creates a new Path connecting two MediaNodes. - * - * The implementation will automatically select the right format and media type. E.g. connecting a - * MediaObject and AudioOutput will create a Path object connecting the audio. This might be - * represented as PCM or perhaps even AC3 depending on the AudioOutput object. - * - * \param source The MediaNode to connect an output from - * \param sink The MediaNode to connect to. - */ -PHONON_EXPORT Path createPath(MediaNode *source, MediaNode *sink); - -} // namespace Phonon - - -#endif // PHONON_PATH_H diff --git a/src/phonon/path_p.h b/src/phonon/path_p.h deleted file mode 100644 index e5fb9210b..000000000 --- a/src/phonon/path_p.h +++ /dev/null @@ -1,75 +0,0 @@ -/* This file is part of the KDE project - Copyright (C) 2007 Matthias Kretz - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), Nokia Corporation - (or its successors, if any) and the KDE Free Qt Foundation, which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . - -*/ - -#ifndef PATH_P_H -#define PATH_P_H - -#include "path.h" -#include -#include -#include -#include "effect.h" -#include "medianodedestructionhandler_p.h" - -class QObject; - -namespace Phonon -{ - -class MediaNode; -typedef QPair QObjectPair; - - -class PathPrivate : public QSharedData, private MediaNodeDestructionHandler -{ - friend class Path; - public: - PathPrivate() - : sourceNode(0), sinkNode(0) -#ifndef QT_NO_PHONON_EFFECT - , effectsParent(0) -#endif //QT_NO_PHONON_EFFECT - { - } - - ~PathPrivate(); - - MediaNode *sourceNode; - MediaNode *sinkNode; - - protected: - void phononObjectDestroyed(MediaNodePrivate *); - -#ifndef QT_NO_PHONON_EFFECT - QObject *effectsParent; // used as parent for Effects created in insertEffect - QList effects; -#endif - private: - bool executeTransaction( const QList &disconnections, const QList &connections); -#ifndef QT_NO_PHONON_EFFECT - bool removeEffect(Effect *effect); -#endif -}; - -} // namespace Phonon - -#endif // PATH_P_H diff --git a/src/phonon/phonon-vlc/AUTHORS b/src/phonon/phonon-vlc/AUTHORS deleted file mode 100644 index a83f12b0c..000000000 --- a/src/phonon/phonon-vlc/AUTHORS +++ /dev/null @@ -1,34 +0,0 @@ -The phonon-VLC authors are: ---------------------------- - -Harald Sitter -Casian Andrei -Ben Cooksley -Jean-Baptiste Kempf -Mark Kretschmann -Martin T. H. Sandsmark -Patrick von Reth -Andreas Hartmetz -Rémi Duraffort -Colin Guthrie -Fathi Boudra -Patrick Spendrin -Rémi Denis-Courmont -Arno Rehn -Kamil Klimek -Michael Forney -Raphael Kubo da Costa -Alex Neundorf -Benoit Calvez -Myriam Schweingruber -Romain Perier -Valentin Rusu -Albert Astals Cid -Alejandro Wainzinger -Alexander Potashev -Andrius da Costa Ribas -Arnaud Le Roy -Locke Shinseiko -Pino Toscano -Ralf Habacker -Thiago Macieira diff --git a/src/phonon/phonon-vlc/CMakeLists.txt b/src/phonon/phonon-vlc/CMakeLists.txt deleted file mode 100644 index 430a138f3..000000000 --- a/src/phonon/phonon-vlc/CMakeLists.txt +++ /dev/null @@ -1,136 +0,0 @@ -if(PHONON_EXPERIMENTAL) - add_definitions(-DPHONON_EXPERIMENTAL) -else() - add_definitions(-DPHONON_VLC_NO_EXPERIMENTAL) -endif() - -include_directories( - ${VLC_INCLUDES} - ${VLC_INCLUDES}/vlc/plugins - ${CMAKE_CURRENT_SOURCE_DIR} - ${CMAKE_CURRENT_BINARY_DIR} - ${CMAKE_CURRENT_BINARY_DIR}/audio -) - -set(PHONON_VLC_MAJOR_VERSION "0") -set(PHONON_VLC_MINOR_VERSION "8") -set(PHONON_VLC_PATCH_VERSION "50") -set(PHONON_VLC_VERSION "${PHONON_VLC_MAJOR_VERSION}.${PHONON_VLC_MINOR_VERSION}.${PHONON_VLC_PATCH_VERSION}") -add_definitions(-DPHONON_VLC_VERSION="${PHONON_VLC_VERSION}") - -# PVLC only uses static mimetype lists, they are created by cmake, hooray. -include(MimeTypes.cmake) - -add_definitions(-DPHONON_LIB_INSTALL_DIR="${LIB_INSTALL_DIR}") - -if(MINGW AND WITH_THREADS) - # VLC is trying to use POSIX poll() even with _WIN32 - add_definitions(-DLIBVLC_USE_PTHREAD) - add_definitions(-DLIBVLC_USE_PTHREAD_CLEANUP) - add_definitions(-DLIBVLC_USE_PTHREAD_CANCEL) -endif() - -if (MSVC OR (WIN32 AND "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Intel")) - include(CheckIncludeFileCXX) - check_include_file_cxx(inttypes.h HAVE_INTTYPES) - check_include_file_cxx(stdint.h HAVE_STDINT) - if ( NOT HAVE_STDINT AND NOT HAVE_INTTYPES ) - message (FATAL_ERROR - "You don't have stdint.h and inttypes.h get them from:" - "http://code.google.com/p/baseutils/source/browse/#svn/trunk/msvc" - ) - endif ( NOT HAVE_STDINT AND NOT HAVE_INTTYPES ) -endif (MSVC OR (WIN32 AND "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Intel")) - -# bundled phonon is version 4.8.51 -add_definitions(-DPHONON_BACKEND_VERSION_4_9) - -set(phonon_vlc_SRCS - audio/audiooutput.cpp - audio/audiodataoutput.cpp - audio/volumefadereffect.cpp - backend.cpp - devicemanager.cpp - effect.cpp - effectmanager.cpp - equalizereffect.cpp - media.cpp - mediacontroller.cpp - mediaobject.cpp - mediaplayer.cpp - sinknode.cpp - streamreader.cpp - # video/videodataoutput.cpp - video/videowidget.cpp - video/videomemorystream.cpp - utils/debug.cpp - utils/libvlc.cpp -) - -if(PHONON_GRAPHICS) - list(APPEND phonon_vlc_SRCS video/videographicsobject.cpp) -endif() - -if(PHONON_EXPERIMENTAL) - add_definitions(-DPHONON_EXPERIMENTAL) - list(APPEND phonon_vlc_SRCS video/videodataoutput.cpp) -endif() - -if(APPLE) - list(APPEND phonon_vlc_SRCS - video/mac/nsvideoview.mm - video/mac/vlcmacwidget.mm) -endif(APPLE) - -set(phonon_vlc_HDRS - effectmanager.h - backend.h - mediaobject.h - audio/audiooutput.h - audio/volumefadereffect.h - audio/audiodataoutput.h - equalizereffect.h - devicemanager.h - video/videodataoutput.h - video/videowidget.h - video/videographicsobject.h - streamreader.h - effect.h - media.h - mediaplayer.h -) - -katie_resources(${phonon_vlc_SRCS} ${phonon_vlc_HDRS}) - -add_library(phonon_vlc MODULE ${phonon_vlc_SRCS} ${phonon_vlc_HDRS}) - -set_target_properties(phonon_vlc PROPERTIES - PREFIX "" -) - -target_link_libraries(phonon_vlc - KtPhonon - ${VLC_LIBRARIES} -) - -install( - TARGETS phonon_vlc - DESTINATION ${BACKEND_INSTALL_DIR} -) - -configure_file( - ${CMAKE_CURRENT_SOURCE_DIR}/utils/mime.h.cmake - ${CMAKE_CURRENT_BINARY_DIR}/utils/mime.h - @ONLY -) - -configure_file( - ${CMAKE_CURRENT_SOURCE_DIR}/vlc.desktop.cmake - ${CMAKE_CURRENT_BINARY_DIR}/vlc.desktop - @ONLY -) - -install( - FILES ${CMAKE_CURRENT_BINARY_DIR}/vlc.desktop - DESTINATION ${KDE4_SERVICES_INSTALL_DIR} -) diff --git a/src/phonon/phonon-vlc/COPYING.LIB b/src/phonon/phonon-vlc/COPYING.LIB deleted file mode 100644 index bcbd56295..000000000 --- a/src/phonon/phonon-vlc/COPYING.LIB +++ /dev/null @@ -1,462 +0,0 @@ - - GNU LESSER GENERAL PUBLIC LICENSE - Version 2.1, February 1999 - - Copyright (C) 1991, 1999 Free Software Foundation, Inc. - 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - -[This is the first released version of the Lesser GPL. It also counts - as the successor of the GNU Library Public License, version 2, hence - the version number 2.1.] - - Preamble - - The licenses for most software are designed to take away your -freedom to share and change it. By contrast, the GNU General Public -Licenses are intended to guarantee your freedom to share and change -free software--to make sure the software is free for all its users. - - This license, the Lesser General Public License, applies to some -specially designated software packages--typically libraries--of the -Free Software Foundation and other authors who decide to use it. You -can use it too, but we suggest you first think carefully about whether -this license or the ordinary General Public License is the better -strategy to use in any particular case, based on the explanations -below. - - When we speak of free software, we are referring to freedom of use, -not price. Our General Public Licenses are designed to make sure that -you have the freedom to distribute copies of free software (and charge -for this service if you wish); that you receive source code or can get -it if you want it; that you can change the software and use pieces of -it in new free programs; and that you are informed that you can do -these things. - - To protect your rights, we need to make restrictions that forbid -distributors to deny you these rights or to ask you to surrender these -rights. These restrictions translate to certain responsibilities for -you if you distribute copies of the library or if you modify it. - - For example, if you distribute copies of the library, whether gratis -or for a fee, you must give the recipients all the rights that we gave -you. You must make sure that they, too, receive or can get the source -code. If you link other code with the library, you must provide -complete object files to the recipients, so that they can relink them -with the library after making changes to the library and recompiling -it. And you must show them these terms so they know their rights. - - We protect your rights with a two-step method: (1) we copyright the -library, and (2) we offer you this license, which gives you legal -permission to copy, distribute and/or modify the library. - - To protect each distributor, we want to make it very clear that -there is no warranty for the free library. Also, if the library is -modified by someone else and passed on, the recipients should know -that what they have is not the original version, so that the original -author's reputation will not be affected by problems that might be -introduced by others. - - Finally, software patents pose a constant threat to the existence of -any free program. We wish to make sure that a company cannot -effectively restrict the users of a free program by obtaining a -restrictive license from a patent holder. Therefore, we insist that -any patent license obtained for a version of the library must be -consistent with the full freedom of use specified in this license. - - Most GNU software, including some libraries, is covered by the -ordinary GNU General Public License. This license, the GNU Lesser -General Public License, applies to certain designated libraries, and -is quite different from the ordinary General Public License. We use -this license for certain libraries in order to permit linking those -libraries into non-free programs. - - When a program is linked with a library, whether statically or using -a shared library, the combination of the two is legally speaking a -combined work, a derivative of the original library. The ordinary -General Public License therefore permits such linking only if the -entire combination fits its criteria of freedom. The Lesser General -Public License permits more lax criteria for linking other code with -the library. - - We call this license the "Lesser" General Public License because it -does Less to protect the user's freedom than the ordinary General -Public License. It also provides other free software developers Less -of an advantage over competing non-free programs. These disadvantages -are the reason we use the ordinary General Public License for many -libraries. However, the Lesser license provides advantages in certain -special circumstances. - - For example, on rare occasions, there may be a special need to -encourage the widest possible use of a certain library, so that it -becomes a de-facto standard. To achieve this, non-free programs must -be allowed to use the library. A more frequent case is that a free -library does the same job as widely used non-free libraries. In this -case, there is little to gain by limiting the free library to free -software only, so we use the Lesser General Public License. - - In other cases, permission to use a particular library in non-free -programs enables a greater number of people to use a large body of -free software. For example, permission to use the GNU C Library in -non-free programs enables many more people to use the whole GNU -operating system, as well as its variant, the GNU/Linux operating -system. - - Although the Lesser General Public License is Less protective of the -users' freedom, it does ensure that the user of a program that is -linked with the Library has the freedom and the wherewithal to run -that program using a modified version of the Library. - - The precise terms and conditions for copying, distribution and -modification follow. Pay close attention to the difference between a -"work based on the library" and a "work that uses the library". The -former contains code derived from the library, whereas the latter must -be combined with the library in order to run. - - GNU LESSER GENERAL PUBLIC LICENSE - TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION - - 0. This License Agreement applies to any software library or other -program which contains a notice placed by the copyright holder or -other authorized party saying it may be distributed under the terms of -this Lesser General Public License (also called "this License"). -Each licensee is addressed as "you". - - A "library" means a collection of software functions and/or data -prepared so as to be conveniently linked with application programs -(which use some of those functions and data) to form executables. - - The "Library", below, refers to any such software library or work -which has been distributed under these terms. A "work based on the -Library" means either the Library or any derivative work under -copyright law: that is to say, a work containing the Library or a -portion of it, either verbatim or with modifications and/or translated -straightforwardly into another language. (Hereinafter, translation is -included without limitation in the term "modification".) - - "Source code" for a work means the preferred form of the work for -making modifications to it. For a library, complete source code means -all the source code for all modules it contains, plus any associated -interface definition files, plus the scripts used to control -compilation and installation of the library. - - Activities other than copying, distribution and modification are not -covered by this License; they are outside its scope. The act of -running a program using the Library is not restricted, and output from -such a program is covered only if its contents constitute a work based -on the Library (independent of the use of the Library in a tool for -writing it). Whether that is true depends on what the Library does -and what the program that uses the Library does. - - 1. You may copy and distribute verbatim copies of the Library's -complete source code as you receive it, in any medium, provided that -you conspicuously and appropriately publish on each copy an -appropriate copyright notice and disclaimer of warranty; keep intact -all the notices that refer to this License and to the absence of any -warranty; and distribute a copy of this License along with the -Library. - - You may charge a fee for the physical act of transferring a copy, -and you may at your option offer warranty protection in exchange for a -fee. - - 2. You may modify your copy or copies of the Library or any portion -of it, thus forming a work based on the Library, and copy and -distribute such modifications or work under the terms of Section 1 -above, provided that you also meet all of these conditions: - - a) The modified work must itself be a software library. - - b) You must cause the files modified to carry prominent notices - stating that you changed the files and the date of any change. - - c) You must cause the whole of the work to be licensed at no - charge to all third parties under the terms of this License. - - d) If a facility in the modified Library refers to a function or a - table of data to be supplied by an application program that uses - the facility, other than as an argument passed when the facility - is invoked, then you must make a good faith effort to ensure that, - in the event an application does not supply such function or - table, the facility still operates, and performs whatever part of - its purpose remains meaningful. - - (For example, a function in a library to compute square roots has - a purpose that is entirely well-defined independent of the - application. Therefore, Subsection 2d requires that any - application-supplied function or table used by this function must - be optional: if the application does not supply it, the square - root function must still compute square roots.) - -These requirements apply to the modified work as a whole. If -identifiable sections of that work are not derived from the Library, -and can be reasonably considered independent and separate works in -themselves, then this License, and its terms, do not apply to those -sections when you distribute them as separate works. But when you -distribute the same sections as part of a whole which is a work based -on the Library, the distribution of the whole must be on the terms of -this License, whose permissions for other licensees extend to the -entire whole, and thus to each and every part regardless of who wrote -it. - -Thus, it is not the intent of this section to claim rights or contest -your rights to work written entirely by you; rather, the intent is to -exercise the right to control the distribution of derivative or -collective works based on the Library. - -In addition, mere aggregation of another work not based on the Library -with the Library (or with a work based on the Library) on a volume of -a storage or distribution medium does not bring the other work under -the scope of this License. - - 3. You may opt to apply the terms of the ordinary GNU General Public -License instead of this License to a given copy of the Library. To do -this, you must alter all the notices that refer to this License, so -that they refer to the ordinary GNU General Public License, version 2, -instead of to this License. (If a newer version than version 2 of the -ordinary GNU General Public License has appeared, then you can specify -that version instead if you wish.) Do not make any other change in -these notices. - - Once this change is made in a given copy, it is irreversible for -that copy, so the ordinary GNU General Public License applies to all -subsequent copies and derivative works made from that copy. - - This option is useful when you wish to copy part of the code of -the Library into a program that is not a library. - - 4. You may copy and distribute the Library (or a portion or -derivative of it, under Section 2) in object code or executable form -under the terms of Sections 1 and 2 above provided that you accompany -it with the complete corresponding machine-readable source code, which -must be distributed under the terms of Sections 1 and 2 above on a -medium customarily used for software interchange. - - If distribution of object code is made by offering access to copy -from a designated place, then offering equivalent access to copy the -source code from the same place satisfies the requirement to -distribute the source code, even though third parties are not -compelled to copy the source along with the object code. - - 5. A program that contains no derivative of any portion of the -Library, but is designed to work with the Library by being compiled or -linked with it, is called a "work that uses the Library". Such a -work, in isolation, is not a derivative work of the Library, and -therefore falls outside the scope of this License. - - However, linking a "work that uses the Library" with the Library -creates an executable that is a derivative of the Library (because it -contains portions of the Library), rather than a "work that uses the -library". The executable is therefore covered by this License. -Section 6 states terms for distribution of such executables. - - When a "work that uses the Library" uses material from a header file -that is part of the Library, the object code for the work may be a -derivative work of the Library even though the source code is not. -Whether this is true is especially significant if the work can be -linked without the Library, or if the work is itself a library. The -threshold for this to be true is not precisely defined by law. - - If such an object file uses only numerical parameters, data -structure layouts and accessors, and small macros and small inline -functions (ten lines or less in length), then the use of the object -file is unrestricted, regardless of whether it is legally a derivative -work. (Executables containing this object code plus portions of the -Library will still fall under Section 6.) - - Otherwise, if the work is a derivative of the Library, you may -distribute the object code for the work under the terms of Section 6. -Any executables containing that work also fall under Section 6, -whether or not they are linked directly with the Library itself. - - 6. As an exception to the Sections above, you may also combine or -link a "work that uses the Library" with the Library to produce a -work containing portions of the Library, and distribute that work -under terms of your choice, provided that the terms permit -modification of the work for the customer's own use and reverse -engineering for debugging such modifications. - - You must give prominent notice with each copy of the work that the -Library is used in it and that the Library and its use are covered by -this License. You must supply a copy of this License. If the work -during execution displays copyright notices, you must include the -copyright notice for the Library among them, as well as a reference -directing the user to the copy of this License. Also, you must do one -of these things: - - a) Accompany the work with the complete corresponding - machine-readable source code for the Library including whatever - changes were used in the work (which must be distributed under - Sections 1 and 2 above); and, if the work is an executable linked - with the Library, with the complete machine-readable "work that - uses the Library", as object code and/or source code, so that the - user can modify the Library and then relink to produce a modified - executable containing the modified Library. (It is understood - that the user who changes the contents of definitions files in the - Library will not necessarily be able to recompile the application - to use the modified definitions.) - - b) Use a suitable shared library mechanism for linking with the - Library. A suitable mechanism is one that (1) uses at run time a - copy of the library already present on the user's computer system, - rather than copying library functions into the executable, and (2) - will operate properly with a modified version of the library, if - the user installs one, as long as the modified version is - interface-compatible with the version that the work was made with. - - c) Accompany the work with a written offer, valid for at least - three years, to give the same user the materials specified in - Subsection 6a, above, for a charge no more than the cost of - performing this distribution. - - d) If distribution of the work is made by offering access to copy - from a designated place, offer equivalent access to copy the above - specified materials from the same place. - - e) Verify that the user has already received a copy of these - materials or that you have already sent this user a copy. - - For an executable, the required form of the "work that uses the -Library" must include any data and utility programs needed for -reproducing the executable from it. However, as a special exception, -the materials to be distributed need not include anything that is -normally distributed (in either source or binary form) with the major -components (compiler, kernel, and so on) of the operating system on -which the executable runs, unless that component itself accompanies -the executable. - - It may happen that this requirement contradicts the license -restrictions of other proprietary libraries that do not normally -accompany the operating system. Such a contradiction means you cannot -use both them and the Library together in an executable that you -distribute. - - 7. You may place library facilities that are a work based on the -Library side-by-side in a single library together with other library -facilities not covered by this License, and distribute such a combined -library, provided that the separate distribution of the work based on -the Library and of the other library facilities is otherwise -permitted, and provided that you do these two things: - - a) Accompany the combined library with a copy of the same work - based on the Library, uncombined with any other library - facilities. This must be distributed under the terms of the - Sections above. - - b) Give prominent notice with the combined library of the fact - that part of it is a work based on the Library, and explaining - where to find the accompanying uncombined form of the same work. - - 8. You may not copy, modify, sublicense, link with, or distribute -the Library except as expressly provided under this License. Any -attempt otherwise to copy, modify, sublicense, link with, or -distribute the Library is void, and will automatically terminate your -rights under this License. However, parties who have received copies, -or rights, from you under this License will not have their licenses -terminated so long as such parties remain in full compliance. - - 9. You are not required to accept this License, since you have not -signed it. However, nothing else grants you permission to modify or -distribute the Library or its derivative works. These actions are -prohibited by law if you do not accept this License. Therefore, by -modifying or distributing the Library (or any work based on the -Library), you indicate your acceptance of this License to do so, and -all its terms and conditions for copying, distributing or modifying -the Library or works based on it. - - 10. Each time you redistribute the Library (or any work based on the -Library), the recipient automatically receives a license from the -original licensor to copy, distribute, link with or modify the Library -subject to these terms and conditions. You may not impose any further -restrictions on the recipients' exercise of the rights granted herein. -You are not responsible for enforcing compliance by third parties with -this License. - - 11. If, as a consequence of a court judgment or allegation of patent -infringement or for any other reason (not limited to patent issues), -conditions are imposed on you (whether by court order, agreement or -otherwise) that contradict the conditions of this License, they do not -excuse you from the conditions of this License. If you cannot -distribute so as to satisfy simultaneously your obligations under this -License and any other pertinent obligations, then as a consequence you -may not distribute the Library at all. For example, if a patent -license would not permit royalty-free redistribution of the Library by -all those who receive copies directly or indirectly through you, then -the only way you could satisfy both it and this License would be to -refrain entirely from distribution of the Library. - -If any portion of this section is held invalid or unenforceable under -any particular circumstance, the balance of the section is intended to -apply, and the section as a whole is intended to apply in other -circumstances. - -It is not the purpose of this section to induce you to infringe any -patents or other property right claims or to contest validity of any -such claims; this section has the sole purpose of protecting the -integrity of the free software distribution system which is -implemented by public license practices. Many people have made -generous contributions to the wide range of software distributed -through that system in reliance on consistent application of that -system; it is up to the author/donor to decide if he or she is willing -to distribute software through any other system and a licensee cannot -impose that choice. - -This section is intended to make thoroughly clear what is believed to -be a consequence of the rest of this License. - - 12. If the distribution and/or use of the Library is restricted in -certain countries either by patents or by copyrighted interfaces, the -original copyright holder who places the Library under this License -may add an explicit geographical distribution limitation excluding those -countries, so that distribution is permitted only in or among -countries not thus excluded. In such case, this License incorporates -the limitation as if written in the body of this License. - - 13. The Free Software Foundation may publish revised and/or new -versions of the Lesser General Public License from time to time. -Such new versions will be similar in spirit to the present version, -but may differ in detail to address new problems or concerns. - -Each version is given a distinguishing version number. If the Library -specifies a version number of this License which applies to it and -"any later version", you have the option of following the terms and -conditions either of that version or of any later version published by -the Free Software Foundation. If the Library does not specify a -license version number, you may choose any version ever published by -the Free Software Foundation. - - 14. If you wish to incorporate parts of the Library into other free -programs whose distribution conditions are incompatible with these, -write to the author to ask for permission. For software which is -copyrighted by the Free Software Foundation, write to the Free -Software Foundation; we sometimes make exceptions for this. Our -decision will be guided by the two goals of preserving the free status -of all derivatives of our free software and of promoting the sharing -and reuse of software generally. - - NO WARRANTY - - 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO -WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. -EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR -OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY -KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE -IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE -LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME -THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. - - 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN -WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY -AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU -FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR -CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE -LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING -RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A -FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF -SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH -DAMAGES. - - END OF TERMS AND CONDITIONS - diff --git a/src/phonon/phonon-vlc/MimeTypes.cmake b/src/phonon/phonon-vlc/MimeTypes.cmake deleted file mode 100644 index b6bf4e310..000000000 --- a/src/phonon/phonon-vlc/MimeTypes.cmake +++ /dev/null @@ -1,110 +0,0 @@ -# Copyright (C) 2012, Harald Sitter -# -# Redistribution and use is allowed according to the terms of the BSD license. -# For details see the accompanying COPYING-CMAKE-SCRIPTS file. - -set(PHONON_VLC_MIME_TYPES - application/ogg - application/x-ogg - application/vnd.rn-realmedia - application/x-annodex - application/x-flash-video - application/x-quicktimeplayer - application/x-extension-mp4 - audio/168sv - audio/3gpp - audio/3gpp2 - audio/8svx - audio/aiff - audio/amr - audio/amr-wb - audio/basic - audio/mp3 - audio/mp4 - audio/midi - audio/mpeg - audio/mpeg2 - audio/mpeg3 - audio/prs.sid - audio/vnd.rn-realaudio - audio/vnd.rn-realmedia - audio/wav - audio/webm - audio/x-16sv - audio/x-8svx - audio/x-aiff - audio/x-basic - audio/x-it - audio/x-m4a - audio/x-matroska - audio/x-mod - audio/x-mp3 - audio/x-mpeg - audio/x-mpeg2 - audio/x-mpeg3 - audio/x-mpegurl - audio/x-ms-wma - audio/x-ogg - audio/x-pn-aiff - audio/x-pn-au - audio/x-pn-realaudio-plugin - audio/x-pn-wav - audio/x-pn-windows-acm - audio/x-real-audio - audio/x-realaudio - audio/x-s3m - audio/x-speex+ogg - audio/x-vorbis+ogg - audio/x-wav - audio/x-xm - image/ilbm - image/png - image/x-ilbm - image/x-png - video/3gpp - video/3gpp2 - video/anim - video/avi - video/divx - video/flv - video/mkv - video/mng - video/mp4 - video/mpeg - video/mpeg-system - video/mpg - video/msvideo - video/ogg - video/quicktime - video/webm - video/x-anim - video/x-flic - video/x-flv - video/x-matroska - video/x-mng - video/x-m4v - video/x-mpeg - video/x-mpeg-system - video/x-ms-asf - video/x-ms-wma - video/x-ms-wmv - video/x-ms-wvx - video/x-msvideo - video/x-quicktime - audio/x-flac - audio/x-ape -) - -macro(CREATE_C_ARRAY var list) - set(ret "") - foreach(str ${PHONON_VLC_MIME_TYPES}) - if(NOT ret) - set(ret "\"${str}\"") - else(NOT ret) - set(ret "${ret}, \"${str}\"") - endif(NOT ret) - endforeach(str) - set(${var} "{${ret}, 0}") -endmacro(CREATE_C_ARRAY var list) - -CREATE_C_ARRAY(PHONON_VLC_MIME_TYPES_C_ARRAY ${PHONON_VLC_MIME_TYPES}) diff --git a/src/phonon/phonon-vlc/NOTE b/src/phonon/phonon-vlc/NOTE deleted file mode 100644 index b80abf067..000000000 --- a/src/phonon/phonon-vlc/NOTE +++ /dev/null @@ -1,3 +0,0 @@ -This is Git checkout fce927e9195f90298f18a5202ce56dd8afb0a5af -from git://anongit.kde.org/phonon-vlc.git that hs been modified to fit our needs. - diff --git a/src/phonon/phonon-vlc/audio/audiodataoutput.cpp b/src/phonon/phonon-vlc/audio/audiodataoutput.cpp deleted file mode 100644 index e519b677f..000000000 --- a/src/phonon/phonon-vlc/audio/audiodataoutput.cpp +++ /dev/null @@ -1,165 +0,0 @@ -/* - Copyright (C) 2006 Matthias Kretz - Copyright (C) 2009 Martin Sandsmark - Copyright (C) 2010 Ben Cooksley - Copyright (C) 2011 Harald Sitter - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), Nokia Corporation - (or its successors, if any) and the KDE Free Qt Foundation, which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . -*/ - -#include "audiodataoutput.h" - -#include "media.h" - -namespace Phonon { -namespace VLC { - -AudioDataOutput::AudioDataOutput(QObject *parent) - : QObject(parent) -{ - m_sampleRate = 44100; - connect(this, SIGNAL(sampleReadDone()), this, SLOT(sendData())); - - // Register channels - m_channels.append(Phonon::AudioDataOutput::LeftChannel); - m_channels.append(Phonon::AudioDataOutput::RightChannel); - m_channels.append(Phonon::AudioDataOutput::CenterChannel); - m_channels.append(Phonon::AudioDataOutput::LeftSurroundChannel); - m_channels.append(Phonon::AudioDataOutput::RightSurroundChannel); - m_channels.append(Phonon::AudioDataOutput::SubwooferChannel); -} - -AudioDataOutput::~AudioDataOutput() -{ -} - -int AudioDataOutput::dataSize() const -{ - return m_dataSize; -} - -int AudioDataOutput::sampleRate() const -{ - return m_sampleRate; -} - -void AudioDataOutput::setDataSize(int size) -{ - m_dataSize = size; -} - -void AudioDataOutput::handleAddToMedia(Media *media) -{ - media->addOption(QString(":sout=#duplicate{dst=display,dst='transcode{vcodec=none,acodec=s16l,samplerate=%1}" - ":smem{audio-prerender-callback=%2," - "audio-postrender-callback=%3," - "audio-data=%4," - "time-sync=true}'}" - ).arg(QString::number(m_sampleRate), - QString::number((long long int) INTPTR_FUNC(AudioDataOutput::lock)), - QString::number((long long int) INTPTR_FUNC(AudioDataOutput::unlock)), - QString::number((long long int) INTPTR_PTR(this)))); -} - -void AudioDataOutput::lock(AudioDataOutput *cw, quint8 **pcm_buffer , quint32 size) -{ - cw->m_locker.lock(); - *pcm_buffer = new quint8[size]; -} - -void AudioDataOutput::unlock(AudioDataOutput *cw, quint8 *pcm_buffer, - quint32 channelCount, quint32 rate, - quint32 sampleCount, quint32 bits_per_sample, - quint32 size, qint64 pts) -{ - Q_UNUSED(size); - Q_UNUSED(pts); - - // (bytesPerChannelPerSample * channels * read_samples) + (bytesPerChannelPerSample * read_channels) - int bytesPerChannelPerSample = bits_per_sample / 8; - cw->m_sampleRate = rate; - cw->m_channelCount = channelCount; - - for (quint32 readSamples = 0; readSamples < sampleCount; ++readSamples) { - // Prepare a sample buffer, and initialise it - quint16 sampleBuffer[6]; - for (int initialised = 0; initialised < 6; ++initialised) { - sampleBuffer[initialised] = 0; - } - - int bufferPosition = (bytesPerChannelPerSample * channelCount * readSamples); - - for (quint32 readChannels = 0; readChannels < channelCount; ++readChannels) { - quint32 complet = 0; - for (int readBytes = 0; readBytes < bytesPerChannelPerSample; ++readBytes) { - // Read from the pcm_buffer into the per channel internal buffer - - quint32 complet_temp = 0; - complet_temp = pcm_buffer[bufferPosition]; - complet_temp <<= (8 * readBytes); - - complet += complet_temp; - ++bufferPosition; - } - - sampleBuffer[readChannels] = complet; - } - - if (channelCount == 1) { - cw->m_channelSamples[1].append(qint16(sampleBuffer[0])); - } - - for (quint32 readChannels = 0; readChannels < channelCount; ++readChannels) { - cw->m_channelSamples[readChannels].append(qint16(sampleBuffer[readChannels])); - } - // Finished reading one sample - } - - delete pcm_buffer; - - cw->m_locker.unlock(); - emit cw->sampleReadDone(); -} - -void AudioDataOutput::sendData() -{ - m_locker.lock(); - - int chan_count = m_channelCount; - if (m_channelCount == 1) { - chan_count = 2; - } - - while (m_channelSamples[0].count() > m_dataSize) { - QMap > m_data; - for (int position = 0; position < chan_count; position++) { - Phonon::AudioDataOutput::Channel chan = m_channels.value(position); - QVector data = m_channelSamples[position].mid(0, m_dataSize); - m_channelSamples[position].remove(0, data.count()); - m_data.insert(chan, data); - } - emit dataReady(m_data); - } - m_locker.unlock(); -} - -} // namespace VLC -} // namespace Phonon - -#include "phonon-vlc/audio/moc_audiodataoutput.cpp" -#include "phonon-vlc/audio/moc_audiodataoutput.h" diff --git a/src/phonon/phonon-vlc/audio/audiodataoutput.h b/src/phonon/phonon-vlc/audio/audiodataoutput.h deleted file mode 100644 index 9c414e098..000000000 --- a/src/phonon/phonon-vlc/audio/audiodataoutput.h +++ /dev/null @@ -1,162 +0,0 @@ -/* - Copyright (C) 2006 Matthias Kretz - Copyright (C) 2009 Martin Sandsmark - Copyright (C) 2010 Ben Cooksley - Copyright (C) 2011 Harald Sitter - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), Nokia Corporation - (or its successors, if any) and the KDE Free Qt Foundation, which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . -*/ - -#ifndef Phonon_VLC_AUDIODATAOUTPUT_H -#define Phonon_VLC_AUDIODATAOUTPUT_H - -#include -#include - -#include -#include - -#include "sinknode.h" - -namespace Phonon { -namespace VLC { - -/** \brief Implementation for AudioDataOutput using libVLC - * - * This class makes the capture of raw audio data possible. It sets special options - * for the libVLC Media Object when connecting to it, and then captures libVLC events - * to get the audio data and send it further with the dataReady() signal. - * - * As a sink node, it can be connected to media objects. - * - * The frontend Phonon::AudioDataOutput object is unused. - * - * See the Phonon documentation for details. - * - * \see AudioOutput - * \see SinkNode - * - * \author Martin Sandsmark - */ -class AudioDataOutput : public QObject, public SinkNode, public AudioDataOutputInterface -{ - Q_OBJECT - Q_INTERFACES(Phonon::AudioDataOutputInterface) -public: - /** - * Creates an audio data output. The sample rate is set to 44100 Hz. - * The available audio channels are registered. These are: - * \li Left \li Right \li Center \li LeftSurround \li RightSurround \li Subwoofer - */ - explicit AudioDataOutput(QObject *parent); - ~AudioDataOutput(); - - Phonon::AudioDataOutput *frontendObject() const - { - return m_frontend; - } - - void setFrontendObject(Phonon::AudioDataOutput *frontend) - { - m_frontend = frontend; - } - -public Q_SLOTS: - /** - * \return The currently used number of samples passed through the signal. - */ - int dataSize() const; - - /** - * \return The current sample rate in Hz. - */ - int sampleRate() const; - - /** - * Sets the number of samples to be passed in one signal emission. - */ - void setDataSize(int size); - - /** - * Adds special options to the libVLC Media Object to adapt it to give audio data - * directly. There are two callbacks used: lock(), unlock(). - * - * \see lock() - * \see unlock() - * \reimp - */ - void handleAddToMedia(Media *media); - -signals: - void dataReady(const QMap > &data); - void dataReady(const QMap > &data); - void endOfMedia(int remainingSamples); - void sampleReadDone(); - -private Q_SLOTS: - /** - * Looks at the channel samples generated in lock() and creates the QMap required for - * the dataReady() signal. Then the signal is emitted. This repeats as long as there is - * data remaining. - * - * \see lock() - */ - void sendData(); - -private: - /** - * This is a VLC prerender callback. The m_locker mutex is locked, and a new buffer is prepared - * for the incoming audio data. - * - * \param cw The AudioDataOutput for this callback - * \param pcm_buffer The new data buffer - * \param size Size for the incoming data - * - * \see unlock() - */ - static void lock(AudioDataOutput *cw, quint8 **pcm_buffer , quint32 size); - - /** - * This is a VLC postrender callback. Interprets the data received in m_buffer, - * separating the samples and channels. Finally, the buffer is freed and m_locker - * is unlocked. Now the audio data output is ready for sending data. - * - * \param cw The AudioDataOutput for this callback - * - * \see lock() - * \see sendData() - */ - static void unlock(AudioDataOutput *cw, quint8 *pcm_buffer, - quint32 channelCount, quint32 rate, - quint32 sampleCount, quint32 bits_per_sample, - quint32 size, qint64 pts); - - int m_dataSize; - int m_sampleRate; - Phonon::AudioDataOutput *m_frontend; - - QMutex m_locker; - int m_channelCount; - QVector m_channelSamples[6]; - QList m_channels; -}; - -} // namespace VLC -} // namespace Phonon - -#endif // Phonon_VLC_AUDIODATAOUTPUT_H diff --git a/src/phonon/phonon-vlc/audio/audiooutput.cpp b/src/phonon/phonon-vlc/audio/audiooutput.cpp deleted file mode 100644 index ee76f6330..000000000 --- a/src/phonon/phonon-vlc/audio/audiooutput.cpp +++ /dev/null @@ -1,183 +0,0 @@ -/* - Copyright (C) 2007-2008 Tanguy Krotoff - Copyright (C) 2008 Lukas Durfina - Copyright (C) 2009 Fathi Boudra - Copyright (C) 2013-2015 Harald Sitter - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . -*/ - -#include "audiooutput.h" - -#include - -#include "backend.h" -#include "utils/debug.h" -#include "devicemanager.h" -#include "mediaobject.h" -#include "media.h" - -namespace Phonon { -namespace VLC { - -AudioOutput::AudioOutput(QObject *parent) - : QObject(parent), - m_volume(1.0) -{ -} - -AudioOutput::~AudioOutput() -{ -} - -void AudioOutput::handleConnectToMediaObject(MediaObject *mediaObject) -{ - Q_UNUSED(mediaObject); - setOutputDeviceImplementation(); - connect(m_player, SIGNAL(mutedChanged(bool)), - this, SLOT(onMutedChanged(bool))); - connect(m_player, SIGNAL(volumeChanged(float)), - this, SLOT(onVolumeChanged(float))); - applyVolume(); -} - -void AudioOutput::handleAddToMedia(Media *media) -{ - media->addOption(":audio"); -} - -qreal AudioOutput::volume() const -{ - return m_volume; -} - -void AudioOutput::setVolume(qreal volume) -{ - if (m_player) { - debug() << "async setting of volume to" << volume; - m_volume = volume; - applyVolume(); - -#if (LIBVLC_VERSION_INT < LIBVLC_VERSION(2, 2, 2, 0)) - emit volumeChanged(m_volume); -#endif - } -} - -int AudioOutput::outputDevice() const -{ - return m_device.index(); -} - -bool AudioOutput::setOutputDevice(int deviceIndex) -{ - const AudioOutputDevice device = AudioOutputDevice::fromIndex(deviceIndex); - if (!device.isValid()) { - error() << Q_FUNC_INFO << "Unable to find the output device with index" << deviceIndex; - return false; - } - return setOutputDevice(device); -} - -bool AudioOutput::setOutputDevice(const AudioOutputDevice &newDevice) -{ - debug() << Q_FUNC_INFO; - - if (!newDevice.isValid()) { - error() << "Invalid audio output device"; - return false; - } - - if (newDevice == m_device) - return true; - - m_device = newDevice; - if (m_player) { - setOutputDeviceImplementation(); - } - - return true; -} - -void AudioOutput::setStreamUuid(QString uuid) -{ - DEBUG_BLOCK; - debug() << uuid; - m_streamUuid = uuid; -} - -void AudioOutput::setOutputDeviceImplementation() -{ - Q_ASSERT(m_player); - - const QVariant dalProperty = m_device.property("deviceAccessList"); - if (!dalProperty.isValid()) { - error() << "Device" << m_device.property("name") << "has no access list"; - return; - } - const DeviceAccessList deviceAccessList = dalProperty.value(); - if (deviceAccessList.isEmpty()) { - error() << "Device" << m_device.property("name") << "has an empty access list"; - return; - } - - // ### we're not trying the whole access list (could mean same device on different soundsystems) - const DeviceAccess &firstDeviceAccess = deviceAccessList.first(); - - QByteArray soundSystem = firstDeviceAccess.first; - debug() << "Setting output soundsystem to" << soundSystem; - m_player->setAudioOutput(soundSystem); - - QByteArray deviceName = firstDeviceAccess.second.toLatin1(); - if (!deviceName.isEmpty()) { - // print the name as possibly messed up by toLatin1() to see conversion problems - debug() << "Setting output device to" << deviceName << '(' << m_device.property("name") << ')'; - m_player->setAudioOutputDevice(soundSystem, deviceName); - } -} - -void AudioOutput::applyVolume() -{ - if (m_player) { - const int preVolume = m_player->audioVolume(); - const int newVolume = m_volume * 100; - m_player->setAudioVolume(newVolume); - -#if (LIBVLC_VERSION_INT < LIBVLC_VERSION(2, 2, 2, 0)) - onMutedChanged(m_volume == 0.0); - onVolumeChanged(newVolume); -#endif - - debug() << "Volume changed from" << preVolume << "to" << newVolume; - } -} - -void AudioOutput::onMutedChanged(bool mute) -{ - emit mutedChanged(mute); -#if (PHONON_VERSION < PHONON_VERSION_CHECK(4, 8, 51)) - mute ? emit volumeChanged(0.0) : emit volumeChanged(volume()); -#endif -} - -void AudioOutput::onVolumeChanged(float volume) -{ - m_volume = volume; - emit volumeChanged(volume); -} - -} -} // Namespace Phonon::VLC - -#include "phonon-vlc/audio/moc_audiooutput.h" diff --git a/src/phonon/phonon-vlc/audio/audiooutput.h b/src/phonon/phonon-vlc/audio/audiooutput.h deleted file mode 100644 index 81c4d5fdb..000000000 --- a/src/phonon/phonon-vlc/audio/audiooutput.h +++ /dev/null @@ -1,130 +0,0 @@ -/* - Copyright (C) 2007-2008 Tanguy Krotoff - Copyright (C) 2008 Lukas Durfina - Copyright (C) 2009 Fathi Boudra - Copyright (C) 2013 Harald Sitter - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . -*/ - -#ifndef PHONON_VLC_AUDIOOUTPUT_H -#define PHONON_VLC_AUDIOOUTPUT_H - -#include - -#include - -#include "sinknode.h" - -namespace Phonon { -namespace VLC { - -/** \brief AudioOutput implementation for Phonon-VLC - * - * This class is a SinkNode that implements the AudioOutputInterface from Phonon. It - * supports setting the volume and the audio output device. - * - * There are signals for the change of the volume or for when an audio device failed. - * - * See the Phonon::AudioOutputInterface documentation for details. - * - * \see AudioDataOutput - */ -class AudioOutput : public QObject, public SinkNode, public AudioOutputInterface -{ - Q_OBJECT - Q_INTERFACES(Phonon::AudioOutputInterface) - -public: - /** - * Creates an AudioOutput with the given backend object. The volume is set to 1.0 - * - * \param p_back Parent backend - * \param p_parent A parent object - */ - explicit AudioOutput(QObject *parent); - ~AudioOutput(); - - /** \reimp */ - void handleConnectToMediaObject(MediaObject *mediaObject); - /** \reimp */ - void handleAddToMedia(Media *media); - - /** - * \return The current volume for this audio output. - */ - qreal volume() const; - - /** - * Sets the volume of the audio output. See the Phonon::AudioOutputInterface::setVolume() documentation - * for details. - */ - void setVolume(qreal volume); - - /** - * \return The index of the current audio output device from the list obtained from the backend object. - */ - int outputDevice() const; - - /** - * Sets the current output device for this audio output. The validity of the device index - * is verified before attempting to change the device. - * - * \param device The index of the device, obtained from the backend's audio device list - * \return \c true if succeeded, or no change was made - * \return \c false if failed - */ - bool setOutputDevice(int); - - /** - * Sets the current output device for this audio output. - * - * \param device The device to set; it should be valid and contain an usable deviceAccessList property - * \return \c true if succeeded, or no change was made - * \return \c false if failed - */ - bool setOutputDevice(const AudioOutputDevice &newDevice); - - void setStreamUuid(QString uuid); - -signals: - void volumeChanged(qreal volume); - void audioDeviceFailed(); - void mutedChanged(bool mute); - -private slots: - /** - * Sets the volume to m_volume. - */ - void applyVolume(); - - void onMutedChanged(bool mute); - void onVolumeChanged(float volume); - -private: - /** - * We can only really set the output device once we have a libvlc_media_player, which comes - * from our SinkNode. - */ - void setOutputDeviceImplementation(); - - qreal m_volume; - AudioOutputDevice m_device; - QString m_streamUuid; -}; - -} // namespace VLC -} // namespace Phonon - -#endif // PHONON_VLC_AUDIOOUTPUT_H diff --git a/src/phonon/phonon-vlc/audio/volumefadereffect.cpp b/src/phonon/phonon-vlc/audio/volumefadereffect.cpp deleted file mode 100644 index 5adcec4a2..000000000 --- a/src/phonon/phonon-vlc/audio/volumefadereffect.cpp +++ /dev/null @@ -1,128 +0,0 @@ -/* This file is part of the KDE project. - * - * Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). - * Copyright (C) 2013 Martin Sandsmark - * - * This library is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 2.1 or 3 of the License. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this library. If not, see . - */ - -#include "volumefadereffect.h" -#include - -#include "utils/debug.h" - -#include - -#ifndef QT_NO_PHONON_VOLUMEFADEREFFECT -namespace Phonon -{ -namespace VLC -{ -VolumeFaderEffect::VolumeFaderEffect(QObject *parent) - : QObject(parent) - , SinkNode() - , m_fadeCurve(Phonon::VolumeFaderEffect::Fade3Decibel) - , m_fadeFromVolume(0) - , m_fadeToVolume(0) -{ - m_fadeTimeline = new QTimeLine(1000, this); - connect(m_fadeTimeline, SIGNAL(valueChanged(qreal)), this, SLOT(slotSetVolume(qreal))); -} - -VolumeFaderEffect::~VolumeFaderEffect() -{ -} - -float VolumeFaderEffect::volume() const -{ - Q_ASSERT(m_player); - return m_player->audioVolume() / 100.0f; -} - -void VolumeFaderEffect::slotSetVolume(qreal volume) -{ - float gstVolume = m_fadeFromVolume + (volume * (m_fadeToVolume - m_fadeFromVolume)); - setVolumeInternal(gstVolume); -} - -Phonon::VolumeFaderEffect::FadeCurve VolumeFaderEffect::fadeCurve() const -{ - return m_fadeCurve; -} - -void VolumeFaderEffect::setFadeCurve(Phonon::VolumeFaderEffect::FadeCurve pFadeCurve) -{ - m_fadeCurve = pFadeCurve; - QEasingCurve fadeCurve; - switch(pFadeCurve) { - case Phonon::VolumeFaderEffect::Fade3Decibel: - fadeCurve = QEasingCurve::InQuad; - break; - case Phonon::VolumeFaderEffect::Fade6Decibel: - fadeCurve = QEasingCurve::Linear; - break; - case Phonon::VolumeFaderEffect::Fade9Decibel: - fadeCurve = QEasingCurve::OutCubic; - break; - case Phonon::VolumeFaderEffect::Fade12Decibel: - fadeCurve = QEasingCurve::OutQuart; - break; - } - m_fadeTimeline->setEasingCurve(fadeCurve); -} - -void VolumeFaderEffect::fadeTo(float targetVolume, int fadeTime) -{ - Q_ASSERT(m_player); - abortFade(); - m_fadeToVolume = targetVolume; - m_fadeFromVolume = m_player->audioVolume() / 100.0f; - - // Don't call QTimeLine::setDuration() with zero. - // It is not supported and breaks fading. - if (fadeTime <= 0) { - debug() << "Called with retarded fade time " << fadeTime; - setVolumeInternal(targetVolume); - return; - } - - m_fadeTimeline->setDuration(fadeTime); - m_fadeTimeline->start(); -} - -void VolumeFaderEffect::setVolume(float v) -{ - abortFade(); - setVolumeInternal(v); -} - -void VolumeFaderEffect::abortFade() -{ - m_fadeTimeline->stop(); -} - -void VolumeFaderEffect::setVolumeInternal(float v) -{ - if (m_player) - m_player->setAudioFade(v); - else - warning() << Q_FUNC_INFO << this << "no m_player set"; -} - -} -} //namespace Phonon::VLC - -#endif //QT_NO_PHONON_VOLUMEFADEREFFECT - -#include "phonon-vlc/audio/moc_volumefadereffect.cpp" -#include "phonon-vlc/audio/moc_volumefadereffect.h" diff --git a/src/phonon/phonon-vlc/audio/volumefadereffect.h b/src/phonon/phonon-vlc/audio/volumefadereffect.h deleted file mode 100644 index b0e95f138..000000000 --- a/src/phonon/phonon-vlc/audio/volumefadereffect.h +++ /dev/null @@ -1,75 +0,0 @@ -/* This file is part of the KDE project. - * - * Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). - * Copyright (C) 2013 Martin Sandsmark - * - * This library is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 2.1 or 3 of the License. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this library. If not, see . - */ - -#ifndef PHONON_VLC_VOLUMEFADEREFFECT_H -#define PHONON_VLC_VOLUMEFADEREFFECT_H - -#ifndef QT_NO_PHONON_EFFECT - -#include - -#include -#include - -#include "sinknode.h" - -class QTimeLine; - -namespace Phonon { - -class MediaObject; - -namespace VLC { - -class VolumeFaderEffect : public QObject, public SinkNode, public VolumeFaderInterface -{ - Q_OBJECT - Q_INTERFACES(Phonon::VolumeFaderInterface) - -public: - explicit VolumeFaderEffect(QObject *parent = 0); - ~VolumeFaderEffect(); - - // VolumeFaderInterface: - float volume() const; - Phonon::VolumeFaderEffect::FadeCurve fadeCurve() const; - void setFadeCurve(Phonon::VolumeFaderEffect::FadeCurve fadeCurve); - void fadeTo(float volume, int fadeTime); - void setVolume(float v); - QPointer mediaObject() { return m_mediaObject; } - -private slots: - void slotSetVolume(qreal v); - -private: - void abortFade(); - inline void setVolumeInternal(float v); - - Phonon::VolumeFaderEffect::FadeCurve m_fadeCurve; - float m_fadeFromVolume; - float m_fadeToVolume; - QTimeLine *m_fadeTimeline; - -}; - -} // namespace VLC -} // namespace Phonon - -#endif // QT_NO_PHONON_EFFECT - -#endif // PHONON_VLC_VOLUMEFADEREFFECT_H diff --git a/src/phonon/phonon-vlc/backend.cpp b/src/phonon/phonon-vlc/backend.cpp deleted file mode 100644 index 306672b82..000000000 --- a/src/phonon/phonon-vlc/backend.cpp +++ /dev/null @@ -1,366 +0,0 @@ -/* - Copyright (C) 2007-2008 Tanguy Krotoff - Copyright (C) 2008 Lukas Durfina - Copyright (C) 2009 Fathi Boudra - Copyright (C) 2009-2011 vlc-phonon AUTHORS - Copyright (C) 2011-2013 Harald Sitter - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . -*/ - -#include "backend.h" - -#include -#include -#include -#include -#include -#include - -#include - -#include - -#include "audio/audiooutput.h" -#include "audio/audiodataoutput.h" -#include "audio/volumefadereffect.h" -#include "devicemanager.h" -#include "effect.h" -#include "effectmanager.h" -#include "mediaobject.h" -#include "sinknode.h" -#include "utils/debug.h" -#include "utils/libvlc.h" -#include "utils/mime.h" -#ifdef PHONON_EXPERIMENTAL -#include "video/videodataoutput.h" -#endif -#ifndef PHONON_NO_GRAPHICSVIEW -#include "video/videographicsobject.h" -#endif -#include "video/videowidget.h" - -Q_EXPORT_PLUGIN2(phonon_vlc, Phonon::VLC::Backend) - -namespace Phonon -{ -namespace VLC -{ - -Backend *Backend::self; - -Backend::Backend(QObject *parent, const QVariantList &) - : QObject(parent) - , m_deviceManager(0) -#ifndef QT_NO_PHONON_EFFECT - , m_effectManager(0) -#endif // QT_NO_PHONON_EFFECT -{ - self = this; - - // Backend information properties - setProperty("identifier", QLatin1String("phonon_vlc")); - setProperty("backendName", QLatin1String("VLC")); - setProperty("backendComment", QLatin1String("VLC backend for Phonon")); - setProperty("backendVersion", QLatin1String(PHONON_VLC_VERSION)); - setProperty("backendIcon", QLatin1String("vlc")); - setProperty("backendWebsite", QLatin1String("https://projects.kde.org/projects/kdesupport/phonon/phonon-vlc")); - - // Check if we should enable debug output - int debugLevel = qgetenv("PHONON_BACKEND_DEBUG").toInt(); - if (debugLevel > 3) // 3 is maximum - debugLevel = 3; - Debug::setMinimumDebugLevel((Debug::DebugLevel)((int) Debug::DEBUG_NONE - 1 - debugLevel)); - - debug() << "Constructing Phonon-VLC Version" << PHONON_VLC_VERSION; - - // Actual libVLC initialisation - if (LibVLC::init()) { - debug() << "Using VLC version" << libvlc_get_version(); - if (!qApp->applicationName().isEmpty()) { - QString userAgent = - QString("%0/%1 (Phonon/%2; Phonon-VLC/%3)").arg( - qApp->applicationName(), - qApp->applicationVersion(), - PHONON_VERSION_STR, - PHONON_VLC_VERSION); - libvlc_set_user_agent(libvlc, - qApp->applicationName().toUtf8().constData(), - userAgent.toUtf8().constData()); - } else { - qWarning("WARNING: Setting the user agent for streaming and" - " PulseAudio requires you to set QCoreApplication::applicationName()"); - } - - if (!qApp->applicationName().isEmpty()) { - const QString id = QString("org.kde.phonon.%1").arg(qApp->applicationName()); - const QString version = qApp->applicationVersion(); - QString icon; - if (!qApp->windowIcon().isNull()){ - // Try to get the fromTheme() name of the QIcon. - icon = qApp->windowIcon().name(); - } - if (icon.isEmpty()) { - // If we failed to get a proper icon name, use the appname instead. - icon = qApp->applicationName().toLower(); - } - libvlc_set_app_id(libvlc, - id.toUtf8().constData(), - version.toUtf8().constData(), - icon.toUtf8().constData()); - } - } else { -#ifdef __GNUC__ - #warning TODO - this error message is as useful as a knife at a gun fight -#endif - QMessageBox msg; - msg.setIcon(QMessageBox::Critical); - msg.setWindowTitle(tr("LibVLC Failed to Initialize")); - msg.setText(tr("Phonon's VLC backend failed to start." - "\n\n" - "This usually means a problem with your VLC installation," - " please report a bug with your distributor.")); - msg.setDetailedText(LibVLC::errorMessage()); - msg.exec(); - fatal() << "Phonon::VLC::vlcInit: Failed to initialize VLC"; - } - - m_deviceManager = new DeviceManager(this); -#ifndef QT_NO_PHONON_EFFECT - m_effectManager = new EffectManager(this); -#endif // QT_NO_PHONON_EFFECT -} - -Backend::~Backend() -{ - if (LibVLC::self) - delete LibVLC::self; - if (GlobalAudioChannels::self) - delete GlobalAudioChannels::self; - if (GlobalSubtitles::self) - delete GlobalSubtitles::self; -} - -QObject *Backend::createObject(BackendInterface::Class c, QObject *parent, const QList &args) -{ - if (!LibVLC::self || !libvlc) - return 0; - - switch (c) { - case MediaObjectClass: - return new MediaObject(parent); - case AudioOutputClass: - return new AudioOutput(parent); -#if (LIBVLC_VERSION_INT < LIBVLC_VERSION(2, 0, 0, 0)) - // Broken >= 2.0 - // https://trac.videolan.org/vlc/ticket/6992 - case AudioDataOutputClass: - return new AudioDataOutput(parent); -#endif -#ifdef PHONON_EXPERIMENTAL - case VideoDataOutputClass: - return new VideoDataOutput(parent); -#endif -#ifndef PHONON_NO_GRAPHICSVIEW - case VideoGraphicsObjectClass: - return new VideoGraphicsObject(parent); -#endif -#ifndef QT_NO_PHONON_EFFECT - case EffectClass: - return effectManager()->createEffect(args[0].toInt(), parent); -#endif // QT_NO_PHONON_EFFECT - case VideoWidgetClass: - return new VideoWidget(qobject_cast(parent)); -// case VolumeFaderEffectClass: -#ifdef __GNUC__ -#warning VFE crashes and has volume bugs ... deactivated -// return new VolumeFaderEffect(parent); -#endif - } - - warning() << "Backend class" << c << "is not supported by Phonon VLC :("; - return 0; -} - -QStringList Backend::availableMimeTypes() const -{ - if (m_supportedMimeTypes.isEmpty()) - const_cast(this)->m_supportedMimeTypes = mimeTypeList(); - return m_supportedMimeTypes; -} - -QList Backend::objectDescriptionIndexes(ObjectDescriptionType type) const -{ - QList list; - - switch (type) { - case Phonon::AudioChannelType: { - list << GlobalAudioChannels::instance()->globalIndexes(); - } - break; - case Phonon::AudioOutputDeviceType: - case Phonon::AudioCaptureDeviceType: - case Phonon::VideoCaptureDeviceType: { - return deviceManager()->deviceIds(type); - } - break; -#ifndef QT_NO_PHONON_EFFECT - case Phonon::EffectType: { - QList effectList = effectManager()->effects(); - for (int eff = 0; eff < effectList.size(); ++eff) { - list.append(eff); - } - } - break; -#endif // QT_NO_PHONON_EFFECT - case Phonon::SubtitleType: { - list << GlobalSubtitles::instance()->globalIndexes(); - } - break; - } - - return list; -} - -QHash Backend::objectDescriptionProperties(ObjectDescriptionType type, int index) const -{ - QHash ret; - - switch (type) { - case Phonon::AudioChannelType: { - const AudioChannelDescription description = GlobalAudioChannels::instance()->fromIndex(index); - ret.insert("name", description.name()); - ret.insert("description", description.description()); - } - break; - case Phonon::AudioOutputDeviceType: - case Phonon::AudioCaptureDeviceType: - case Phonon::VideoCaptureDeviceType: { - // Index should be unique, even for different categories - return deviceManager()->deviceProperties(index); - } - break; -#ifndef QT_NO_PHONON_EFFECT - case Phonon::EffectType: { - const QList effectList = effectManager()->effects(); - if (index >= 0 && index <= effectList.size()) { - const EffectInfo &effect = effectList.at(index); - ret.insert("name", effect.name()); - ret.insert("description", effect.description()); - ret.insert("author", effect.author()); - } else { - Q_ASSERT(1); // Since we use list position as ID, this should not happen - } - } - break; -#endif // QT_NO_PHONON_EFFECT - case Phonon::SubtitleType: { - const SubtitleDescription description = GlobalSubtitles::instance()->fromIndex(index); - ret.insert("name", description.name()); - ret.insert("description", description.description()); - ret.insert("type", description.property("type")); - } - break; - } - - return ret; -} - -bool Backend::startConnectionChange(QSet objects) -{ - //FIXME - foreach(QObject * object, objects) { - debug() << "Object:" << object->metaObject()->className(); - } - - // There is nothing we can do but hope the connection changes will not take too long - // so that buffers would underrun - // But we should be pretty safe the way xine works by not doing anything here. - return true; -} - -bool Backend::connectNodes(QObject *source, QObject *sink) -{ - debug() << "Backend connected" << source->metaObject()->className() << "to" << sink->metaObject()->className(); - - SinkNode *sinkNode = dynamic_cast(sink); - if (sinkNode) { - MediaObject *mediaObject = qobject_cast(source); - if (mediaObject) { - // Connect the SinkNode to a MediaObject - sinkNode->connectToMediaObject(mediaObject); - return true; - } - -#ifndef QT_NO_PHONON_EFFECT - VolumeFaderEffect *effect = qobject_cast(source); - if (effect) { - sinkNode->connectToMediaObject(effect->mediaObject()); - return true; - } -#endif // QT_NO_PHONON_EFFECT - } - - warning() << "Linking" << source->metaObject()->className() << "to" << sink->metaObject()->className() << "failed"; - - return false; -} - -bool Backend::disconnectNodes(QObject *source, QObject *sink) -{ - SinkNode *sinkNode = dynamic_cast(sink); - if (sinkNode) { - MediaObject *const mediaObject = qobject_cast(source); - if (mediaObject) { - // Disconnect the SinkNode from a MediaObject - sinkNode->disconnectFromMediaObject(mediaObject); - return true; - } - -#ifndef QT_NO_PHONON_EFFECT - VolumeFaderEffect *const effect = qobject_cast(source); - if (effect) { - sinkNode->disconnectFromMediaObject(effect->mediaObject()); - return true; - } -#endif // QT_NO_PHONON_EFFECT - } - - return false; -} - -bool Backend::endConnectionChange(QSet objects) -{ - foreach(QObject *object, objects) { - debug() << "Object:" << object->metaObject()->className(); - } - return true; -} - -DeviceManager *Backend::deviceManager() const -{ - return m_deviceManager; -} - -#ifndef QT_NO_PHONON_EFFECT -EffectManager *Backend::effectManager() const -{ - return m_effectManager; -} -#endif // QT_NO_PHONON_EFFECT - -} // namespace VLC -} // namespace Phonon - -#include "phonon-vlc/moc_backend.h" diff --git a/src/phonon/phonon-vlc/backend.h b/src/phonon/phonon-vlc/backend.h deleted file mode 100644 index bdd32a352..000000000 --- a/src/phonon/phonon-vlc/backend.h +++ /dev/null @@ -1,163 +0,0 @@ -/* - Copyright (C) 2007-2008 Tanguy Krotoff - Copyright (C) 2008 Lukas Durfina - Copyright (C) 2009 Fathi Boudra - Copyright (C) 2009-2011 vlc-phonon AUTHORS - Copyright (C) 2011 Harald Sitter - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . -*/ - -#ifndef Phonon_VLC_BACKEND_H -#define Phonon_VLC_BACKEND_H - -#include - -#include -#include - -class LibVLC; - -namespace Phonon -{ -namespace VLC -{ -class DeviceManager; -#ifndef QT_NO_PHONON_EFFECT -class EffectManager; -#endif // QT_NO_PHONON_EFFECT - -/** \brief Backend class for Phonon-VLC. - * - * This class provides the special objects created by the backend and information about - * various things that the backend supports. An object of this class is the root for - * the backend plugin. - * - * Phonon will request the backend to create objects of various classes, like MediaObject, - * AudioOutput, VideoWidget, Effect. There are also methods to handle the connections between - * these objects. - * - * This class also provides information about the devices and effects that the backend supports. - * These are audio output devices, audio capture devices, video capture devices, effects. - */ - -class Backend : public QObject, public BackendInterface -{ - Q_OBJECT - Q_INTERFACES(Phonon::BackendInterface) - -public: - /** - * Instance. Since there is no backend instance without actual Backend object - * this class behaves likes a singleton. - */ - static Backend *self; - - /** - * Constructs the backend. Sets the backend properties, fetches the debug level from the - * environment, initializes libVLC, constructs the device and effect managers, initializes - * PulseAudio support. - * - * \param parent A parent object for the backend (passed to the QObject constructor) - */ - explicit Backend(QObject *parent = 0, const QVariantList & = QVariantList()); - virtual ~Backend(); - - /// \return The device manager that is associated with this backend object - DeviceManager *deviceManager() const; - -#ifndef QT_NO_PHONON_EFFECT - /// \return The effect manager that is associated with this backend object. - EffectManager *effectManager() const; -#endif // QT_NO_PHONON_EFFECT - - /** - * Creates a backend object of the desired class and with the desired parent. Extra arguments can be provided. - * - * \param c The class of object that is to be created - * \param parent The object that will be the parent of the new object - * \param args Optional arguments for the object creation - * \return The desired object or NULL if the class is not implemented. - */ - QObject *createObject(BackendInterface::Class, QObject *parent, const QList &args); - - /// \returns a list of all available mimetypes (hardcoded) - QStringList availableMimeTypes() const; - - /** - * Returns a list of indexes for the desired object types. It specifies a list of objects - * of a particular category that the backend knows about. These indexes can be used with - * objectDescriptionProperties() to get the properties of a particular object. - * - * \param type The type of objects for the list - */ - QList objectDescriptionIndexes(ObjectDescriptionType type) const; - - /** - * Returns a list of properties for a particular object of the desired category. - * - * \param type The type of object for the index - * \param index The index for the object of the desired type - * \return The property list. If the object is inexistent, an empty list is returned. - */ - QHash objectDescriptionProperties(ObjectDescriptionType type, int index) const; - - /** - * Called when a connection between nodes is about to be changed - * - * \param objects A set of objects that will be involved in the change - */ - bool startConnectionChange(QSet); - - /** - * Connects two media nodes. The sink is informed that it should connect itself to the source. - * - * \param source The source media node for the connection - * \param sink The sink media node for the connection - * \return True if the connection was successful - */ - bool connectNodes(QObject *, QObject *); - - /** - * Disconnects two previously connected media nodes. It disconnects the sink node from the source node. - * - * \param source The source node for the disconnection - * \param sink The sink node for the disconnection - * \return True if the disconnection was successful - */ - bool disconnectNodes(QObject *, QObject *); - - /** - * Called after a connection between nodes has been changed - * - * \param objects Nodes involved in the disconnection - */ - bool endConnectionChange(QSet); - -Q_SIGNALS: - void objectDescriptionChanged(ObjectDescriptionType); - -private: - mutable QStringList m_supportedMimeTypes; - - DeviceManager *m_deviceManager; -#ifndef QT_NO_PHONON_EFFECT - EffectManager *m_effectManager; -#endif // QT_NO_PHONON_EFFECT -}; - -} // namespace VLC -} // namespace Phonon - -#endif // Phonon_VLC_BACKEND_H diff --git a/src/phonon/phonon-vlc/devicemanager.cpp b/src/phonon/phonon-vlc/devicemanager.cpp deleted file mode 100644 index 5192eb8fe..000000000 --- a/src/phonon/phonon-vlc/devicemanager.cpp +++ /dev/null @@ -1,326 +0,0 @@ -/* - Copyright (C) 2007-2008 Tanguy Krotoff - Copyright (C) 2008 Lukas Durfina - Copyright (C) 2009 Fathi Boudra - Copyright (C) 2009-2010 vlc-phonon AUTHORS - Copyright (C) 2011 Harald Sitter - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . -*/ - -#include "devicemanager.h" - -#include - -#include "backend.h" -#include "utils/debug.h" -#include "utils/libvlc.h" -#include "utils/vstring.h" - -namespace Phonon -{ -namespace VLC -{ - -/* - * Device Info - */ - -DeviceInfo::DeviceInfo(const QString &name, bool isAdvanced) -{ - // Get an id - static int counter = 0; - m_id = counter++; - - // Get name and description for the device - m_name = name; - m_isAdvanced = isAdvanced; - m_capabilities = None; - - // A default device should never be advanced - if (name.startsWith(QLatin1String("default"), Qt::CaseInsensitive)) - m_isAdvanced = false; -} - -int DeviceInfo::id() const -{ - return m_id; -} - -const QString& DeviceInfo::name() const -{ - return m_name; -} - -const QString& DeviceInfo::description() const -{ - return m_description; -} - -bool DeviceInfo::isAdvanced() const -{ - return m_isAdvanced; -} - -void DeviceInfo::setAdvanced(bool advanced) -{ - m_isAdvanced = advanced; -} - -const DeviceAccessList& DeviceInfo::accessList() const -{ - return m_accessList; -} - -void DeviceInfo::addAccess(const DeviceAccess& access) -{ - if (m_accessList.isEmpty()) - m_description = access.first + ": " + access.second; - m_accessList.append(access); -} - -quint16 DeviceInfo::capabilities() const -{ - return m_capabilities; -} - -void DeviceInfo::setCapabilities(quint16 cap) -{ - m_capabilities = cap; -} - - -/* - * Device Manager - */ - -DeviceManager::DeviceManager(Backend *parent) - : QObject(parent) - , m_backend(parent) -{ - Q_ASSERT(parent); - updateDeviceList(); -} - -DeviceManager::~DeviceManager() -{ -} - -QList DeviceManager::deviceIds(ObjectDescriptionType type) -{ - DeviceInfo::Capability capability = DeviceInfo::None; - switch (type) { - case Phonon::AudioOutputDeviceType: - capability = DeviceInfo::AudioOutput; - break; - case Phonon::AudioCaptureDeviceType: - capability = DeviceInfo::AudioCapture; - break; - case Phonon::VideoCaptureDeviceType: - capability = DeviceInfo::VideoCapture; - break; - default: ; - } - - QList ids; - foreach (const DeviceInfo &device, m_devices) { - if (device.capabilities() & capability) - ids.append(device.id()); - } - - return ids; -} - -QHash DeviceManager::deviceProperties(int id) -{ - QHash properties; - - foreach (const DeviceInfo &device, m_devices) { - if (device.id() == id) { - properties.insert("name", device.name()); - properties.insert("description", device.description()); - properties.insert("isAdvanced", device.isAdvanced()); - properties.insert("deviceAccessList", QVariant::fromValue(device.accessList())); - properties.insert("discovererIcon", "vlc"); - - if (device.capabilities() & DeviceInfo::AudioOutput) { - properties.insert("icon", QLatin1String("audio-card")); - } - - if (device.capabilities() & DeviceInfo::AudioCapture) { - properties.insert("hasaudio", true); - properties.insert("icon", QLatin1String("audio-input-microphone")); - } - - if (device.capabilities() & DeviceInfo::VideoCapture) { - properties.insert("hasvideo", true); - properties.insert("icon", QLatin1String("camera-web")); - } - break; - } - } - - return properties; -} - -const DeviceInfo *DeviceManager::device(int id) const -{ - for (int i = 0; i < m_devices.size(); i ++) { - if (m_devices[i].id() == id) - return &m_devices[i]; - } - - return NULL; -} - -static QList vlcAudioOutBackends() -{ - QList ret; - - VLC_FOREACH_LIST(audio_output, aout) { - QByteArray name(aout->psz_name); - if (!ret.contains(name)) - ret.append(name); - } - - return ret; -} - -void DeviceManager::updateDeviceList() -{ - QList newDeviceList; - - if (!LibVLC::self || !libvlc) - return; - - QList audioOutBackends = vlcAudioOutBackends(); - - QList knownSoundSystems; - // Whitelist - Order has no particular impact. - // NOTE: if listing was not intercepted by the PA code above we also need - // to try injecting the pulse aout as otherwise the user would have to - // use the fake PA device in ALSA to output through PA (kind of silly). - knownSoundSystems << QByteArray("pulse") - << QByteArray("alsa") - << QByteArray("oss") - << QByteArray("jack") - << QByteArray("aout_directx") // Windows up to VLC 2.0 - << QByteArray("directsound") // Windows from VLC 2.1 upwards - << QByteArray("auhal"); // Mac - foreach (const QByteArray &soundSystem, knownSoundSystems) { - if (!audioOutBackends.contains(soundSystem)) { - debug() << "Sound system" << soundSystem << "not supported by libvlc"; - continue; - } - - // FIXME: there is a rather ungodly amount of code duplication going - // on here. -#if (LIBVLC_VERSION_INT >= LIBVLC_VERSION(2, 2, 0, 0)) - bool hasDevices = false; - VLC_FOREACH(audio_output_device, - device, - libvlc_audio_output_device_list_get(libvlc, soundSystem), - libvlc_audio_output_device_list_release) { - QString idName = QString::fromUtf8(device->psz_device); - QString longName = QString::fromUtf8(device->psz_description); - - debug() << "found device" << soundSystem << idName << longName; - - DeviceInfo info(longName, true); - info.addAccess(DeviceAccess(soundSystem, idName)); - info.setCapabilities(DeviceInfo::AudioOutput); - newDeviceList.append(info); - - hasDevices = true; - } - - if (!hasDevices) { - debug() << "manually injecting sound system" << soundSystem; - DeviceInfo info(QString::fromUtf8(soundSystem), false); - info.addAccess(DeviceAccess(soundSystem, "")); - info.setCapabilities(DeviceInfo::AudioOutput); - newDeviceList.append(info); - } -#else - const int deviceCount = libvlc_audio_output_device_count(libvlc, soundSystem); - - for (int i = 0; i < deviceCount; i++) { - VString idName(libvlc_audio_output_device_id(libvlc, soundSystem, i)); - VString longName(libvlc_audio_output_device_longname(libvlc, soundSystem, i)); - - debug() << "found device" << soundSystem << idName << longName; - - DeviceInfo info(longName, true); - info.addAccess(DeviceAccess(soundSystem, idName)); - info.setCapabilities(DeviceInfo::AudioOutput); - newDeviceList.append(info); - } - - // libVLC gives no devices for some sound systems, like OSS - if (deviceCount == 0) { - debug() << "manually injecting sound system" << soundSystem; - // NOTE: Do not mark manually injected devices as advanced. - // libphonon filters advanced devices from the default - // selection which on systems such as OSX or Windows can - // lead to an empty device list as the injected device is - // the only available one. - DeviceInfo info(QString::fromUtf8(soundSystem), false); - info.addAccess(DeviceAccess(soundSystem, "")); - info.setCapabilities(DeviceInfo::AudioOutput); - newDeviceList.append(info); - } -#endif - } - - /* - * Compares the list with the devices available at the moment with the last list. If - * a new device is seen, a signal is emitted. If a device disappeared, another signal - * is emitted. - */ - - // Search for added devices - for (int i = 0; i < newDeviceList.count(); ++i) { - int id = newDeviceList[i].id(); - if (!listContainsDevice(m_devices, id)) { - // This is a new device, add it - m_devices.append(newDeviceList[i]); - emit deviceAdded(id); - - debug() << "Added backend device" << newDeviceList[i].name(); - } - } - - // Search for removed devices - for (int i = m_devices.count() - 1; i >= 0; --i) { - int id = m_devices[i].id(); - if (!listContainsDevice(newDeviceList, id)) { - emit deviceRemoved(id); - m_devices.removeAt(i); - } - } -} - -bool DeviceManager::listContainsDevice(const QList &list, int id) -{ - foreach (const DeviceInfo &d, list) { - if (d.id() == id) - return true; - } - return false; -} - -} -} - -#include "phonon-vlc/moc_devicemanager.h" diff --git a/src/phonon/phonon-vlc/devicemanager.h b/src/phonon/phonon-vlc/devicemanager.h deleted file mode 100644 index 73f112377..000000000 --- a/src/phonon/phonon-vlc/devicemanager.h +++ /dev/null @@ -1,146 +0,0 @@ -/* - Copyright (C) 2009-2010 vlc-phonon AUTHORS - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . -*/ - -#ifndef Phonon_VLC_DEVICEMANAGER_H -#define Phonon_VLC_DEVICEMANAGER_H - -#include - -#include - -namespace Phonon -{ -namespace VLC -{ - -class Backend; - -/** \brief Container for information about devices supported by libVLC - * - * It includes a (hopefully unique) device identifier, a name identifier, a - * description, a hardware identifier (may be a platform dependent device name), - * and other relevant info. - */ -class DeviceInfo -{ -public: - enum Capability { - None = 0x0000, - AudioOutput = 0x0001, - AudioCapture = 0x0002, - VideoCapture = 0x0004 - }; -public: - /** - * Constructs a device info object and sets it's device identifiers. - */ - explicit DeviceInfo(const QString &name, bool isAdvanced = true); - - int id() const; - const QString& name() const; - const QString& description() const; - bool isAdvanced() const; - void setAdvanced(bool advanced); - const DeviceAccessList& accessList() const; - void addAccess(const DeviceAccess &access); - quint16 capabilities() const; - void setCapabilities(quint16 cap); - -private: - int m_id; - QString m_name; - QString m_description; - bool m_isAdvanced; - DeviceAccessList m_accessList; - quint16 m_capabilities; -}; - -/** \brief Keeps track of audio/video devices that libVLC supports - * - * This class maintains a device list. Types of devices: - * \li audio output devices - * \li audio capture devices - * \li video capture devices - * - * Methods are provided to retrieve information about these devices. - * - * \see EffectManager - */ -class DeviceManager : public QObject -{ - Q_OBJECT - -public: - /** - * Constructs a device manager and immediately updates the devices. - */ - explicit DeviceManager(Backend *parent); - - /** - * Clears all the devices before destroying. - */ - virtual ~DeviceManager(); - - /** - * \param type Only devices with a capability of this type are returned - * The following are supported: - * \li AudioOutputDeviceType - * \li AudioCaptureDeviceType - * \li VideoCaptureDeviceType - * - * \return A list of device identifiers that have capabilities that - * match the desired type - * - * \note The capture devices are temporarily not implemented / removed - */ - QList deviceIds(ObjectDescriptionType type); - - /** - * \param id The identifier for the device - * \return Object description properties for a device - */ - QHash deviceProperties(int id); - - /** - * \param id The identifier for the device - * \return Pointer to DeviceInfo, or NULL if the id is invalid - */ - const DeviceInfo *device(int id) const; - -signals: - void deviceAdded(int); - void deviceRemoved(int); - -public slots: - /** - * Update the current list of active devices. It probes for audio output devices, - * audio capture devices, video capture devices. The methods depend on the - * device types. - */ - void updateDeviceList(); - -private: - static bool listContainsDevice(const QList &list, int id); - -private: - Backend *m_backend; - QList m_devices; -}; -} -} // namespace Phonon::VLC - -#endif // Phonon_VLC_DEVICEMANAGER_H diff --git a/src/phonon/phonon-vlc/effect.cpp b/src/phonon/phonon-vlc/effect.cpp deleted file mode 100644 index 620133d58..000000000 --- a/src/phonon/phonon-vlc/effect.cpp +++ /dev/null @@ -1,231 +0,0 @@ -/* - Copyright (C) 2007-2008 Tanguy Krotoff - Copyright (C) 2008 Lukas Durfina - Copyright (C) 2009 Fathi Boudra - Copyright (C) 2009-2011 vlc-phonon AUTHORS - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . -*/ - -#ifndef QT_NO_PHONON_EFFECT - -#include "effect.h" - -#include "effectmanager.h" - -#include "mediaobject.h" - -namespace Phonon -{ -namespace VLC -{ - -Effect::Effect(EffectManager *p_em, int i_effectId, QObject *p_parent) - : QObject(p_parent) - , SinkNode() -{ - Q_UNUSED(p_em); - Q_UNUSED(i_effectId); -// p_effectManager = p_em; -// const QList effects = p_effectManager->effects(); - -// if (i_effectId >= 0 && i_effectId < effects.size()) { -// i_effect_filter = effects[ i_effectId ]->filter(); -// effect_type = effects[ i_effectId ]->type(); -// setupEffectParams(); -// } else { -// // effect ID out of range -// Q_ASSERT(0); -// } -} - -Effect::~Effect() -{ - parameterList.clear(); -} - -void Effect::handleConnectToMediaObject(MediaObject *) -{ - switch (effect_type) { - case EffectInfo::AudioEffect: -// libvlc_audio_filter_add(p_vlc_instance, (libvlc_audio_filter_names_t)i_effect_filter, vlc_exception); -// vlcExceptionRaised(); - break; - case EffectInfo::VideoEffect: -// libvlc_video_filter_add(p_vlc_current_media_player, (libvlc_video_filter_names_t)i_effect_filter, vlc_exception); -// vlcExceptionRaised(); - break; - } -} - -void Effect::handleDisconnectFromMediaObject(MediaObject *) -{ - switch (effect_type) { - case EffectInfo::AudioEffect: -// libvlc_audio_filter_remove(p_vlc_instance, (libvlc_audio_filter_names_t)i_effect_filter, vlc_exception); -// vlcExceptionRaised(); - break; - case EffectInfo::VideoEffect: -// libvlc_video_filter_remove(p_vlc_current_media_player, (libvlc_video_filter_names_t)i_effect_filter, vlc_exception); -// vlcExceptionRaised(); - break; - } -} - -void Effect::setupEffectParams() -{ -// libvlc_filter_parameter_list_t *p_list; - switch (effect_type) { - case EffectInfo::AudioEffect: -// p_list = libvlc_audio_filter_get_parameters(p_vlc_instance, (libvlc_audio_filter_names_t)i_effect_filter, vlc_exception ); -// vlcExceptionRaised(); - break; - case EffectInfo::VideoEffect: -// p_list = libvlc_video_filter_get_parameters(p_vlc_instance, (libvlc_video_filter_names_t)i_effect_filter, vlc_exception ); -// vlcExceptionRaised(); - break; - } -// if( !p_list ) -// return; - -// int i_index = 0; -// libvlc_filter_parameter_list_t *p_parameter_list = p_list; -// while (p_parameter_list) { -// switch (p_parameter_list->var_type) { -// case LIBVLC_BOOL: { -// const QString description = p_parameter_list->psz_description; -// parameterList.append(Phonon::EffectParameter( -// i_index, -// QString(p_parameter_list->psz_parameter_name), -// Phonon::EffectParameter::ToggledHint, // hints -// QVariant((bool) p_parameter_list->default_value.b_bool), -// QVariant((bool) false), -// QVariant((bool) true), -// QVariantList(), -// description)); -// break; -// } -// case LIBVLC_INT: { -// const QString description = p_parameter_list->psz_description; -// parameterList.append(Phonon::EffectParameter( -// i_index, -// QString(p_parameter_list->psz_parameter_name), -// EffectParameter::IntegerHint, // hints -// QVariant((int) p_parameter_list->default_value.i_int), -// QVariant((int) p_parameter_list->min_value.i_int), -// QVariant((int) p_parameter_list->max_value.i_int), -// QVariantList(), -// description)); -// break; -// } -// case LIBVLC_FLOAT: { -// const QString description = p_parameter_list->psz_description; -// parameterList.append(Phonon::EffectParameter( -// i_index, -// QString(p_parameter_list->psz_parameter_name), -// 0, // hints -// QVariant((double) p_parameter_list->default_value.f_float), -// QVariant((double) p_parameter_list->min_value.f_float), -// QVariant((double) p_parameter_list->max_value.f_float), -// QVariantList(), -// description)); -// break; -// } -// case LIBVLC_STRING: { -// const QString description = p_parameter_list->psz_description; -// parameterList.append(Phonon::EffectParameter( -// i_index, -// QString(p_parameter_list->psz_parameter_name), -// 0, // hints -// QVariant((const char *) p_parameter_list->default_value.psz_string), -// NULL, -// NULL, -// QVariantList(), -// description)); -// break; -// } -// } -// i_index++; -// p_parameter_list = p_parameter_list->p_next; -// } -// libvlc_filter_parameters_release(p_list); -} - -QList Effect::parameters() const -{ - return parameterList; -} - -QVariant Effect::parameterValue(const EffectParameter ¶m) const -{ - Q_UNUSED(param); - return QVariant(); -} - -void Effect::setParameterValue(const EffectParameter ¶m, const QVariant &newValue) -{ - Q_UNUSED(param); - Q_UNUSED(newValue); -// libvlc_value_t value; -// libvlc_var_type_t type; -// switch (param.type()) { -// case QVariant::Bool: -// value.b_bool = newValue.toBool(); -// type = LIBVLC_BOOL; -// break; -// case QVariant::Int: -// value.i_int = newValue.toInt(); -// type = LIBVLC_INT; -// break; -// case QVariant::Double: -// value.f_float = (float) newValue.toDouble(); -// type = LIBVLC_FLOAT; -// break; -// case QVariant::String: -// value.psz_string = newValue.toString().toAscii().data(); -// type = LIBVLC_STRING; -// break; -// default: -// break; -// } -// switch (effect_type) { -// case EffectInfo::AudioEffect: -// libvlc_audio_filter_set_parameter( -// p_vlc_instance, -// // (libvlc_audio_filter_names_t) i_effect_filter, -// param.name().toAscii().data(), -// type, -// value, -// vlc_exception); -// vlcExceptionRaised(); -// break; -// case EffectInfo::VideoEffect: -// libvlc_video_filter_set_parameter( -// p_vlc_current_media_player, -// (libvlc_video_filter_names_t) i_effect_filter, -// param.name().toAscii().data(), -// type, -// value, -// vlc_exception); -// vlcExceptionRaised(); -// break; -// } -} - -} -} // Namespace Phonon::VLC - -#include "phonon-vlc/moc_effect.h" - -#endif // QT_NO_PHONON_EFFECT \ No newline at end of file diff --git a/src/phonon/phonon-vlc/effect.h b/src/phonon/phonon-vlc/effect.h deleted file mode 100644 index 60ff37680..000000000 --- a/src/phonon/phonon-vlc/effect.h +++ /dev/null @@ -1,84 +0,0 @@ -/* - Copyright (C) 2007-2008 Tanguy Krotoff - Copyright (C) 2008 Lukas Durfina - Copyright (C) 2009 Fathi Boudra - Copyright (C) 2009-2011 vlc-phonon AUTHORS - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . -*/ - -#ifndef PHONON_VLC_EFFECT_H -#define PHONON_VLC_EFFECT_H - -#ifndef QT_NO_PHONON_EFFECT - -#include "sinknode.h" -#include "effectmanager.h" - -#include -#include - -namespace Phonon -{ -namespace VLC -{ - -class EffectManager; - -/** \brief Effect implementation for Phonon-VLC - * - * There are methods to get or set the effect parameters, implemented for - * the EffectInterface. See the Phonon documentation for details. - * - * As a sink node, it provides methods to handle the connection to a media object. - * - * An effect manager is the parent of each effect. - * - * \see EffectManager - * \see VolumeFaderEffect - */ -class Effect : public QObject, public SinkNode, public EffectInterface -{ - Q_OBJECT - Q_INTERFACES(Phonon::EffectInterface) - -public: - - Effect(EffectManager *p_em, int i_effectId, QObject *p_parent); - ~Effect(); - - void setupEffectParams(); - QList parameters() const; - QVariant parameterValue(const EffectParameter ¶m) const; - void setParameterValue(const EffectParameter ¶m, const QVariant &newValue); - - /** \reimp */ - void handleConnectToMediaObject(MediaObject *p_media_object); - /** \reimp */ - void handleDisconnectFromMediaObject(MediaObject *p_media_object); - -private: - - EffectManager *p_effectManager; - int i_effect_filter; - EffectInfo::Type effect_type; - QList parameterList; -}; - -} -} // Namespace Phonon::VLC - -#endif // QT_NO_PHONON_EFFECT - -#endif // PHONON_VLC_EFFECT_H diff --git a/src/phonon/phonon-vlc/effectmanager.cpp b/src/phonon/phonon-vlc/effectmanager.cpp deleted file mode 100644 index abea19ac8..000000000 --- a/src/phonon/phonon-vlc/effectmanager.cpp +++ /dev/null @@ -1,141 +0,0 @@ -/* - Copyright (C) 2007-2008 Tanguy Krotoff - Copyright (C) 2008 Lukas Durfina - Copyright (C) 2009 Fathi Boudra - Copyright (C) 2009-2011 vlc-phonon AUTHORS - Copyright (C) 2011 Harald Sitter - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . -*/ - -#ifndef QT_NO_PHONON_EFFECT - -#include "effectmanager.h" - -#include -#include - -#if (LIBVLC_VERSION_INT >= LIBVLC_VERSION(2, 2, 0, 0)) -#include "equalizereffect.h" -#endif - -#include "utils/debug.h" -#include "utils/libvlc.h" - -namespace Phonon { -namespace VLC { - -EffectInfo::EffectInfo(const QString &name, const QString &description, - const QString &author, int filter, Type type) - : m_name(name) - , m_description(description) - , m_author(author) - , m_filter(filter) - , m_type(type) -{} - -EffectManager::EffectManager(QObject *parent) - : QObject(parent) -{ - if (!libvlc) - return; - - updateEffects(); -} - -EffectManager::~EffectManager() -{ - m_audioEffectList.clear(); - m_videoEffectList.clear(); - - // EffectsList holds the same pointers as audio and video, so qDeleteAll on - // this container would cause a double freeing. - m_effectList.clear(); -} - -const QList EffectManager::audioEffects() const -{ - return m_audioEffectList; -} - -const QList EffectManager::videoEffects() const -{ - return m_videoEffectList; -} - -const QList EffectManager::effects() const -{ - return m_effectList; -} - -QObject *EffectManager::createEffect(int id, QObject *parent) -{ - Q_UNUSED(id); -#if (LIBVLC_VERSION_INT >= LIBVLC_VERSION(2, 2, 0, 0)) - return new EqualizerEffect(parent); -#else - Q_UNUSED(parent); -#endif - return 0; -} - -void EffectManager::updateEffects() -{ - DEBUG_BLOCK; - - m_effectList.clear(); - m_audioEffectList.clear(); - m_videoEffectList.clear(); - - // Generic effect activation etc is entirely kaput and equalizer has specific - // API anyway, so we simply manually insert it \o/ - -#if (LIBVLC_VERSION_INT >= LIBVLC_VERSION(2, 2, 0, 0)) - const QString eqName = QString("equalizer-%1bands").arg(QString::number(libvlc_audio_equalizer_get_band_count())); - m_audioEffectList.append(EffectInfo( - eqName, - QString(""), - QString(""), - 0, - EffectInfo::AudioEffect)); -#endif - -// int moduleCount = -1; -// VLC_FOREACH_MODULE(module, libvlc_audio_filter_list_get(libvlc)) { -// m_audioEffectList.append(new EffectInfo(module->psz_longname, -// module->psz_help, -// QString(), -// ++moduleCount, -// EffectInfo::AudioEffect)); -// } - -// moduleCount = -1; -// VLC_FOREACH_MODULE(module, libvlc_video_filter_list_get(libvlc)) { -// m_videoEffectList.append(new EffectInfo(module->psz_longname, -// module->psz_help, -// QString(), -// ++moduleCount, -// EffectInfo::VideoEffect)); -// } - - m_effectList.append(m_audioEffectList); - m_effectList.append(m_videoEffectList); -} - -} // namespace VLC -} // namespace Phonon - -#include "phonon-vlc/moc_effectmanager.h" - -#endif // QT_NO_PHONON_EFFECT diff --git a/src/phonon/phonon-vlc/effectmanager.h b/src/phonon/phonon-vlc/effectmanager.h deleted file mode 100644 index 60f15e6d6..000000000 --- a/src/phonon/phonon-vlc/effectmanager.h +++ /dev/null @@ -1,123 +0,0 @@ -/* - Copyright (C) 2007-2008 Tanguy Krotoff - Copyright (C) 2008 Lukas Durfina - Copyright (C) 2009 Fathi Boudra - Copyright (C) 2009-2011 vlc-phonon AUTHORS - Copyright (C) 2011 Harald Sitter - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . -*/ - -#ifndef Phonon_VLC_EFFECTMANAGER_H -#define Phonon_VLC_EFFECTMANAGER_H - -#ifndef QT_NO_PHONON_EFFECT - -#include - -namespace Phonon { -namespace VLC { - -class Backend; -class EffectManager; - -/// Holds information about an effect -class EffectInfo -{ -public: - - enum Type {AudioEffect, VideoEffect}; - - EffectInfo(const QString &name, - const QString &description, - const QString &author, - int filter, - Type type); - - QString name() const { - return m_name; - } - - QString description() const { - return m_description; - } - - QString author() const { - return m_author; - } - - int filter() const { - return m_filter; - } - - Type type() const { - return m_type; - } - -private: - QString m_name; - QString m_description; - QString m_author; - int m_filter; - Type m_type; -}; - -/** \brief Manages a list of effects. - * - * \see EffectInfo - */ -class EffectManager : public QObject -{ - Q_OBJECT -public: - /** - * Creates a new effect manager. It creates the lists of effects. - * - * \param backend A parent backend object for the effect manager - * - * \warning Currently it doesn't add any effects, everything is disabled. - * \see EffectInfo - */ - explicit EffectManager(QObject *parent = 0); - - /// Deletes all the effects from the lists and destroys the effect manager. - ~EffectManager(); - - /// Returns a list of available audio effects - const QList audioEffects() const; - - /// Returns a list of available video effects - const QList videoEffects() const; - - /// Returns a list of available effects - const QList effects() const; - - QObject *createEffect(int id, QObject *parent); - -private: - /// Generates the aggegated list of effects from both video and audio - void updateEffects(); - - QList m_effectList; - QList m_audioEffectList; - QList m_videoEffectList; - bool m_equalizerEnabled; -}; - -} // namespace VLC -} // namespace Phonon - -#endif // QT_NO_PHONON_EFFECT - -#endif // Phonon_VLC_EFFECTMANAGER_H diff --git a/src/phonon/phonon-vlc/equalizereffect.cpp b/src/phonon/phonon-vlc/equalizereffect.cpp deleted file mode 100644 index 3f562f491..000000000 --- a/src/phonon/phonon-vlc/equalizereffect.cpp +++ /dev/null @@ -1,90 +0,0 @@ -/* - Copyright (C) 2013 Harald Sitter - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . -*/ - -#ifndef QT_NO_PHONON_EFFECT - -#include -#if (LIBVLC_VERSION_INT >= LIBVLC_VERSION(2, 2, 0, 0)) - -#include "equalizereffect.h" - -#include "mediaplayer.h" -#include "utils/debug.h" - -namespace Phonon { -namespace VLC { - -EqualizerEffect::EqualizerEffect(QObject *parent) - : QObject(parent) - , SinkNode() - , EffectInterface() - , m_equalizer(libvlc_audio_equalizer_new()) -{ - // Amarok decided to make up rules because phonon didn't manage to - // pre-amp string needs to be pre-amp - // bands need to be xxHz - // That way they can be consistently mapped to localized/formatted strings. - - EffectParameter preamp(-1, "pre-amp", 0 /* hint */, 0.0f, -20.0f, 20.0f); - m_bands.append(preamp); - - const unsigned int bandCount = libvlc_audio_equalizer_get_band_count(); - for (unsigned int i = 0; i < bandCount; ++i) { - const float frequency = libvlc_audio_equalizer_get_band_frequency(i); - const QString name = QString("%1Hz").arg(QString::number(frequency)); - EffectParameter parameter(i, name, 0 /* hint */, 0.0f, -20.0f, 20.0f); - m_bands.append(parameter); - } -} - -EqualizerEffect::~EqualizerEffect() -{ - libvlc_audio_equalizer_release(m_equalizer); -} - -QList EqualizerEffect::parameters() const -{ - return m_bands; -} - -QVariant EqualizerEffect::parameterValue(const EffectParameter ¶meter) const -{ - return libvlc_audio_equalizer_get_amp_at_index(m_equalizer, parameter.id()); -} - -void EqualizerEffect::setParameterValue(const EffectParameter ¶meter, - const QVariant &newValue) -{ - if (parameter.id() == -1) - libvlc_audio_equalizer_set_preamp(m_equalizer, newValue.toFloat()); - else - libvlc_audio_equalizer_set_amp_at_index(m_equalizer, newValue.toFloat(), parameter.id()); -} - -void EqualizerEffect::handleConnectToMediaObject(MediaObject *mediaObject) -{ - m_player->setEqualizer(m_equalizer); -} - -} // namespace VLC -} // namespace Phonon - -#include "phonon-vlc/moc_equalizereffect.h" - -#endif // LIBVLC_VERSION - -#endif // QT_NO_PHONON_EFFECT \ No newline at end of file diff --git a/src/phonon/phonon-vlc/equalizereffect.h b/src/phonon/phonon-vlc/equalizereffect.h deleted file mode 100644 index b6bd37b6e..000000000 --- a/src/phonon/phonon-vlc/equalizereffect.h +++ /dev/null @@ -1,59 +0,0 @@ -/* - Copyright (C) 2013 Harald Sitter - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . -*/ - -#ifndef PHONON_VLC_EQUALIZEREFFECT_H -#define PHONON_VLC_EQUALIZEREFFECT_H - -#ifndef QT_NO_PHONON_EFFECT - -#include - -#include -#include - -#include - -#include "sinknode.h" - -namespace Phonon { -namespace VLC { - -class EqualizerEffect : public QObject, public SinkNode, public EffectInterface -{ - Q_OBJECT - Q_INTERFACES(Phonon::EffectInterface) -public: - explicit EqualizerEffect(QObject *parent = 0); - ~EqualizerEffect(); - - QList parameters() const; - QVariant parameterValue(const EffectParameter ¶meter) const; - void setParameterValue(const EffectParameter ¶meter, const QVariant &newValue); - - void handleConnectToMediaObject(MediaObject *mediaObject); - -private: - libvlc_equalizer_t *m_equalizer; - QList m_bands; -}; - -} // namespace VLC -} // namespace Phonon - -#endif // QT_NO_PHONON_EFFECT - -#endif // PHONON_VLC_EQUALIZEREFFECT_H diff --git a/src/phonon/phonon-vlc/media.cpp b/src/phonon/phonon-vlc/media.cpp deleted file mode 100644 index 19ce47d8c..000000000 --- a/src/phonon/phonon-vlc/media.cpp +++ /dev/null @@ -1,111 +0,0 @@ -/* - Copyright (C) 2011 Harald Sitter - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . -*/ - -#include "media.h" - -#include - -#include - -#include "utils/debug.h" -#include "utils/libvlc.h" -#include "utils/vstring.h" - -namespace Phonon { -namespace VLC { - -Media::Media(const QByteArray &mrl, QObject *parent) : - QObject(parent), - m_media(libvlc_media_new_location(libvlc, mrl.constData())), - m_mrl(mrl) -{ - Q_ASSERT(m_media); - - libvlc_event_manager_t *manager = libvlc_media_event_manager(m_media); - libvlc_event_type_t events[] = { - libvlc_MediaMetaChanged, - libvlc_MediaSubItemAdded, - libvlc_MediaDurationChanged, - libvlc_MediaParsedChanged, - libvlc_MediaFreed, - libvlc_MediaStateChanged - }; - const int eventCount = sizeof(events) / sizeof(*events); - for (int i = 0; i < eventCount; ++i) { - libvlc_event_attach(manager, events[i], event_cb, this); - } -} - -Media::~Media() -{ - if (m_media) { - libvlc_media_release(m_media); - m_media = 0; - } -} - -void Media::addOption(const QString &option) -{ - libvlc_media_add_option_flag(m_media, - option.toUtf8().data(), - libvlc_media_option_trusted); -} - -QString Media::meta(libvlc_meta_t meta) -{ - return VString(libvlc_media_get_meta(m_media, meta)).toQString(); -} - -void Media::event_cb(const libvlc_event_t *event, void *opaque) -{ - Media *that = reinterpret_cast(opaque); - Q_ASSERT(that); - - switch (event->type) { - case libvlc_MediaDurationChanged: - QMetaObject::invokeMethod( - that, "durationChanged", - Qt::QueuedConnection, - Q_ARG(qint64, event->u.media_duration_changed.new_duration)); - break; - case libvlc_MediaMetaChanged: - QMetaObject::invokeMethod( - that, "metaDataChanged", - Qt::QueuedConnection); - break; - case libvlc_MediaSubItemAdded: - case libvlc_MediaParsedChanged: - case libvlc_MediaFreed: - case libvlc_MediaStateChanged: - default: - break; - QString msg = QString("Unknown event: ") + QString(libvlc_event_type_name(event->type)); - Q_ASSERT_X(false, "event_cb", qPrintable(msg)); - break; - } -} - -void Media::setCdTrack(int track) -{ - debug() << "setting CDDA track" << track; - addOption(QLatin1String(":cdda-track="), QVariant(track)); -} - -} // namespace VLC -} // namespace Phonon - -#include "phonon-vlc/moc_media.h" diff --git a/src/phonon/phonon-vlc/media.h b/src/phonon/phonon-vlc/media.h deleted file mode 100644 index 373045c66..000000000 --- a/src/phonon/phonon-vlc/media.h +++ /dev/null @@ -1,77 +0,0 @@ -/* - Copyright (C) 2011 Harald Sitter - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . -*/ - -#ifndef PHONON_VLC_MEDIA_H -#define PHONON_VLC_MEDIA_H - -#include -#include -#include - -#include -#include - -#define INTPTR_PTR(x) reinterpret_cast(x) -#define INTPTR_FUNC(x) reinterpret_cast(&x) - -namespace Phonon { -namespace VLC { - -class Media : public QObject -{ - Q_OBJECT -public: - explicit Media(const QByteArray &mrl, QObject *parent = 0); - ~Media(); - - inline libvlc_media_t *libvlc_media() const { return m_media; } - inline operator libvlc_media_t *() const { return m_media; } - - inline void addOption(const QString &option, const QVariant &argument) - { - addOption(option % argument.toString()); - } - - inline void addOption(const QString &option, intptr_t functionPtr) - { - QString optionWithPtr = option; - optionWithPtr.append(QString::number(static_cast(functionPtr))); - addOption(optionWithPtr); - } - - void addOption(const QString &option); - - QString meta(libvlc_meta_t meta); - - void setCdTrack(int track); - -signals: - void durationChanged(qint64 duration); - void metaDataChanged(); - -private: - static void event_cb(const libvlc_event_t *event, void *opaque); - - libvlc_media_t *m_media; - libvlc_state_t m_state; - QByteArray m_mrl; -}; - -} // namespace VLC -} // namespace Phonon - -#endif // PHONON_VLC_MEDIA_H diff --git a/src/phonon/phonon-vlc/mediacontroller.cpp b/src/phonon/phonon-vlc/mediacontroller.cpp deleted file mode 100644 index 1435bb385..000000000 --- a/src/phonon/phonon-vlc/mediacontroller.cpp +++ /dev/null @@ -1,476 +0,0 @@ -/* - Copyright (C) 2007-2008 Tanguy Krotoff - Copyright (C) 2008 Lukas Durfina - Copyright (C) 2009 Fathi Boudra - Copyright (C) 2009-2011 vlc-phonon AUTHORS - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . -*/ - -#include "mediacontroller.h" - -#include - -#include - -#include "utils/debug.h" -#include "utils/libvlc.h" -#include "mediaplayer.h" - -namespace Phonon { -namespace VLC { - -#ifdef __GNUC__ -#warning titles and chapters not covered by globaldescriptioncontainer!! -#endif - -MediaController::MediaController() - : m_subtitleAutodetect(true) - , m_subtitleEncoding("UTF-8") - , m_subtitleFontChanged(false) - , m_player(0) - , m_refreshTimer(new QTimer(dynamic_cast(this))) - , m_attemptingAutoplay(false) -{ - GlobalSubtitles::instance()->register_(this); - GlobalAudioChannels::instance()->register_(this); - resetMembers(); -} - -MediaController::~MediaController() -{ - GlobalSubtitles::instance()->unregister_(this); - GlobalAudioChannels::instance()->unregister_(this); -} - -bool MediaController::hasInterface(Interface iface) const -{ - switch (iface) { - case AddonInterface::NavigationInterface: - return true; - break; - case AddonInterface::ChapterInterface: - return true; - break; - case AddonInterface::AngleInterface: - return false; - break; - case AddonInterface::TitleInterface: - return true; - break; - case AddonInterface::SubtitleInterface: - return true; - break; - case AddonInterface::AudioChannelInterface: - return true; - break; - } - - warning() << "Interface" << iface << "is not supported by Phonon VLC :("; - return false; -} - -QVariant MediaController::interfaceCall(Interface iface, int i_command, const QList & arguments) -{ - DEBUG_BLOCK; - switch (iface) { - case AddonInterface::ChapterInterface: - switch (static_cast(i_command)) { - case AddonInterface::availableChapters: - return availableChapters(); - case AddonInterface::chapter: - return currentChapter(); - case AddonInterface::setChapter: - if (arguments.isEmpty() || !arguments.first().canConvert(QVariant::Int)) { - error() << Q_FUNC_INFO << "arguments invalid"; - return false; - } - setCurrentChapter(arguments.first().toInt()); - return true; - } - break; - case AddonInterface::TitleInterface: - switch (static_cast(i_command)) { - case AddonInterface::availableTitles: - return availableTitles(); - case AddonInterface::title: - return currentTitle(); - case AddonInterface::setTitle: - if (arguments.isEmpty() || !arguments.first().canConvert(QVariant::Int)) { - error() << Q_FUNC_INFO << "arguments invalid"; - return false; - } - setCurrentTitle(arguments.first().toInt()); - return true; - case AddonInterface::autoplayTitles: - return autoplayTitles(); - case AddonInterface::setAutoplayTitles: - if (arguments.isEmpty() || !arguments.first().canConvert(QVariant::Bool)) { - error() << Q_FUNC_INFO << " arguments invalid"; - return false; - } - setAutoplayTitles(arguments.first().toBool()); - return true; - } - break; - case AddonInterface::AngleInterface: - warning() << "AddonInterface::AngleInterface not supported!"; - break; - case AddonInterface::SubtitleInterface: - switch (static_cast(i_command)) { - case AddonInterface::availableSubtitles: - return QVariant::fromValue(availableSubtitles()); - case AddonInterface::currentSubtitle: - return QVariant::fromValue(currentSubtitle()); - case AddonInterface::setCurrentSubtitle: - if (arguments.isEmpty() || !arguments.first().canConvert()) { - error() << Q_FUNC_INFO << "arguments invalid"; - return false; - } - setCurrentSubtitle(arguments.first().value()); - return true; - case AddonInterface::setCurrentSubtitleFile: - if (arguments.isEmpty() || !arguments.first().canConvert()) { - error() << Q_FUNC_INFO << " arguments invalid"; - return false; - } - setCurrentSubtitleFile(arguments.first().value()); - case AddonInterface::subtitleAutodetect: - return QVariant::fromValue(subtitleAutodetect()); - case AddonInterface::setSubtitleAutodetect: - if (arguments.isEmpty() || !arguments.first().canConvert()) { - error() << Q_FUNC_INFO << " arguments invalid"; - return false; - } - setSubtitleAutodetect(arguments.first().value()); - return true; - case AddonInterface::subtitleEncoding: - return subtitleEncoding(); - case AddonInterface::setSubtitleEncoding: - if (arguments.isEmpty() || !arguments.first().canConvert()) { - error() << Q_FUNC_INFO << " arguments invalid"; - return false; - } - setSubtitleEncoding(arguments.first().value()); - return true; - case AddonInterface::subtitleFont: - return subtitleFont(); - case AddonInterface::setSubtitleFont: - if (arguments.isEmpty() || !arguments.first().canConvert()) { - error() << Q_FUNC_INFO << " arguments invalid"; - return false; - } - setSubtitleFont(arguments.first().value()); - return true; - } - break; - case AddonInterface::AudioChannelInterface: - switch (static_cast(i_command)) { - case AddonInterface::availableAudioChannels: - return QVariant::fromValue(availableAudioChannels()); - case AddonInterface::currentAudioChannel: - return QVariant::fromValue(currentAudioChannel()); - case AddonInterface::setCurrentAudioChannel: - if (arguments.isEmpty() || !arguments.first().canConvert()) { - error() << Q_FUNC_INFO << "arguments invalid"; - return false; - } - setCurrentAudioChannel(arguments.first().value()); - return true; - } - break; - } - - error() << Q_FUNC_INFO << "unsupported AddonInterface::Interface:" << iface; - - return QVariant(); -} - -void MediaController::resetMediaController() -{ - resetMembers(); - emit availableAudioChannelsChanged(); - emit availableSubtitlesChanged(); - emit availableTitlesChanged(0); - emit availableChaptersChanged(0); -} - -void MediaController::resetMembers() -{ - m_currentAudioChannel = Phonon::AudioChannelDescription(); - GlobalAudioChannels::self->clearListFor(this); - - m_currentSubtitle = Phonon::SubtitleDescription(); - GlobalSubtitles::instance()->clearListFor(this); - - m_currentChapter = 0; - m_availableChapters = 0; - - m_currentTitle = 1; - m_availableTitles = 0; - - m_attemptingAutoplay = false; -} - -// ----------------------------- Audio Channel ------------------------------ // -void MediaController::setCurrentAudioChannel(const Phonon::AudioChannelDescription &audioChannel) -{ - const int localIndex = GlobalAudioChannels::instance()->localIdFor(this, audioChannel.index()); - if (!m_player->setAudioTrack(localIndex)) - error() << "libVLC:" << LibVLC::errorMessage(); - else - m_currentAudioChannel = audioChannel; -} - -QList MediaController::availableAudioChannels() const -{ - return GlobalAudioChannels::instance()->listFor(this); -} - -Phonon::AudioChannelDescription MediaController::currentAudioChannel() const -{ - return m_currentAudioChannel; -} - -void MediaController::refreshAudioChannels() -{ - GlobalAudioChannels::instance()->clearListFor(this); - - const int currentChannelId = m_player->subtitle(); - - int idCount = 0; - VLC_FOREACH_TRACK(it, m_player->audioTrackDescription()) { - // LibVLC's internal ID is broken, so we simply count up as internally - // the setter will simply go by position in list anyway. - GlobalAudioChannels::instance()->add(this, idCount, QString::fromUtf8(it->psz_name), ""); - if (idCount == currentChannelId) { -#ifdef __GNUC__ -#warning GlobalDescriptionContainer does not allow reverse resolution from local to descriptor! -#endif - const QList list = GlobalAudioChannels::instance()->listFor(this); - foreach (const AudioChannelDescription &descriptor, list) { - if (descriptor.name() == QString::fromUtf8(it->psz_name)) { - m_currentAudioChannel = descriptor; - } - } - } - ++idCount; - } - - emit availableAudioChannelsChanged(); -} - -// -------------------------------- Subtitle -------------------------------- // -void MediaController::setCurrentSubtitle(const Phonon::SubtitleDescription &subtitle) -{ - DEBUG_BLOCK; - QString type = subtitle.property("type").toString(); - - debug() << subtitle; - - if (type == "file") { - QString filename = subtitle.property("name").toString(); - if (!filename.isEmpty()) { - if (!m_player->setSubtitle(filename)) - error() << "libVLC:" << LibVLC::errorMessage(); - else - m_currentSubtitle = subtitle; - - // There is no subtitle event inside libvlc so let's send our own event... - GlobalSubtitles::instance()->add(this, m_currentSubtitle); - emit availableSubtitlesChanged(); - } - } else { - const int localIndex = GlobalSubtitles::instance()->localIdFor(this, subtitle.index()); - debug () << "localid" << localIndex; - if (!m_player->setSubtitle(localIndex)) - error() << "libVLC:" << LibVLC::errorMessage(); - else - m_currentSubtitle = subtitle; - } -} - -void MediaController::setCurrentSubtitleFile(const QUrl &url) -{ - const QString file = url.toLocalFile(); - if (!m_player->setSubtitle(file)) - error() << "libVLC failed to set subtitle file:" << LibVLC::errorMessage(); - // Unfortunately the addition of SPUs does not trigger an event in the - // VLC mediaplayer, yet the actual addition to the descriptor is async. - // So for the time being our best shot at getting an up-to-date list of SPUs - // is shooting in the dark and hoping we hit something. - // Refresha after 1, 2 and 5 seconds. If we have no updated list after 5 - // seconds we are out of luck. - // https://trac.videolan.org/vlc/ticket/9796 - QObject *mediaObject = dynamic_cast(this); // MediaObject : QObject, MediaController - m_refreshTimer->singleShot(1 * 1000, mediaObject, SLOT(refreshDescriptors())); - m_refreshTimer->singleShot(2 * 1000, mediaObject, SLOT(refreshDescriptors())); - m_refreshTimer->singleShot(5 * 1000, mediaObject, SLOT(refreshDescriptors())); -} - -QList MediaController::availableSubtitles() const -{ - return GlobalSubtitles::instance()->listFor(this); -} - -Phonon::SubtitleDescription MediaController::currentSubtitle() const -{ - return m_currentSubtitle; -} - -void MediaController::refreshSubtitles() -{ - DEBUG_BLOCK; - GlobalSubtitles::instance()->clearListFor(this); - - const int currentSubtitleId = m_player->subtitle(); - - VLC_FOREACH_TRACK(it, m_player->videoSubtitleDescription()) { - debug() << "found subtitle" << it->psz_name << "[" << it->i_id << "]"; - GlobalSubtitles::instance()->add(this, it->i_id, QString::fromUtf8(it->psz_name), ""); - if (it->i_id == currentSubtitleId) { -#ifdef __GNUC__ -#warning GlobalDescriptionContainer does not allow reverse resolution from local to descriptor! -#endif - const QList list = GlobalSubtitles::instance()->listFor(this); - foreach (const SubtitleDescription &descriptor, list) { - if (descriptor.name() == QString::fromUtf8(it->psz_name)) { - m_currentSubtitle = descriptor; - } - } - } - } - - emit availableSubtitlesChanged(); -} - -bool MediaController::subtitleAutodetect() const -{ - return m_subtitleAutodetect; -} - -void MediaController::setSubtitleAutodetect(bool enabled) -{ - m_subtitleAutodetect = enabled; -} - -QString MediaController::subtitleEncoding() const -{ - return m_subtitleEncoding; -} - -void MediaController::setSubtitleEncoding(const QString &encoding) -{ - m_subtitleEncoding = encoding; -} - -QFont MediaController::subtitleFont() const -{ - return m_subtitleFont; -} - -void MediaController::setSubtitleFont(const QFont &font) -{ - m_subtitleFontChanged = true; - m_subtitleFont = font; -} - -// --------------------------------- Title ---------------------------------- // -void MediaController::setCurrentTitle(int title) -{ - DEBUG_BLOCK; - m_currentTitle = title; - - switch (source().discType()) { - case Cd: - m_player->setCdTrack(title); - return; - case Dvd: - case Vcd: - case BluRay: - m_player->setTitle(title); - return; - case NoDisc: - warning() << "Current media source is not a CD, DVD or VCD!"; - return; - } - - warning() << "MediaSource does not support setting of tile in this version of Phonon VLC!" - << "Type is" << source().discType(); -} - -int MediaController::availableTitles() const -{ - return m_availableTitles; -} - -int MediaController::currentTitle() const -{ - return m_currentTitle; -} - -void MediaController::setAutoplayTitles(bool autoplay) -{ - m_autoPlayTitles = autoplay; -} - -bool MediaController::autoplayTitles() const -{ - return m_autoPlayTitles; -} - -void MediaController::refreshTitles() -{ - m_availableTitles = 0; - - VLC_FOREACH_TRACK(it, m_player->titleDescription()) { - ++m_availableTitles; - emit availableTitlesChanged(m_availableTitles); - } -} - -// -------------------------------- Chapter --------------------------------- // -void MediaController::setCurrentChapter(int chapter) -{ - m_currentChapter = chapter; - m_player->setChapter(chapter); -} - -int MediaController::availableChapters() const -{ - return m_availableChapters; -} - -int MediaController::currentChapter() const -{ - return m_currentChapter; -} - -// We need to rebuild available chapters when title is changed -void MediaController::refreshChapters(int title) -{ - m_availableChapters = 0; - - // Get the description of available chapters for specific title - VLC_FOREACH_TRACK(it, m_player->videoChapterDescription(title)) { - ++m_availableChapters; - emit availableChaptersChanged(m_availableChapters); - } -} - -// --------------------------------- Angle ---------------------------------- // -// NOT SUPPORTED IN LIBVLC // - -} // namespace VLC -} // namespace Phonon diff --git a/src/phonon/phonon-vlc/mediacontroller.h b/src/phonon/phonon-vlc/mediacontroller.h deleted file mode 100644 index a6b0561b6..000000000 --- a/src/phonon/phonon-vlc/mediacontroller.h +++ /dev/null @@ -1,156 +0,0 @@ -/* - Copyright (C) 2007-2008 Tanguy Krotoff - Copyright (C) 2008 Lukas Durfina - Copyright (C) 2009 Fathi Boudra - Copyright (C) 2009-2011 vlc-phonon AUTHORS - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . -*/ - -#ifndef PHONON_VLC_MEDIACONTROLLER_H -#define PHONON_VLC_MEDIACONTROLLER_H - -#include -#include -#include - -#include - -class QTimer; - -namespace Phonon { -namespace VLC { - -class MediaPlayer; - -/** - * \brief Interface for AddonInterface. - * - * Provides a bridge between Phonon's AddonInterface and MediaController. - * - * This class cannot inherit from QObject has MediaObject already inherit from QObject. - * This is a Qt limitation: there is no possibility to inherit virtual Qobject :/ - * See http://doc.trolltech.com/qq/qq15-academic.html - * Phonon implementation got the same problem. - * - * \see MediaObject - */ -class MediaController : public AddonInterface -{ -public: - - MediaController(); - virtual ~MediaController(); - - bool hasInterface(Interface iface) const; - - QVariant interfaceCall(Interface iface, int i_command, const QList & arguments = QList()); - - /** - * Overloaded by MediaObject through MediaObjectInterface. - * Access to the media source is necessary to identify the type of the source - * and behave accordingly. - * - * For example setTitle calls need to work on both DVDs and CDs, however - * in libvlc titles and tracks are two different concepts. - */ - virtual MediaSource source() const = 0; - - // MediaController signals - virtual void availableSubtitlesChanged() = 0; - virtual void availableAudioChannelsChanged() = 0; - - virtual void availableChaptersChanged(int) = 0; - virtual void availableTitlesChanged(int) = 0; - - void titleAdded(int id, const QString &name); - void chapterAdded(int titleId, const QString &name); - -protected: - // AudioChannel - void setCurrentAudioChannel(const Phonon::AudioChannelDescription &audioChannel); - QList availableAudioChannels() const; - Phonon::AudioChannelDescription currentAudioChannel() const; - void refreshAudioChannels(); - - // Subtitle - void setCurrentSubtitle(const Phonon::SubtitleDescription &subtitle); - void setCurrentSubtitleFile(const QUrl &url); - QList availableSubtitles() const; - Phonon::SubtitleDescription currentSubtitle() const; - void refreshSubtitles(); - bool subtitleAutodetect() const; - void setSubtitleAutodetect(bool enabled); - QString subtitleEncoding() const; - void setSubtitleEncoding(const QString &encoding); - QFont subtitleFont() const; - void setSubtitleFont(const QFont &font); - - // Chapter - void setCurrentChapter(int chapterNumber); - int availableChapters() const; - int currentChapter() const; - void refreshChapters(int title); - - // Title - void setCurrentTitle(int titleNumber); - int availableTitles() const; - int currentTitle() const; - void setAutoplayTitles(bool autoplay); - bool autoplayTitles() const; - void refreshTitles(); - - /** - * Clear all member variables and emit appropriate signals. - * This is used each time we restart the video. - * - * \see resetMembers - */ - void resetMediaController(); - - /** - * Reset all member variables. - * - * \see resetMediaController - */ - void resetMembers(); - - Phonon::AudioChannelDescription m_currentAudioChannel; - Phonon::SubtitleDescription m_currentSubtitle; - - int m_currentChapter; - int m_availableChapters; - - int m_currentTitle; - int m_availableTitles; - - bool m_autoPlayTitles; - - bool m_subtitleAutodetect; - QString m_subtitleEncoding; - bool m_subtitleFontChanged; - QFont m_subtitleFont; - - // MediaPlayer - MediaPlayer *m_player; - - QTimer *m_refreshTimer; - - bool m_attemptingAutoplay; -}; - -} // namespace VLC -} // namespace Phonon - -#endif // PHONON_VLC_MEDIACONTROLLER_H diff --git a/src/phonon/phonon-vlc/mediaobject.cpp b/src/phonon/phonon-vlc/mediaobject.cpp deleted file mode 100644 index 7df56e231..000000000 --- a/src/phonon/phonon-vlc/mediaobject.cpp +++ /dev/null @@ -1,823 +0,0 @@ -/* - Copyright (C) 2007-2008 Tanguy Krotoff - Copyright (C) 2008 Lukas Durfina - Copyright (C) 2009 Fathi Boudra - Copyright (C) 2010 Ben Cooksley - Copyright (C) 2009-2011 vlc-phonon AUTHORS - Copyright (C) 2010-2015 Harald Sitter - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . -*/ - -#include "mediaobject.h" - -#include -#include -#include - -#include -#include - -#include "utils/debug.h" -#include "utils/libvlc.h" -#include "media.h" -#include "sinknode.h" -#include "streamreader.h" - -//Time in milliseconds before sending aboutToFinish() signal -//2 seconds -static const int ABOUT_TO_FINISH_TIME = 2000; - -namespace Phonon { -namespace VLC { - -MediaObject::MediaObject(QObject *parent) - : QObject(parent) - , m_nextSource(MediaSource(QUrl())) - , m_streamReader(0) - , m_state(Phonon::StoppedState) - , m_tickInterval(0) - , m_transitionTime(0) - , m_media(0) -{ - qRegisterMetaType >("QMultiMap"); - - m_player = new MediaPlayer(this); - if (!m_player->libvlc_media_player()) - error() << "libVLC:" << LibVLC::errorMessage(); - - // Player signals. - connect(m_player, SIGNAL(seekableChanged(bool)), this, SIGNAL(seekableChanged(bool))); - connect(m_player, SIGNAL(timeChanged(qint64)), this, SLOT(timeChanged(qint64))); - connect(m_player, SIGNAL(stateChanged(MediaPlayer::State)), this, SLOT(updateState(MediaPlayer::State))); - connect(m_player, SIGNAL(hasVideoChanged(bool)), this, SLOT(onHasVideoChanged(bool))); - connect(m_player, SIGNAL(bufferChanged(int)), this, SLOT(setBufferStatus(int))); - connect(m_player, SIGNAL(timeChanged(qint64)), this, SLOT(timeChanged(qint64))); - - // Internal Signals. - connect(this, SIGNAL(moveToNext()), SLOT(moveToNextSource())); - connect(m_refreshTimer, SIGNAL(timeout()), this, SLOT(refreshDescriptors())); - - resetMembers(); -} - -MediaObject::~MediaObject() -{ - unloadMedia(); -} - -void MediaObject::resetMembers() -{ - // default to -1, so that streams won't break and to comply with the docs (-1 if unknown) - m_totalTime = -1; - m_hasVideo = false; - m_seekpoint = 0; - - m_prefinishEmitted = false; - m_aboutToFinishEmitted = false; - - m_lastTick = 0; - - m_timesVideoChecked = 0; - - m_buffering = false; - m_stateAfterBuffering = ErrorState; - - resetMediaController(); -} - -void MediaObject::play() -{ - DEBUG_BLOCK; - - switch (m_state) { - case PlayingState: - // Do not do anything if we are already playing (as per documentation). - return; - case PausedState: - m_player->resume(); - break; - default: - setupMedia(); - if (m_player->play()) - error() << "libVLC:" << LibVLC::errorMessage(); - break; - } -} - -void MediaObject::pause() -{ - DEBUG_BLOCK; - switch (m_state) { - case BufferingState: - case PlayingState: - m_player->pause(); - break; - case PausedState: - return; - default: - debug() << "doing paused play"; - setupMedia(); - m_player->pausedPlay(); - break; - } -} - -void MediaObject::stop() -{ - DEBUG_BLOCK; - if (m_streamReader) - m_streamReader->unlock(); - m_nextSource = MediaSource(QUrl()); - m_player->stop(); -} - -void MediaObject::seek(qint64 milliseconds) -{ - DEBUG_BLOCK; - - switch (m_state) { - case PlayingState: - case PausedState: - case BufferingState: - break; - default: - // Seeking while not being in a playingish state is cached for later. - m_seekpoint = milliseconds; - return; - } - - debug() << "seeking" << milliseconds << "msec"; - - m_player->setTime(milliseconds); - - const qint64 time = currentTime(); - const qint64 total = totalTime(); - - // Reset last tick marker so we emit time even after seeking - if (time < m_lastTick) - m_lastTick = time; - if (time < total - m_prefinishMark) - m_prefinishEmitted = false; - if (time < total - ABOUT_TO_FINISH_TIME) - m_aboutToFinishEmitted = false; -} - -void MediaObject::timeChanged(qint64 time) -{ - const qint64 totalTime = m_totalTime; - - switch (m_state) { - case PlayingState: - case BufferingState: - case PausedState: - emitTick(time); - default: - break; - } - - if (m_state == PlayingState || m_state == BufferingState) { // Buffering is concurrent - if (time >= totalTime - m_prefinishMark) { - if (!m_prefinishEmitted) { - m_prefinishEmitted = true; - emit prefinishMarkReached(totalTime - time); - } - } - // Note that when the totalTime is <= 0 we cannot calculate any sane delta. - if (totalTime > 0 && time >= totalTime - ABOUT_TO_FINISH_TIME) - emitAboutToFinish(); - } -} - -void MediaObject::emitTick(qint64 time) -{ - if (m_tickInterval == 0) // Make sure we do not ever emit ticks when deactivated.\] - return; - if (time + m_tickInterval >= m_lastTick) { - m_lastTick = time; - emit tick(time); - } -} - -void MediaObject::loadMedia(const QByteArray &mrl) -{ - DEBUG_BLOCK; - - // Initial state is loading, from which we quickly progress to stopped because - // libvlc does not provide feedback on loading and the media does not get loaded - // until we play it. - // FIXME: libvlc should really allow for this as it can cause unexpected delay - // even though the GUI might indicate that playback should start right away. - changeState(Phonon::LoadingState); - - m_mrl = mrl; - debug() << "loading encoded:" << m_mrl; - - // We do not have a loading state generally speaking, usually the backend - // is exepected to go to loading state and then at some point reach stopped, - // at which point playback can be started. - // See state enum documentation for more information. - changeState(Phonon::StoppedState); -} - -void MediaObject::loadMedia(const QString &mrl) -{ - loadMedia(mrl.toUtf8()); -} - -qint32 MediaObject::tickInterval() const -{ - return m_tickInterval; -} - -/** - * Supports runtime changes. - * If the user goes to tick(0) we stop the timer, otherwise we fire it up. - */ -void MediaObject::setTickInterval(qint32 interval) -{ - m_tickInterval = interval; -} - -qint64 MediaObject::currentTime() const -{ - qint64 time = -1; - - switch (state()) { - case Phonon::PausedState: - case Phonon::BufferingState: - case Phonon::PlayingState: - time = m_player->time(); - break; - case Phonon::StoppedState: - case Phonon::LoadingState: - time = 0; - break; - case Phonon::ErrorState: - time = -1; - break; - } - - return time; -} - -Phonon::State MediaObject::state() const -{ - return m_state; -} - -Phonon::ErrorType MediaObject::errorType() const -{ - return Phonon::NormalError; -} - -MediaSource MediaObject::source() const -{ - return m_mediaSource; -} - -void MediaObject::setSource(const MediaSource &source) -{ - DEBUG_BLOCK; - - // Reset previous streamereaders - if (m_streamReader) { - m_streamReader->unlock(); - delete m_streamReader; - m_streamReader = 0; - // For streamreaders we exchanage the player's seekability with the - // reader's so here we change it back. - // Note: the reader auto-disconnects due to destruction. - connect(m_player, SIGNAL(seekableChanged(bool)), this, SIGNAL(seekableChanged(bool))); - } - - // Reset previous isScreen flag - m_isScreen = false; - - m_mediaSource = source; - - QByteArray url; - switch (source.type()) { - case MediaSource::Invalid: - error() << Q_FUNC_INFO << "MediaSource Type is Invalid:" << source.type(); - break; - case MediaSource::Empty: - error() << Q_FUNC_INFO << "MediaSource is empty."; - break; - case MediaSource::LocalFile: - case MediaSource::Url: - debug() << "MediaSource::Url:" << source.url(); - if (source.url().scheme().isEmpty()) { - url = "file://"; - // QUrl considers url.scheme.isEmpty() == url.isRelative(), - // so to be sure the url is not actually absolute we just - // check the first character - if (!source.url().toString().startsWith('/')) - url.append(QFile::encodeName(QDir::currentPath()) + '/'); - } - url += source.url().toEncoded(); - loadMedia(url); - break; - case MediaSource::Disc: - switch (source.discType()) { - case Phonon::NoDisc: - error() << Q_FUNC_INFO << "the MediaSource::Disc doesn't specify which one (Phonon::NoDisc)"; - return; - case Phonon::Cd: - loadMedia(QLatin1Literal("cdda://") % m_mediaSource.deviceName()); - break; - case Phonon::Dvd: - loadMedia(QLatin1Literal("dvd://") % m_mediaSource.deviceName()); - break; - case Phonon::Vcd: - loadMedia(QLatin1Literal("vcd://") % m_mediaSource.deviceName()); - break; - case Phonon::BluRay: - loadMedia(QLatin1Literal("bluray://") % m_mediaSource.deviceName()); - break; - } - break; - case MediaSource::CaptureDevice: { - QByteArray driverName; - QString deviceName; - - if (source.deviceAccessList().isEmpty()) { - error() << Q_FUNC_INFO << "No device access list for this capture device"; - break; - } - - // TODO try every device in the access list until it works, not just the first one - driverName = source.deviceAccessList().first().first; - deviceName = source.deviceAccessList().first().second; - - if (driverName == QByteArray("v4l2")) { - loadMedia(QLatin1Literal("v4l2://") % deviceName); - } else if (driverName == QByteArray("alsa")) { - /* - * Replace "default" and "plughw" and "x-phonon" with "hw" for capture device names, because - * VLC does not want to open them when using default instead of hw. - * plughw also does not work. - * - * TODO investigate what happens - */ - if (deviceName.startsWith(QLatin1String("default"))) { - deviceName.replace(0, 7, "hw"); - } - if (deviceName.startsWith(QLatin1String("plughw"))) { - deviceName.replace(0, 6, "hw"); - } - if (deviceName.startsWith(QLatin1String("x-phonon"))) { - deviceName.replace(0, 8, "hw"); - } - - loadMedia(QLatin1Literal("alsa://") % deviceName); - } else if (driverName == "screen") { - loadMedia(QLatin1Literal("screen://") % deviceName); - - // Set the isScreen flag needed to add extra options in playInternal - m_isScreen = true; - } else { - error() << Q_FUNC_INFO << "Unsupported MediaSource::CaptureDevice:" << driverName; - break; - } - break; - } - case MediaSource::Stream: - m_streamReader = new StreamReader(this); - // LibVLC refuses to emit seekability as it does a try-and-seek approach - // to work around this we exchange the player's seekability signal - // for the readers - // https://bugs.kde.org/show_bug.cgi?id=293012 - connect(m_streamReader, SIGNAL(streamSeekableChanged(bool)), this, SIGNAL(seekableChanged(bool))); - disconnect(m_player, SIGNAL(seekableChanged(bool)), this, SIGNAL(seekableChanged(bool))); - // Only connect now to avoid seekability detection before we are connected. - m_streamReader->connectToSource(source); - loadMedia(QByteArray("imem://")); - break; - } - - debug() << "Sending currentSourceChanged"; - emit currentSourceChanged(m_mediaSource); -} - -void MediaObject::setNextSource(const MediaSource &source) -{ - DEBUG_BLOCK; - debug() << source.url(); - m_nextSource = source; - // This function is not ever called by the consumer but only libphonon. - // Furthermore libphonon only calls this function in its aboutToFinish slot, - // iff sources are already in the queue. In case our aboutToFinish was too - // late we may already be stopped when the slot gets activated. - // Therefore we need to make sure that we move to the next source iff - // this function is called when we are in stoppedstate. - if (m_state == StoppedState) - moveToNext(); -} - -qint32 MediaObject::prefinishMark() const -{ - return m_prefinishMark; -} - -void MediaObject::setPrefinishMark(qint32 msecToEnd) -{ - m_prefinishMark = msecToEnd; - if (currentTime() < totalTime() - m_prefinishMark) { - // Not about to finish - m_prefinishEmitted = false; - } -} - -qint32 MediaObject::transitionTime() const -{ - return m_transitionTime; -} - -void MediaObject::setTransitionTime(qint32 time) -{ - m_transitionTime = time; -} - -void MediaObject::emitAboutToFinish() -{ - if (!m_aboutToFinishEmitted) { - // Track is about to finish - m_aboutToFinishEmitted = true; - emit aboutToFinish(); - } -} - -// State changes are force queued by libphonon. -void MediaObject::changeState(Phonon::State newState) -{ - DEBUG_BLOCK; - - // State not changed - if (newState == m_state) - return; - - debug() << m_state << "-->" << newState; - -#ifdef __GNUC__ -#warning do we actually need m_seekpoint? if a consumer seeks before playing state that is their problem?! -#endif - // Workaround that seeking needs to work before the file is being played... - // We store seeks and apply them when going to seek (or discard them on reset). - if (newState == PlayingState) { - if (m_seekpoint != 0) { - seek(m_seekpoint); - m_seekpoint = 0; - } - } - - // State changed - Phonon::State previousState = m_state; - m_state = newState; - emit stateChanged(m_state, previousState); -} - -void MediaObject::moveToNextSource() -{ - DEBUG_BLOCK; - - setSource(m_nextSource); - - // The consumer may set an invalid source as final source to force a - // queued stop, regardless of how fast the consumer is at actually calling - // stop. Such a source must not cause an actual move (moving ~= state - // changes towards playing) but instead we only set the source to reflect - // that we got the setNextSource call. - if (hasNextTrack()) - play(); - - m_nextSource = MediaSource(QUrl()); -} - -inline bool MediaObject::hasNextTrack() -{ - return m_nextSource.type() != MediaSource::Invalid && m_nextSource.type() != MediaSource::Empty; -} - -inline void MediaObject::unloadMedia() -{ - if (m_media) { - m_media->disconnect(this); - m_media->deleteLater(); - m_media = 0; - } -} - -void MediaObject::setupMedia() -{ - DEBUG_BLOCK; - - unloadMedia(); - resetMembers(); - - // Create a media with the given MRL - m_media = new Media(m_mrl, this); - if (!m_media) - error() << "libVLC:" << LibVLC::errorMessage(); - - if (m_isScreen) { - m_media->addOption(QLatin1String("screen-fps=24.0")); - m_media->addOption(QLatin1String("screen-caching=300")); - } - - if (source().discType() == Cd && m_currentTitle > 0) - m_media->setCdTrack(m_currentTitle); - - if (m_streamReader) - // StreamReader is no sink but a source, for this we have no concept right now - // also we do not need one since the reader is the only source we have. - // Consequently we need to manually tell the StreamReader to attach to the Media. - m_streamReader->addToMedia(m_media); - - if (!m_subtitleAutodetect) - m_media->addOption(QLatin1String(":no-sub-autodetect-file")); - - if (m_subtitleEncoding != QLatin1String("UTF-8")) // utf8 is phonon default, so let vlc handle it - m_media->addOption(QLatin1String(":subsdec-encoding="), m_subtitleEncoding); - - if (!m_subtitleFontChanged) // Update font settings - m_subtitleFont = QFont(); - -#ifdef __GNUC__ -#warning freetype module is not working as expected - font api not working -#endif - // BUG: VLC's freetype module doesn't pick up per-media options - // vlc -vvvv --freetype-font="Comic Sans MS" multiple_sub_sample.mkv :freetype-font=Arial - // https://trac.videolan.org/vlc/ticket/9797 - m_media->addOption(QLatin1String(":freetype-font="), m_subtitleFont.family()); - m_media->addOption(QLatin1String(":freetype-fontsize="), m_subtitleFont.pointSize()); - if (m_subtitleFont.bold()) - m_media->addOption(QLatin1String(":freetype-bold")); - else - m_media->addOption(QLatin1String(":no-freetype-bold")); - - foreach (SinkNode *sink, m_sinks) { - sink->addToMedia(m_media); - } - - // Connect to Media signals. Disconnection is done at unloading. - connect(m_media, SIGNAL(durationChanged(qint64)), - this, SLOT(updateDuration(qint64))); - connect(m_media, SIGNAL(metaDataChanged()), - this, SLOT(updateMetaData())); - - // Update available audio channels/subtitles/angles/chapters/etc... - // i.e everything from MediaController - // There is no audio channel/subtitle/angle/chapter events inside libvlc - // so let's send our own events... - // This will reset the GUI - resetMediaController(); - - // Play - m_player->setMedia(m_media); -} - -QString MediaObject::errorString() const -{ - return libvlc_errmsg(); -} - -bool MediaObject::hasVideo() const -{ - return m_player->hasVideoOutput(); -} - -bool MediaObject::isSeekable() const -{ - if (m_streamReader) - return m_streamReader->streamSeekable(); - return m_player->isSeekable(); -} - -void MediaObject::updateDuration(qint64 newDuration) -{ - // This here cache is needed because we need to provide -1 as totalTime() - // for as long as we do not get a proper update through this slot. - // VLC reports -1 with no media but 0 if it does not know the duration, so - // apps that assume 0 = unknown get screwed if they query too early. - // http://bugs.tomahawk-player.org/browse/TWK-1029 - m_totalTime = newDuration; - emit totalTimeChanged(m_totalTime); -} - -void MediaObject::updateMetaData() -{ - QMultiMap metaDataMap; - - const QString artist = m_media->meta(libvlc_meta_Artist); - const QString title = m_media->meta(libvlc_meta_Title); - const QString nowPlaying = m_media->meta(libvlc_meta_NowPlaying); - - // Streams sometimes have the artist and title munged in nowplaying. - // With ALBUM = Title and TITLE = NowPlaying it will still show up nicely in Amarok. - if (artist.isEmpty() && !nowPlaying.isEmpty()) { - metaDataMap.insert(QLatin1String("ALBUM"), title); - metaDataMap.insert(QLatin1String("TITLE"), nowPlaying); - } else { - metaDataMap.insert(QLatin1String("ALBUM"), m_media->meta(libvlc_meta_Album)); - metaDataMap.insert(QLatin1String("TITLE"), title); - } - - metaDataMap.insert(QLatin1String("ARTIST"), artist); - metaDataMap.insert(QLatin1String("DATE"), m_media->meta(libvlc_meta_Date)); - metaDataMap.insert(QLatin1String("GENRE"), m_media->meta(libvlc_meta_Genre)); - metaDataMap.insert(QLatin1String("TRACKNUMBER"), m_media->meta(libvlc_meta_TrackNumber)); - metaDataMap.insert(QLatin1String("DESCRIPTION"), m_media->meta(libvlc_meta_Description)); - metaDataMap.insert(QLatin1String("COPYRIGHT"), m_media->meta(libvlc_meta_Copyright)); - metaDataMap.insert(QLatin1String("URL"), m_media->meta(libvlc_meta_URL)); - metaDataMap.insert(QLatin1String("ENCODEDBY"), m_media->meta(libvlc_meta_EncodedBy)); - - if (metaDataMap == m_vlcMetaData) { - // No need to issue any change, the data is the same - return; - } - m_vlcMetaData = metaDataMap; - - emit metaDataChanged(metaDataMap); -} - -void MediaObject::updateState(MediaPlayer::State state) -{ - DEBUG_BLOCK; - debug() << state; - debug() << "attempted autoplay?" << m_attemptingAutoplay; - - if (m_attemptingAutoplay) { - switch (state) { - case MediaPlayer::PlayingState: - case MediaPlayer::PausedState: - m_attemptingAutoplay = false; - break; - case MediaPlayer::ErrorState: - debug() << "autoplay failed, must be end of media."; - // The error should not be reflected to the consumer. So we swap it - // for finished() which is actually what is happening here. - // Or so we think ;) - state = MediaPlayer::EndedState; - --m_currentTitle; - break; - default: - debug() << "not handling as part of autplay:" << state; - break; - } - } - - switch (state) { - case MediaPlayer::NoState: - changeState(LoadingState); - break; - case MediaPlayer::OpeningState: - changeState(LoadingState); - break; - case MediaPlayer::BufferingState: - changeState(BufferingState); - break; - case MediaPlayer::PlayingState: - changeState(PlayingState); - break; - case MediaPlayer::PausedState: - changeState(PausedState); - break; - case MediaPlayer::StoppedState: - changeState(StoppedState); - break; - case MediaPlayer::EndedState: - if (hasNextTrack()) { - moveToNextSource(); - } else if (source().discType() == Cd && m_autoPlayTitles && !m_attemptingAutoplay) { - debug() << "trying to simulate autoplay"; - m_attemptingAutoplay = true; - m_player->setCdTrack(++m_currentTitle); - } else { - m_attemptingAutoplay = false; - emitAboutToFinish(); - emit finished(); - changeState(StoppedState); - } - break; - case MediaPlayer::ErrorState: - debug() << errorString(); - emitAboutToFinish(); - emit finished(); - changeState(ErrorState); - break; - } - - if (m_buffering) { - switch (state) { - case MediaPlayer::BufferingState: - break; - case MediaPlayer::PlayingState: - debug() << "Restoring buffering state after state change to Playing"; - changeState(BufferingState); - m_stateAfterBuffering = PlayingState; - break; - case MediaPlayer::PausedState: - debug() << "Restoring buffering state after state change to Paused"; - changeState(BufferingState); - m_stateAfterBuffering = PausedState; - break; - default: - debug() << "Buffering aborted!"; - m_buffering = false; - break; - } - } - - return; -} - -void MediaObject::onHasVideoChanged(bool hasVideo) -{ - DEBUG_BLOCK; - if (m_hasVideo != hasVideo) { - m_hasVideo = hasVideo; - emit hasVideoChanged(m_hasVideo); - } else - // We can simply return if we are have the appropriate caching already. - // Otherwise we'd do pointless rescans of mediacontroller stuff. - // MC and MO are force-reset on media changes anyway. - return; - - refreshDescriptors(); -} - -void MediaObject::setBufferStatus(int percent) -{ - // VLC does not have a buffering state (surprise!) but instead only sends the - // event (surprise!). Hence we need to simulate the state change. - // Problem with BufferingState is that it is actually concurrent to Playing or Paused - // meaning that while you are buffering you can also pause, thus triggering - // a state change to paused. To handle this we let updateState change the - // state accordingly (as we need to allow the UI to update itself, and - // immediately after that we change back to buffering again. - // This loop can only be interrupted by a state change to !Playing & !Paused - // or by reaching a 100 % buffer caching (i.e. full cache). - - m_buffering = true; - if (m_state != BufferingState) { - m_stateAfterBuffering = m_state; - changeState(BufferingState); - } - - emit bufferStatus(percent); - - // Transit to actual state only after emission so the signal is still - // delivered while in BufferingState. - if (percent >= 100) { // http://trac.videolan.org/vlc/ticket/5277 - m_buffering = false; - changeState(m_stateAfterBuffering); - } -} - -void MediaObject::refreshDescriptors() -{ - if (m_player->titleCount() > 0) - refreshTitles(); - - if (hasVideo()) { - refreshAudioChannels(); - refreshSubtitles(); - - if (m_player->videoChapterCount() > 0) - refreshChapters(m_player->title()); - } -} - -qint64 MediaObject::totalTime() const -{ - return m_totalTime; -} - -void MediaObject::addSink(SinkNode *node) -{ - Q_ASSERT(!m_sinks.contains(node)); - m_sinks.append(node); -} - -void MediaObject::removeSink(SinkNode *node) -{ - Q_ASSERT(node); - m_sinks.removeAll(node); -} - -} // namespace VLC -} // namespace Phonon - -#include "phonon-vlc/moc_mediaobject.h" diff --git a/src/phonon/phonon-vlc/mediaobject.h b/src/phonon/phonon-vlc/mediaobject.h deleted file mode 100644 index 8033113d3..000000000 --- a/src/phonon/phonon-vlc/mediaobject.h +++ /dev/null @@ -1,347 +0,0 @@ -/* - Copyright (C) 2007-2008 Tanguy Krotoff - Copyright (C) 2008 Lukas Durfina - Copyright (C) 2009 Fathi Boudra - Copyright (C) 2009-2011 vlc-phonon AUTHORS - Copyright (C) 2010-2011 Harald Sitter - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . -*/ - -#ifndef PHONON_VLC_MEDIAOBJECT_H -#define PHONON_VLC_MEDIAOBJECT_H - -#include -#include - -#include -#include - -#include "mediacontroller.h" -#include "mediaplayer.h" - -namespace Phonon -{ -namespace VLC -{ - -class Media; -class SinkNode; -class StreamReader; - -/** \brief Implementation for the most important class in Phonon - * - * The MediaObject class is the workhorse for Phonon. It handles what is needed - * to play media. It has a media source object used to configure what media to - * play. - * - * It provides the essential methods setSource(), play(), seek() and additional - * methods to configure the next media source, the transition between sources, - * transition times, ticks, other. - * - * There are numerous signals that provide information about the state of the media - * and of the playing process. The aboutToFinish() and finished() signals are used - * to see when the current media is finished. - * - * This class does not contain methods directly involved with libVLC. This part is - * handled by the VLCMediaObject class. There are protected methods and slots - * inherited by that class, like playInternal(), seekInternal(). - * These methods have no implementation here. - * - * For documentation regarding the methods implemented for MediaObjectInterface, see - * the Phonon documentation. - * - * \see Phonon::MediaObjectInterface - * \see VLCMediaObject - */ -class MediaObject : public QObject, public MediaObjectInterface, public MediaController -{ - Q_OBJECT - Q_INTERFACES(Phonon::MediaObjectInterface Phonon::AddonInterface) - friend class SinkNode; - -public: - /** - * Initializes the members, connects the private slots to their corresponding signals, - * sets the next media source to an empty media source. - * - * \param parent A parent for the QObject - */ - explicit MediaObject(QObject *parent); - ~MediaObject(); - - /** - * Reset members (those that need resetting anyway). - * Should always be called before going to a new source. - */ - void resetMembers(); - - /** - * If the current state is paused, it resumes playing. Else, the playback - * is commenced. - */ - void play(); - - /// Pauses the playback for the media player. - void pause(); - - /// Sets the next media source to an empty one and stops playback. - void stop(); - - /// \returns \c true when there is a video available, \c false otherwise - bool hasVideo() const; - - /// \returns \c true when the MediaObject is seekable, \c false otherwise - bool isSeekable() const; - - /// \returns total time (length, duration) of the current MediaSource (-1 if unknown) - qint64 totalTime() const; - - /// \returns An error message with the last libVLC error. - QString errorString() const; - - /** - * Adds a sink for this media object. During playInternal(), all the sinks - * will have their addToMedia() called. - * - * \see playInternal() - * \see SinkNode::addToMedia() - */ - void addSink(SinkNode *node); - - /// Removes a sink from this media object. - void removeSink(SinkNode *node); - - /** - * Pushes a seek command to the SeekStack for this media object. The SeekStack then - * calls seekInternal() when it's popped. - */ - void seek(qint64 milliseconds); - - /** - * \return The interval between successive tick() signals. If set to 0, the emission - * of these signals is disabled. - */ - qint32 tickInterval() const; - - /** - * Sets the interval between successive tick() signals. If set to 0, it disables the - * emission of these signals. - */ - void setTickInterval(qint32 tickInterval); - - /** - * \return The current time of the media, depending on the current state. - * If the current state is stopped or loading, 0 is returned. - * If the current state is error or unknown, -1 is returned. - */ - qint64 currentTime() const; - - /// \return The current state for this media object. - Phonon::State state() const; - - /// All errors are categorized as normal errors. - Phonon::ErrorType errorType() const; - - /// \return The current media source for this media object. - MediaSource source() const; - - /** - * Sets the current media source for this media object. Depending on the source type, - * the media object loads the specified media. The MRL is passed to loadMedia(), if the media - * is not a stream. The currentSourceChanged() signal - * is emitted. - * - * Supported media source types: - * \li local files - * \li URL - * \li discs (CD, DVD, VCD) - * \li capture devices (V4L) - * \li streams - * - * \param source The media source that will become the current source. - * - * \see loadMedia() - */ - void setSource(const MediaSource &source); - - /// Sets the media source that will replace the current one, after the playback for it finishes. - void setNextSource(const MediaSource &source); - - qint32 prefinishMark() const; - void setPrefinishMark(qint32 msecToEnd); - - qint32 transitionTime() const; - void setTransitionTime(qint32); - - void emitAboutToFinish(); - -signals: - // MediaController signals - void availableSubtitlesChanged(); - void availableAudioChannelsChanged(); - - void availableChaptersChanged(int); - void availableTitlesChanged(int); - - void chapterChanged(int chapterNumber); - void titleChanged(int titleNumber); - void durationChanged(qint64 newDuration); - - /** - * New widget size computed by VLC. - * - * It should be applied to the widget that contains the VLC video. - */ - void videoWidgetSizeChanged(int i_width, int i_height); - - void aboutToFinish(); - void bufferStatus(int percentFilled); - void currentSourceChanged(const MediaSource &newSource); - void finished(); - void hasVideoChanged(bool b_has_video); - void metaDataChanged(const QMultiMap & metaData); - void prefinishMarkReached(qint32 msecToEnd); - void seekableChanged(bool seekable); - void stateChanged(Phonon::State newState, Phonon::State oldState); - void tick(qint64 time); - void totalTimeChanged(qint64 newTotalTime); - - void moveToNext(); - -private slots: - /** - * If the new state is different from the current state, the current state is - * changed and the corresponding signal is emitted. - */ - void changeState(Phonon::State newState); - - /** - * Checks when the tick(), prefinishMarkReached(), aboutToFinish() signals need to - * be emitted and emits them if necessary. - * - * \param currentTime The current play time for the media, in miliseconds. - */ - void timeChanged(qint64 time); - void emitTick(qint64 time); - - /** - * If the next media source is valid, the current source is replaced and playback is commenced. - * The next source is set to an empty source. - * - * \see setNextSource() - */ - void moveToNextSource(); - - /*** Update media duration time - see comment in CPP */ - void updateDuration(qint64 newDuration); - - /** Retrieve meta data of a file (i.e ARTIST, TITLE, ALBUM, etc...). */ - void updateMetaData(); - void updateState(MediaPlayer::State state); - - /** Called when the availability of video output changed */ - void onHasVideoChanged(bool hasVideo); - - void setBufferStatus(int percent); - - /** Refreshes all MediaController descriptors if Video is present. */ - void refreshDescriptors(); - -private: - /** - * This method actually calls the functions needed to begin playing the media. - * If another media is already playing, it is discarded. The new media filename is set - * with loadMediaInternal(). A new VLC Media is created and set into the VLC Media Player. - * All the connected sink nodes are connected to the new media. It connects the media object - * to the events for the VLC Media, updates the meta-data, sets up the video widget id, and - * starts playing. - * - * \see loadMediaInternal() - * \see connectToMediaVLCEvents() - * \see updateMetaData() - * \see setVLCWidgetId() - */ - void setupMedia(); - - /** - * Seeks to the required position. If the state is not playing, the seek position is remembered. - */ - void seekInternal(qint64 milliseconds); - - bool hasNextTrack(); - - /** - * Changes the current state to buffering and sets the new current file. - * - * \param filename The MRL of the media source - */ - void loadMedia(const QByteArray &mrl); - - /** - * Overload for loadMedia, converting a QString to a QByteArray. - * - * \param filename The MRL of the media source - * - * \see loadMedia - */ - void loadMedia(const QString &mrl); - - /** - * Uninitializes the media - */ - void unloadMedia(); - - MediaSource m_nextSource; - - MediaSource m_mediaSource; - StreamReader *m_streamReader; - Phonon::State m_state; - - qint32 m_prefinishMark; - bool m_prefinishEmitted; - - bool m_aboutToFinishEmitted; - - qint32 m_tickInterval; - qint64 m_lastTick; - qint32 m_transitionTime; - - Media *m_media; - - qint64 m_totalTime; - QByteArray m_mrl; - QMultiMap m_vlcMetaData; - QList m_sinks; - - bool m_hasVideo; - bool m_isScreen; - - /** - * Workaround for being able to seek before VLC goes to playing state. - * Seeks before playing are stored in this var, and processed on state change - * to Playing. - */ - qint64 m_seekpoint; - - int m_timesVideoChecked; - - bool m_buffering; - Phonon::State m_stateAfterBuffering; -}; - -} // namespace VLC -} // namespace Phonon - -#endif // PHONON_VLC_MEDIAOBJECT_H diff --git a/src/phonon/phonon-vlc/mediaplayer.cpp b/src/phonon/phonon-vlc/mediaplayer.cpp deleted file mode 100644 index 8bd20d24a..000000000 --- a/src/phonon/phonon-vlc/mediaplayer.cpp +++ /dev/null @@ -1,397 +0,0 @@ -/* - Copyright (C) 2011-2015 Harald Sitter - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . -*/ - -#include "mediaplayer.h" - -#include -#include -#include -#include -#include -#include - -#include - -#include "utils/libvlc.h" -#include "media.h" - -// Callbacks come from a VLC thread. In some cases Qt fails to detect this and -// tries to invoke directly (i.e. from same thread). This can lead to thread -// pollution throughout Phonon, which is very much not desired. -#define P_EMIT_HAS_VIDEO(hasVideo) \ - QMetaObject::invokeMethod(\ - that, "hasVideoChanged", \ - Qt::QueuedConnection, \ - Q_ARG(bool, hasVideo)) - -#define P_EMIT_STATE(__state) \ - QMetaObject::invokeMethod(\ - that, "stateChanged", \ - Qt::QueuedConnection, \ - Q_ARG(MediaPlayer::State, __state)) - -namespace Phonon { -namespace VLC { - -MediaPlayer::MediaPlayer(QObject *parent) - : QObject(parent) - , m_media(0) - , m_player(libvlc_media_player_new(libvlc)) - , m_doingPausedPlay(false) - , m_volume(75) - , m_fadeAmount(1.0f) -{ - Q_ASSERT(m_player); - - qRegisterMetaType("MediaPlayer::State"); - - libvlc_event_manager_t *manager = libvlc_media_player_event_manager(m_player); - libvlc_event_type_t events[] = { - libvlc_MediaPlayerMediaChanged, - libvlc_MediaPlayerNothingSpecial, - libvlc_MediaPlayerOpening, - libvlc_MediaPlayerBuffering, - libvlc_MediaPlayerPlaying, - libvlc_MediaPlayerPaused, - libvlc_MediaPlayerStopped, - libvlc_MediaPlayerForward, - libvlc_MediaPlayerBackward, - libvlc_MediaPlayerEndReached, - libvlc_MediaPlayerEncounteredError, - libvlc_MediaPlayerTimeChanged, - libvlc_MediaPlayerPositionChanged, - libvlc_MediaPlayerSeekableChanged, - libvlc_MediaPlayerPausableChanged, - libvlc_MediaPlayerTitleChanged, - libvlc_MediaPlayerSnapshotTaken, - libvlc_MediaPlayerLengthChanged, - libvlc_MediaPlayerVout - #if (LIBVLC_VERSION_INT >= LIBVLC_VERSION(2, 2, 2, 0)) - , libvlc_MediaPlayerCorked, - libvlc_MediaPlayerUncorked, - libvlc_MediaPlayerMuted, - libvlc_MediaPlayerUnmuted, - libvlc_MediaPlayerAudioVolume - #endif - }; - const int eventCount = sizeof(events) / sizeof(*events); - for (int i = 0; i < eventCount; ++i) { - libvlc_event_attach(manager, events[i], event_cb, this); - } - - // Deactivate video title overlay (i.e. name of the video displaying - // at start. Since 2.1 that is handled via the API which in general is more - // reliable than setting it via libvlc_new (or so I have been told....) - libvlc_media_player_set_video_title_display(m_player, libvlc_position_disable, 0); -} - -MediaPlayer::~MediaPlayer() -{ - libvlc_media_player_release(m_player); -} - -void MediaPlayer::setMedia(Media *media) -{ - m_media = media; - libvlc_media_player_set_media(m_player, *m_media); -} - -bool MediaPlayer::play() -{ - m_doingPausedPlay = false; - return libvlc_media_player_play(m_player) == 0; -} - -void MediaPlayer::pause() -{ - m_doingPausedPlay = false; - libvlc_media_player_set_pause(m_player, 1); -} - -void MediaPlayer::pausedPlay() -{ - m_doingPausedPlay = true; - libvlc_media_player_play(m_player); -} - -void MediaPlayer::resume() -{ - m_doingPausedPlay = false; - libvlc_media_player_set_pause(m_player, 0); -} - -void MediaPlayer::togglePause() -{ - libvlc_media_player_pause(m_player); -} - -void MediaPlayer::stop() -{ - m_doingPausedPlay = false; - libvlc_media_player_stop(m_player); -} - -qint64 MediaPlayer::length() const -{ - return libvlc_media_player_get_length(m_player); -} - -qint64 MediaPlayer::time() const -{ - return libvlc_media_player_get_time(m_player); -} - -void MediaPlayer::setTime(qint64 newTime) -{ - libvlc_media_player_set_time(m_player, newTime); -} - -bool MediaPlayer::isSeekable() const -{ - return libvlc_media_player_is_seekable(m_player); -} - -bool MediaPlayer::hasVideoOutput() const -{ - return libvlc_media_player_has_vout(m_player) > 0; -} - -bool MediaPlayer::setSubtitle(int subtitle) -{ - return libvlc_video_set_spu(m_player, subtitle) == 0; -} - -bool MediaPlayer::setSubtitle(const QString &file) -{ - return libvlc_video_set_subtitle_file(m_player, file.toUtf8().data()) == 1; -} - -void MediaPlayer::setTitle(int title) -{ - libvlc_media_player_set_title(m_player, title); -} - -void MediaPlayer::setChapter(int chapter) -{ - libvlc_media_player_set_chapter(m_player, chapter); -} - -QImage MediaPlayer::snapshot() const -{ - QTemporaryFile tempFile(QDir::tempPath() % QDir::separator() % QLatin1Literal("phonon-vlc-snapshot")); - tempFile.open(); - - // This function is sync. - if (libvlc_video_take_snapshot(m_player, 0, tempFile.fileName().toLocal8Bit().data(), 0, 0) != 0) - return QImage(); - - return QImage(tempFile.fileName()); -} - -bool MediaPlayer::setAudioTrack(int track) -{ - return libvlc_audio_set_track(m_player, track) == 0; -} - -void MediaPlayer::event_cb(const libvlc_event_t *event, void *opaque) -{ - MediaPlayer *that = reinterpret_cast(opaque); - Q_ASSERT(that); - - // Do not forget to register for the events you want to handle here! - switch (event->type) { - case libvlc_MediaPlayerTimeChanged: - QMetaObject::invokeMethod( - that, "timeChanged", - Qt::QueuedConnection, - Q_ARG(qint64, event->u.media_player_time_changed.new_time)); - break; - case libvlc_MediaPlayerSeekableChanged: - QMetaObject::invokeMethod( - that, "seekableChanged", - Qt::QueuedConnection, - Q_ARG(bool, event->u.media_player_seekable_changed.new_seekable)); - break; - case libvlc_MediaPlayerLengthChanged: - QMetaObject::invokeMethod( - that, "lengthChanged", - Qt::QueuedConnection, - Q_ARG(qint64, event->u.media_player_length_changed.new_length)); - break; - case libvlc_MediaPlayerNothingSpecial: - P_EMIT_STATE(NoState); - break; - case libvlc_MediaPlayerOpening: - P_EMIT_STATE(OpeningState); - break; - case libvlc_MediaPlayerBuffering: - QMetaObject::invokeMethod( - that, "bufferChanged", - Qt::QueuedConnection, - Q_ARG(int, event->u.media_player_buffering.new_cache)); - break; - case libvlc_MediaPlayerPlaying: - // Intercept state change and apply pausing once playing. - if (that->m_doingPausedPlay) { - that->m_doingPausedPlay = false; - // VLC internally will call stop if a player can not be paused, this - // can lead to deadlocks as stop is partially blocking, to avoid this - // we explicitly do a queued stop whenever a player can not be paused. - // In those situations pausedplay capability can not be provided, so - // applications wanting to do pausedplay will need to handle it anyway - // as faking a paused state when there is none would be a very code - // intense workaround asking for weird abstraction leakage. - // See kde bug 337604. - if (libvlc_media_player_can_pause(that->m_player)) { - that->pause(); - } else { - QMetaObject::invokeMethod(that, "stop", Qt::QueuedConnection); - } - } else - P_EMIT_STATE(PlayingState); - break; - case libvlc_MediaPlayerPaused: - P_EMIT_STATE(PausedState); - break; - case libvlc_MediaPlayerStopped: - P_EMIT_STATE(StoppedState); - break; - case libvlc_MediaPlayerEndReached: - P_EMIT_STATE(EndedState); - break; - case libvlc_MediaPlayerEncounteredError: - P_EMIT_STATE(ErrorState); - break; - case libvlc_MediaPlayerVout: - if (event->u.media_player_vout.new_count > 0) - P_EMIT_HAS_VIDEO(true); - else - P_EMIT_HAS_VIDEO(false); - break; - case libvlc_MediaPlayerMediaChanged: - break; -#if (LIBVLC_VERSION_INT >= LIBVLC_VERSION(2, 2, 2, 0)) - case libvlc_MediaPlayerCorked: - that->pause(); - break; - case libvlc_MediaPlayerUncorked: - that->play(); - break; - case libvlc_MediaPlayerMuted: - QMetaObject::invokeMethod( - that, "mutedChanged", - Qt::QueuedConnection, - Q_ARG(bool, true)); - break; - case libvlc_MediaPlayerUnmuted: - QMetaObject::invokeMethod( - that, "mutedChanged", - Qt::QueuedConnection, - Q_ARG(bool, false)); - break; - case libvlc_MediaPlayerAudioVolume: - QMetaObject::invokeMethod( - that, "volumeChanged", - Qt::QueuedConnection, - Q_ARG(float, event->u.media_player_audio_volume.volume)); - break; -#endif - case libvlc_MediaPlayerForward: - case libvlc_MediaPlayerBackward: - case libvlc_MediaPlayerPositionChanged: - case libvlc_MediaPlayerPausableChanged: - case libvlc_MediaPlayerTitleChanged: - case libvlc_MediaPlayerSnapshotTaken: // Snapshot call is sync, so this is useless. - default: - break; - QString msg = QString("Unknown event: ") + QString(libvlc_event_type_name(event->type)); - Q_ASSERT_X(false, "event_cb", qPrintable(msg)); - break; - } -} - -QDebug operator<<(QDebug dbg, const MediaPlayer::State &s) -{ - QString name; - switch (s) { - case MediaPlayer::NoState: - name = QLatin1String("MediaPlayer::NoState"); - break; - case MediaPlayer::OpeningState: - name = QLatin1String("MediaPlayer::OpeningState"); - break; - case MediaPlayer::BufferingState: - name = QLatin1String("MediaPlayer::BufferingState"); - break; - case MediaPlayer::PlayingState: - name = QLatin1String("MediaPlayer::PlayingState"); - break; - case MediaPlayer::PausedState: - name = QLatin1String("MediaPlayer::PausedState"); - break; - case MediaPlayer::StoppedState: - name = QLatin1String("MediaPlayer::StoppedState"); - break; - case MediaPlayer::EndedState: - name = QLatin1String("MediaPlayer::EndedState"); - break; - case MediaPlayer::ErrorState: - name = QLatin1String("MediaPlayer::ErrorState"); - break; - } - dbg.nospace() << "State(" << qPrintable(name) << ")"; - return dbg.space(); -} - -void MediaPlayer::setAudioFade(qreal fade) -{ - m_fadeAmount = fade; - setVolumeInternal(); -} - -void MediaPlayer::setAudioVolume(int volume) -{ - m_volume = volume; - setVolumeInternal(); -} - -void MediaPlayer::setVolumeInternal() -{ - libvlc_audio_set_volume(m_player, m_volume * m_fadeAmount); -} - -void MediaPlayer::setCdTrack(int track) -{ - if (!m_media) - return; - libvlc_media_player_stop(m_player); - m_media->setCdTrack(track); - libvlc_media_player_set_media(m_player, *m_media); - libvlc_media_player_play(m_player); -} - -#if (LIBVLC_VERSION_INT >= LIBVLC_VERSION(2, 2, 0, 0)) -void MediaPlayer::setEqualizer(libvlc_equalizer_t *equalizer) -{ - libvlc_media_player_set_equalizer(m_player, equalizer); -} -#endif - -} // namespace VLC -} // namespace Phonon - -#include "phonon-vlc/moc_mediaplayer.h" diff --git a/src/phonon/phonon-vlc/mediaplayer.h b/src/phonon/phonon-vlc/mediaplayer.h deleted file mode 100644 index 5e51e17d2..000000000 --- a/src/phonon/phonon-vlc/mediaplayer.h +++ /dev/null @@ -1,202 +0,0 @@ -/* - Copyright (C) 2011 Harald Sitter - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . -*/ - -#ifndef PHONON_VLC_MEDIAPLAYER_H -#define PHONON_VLC_MEDIAPLAYER_H - -#include -#include - -#include -#include - -class QImage; -class QString; - -namespace Phonon { -namespace VLC { - -class Media; - -class MediaPlayer : public QObject -{ - Q_OBJECT -public: - enum State { - NoState = 0, - OpeningState, - BufferingState, - PlayingState, - PausedState, - StoppedState, - EndedState, - ErrorState - }; - - explicit MediaPlayer(QObject *parent = 0); - ~MediaPlayer(); - - inline libvlc_media_player_t *libvlc_media_player() const { return m_player; } - inline operator libvlc_media_player_t *() const { return m_player; } - - void setMedia(Media *media); - - void setVideoCallbacks(); - void setVideoFormatCallbacks(); - - void setNsObject(void *drawable) { libvlc_media_player_set_nsobject(m_player, drawable); } - void setXWindow(quint32 drawable) { libvlc_media_player_set_xwindow(m_player, drawable); } - void setHwnd(void *drawable) { libvlc_media_player_set_hwnd(m_player, drawable); } - - // Playback - bool play(); - void pause(); - void pausedPlay(); - void resume(); - void togglePause(); - Q_INVOKABLE void stop(); - - qint64 length() const; - qint64 time() const; - void setTime(qint64 newTime); - - bool isSeekable() const; - - // Video - QSize videoSize() const - { - unsigned int width; - unsigned int height; - libvlc_video_get_size(m_player, 0, &width, &height); - return QSize(width, height); - } - - bool hasVideoOutput() const; - - /// Set new video aspect ratio. - /// \param aspect new video aspect-ratio or empty to reset to default - void setVideoAspectRatio(const QByteArray &aspect) - { libvlc_video_set_aspect_ratio(m_player, aspect.isEmpty() ? 0 : aspect.data()); } - - void setVideoAdjust(libvlc_video_adjust_option_t adjust, int value) - { libvlc_video_set_adjust_int(m_player, adjust, value); } - - void setVideoAdjust(libvlc_video_adjust_option_t adjust, float value) - { libvlc_video_set_adjust_float(m_player, adjust, value); } - - int subtitle() const - { return libvlc_video_get_spu(m_player); } - - libvlc_track_description_t *videoSubtitleDescription() const - { return libvlc_video_get_spu_description(m_player); } - - bool setSubtitle(int subtitle); - bool setSubtitle(const QString &file); - - int title() const - { return libvlc_media_player_get_title(m_player); } - - int titleCount() const - { return libvlc_media_player_get_title_count(m_player); } - - libvlc_track_description_t *titleDescription() const - { return libvlc_video_get_title_description(m_player); } - - void setTitle(int title); - - int videoChapterCount() const - { return libvlc_media_player_get_chapter_count(m_player); } - - libvlc_track_description_t *videoChapterDescription(int title) const - { return libvlc_video_get_chapter_description(m_player, title); } - - void setChapter(int chapter); - - /** Reentrant, through libvlc */ - QImage snapshot() const; - - // Audio - /// Get current audio volume. - /// \return the software volume in percents (0 = mute, 100 = nominal / 0dB) - int audioVolume() const { return m_volume; } - - /// Set new audio volume. - /// \param volume new volume - void setAudioVolume(int volume); - - /// Set the fade percentage, between 0 (muted) and 1.0 (no fade) - void setAudioFade(qreal fade); - - /// \param name name of the output to set - /// \returns \c true when setting was successful, \c false otherwise - bool setAudioOutput(const QByteArray &name) - { return libvlc_audio_output_set(m_player, name.data()) == 0; } - - /** - * Set audio output device by name. - * \param outputName the aout name (pulse, alsa, oss, etc.) - * \param deviceName the output name (aout dependent) - */ - void setAudioOutputDevice(const QByteArray &outputName, const QByteArray &deviceName) - { libvlc_audio_output_device_set(m_player, outputName.data(), deviceName.data()); } - - int audioTrack() const - { return libvlc_audio_get_track(m_player); } - - libvlc_track_description_t * audioTrackDescription() const - { return libvlc_audio_get_track_description(m_player); } - - bool setAudioTrack(int track); - - void setCdTrack(int track); - -#if (LIBVLC_VERSION_INT >= LIBVLC_VERSION(2, 2, 0, 0)) - void setEqualizer(libvlc_equalizer_t *equalizer); -#endif - -signals: - void lengthChanged(qint64 length); - void seekableChanged(bool seekable); - void stateChanged(MediaPlayer::State state); - void timeChanged(qint64 time); - void bufferChanged(int percent); - - /** Emitted when the vout availability has changed */ - void hasVideoChanged(bool hasVideo); - - void mutedChanged(bool mute); - void volumeChanged(float volume); - -private: - static void event_cb(const libvlc_event_t *event, void *opaque); - void setVolumeInternal(); - - Media *m_media; - - libvlc_media_player_t *m_player; - - bool m_doingPausedPlay; - int m_volume; - qreal m_fadeAmount; -}; - -QDebug operator<<(QDebug dbg, const MediaPlayer::State &s); - -} // namespace VLC -} // namespace Phonon - -#endif // PHONON_VLC_MEDIAPLAYER_H diff --git a/src/phonon/phonon-vlc/sinknode.cpp b/src/phonon/phonon-vlc/sinknode.cpp deleted file mode 100644 index 551e4b1e2..000000000 --- a/src/phonon/phonon-vlc/sinknode.cpp +++ /dev/null @@ -1,81 +0,0 @@ -/* - Copyright (C) 2013 Harald Sitter - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . -*/ - -#include "sinknode.h" - -#include "utils/debug.h" -#include "mediaobject.h" -#include "mediaplayer.h" - -namespace Phonon { -namespace VLC { - -SinkNode::SinkNode() - : m_mediaObject(0) - , m_player(0) -{ -} - -SinkNode::~SinkNode() -{ - if (m_mediaObject) { - disconnectFromMediaObject(m_mediaObject); - } -} - -void SinkNode::connectToMediaObject(MediaObject *mediaObject) -{ - if (m_mediaObject) { - error() << Q_FUNC_INFO << "m_mediaObject already connected"; - } - - m_mediaObject = mediaObject; - m_player = mediaObject->m_player; - m_mediaObject->addSink(this); - - // ---> Global handling goes here! Above the derivee handle! <--- // - - handleConnectToMediaObject(mediaObject); -} - -void SinkNode::disconnectFromMediaObject(MediaObject *mediaObject) -{ - handleDisconnectFromMediaObject(mediaObject); - - // ---> Global handling goes here! Below the derivee handle! <--- // - - if (m_mediaObject != mediaObject) { - error() << Q_FUNC_INFO << "SinkNode was not connected to mediaObject"; - } - - if (m_mediaObject) { - m_mediaObject->removeSink(this); - } - - m_mediaObject = 0; - m_player = 0; -} - -void SinkNode::addToMedia(Media *media) -{ - // ---> Global handling goes here! Above the derivee handle! <--- // - - handleAddToMedia(media); -} - -} // namespace VLC -} // namespace Phonon diff --git a/src/phonon/phonon-vlc/sinknode.h b/src/phonon/phonon-vlc/sinknode.h deleted file mode 100644 index ed20fc9d7..000000000 --- a/src/phonon/phonon-vlc/sinknode.h +++ /dev/null @@ -1,102 +0,0 @@ -/* - Copyright (C) 2013 Harald Sitter - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . -*/ - -#ifndef PHONON_VLC_SINKNODE_H -#define PHONON_VLC_SINKNODE_H - -#include - -namespace Phonon { -namespace VLC { - -class Media; -class MediaObject; -class MediaPlayer; - -/** \brief The sink node is essentialy an output for a media object - * - * This class handles connections for the sink to a media object. It remembers - * the media object and the libVLC media player associated with it. - * - * \see MediaObject - */ -class SinkNode -{ -public: - SinkNode(); - virtual ~SinkNode(); - - /** - * Associates the sink node to the provided media object. The m_mediaObject and m_vlcPlayer - * attributes are set, and the sink is added to the media object's sinks. - * - * \param mediaObject The media object to connect to. - * - * \see disconnectFromMediaObject() - */ - void connectToMediaObject(MediaObject *mediaObject); - - /** - * Removes this sink from the specified media object's sinks. - * - * \param mediaObject The media object to disconnect from - * - * \see connectToMediaObject() - */ - void disconnectFromMediaObject(MediaObject *mediaObject); - - /** - * Does nothing. To be reimplemented in child classes. - */ - void addToMedia(Media *media); - -protected: - /** - * Handling function for derived classes. - * \note This handle is executed *after* the global handle. - * Meaning the SinkNode base will be done handling the connect. - * \see connectToMediaObject - */ - virtual void handleConnectToMediaObject(MediaObject *mediaObject) { Q_UNUSED(mediaObject); } - - /** - * Handling function for derived classes. - * \note This handle is executed *before* the global handle. - * Meaning the SinkNode base will continue handling the disconnect. - * \see disconnectFromMediaObject - */ - virtual void handleDisconnectFromMediaObject(MediaObject *mediaObject) { Q_UNUSED(mediaObject); } - - /** - * Handling function for derived classes. - * \note This handle is executed *after* the global handle. - * Meaning the SinkNode base will be done handling the connect. - * \see addToMedia - */ - virtual void handleAddToMedia(Media *media) { Q_UNUSED(media); } - - /** Available while connected to a MediaObject (until disconnected) */ - QPointer m_mediaObject; - - /** Available while connected to a MediaObject (until disconnected) */ - MediaPlayer *m_player; -}; - -} // namespace VLC -} // namespace Phonon - -#endif // PHONON_VLC_SINKNODE_H diff --git a/src/phonon/phonon-vlc/streamreader.cpp b/src/phonon/phonon-vlc/streamreader.cpp deleted file mode 100644 index 2c5df9004..000000000 --- a/src/phonon/phonon-vlc/streamreader.cpp +++ /dev/null @@ -1,244 +0,0 @@ -/* - Copyright (C) 2007-2008 Tanguy Krotoff - Copyright (C) 2008 Lukas Durfina - Copyright (C) 2009 Fathi Boudra - Copyright (C) 2009-2011 vlc-phonon AUTHORS - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . -*/ - -#include "streamreader.h" - -#include - -#include - -#include "utils/debug.h" -#include "media.h" -#include "mediaobject.h" -#ifndef QT_NO_PHONON_ABSTRACTMEDIASTREAM - -namespace Phonon { -namespace VLC { - -#define BLOCKSIZE 32768 - -StreamReader::StreamReader(MediaObject *parent) - : QObject(parent) - , m_pos(0) - , m_size(0) - , m_eos(false) - , m_seekable(false) - , m_unlocked(false) - , m_mediaObject(parent) -{ -} - -StreamReader::~StreamReader() -{ -} - -void StreamReader::addToMedia(Media *media) -{ - lock(); // Make sure we can lock in read(). - - media->addOption(QLatin1String("imem-cat=4")); - media->addOption(QLatin1String("imem-data="), INTPTR_PTR(this)); - media->addOption(QLatin1String("imem-get="), INTPTR_FUNC(readCallback)); - media->addOption(QLatin1String("imem-release="), INTPTR_FUNC(readDoneCallback)); - media->addOption(QLatin1String("imem-seek="), INTPTR_FUNC(seekCallback)); - - // if stream has known size, we may pass it - // imem module will use it and pass it to demux - if (streamSize() > 0) { - media->addOption(QString("imem-size=%1").arg(streamSize())); - } -} - -void StreamReader::lock() -{ - QMutexLocker lock(&m_mutex); - DEBUG_BLOCK; - m_unlocked = false; -} - -void StreamReader::unlock() -{ - QMutexLocker lock(&m_mutex); - DEBUG_BLOCK; - m_unlocked = true; - m_waitingForData.wakeAll(); -} - -int StreamReader::readCallback(void *data, const char *cookie, - int64_t *dts, int64_t *pts, unsigned *flags, // krazy:exclude=typedefs - size_t *bufferSize, void **buffer) -{ - Q_UNUSED(cookie); - Q_UNUSED(dts); - Q_UNUSED(pts); - Q_UNUSED(flags); - - StreamReader *that = static_cast(data); - size_t length = BLOCKSIZE; - - *buffer = new char[length]; - - int size = length; - bool ret = that->read(that->currentPos(), &size, static_cast(*buffer)); - - *bufferSize = static_cast(size); - - return ret ? 0 : -1; -} - -int StreamReader::readDoneCallback(void *data, const char *cookie, - size_t bufferSize, void *buffer) -{ - Q_UNUSED(data); - Q_UNUSED(cookie); - Q_UNUSED(bufferSize); - delete[] static_cast(buffer); - return 0; -} - -int StreamReader::seekCallback(void *data, const uint64_t pos) -{ - StreamReader *that = static_cast(data); - if (static_cast(pos) > that->streamSize()) { // krazy:exclude=typedefs - // attempt to seek past the end of our data. - return -1; - } - - that->setCurrentPos(pos); - // this should return a true/false, but it doesn't, so assume success. - - return 0; -} - -quint64 StreamReader::currentBufferSize() const -{ - return m_buffer.size(); -} - -bool StreamReader::read(quint64 pos, int *length, char *buffer) -{ - QMutexLocker lock(&m_mutex); - DEBUG_BLOCK; - bool ret = true; - - if (m_unlocked) { - return ret; - } - - if (currentPos() != pos) { - if (!streamSeekable()) { - return false; - } - setCurrentPos(pos); - } - - if (m_buffer.capacity() < *length) { - m_buffer.reserve(*length); - } - - while (currentBufferSize() < static_cast(*length)) { - quint64 oldSize = currentBufferSize(); - needData(); - - m_waitingForData.wait(&m_mutex); - - if (oldSize == currentBufferSize()) { - if (m_eos && m_buffer.isEmpty()) { - return false; - } - // We didn't get any more data - *length = static_cast(oldSize); - // If we have some data to return, why tell to reader that we failed? - // Remember that length argument is more like maxSize not requiredSize - ret = true; - } - } - - if (m_mediaObject->state() != Phonon::BufferingState && - m_mediaObject->state() != Phonon::LoadingState) { - enoughData(); - } - - memcpy(buffer, m_buffer.data(), *length); - m_pos += *length; - // trim the buffer by the amount read - m_buffer = m_buffer.mid(*length); - - return ret; -} - -void StreamReader::endOfData() -{ - m_eos = true; - m_waitingForData.wakeAll(); -} - -void StreamReader::writeData(const QByteArray &data) -{ - QMutexLocker lock(&m_mutex); - DEBUG_BLOCK; - m_buffer.append(data); - m_waitingForData.wakeAll(); -} - -quint64 StreamReader::currentPos() const -{ - return m_pos; -} - -void StreamReader::setCurrentPos(qint64 pos) -{ - QMutexLocker lock(&m_mutex); - m_pos = pos; - m_buffer.clear(); // Not optimal, but meh - - // Do not touch m_size here, it reflects the size of the stream not the size of the buffer, - // and generally seeking does not change the size! - - seekStream(pos); -} - -void StreamReader::setStreamSize(qint64 newSize) -{ - m_size = newSize; -} - -qint64 StreamReader::streamSize() const -{ - return m_size; -} - -void StreamReader::setStreamSeekable(bool seekable) -{ - m_seekable = seekable; - emit streamSeekableChanged(seekable); -} - -bool StreamReader::streamSeekable() const -{ - return m_seekable; -} - -} // namespace VLC -} // namespace Phonon - -#endif //QT_NO_PHONON_ABSTRACTMEDIASTREAM - -#include "phonon-vlc/moc_streamreader.h" diff --git a/src/phonon/phonon-vlc/streamreader.h b/src/phonon/phonon-vlc/streamreader.h deleted file mode 100644 index f8a565a34..000000000 --- a/src/phonon/phonon-vlc/streamreader.h +++ /dev/null @@ -1,121 +0,0 @@ -/* - Copyright (C) 2007-2008 Tanguy Krotoff - Copyright (C) 2008 Lukas Durfina - Copyright (C) 2009 Fathi Boudra - Copyright (C) 2009-2011 vlc-phonon AUTHORS - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . -*/ - -#ifndef PHONON_STREAMREADER_H -#define PHONON_STREAMREADER_H - -#include -#include - -#include - -#include -#include - -#ifndef QT_NO_PHONON_ABSTRACTMEDIASTREAM - -namespace Phonon -{ - -class MediaSource; - -namespace VLC -{ - -class Media; -class MediaObject; - -/** \brief Class for supporting custom data streams to the backend - * - * This class receives data from a Phonon MediaSource that is a stream. - * When data is requested, it fetches it from the media source and passes it further. - * MediaObject uses this class to pass stream data to libVLC. - * - * It implements Phonon::StreamInterface, necessary for the connection with an - * Phonon::AbstractMediaStream owned by the Phonon::MediaSource. See the Phonon - * documentation for details. - * - * There are callbacks implemented in streamhooks.cpp, for libVLC. - */ -class StreamReader : public QObject, public Phonon::StreamInterface -{ - Q_OBJECT - Q_INTERFACES(Phonon::StreamInterface) -public: - explicit StreamReader(MediaObject *parent); - ~StreamReader(); - - void addToMedia(Media *media); - - void lock(); - void unlock(); - - static int readCallback(void *data, const char *cookie, - int64_t *dts, int64_t *pts, unsigned *flags, // krazy:exclude=typedefs - size_t *bufferSize, void **buffer); - - static int readDoneCallback(void *data, const char *cookie, - size_t bufferSize, void *buffer); - - static int seekCallback(void *data, const uint64_t pos); - - quint64 currentBufferSize() const; - void writeData(const QByteArray &data); - quint64 currentPos() const; - void setCurrentPos(qint64 pos); - - /** - * Requests data from this stream. The stream requests data from the - * Phonon::MediaSource's abstract media stream with the needData() signal. - * If the requested data is available, it is copied into the buffer. - * - * \param pos Position in the stream - * \param length Length of the data requested - * \param buffer A buffer to put the data - */ - bool read(quint64 offset, int *length, char *buffer); - - void endOfData(); - void setStreamSize(qint64 newSize); - qint64 streamSize() const; - void setStreamSeekable(bool seekable); - bool streamSeekable() const; - -signals: - void streamSeekableChanged(bool seekable); - -protected: - QByteArray m_buffer; - quint64 m_pos; - quint64 m_size; - bool m_eos; - bool m_seekable; - bool m_unlocked; - QMutex m_mutex; - QWaitCondition m_waitingForData; - MediaObject *m_mediaObject; -}; - -} -} - -#endif //QT_NO_PHONON_ABSTRACTMEDIASTREAM - -#endif // PHONON_STREAMREADER_H diff --git a/src/phonon/phonon-vlc/utils/debug.cpp b/src/phonon/phonon-vlc/utils/debug.cpp deleted file mode 100644 index c0e621868..000000000 --- a/src/phonon/phonon-vlc/utils/debug.cpp +++ /dev/null @@ -1,224 +0,0 @@ -/* - Copyright (c) 2003-2005 Max Howell - Copyright (c) 2007-2009 Mark Kretschmann - Copyright (c) 2010 Kevin Funk - Copyright (c) 2011 Harald Sitter - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . -*/ - -#include "debug.h" -#include "debug_p.h" - -#include -#include -#include - -#ifdef Q_OS_UNIX -# include -#endif - -// Define Application wide prefix -#ifndef APP_PREFIX -#define APP_PREFIX QLatin1String( "PHONON-VLC" ) -#endif - -#define DEBUG_INDENT_OBJECTNAME QLatin1String("Debug_Indent_object") - -QMutex Debug::mutex( QMutex::Recursive ); - -using namespace Debug; - -static bool s_debugColorsEnabled = true; -static DebugLevel s_debugLevel = DEBUG_NONE; - -IndentPrivate::IndentPrivate(QObject* parent) - : QObject(parent) -{ - setObjectName( DEBUG_INDENT_OBJECTNAME ); -} - -/** - * We can't use a statically instantiated QString for the indent, because - * static namespaces are unique to each dlopened library. So we piggy back - * the QString on the KApplication instance - */ -IndentPrivate* IndentPrivate::instance() -{ - QObject* qOApp = reinterpret_cast(qApp); - QObject* obj = qOApp ? qOApp->findChild( DEBUG_INDENT_OBJECTNAME ) : 0; - return (obj ? static_cast( obj ) : new IndentPrivate( qApp )); -} - -/* - Text color codes (use last digit here) - 30=black 31=red 32=green 33=yellow 34=blue 35=magenta 36=cyan 37=white -*/ -static int s_colors[] = { 1, 2, 4, 5, 6 }; // no yellow and white for sanity -static int s_colorIndex = 0; - -static QString toString( DebugLevel level ) -{ - switch( level ) - { - case DEBUG_WARN: - return "[WARNING]"; - case DEBUG_ERROR: - return "[ERROR__]"; - case DEBUG_FATAL: - return "[FATAL__]"; - default: - return QString(); - } -} - -static int toColor( DebugLevel level ) -{ - switch( level ) { - case DEBUG_WARN: - return 3; // red - case DEBUG_ERROR: - case DEBUG_FATAL: - return 1; // yellow - default: - return 0; // default: black - } -} - -static QString colorize( const QString &text, int color = s_colorIndex ) -{ - if( !debugColorEnabled() ) - return text; - - return QString( "\x1b[00;3%1m%2\x1b[00;39m" ).arg( QString::number(s_colors[color]), text ); -} - -static QString reverseColorize( const QString &text, int color ) -{ - if( !debugColorEnabled() ) - return text; - - return QString( "\x1b[07;3%1m%2\x1b[00;39m" ).arg( QString::number(color), text ); -} - -QString Debug::indent() -{ - return IndentPrivate::instance()->m_string; -} - -bool Debug::debugEnabled() -{ - return s_debugLevel < DEBUG_NONE; -} - -bool Debug::debugColorEnabled() -{ - return s_debugColorsEnabled; -} - -DebugLevel Debug::minimumDebugLevel() -{ - return s_debugLevel; -} - -void Debug::setColoredDebug( bool enable ) -{ - s_debugColorsEnabled = enable; -} - -void Debug::setMinimumDebugLevel(DebugLevel level) -{ - s_debugLevel = level; -} - -QDebug Debug::dbgstream( DebugLevel level ) -{ - if ( level < s_debugLevel ) - return nullDebug(); - - mutex.lock(); - const QString currentIndent = indent(); - mutex.unlock(); - - QString text = QString("%1%2").arg( APP_PREFIX ).arg( currentIndent ); - if ( level > DEBUG_INFO ) - text.append( ' ' + reverseColorize( toString(level), toColor( level ) ) ); - - return QDebug( QtDebugMsg ) << qPrintable( text ); -} - -void Debug::perfLog( const QString &message, const QString &func ) -{ -#ifdef Q_OS_UNIX - if( !debugEnabled() ) - return; - - QString str = QString( "MARK: %1: %2 %3" ).arg( qApp->applicationName(), func, message ); - access( str.toLocal8Bit().data(), F_OK ); -#endif -} - -Block::Block( const char *label ) - : m_label( label ) - , m_color( s_colorIndex ) -{ - if( !debugEnabled() || DEBUG_INFO < s_debugLevel) - return; - - m_startTime.start(); - - mutex.lock(); - s_colorIndex = (s_colorIndex + 1) % 5; - dbgstream() - << qPrintable( colorize( QLatin1String( "BEGIN:" ), m_color ) ) - << m_label; - IndentPrivate::instance()->m_string += QLatin1String(" "); - mutex.unlock(); -} - -Block::~Block() -{ - if( !debugEnabled() || DEBUG_INFO < s_debugLevel) - return; - - const double duration = m_startTime.elapsed() / 1000.0; - - mutex.lock(); - IndentPrivate::instance()->m_string.truncate( Debug::indent().length() - 2 ); - mutex.unlock(); - - // Print timing information, and a special message (DELAY) if the method took longer than 5s - if( duration < 5.0 ) - { - dbgstream() - << qPrintable( colorize( QLatin1String( "END__:" ), m_color ) ) - << m_label - << qPrintable( colorize( QString( "[Took: %3s]") - .arg( QString::number(duration, 'g', 2) ), m_color ) ); - } - else - { - dbgstream() - << qPrintable( colorize( QString( "END__:" ), m_color ) ) - << m_label - << qPrintable( reverseColorize( QString( "[DELAY Took (quite long) %3s]") - .arg( QString::number(duration, 'g', 2) ), toColor( DEBUG_WARN ) ) ); - } -} - -void Debug::stamp() -{ - static int n = 0; - debug() << "| Stamp: " << ++n << endl; -} diff --git a/src/phonon/phonon-vlc/utils/debug.h b/src/phonon/phonon-vlc/utils/debug.h deleted file mode 100644 index 1373f77c3..000000000 --- a/src/phonon/phonon-vlc/utils/debug.h +++ /dev/null @@ -1,192 +0,0 @@ -/* - Copyright (c) 2003-2005 Max Howell - Copyright (c) 2007-2009 Mark Kretschmann - Copyright (c) 2010 Kevin Funk - Copyright (c) 2011 Harald Sitter - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . -*/ - -#ifndef PHONON_DEBUG_H -#define PHONON_DEBUG_H - -// We always want debug output available at runtime -#undef QT_NO_DEBUG_OUTPUT -#undef KDE_NO_DEBUG_OUTPUT - -#include -#include - -# include - -// Platform specific macros -#ifdef _WIN32 // krazy:exclude=cpp we really want to check a compiler feature here :P -#define __PRETTY_FUNCTION__ __FUNCTION__ -#endif -#ifdef __SUNPRO_CC -#define __PRETTY_FUNCTION__ __FILE__ -#endif - -/** - * @namespace Debug - * @short kdebug with indentation functionality and convenience macros - * @author Max Howell - * - * Usage: - * - * #define DEBUG_PREFIX "Blah" - * #include "debug.h" - * - * void function() - * { - * Debug::Block myBlock( __PRETTY_FUNCTION__ ); - * - * debug() << "output1" << endl; - * debug() << "output2" << endl; - * } - * - * Will output: - * - * app: BEGIN: void function() - * app: [Blah] output1 - * app: [Blah] output2 - * app: END: void function(): Took 0.1s - * - * @see Block - * @see CrashHelper - * @see ListStream - */ -namespace Debug -{ - extern QMutex mutex; - - enum DebugLevel { - DEBUG_INFO = 0, - DEBUG_WARN = 1, - DEBUG_ERROR = 2, - DEBUG_FATAL = 3, - DEBUG_NONE = 4 - }; - - QDebug dbgstream( DebugLevel level = DEBUG_INFO ); - bool debugEnabled(); - bool debugColorEnabled(); - DebugLevel minimumDebugLevel(); - void setColoredDebug( bool enable ); - void setMinimumDebugLevel( DebugLevel level ); - QString indent(); - - static inline QDebug dbgstreamwrapper( DebugLevel level ) { return dbgstream( level ); } - - static inline QDebug debug() { return dbgstreamwrapper( DEBUG_INFO ); } - static inline QDebug warning() { return dbgstreamwrapper( DEBUG_WARN ); } - static inline QDebug error() { return dbgstreamwrapper( DEBUG_ERROR ); } - static inline QDebug fatal() { return dbgstreamwrapper( DEBUG_FATAL ); } - - void perfLog( const QString &message, const QString &func ); -} - -using Debug::debug; -using Debug::warning; -using Debug::error; -using Debug::fatal; - -/// Standard function announcer -#define DEBUG_FUNC_INFO { Debug::mutex.lock(); qDebug() << Debug::indent() ; Debug::mutex.unlock(); } - -/// Announce a line -#define DEBUG_LINE_INFO { Debug::mutex.lock(); qDebug() << Debug::indent() << "Line: " << __LINE__; Debug::mutex.unlock(); } - -/// Convenience macro for making a standard Debug::Block -#define DEBUG_BLOCK Debug::Block uniquelyNamedStackAllocatedStandardBlock( __PRETTY_FUNCTION__ ); - -/// Performance logging -#define PERF_LOG( msg ) { Debug::perfLog( msg, __PRETTY_FUNCTION__ ); } - -class BlockPrivate; - -namespace Debug -{ - /** - * @class Debug::Block - * @short Use this to label sections of your code - * - * Usage: - * - * void function() - * { - * Debug::Block myBlock( "section" ); - * - * debug() << "output1" << endl; - * debug() << "output2" << endl; - * } - * - * Will output: - * - * app: BEGIN: section - * app: [prefix] output1 - * app: [prefix] output2 - * app: END: section - Took 0.1s - * - */ - class Block - { - public: - explicit Block( const char *name ); - ~Block(); - - private: - QElapsedTimer m_startTime; - const char *m_label; - int m_color; - }; - - /** - * @name Debug::stamp() - * @short To facilitate crash/freeze bugs, by making it easy to mark code that has been processed - * - * Usage: - * - * { - * Debug::stamp(); - * function1(); - * Debug::stamp(); - * function2(); - * Debug::stamp(); - * } - * - * Will output (assuming the crash occurs in function2() - * - * app: Stamp: 1 - * app: Stamp: 2 - * - */ - void stamp(); -} - -#include - -namespace Debug -{ - /** - * @class Debug::List - * @short You can pass anything to this and it will output it as a list - * - * debug() << (Debug::List() << anInt << aString << aQStringList << aDouble) << endl; - */ - - typedef QList List; -} - -#endif diff --git a/src/phonon/phonon-vlc/utils/debug_p.h b/src/phonon/phonon-vlc/utils/debug_p.h deleted file mode 100644 index b27da2389..000000000 --- a/src/phonon/phonon-vlc/utils/debug_p.h +++ /dev/null @@ -1,57 +0,0 @@ -/* - Copyright (c) 2010 Kevin Funk - Copyright (c) 2011 Casian Andrei - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . -*/ - -#ifndef DEBUGPRIVATE_H -#define DEBUGPRIVATE_H - -#include "debug.h" - -#include - -class IndentPrivate - : public QObject -{ -private: - explicit IndentPrivate(QObject* parent = 0); - -public: - static IndentPrivate* instance(); - - QString m_string; -}; - -/* - * From kdelibs/kdecore/io - */ -class NoDebugStream: public QIODevice -{ - // Q_OBJECT -public: - NoDebugStream() { open(WriteOnly); } - bool isSequential() const { return true; } - qint64 readData(char *, qint64) { return 0; /* eof */ } - qint64 readLineData(char *, qint64) { return 0; /* eof */ } - qint64 writeData(const char *, qint64 len) { return len; } -} devnull; - -QDebug nullDebug() -{ - return QDebug(&devnull); -} - -#endif // DEBUGPRIVATE_H diff --git a/src/phonon/phonon-vlc/utils/libvlc.cpp b/src/phonon/phonon-vlc/utils/libvlc.cpp deleted file mode 100644 index ecacd8c4c..000000000 --- a/src/phonon/phonon-vlc/utils/libvlc.cpp +++ /dev/null @@ -1,119 +0,0 @@ -/* - Copyright (C) 2011-2012 vlc-phonon AUTHORS - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . -*/ - -#include "libvlc.h" - -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include - -#include "debug.h" - -LibVLC *LibVLC::self; - -LibVLC::LibVLC() - : m_vlcInstance(0) -{ -} - -LibVLC::~LibVLC() -{ - if (m_vlcInstance) - libvlc_release(m_vlcInstance); - self = 0; -} - -bool LibVLC::init() -{ - Q_ASSERT_X(!self, "LibVLC", "there should be only one LibVLC object"); - LibVLC::self = new LibVLC; - - QList args; - - // Ends up as something like $HOME/.config/Phonon/vlc.conf - const QString configFileName = QSettings("Phonon", "vlc").fileName(); - if (QFile::exists(configFileName)) { - args << QByteArray("--config=").append(QFile::encodeName(configFileName)); - args << "--no-ignore-config"; - } - - int debugLevel = qgetenv("PHONON_SUBSYSTEM_DEBUG").toInt(); - if (debugLevel > 0) { - args << QByteArray("--verbose=").append(QByteArray::number(debugLevel)); - args << QByteArray("--extraintf=logger"); -#ifdef Q_WS_WIN - QDir logFilePath(QString(qgetenv("APPDATA")).append("/vlc")); -#else - QDir logFilePath(QDir::homePath().append("/.vlc")); -#endif //Q_WS_WIN - logFilePath.mkdir("log"); - const QString logFile = logFilePath.path() - .append("/log/vlc-log-") - .append(QString::number(qApp->applicationPid())) - .append(".txt"); - args << QByteArray("--logfile=").append(QFile::encodeName(QDir::toNativeSeparators(logFile))); - } - - args << "--no-media-library"; - args << "--no-osd"; - args << "--no-stats"; - // By default VLC will put a picture-in-picture when making a snapshot. - // This is unexpected behaviour for us, so we force it off. - args << "--no-snapshot-preview"; - // Do not load xlib dependent modules as we cannot ensure proper init - // order as expected by xlib thus leading to crashes. - // KDE BUG: 240001 - args << "--no-xlib"; - // Do not preload services discovery modules, we don't use them. - args << "--services-discovery=''"; - // Allow multiple starts (one gets to wonder whether that makes a difference). -#if !defined(Q_OS_MAC) && (defined(Q_OS_WIN) || !defined(PHONON_NO_DBUS)) - args << "--no-one-instance"; -#endif - args << "--no-audio"; - args << "--no-video"; - // 6 seconds disk read buffer (up from vlc 2.1 default of 300ms) when using alsa, prevents most buffer underruns - // when the disk is very busy. We expect the pulse buffer after decoding to solve the same problem. - args << "--file-caching=6000"; - - // Build const char* array - QVarLengthArray vlcArgs(args.size()); - for (int i = 0; i < args.size(); ++i) { - vlcArgs[i] = args.at(i).constData(); - } - - // Create and initialize a libvlc instance (it should be done only once) - self->m_vlcInstance = libvlc_new(vlcArgs.size(), vlcArgs.constData()); - if (!self->m_vlcInstance) { - fatal() << "libVLC: could not initialize"; - return false; - } - return true; -} - -const char *LibVLC::errorMessage() -{ - return libvlc_errmsg(); -} diff --git a/src/phonon/phonon-vlc/utils/libvlc.h b/src/phonon/phonon-vlc/utils/libvlc.h deleted file mode 100644 index 6dcc96fe7..000000000 --- a/src/phonon/phonon-vlc/utils/libvlc.h +++ /dev/null @@ -1,140 +0,0 @@ -/* - Copyright (C) 2011 vlc-phonon AUTHORS - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . -*/ - -#ifndef LIBVLC_H -#define LIBVLC_H - -#include -#include - -#include - -struct libvlc_instance_t; - -/** - * Convenience macro accessing the vlc_instance_t via LibVLC::self. - * Please note that init() must have been called whenever using this, as no - * checking of self is conducted (i.e. can be null). - */ -#define libvlc LibVLC::self->vlc() - -/** - * Foreach loop macro for VLC descriptions. - * - * For this macro to work the type name must be of the form: - * \verbatim libvlc_FOO_t \endverbatim - * * - * \param type the type identifier of VLC (without libvlc and _t) - * \param variable the variable name you want to use - * \param getter the getter from which to get the iterator - * \param releaser, function name to release the list - */ -#define VLC_FOREACH(type, variable, getter, releaser) \ - for (libvlc_##type##_t *__libvlc_first_element = getter, *variable = __libvlc_first_element; \ - variable; \ - variable = variable->p_next, !variable ? releaser(__libvlc_first_element) : (void)0) - -// This foreach expects only a type and variable because getter and releaser are generic. -// Also the type is in short form i.e. libvlc_foo_t would be foo. -#define VLC_FOREACH_LIST(type, variable) VLC_FOREACH(type, variable, libvlc_##type##_list_get(libvlc), libvlc_##type##_list_release) - -// These foreach expect no type because the type is generic, they do however -// expect a getter to allow usage with our wrapper classes and since the getter -// will most likely not be generic. -// For instance libvlc_audio_get_track_description returns a generic -// libvlc_track_description_t pointer. So the specific audio_track function -// relates to the generic track description type. -#define VLC_FOREACH_TRACK(variable, getter) VLC_FOREACH(track_description, variable, getter, libvlc_track_description_list_release) -#define VLC_FOREACH_MODULE(variable, getter) VLC_FOREACH(module_description, variable, getter, libvlc_module_description_list_release) - -/** - * \brief Singleton class containing a libvlc instance. - * - * This class is a convenience class implementing the singleton pattern to hold - * an instance of libvlc. This instance is necessary to call various libvlc - * functions (such as creating a new mediaplayer instance). - * - * To initialize the object call init(), this will create the actualy LibVLC - * instance and then try to initialize the libvlc instance itself. - * init() returns false in case the libvlc instance could not be created. - * - * For convenience reasons there is also a libvlc macro which gets the LibVLC - * instance and then the libvlc_instance_t form that. Note that this macro - * does not check whether LibVLC actually got initialized, so it should only - * be used when you can be absolutely sure that init() was already called - * - * \code - * LibVLC::init(0); // init LibVLC - * if (!LibVLC::self) { - * exit(1); // error if self is null - * } - * libvlc_media_player_new(libvlc); // use libvlc macro - * \endcode - * - * \author Harald Sitter org> - */ -class LibVLC -{ -public: - /** - * The singleton itself. Beware that this returns 0 unless init was called. - * - * \returns LibVLC instance or 0 if there is none. - * - * \see init - */ - static LibVLC *self; - - /** - * \returns the contained libvlc instance. - */ - libvlc_instance_t *vlc() - { - return m_vlcInstance; - } - - /** - * Construct singleton and initialize and launch the VLC library. - * - * \return VLC initialization result - */ - static bool init(); - - /** - * \returns the most recent error message of libvlc - */ - static const char *errorMessage(); - - /** - * Destruct the LibVLC singleton and release the contained libvlc instance. - */ - ~LibVLC(); - -private: - Q_DISABLE_COPY(LibVLC) - - /** - * Private default constructor, to create LibVLC call init instead. - * - * \see init - */ - LibVLC(); - - libvlc_instance_t *m_vlcInstance; -}; - -#endif // LIBVLC_H diff --git a/src/phonon/phonon-vlc/utils/mime.h.cmake b/src/phonon/phonon-vlc/utils/mime.h.cmake deleted file mode 100644 index fcec78c2b..000000000 --- a/src/phonon/phonon-vlc/utils/mime.h.cmake +++ /dev/null @@ -1,41 +0,0 @@ -/* - Copyright (C) 2012 Harald Sitter - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . -*/ - -#ifndef PHONON_VLC_MIME_H -#define PHONON_VLC_MIME_H - -#include - -namespace Phonon { -namespace VLC { - -static QStringList mimeTypeList() -{ - // In CMake we null-terminate this list for ease of iteration. - const char *c_strings[] = @PHONON_VLC_MIME_TYPES_C_ARRAY@; - - QStringList list; - int i = 0; - while (c_strings[i]) - list.append(QLatin1String(c_strings[i++])); - return list; -} - -} // namespace VLC -} // namespace Phonon - -#endif // PHONON_VLC_MIME_H diff --git a/src/phonon/phonon-vlc/utils/vstring.h b/src/phonon/phonon-vlc/utils/vstring.h deleted file mode 100644 index e9de06d31..000000000 --- a/src/phonon/phonon-vlc/utils/vstring.h +++ /dev/null @@ -1,59 +0,0 @@ -/* - Copyright (C) 2012 Harald Sitter - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . -*/ - -#ifndef PHONON_VLC_VSTRING_H -#define PHONON_VLC_VSTRING_H - -#include -#include -#include - -/** - * @brief The VString class wraps around a char* returned from libvlc functions. - * Directly from libvlc functions returned cstrings are unique in two ways. - * For one they are to be freed by the caller, and for another they are always - * UTF8 (as VLC internally only uses UTF8). - * - * Particularly the first point is where VString comes in, it will on destruction - * call libvlc_free to free the string, thus avoiding memleaks. - * Additionally it conveniently converts to QString using either toQString - * or implicit cast to QString which makes it completely transparent to other - * functions. It also prevents you from carrying the cstring out of scope and - * render implicit copies of it invalid once free is called somewhere. - * Both functions use QString::fromUtf8 and are therefore the best way to - * process the string. - */ -class VString -{ -public: - explicit VString(char *vlcString) : m_vlcString(vlcString) {} - ~VString() - { - libvlc_free(m_vlcString); - } - - // VLC internally only uses UTF8! - QString toQString() { return QString::fromUtf8(m_vlcString); } - operator QString() { return toQString(); } - -private: - VString() {} - - char *m_vlcString; -}; - -#endif // PHONON_VLC_VSTRING_H diff --git a/src/phonon/phonon-vlc/video/mac/nsvideoview.h b/src/phonon/phonon-vlc/video/mac/nsvideoview.h deleted file mode 100644 index 9485283bc..000000000 --- a/src/phonon/phonon-vlc/video/mac/nsvideoview.h +++ /dev/null @@ -1,29 +0,0 @@ -/* - Copyright (C) 2010 Benoit Calvez - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . -*/ - -#ifndef NSVIDEOVIEW_H -#define NSVIDEOVIEW_H - -#import - -@interface VideoView : NSView -- (void)addVoutSubview: (NSView *)view; -- (void)removeVoutSubview: (NSView *)view; -- (BOOL)stretchesVideo; -@end - -#endif // NSVIDEOVIEW_H diff --git a/src/phonon/phonon-vlc/video/mac/nsvideoview.mm b/src/phonon/phonon-vlc/video/mac/nsvideoview.mm deleted file mode 100644 index ef97b6252..000000000 --- a/src/phonon/phonon-vlc/video/mac/nsvideoview.mm +++ /dev/null @@ -1,37 +0,0 @@ -/* - Copyright (C) 2010 Benoit Calvez - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . -*/ - -#include "nsvideoview.h" - -@implementation VideoView -- (void)addVoutSubview:(NSView *)view -{ - [view setFrame:[self bounds]]; - [self addSubview:view]; - [view setAutoresizingMask: NSViewHeightSizable |NSViewWidthSizable]; -} -- (void)removeVoutSubview:(NSView *)view -{ - [view removeFromSuperview]; -} -- (BOOL)stretchesVideo -{ - //Whatever you would want - return NO; -} - -@end diff --git a/src/phonon/phonon-vlc/video/mac/vlcmacwidget.h b/src/phonon/phonon-vlc/video/mac/vlcmacwidget.h deleted file mode 100644 index 55b7c02d8..000000000 --- a/src/phonon/phonon-vlc/video/mac/vlcmacwidget.h +++ /dev/null @@ -1,32 +0,0 @@ -/* - Copyright (C) 2010 Benoit Calvez - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . -*/ - -#ifndef VLCMACWIDGET_H -#define VLCMACWIDGET_H - -#include - -#import - -class VlcMacWidget : public QMacCocoaViewContainer -{ -public: - explicit VlcMacWidget(QWidget *parent = 0); -}; - - -#endif // VLCMACWIDGET_H diff --git a/src/phonon/phonon-vlc/video/mac/vlcmacwidget.mm b/src/phonon/phonon-vlc/video/mac/vlcmacwidget.mm deleted file mode 100644 index 9ee73041e..000000000 --- a/src/phonon/phonon-vlc/video/mac/vlcmacwidget.mm +++ /dev/null @@ -1,42 +0,0 @@ -/* - Copyright (C) 2010 Benoit Calvez - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . -*/ - -#include "vlcmacwidget.h" -#import -#import "nsvideoview.h" - -#include - -VlcMacWidget::VlcMacWidget(QWidget *parent) : QMacCocoaViewContainer(0, parent) -{ - // Many Cocoa objects create temporary autorelease objects, - // so create a pool to catch them. - - printf("[0x123c1b938] vout_macosx generic debug: No drawable-nsobject, passing over.[0x123c1b938] vout_macosx generic debug: No drawable-nsobject, passing over.[0x123c1b938] vout_macosx generic debug: No drawable-nsobject, passing over.[0x123c1b938] vout_macosx generic debug: No drawable-nsobject, passing over.[0x123c1b938] vout_macosx generic debug: No drawable-nsobject, passing over.[0x123c1b938] vout_macosx generic debug: No drawable-nsobject, passing over.[0x123c1b938] vout_macosx generic debug: No drawable-nsobject, passing over.[0x123c1b938] vout_macosx generic debug: No drawable-nsobject, passing over."); - NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; - VideoView *videoView = [[VideoView alloc] init]; - - this->setCocoaView(videoView); - - // Release our reference, since our super class takes ownership and we - // don't need it anymore. - [videoView release]; - - // Clean up our pool as we no longer need it. - [pool release]; - -} diff --git a/src/phonon/phonon-vlc/video/videodataoutput.cpp b/src/phonon/phonon-vlc/video/videodataoutput.cpp deleted file mode 100644 index 772334930..000000000 --- a/src/phonon/phonon-vlc/video/videodataoutput.cpp +++ /dev/null @@ -1,202 +0,0 @@ -/* - Copyright (C) 2010-2012 Harald Sitter - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), Nokia Corporation - (or its successors, if any) and the KDE Free Qt Foundation, which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . -*/ - -#include "videodataoutput.h" - -#include -#include -#include - -#include - -#include "utils/debug.h" -#include "media.h" -#include "mediaobject.h" - -using namespace Phonon::Experimental; - -namespace Phonon -{ -namespace VLC -{ - -VideoDataOutput::VideoDataOutput(QObject *parent) - : QObject(parent) - , m_frontend(0) -{ -} - -VideoDataOutput::~VideoDataOutput() -{ -} - -void VideoDataOutput::handleConnectToMediaObject(MediaObject *mediaObject) -{ - Q_UNUSED(mediaObject); - setCallbacks(m_player); -} - -void VideoDataOutput::handleDisconnectFromMediaObject(MediaObject *mediaObject) -{ - Q_UNUSED(mediaObject); - unsetCallbacks(m_player); -} - -void VideoDataOutput::handleAddToMedia(Media *media) -{ - media->addOption(":video"); -} - -Experimental::AbstractVideoDataOutput *VideoDataOutput::frontendObject() const -{ - return m_frontend; -} - -void VideoDataOutput::setFrontendObject(Experimental::AbstractVideoDataOutput *frontend) -{ - m_frontend = frontend; -} - -void *VideoDataOutput::lockCallback(void **planes) -{ - m_mutex.lock(); - DEBUG_BLOCK; - planes[0] = reinterpret_cast(m_frame.data0.data()); - planes[1] = reinterpret_cast(m_frame.data1.data()); - planes[2] = reinterpret_cast(m_frame.data2.data()); - return 0; -} - -void VideoDataOutput::unlockCallback(void *picture, void *const*planes) -{ - Q_UNUSED(picture); - Q_UNUSED(planes); - DEBUG_BLOCK; - - // For some reason VLC yields BGR24, so we swap it to RGB - if (m_frame.format == Experimental::VideoFrame2::Format_RGB888) { - uchar *data = (uchar *) m_frame.data0.data(); - uchar tmp; - for (int i = 0; i < m_frame.data0.size(); i += 3) { - tmp = data[i]; - data[i] = data[i+2]; - data[i+2] = tmp; - } - } - - if (m_frontend) - m_frontend->frameReady(m_frame); - - m_mutex.unlock(); -} - -void VideoDataOutput::displayCallback(void *picture) -{ - Q_UNUSED(picture); - DEBUG_BLOCK; - // We send the frame while unlocking as we could loose syncing otherwise. - // With VDO the consumer is expected to ensure syncness while not blocking - // unlock for long periods of time. Good luck with that... -.- -} - -static VideoFrame2::Format fourccToFormat(const char *fourcc) -{ - if (qstrcmp(fourcc, "RV24")) - return VideoFrame2::Format_RGB888; - else if (qstrcmp(fourcc, "RV32")) - return VideoFrame2::Format_RGB32; - else if (qstrcmp(fourcc, "YV12")) - return VideoFrame2::Format_YV12; - else if (qstrcmp(fourcc, "YUY2")) - return VideoFrame2::Format_YUY2; - else - return VideoFrame2::Format_Invalid; -} - -static const vlc_chroma_description_t *setFormat(VideoFrame2::Format format, char **chroma) -{ - switch (format) { - case VideoFrame2::Format_Invalid: - *chroma = 0; - return 0; - case VideoFrame2::Format_RGB32: - qstrcpy(*chroma, "RV32"); - return vlc_fourcc_GetChromaDescription(VLC_CODEC_RGB32); - case VideoFrame2::Format_RGB888: - qstrcpy(*chroma, "RV24"); - return vlc_fourcc_GetChromaDescription(VLC_CODEC_RGB24); - case VideoFrame2::Format_YV12: - qstrcpy(*chroma, "YV12"); - return vlc_fourcc_GetChromaDescription(VLC_CODEC_YV12); - case VideoFrame2::Format_YUY2: - qstrcpy(*chroma, "YUY2"); - return vlc_fourcc_GetChromaDescription(VLC_CODEC_YUYV); - } - return 0; -} - -unsigned VideoDataOutput::formatCallback(char *chroma, - unsigned *width, unsigned *height, - unsigned *pitches, unsigned *lines) -{ - DEBUG_BLOCK; - - m_frame.width = *width; - m_frame.height = *height; - - const vlc_chroma_description_t *chromaDesc = 0; - - QSet allowedFormats = m_frontend->allowedFormats(); - VideoFrame2::Format suggestedFormat = fourccToFormat(chroma); - if (suggestedFormat != VideoFrame2::Format_Invalid - && allowedFormats.contains(suggestedFormat)) { // Use suggested - chromaDesc = setFormat(suggestedFormat, &chroma); - m_frame.format = suggestedFormat; - } else { // Pick first and use that - foreach (const VideoFrame2::Format &format, allowedFormats) { - chromaDesc = setFormat(format, &chroma); - if (chroma) { - m_frame.format = format; - break; - } - } - } - - Q_ASSERT(chromaDesc); - - unsigned int bufferSize = setPitchAndLines(chromaDesc, *width, *height, pitches, lines); - - m_frame.data0.resize(pitches[0] * lines[0]); - m_frame.data1.resize(pitches[1] * lines[1]); - m_frame.data2.resize(pitches[2] * lines[0]); - - return bufferSize; -} - -void VideoDataOutput::formatCleanUpCallback() -{ - DEBUG_BLOCK; -} - -} // namespace VLC -} // namespace Phonon - -#include "phonon-vlc/video/moc_videodataoutput.h" diff --git a/src/phonon/phonon-vlc/video/videodataoutput.h b/src/phonon/phonon-vlc/video/videodataoutput.h deleted file mode 100644 index 422e06d05..000000000 --- a/src/phonon/phonon-vlc/video/videodataoutput.h +++ /dev/null @@ -1,74 +0,0 @@ -/* - Copyright (C) 2012 Harald Sitter - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . -*/ - -#ifndef Phonon_VLC_VIDEODATAOUTPUT_H -#define Phonon_VLC_VIDEODATAOUTPUT_H - -#include -#include - -#include -#include - -#include "sinknode.h" -#include "videomemorystream.h" - -namespace Phonon -{ -namespace VLC -{ - -/** - * @author Harald Sitter - */ -class VideoDataOutput : public QObject, public SinkNode, - public Experimental::VideoDataOutputInterface, private VideoMemoryStream -{ - Q_OBJECT - Q_INTERFACES(Phonon::Experimental::VideoDataOutputInterface) -public: - explicit VideoDataOutput(QObject *parent); - ~VideoDataOutput(); - - void handleConnectToMediaObject(MediaObject *mediaObject); - void handleDisconnectFromMediaObject(MediaObject *mediaObject); - void handleAddToMedia(Media *media); - - Experimental::AbstractVideoDataOutput *frontendObject() const; - void setFrontendObject(Experimental::AbstractVideoDataOutput *frontend); - - virtual void *lockCallback(void **planes); - virtual void unlockCallback(void *picture,void *const *planes); - virtual void displayCallback(void *picture); - - virtual unsigned formatCallback(char *chroma, - unsigned *width, unsigned *height, - unsigned *pitches, - unsigned *lines); - virtual void formatCleanUpCallback(); - -private: - Experimental::AbstractVideoDataOutput *m_frontend; - Experimental::VideoFrame2 m_frame; - QByteArray m_buffer; - QMutex m_mutex; -}; - -} // namespace VLC -} // namespace Phonon - -#endif // PHONON_VLC_VIDEODATAOUTPUT_H diff --git a/src/phonon/phonon-vlc/video/videographicsobject.cpp b/src/phonon/phonon-vlc/video/videographicsobject.cpp deleted file mode 100644 index e8c850c59..000000000 --- a/src/phonon/phonon-vlc/video/videographicsobject.cpp +++ /dev/null @@ -1,178 +0,0 @@ -/* - Copyright (C) 2011-2012 Harald Sitter - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . -*/ - -#include "videographicsobject.h" - -#include - -#include "utils/debug.h" -#include "mediaobject.h" - -namespace Phonon { -namespace VLC { - -VideoGraphicsObject::VideoGraphicsObject(QObject *parent) : - QObject(parent), - m_chosenFormat(VideoFrame::Format_Invalid) -{ - DEBUG_BLOCK; - m_frame.format = VideoFrame::Format_Invalid; -} - -VideoGraphicsObject::~VideoGraphicsObject() -{ - DEBUG_BLOCK; - m_mutex.lock(); -} - -void VideoGraphicsObject::connectToMediaObject(MediaObject *mediaObject) -{ - DEBUG_BLOCK; - SinkNode::connectToMediaObject(mediaObject); - setCallbacks(m_player); -} - -void VideoGraphicsObject::disconnectFromMediaObject(MediaObject *mediaObject) -{ - // Try to prevent callbacks called after this object is being deleted - if (m_mediaObject) { - m_mediaObject->stop(); - } - - unsetCallbacks(m_player); - SinkNode::disconnectFromMediaObject(mediaObject); -} - -void VideoGraphicsObject::lock() -{ - m_mutex.lock(); -} - -bool VideoGraphicsObject::tryLock() -{ - return m_mutex.tryLock(); -} - -void VideoGraphicsObject::unlock() -{ - m_mutex.unlock(); -} - -QList VideoGraphicsObject::offering(QList offers) -{ - // FIXME: impl - return offers; -} - -void VideoGraphicsObject::choose(VideoFrame::Format format) -{ - // FIXME: review - m_chosenFormat = format; -} - -void *VideoGraphicsObject::lockCallback(void **planes) -{ - lock(); - - for (unsigned int i = 0; i < m_frame.planeCount; ++i) { - planes[i] = reinterpret_cast(m_frame.plane[i].data()); - } - - return 0; // There is only one buffer, so no need to identify it. -} - -void VideoGraphicsObject::unlockCallback(void *picture, void *const*planes) -{ - Q_UNUSED(picture); - Q_UNUSED(planes); - unlock(); - // To avoid thread polution do not call frameReady directly, but via the - // event loop. - QMetaObject::invokeMethod(this, "frameReady", Qt::QueuedConnection); -} - -void VideoGraphicsObject::displayCallback(void *picture) -{ - Q_UNUSED(picture); // There is only one buffer. -} - -unsigned int VideoGraphicsObject::formatCallback(char *chroma, - unsigned *width, unsigned *height, - unsigned *pitches, unsigned *lines) -{ - DEBUG_BLOCK; - debug() << "Format:" - << "chroma:" << chroma - << "width:" << *width - << "height:" << *height - << "pitches:" << *pitches - << "lines:" << *lines; - - if (m_chosenFormat == VideoFrame::Format_Invalid) - emit needFormat(); - - Q_ASSERT(m_chosenFormat != VideoFrame::Format_Invalid); - - const vlc_chroma_description_t *chromaDesc = 0; - switch(m_chosenFormat) { - case VideoFrame::Format_RGB32: - m_frame.format = VideoFrame::Format_RGB32; - qstrcpy(chroma, "RV32"); - chromaDesc = vlc_fourcc_GetChromaDescription(VLC_CODEC_RGB32); - break; - case VideoFrame::Format_YV12: - m_frame.format = VideoFrame::Format_YV12; - qstrcpy(chroma, "YV12"); - chromaDesc = vlc_fourcc_GetChromaDescription(VLC_CODEC_YV12); - break; - case VideoFrame::Format_I420: - m_frame.format = VideoFrame::Format_I420; - qstrcpy(chroma, "I420"); - chromaDesc = vlc_fourcc_GetChromaDescription(VLC_CODEC_I420); - break; - } - - Q_ASSERT(chromaDesc); - - m_frame.width = *width; - m_frame.height = *height; - m_frame.planeCount = chromaDesc->plane_count; - - debug() << chroma; - const unsigned int bufferSize = setPitchAndLines(chromaDesc, - *width, *height, - pitches, lines, - (unsigned *) &m_frame.visiblePitch, (unsigned *)&m_frame.visibleLines); - for (unsigned int i = 0; i < m_frame.planeCount; ++i) { - m_frame.pitch[i] = pitches[i]; - m_frame.lines[i] = lines[i]; - m_frame.plane[i].resize(pitches[i] * lines[i]); - } - return bufferSize; -} - -void VideoGraphicsObject::formatCleanUpCallback() -{ - DEBUG_BLOCK; - // To avoid thread polution do not call reset directly but via the event loop. - QMetaObject::invokeMethod(this, "reset", Qt::QueuedConnection); -} - -} // namespace VLC -} // namespace Phonon - -#include "phonon-vlc/video/moc_videographicsobject.h" diff --git a/src/phonon/phonon-vlc/video/videographicsobject.h b/src/phonon/phonon-vlc/video/videographicsobject.h deleted file mode 100644 index d683a2466..000000000 --- a/src/phonon/phonon-vlc/video/videographicsobject.h +++ /dev/null @@ -1,87 +0,0 @@ -/* - Copyright (C) 2011-2012 Harald Sitter - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . -*/ - -#ifndef PHONON_VLC_VIDEOGRAPHICSOBJECT_H -#define PHONON_VLC_VIDEOGRAPHICSOBJECT_H - -#include -#include - -#include -#include - -#include - -#include "sinknode.h" -#include "videomemorystream.h" - -struct libvlc_media_t; - -namespace Phonon { -namespace VLC { - -class VideoGraphicsObject : public QObject, - public VideoGraphicsObjectInterface, - public SinkNode, - public VideoMemoryStream -{ - Q_OBJECT - Q_INTERFACES(Phonon::VideoGraphicsObjectInterface) -public: - explicit VideoGraphicsObject(QObject *parent = 0); - virtual ~VideoGraphicsObject(); - - virtual void connectToMediaObject(MediaObject *mediaObject); - virtual void disconnectFromMediaObject(MediaObject *mediaObject); - - void lock(); - bool tryLock(); - void unlock(); - - const VideoFrame *frame() const { return &m_frame; } - - Q_INVOKABLE QList offering(QList offers); - Q_INVOKABLE void choose(VideoFrame::Format format); - - virtual void *lockCallback(void **planes); - virtual void unlockCallback(void *picture,void *const *planes); - virtual void displayCallback(void *picture); - - virtual unsigned formatCallback(char *chroma, - unsigned *width, unsigned *height, - unsigned *pitches, - unsigned *lines); - virtual void formatCleanUpCallback(); - -signals: - void frameReady(); - void reset(); - - void needFormat(); - -protected: - QMutex m_mutex; - - Phonon::VideoFrame m_frame; - - Phonon::VideoFrame::Format m_chosenFormat; -}; - -} // namespace VLC -} // namespace Phonon - -#endif // PHONON_VLC_VIDEOGRAPHICSOBJECT_H diff --git a/src/phonon/phonon-vlc/video/videomemorystream.cpp b/src/phonon/phonon-vlc/video/videomemorystream.cpp deleted file mode 100644 index 6886bcf98..000000000 --- a/src/phonon/phonon-vlc/video/videomemorystream.cpp +++ /dev/null @@ -1,147 +0,0 @@ -/* - Copyright (C) 2012 Harald Sitter - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . -*/ - -#include "videomemorystream.h" - -#include "mediaplayer.h" - -namespace Phonon { -namespace VLC { - -static inline VideoMemoryStream *p_this(void *opaque) { return static_cast(opaque); } -static inline VideoMemoryStream *p_this(void **opaque) { return static_cast(*opaque); } -#define P_THIS p_this(opaque) - -VideoMemoryStream::VideoMemoryStream() -{ -} - -VideoMemoryStream::~VideoMemoryStream() -{ -} - -static inline qint64 gcd(qint64 a, qint64 b) -{ - while( b ) - { - qint64 c = a % b; - a = b; - b = c; - } - return a; -} - -static int lcm(int a, int b) -{ - return a * b / GCD( a, b ); -} - -unsigned VideoMemoryStream::setPitchAndLines(const vlc_chroma_description_t *desc, - unsigned width, unsigned height, - unsigned *pitches, unsigned *lines, - unsigned *visiblePitches, unsigned *visibleLines) -{ - // Mostly taken from vlc/src/misc/picture.c - // Simple alignment would be an option but I trust the VLC guys they know what they are doing. - int i_modulo_w = 1; - int i_modulo_h = 1; - unsigned int i_ratio_h = 1; - for( unsigned i = 0; i < desc->plane_count; i++ ) - { - i_modulo_w = lcm( i_modulo_w, 8 * desc->p[i].w.den ); - i_modulo_h = lcm( i_modulo_h, 8 * desc->p[i].h.den ); - if( i_ratio_h < desc->p[i].h.den ) - i_ratio_h = desc->p[i].h.den; - - } - i_modulo_h = lcm( i_modulo_h, 32 ); - - const int i_width_aligned = ( width + i_modulo_w - 1 ) / i_modulo_w * i_modulo_w; - const int i_height_aligned = ( height + i_modulo_h - 1 ) / i_modulo_h * i_modulo_h; - const int i_height_extra = 2 * i_ratio_h; /* This one is a hack for some ASM functions */ - - unsigned int bufferSize = 0; - for(unsigned i = 0; i < desc->plane_count; ++i) - { - pitches[i] = i_width_aligned * desc->p[i].w.num / desc->p[i].w.den * desc->pixel_size; - if (visiblePitches) - visiblePitches[i] = width * desc->p[i].w.num / desc->p[i].w.den * desc->pixel_size; - - lines[i] = (i_height_aligned + i_height_extra ) * desc->p[i].h.num / desc->p[i].h.den; - if (visibleLines) - visibleLines[i] = height * desc->p[i].h.num / desc->p[i].h.den; - - bufferSize += pitches[i] * lines[i]; - } - - return bufferSize; -} - -void VideoMemoryStream::setCallbacks(MediaPlayer *player) -{ - libvlc_video_set_callbacks(player->libvlc_media_player(), - lockCallbackInternal, - unlockCallbackInternal, - displayCallbackInternal, - this); - libvlc_video_set_format_callbacks(player->libvlc_media_player(), - formatCallbackInternal, - formatCleanUpCallbackInternal); -} - -void VideoMemoryStream::unsetCallbacks(MediaPlayer *player) -{ - libvlc_video_set_callbacks(player->libvlc_media_player(), - 0, - 0, - 0, - 0); - libvlc_video_set_format_callbacks(player->libvlc_media_player(), - 0, - 0); -} - - -void *VideoMemoryStream::lockCallbackInternal(void *opaque, void **planes) -{ - return P_THIS->lockCallback(planes); -} - -void VideoMemoryStream::unlockCallbackInternal(void *opaque, void *picture, void *const*planes) -{ - P_THIS->unlockCallback(picture, planes); -} - -void VideoMemoryStream::displayCallbackInternal(void *opaque, void *picture) -{ - P_THIS->displayCallback(picture); -} - -unsigned VideoMemoryStream::formatCallbackInternal(void **opaque, char *chroma, - unsigned *width, unsigned *height, - unsigned *pitches, unsigned *lines) -{ - return P_THIS->formatCallback(chroma, width, height, pitches, lines); -} - -void VideoMemoryStream::formatCleanUpCallbackInternal(void *opaque) -{ - P_THIS->formatCleanUpCallback(); -} - -} // namespace VLC -} // namespace Phonon diff --git a/src/phonon/phonon-vlc/video/videomemorystream.h b/src/phonon/phonon-vlc/video/videomemorystream.h deleted file mode 100644 index a5c7057d2..000000000 --- a/src/phonon/phonon-vlc/video/videomemorystream.h +++ /dev/null @@ -1,73 +0,0 @@ -/* - Copyright (C) 2012 Harald Sitter - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . -*/ - -#ifndef PHONON_VLC_VIDEOMEMORYSTREAM_H -#define PHONON_VLC_VIDEOMEMORYSTREAM_H - -#include -#include - -namespace Phonon { -namespace VLC { - -class MediaPlayer; - -class VideoMemoryStream -{ -public: - explicit VideoMemoryStream(); - virtual ~VideoMemoryStream(); - - /** - * @returns overall buffersize needed - */ - static unsigned setPitchAndLines(const vlc_chroma_description_t *chromaDescription, - unsigned width, unsigned height, - unsigned *pitches, unsigned *lines, - unsigned *visiblePitches = 0, unsigned *visibleLines = 0); - - void setCallbacks(Phonon::VLC::MediaPlayer *player); - void unsetCallbacks(Phonon::VLC::MediaPlayer *player); - -protected: - virtual void *lockCallback(void **planes) = 0; - virtual void unlockCallback(void *picture,void *const *planes) = 0; - virtual void displayCallback(void *picture) = 0; - - virtual unsigned formatCallback(char *chroma, - unsigned *width, unsigned *height, - unsigned *pitches, - unsigned *lines) = 0; - virtual void formatCleanUpCallback() = 0; - -private: - static void *lockCallbackInternal(void *opaque, void **planes); - static void unlockCallbackInternal(void *opaque, void *picture, void *const *planes); - static void displayCallbackInternal(void *opaque, void *picture); - - static unsigned formatCallbackInternal(void **opaque, char *chroma, - unsigned *width, unsigned *height, - unsigned *pitches, - unsigned *lines); - static void formatCleanUpCallbackInternal(void *opaque); - -}; - -} // namespace VLC -} // namespace Phonon - -#endif // PHONON_VLC_VIDEOMEMORYSTREAM_H diff --git a/src/phonon/phonon-vlc/video/videowidget.cpp b/src/phonon/phonon-vlc/video/videowidget.cpp deleted file mode 100644 index dac929db2..000000000 --- a/src/phonon/phonon-vlc/video/videowidget.cpp +++ /dev/null @@ -1,509 +0,0 @@ -/* - Copyright (C) 2007-2008 Tanguy Krotoff - Copyright (C) 2008 Lukas Durfina - Copyright (C) 2009 Fathi Boudra - Copyright (C) 2009-2011 vlc-phonon AUTHORS - Copyright (C) 2011-2012 Harald Sitter - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . -*/ - -#include "videowidget.h" - -#include -#include - -#include - -#include "utils/debug.h" -#include "mediaobject.h" -#include "media.h" - -#include "video/videomemorystream.h" - -namespace Phonon { -namespace VLC { - -#define DEFAULT_QSIZE QSize(320, 240) - -class SurfacePainter : public VideoMemoryStream -{ -public: - void handlePaint(QPaintEvent *event) - { - // Mind that locking here is still faster than making this lockfree by - // dispatching QEvents. - // Plus VLC can actually skip frames as necessary. - QMutexLocker lock(&m_mutex); - Q_UNUSED(event); - QPainter painter(widget); - // When using OpenGL for the QPaintEngine drawing the same QImage twice - // does not actually result in a texture change for one reason or another. - // So we simply create new iamges for every event. This is plenty cheap - // as the QImage only points to the plane data (it can't even make it - // properly shared as it does not know that the data belongs to a QBA). - painter.drawImage(drawFrameRect(), - QImage(reinterpret_cast(m_plane.constData()), - m_frame.width(), m_frame.height(), - m_frame.bytesPerLine(), m_frame.format())); - event->accept(); - } - - VideoWidget *widget; - -private: - virtual void *lockCallback(void **planes) - { - m_mutex.lock(); - planes[0] = (void *) m_plane.data(); - return 0; - } - - virtual void unlockCallback(void *picture,void *const *planes) - { - Q_UNUSED(picture); - Q_UNUSED(planes); - m_mutex.unlock(); - } - - virtual void displayCallback(void *picture) - { - Q_UNUSED(picture); - if (widget) - widget->update(); - } - - virtual unsigned formatCallback(char *chroma, - unsigned *width, unsigned *height, - unsigned *pitches, - unsigned *lines) - { - qstrcpy(chroma, "RV32"); - unsigned bufferSize = setPitchAndLines(vlc_fourcc_GetChromaDescription(VLC_CODEC_RGB32), - *width, *height, - pitches, lines); - m_plane.resize(bufferSize); - m_frame = QImage(reinterpret_cast(m_plane.constData()), - *width, *height, pitches[0], QImage::Format_RGB32); - return bufferSize; - } - - virtual void formatCleanUpCallback() - { - // Lazy delete the object to avoid callbacks from VLC after deletion. - if (!widget) - delete this; - } - - QRect scaleToAspect(QRect srcRect, int w, int h) const - { - float width = srcRect.width(); - float height = srcRect.width() * (float(h) / float(w)); - if (height > srcRect.height()) { - height = srcRect.height(); - width = srcRect.height() * (float(w) / float(h)); - } - return QRect(0, 0, (int)width, (int)height); - } - - QRect drawFrameRect() const - { - QRect widgetRect = widget->rect(); - QRect drawFrameRect; - switch (widget->aspectRatio()) { - case Phonon::VideoWidget::AspectRatioWidget: - drawFrameRect = widgetRect; - // No more calculations needed. - return drawFrameRect; - case Phonon::VideoWidget::AspectRatio4_3: - drawFrameRect = scaleToAspect(widgetRect, 4, 3); - break; - case Phonon::VideoWidget::AspectRatio16_9: - drawFrameRect = scaleToAspect(widgetRect, 16, 9); - break; - case Phonon::VideoWidget::AspectRatioAuto: - drawFrameRect = QRect(0, 0, m_frame.width(), m_frame.height()); - break; - } - - // Scale m_drawFrameRect to fill the widget - // without breaking aspect: - float widgetWidth = widgetRect.width(); - float widgetHeight = widgetRect.height(); - float frameWidth = widgetWidth; - float frameHeight = drawFrameRect.height() * float(widgetWidth) / float(drawFrameRect.width()); - - switch (widget->scaleMode()) { - case Phonon::VideoWidget::ScaleAndCrop: - if (frameHeight < widgetHeight) { - frameWidth *= float(widgetHeight) / float(frameHeight); - frameHeight = widgetHeight; - } - break; - case Phonon::VideoWidget::FitInView: - if (frameHeight > widgetHeight) { - frameWidth *= float(widgetHeight) / float(frameHeight); - frameHeight = widgetHeight; - } - break; - } - drawFrameRect.setSize(QSize(int(frameWidth), int(frameHeight))); - drawFrameRect.moveTo(int((widgetWidth - frameWidth) / 2.0f), - int((widgetHeight - frameHeight) / 2.0f)); - return drawFrameRect; - } - - QImage m_frame; - // We need an idependent plane as QImage needs to be forced to use the right stride/pitch. - QByteArray m_plane; - QMutex m_mutex; -}; - -VideoWidget::VideoWidget(QWidget *parent) : - BaseWidget(parent), - SinkNode(), - m_videoSize(DEFAULT_QSIZE), - m_aspectRatio(Phonon::VideoWidget::AspectRatioAuto), - m_scaleMode(Phonon::VideoWidget::FitInView), - m_filterAdjustActivated(false), - m_brightness(0.0), - m_contrast(0.0), - m_hue(0.0), - m_saturation(0.0), - m_surfacePainter(0) -{ - // We want background painting so Qt autofills with black. - setAttribute(Qt::WA_NoSystemBackground, false); - - // Required for dvdnav -#ifdef __GNUC__ -#warning dragonplayer munches on our mouse events, so clicking in a DVD menu does not work - vlc 1.2 where are thu? -#endif // __GNUC__ - setMouseTracking(true); - - // setBackgroundColor - QPalette p = palette(); - p.setColor(backgroundRole(), Qt::black); - setPalette(p); - setAutoFillBackground(true); -} - -VideoWidget::~VideoWidget() -{ - if (m_surfacePainter) - m_surfacePainter->widget = 0; // Lazy delete -} - -void VideoWidget::handleConnectToMediaObject(MediaObject *mediaObject) -{ - connect(mediaObject, SIGNAL(hasVideoChanged(bool)), - SLOT(updateVideoSize(bool))); - connect(mediaObject, SIGNAL(hasVideoChanged(bool)), - SLOT(processPendingAdjusts(bool))); - connect(mediaObject, SIGNAL(currentSourceChanged(MediaSource)), - SLOT(clearPendingAdjusts())); - - clearPendingAdjusts(); -} - -void VideoWidget::handleDisconnectFromMediaObject(MediaObject *mediaObject) -{ - // Undo all connections or path creation->destruction->creation can cause - // duplicated connections or getting singals from two different MediaObjects. - disconnect(mediaObject, 0, this, 0); -} - -void VideoWidget::handleAddToMedia(Media *media) -{ - media->addOption(":video"); - - if (!m_surfacePainter) { -#if defined(Q_OS_MAC) - m_player->setNsObject(cocoaView()); -#elif defined(Q_OS_UNIX) - m_player->setXWindow(winId()); -#elif defined(Q_OS_WIN) - m_player->setHwnd((HWND)winId()); -#endif - } -} - -Phonon::VideoWidget::AspectRatio VideoWidget::aspectRatio() const -{ - return m_aspectRatio; -} - -void VideoWidget::setAspectRatio(Phonon::VideoWidget::AspectRatio aspect) -{ - DEBUG_BLOCK; - if (!m_player) - return; - - m_aspectRatio = aspect; - - switch (m_aspectRatio) { - // FIXME: find a way to implement aspectratiowidget, it is meant to scale - // and stretch (i.e. scale to window without retaining aspect ratio). - case Phonon::VideoWidget::AspectRatioAuto: - m_player->setVideoAspectRatio(QByteArray()); - return; - case Phonon::VideoWidget::AspectRatio4_3: - m_player->setVideoAspectRatio("4:3"); - return; - case Phonon::VideoWidget::AspectRatio16_9: - m_player->setVideoAspectRatio("16:9"); - return; - } - warning() << "The aspect ratio" << aspect << "is not supported by Phonon VLC."; -} - -Phonon::VideoWidget::ScaleMode VideoWidget::scaleMode() const -{ - return m_scaleMode; -} - -void VideoWidget::setScaleMode(Phonon::VideoWidget::ScaleMode scale) -{ -#ifdef __GNUC__ -#warning OMG WTF -#endif - m_scaleMode = scale; - switch (m_scaleMode) { - } - warning() << "The scale mode" << scale << "is not supported by Phonon VLC."; -} - -qreal VideoWidget::brightness() const -{ - return m_brightness; -} - -void VideoWidget::setBrightness(qreal brightness) -{ - DEBUG_BLOCK; - if (!m_player) { - return; - } - if (!enableFilterAdjust()) { - // Add to pending adjusts - m_pendingAdjusts.insert(QByteArray("setBrightness"), brightness); - return; - } - - // VLC operates within a 0.0 to 2.0 range for brightness. - m_brightness = brightness; - m_player->setVideoAdjust(libvlc_adjust_Brightness, - phononRangeToVlcRange(m_brightness, 2.0)); -} - -qreal VideoWidget::contrast() const -{ - return m_contrast; -} - -void VideoWidget::setContrast(qreal contrast) -{ - DEBUG_BLOCK; - if (!m_player) { - return; - } - if (!enableFilterAdjust()) { - // Add to pending adjusts - m_pendingAdjusts.insert(QByteArray("setContrast"), contrast); - return; - } - - // VLC operates within a 0.0 to 2.0 range for contrast. - m_contrast = contrast; - m_player->setVideoAdjust(libvlc_adjust_Contrast, phononRangeToVlcRange(m_contrast, 2.0)); -} - -qreal VideoWidget::hue() const -{ - return m_hue; -} - -void VideoWidget::setHue(qreal hue) -{ - DEBUG_BLOCK; - if (!m_player) { - return; - } - if (!enableFilterAdjust()) { - // Add to pending adjusts - m_pendingAdjusts.insert(QByteArray("setHue"), hue); - return; - } - - // VLC operates within a 0 to 360 range for hue. - // Phonon operates on -1.0 to 1.0, so we need to consider 0 to 180 as - // 0 to 1.0 and 180 to 360 as -1 to 0.0. - // 360/0 (0) - // ___ - // / \ - // 270 (-.25) | | 90 (.25) - // \___/ - // 180 (1/-1) - // (-.25 is 360 minus 90 (vlcValue of .25). - m_hue = hue; - const int vlcValue = static_cast(phononRangeToVlcRange(qAbs(hue), 180.0, false)); - int value = 0; - if (hue >= 0) - value = vlcValue; - else - value = 360.0 - vlcValue; - m_player->setVideoAdjust(libvlc_adjust_Hue, value); -} - -qreal VideoWidget::saturation() const -{ - return m_saturation; -} - -void VideoWidget::setSaturation(qreal saturation) -{ - DEBUG_BLOCK; - if (!m_player) { - return; - } - if (!enableFilterAdjust()) { - // Add to pending adjusts - m_pendingAdjusts.insert(QByteArray("setSaturation"), saturation); - return; - } - - // VLC operates within a 0.0 to 3.0 range for saturation. - m_saturation = saturation; - m_player->setVideoAdjust(libvlc_adjust_Saturation, - phononRangeToVlcRange(m_saturation, 3.0)); -} - -QWidget *VideoWidget::widget() -{ - return this; -} - -QSize VideoWidget::sizeHint() const -{ - return m_videoSize; -} - -void VideoWidget::updateVideoSize(bool hasVideo) -{ - if (hasVideo) { - m_videoSize = m_player->videoSize(); - updateGeometry(); - update(); - } else - m_videoSize = DEFAULT_QSIZE; -} - -void VideoWidget::setVisible(bool visible) -{ - if (window() && window()->testAttribute(Qt::WA_DontShowOnScreen) && !m_surfacePainter) { - debug() << "SURFACE PAINTING"; - m_surfacePainter = new SurfacePainter; - m_surfacePainter->widget = this; - m_surfacePainter->setCallbacks(m_player); - } - QWidget::setVisible(visible); -} - -void VideoWidget::processPendingAdjusts(bool videoAvailable) -{ - if (!videoAvailable || !m_mediaObject || !m_mediaObject->hasVideo()) { - return; - } - - QHashIterator it(m_pendingAdjusts); - while (it.hasNext()) { - it.next(); - QMetaObject::invokeMethod(this, it.key().constData(), Q_ARG(qreal, it.value())); - } - m_pendingAdjusts.clear(); -} - -void VideoWidget::clearPendingAdjusts() -{ - m_pendingAdjusts.clear(); -} - -void VideoWidget::paintEvent(QPaintEvent *event) -{ - Q_UNUSED(event); - if (m_surfacePainter) - m_surfacePainter->handlePaint(event); -} - -bool VideoWidget::enableFilterAdjust(bool adjust) -{ - DEBUG_BLOCK; - // Need to check for MO here, because we can get called before a VOut is actually - // around in which case we just ignore this. - if (!m_mediaObject || !m_mediaObject->hasVideo()) { - debug() << "no mo or no video!!!"; - return false; - } - if ((!m_filterAdjustActivated && adjust) || - (m_filterAdjustActivated && !adjust)) { - debug() << "adjust: " << adjust; - m_player->setVideoAdjust(libvlc_adjust_Enable, static_cast(adjust)); - m_filterAdjustActivated = adjust; - } - return true; -} - -float VideoWidget::phononRangeToVlcRange(qreal phononValue, float upperBoundary, - bool shift) -{ - // VLC operates on different ranges than Phonon. Phonon always uses a range of - // -1:1 with 0 as the default value. - // It is therefore necessary to convert between the two schemes using sophisticated magic. - // First the incoming range is locked between -1..1, then depending on shift - // either normalized to 0..2 or 0..1 and finally a new value is calculated - // depending on the upperBoundary and the normalized range. - float value = static_cast(phononValue); - float range = 2.0; // The default normalized range will be 0..2 = 2 - - // Ensure valid range - if (value < -1.0) - value = -1.0; - else if (value > 1.0) - value = 1.0; - - if (shift) - value += 1.0; // Shift into 0..2 range - else { - // Chop negative value; normalize to 0..1 = range 1 - if (value < 0.0) - value = 0.0; - range = 1.0; - } - - return (value * (upperBoundary/range)); -} - -QImage VideoWidget::snapshot() const -{ - DEBUG_BLOCK; - if (m_player) - return m_player->snapshot(); - else - return QImage(); -} - -} // namespace VLC -} // namespace Phonon - -#include "phonon-vlc/video/moc_videowidget.h" diff --git a/src/phonon/phonon-vlc/video/videowidget.h b/src/phonon/phonon-vlc/video/videowidget.h deleted file mode 100644 index c0ed0e235..000000000 --- a/src/phonon/phonon-vlc/video/videowidget.h +++ /dev/null @@ -1,248 +0,0 @@ -/* - Copyright (C) 2007-2008 Tanguy Krotoff - Copyright (C) 2008 Lukas Durfina - Copyright (C) 2009 Fathi Boudra - Copyright (C) 2009-2011 vlc-phonon AUTHORS - Copyright (C) 2011-2012 Harald Sitter - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . -*/ - -#ifndef PHONON_VLC_VIDEOWIDGET_H -#define PHONON_VLC_VIDEOWIDGET_H - -#include - -#include - -#ifdef Q_OS_MAC -#include "video/mac/vlcmacwidget.h" -typedef VlcMacWidget BaseWidget; -#else -typedef QWidget BaseWidget; -#endif - -#include "sinknode.h" - -namespace Phonon { -namespace VLC { - -class SurfacePainter; - -/** \brief Implements the Phonon VideoWidget MediaNode, responsible for displaying video - * - * Phonon video is displayed using this widget. It implements the VideoWidgetInterface. - * It is connected to a media object that provides the video source. Methods to control - * video settings such as brightness or contrast are provided. - */ -class VideoWidget : public BaseWidget, public SinkNode, public VideoWidgetInterface44 -{ - Q_OBJECT - Q_INTERFACES(Phonon::VideoWidgetInterface44) -public: - /** - * Constructs a new VideoWidget with the given parent. The video settings members - * are set to their default values. - */ - explicit VideoWidget(QWidget *parent); - - /** - * Death to the VideoWidget! - */ - ~VideoWidget(); - - /** - * Connects the VideoWidget to a media object by setting the video widget - * window system identifier of the media object to that of the owned private - * video widget. It also connects the signal from the mediaObject regarding - * a resize of the video. - * - * If the mediaObject was connected to another VideoWidget, the connection is - * lost. - * - * \see MediaObject - * \param mediaObject What media object to connect to - * \reimp - */ - void handleConnectToMediaObject(MediaObject *mediaObject); - /** \reimp */ - void handleDisconnectFromMediaObject(MediaObject *mediaObject); - /** \reimp */ - void handleAddToMedia(Media *media); - - /** - * \return The aspect ratio previously set for the video widget - */ - Phonon::VideoWidget::AspectRatio aspectRatio() const; - - /** - * Set the aspect ratio of the video. - * VLC accepted formats are x:y (4:3, 16:9, etc...) expressing the global image aspect. - */ - void setAspectRatio(Phonon::VideoWidget::AspectRatio aspect); - - /** - * \return The scale mode previously set for the video widget - */ - Phonon::VideoWidget::ScaleMode scaleMode() const; - - /** - * Set how the video is scaled, keeping the aspect ratio into account when the video is resized. - * - * The ScaleMode enumeration describes how to treat aspect ratio during resizing of video. - * \li Phonon::VideoWidget::FitInView - the video will be fitted to fill the view keeping aspect ratio - * \li Phonon::VideoWidget::ScaleAndCrop - the video is scaled - */ - void setScaleMode(Phonon::VideoWidget::ScaleMode scale); - - /** - * \return The brightness previously set for the video widget - */ - qreal brightness() const; - - /** - * Set the brightness of the video - */ - Q_INVOKABLE void setBrightness(qreal brightness); - - /** - * \return The contrast previously set for the video widget - */ - qreal contrast() const; - - /** - * Set the contrast of the video - */ - Q_INVOKABLE void setContrast(qreal contrast); - - /** - * \return The hue previously set for the video widget - */ - qreal hue() const; - - /** - * Set the hue of the video - */ - Q_INVOKABLE void setHue(qreal hue); - - /** - * \return The saturation previously set for the video widget - */ - qreal saturation() const; - - /** - * Set the saturation of the video - */ - Q_INVOKABLE void setSaturation(qreal saturation); - - /** - * \return The owned widget that is used for the actual draw. - */ - QWidget *widget(); - - /// \reimp - QSize sizeHint() const; - - void setVisible(bool visible); - -private slots: - /// Updates the sizeHint to match the native size of the video. - /// \param hasVideo \c true when there is a video, \c false otherwise - void updateVideoSize(bool hasVideo); - - /** - * Sets all pending video adjusts (hue, brightness etc.) that the application - * wanted to set before the vidoe became available. - * - * \param videoAvailable whether or not video is available at the time of calling - */ - void processPendingAdjusts(bool videoAvailable); - - /** - * Clears all pending video adjusts (hue, brightness etc.). - */ - void clearPendingAdjusts(); - -protected: - /// \reimp - void paintEvent(QPaintEvent *event); - -private: - /** - * Sets whether filter adjust is active or not. - * - * \param adjust true if adjust is supposed to be activated, false if not - * - * \returns whether the adjust request was accepted, if not the callee should - * add the request to m_pendingAdjusts for later processing once a video - * became available. Adjusts get accepted always except when - * MediaObject::hasVideo() is false, so it is not related to the - * actual execution of the request. - */ - bool enableFilterAdjust(bool adjust = true); - - /** - * Converts a Phonon range to a VLC value range. - * - * A Phonon range is always a qreal between -1.0 and 1.0, a VLC range however - * can be any between 0 and 360. This functon maps the Phonon value to an - * appropriate value within a specified target range. - * - * \param phononValue the incoming Phonon specific value, should be -1.0:1.0 - * should it however not be within that range will it be - * manually locked (i.e. exceeding values become either -1.0 or 1.0) - * \param upperBoundary the upper boundary for the target range. The lower - * boundary is currently always assumed to be 0 - * \param shift whether or not to shift the Phonon range to positive values - * before mapping to VLC values (useful when our 0 must be a VLC 0). - * Please note that if you do not shift the range will be reduced to - * 0:1, phononValue < 0 will be set to 0. - * - * \returns float usable to VLC - */ - static float phononRangeToVlcRange(qreal phononValue, float upperBoundary, - bool shift = true); - - /** - * \return The snapshot of the current video frame. - */ - QImage snapshot() const; - - /** - * Pending video adjusts the application tried to set before we actually - * had a video to set them on. - */ - QHash m_pendingAdjusts; - - /** - * Original size of the video, needed for sizeHint(). - */ - QSize m_videoSize; - - Phonon::VideoWidget::AspectRatio m_aspectRatio; - Phonon::VideoWidget::ScaleMode m_scaleMode; - - bool m_filterAdjustActivated; - qreal m_brightness; - qreal m_contrast; - qreal m_hue; - qreal m_saturation; - - SurfacePainter *m_surfacePainter; -}; - -} // namespace VLC -} // namespace Phonon - -#endif // PHONON_VLC_VIDEOWIDGET_H diff --git a/src/phonon/phonon-vlc/vlc.desktop.cmake b/src/phonon/phonon-vlc/vlc.desktop.cmake deleted file mode 100644 index df2f7bed2..000000000 --- a/src/phonon/phonon-vlc/vlc.desktop.cmake +++ /dev/null @@ -1,105 +0,0 @@ -[Desktop Entry] -Type=Service -X-KDE-ServiceTypes=PhononBackend -MimeType=@PHONON_VLC_MIME_TYPES@; -X-KDE-Library=phonon_vlc -X-KDE-PhononBackendInfo-InterfaceVersion=1 -X-KDE-PhononBackendInfo-Version=@PHONON_VLC_VERSION@ -X-KDE-PhononBackendInfo-Website=http://www.videolan.org/ -Icon=vlc -InitialPreference=20 - -Name=VLC -Name[ast]=VLC -Name[bg]=VLC -Name[bs]=VLC -Name[ca]=VLC -Name[ca@valencia]=VLC -Name[cs]=VLC -Name[da]=VLC -Name[de]=VLC -Name[el]=VLC -Name[en_GB]=VLC -Name[es]=VLC -Name[et]=VLC -Name[eu]=VLC -Name[fa]=وی‌ال‌سی (VLC) -Name[fi]=VLC -Name[fr]=VLC -Name[ga]=VLC -Name[gl]=VLC -Name[hu]=VLC -Name[it]=VLC -Name[kk]=VLC -Name[ko]=VLC -Name[lt]=VLC -Name[mr]=व्ही-एल-सी -Name[nb]=VLC -Name[nds]=VLC -Name[nl]=VLC -Name[pa]=VLC -Name[pl]=VLC -Name[pt]=VLC -Name[pt_BR]=VLC -Name[ro]=VLC -Name[ru]=VLC -Name[sk]=VLC -Name[sl]=VLC -Name[sr]=ВЛЦ -Name[sr@ijekavian]=ВЛЦ -Name[sr@ijekavianlatin]=VLC -Name[sr@latin]=VLC -Name[sv]=VLC -Name[tr]=VLC -Name[ug]=VLC -Name[uk]=VLC -Name[x-test]=xxVLCxx -Name[zh_CN]=VLC -Name[zh_TW]=VLC - -Comment=Phonon VLC backend -Comment[bg]=Ядро VLC за Phonon -Comment[bs]=VLC kao pozadina za Phonon -Comment[ca]=Dorsal del VLC pel Phonon -Comment[ca@valencia]=Dorsal del VLC pel Phonon -Comment[cs]=Podpůrná vrstva VLC -Comment[da]=Phonon VLC-motor -Comment[de]=Phonon-Treiber für VLC -Comment[el]=Σύστημα υποστήριξης Phonon VLC -Comment[en_GB]=Phonon VLC backend -Comment[es]=Motor VLC para Phonon -Comment[et]=Phononi VLC taustaprogramm -Comment[eu]=Phonon-en VLC bizkarraldekoa -Comment[fa]=پسانه‌ی وی‌ال‌سی برای فنون (Phonon VLC backend) -Comment[fi]=Phonon VLC -taustajärjestelmä -Comment[fr]=Module VLC pour Phonon -Comment[ga]=Inneall VLC Phonon -Comment[gl]=Infraestrutura de VLC para Phonon -Comment[hu]=Phonon VLC-backend -Comment[it]=Motore VLC di Phonon -Comment[kk]=Phonon VLC тетігі -Comment[ko]=Phonon VLC 백엔드 -Comment[lt]=Phonon VLC galinė sąsaja -Comment[mr]=फोनॉन व्ही-एल-सी बॅकएन्ड -Comment[nb]=Phonon VLC-motor -Comment[nds]=VLC-Hülpprogramm för Phonon -Comment[nl]=VLC-backend van Phonon -Comment[pa]=ਫੋਨੋਨ VLC ਬੈਕਐਂਡ -Comment[pl]=Silnik VLC dla Phonon -Comment[pt]=Infra-estrutura do VLC para o Phonon -Comment[pt_BR]=Infraestrutura do VLC para o Phonon -Comment[ro]=Suportul VLC pentru Phonon -Comment[ru]=Механизм VLC для Phonon -Comment[sk]=Backend Phonon VLC -Comment[sl]=Zaledje VLC za Phonon -Comment[sr]=ВЛЦ као позадина Фонона -Comment[sr@ijekavian]=ВЛЦ као позадина Фонона -Comment[sr@ijekavianlatin]=VLC kao pozadina Phonona -Comment[sr@latin]=VLC kao pozadina Phonona -Comment[sv]=Phonon VLC-gränssnitt -Comment[tr]=Phonon VLC arka ucu -Comment[ug]=Phonon VLC ئارقا ئۇچى -Comment[uk]=Модуль VLC Phonon -Comment[x-test]=xxPhonon VLC backendxx -Comment[zh_CN]= Phonon VLC 后端 -Comment[zh_TW]=Phonon VLC 後端介面 diff --git a/src/phonon/phonon_export.h b/src/phonon/phonon_export.h deleted file mode 100644 index 52d50cf81..000000000 --- a/src/phonon/phonon_export.h +++ /dev/null @@ -1,52 +0,0 @@ -/* - Copyright (C) 2007 Matthias Kretz - Copyright (C) 2011 Harald Sitter - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), Nokia Corporation - (or its successors, if any) and the KDE Free Qt Foundation, which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . -*/ - -#ifndef PHONON_EXPORT_H -#define PHONON_EXPORT_H - -#include - -#ifndef PHONON_EXPORT -# if defined Q_WS_WIN -# ifdef MAKE_PHONON_LIB /* We are building this library */ -# define PHONON_EXPORT Q_DECL_EXPORT -# else /* We are using this library */ -# define PHONON_EXPORT Q_DECL_IMPORT -# endif -# else /* UNIX */ -# ifdef MAKE_PHONON_LIB /* We are building this library */ -# define PHONON_EXPORT Q_DECL_EXPORT -# else /* We are using this library */ -# define PHONON_EXPORT Q_DECL_IMPORT -# endif -# endif -#endif - -#ifndef PHONON_DEPRECATED -# define PHONON_DEPRECATED Q_DECL_DEPRECATED -#endif - -#ifndef PHONON_EXPORT_DEPRECATED -# define PHONON_EXPORT_DEPRECATED Q_DECL_DEPRECATED PHONON_EXPORT -#endif - -#endif diff --git a/src/phonon/phononconfig_p.h.in b/src/phonon/phononconfig_p.h.in deleted file mode 100644 index 72beca3a9..000000000 --- a/src/phonon/phononconfig_p.h.in +++ /dev/null @@ -1,16 +0,0 @@ -/* Phonon definitions from CMake */ - -#ifndef PHONONCONFIG_H_P -#define PHONONCONFIG_H_P - -#include - -/** Whether to build with D-Bus support */ -#cmakedefine PHONON_NO_DBUS_DEFINE - -/** If QT_NO_DBUS is defined, always set PHONON_NO_DBUS */ -#if !defined(PHONON_NO_DBUS) && defined(QT_NO_DBUS) -#define PHONON_NO_DBUS 1 -#endif - -#endif // PHONONCONFIG_H_P diff --git a/src/phonon/phonondefs.h b/src/phonon/phonondefs.h deleted file mode 100644 index b9ed10801..000000000 --- a/src/phonon/phonondefs.h +++ /dev/null @@ -1,149 +0,0 @@ -/* This file is part of the KDE project - Copyright (C) 2006-2007 Matthias Kretz - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), Nokia Corporation - (or its successors, if any) and the KDE Free Qt Foundation, which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . - -*/ - -#ifndef PHONONDEFS_H -#define PHONONDEFS_H - -#include -#include "phonon_export.h" - -#ifdef PHONON_BACKEND_VERSION_4_7 -# ifndef PHONON_BACKEND_VERSION_4_4 -# define PHONON_BACKEND_VERSION_4_4 -# endif -#endif -#ifdef PHONON_BACKEND_VERSION_4_4 -# ifndef PHONON_BACKEND_VERSION_4_3 -# define PHONON_BACKEND_VERSION_4_3 -# endif -#endif -#ifdef PHONON_BACKEND_VERSION_4_3 -# ifndef PHONON_BACKEND_VERSION_4_2 -# define PHONON_BACKEND_VERSION_4_2 -# endif -#endif - -// the following inlines are correct - exclude per line doesn't work for multiline-macros so exclude -// the whole file for inline checks -//krazy:excludeall=inline -#define P_DECLARE_PRIVATE(Class) \ - inline Class##Private* k_func() { return reinterpret_cast(k_ptr); } \ - inline const Class##Private* k_func() const { return reinterpret_cast(k_ptr); } \ - friend class Class##Private; - -/** - * \internal - * Used in class declarations to provide the needed functions. This is used for - * abstract base classes. - * - * \param classname The Name of the class this macro is used for. - * - * Example: - * \code - * class AbstractEffect : public QObject - * { - * Q _OBJECT - * Q_PROPERTY(int propertyA READ propertyA WRITE setPropertyA) - * PHONON_ABSTRACTBASE(AbstractEffect) - * public: - * int propertyA() const; - * void setPropertyA(int); - * }; - * \endcode - * - * \see PHONON_OBJECT - * \see PHONON_HEIR - */ -#define PHONON_ABSTRACTBASE(classname) \ -protected: \ - /** - * \internal - * Constructor that is called from derived classes. - * - * \param parent Standard QObject parent. - */ \ - classname(classname ## Private &dd, QObject *parent); \ -private: - -/** - * \internal - * Used in class declarations to provide the needed functions. This is used for - * classes that inherit QObject directly. - * - * \param classname The Name of the class this macro is used for. - * - * Example: - * \code - * class EffectSettings : public QObject - * { - * Q _OBJECT - * Q_PROPERTY(int propertyA READ propertyA WRITE setPropertyA) - * PHONON_OBJECT(EffectSettings) - * public: - * int propertyA() const; - * void setPropertyA(int); - * }; - * \endcode - * - * \see PHONON_ABSTRACTBASE - * \see PHONON_HEIR - */ -#define PHONON_OBJECT(classname) \ -public: \ - /** - * Constructs an object with the given \p parent. - */ \ - classname(QObject *parent = 0); \ -private: - -/** - * \internal - * Used in class declarations to provide the needed functions. This is used for - * classes that inherit another Phonon object. - * - * \param classname The Name of the class this macro is used for. - * - * Example: - * \code - * class ConcreteEffect : public AbstractEffect - * { - * Q _OBJECT - * Q_PROPERTY(int propertyB READ propertyB WRITE setPropertyB) - * PHONON_HEIR(ConcreteEffect) - * public: - * int propertyB() const; - * void setPropertyB(int); - * }; - * \endcode - * - * \see PHONON_ABSTRACTBASE - * \see PHONON_OBJECT - */ -#define PHONON_HEIR(classname) \ -public: \ - /** - * Constructs an object with the given \p parent. - */ \ - classname(QObject *parent = 0); \ - - -#endif // PHONONDEFS_H diff --git a/src/phonon/phonondefs_p.h b/src/phonon/phonondefs_p.h deleted file mode 100644 index 33749ba47..000000000 --- a/src/phonon/phonondefs_p.h +++ /dev/null @@ -1,372 +0,0 @@ -/* - Copyright (C) 2006-2007 Matthias Kretz - Copyright (C) 2011 Harald Sitter - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), Nokia Corporation - (or its successors, if any) and the KDE Free Qt Foundation, which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . -*/ - -#ifndef PHONONDEFS_P_H -#define PHONONDEFS_P_H - -#include -#include "medianode_p.h" -#include "phononpimpl_p.h" - -#define PHONON_CONCAT_HELPER_INTERNAL(x, y) x ## y -#define PHONON_CONCAT_HELPER(x, y) PHONON_CONCAT_HELPER_INTERNAL(x, y) - -#define PHONON_PRIVATECLASS \ -protected: \ - virtual bool aboutToDeleteBackendObject(); \ - virtual void createBackendObject(); \ - /** - * \internal - * After construction of the Iface object this method is called - * throughout the complete class hierarchy in order to set up the - * properties that were already set on the public interface. - * - * An example implementation could look like this: - * \code - * ParentClassPrivate::setupBackendObject(); - * m_iface->setPropertyA(d->propertyA); - * m_iface->setPropertyB(d->propertyB); - * \endcode - */ \ - void setupBackendObject(); - -#define PHONON_PRIVATEABSTRACTCLASS \ -protected: \ - virtual bool aboutToDeleteBackendObject(); \ - /** - * \internal - * After construction of the Iface object this method is called - * throughout the complete class hierarchy in order to set up the - * properties that were already set on the public interface. - * - * An example implementation could look like this: - * \code - * ParentClassPrivate::setupBackendObject(); - * m_iface->setPropertyA(d->propertyA); - * m_iface->setPropertyB(d->propertyB); - * \endcode - */ \ - void setupBackendObject(); - -#define PHONON_ABSTRACTBASE_IMPL \ -PHONON_CLASSNAME::PHONON_CLASSNAME(PHONON_CONCAT_HELPER(PHONON_CLASSNAME, Private) &dd, QObject *parent) \ - : QObject(parent), \ - MediaNode(dd) \ -{ \ -} - -#define PHONON_OBJECT_IMPL \ -PHONON_CLASSNAME::PHONON_CLASSNAME(QObject *parent) \ - : QObject(parent), \ - MediaNode(*new PHONON_CONCAT_HELPER(PHONON_CLASSNAME, Private)()) \ -{ \ -} \ -void PHONON_CONCAT_HELPER(PHONON_CLASSNAME, Private)::createBackendObject() \ -{ \ - if (m_backendObject) \ - return; \ - P_Q(PHONON_CLASSNAME); \ - m_backendObject = Factory::PHONON_CONCAT_HELPER(create, PHONON_CLASSNAME)(q); \ - if (m_backendObject) { \ - setupBackendObject(); \ - } \ -} - -#define PHONON_HEIR_IMPL(parentclass) \ -PHONON_CLASSNAME::PHONON_CLASSNAME(QObject *parent) \ - : parentclass(*new PHONON_CONCAT_HELPER(PHONON_CLASSNAME, Private), parent) \ -{ \ -} \ -void PHONON_CONCAT_HELPER(PHONON_CLASSNAME, Private)::createBackendObject() \ -{ \ - if (m_backendObject) \ - return; \ - P_Q(PHONON_CLASSNAME); \ - m_backendObject = Factory::PHONON_CONCAT_HELPER(create, PHONON_CLASSNAME)(q); \ - if (m_backendObject) { \ - setupBackendObject(); \ - } \ -} - -#define BACKEND_GET(returnType, returnVar, methodName) \ -QMetaObject::invokeMethod(d->m_backendObject, methodName, Qt::DirectConnection, Q_RETURN_ARG(returnType, returnVar)) -#define BACKEND_GET1(returnType, returnVar, methodName, varType1, var1) \ -QMetaObject::invokeMethod(d->m_backendObject, methodName, Qt::DirectConnection, Q_RETURN_ARG(returnType, returnVar), Q_ARG(varType1, var1)) -#define BACKEND_GET2(returnType, returnVar, methodName, varType1, var1, varType2, var2) \ -QMetaObject::invokeMethod(d->m_backendObject, methodName, Qt::DirectConnection, Q_RETURN_ARG(returnType, returnVar), Q_ARG(varType1, var1), Q_ARG(varType2, var2)) -#define BACKEND_CALL(methodName) \ -QMetaObject::invokeMethod(d->m_backendObject, methodName, Qt::DirectConnection) -#define BACKEND_CALL1(methodName, varType1, var1) \ -QMetaObject::invokeMethod(d->m_backendObject, methodName, Qt::DirectConnection, Q_ARG(varType1, var1)) -#define BACKEND_CALL2(methodName, varType1, var1, varType2, var2) \ -QMetaObject::invokeMethod(d->m_backendObject, methodName, Qt::DirectConnection, Q_ARG(varType1, var1), Q_ARG(varType2, var2)) - -#define pBACKEND_GET(returnType, returnVar, methodName) \ -QMetaObject::invokeMethod(m_backendObject, methodName, Qt::DirectConnection, Q_RETURN_ARG(returnType, returnVar)) -#define pBACKEND_GET1(returnType, returnVar, methodName, varType1, var1) \ -QMetaObject::invokeMethod(m_backendObject, methodName, Qt::DirectConnection, Q_RETURN_ARG(returnType, returnVar), Q_ARG(varType1, var1)) -#define pBACKEND_GET2(returnType, returnVar, methodName, varType1, var1, varType2, var2) \ -QMetaObject::invokeMethod(m_backendObject, methodName, Qt::DirectConnection, Q_RETURN_ARG(returnType, returnVar), Q_ARG(varType1, var1), Q_ARG(varType2, var2)) -#define pBACKEND_CALL(methodName) \ -QMetaObject::invokeMethod(m_backendObject, methodName, Qt::DirectConnection) -#define pBACKEND_CALL1(methodName, varType1, var1) \ -QMetaObject::invokeMethod(m_backendObject, methodName, Qt::DirectConnection, Q_ARG(varType1, var1)) -#define pBACKEND_CALL2(methodName, varType1, var1, varType2, var2) \ -QMetaObject::invokeMethod(m_backendObject, methodName, Qt::DirectConnection, Q_ARG(varType1, var1), Q_ARG(varType2, var2)) - -namespace Phonon -{ - namespace - { - class NoIface; - - /// All template arguments are valid - template struct IsValid { enum { Result = true }; }; - /// except NoIface - template<> struct IsValid { enum { Result = false }; }; - - template inline T my_cast(QObject *o) { return qobject_cast(o); } - template inline T my_cast(const QObject *o) { return qobject_cast(o); } - - template<> inline NoIface *my_cast(QObject *) { return 0; } - template<> inline NoIface *my_cast(const QObject *) { return 0; } - } // anonymous namespace - - /** - * \internal - * - * \brief Helper class to cast the backend object to the correct version of the interface. - * - * Additions to the backend interfaces cannot be done by adding virtual methods as that would - * break the binary interface. So the old class is renamed and a new class with the old name - * inheriting the old class is added, containing all the new virtual methods. - * Example: - * \code - class FooInterface - { - public: - virtual ~FooInterface() {} - virtual oldMethod() = 0; - }; - Q_DECLARE_INTERFACE(FooInterface, "FooInterface0.phonon.kde.org") - * \endcode - * becomes - * \code - class FooInterface0 - { - public: - virtual ~FooInterface0() {} - virtual oldMethod() = 0; - }; - class FooInterface : public FooInterface0 - { - public: - virtual newMethod() = 0; - }; - Q_DECLARE_INTERFACE(FooInterface0, "FooInterface0.phonon.kde.org") - Q_DECLARE_INTERFACE(FooInterface, "FooInterface1.phonon.kde.org") - * \endcode - * - * With this, backends compiled against the old header can be qobject_casted to FooInterface0, - * but not to FooInterface. On the other hand backends compiled against the new header (they first - * need to implement newMethod) can only be qobject_casted to FooInterface but not to - * FooInterface0. (The qobject_cast relies on the string in Q_DECLARE_INTERFACE and not the - * class name which is why it behaves that way.) - * - * Now, in order to call oldMethod, the code needs to try to cast to both FooInterface and - * FooInterface0 (new backends will work with the former, old backends with the latter) and then - * if one of them in non-zero call oldMethod on it. - * - * To call newMethod only a cast to FooInterface needs to be done. - * - * The Iface class does all this for you for up to three (for now) interface revisions. Just - * create an object like this: - * \code - Iface iface0(d); - if (iface0) { - iface0->oldMethod(); - } - Iface iface(d); - if (iface) { - iface->newMethod(); - } - * \endcode - * - * This becomes a bit more convenient if you add macros like this: - * \code - #define IFACES1 FooInterface - #define IFACES0 FooInterface0, IFACES1 - * \endcode - * which you can use like this: - * \code - Iface iface0(d); - if (iface0) { - iface0->oldMethod(); - } - Iface iface(d); - if (iface) { - iface->newMethod(); - } - * \endcode - * With the next revision you can then change the macros to - * \code - #define IFACES2 FooInterface - #define IFACES1 FooInterface1, IFACES2 - #define IFACES0 FooInterface0, IFACES1 - * \endcode - * - * \author Matthias Kretz - */ - template - class Iface - { - public: - static inline T0 *cast(MediaNodePrivate *const d) - { - if (IsValid::Result) { - T0 *ret; - if (IsValid::Result) { - ret = reinterpret_cast(my_cast(d->m_backendObject)); - if (ret) return ret; - if (IsValid::Result) { - ret = reinterpret_cast(my_cast(d->m_backendObject)); - if (ret) return ret; - } - } - ret = reinterpret_cast(my_cast(d->m_backendObject)); - if (ret) return ret; - } - return qobject_cast(d->m_backendObject); - } - - static inline const T0 *cast(const MediaNodePrivate *const d) - { - if (IsValid::Result) { - const T0 *ret; - if (IsValid::Result) { - ret = reinterpret_cast(my_cast(d->m_backendObject)); - if (ret) return ret; - if (IsValid::Result) { - ret = reinterpret_cast(my_cast(d->m_backendObject)); - if (ret) return ret; - } - } - ret = reinterpret_cast(my_cast(d->m_backendObject)); - if (ret) return ret; - } - return qobject_cast(d->m_backendObject); - } - - inline Iface(MediaNodePrivate *const d) : iface(cast(d)) {} - inline operator T0 *() { return iface; } - inline operator const T0 *() const { return iface; } - inline T0 *operator->() { Q_ASSERT(iface); return iface; } - inline const T0 *operator->() const { Q_ASSERT(iface); return iface; } - private: - T0 *const iface; - }; - - template - class ConstIface - { - public: - inline ConstIface(const MediaNodePrivate *const d) : iface(Iface::cast(d)) {} - inline operator const T0 *() const { return iface; } - inline const T0 *operator->() const { Q_ASSERT(iface); return iface; } - private: - const T0 *const iface; - }; -} // namespace Phonon - -#define INTERFACE_CALL(function) \ -Iface::cast(d)->function - -#define pINTERFACE_CALL(function) \ -Iface::cast(this)->function - -#define PHONON_GETTER(rettype, name, retdefault) \ -rettype PHONON_CLASSNAME::name() const \ -{ \ - const PHONON_CONCAT_HELPER(PHONON_CLASSNAME, Private) *d = k_func(); \ - if (!d->m_backendObject) \ - return retdefault; \ - rettype ret; \ - BACKEND_GET(rettype, ret, #name); \ - return ret; \ -} - -#define PHONON_INTERFACE_GETTER(rettype, name, retdefault) \ -rettype PHONON_CLASSNAME::name() const \ -{ \ - const PHONON_CONCAT_HELPER(PHONON_CLASSNAME, Private) *d = k_func(); \ - if (!d->m_backendObject) \ - return retdefault; \ - return Iface::cast(d)->name(); \ -} - -#define PHONON_GETTER1(rettype, name, retdefault, argtype1, argvar1) \ -rettype PHONON_CLASSNAME::name(argtype1 argvar1) const \ -{ \ - const PHONON_CONCAT_HELPER(PHONON_CLASSNAME, Private) *d = k_func(); \ - if (!d->m_backendObject) \ - return retdefault; \ - rettype ret; \ - BACKEND_GET1(rettype, ret, #name, const QObject *, argvar1->k_ptr->backendObject()); \ - return ret; \ -} - -#define PHONON_INTERFACE_GETTER1(rettype, name, retdefault, argtype1, argvar1) \ -rettype PHONON_CLASSNAME::name(argtype1 argvar1) const \ -{ \ - const PHONON_CONCAT_HELPER(PHONON_CLASSNAME, Private) *d = k_func(); \ - if (!d->m_backendObject) \ - return retdefault; \ - return Iface::cast(d)->name(argvar1->k_ptr->backendObject()); \ -} - -#define PHONON_SETTER(functionname, privatevar, argtype1) \ -void PHONON_CLASSNAME::functionname(argtype1 x) \ -{ \ - PHONON_CONCAT_HELPER(PHONON_CLASSNAME, Private) *d = k_func(); \ - d->privatevar = x; \ - if (k_ptr->backendObject()) { \ - BACKEND_CALL1(#functionname, argtype1, x); \ - } \ -} - -#define PHONON_INTERFACE_SETTER(functionname, privatevar, argtype1) \ -void PHONON_CLASSNAME::functionname(argtype1 x) \ -{ \ - PHONON_CONCAT_HELPER(PHONON_CLASSNAME, Private) *d = k_func(); \ - d->privatevar = x; \ - if (k_ptr->backendObject()) { \ - Iface::cast(d)->functionname(x); \ - } \ -} - -#ifndef METATYPE_QLIST_INT_DEFINED -#define METATYPE_QLIST_INT_DEFINED -// Want this exactly once, see phonondefs_p.h kcm/outputdevicechoice.cpp -Q_DECLARE_METATYPE(QList) -#endif - -#endif // PHONONDEFS_P_H diff --git a/src/phonon/phononnamespace.cpp b/src/phonon/phononnamespace.cpp deleted file mode 100644 index 275f4ea00..000000000 --- a/src/phonon/phononnamespace.cpp +++ /dev/null @@ -1,232 +0,0 @@ -/* This file is part of the KDE project - Copyright (C) 2006-2007 Matthias Kretz - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), Nokia Corporation - (or its successors, if any) and the KDE Free Qt Foundation, which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . - -*/ - -#include "phononnamespace.h" -#include "phononnamespace_p.h" -#include "phonondefs_p.h" - -#include "experimental/videoframe2.h" - -#include "factory_p.h" - -#include -#include - -namespace Phonon -{ - /*! - Returns the version number of Phonon at run-time as a string (for - example, "4.0.0"). This may be a different version than the - version the application was compiled against. - - \sa PHONON_VERSION_STR - */ - const char *phononVersion() - { - return PHONON_VERSION_STR; - } - - QString categoryToString(Category c) - { - switch(c) - { - case Phonon::NoCategory: - break; - case Phonon::NotificationCategory: - return QCoreApplication::translate("Phonon::", "Notifications"); - case Phonon::MusicCategory: - return QCoreApplication::translate("Phonon::", "Music"); - case Phonon::VideoCategory: - return QCoreApplication::translate("Phonon::", "Video"); - case Phonon::CommunicationCategory: - return QCoreApplication::translate("Phonon::", "Communication"); - case Phonon::GameCategory: - return QCoreApplication::translate("Phonon::", "Games"); - case Phonon::AccessibilityCategory: - return QCoreApplication::translate("Phonon::", "Accessibility"); - } - return QString(); - } - - QString categoryToString(CaptureCategory c) - { - switch(c) - { - case Phonon::NoCategory: - break; - case Phonon::CommunicationCategory: - return QCoreApplication::translate("Phonon::", "Communication"); - case Phonon::RecordingCaptureCategory: - return QCoreApplication::translate("Phonon::", "Recording"); - case Phonon::ControlCaptureCategory: - return QCoreApplication::translate("Phonon::", "Control"); - } - return QString(); - } - - QDebug operator <<(QDebug dbg, const Phonon::DiscType &type) - { - switch (type) { - case Phonon::NoDisc: - dbg.space() << "Phonon::NoDisc"; - break; - case Phonon::Cd: - dbg.space() << "Phonon::Cd"; - break; - case Phonon::Dvd: - dbg.space() << "Phonon::Dvd"; - break; - case Phonon::Vcd: - dbg.space() << "Phonon::Vcd"; - break; - case Phonon::BluRay: - dbg.space() << "Phonon::BluRay"; - break; - } - return dbg.maybeSpace(); - } - - QDebug operator <<(QDebug dbg, const Phonon::MetaData &metaData) - { - switch (metaData) { - case Phonon::ArtistMetaData: - dbg.space() << "Phonon::ArtistMetaData"; - break; - case Phonon::AlbumMetaData: - dbg.space() << "Phonon::AlbumMetaData"; - break; - case Phonon::TitleMetaData: - dbg.space() << "Phonon::TitleMetaData"; - break; - case Phonon::DateMetaData: - dbg.space() << "Phonon::DateMetaData"; - break; - case Phonon::GenreMetaData: - dbg.space() << "Phonon::GenreMetaData"; - break; - case Phonon::TracknumberMetaData: - dbg.space() << "Phonon::TracknumberMetaData"; - break; - case Phonon::DescriptionMetaData: - dbg.space() << "Phonon::DescriptionMetaData"; - break; - case Phonon::MusicBrainzDiscIdMetaData: - dbg.space() << "Phonon::MusicBrainzDiscIdMetaData"; - break; - } - return dbg.maybeSpace(); - } - - QDebug operator <<(QDebug dbg, const Phonon::State &state) - { - switch (state) { - case Phonon::LoadingState: - dbg.space() << "Phonon::LoadingState"; - break; - case Phonon::StoppedState: - dbg.space() << "Phonon::StoppedState"; - break; - case Phonon::PlayingState: - dbg.space() << "Phonon::PlayingState"; - break; - case Phonon::BufferingState: - dbg.space() << "Phonon::BufferingState"; - break; - case Phonon::PausedState: - dbg.space() << "Phonon::PausedState"; - break; - case Phonon::ErrorState: - dbg.space() << "Phonon::ErrorState"; - break; - } - return dbg.maybeSpace(); - } - - QDebug operator <<(QDebug dbg, const Phonon::Category &category) - { - dbg.space() << categoryToString(category); - return dbg.maybeSpace(); - } - - QDebug operator <<(QDebug dbg, const Phonon::CaptureCategory &category) - { - dbg.space() << categoryToString(category); - return dbg.maybeSpace(); - } - - QDebug operator <<(QDebug dbg, const Phonon::Capture::DeviceType &type) - { - switch (type) { - case Phonon::Capture::AudioType: - dbg.space() << "Phonon::Capture::AudioType"; - break; - case Phonon::Capture::VideoType: - dbg.space() << "Phonon::Capture::VideoType"; - break; - } - return dbg.maybeSpace(); - } - - QDebug operator <<(QDebug dbg, const Phonon::ErrorType &errorType) - { - switch (errorType) { - case Phonon::NoError: - dbg.space() << "Phonon::NoError"; - break; - case Phonon::NormalError: - dbg.space() << "Phonon::NormalError"; - break; - case Phonon::FatalError: - dbg.space() << "Phonon::FatalError"; - break; - } - return dbg.maybeSpace(); - } -} - -static int registerPhononMetaTypes() -{ - qRegisterMetaType(); - qRegisterMetaType(); - qRegisterMetaType(); - qRegisterMetaType(); - - // need those for QSettings - qRegisterMetaType >(); - qRegisterMetaTypeStreamOperators >("QList"); - qRegisterMetaType(); - - qRegisterMetaType(); - qRegisterMetaTypeStreamOperators("Phonon::DeviceAccess"); - qRegisterMetaType(); - qRegisterMetaTypeStreamOperators("Phonon::DeviceAccessList"); - - return 0; // something -} - -#ifdef Q_CONSTRUCTOR_FUNCTION -Q_CONSTRUCTOR_FUNCTION(registerPhononMetaTypes) -#else -static const int _Phonon_registerMetaTypes = registerPhononMetaTypes(); -#endif - -// vim: sw=4 ts=4 diff --git a/src/phonon/phononnamespace.h.in b/src/phonon/phononnamespace.h.in deleted file mode 100644 index 177ebe7b9..000000000 --- a/src/phonon/phononnamespace.h.in +++ /dev/null @@ -1,326 +0,0 @@ -/* This file is part of the KDE project - Copyright (C) 2005-2008 Matthias Kretz - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), Nokia Corporation - (or its successors, if any) and the KDE Free Qt Foundation, which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . - -*/ - -#ifndef PHONONNAMESPACE_H -#define PHONONNAMESPACE_H - -#include "phonon_export.h" - -/** - * Helper macro that can be used like - * \code - * #if (PHONON_VERSION >= PHONON_VERSION_CHECK(4, 4, 0)) - * \endcode - */ -#define PHONON_VERSION_CHECK(major, minor, patch) ((major<<16)|(minor<<8)|(patch)) - -/** - * PHONON_VERSION is (major << 16) + (minor << 8) + patch. - */ -#define PHONON_VERSION PHONON_VERSION_CHECK(@PHONON_LIB_MAJOR_VERSION@, @PHONON_LIB_MINOR_VERSION@, @PHONON_LIB_PATCH_VERSION@) - -/** - * PHONON_VERSION_STR is "major.minor.patch". E.g. "4.2.1" - */ -#define PHONON_VERSION_STR "@PHONON_LIB_MAJOR_VERSION@.@PHONON_LIB_MINOR_VERSION@.@PHONON_LIB_PATCH_VERSION@" - -/** - * Definitions to disable capture - should end up in the backends and - * platform plugins, too - */ -#cmakedefine PHONON_NO_CAPTURE_DEFINE -#ifdef PHONON_NO_CAPTURE -#define PHONON_NO_VIDEOCAPTURE -#define PHONON_NO_AUDIOCAPTURE -#endif - - -class QString; - -/** - * \brief The %KDE Multimedia classes - * - * In this Namespace you find the classes to access Multimedia functions for - * audio and video playback. Those classes are not dependent - * on any specific framework (like they were in pre KDE4 times) but rather use - * exchangeable backends to do the work. - * - * If you want to write a new backend take a look at \ref phonon_backend_development_page. - * - * \author Matthias Kretz - */ -namespace Phonon -{ - PHONON_EXPORT const char *phononVersion(); - - /** - * Enum to identify the media discs supported by MediaObject. - * - * \see MediaSource(Phonon::DiscType, const QString &deviceName) - */ - enum DiscType { - NoDisc = -1, /** < No disc was selected. Only used as default value in - \class MediaSource */ - Cd = 0, /** < Audio CD */ - Dvd = 1, /** < Video DVD (no arbitrary data DVDs) */ - Vcd = 2, /** < Video CD */ - BluRay = 3 /** < BluRay video disc \since 4.7.0 */ - }; - - /** - * Provided as keys for MediaObject::metaData for convenience, in addition to the strings defined in - * the Ogg Vorbis specification. - */ - enum MetaData { - /** - * The artist generally considered responsible for the work. In popular - * music this is usually the performing band or singer. For classical - * music it would be the composer. For an audio book it would be the - * author of the original text. - */ - ArtistMetaData, - /** - * The collection name to which this track belongs. - */ - AlbumMetaData, - /** - * Track/Work name - */ - TitleMetaData, - /** - * Date the track was recorded - */ - DateMetaData, - /** - * A short text indication of music genre - */ - GenreMetaData, - /** - * The track number of this piece if part of a specific larger - * collection or album - */ - TracknumberMetaData, - /** - * A short text description of the contents - */ - DescriptionMetaData, - MusicBrainzDiscIdMetaData - }; - - /** - * The state the media producing object is in at the moment. - * - * \see MediaObject - */ - enum State { - /** - * After construction it might take a while before the Player is - * ready to play(). Normally this doesn't happen for local - * files, but can happen for remote files where the asynchronous - * mimetype detection and prebuffering can take a while. - */ - LoadingState, - /** - * The Player has a valid media file loaded and is ready for - * playing. - */ - StoppedState, - /** - * The Player is playing a media file. - */ - PlayingState, - /** - * The Player is waiting for data to be able to continue - * playing. - */ - BufferingState, - /** - * The Player is currently paused. - */ - PausedState, - /** - * An unrecoverable error occurred. The Object is unusable in this state. - */ - ErrorState - }; - - /** - * Set's the category your program should be listed in in the mixer. - * - * A Jukebox will set this to Music, a VoIP program to Communication, a - * DVD player to video, and so on. - * - * \note These categories can also become useful for an application that - * controls the volumes automatically, like turning down the music when a call - * comes in, or turning down the notifications when the media player knows - * it's playing classical music. - * - * \see AudioOutput::setCategory - */ - enum Category { - /** - * Will make use of the default device. - */ - NoCategory = -1, - /** - * If the sounds produced are notifications (bing, beep and such) you - * should use this category. - */ - NotificationCategory = 0, - /** - * If your application is a music player (like a jukebox or media player - * playing an audio file). - */ - MusicCategory = 1, - /** - * If the sound is the audio channel of a video. - */ - VideoCategory = 2, - /** - * If your applications produces sounds from communication with somebody - * else (VoIP, voice chat). - */ - CommunicationCategory = 3, - /** - * Sound produced by a computer game should go into this category. - */ - GameCategory = 4, - /** - * Sounds produced for accessibility (e.g. Text-To-Speech) - */ - AccessibilityCategory = 5, - /** - * \internal - * Holds the largest value of categories. - */ - LastCategory = AccessibilityCategory - }; - - /** - * What capture category does an application adhere to. Mainly - * used to decide upon what capture device will be used, depending - * on the global configuration (user preference). - * - * \see MediaObject::setVideoCaptureDevice - * \see MediaObject::setAudioCaptureDevice - * \see AvCapture - */ - enum CaptureCategory { - /** - * Will make use of the default device - */ - NoCaptureCategory = NoCategory, - - /** - * For applications that use video or audio capture for communication, - * video conference style. (VoIP, voice chat) - */ - CommunicationCaptureCategory = CommunicationCategory, - - /** - * Recording applications, that actually save the data somewhere - */ - RecordingCaptureCategory, - - /** - * Voice control. Maybe used for accesibility purpouses too - */ - ControlCaptureCategory = AccessibilityCategory - }; - - namespace Capture { - /** - * Describes the type of a capture device, audio or video - */ - enum DeviceType { - AudioType, - VideoType - }; - } - - /** - * Tells your program how to recover from an error. - * - * \see MediaObject::errorType() - */ - enum ErrorType { - /** - * No error. MediaObject::errorType() returns this if - * MediaObject::state() != Phonon::ErrorState. - */ - NoError = 0, - /** - * Playback should work, and trying with another URL should work. - */ - NormalError = 1, - /** - * Something important does not work. Your program cannot continue - * playback or capture or whatever it was trying to do - * without help from the user. - */ - FatalError = 2 - }; - - /** - * Returns a (translated) string to show to the user identifying the given - * Category. - */ - PHONON_EXPORT QString categoryToString(Category c); - - /** - * Returns a (translated) string to show to the user identifying the given - * CaptureCategory. - */ - PHONON_EXPORT QString categoryToString(CaptureCategory c); - - // TODO: naming - /*enum MediaStreamType { - Audio = 1, - Video = 2, - StillImage = 4, - Subtitle = 8, - AllMedia = 0xFFFFFFFF - }; - Q_DECLARE_FLAGS(MediaStreamTypes, MediaStreamType)*/ - - PHONON_EXPORT QDebug operator <<(QDebug dbg, const Phonon::DiscType &); - PHONON_EXPORT QDebug operator <<(QDebug dbg, const Phonon::MetaData &); - PHONON_EXPORT QDebug operator <<(QDebug dbg, const Phonon::State &); - PHONON_EXPORT QDebug operator <<(QDebug dbg, const Phonon::Category &); - PHONON_EXPORT QDebug operator <<(QDebug dbg, const Phonon::CaptureCategory &); - PHONON_EXPORT QDebug operator <<(QDebug dbg, const Phonon::Capture::DeviceType &); - PHONON_EXPORT QDebug operator <<(QDebug dbg, const Phonon::ErrorType &); - -} // namespace Phonon -//Q_DECLARE_OPERATORS_FOR_FLAGS(Phonon::MediaStreamTypes) - -#include - -Q_DECLARE_METATYPE(Phonon::State) -Q_DECLARE_METATYPE(Phonon::ErrorType) -Q_DECLARE_METATYPE(Phonon::Category) -Q_DECLARE_METATYPE(Phonon::CaptureCategory) - - - -// vim: sw=4 ts=4 tw=80 -#endif // PHONONNAMESPACE_H diff --git a/src/phonon/phononnamespace_p.h b/src/phonon/phononnamespace_p.h deleted file mode 100644 index f3633b48e..000000000 --- a/src/phonon/phononnamespace_p.h +++ /dev/null @@ -1,61 +0,0 @@ -/* This file is part of the KDE project - Copyright (C) 2005-2006 Matthias Kretz - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), Nokia Corporation - (or its successors, if any) and the KDE Free Qt Foundation, which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . -*/ - -#ifndef PHONONNAMESPACE_P_H -#define PHONONNAMESPACE_P_H - -#include "phononnamespace.h" - -#include - -#if defined(QT_NO_DEBUG) -#define pDebug if (true) {} else qDebug -#else -#define pDebug if (qgetenv("PHONON_DEBUG").isEmpty()) {} else qDebug -#endif -#define pWarning() qDebug() << "WARNING:" -#define pError() qDebug() << "ERROR:" -#define pFatal(message) qDebug() << "FATAL ERROR:" << message; ::abort() - -namespace Phonon -{ -/** - * \internal - * Converts an old Category used for capture to the dedicated CaptureCategory - * Only for internal compat purposes! - */ - inline CaptureCategory categoryToCaptureCategory(Category c) - { - switch (c) { - case NoCategory: - return NoCaptureCategory; - case CommunicationCategory: - return CommunicationCaptureCategory; - case AccessibilityCategory: - return ControlCaptureCategory; - default: - return NoCaptureCategory; - } - } -} // namespace Phonon - -// vim: sw=4 ts=4 tw=80 -#endif // PHONONNAMESPACE_P_H diff --git a/src/phonon/phononpimpl_p.h b/src/phonon/phononpimpl_p.h deleted file mode 100644 index fd286761c..000000000 --- a/src/phonon/phononpimpl_p.h +++ /dev/null @@ -1,45 +0,0 @@ -/* - Copyright (C) 2011 Harald Sitter - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), Nokia Corporation - (or its successors, if any) and the KDE Free Qt Foundation, which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . -*/ - -#ifndef PHONONPIMPL_P_H -#define PHONONPIMPL_P_H - -/** - * Declares and defines helpers to access a public class. - */ -#define P_DECLARE_PUBLIC(Class) \ - inline Class* q_func() { return static_cast(q_ptr); } \ - inline const Class* q_func() const { return static_cast(q_ptr); } \ - friend class Class; - -/** - * Get pointer to private class instance. - * \see P_DECLARE_PRIVATE - */ -#define P_D(Class) Class##Private *const d = k_func() - -/** - * Get pointer to public class instance. - * \see P_DECLARE_PUBLIC - */ -#define P_Q(Class) Class *const q = q_func() - -#endif // PHONONPIMPL_P_H diff --git a/src/phonon/platform.cpp b/src/phonon/platform.cpp deleted file mode 100644 index eea09c49c..000000000 --- a/src/phonon/platform.cpp +++ /dev/null @@ -1,157 +0,0 @@ -/* This file is part of the KDE project - Copyright (C) 2007 Matthias Kretz - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), Nokia Corporation - (or its successors, if any) and the KDE Free Qt Foundation, which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . - -*/ - -#include "platform_p.h" -#include "platformplugin.h" -#include "factory_p.h" -#include -#include -#include -#include -#include - -namespace Phonon -{ - -void Platform::saveVolume(const QString &outputName, qreal volume) -{ -#ifndef QT_NO_PHONON_PLATFORMPLUGIN - PlatformPlugin *f = Factory::platformPlugin(); - if (f) { - f->saveVolume(outputName, volume); - } -#else - Q_UNUSED(outputName); - Q_UNUSED(volume); -#endif //QT_NO_PHONON_PLATFORMPLUGIN -} - -qreal Platform::loadVolume(const QString &outputName) -{ -#ifndef QT_NO_PHONON_PLATFORMPLUGIN - const PlatformPlugin *f = Factory::platformPlugin(); - if (f) { - return f->loadVolume(outputName); - } -#else - Q_UNUSED(outputName); -#endif //QT_NO_PHONON_PLATFORMPLUGIN - return 1.0; -} - -AbstractMediaStream *Platform::createMediaStream(const QUrl &url, QObject *parent) -{ -#ifndef QT_NO_PHONON_PLATFORMPLUGIN - PlatformPlugin *f = Factory::platformPlugin(); - if (f) { - return f->createMediaStream(url, parent); - } -#else - Q_UNUSED(url); - Q_UNUSED(parent); -#endif //QT_NO_PHONON_PLATFORMPLUGIN - return 0; -} - -QIcon Platform::icon(const QString &name, QStyle *style) -{ - QIcon ret; -#ifndef QT_NO_PHONON_PLATFORMPLUGIN - if (const PlatformPlugin *f = Factory::platformPlugin()) { - ret = f->icon(name); - } -#endif //QT_NO_PHONON_PLATFORMPLUGIN - - // No platform plugin present. Use internal versions. - if (ret.isNull()) { - if (!style) { - style = QApplication::style(); - } - if (name == QLatin1String("player-volume")) { - ret = style->standardPixmap(QStyle::SP_MediaVolume); - } else if (name == QLatin1String("player-volume-muted")) { - ret = style->standardPixmap(QStyle::SP_MediaVolumeMuted); - } - } - - // Still no icon set. Use QIcon to access the platform theme. - if (ret.isNull()) - ret = QIcon::fromTheme(name); - - // Now we are getting angry... keep dropping '-foo' parts from the end of - // the name until we get something usable or run out of substrings. - // (this is a simplified version of fallback lookup as done by KIconLoader; - // essentially audio-card-pci can also be provided by audio-card which is - // the more generic version). - QString choppedName = name; - while (ret.isNull() && !choppedName.isEmpty()) { - choppedName.resize(choppedName.lastIndexOf(QChar('-'))); - ret = QIcon::fromTheme(choppedName); - } - - return ret; -} - -void Platform::notification(const char *notificationName, const QString &text, - const QStringList &actions, QObject *receiver, - const char *actionSlot) -{ -#ifndef QT_NO_PHONON_PLATFORMPLUGIN - const PlatformPlugin *f = Factory::platformPlugin(); - if (f) { - f->notification(notificationName, text, actions, receiver, actionSlot); - } -#else - Q_UNUSED(notificationName); - Q_UNUSED(text); - Q_UNUSED(actions); - Q_UNUSED(receiver); - Q_UNUSED(actionSlot); -#endif //QT_NO_PHONON_PLATFORMPLUGIN -} - -QString Platform::applicationName() -{ -#ifndef QT_NO_PHONON_PLATFORMPLUGIN - const PlatformPlugin *f = Factory::platformPlugin(); - if (f) { - return f->applicationName(); - } -#endif //QT_NO_PHONON_PLATFORMPLUGIN - QString ret = QCoreApplication::applicationName(); - if (ret.isEmpty()) - ret = QCoreApplication::applicationFilePath(); - return ret; -} - -QList > Platform::deviceAccessListFor(const Phonon::AudioOutputDevice &deviceDesc) -{ -#ifndef QT_NO_PHONON_PLATFORMPLUGIN - const PlatformPlugin *f = Factory::platformPlugin(); - if (f) { - return f->deviceAccessListFor(deviceDesc); - } -#endif //QT_NO_PHONON_PLATFORMPLUGIN - return QList >(); -} - -} // namespace Phonon diff --git a/src/phonon/platform_p.h b/src/phonon/platform_p.h deleted file mode 100644 index 293153369..000000000 --- a/src/phonon/platform_p.h +++ /dev/null @@ -1,58 +0,0 @@ -/* This file is part of the KDE project - Copyright (C) 2007 Matthias Kretz - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), Nokia Corporation - (or its successors, if any) and the KDE Free Qt Foundation, which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . - -*/ - -#ifndef PHONON_PLATFORM_P_H -#define PHONON_PLATFORM_P_H - - -#include -#include -#include -#include "phonon_export.h" -#include "objectdescription.h" - -class QIcon; -class QObject; -class QUrl; -class QStyle; - -namespace Phonon -{ -class AbstractMediaStream; - -namespace Platform -{ - -void saveVolume(const QString &outputName, qreal volume); -qreal loadVolume(const QString &outputName); -AbstractMediaStream *createMediaStream(const QUrl &url, QObject *parent); -QIcon icon(const QString &name, QStyle *style = 0); -void notification(const char *notificationName, const QString &text, - const QStringList &actions = QStringList(), QObject *receiver = 0, - const char *actionSlot = 0); -QString applicationName(); -QList > deviceAccessListFor(const Phonon::AudioOutputDevice &deviceDesc); - -} // namespace Platform -} // namespace Phonon - -#endif // PHONON_PLATFORM_P_H diff --git a/src/phonon/platformplugin.h b/src/phonon/platformplugin.h deleted file mode 100644 index 29bc0af88..000000000 --- a/src/phonon/platformplugin.h +++ /dev/null @@ -1,131 +0,0 @@ -/* This file is part of the KDE project - Copyright (C) 2007-2008 Matthias Kretz - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), Nokia Corporation - (or its successors, if any) and the KDE Free Qt Foundation, which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . - -*/ - -#ifndef PHONON_PLATFORMPLUGIN_H -#define PHONON_PLATFORMPLUGIN_H - -#include -#include -#include -#include "phonon_export.h" -#include "objectdescription.h" - - -#ifndef QT_NO_PHONON_PLATFORMPLUGIN - -class QUrl; -class QObject; -class QIcon; - -namespace Phonon -{ -class AbstractMediaStream; - -class PlatformPlugin -{ - public: - virtual ~PlatformPlugin() {} - - /** - * Creates a AbstractMediaStream object that provides the data for the given \p url. On KDE - * this uses KIO. - */ - virtual AbstractMediaStream *createMediaStream(const QUrl &url, QObject *parent) = 0; - - /** - * Returns the icon for the given icon name. - */ - virtual QIcon icon(const QString &name) const = 0; - - /** - * Shows a notification popup - */ - virtual void notification(const char *notificationName, const QString &text, - const QStringList &actions = QStringList(), QObject *receiver = 0, - const char *actionSlot = 0) const = 0; - - /** - * Returns the name of the application. For most Qt application this is - * QCoreApplication::applicationName(), but for KDE this is overridden by KAboutData. - */ - virtual QString applicationName() const = 0; - - /** - * Creates a backend object. This way the platform can decide the backend preference. - */ - virtual QObject *createBackend() = 0; - - /** - * Using the library loader of the platform, loads a given backend. - */ - virtual QObject *createBackend(const QString &library, const QString &version) = 0; - - /** - * Tries to check whether the default backend supports a given MIME type without loading the - * actual backend library. On KDE this reads the MIME type list from the .desktop file of - * the backend. - */ - virtual bool isMimeTypeAvailable(const QString &mimeType) const = 0; - - /** - * Saves the volume for the given output. - */ - virtual void saveVolume(const QString &outputName, qreal volume) = 0; - - /** - * Loads the volume for the given output. - */ - virtual qreal loadVolume(const QString &outputName) const = 0; - - virtual QList objectDescriptionIndexes(ObjectDescriptionType type) const = 0; - virtual QHash objectDescriptionProperties(ObjectDescriptionType type, int index) const = 0; - - /** - * Returns a list of (driver, handle) pairs for the given AudioOutputDevice description. - * Implementation is optional. - */ - virtual DeviceAccessList deviceAccessListFor(const AudioOutputDevice &) const { return DeviceAccessList(); } - -#ifndef PHONON_NO_AUDIOCAPTURE - /** - * Returns a list of (driver, handle) pairs for the given AudioCaptureDevice description. - * Implementation is optional. - */ - virtual DeviceAccessList deviceAccessListFor(const AudioCaptureDevice &) const { return DeviceAccessList(); } -#endif // PHONON_NO_AUDIOCAPTURE - -#ifndef PHONON_NO_VIDEOCAPTURE - /** - * Returns a list of (driver, handle) pairs for the given VideoCaptureDevice description. - * Implementation is optional. - */ - virtual DeviceAccessList deviceAccessListFor(const VideoCaptureDevice &) const { return DeviceAccessList(); } -#endif // PHONON_NO_VIDEOCAPTURE -}; -} // namespace Phonon - -Q_DECLARE_INTERFACE(Phonon::PlatformPlugin, "3PlatformPlugin.phonon.kde.org") - -#endif //QT_NO_PHONON_PLATFORMPLUGIN - - -#endif // PHONON_PLATFORMPLUGIN_H diff --git a/src/phonon/qsettingsgroup_p.h b/src/phonon/qsettingsgroup_p.h deleted file mode 100644 index 801b38d8a..000000000 --- a/src/phonon/qsettingsgroup_p.h +++ /dev/null @@ -1,90 +0,0 @@ -/* This file is part of the KDE project - Copyright (C) 2007 Matthias Kretz - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), Nokia Corporation - (or its successors, if any) and the KDE Free Qt Foundation, which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . - -*/ - -#ifndef PHONON_QSETTINGSGROUP_P_H -#define PHONON_QSETTINGSGROUP_P_H - -#include -#include -#include - -#ifndef QT_NO_PHONON_SETTINGSGROUP - - -namespace Phonon -{ -class QSettingsGroup -{ - public: - inline QSettingsGroup(QSettings *settings, const QString &name) - : m_mutableSettings(settings), - m_settings(settings), - m_group(name + QLatin1Char('/')) - { - } - - inline QSettingsGroup(const QSettings *settings, const QString &name) - : m_mutableSettings(0), - m_settings(settings), - m_group(name + QLatin1Char('/')) - { - } - - template - inline T value(const QString &key, const T &def) const - { - return qvariant_cast(value(key, qVariantFromValue(def))); - } - - inline QVariant value(const QString &key, const QVariant &def) const - { - return m_settings->value(m_group + key, def); - } - - template - inline void setValue(const QString &key, const T &value) - { - Q_ASSERT(m_mutableSettings); - m_mutableSettings->setValue(m_group + key, qVariantFromValue(value)); - } - - inline void removeEntry(const QString &key) - { - Q_ASSERT(m_mutableSettings); - m_mutableSettings->remove(m_group + key); - } - - inline bool hasKey(const QString &key) const - { - return m_settings->contains(m_group + key); - } - - private: - QSettings *const m_mutableSettings; - const QSettings *const m_settings; - QString m_group; -}; -} // namespace Phonon - -#endif //QT_NO_PHONON_SETTINGSGROUP - -#endif // PHONON_QSETTINGSGROUP_P_H diff --git a/src/phonon/seekslider.cpp b/src/phonon/seekslider.cpp deleted file mode 100644 index 4863ab71c..000000000 --- a/src/phonon/seekslider.cpp +++ /dev/null @@ -1,260 +0,0 @@ -/* This file is part of the KDE project - Copyright (C) 2006-2007 Matthias Kretz - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), Nokia Corporation - (or its successors, if any) and the KDE Free Qt Foundation, which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . - -*/ - -#include "seekslider.h" -#include "seekslider_p.h" -#include "mediaobject.h" -#include "phonondefs_p.h" - -#include -#include - -#ifndef QT_NO_PHONON_SEEKSLIDER - -namespace Phonon -{ - -SeekSlider::SeekSlider(QWidget *parent) - : QWidget(parent) - , k_ptr(new SeekSliderPrivate(this)) -{ - P_D(SeekSlider); - connect(&d->slider, SIGNAL(valueChanged(int)), SLOT(_k_seek(int))); -} - -SeekSlider::SeekSlider(MediaObject *mo, QWidget *parent) - : QWidget(parent) - , k_ptr(new SeekSliderPrivate(this)) -{ - P_D(SeekSlider); - connect(&d->slider, SIGNAL(valueChanged(int)), SLOT(_k_seek(int))); - setMediaObject(mo); -} - -/*SeekSlider::SeekSlider(SeekSliderPrivate &_d, QWidget *parent) - : QWidget(parent) - , k_ptr(&_d) -{ -} */ - -SeekSlider::~SeekSlider() -{ - delete k_ptr; -} - -void SeekSlider::setMediaObject(MediaObject *media) -{ - P_D(SeekSlider); - if (d->media) { - disconnect(d->media, 0, this, 0); - } - d->media = media; - - if (media) { - connect(media, SIGNAL(stateChanged(Phonon::State,Phonon::State)), - SLOT(_k_stateChanged(Phonon::State))); - connect(media, SIGNAL(totalTimeChanged(qint64)), SLOT(_k_length(qint64))); - connect(media, SIGNAL(tick(qint64)), SLOT(_k_tick(qint64))); - connect(media, SIGNAL(seekableChanged(bool)), SLOT(_k_seekableChanged(bool))); - connect(media, SIGNAL(currentSourceChanged(Phonon::MediaSource)), SLOT(_k_currentSourceChanged())); - d->_k_stateChanged(media->state()); - d->_k_seekableChanged(media->isSeekable()); - d->_k_length(media->totalTime()); - } else { - d->_k_stateChanged(Phonon::StoppedState); - d->_k_seekableChanged(false); - } -} - -MediaObject *SeekSlider::mediaObject() const -{ - P_D(const SeekSlider); - return d->media; -} - -void SeekSliderPrivate::_k_seek(int msec) -{ - if (!ticking && media) { - media->seek(msec); - } -} - -void SeekSliderPrivate::_k_tick(qint64 msec) -{ - ticking = true; - slider.setValue(msec); - ticking = false; -} - -void SeekSliderPrivate::_k_length(qint64 msec) -{ - ticking = true; - slider.setRange(0, msec); - ticking = false; -} - -void SeekSliderPrivate::_k_seekableChanged(bool isSeekable) -{ - if (!isSeekable || !media) { - setEnabled(false); - } else { - switch (media->state()) { - case Phonon::PlayingState: - if (media->tickInterval() == 0) { - // if the tick signal is not enabled the slider is useless - // set the tickInterval to some common value - media->setTickInterval(350); - } - case Phonon::BufferingState: - case Phonon::PausedState: - setEnabled(true); - break; - case Phonon::StoppedState: - case Phonon::LoadingState: - case Phonon::ErrorState: - setEnabled(false); - ticking = true; - slider.setValue(0); - ticking = false; - break; - } - } -} - -void SeekSliderPrivate::_k_currentSourceChanged() -{ - //this releases the mouse and makes the seek slider stop seeking if the current source has changed - QMouseEvent event(QEvent::MouseButtonRelease, QPoint(), Qt::LeftButton, 0, 0); - QApplication::sendEvent(&slider, &event); -} - -void SeekSliderPrivate::setEnabled(bool x) -{ - slider.setEnabled(x); - iconLabel.setPixmap(icon.pixmap(iconSize, x ? QIcon::Normal : QIcon::Disabled)); -} - -void SeekSliderPrivate::_k_stateChanged(State newstate) -{ - if (!media || !media->isSeekable()) { - setEnabled(false); - return; - } - switch (newstate) { - case Phonon::PlayingState: - if (media->tickInterval() == 0) { - // if the tick signal is not enabled the slider is useless - // set the tickInterval to some common value - media->setTickInterval(350); - } - case Phonon::BufferingState: - case Phonon::PausedState: - setEnabled(true); - break; - case Phonon::StoppedState: - case Phonon::LoadingState: - case Phonon::ErrorState: - setEnabled(false); - ticking = true; - slider.setValue(0); - ticking = false; - break; - } -} - -bool SeekSlider::hasTracking() const -{ - return k_ptr->slider.hasTracking(); -} - -void SeekSlider::setTracking(bool tracking) -{ - k_ptr->slider.setTracking(tracking); -} - -int SeekSlider::pageStep() const -{ - return k_ptr->slider.pageStep(); -} - -void SeekSlider::setPageStep(int milliseconds) -{ - k_ptr->slider.setPageStep(milliseconds); -} - -int SeekSlider::singleStep() const -{ - return k_ptr->slider.singleStep(); -} - -void SeekSlider::setSingleStep(int milliseconds) -{ - k_ptr->slider.setSingleStep(milliseconds); -} - -bool SeekSlider::isIconVisible() const -{ - P_D(const SeekSlider); - return d->iconLabel.isVisible(); -} - -void SeekSlider::setIconVisible(bool vis) -{ - P_D(SeekSlider); - d->iconLabel.setVisible(vis); -} - -Qt::Orientation SeekSlider::orientation() const -{ - return k_ptr->slider.orientation(); -} - -void SeekSlider::setOrientation(Qt::Orientation o) -{ - P_D(SeekSlider); - Qt::Alignment align = (o == Qt::Horizontal ? Qt::AlignVCenter : Qt::AlignHCenter); - d->layout.setAlignment(&d->iconLabel, align); - d->layout.setAlignment(&d->slider, align); - d->layout.setDirection(o == Qt::Horizontal ? QBoxLayout::LeftToRight : QBoxLayout::TopToBottom); - d->slider.setOrientation(o); -} - -QSize SeekSlider::iconSize() const -{ - return k_ptr->iconSize; -} - -void SeekSlider::setIconSize(const QSize &iconSize) -{ - P_D(SeekSlider); - d->iconSize = iconSize; - d->iconLabel.setPixmap(d->icon.pixmap(d->iconSize, d->slider.isEnabled() ? QIcon::Normal : QIcon::Disabled)); -} - -} // namespace Phonon - -#endif //QT_NO_PHONON_SEEKSLIDER - -#include "moc_seekslider.cpp" - -// vim: sw=4 ts=4 -#include "moc_seekslider.h" diff --git a/src/phonon/seekslider.h b/src/phonon/seekslider.h deleted file mode 100644 index d749777d2..000000000 --- a/src/phonon/seekslider.h +++ /dev/null @@ -1,153 +0,0 @@ -/* This file is part of the KDE project - Copyright (C) 2006-2007 Matthias Kretz - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), Nokia Corporation - (or its successors, if any) and the KDE Free Qt Foundation, which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . - -*/ - -#ifndef PHONON_UI_SEEKSLIDER_H -#define PHONON_UI_SEEKSLIDER_H - -#include "phonon_export.h" -#include "phonondefs.h" -#include "phononnamespace.h" -#include - - -#ifndef QT_NO_PHONON_SEEKSLIDER - -namespace Phonon -{ -class MediaObject; - -class SeekSliderPrivate; - -/** \class SeekSlider seekslider.h phonon/SeekSlider - * \short Widget providing a slider for seeking in MediaObject objects. - * - * \ingroup PhononWidgets - * \author Matthias Kretz - */ -class PHONON_EXPORT SeekSlider : public QWidget -{ - Q_OBJECT - P_DECLARE_PRIVATE(SeekSlider) - /** - * This property holds whether the icon next to the slider is visible. - * - * By default the icon is visible if the platform provides an icon; else - * it's hidden. - */ - Q_PROPERTY(bool iconVisible READ isIconVisible WRITE setIconVisible) - - /** - * This property holds whether slider tracking is enabled. - * - * If tracking is enabled (the default), the media seeks - * while the slider is being dragged. If tracking is - * disabled, the media seeks only when the user - * releases the slider. - */ - Q_PROPERTY(bool tracking READ hasTracking WRITE setTracking) - - /** - * This property holds the page step. - * - * The larger of two natural steps that a slider provides and - * typically corresponds to the user pressing PageUp or PageDown. - * - * Defaults to 5 seconds. - */ - Q_PROPERTY(int pageStep READ pageStep WRITE setPageStep) - - /** - * This property holds the single step. - * - * The smaller of two natural steps that a slider provides and - * typically corresponds to the user pressing an arrow key. - * - * Defaults to 0.5 seconds. - */ - Q_PROPERTY(int singleStep READ singleStep WRITE setSingleStep) - - /** - * This property holds the orientation of the slider. - * - * The orientation must be Qt::Vertical or Qt::Horizontal (the default). - */ - Q_PROPERTY(Qt::Orientation orientation READ orientation WRITE setOrientation) - - /** - * \brief the icon size used for the mute button/icon. - * - * The default size is defined by the GUI style. - */ - Q_PROPERTY(QSize iconSize READ iconSize WRITE setIconSize) - - public: - /** - * Constructs a seek slider widget with the given \p parent. - */ - explicit SeekSlider(QWidget *parent = 0); - explicit SeekSlider(MediaObject *media, QWidget *parent = 0); - - /** - * Destroys the seek slider. - */ - ~SeekSlider(); - - bool hasTracking() const; - void setTracking(bool tracking); - int pageStep() const; - void setPageStep(int milliseconds); - int singleStep() const; - void setSingleStep(int milliseconds); - Qt::Orientation orientation() const; - bool isIconVisible() const; - QSize iconSize() const; - MediaObject *mediaObject() const; - - public Q_SLOTS: - void setOrientation(Qt::Orientation); - void setIconVisible(bool); - void setIconSize(const QSize &size); - - /** - * Sets the media object to be controlled by this slider. - */ - void setMediaObject(MediaObject *); - - protected: - SeekSliderPrivate *const k_ptr; - - private: - Q_PRIVATE_SLOT(k_func(), void _k_stateChanged(Phonon::State)) - Q_PRIVATE_SLOT(k_func(), void _k_seek(int)) - Q_PRIVATE_SLOT(k_func(), void _k_tick(qint64)) - Q_PRIVATE_SLOT(k_func(), void _k_length(qint64)) - Q_PRIVATE_SLOT(k_func(), void _k_seekableChanged(bool)) - Q_PRIVATE_SLOT(k_func(), void _k_currentSourceChanged()) -}; - -} // namespace Phonon - -#endif //QT_NO_PHONON_SEEKSLIDER - - -// vim: sw=4 ts=4 tw=80 -#endif // PHONON_UI_SEEKSLIDER_H diff --git a/src/phonon/seekslider_p.h b/src/phonon/seekslider_p.h deleted file mode 100644 index 8d19caee3..000000000 --- a/src/phonon/seekslider_p.h +++ /dev/null @@ -1,99 +0,0 @@ -/* This file is part of the KDE project - Copyright (C) 2006 Matthias Kretz - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), Nokia Corporation - (or its successors, if any) and the KDE Free Qt Foundation, which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . - -*/ - -#ifndef SEEKSLIDER_P_H -#define SEEKSLIDER_P_H - -#include -#include -#include -#include -#include -#include - -#include "factory_p.h" -#include "phonondefs_p.h" -#include "platform_p.h" -#include "seekslider.h" -#include "swiftslider_p.h" - -#ifndef QT_NO_PHONON_SEEKSLIDER - -namespace Phonon -{ -class MediaObject; -class SeekSliderPrivate -{ - P_DECLARE_PUBLIC(SeekSlider) - protected: - SeekSliderPrivate(SeekSlider *parent) - : layout(QBoxLayout::LeftToRight, parent), - slider(Qt::Horizontal, parent), - iconLabel(parent), - ticking(false) -#ifndef QT_NO_PHONON_PLATFORMPLUGIN - ,icon(Platform::icon(QLatin1String("player-time"), parent->style())) -#endif //QT_NO_PHONON_PLATFORMPLUGIN - { - const int e = parent->style()->pixelMetric(QStyle::PM_ButtonIconSize); - iconSize = QSize(e, e); - - slider.setPageStep(5000); // 5 sec - slider.setSingleStep(500); // 0.5 sec - - layout.setMargin(0); - layout.setSpacing(2); - layout.addWidget(&iconLabel, 0, Qt::AlignVCenter); - layout.addWidget(&slider, 0, Qt::AlignVCenter); - - setEnabled(false); - - if (icon.isNull()) { - iconLabel.setVisible(false); - } - } - - SeekSlider *q_ptr; - - private: - void setEnabled(bool); - void _k_stateChanged(Phonon::State); - void _k_seek(int); - void _k_tick(qint64); - void _k_length(qint64); - void _k_seekableChanged(bool); - void _k_currentSourceChanged(); - - QBoxLayout layout; - SwiftSlider slider; - QLabel iconLabel; - QPointer media; - bool ticking; - QIcon icon; - QSize iconSize; -}; -} // namespace Phonon - -#endif //QT_NO_PHONON_SEEKSLIDER - -#endif // SEEKSLIDER_P_H -// vim: sw=4 ts=4 tw=80 diff --git a/src/phonon/statesvalidator.cpp b/src/phonon/statesvalidator.cpp deleted file mode 100644 index 59a7c3653..000000000 --- a/src/phonon/statesvalidator.cpp +++ /dev/null @@ -1,207 +0,0 @@ -/* - Copyright (C) 2012 Trever Fischer - Copyright (C) 2012 Harald Sitter - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), Nokia Corporation - (or its successors, if any) and the KDE Free Qt Foundation, which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . -*/ - -#include "statesvalidator_p.h" - -#include "mediaobject.h" -#include "phononnamespace_p.h" - -#ifdef PHONON_ASSERT_STATES -#define P_INVALID_STATE(msg) Q_ASSERT_X(0, __FILE__, msg) -#else -#define P_INVALID_STATE(msg) pDebug() << "State assert failed:" << msg -#endif - -namespace Phonon -{ - -StatesValidator::StatesValidator(MediaObject *parent) - : QObject(parent) - , m_mediaObject(parent) - , m_prevState(Phonon::ErrorState) - , m_sourceQueued(false) - , m_aboutToFinishEmitted(false) - , m_aboutToFinishBeforeSeek(false) - , m_aboutToFinishPos(-1) -{ - connect(m_mediaObject, SIGNAL(stateChanged(Phonon::State,Phonon::State)), - this, SLOT(validateStateChange(Phonon::State,Phonon::State))); - connect(m_mediaObject, SIGNAL(currentSourceChanged(Phonon::MediaSource)), - this, SLOT(validateSourceChange())); - connect(m_mediaObject, SIGNAL(tick(qint64)), this, SLOT(validateTick(qint64))); - connect(m_mediaObject, SIGNAL(aboutToFinish()), this, SLOT(validateAboutToFinish())); - connect(m_mediaObject, SIGNAL(finished()), this, SLOT(validateFinished())); - connect(m_mediaObject, SIGNAL(bufferStatus(int)), this, SLOT(validateBufferStatus())); -} - -StatesValidator::~StatesValidator() -{ -} - -/** - * The aboutToFinish signal is emitted when the queue is coming to an end. - * This in particular means that it must not be emitted twice, unless no track - * is in the queue and the user seeked back in time before finished - * Since we track the frontend signal here, we only get this signal when the - * queue is in fact empty in the frontend. - * It can however happen that the frontend already delivered the last queue item, - * then the user seeks and the backend forgets to use the already delivered item, - * emitting a bogus aboutToFinish. - */ -void StatesValidator::validateAboutToFinish() -{ - if (m_aboutToFinishEmitted) { - P_INVALID_STATE("aboutToFinish emitted more than once!"); - } - m_aboutToFinishEmitted = true; - m_aboutToFinishPos = m_pos; -} - -void StatesValidator::validateFinished() -{ - if (m_mediaObject->state() != Phonon::PlayingState) { - P_INVALID_STATE("Playback finished when we weren't playing!"); - } -} - -void StatesValidator::validateSourceChange() -{ - if (m_mediaObject->state() != Phonon::StoppedState - && m_mediaObject->state() != Phonon::PlayingState - && m_mediaObject->state() != Phonon::PausedState - && m_mediaObject->state() != Phonon::BufferingState) { - P_INVALID_STATE("Source got changed outside a valid state"); - } - m_sourceQueued = false; // Once we get the signal the backend internal one-source queue is definitely cleared. - m_aboutToFinishEmitted = false; - m_aboutToFinishBeforeSeek = false; -} - -void StatesValidator::validateBufferStatus() -{ - if (m_mediaObject->state() != Phonon::PlayingState - && m_mediaObject->state() != Phonon::PausedState - && m_mediaObject->state() != Phonon::BufferingState) { - P_INVALID_STATE("Buffer status changed when we weren't supposed to be buffering"); - } -} - -void StatesValidator::validateTick(qint64 pos) -{ - // Mind that Buffering is a concurrent state, you may have been playing and - // then start buffering for example for a seek. - if (m_mediaObject->state() != Phonon::PlayingState - && (m_prevState != Phonon::PlayingState - && m_mediaObject->state() != Phonon::BufferingState)) { - P_INVALID_STATE("Received tick outside of Playing state."); - } - // If and only if we did not queue a new source may a seek back in time - // result in a reemission of the signal. It should not, but it is allowed. - // Point being, if the API consumer did not set one the first time, they - // likely will not care about it a second time either. - if (m_aboutToFinishEmitted && (pos < m_aboutToFinishPos) && !m_sourceQueued) - m_aboutToFinishEmitted = false; - m_pos = pos; -} - -void StatesValidator::validateStateChange(Phonon::State newstate, Phonon::State oldstate) -{ - if (!validateStateTransition(newstate, oldstate)) { - pDebug() << "Invalid state transition:" << oldstate << "->" << newstate; - P_INVALID_STATE("Invalid state transition"); - } else { - pDebug() << "Valid state transition:" << oldstate << "->" << newstate; - } - m_prevState = oldstate; -} - -bool StatesValidator::validateStateTransition(Phonon::State newstate, Phonon::State oldstate) -{ - // Non-playback states trigger a reset of aboutToFinish. - switch (oldstate) { - case Phonon::StoppedState: - switch (newstate) { - case Phonon::LoadingState: - case Phonon::PlayingState: - case Phonon::PausedState: - return true; - default: - return false; - } - break; - case Phonon::LoadingState: - switch (newstate) { - case Phonon::ErrorState: - case Phonon::StoppedState: - return true; - default: - return false; - } - break; - case Phonon::ErrorState: - switch (newstate) { - case Phonon::LoadingState: - return true; - default: - return false; - } - break; - case Phonon::PlayingState: - switch (newstate) { - case Phonon::PausedState: - case Phonon::BufferingState: - case Phonon::ErrorState: - case Phonon::StoppedState: - return true; - default: - return false; - } - break; - case Phonon::PausedState: - switch (newstate) { - case Phonon::PlayingState: - case Phonon::BufferingState: - case Phonon::ErrorState: - case Phonon::StoppedState: - return true; - default: - return false; - } - break; - case Phonon::BufferingState: - switch (newstate) { - case Phonon::PlayingState: - case Phonon::PausedState: - case Phonon::ErrorState: -// TODO: buffering state needs fixing, should not transit to stop - case Phonon::StoppedState: - return true; - default: - return false; - } - } - return false; -} - -} // namespace Phonon - -#include "moc_statesvalidator_p.h" diff --git a/src/phonon/statesvalidator_p.h b/src/phonon/statesvalidator_p.h deleted file mode 100644 index a27280254..000000000 --- a/src/phonon/statesvalidator_p.h +++ /dev/null @@ -1,69 +0,0 @@ -/* - Copyright (C) 2012 Trever Fischer - Copyright (C) 2012 Harald Sitter - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), Nokia Corporation - (or its successors, if any) and the KDE Free Qt Foundation, which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . -*/ - -#ifndef PHONON_STATESVALIDATOR_P_H -#define PHONON_STATESVALIDATOR_P_H - -#include - -#include "phononnamespace.h" - -namespace Phonon -{ - -class MediaObject; - -class StatesValidator : public QObject -{ - Q_OBJECT -public: - explicit StatesValidator(MediaObject *parent = 0); - ~StatesValidator(); - - inline void sourceQueued() { m_sourceQueued = true; } - -private slots: - void validateStateChange(Phonon::State, Phonon::State); - void validateTick(qint64 tick); - void validateAboutToFinish(); - void validateFinished(); - void validateBufferStatus(); - void validateSourceChange(); - -private: - bool validateStateTransition(Phonon::State newstate, Phonon::State oldstate); - - MediaObject *m_mediaObject; - - Phonon::State m_prevState; /** < Track prev state to do a better job at Buffering validation */ - - bool m_sourceQueued; /** < Track whether a source was queued in the backend */ - qint64 m_pos; /** < Track position for abouttofinish validation */ - - bool m_aboutToFinishEmitted; - bool m_aboutToFinishBeforeSeek; /** < True when a seek was conducted before a source change */ - qint64 m_aboutToFinishPos; /** < Position when abouttofinish was emitted */ -}; - -} // namespace Phonon - -#endif // PHONON_STATESVALIDATOR_P_H diff --git a/src/phonon/streaminterface.cpp b/src/phonon/streaminterface.cpp deleted file mode 100644 index 2e9311b3b..000000000 --- a/src/phonon/streaminterface.cpp +++ /dev/null @@ -1,113 +0,0 @@ -/* This file is part of the KDE project - Copyright (C) 2007 Matthias Kretz - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), Nokia Corporation - (or its successors, if any) and the KDE Free Qt Foundation, which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . - -*/ - -#include "streaminterface.h" -#include "streaminterface_p.h" -#include "abstractmediastream.h" -#include "abstractmediastream_p.h" -#include "mediasource_p.h" - -#ifndef QT_NO_PHONON_ABSTRACTMEDIASTREAM - -namespace Phonon -{ - -StreamInterface::StreamInterface() - : d(new StreamInterfacePrivate) -{ - d->q = this; -} - -StreamInterface::~StreamInterface() -{ - if (d->connected) { - AbstractMediaStreamPrivate *dd = d->mediaSource.stream()->d_func(); - dd->setStreamInterface(0); - } - delete d; -} - -void StreamInterface::connectToSource(const MediaSource &mediaSource) -{ - Q_ASSERT(!d->connected); - d->connected = true; - d->mediaSource = mediaSource; - Q_ASSERT(d->mediaSource.type() == MediaSource::Stream); - Q_ASSERT(d->mediaSource.stream()); - AbstractMediaStreamPrivate *dd = d->mediaSource.stream()->d_func(); - dd->setStreamInterface(this); - // Operations above do not access the stream itself, so they do not need to - // use invokeMethod. - reset(); -} - -// Does not need to use invokeMethod as we are are not accessing the stream. -void StreamInterfacePrivate::disconnectMediaStream() -{ - Q_ASSERT(connected); - connected = false; - - // if mediaSource has autoDelete set then it will delete the AbstractMediaStream again who's - // destructor is calling us right now - mediaSource.setAutoDelete(false); - - mediaSource = MediaSource(); - q->endOfData(); - q->setStreamSeekable(false); -} - -void StreamInterface::needData() -{ - if (d->mediaSource.type() == MediaSource::Stream) { - QMetaObject::invokeMethod(d->mediaSource.stream(), "needData", Qt::QueuedConnection); - } -} - -void StreamInterface::enoughData() -{ - Q_ASSERT(d->connected); - if (d->mediaSource.type() == MediaSource::Stream) { - QMetaObject::invokeMethod(d->mediaSource.stream(), "enoughData", Qt::QueuedConnection); - } -} - -void StreamInterface::seekStream(qint64 offset) -{ - Q_ASSERT(d->connected); - if (d->mediaSource.type() == MediaSource::Stream) { - QMetaObject::invokeMethod(d->mediaSource.stream(), "seekStream", Qt::QueuedConnection, Q_ARG(qint64, offset)); - } -} - -void StreamInterface::reset() -{ - Q_ASSERT(d->connected); - if (d->mediaSource.type() == MediaSource::Stream) { - QMetaObject::invokeMethod(d->mediaSource.stream(), "reset", Qt::QueuedConnection); - } -} - -} // namespace Phonon - -#endif //QT_NO_PHONON_ABSTRACTMEDIASTREAM - - diff --git a/src/phonon/streaminterface.h b/src/phonon/streaminterface.h deleted file mode 100644 index 240806dc1..000000000 --- a/src/phonon/streaminterface.h +++ /dev/null @@ -1,137 +0,0 @@ -/* - Copyright (C) 2007 Matthias Kretz - Copyright (C) 2011 Harald Sitter - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), Nokia Corporation - (or its successors, if any) and the KDE Free Qt Foundation, which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . -*/ - -#ifndef PHONON_STREAMINTERFACE_H -#define PHONON_STREAMINTERFACE_H - -#include "phonon_export.h" -#include - - -#ifndef QT_NO_PHONON_ABSTRACTMEDIASTREAM - -namespace Phonon -{ -class StreamInterfacePrivate; -class MediaSource; - -/** \class StreamInterface streaminterface.h phonon/StreamInterface - * \brief Backend interface to handle media streams (AbstractMediaStream). - * - * All functions relay their calls to the AbstractMediaStream using invokeMethod on the - * AbstractMediaStream's QMetaObject. This means that every function call will - * actually be executed in the thread context of the AbstractMediaStream (which - * usually is a thread Phonon also lives in, could however also be another one). - * This protectes the AbstractMediaStream against calls from different threads, - * such as a callback thread. - * This is very important as most IO implementations are by default not - * thread-safe. - * - * This protection is only established in one direction though, meaning that a - * backend implementation of this interface must be made thread-safe at all costs - * as it can get called from any thread. - * - * \author Matthias Kretz - */ -class PHONON_EXPORT StreamInterface -{ - friend class StreamInterfacePrivate; - friend class AbstractMediaStreamPrivate; - public: - virtual ~StreamInterface(); - - /** - * Called by the application to send a chunk of (encoded) media data. - * - * It is recommended to keep the QByteArray object until the data is consumed so that no - * memcopy is needed. - */ - virtual void writeData(const QByteArray &data) = 0; - - /** - * Called when no more media data is available and writeData will not be called anymore. - */ - virtual void endOfData() = 0; - - /** - * Called at the start of the stream to tell how many bytes will be sent through writeData - * (if no seeks happen, of course). If this value is negative the stream size cannot be - * determined (might be a "theoretically infinite" stream - like webradio). - */ - virtual void setStreamSize(qint64 newSize) = 0; - - /** - * Tells whether the stream is seekable. - */ - virtual void setStreamSeekable(bool s) = 0; - - /** - * Call this function from the constructor of your StreamInterface implementation (or as - * soon as you get the MediaSource object). This will connect your object to the - * AbstractMediaStream object. Only after the connection is done will the following - * functions have an effect. - */ - void connectToSource(const MediaSource &mediaSource); - - /** - * Call this function to tell the AbstractMediaStream that you need more data. The data will - * arrive through writeData. - * writeData() will not be called from needData() due to the thread protection of - * the AbstractMediaStream. - * - * Depending on the buffering you need you either treat needData as a replacement for a - * read call like QIODevice::read, or you start calling needData whenever your buffer - * reaches a certain lower threshold. - */ - void needData(); - - /** - * Call this function to tell the AbstractMediaStream that you have enough data in your - * buffer and that it should pause calling writeData if possible. - */ - void enoughData(); - - /** - * If the stream is seekable, calling this function will make the next call to writeData - * pass data that starts at the byte offset \p seekTo. - */ - void seekStream(qint64 seekTo); - - /** - * Resets the AbstractMediaStream. E.g. this can be useful for non-seekable streams to start - * over again. - */ - void reset(); - - protected: - StreamInterface(); - - StreamInterfacePrivate *const d; -}; -} // namespace Phonon - -Q_DECLARE_INTERFACE(Phonon::StreamInterface, "StreamInterface1.phonon.kde.org") - -#endif //QT_NO_PHONON_ABSTRACTMEDIASTREAM - - -#endif // PHONON_STREAMINTERFACE_H diff --git a/src/phonon/streaminterface_p.h b/src/phonon/streaminterface_p.h deleted file mode 100644 index 6cf0901ee..000000000 --- a/src/phonon/streaminterface_p.h +++ /dev/null @@ -1,55 +0,0 @@ -/* This file is part of the KDE project - Copyright (C) 2007 Matthias Kretz - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), Nokia Corporation - (or its successors, if any) and the KDE Free Qt Foundation, which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . - -*/ - -#ifndef STREAMINTERFACE_P_H -#define STREAMINTERFACE_P_H - -#include "streaminterface.h" -#include "mediasource.h" - -#ifndef QT_NO_PHONON_ABSTRACTMEDIASTREAM - -namespace Phonon -{ -class StreamInterfacePrivate -{ - friend class StreamInterface; - public: - void disconnectMediaStream(); - - protected: - inline StreamInterfacePrivate() - : connected(false) - { - } - - StreamInterface *q; - MediaSource mediaSource; - bool connected; -}; - -} // namespace Phonon - -#endif // QT_NO_PHONON_ABSTRACTMEDIASTREAM - -#endif // STREAMINTERFACE_P_H -// vim: sw=4 sts=4 et tw=100 diff --git a/src/phonon/swiftslider.cpp b/src/phonon/swiftslider.cpp deleted file mode 100644 index a1e3c4dea..000000000 --- a/src/phonon/swiftslider.cpp +++ /dev/null @@ -1,109 +0,0 @@ -/* This file is part of the KDE project - Copyright (C) 2006-2008 Ricardo Villalba - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), Nokia Corporation - (or its successors, if any) and the KDE Free Qt Foundation, which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . - -*/ - -#include "swiftslider_p.h" - -#include -#include -#include - -#if !defined(QT_NO_PHONON_SEEKSLIDER) && !defined(QT_NO_PHONON_VOLUMESLIDER) - -namespace Phonon -{ - -SwiftSlider::SwiftSlider(Qt::Orientation orientation, QWidget * parent) - : QSlider(orientation, parent) - , m_wheelTimer(this) -{ - m_wheelTimer.setInterval(100); - m_wheelTimer.setSingleShot(true); - connect(&m_wheelTimer, SIGNAL(timeout()), this, SIGNAL(scrollEnd())); -} - -SwiftSlider::~SwiftSlider() -{ -} - -// Function copied from qslider.cpp -inline int SwiftSlider::pick(const QPoint &pt) const -{ - return orientation() == Qt::Horizontal ? pt.x() : pt.y(); -} - -// Function copied from qslider.cpp and modified to make it compile -int SwiftSlider::pixelPosToRangeValue(int pos) const -{ - QStyleOptionSlider opt; - initStyleOption(&opt); - QRect gr = style()->subControlRect(QStyle::CC_Slider, &opt, QStyle::SC_SliderGroove, this); - QRect sr = style()->subControlRect(QStyle::CC_Slider, &opt, QStyle::SC_SliderHandle, this); - int sliderMin, sliderMax, sliderLength; - - if (orientation() == Qt::Horizontal) { - sliderLength = sr.width(); - sliderMin = gr.x(); - sliderMax = gr.right() - sliderLength + 1; - } else { - sliderLength = sr.height(); - sliderMin = gr.y(); - sliderMax = gr.bottom() - sliderLength + 1; - } - return QStyle::sliderValueFromPosition(minimum(), maximum(), pos - sliderMin, - sliderMax - sliderMin, opt.upsideDown); -} - -// Based on code from qslider.cpp -void SwiftSlider::mousePressEvent(QMouseEvent *event) -{ - if (event->button() == Qt::LeftButton) { - QStyleOptionSlider opt; - initStyleOption(&opt); - const QRect sliderRect = style()->subControlRect(QStyle::CC_Slider, &opt, QStyle::SC_SliderHandle, this); - const QPoint center = sliderRect.center() - sliderRect.topLeft(); - // to take half of the slider off for the setSliderPosition call we use the center - topLeft - - if (!sliderRect.contains(event->pos())) { - event->accept(); - - setSliderPosition(pixelPosToRangeValue(pick(event->pos() - center))); - triggerAction(SliderMove); - setRepeatAction(SliderNoAction); - } else { - QSlider::mousePressEvent(event); - } - } else { - QSlider::mousePressEvent(event); - } -} - -void SwiftSlider::wheelEvent(QWheelEvent *event) -{ - m_wheelTimer.start(); - QSlider::wheelEvent(event); -} - -} // namespace Phonon - -#endif //QT_NO_PHONON_VOLUMESLIDER && QT_NO_PHONON_VOLUMESLIDER - -#include "moc_swiftslider_p.h" diff --git a/src/phonon/swiftslider_p.h b/src/phonon/swiftslider_p.h deleted file mode 100644 index 2f8613206..000000000 --- a/src/phonon/swiftslider_p.h +++ /dev/null @@ -1,72 +0,0 @@ -/* This file is part of the KDE project - Copyright (C) 2006-2008 Ricardo Villalba - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), Nokia Corporation - (or its successors, if any) and the KDE Free Qt Foundation, which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . - -*/ - -#ifndef SWIFTSLIDER_H -#define SWIFTSLIDER_H - -#include -#include - -#if !defined(QT_NO_PHONON_SEEKSLIDER) && !defined(QT_NO_PHONON_VOLUMESLIDER) - -namespace Phonon -{ - -/** \class SwiftSlider swiftslider_p.h phonon/SwiftSlider - * \short Modified QSlider that allows sudden/quick moves instead of stepped moves ("Click'n'Go" QSlider) - * - * This is an internal class used by SeekSlider and VolumeSlider. - * - * Ricardo Villalba, the original author of MySlider.cpp (from the SMPlayer project) - * gave his permission for the inclusion of this code inside Phonon by - * switching MySlider.cpp to the LGPLv2.1+ license. - * See http://smplayer.svn.sourceforge.net/viewvc/smplayer/smplayer/trunk/src/myslider.cpp?revision=2406&view=markup - * - * The original discussion about a "Click'n'Go QSlider": http://lists.trolltech.com/qt-interest/2006-11/msg00363.html - * - * \ingroup PhononWidgets - */ -class SwiftSlider : public QSlider -{ - Q_OBJECT -public: - SwiftSlider(Qt::Orientation orientation, QWidget * parent); - ~SwiftSlider(); - -signals: - void scrollStart(); - void scrollEnd(); - -private: - void mousePressEvent(QMouseEvent *event); - void wheelEvent(QWheelEvent *event); - inline int pick(const QPoint &pt) const; - int pixelPosToRangeValue(int pos) const; - - QTimer m_wheelTimer; -}; - -} // namespace Phonon - -#endif //QT_NO_PHONON_VOLUMESLIDER && QT_NO_PHONON_VOLUMESLIDER - -#endif //SWIFTSLIDER_H diff --git a/src/phonon/videoplayer.cpp b/src/phonon/videoplayer.cpp deleted file mode 100644 index df708864e..000000000 --- a/src/phonon/videoplayer.cpp +++ /dev/null @@ -1,212 +0,0 @@ -/* This file is part of the KDE project - Copyright (C) 2004-2007 Matthias Kretz - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), Nokia Corporation - (or its successors, if any) and the KDE Free Qt Foundation, which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . - -*/ - -#include "videoplayer.h" -#include "mediaobject.h" -#include "audiooutput.h" -#include "videowidget.h" -#include "path.h" -#include -#include - -#ifndef QT_NO_PHONON_VIDEOPLAYER - -namespace Phonon -{ - -class VideoPlayerPrivate -{ - public: - VideoPlayerPrivate() - : player(0) - , aoutput(0) - , voutput(0) - , category(Phonon::NoCategory) - , initialized(false) {} - - void ensureCreated() const; - - mutable MediaObject *player; - mutable AudioOutput *aoutput; - mutable VideoWidget *voutput; - - mutable MediaSource src; - mutable Phonon::Category category; - mutable bool initialized; - VideoPlayer *q_ptr; -}; - -void VideoPlayerPrivate::ensureCreated() const -{ - if (!initialized) { - initialized = true; - QVBoxLayout *layout = new QVBoxLayout(q_ptr); - layout->setMargin(0); - - aoutput = new AudioOutput(category, q_ptr); - voutput = new VideoWidget(q_ptr); - layout->addWidget(voutput); - - player = new MediaObject(q_ptr); - Phonon::createPath(player, aoutput); - Phonon::createPath(player, voutput); - - q_ptr->connect(player, SIGNAL(finished()), SIGNAL(finished())); - } -} - -VideoPlayer::VideoPlayer(Phonon::Category category, QWidget *parent) - : QWidget(parent) - , d(new VideoPlayerPrivate) -{ - d->q_ptr = this; - d->category = category; -} - -VideoPlayer::VideoPlayer(QWidget *parent) - : QWidget(parent) - , d(new VideoPlayerPrivate) -{ - d->q_ptr = this; - d->category = Phonon::VideoCategory; -} - -VideoPlayer::~VideoPlayer() -{ - delete d; -} - -MediaObject *VideoPlayer::mediaObject() const -{ - d->ensureCreated(); - return d->player; -} - -AudioOutput *VideoPlayer::audioOutput() const -{ - d->ensureCreated(); - return d->aoutput; -} - -VideoWidget *VideoPlayer::videoWidget() const -{ - d->ensureCreated(); - return d->voutput; -} - -void VideoPlayer::load(const MediaSource &source) -{ - d->ensureCreated(); - d->player->setCurrentSource(source); -} - -void VideoPlayer::play(const MediaSource &source) -{ - d->ensureCreated(); - if (source == d->player->currentSource()) { - if (!isPlaying()) - d->player->play(); - return; - } - // new URL - d->player->setCurrentSource(source); - - if (ErrorState == d->player->state()) - return; - - d->player->play(); -} - -void VideoPlayer::play() -{ - d->ensureCreated(); - d->player->play(); -} - -void VideoPlayer::pause() -{ - d->ensureCreated(); - d->player->pause(); -} - -void VideoPlayer::stop() -{ - d->ensureCreated(); - d->player->stop(); -} - -qint64 VideoPlayer::totalTime() const -{ - d->ensureCreated(); - return d->player->totalTime(); -} - -qint64 VideoPlayer::currentTime() const -{ - d->ensureCreated(); - return d->player->currentTime(); -} - -void VideoPlayer::seek(qint64 ms) -{ - d->ensureCreated(); - d->player->seek(ms); -} - -float VideoPlayer::volume() const -{ - d->ensureCreated(); - return d->aoutput->volume(); -} - -void VideoPlayer::setVolume(float v) -{ - d->ensureCreated(); - d->aoutput->setVolume(v); -} - -bool VideoPlayer::isPlaying() const -{ - d->ensureCreated(); - return (d->player->state() == PlayingState); -} - -bool VideoPlayer::isPaused() const -{ - d->ensureCreated(); - return (d->player->state() == PausedState); -} - -bool VideoPlayer::event(QEvent *e) { - if (e->type() == QEvent::Show) - d->ensureCreated(); - return QWidget::event(e); -} - -} // namespaces - -#endif //QT_NO_PHONON_VIDEOPLAYER - -#include "moc_videoplayer.cpp" - -// vim: sw=4 ts=4 -#include "moc_videoplayer.h" diff --git a/src/phonon/videoplayer.h b/src/phonon/videoplayer.h deleted file mode 100644 index 1e3e65c36..000000000 --- a/src/phonon/videoplayer.h +++ /dev/null @@ -1,204 +0,0 @@ -/* This file is part of the KDE project - Copyright (C) 2004-2007 Matthias Kretz - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), Nokia Corporation - (or its successors, if any) and the KDE Free Qt Foundation, which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . - -*/ - -#ifndef Phonon_VIDEOPLAYER_H -#define Phonon_VIDEOPLAYER_H - -#include "phonon_export.h" -#include "phononnamespace.h" -#include "mediasource.h" -#include - - -#ifndef QT_NO_PHONON_VIDEOPLAYER - -namespace Phonon -{ -class VideoPlayerPrivate; -class MediaObject; -class AudioOutput; -class VideoWidget; - -/** \class VideoPlayer videoplayer.h phonon/VideoPlayer - * \short Playback class for simple tasks. - * - * With %VideoPlayer you can get results quickly and easily. You can do the standard - * playback tasks like play, pause and stop, but also set a playback volume and - * seek (there's no guarantee that the seek will work, though). - * - * Keep in mind that when the %VideoPlayer instance is deleted the playback will - * stop. - * - * A play and forget code example: - * \code - * VideoPlayer *player = new VideoPlayer(parentWidget); - * connect(player, SIGNAL(finished()), player, SLOT(deleteLater())); - * player->play(url); - * \endcode - * - * \ingroup Playback - * \ingroup PhononVideo - * \author Matthias Kretz - */ -class PHONON_EXPORT VideoPlayer : public QWidget -{ - Q_OBJECT - public: - /** - * Constructs a new %VideoPlayer instance. - * - * \param category The category used for the audio output device. - * \param parent The QObject parent. - */ - explicit VideoPlayer(Phonon::Category category, QWidget *parent = 0); - - /** - * Constructs a new video widget with a \p parent - * using Phonon::VideoCategory as its category. - * - * \param parent The QObject parent. - */ - VideoPlayer(QWidget *parent = 0); - - /** - * On destruction the playback is stopped, also the audio output is - * removed so that the desktop mixer will not show the application - * anymore. If you need a persistent audio output don't use - * %VideoPlayer but MediaObject, VideoPath and VideoOutput. - */ - ~VideoPlayer(); - - /** - * Get the total time (in milliseconds) of the file currently being played. - */ - qint64 totalTime() const; - /** - * Get the current time (in milliseconds) of the file currently being played. - */ - qint64 currentTime() const; - /** - * This is the current volume of the output as voltage factor. - * - * 1.0 means 100%, 0.5 means 50% voltage/25% power, 0.0 means 0% - */ - float volume() const; - - /** - * \returns \c true if it is currently playing - * \returns \c false if it is currently stopped or paused - */ - bool isPlaying() const; - /** - * \returns \c true if it is currently paused - * \returns \c false if it is currently playing or stopped - */ - bool isPaused() const; - - /** - * getter for the MediaObject. - */ - MediaObject *mediaObject() const; - - /** - * getter for the AudioOutput. - */ - AudioOutput *audioOutput() const; - - /** - * getter for the VideoWidget. - */ - VideoWidget *videoWidget() const; - - public Q_SLOTS: - /** - * Starts preloading the media data and fill audiobuffers in the - * backend. - * - * When there's already a media playing (or paused) it will be stopped - * (the finished signal will not be emitted). - */ - void load(const Phonon::MediaSource &source); - - /** - * Play the media at the given URL. Starts playback as fast as possible. - * This can take a considerable time depending on the URL and the - * backend. - * - * If you need low latency between calling play() and the sound actually - * starting to play on your output device you need to use MediaObject - * and be able to set the URL before calling play(). Note that - * \code - * audioPlayer->load(url); - * audioPlayer->play(); - * \endcode - * doesn't make a difference: the application should be idle between the - * load and play calls so that the backend can start preloading the - * media and fill audio buffers. - */ - void play(const Phonon::MediaSource &source); - - /** - * Continues playback of a paused media. Restarts playback of a stopped - * media. - */ - void play(); - /** - * Pauses the playback. - */ - void pause(); - /** - * Stops the playback. - */ - void stop(); - - /** - * Seeks to the requested time. Note that the backend is free to ignore - * the seek request if the media source isn't seekable. - * - * \param ms Time in milliseconds from the start of the media. - */ - void seek(qint64 ms); - /** - * Sets the volume of the output as voltage factor. - * - * 1.0 means 100%, 0.5 means 50% voltage/25% power, 0.0 means 0% - */ - void setVolume(float volume); - - Q_SIGNALS: - /** - * This signal is emitted when the playback finished. - */ - void finished(); - - protected: - bool event(QEvent *); - VideoPlayerPrivate *const d; -}; - -} //namespace Phonon - -#endif //QT_NO_PHONON_VIDEOPLAYER - - -#endif // Phonon_VIDEOPLAYER_H -// vim: sw=4 ts=4 tw=80 diff --git a/src/phonon/videowidget.cpp b/src/phonon/videowidget.cpp deleted file mode 100644 index 96327d608..000000000 --- a/src/phonon/videowidget.cpp +++ /dev/null @@ -1,192 +0,0 @@ -/* This file is part of the KDE project - Copyright (C) 2005-2007 Matthias Kretz - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), Nokia Corporation - (or its successors, if any) and the KDE Free Qt Foundation, which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . - -*/ - -#include "videowidget.h" -#include "videowidget_p.h" -#include "videowidgetinterface.h" -#include "factory_p.h" -#include "phonondefs_p.h" -#include "phononnamespace_p.h" - -#include -#define IFACES4 VideoWidgetInterface44 -#define IFACES0 VideoWidgetInterface, IFACES4 -#define PHONON_INTERFACENAME IFACES0 - -#ifndef QT_NO_PHONON_VIDEO - -namespace Phonon -{ - -VideoWidget::VideoWidget(QWidget *parent) - : QWidget(parent) - , Phonon::AbstractVideoOutput(*new VideoWidgetPrivate(this)) -{ - P_D(VideoWidget); - d->init(); - d->createBackendObject(); - setMouseTracking(true); -} - - - -VideoWidget::VideoWidget(VideoWidgetPrivate &dd, QWidget *parent) - : QWidget(parent), - Phonon::AbstractVideoOutput(dd) -{ - P_D(VideoWidget); - d->init(); -} - -void VideoWidgetPrivate::init() -{ - P_Q(VideoWidget); - changeFlags = q->windowFlags() & (Qt::SubWindow | Qt::Window); -} - -void VideoWidget::mouseMoveEvent(QMouseEvent *e) -{ - QWidget::mouseMoveEvent(e); -} - -void VideoWidgetPrivate::createBackendObject() -{ - if (m_backendObject) - return; - P_Q(VideoWidget); - m_backendObject = Factory::createVideoWidget(q); - if (m_backendObject) { - setupBackendObject(); - } -} - -#define PHONON_CLASSNAME VideoWidget - -PHONON_INTERFACE_GETTER(Phonon::VideoWidget::AspectRatio, aspectRatio, d->aspectRatio) -PHONON_INTERFACE_SETTER(setAspectRatio, aspectRatio, Phonon::VideoWidget::AspectRatio) - -PHONON_INTERFACE_GETTER(Phonon::VideoWidget::ScaleMode, scaleMode, d->scaleMode) -PHONON_INTERFACE_SETTER(setScaleMode, scaleMode, Phonon::VideoWidget::ScaleMode) - -PHONON_INTERFACE_GETTER(qreal, brightness, d->brightness) -PHONON_INTERFACE_SETTER(setBrightness, brightness, qreal) - -PHONON_INTERFACE_GETTER(qreal, contrast, d->contrast) -PHONON_INTERFACE_SETTER(setContrast, contrast, qreal) - -PHONON_INTERFACE_GETTER(qreal, hue, d->hue) -PHONON_INTERFACE_SETTER(setHue, hue, qreal) - -PHONON_INTERFACE_GETTER(qreal, saturation, d->saturation) -PHONON_INTERFACE_SETTER(setSaturation, saturation, qreal) - - -QImage VideoWidget::snapshot() const { - P_D(const VideoWidget); - ConstIface iface(d); - if(iface) return iface->snapshot(); - return QImage(); // TODO not implemented in VideoInterface -} - - -void VideoWidget::setFullScreen(bool newFullScreen) -{ - pDebug() << Q_FUNC_INFO << newFullScreen; - P_D(VideoWidget); - // TODO: disable screensaver? or should we leave that responsibility to the - // application? - Qt::WindowFlags flags = windowFlags(); - if (newFullScreen) { - if (!isFullScreen()) { - //we only update that value if it is not already fullscreen - d->changeFlags = flags & (Qt::Window | Qt::SubWindow); - flags |= Qt::Window; - flags ^= Qt::SubWindow; - setWindowFlags(flags); -#ifdef Q_WS_X11 - // This works around a bug with Compiz - // as the window must be visible before we can set the state - show(); - raise(); - setWindowState( windowState() | Qt::WindowFullScreen ); // set -#else - setWindowState( windowState() | Qt::WindowFullScreen ); // set - show(); -#endif - } - } else if (isFullScreen()) { - flags ^= (Qt::Window | Qt::SubWindow); //clear the flags... - flags |= d->changeFlags; //then we reset the flags (window and subwindow) - setWindowFlags(flags); - setWindowState( windowState() ^ Qt::WindowFullScreen ); // reset - show(); - } -} - -void VideoWidget::exitFullScreen() -{ - setFullScreen(false); -} - -void VideoWidget::enterFullScreen() -{ - setFullScreen(true); -} - -bool VideoWidgetPrivate::aboutToDeleteBackendObject() -{ - aspectRatio = pINTERFACE_CALL(aspectRatio()); - scaleMode = pINTERFACE_CALL(scaleMode()); - return AbstractVideoOutputPrivate::aboutToDeleteBackendObject(); -} - -void VideoWidgetPrivate::setupBackendObject() -{ - P_Q(VideoWidget); - Q_ASSERT(m_backendObject); - //AbstractVideoOutputPrivate::setupBackendObject(); - pDebug() << "calling setAspectRatio on the backend " << aspectRatio; - pINTERFACE_CALL(setAspectRatio(aspectRatio)); - pINTERFACE_CALL(setScaleMode(scaleMode)); - - QWidget *w = pINTERFACE_CALL(widget()); - if (w) { - layout.addWidget(w); - q->setSizePolicy(w->sizePolicy()); - w->setMouseTracking(true); - } -} - -bool VideoWidget::event(QEvent *e) -{ - return QWidget::event(e); -} - -} //namespace Phonon - -#endif //QT_NO_PHONON_VIDEO - -#include "moc_videowidget.cpp" - -#undef PHONON_CLASSNAME -// vim: sw=4 ts=4 tw=80 -#include "moc_videowidget.h" diff --git a/src/phonon/videowidget.h b/src/phonon/videowidget.h deleted file mode 100644 index 86d9930e7..000000000 --- a/src/phonon/videowidget.h +++ /dev/null @@ -1,216 +0,0 @@ -/* This file is part of the KDE project - Copyright (C) 2005-2007 Matthias Kretz - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), Nokia Corporation - (or its successors, if any) and the KDE Free Qt Foundation, which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . - -*/ -#ifndef Phonon_VIDEOWIDGET_H -#define Phonon_VIDEOWIDGET_H - -#include "phonon_export.h" -#include "phonondefs.h" -#include "abstractvideooutput.h" -#include - - -class QString; - -#ifndef QT_NO_PHONON_VIDEO - -namespace Phonon -{ -class AbstractVideoOutput; - class VideoWidgetPrivate; - /** \class VideoWidget videowidget.h phonon/VideoWidget - * \short Widget to display video. - * - * This widget shows the video signal. - * - * \code - * MediaObject *media = new MediaObject(parent); - * VideoWidget *vwidget = new VideoWidget(parent); - * Phonon::createPath(media, vwidget); - * \endcode - * - * \ingroup PhononVideo - * \ingroup PhononWidgets - * \author Matthias Kretz - */ - class PHONON_EXPORT VideoWidget : public QWidget, public Phonon::AbstractVideoOutput - { - P_DECLARE_PRIVATE(VideoWidget) - Q_OBJECT - Q_ENUMS(AspectRatio ScaleMode) - /** - * This property holds whether the video is shown using the complete - * screen. - * - * The property differs from QWidget::fullScreen in that it is - * writeable. - * - * By default the widget is not shown in fullScreen. - * - * \warning When switching the video to fullscreen using setFullScreen - * your application loses control over the widget that actually shows - * the video (which is then shown as a toplevel window while your - * application still uses this widget). If you only need to capture key - * events the event forwarding done internally should suffice for your - * needs. If you need to map mouse coordinates or add widgets (that are - * not overlays) you should probably handle fullscreen yourself. - */ - Q_PROPERTY(bool fullScreen READ isFullScreen WRITE setFullScreen) - /** - * - * Defaults to AspectRatioAuto. - * - * \see AspectRatio - */ - Q_PROPERTY(AspectRatio aspectRatio READ aspectRatio WRITE setAspectRatio) - - /** - * If the size of the widget and the size of the video are not equal. - * The video will be zoomed to fit the widget. The smaller zoom - * (AddBarsScaleMode) adds black bars at the left/right or top/bottom to - * make all of the image visible (default). The bigger zoom (ExpandMode) - * fills the widget completely, keeping all information in one direction - * and leaving parts of the image outside of the widget in the other - * direction. - */ - Q_PROPERTY(ScaleMode scaleMode READ scaleMode WRITE setScaleMode) - - /** - * This property holds brightness of the video. - * - * Default is 0. Acceptable values are in range of -1, 1. - */ - Q_PROPERTY(qreal brightness READ brightness WRITE setBrightness) - /** - * This property holds the contrast of the video. - * - * Default is 0. Acceptable values are in range of -1, 1. - */ - Q_PROPERTY(qreal contrast READ contrast WRITE setContrast) - /** - * This property holds the hue of the video. - * - * Default is 0. Acceptable values are in range of -1, 1. - */ - Q_PROPERTY(qreal hue READ hue WRITE setHue) - /** - * This property holds saturation of the video. - * - * Default is 0. Acceptable values are in range of -1, 1. - */ - Q_PROPERTY(qreal saturation READ saturation WRITE setSaturation) - - public: - /** - * Defines the width:height to be used for the video. - */ - enum AspectRatio - { - /** - * Let the decoder find the aspect ratio automatically from the - * media file (this is the default). - */ - AspectRatioAuto = 0, - /** - * Fits the video into the widget making the aspect ratio depend - * solely on the size of the widget. This way the aspect ratio - * is freely resizeable by the user. - */ - AspectRatioWidget = 1, - /** - * Make width/height == 4/3, which is the old TV size and - * monitor size (1024/768 == 4/3). (4:3) - */ - AspectRatio4_3 = 2, - /** - * Make width/height == 16/9, which is the size of most current - * media. (16:9) - */ - AspectRatio16_9 = 3 -//X /** -//X * Assume that every pixel of the video image needs to be displayed with the same -//X * physical width and height. (1:1 image pixels, not imagewidth -//X * = imageheight) -//X */ -//X AspectRatioSquare = 4, - }; - - enum ScaleMode { - FitInView = 0, - ScaleAndCrop = 1 - }; - - /** - * Constructs a new video widget with a \p parent. - */ - VideoWidget(QWidget *parent = 0); - - AspectRatio aspectRatio() const; - ScaleMode scaleMode() const; - - qreal brightness() const; - qreal contrast() const; - qreal hue() const; - qreal saturation() const; - QImage snapshot() const; - - //TODO: bar colors property - public Q_SLOTS: - void setFullScreen(bool fullscreen); - - /** - * Convenience slot, calling setFullScreen(false) - */ - void exitFullScreen(); - - /** - * Convenience slot, calling setFullScreen(true) - */ - void enterFullScreen(); - - void setAspectRatio(AspectRatio); - void setScaleMode(ScaleMode); - - void setBrightness(qreal value); - void setContrast(qreal value); - void setHue(qreal value); - void setSaturation(qreal value); - - protected: - /** - * \internal - * - * Constructs a new video widget with private data pointer \p d and - * a \p parent. - */ - VideoWidget(VideoWidgetPrivate &d, QWidget *parent); - - void mouseMoveEvent(QMouseEvent *); - bool event(QEvent *); - }; - -} //namespace Phonon - -#endif //QT_NO_PHONON_VIDEO - - -// vim: sw=4 ts=4 tw=80 -#endif // Phonon_VIDEOWIDGET_H diff --git a/src/phonon/videowidget_p.h b/src/phonon/videowidget_p.h deleted file mode 100644 index cda3d1c36..000000000 --- a/src/phonon/videowidget_p.h +++ /dev/null @@ -1,75 +0,0 @@ -/* This file is part of the KDE project - Copyright (C) 2006-2007 Matthias Kretz - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), Nokia Corporation - (or its successors, if any) and the KDE Free Qt Foundation, which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . - -*/ - -#ifndef VIDEOWIDGET_P_H -#define VIDEOWIDGET_P_H - -#include "videowidget.h" -#include "abstractvideooutput_p.h" -#include - -#ifndef QT_NO_PHONON_VIDEO - -namespace Phonon -{ - -class VideoWidgetPrivate : public Phonon::AbstractVideoOutputPrivate -{ - P_DECLARE_PUBLIC(VideoWidget) - public: - virtual QObject *qObject() { return q_func(); } - protected: - virtual bool aboutToDeleteBackendObject(); - virtual void createBackendObject(); - void setupBackendObject(); - - VideoWidgetPrivate(VideoWidget *parent) - : layout(parent), - aspectRatio(VideoWidget::AspectRatioAuto), - scaleMode(VideoWidget::FitInView), - brightness(0), - contrast(0), - hue(0), - saturation(0) - { - layout.setMargin(0); - } - - QHBoxLayout layout; - VideoWidget::AspectRatio aspectRatio; - VideoWidget::ScaleMode scaleMode; - Qt::WindowFlags changeFlags; - - qreal brightness; - qreal contrast; - qreal hue; - qreal saturation; - - private: - void init(); -}; - -} // namespace Phonon - -#endif //QT_NO_PHONON_VIDEO -#endif // VIDEOWIDGET_P_H -// vim: sw=4 ts=4 tw=80 diff --git a/src/phonon/videowidgetinterface.h b/src/phonon/videowidgetinterface.h deleted file mode 100644 index ff6745eaf..000000000 --- a/src/phonon/videowidgetinterface.h +++ /dev/null @@ -1,74 +0,0 @@ -/* This file is part of the KDE project - Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), Nokia Corporation - (or its successors, if any) and the KDE Free Qt Foundation, which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . - -*/ - -#ifndef PHONON_VIDEOWIDGETINTERFACE_H -#define PHONON_VIDEOWIDGETINTERFACE_H - -#include "videowidget.h" - - -#ifndef QT_NO_PHONON_VIDEO - -namespace Phonon -{ -class VideoWidgetInterface -{ - public: - virtual ~VideoWidgetInterface() {} - - virtual Phonon::VideoWidget::AspectRatio aspectRatio() const = 0; - virtual void setAspectRatio(Phonon::VideoWidget::AspectRatio) = 0; - virtual qreal brightness() const = 0; - virtual void setBrightness(qreal) = 0; - virtual Phonon::VideoWidget::ScaleMode scaleMode() const = 0; - virtual void setScaleMode(Phonon::VideoWidget::ScaleMode) = 0; - virtual qreal contrast() const = 0; - virtual void setContrast(qreal) = 0; - virtual qreal hue() const = 0; - virtual void setHue(qreal) = 0; - virtual qreal saturation() const = 0; - virtual void setSaturation(qreal) = 0; - virtual QWidget *widget() = 0; -//X virtual int overlayCapabilities() const = 0; -//X virtual bool createOverlay(QWidget *widget, int type) = 0; -}; - -class VideoWidgetInterface44 : public VideoWidgetInterface -{ - public: - virtual QImage snapshot() const = 0; -}; -} - -#ifdef PHONON_BACKEND_VERSION_4_4 -namespace Phonon { typedef VideoWidgetInterface44 VideoWidgetInterfaceLatest; } -#else -namespace Phonon { typedef VideoWidgetInterface VideoWidgetInterfaceLatest; } -#endif - -Q_DECLARE_INTERFACE(Phonon::VideoWidgetInterface44, "VideoWidgetInterface44.phonon.kde.org") -Q_DECLARE_INTERFACE(Phonon::VideoWidgetInterface, "VideoWidgetInterface3.phonon.kde.org") - -#endif //QT_NO_PHONON_VIDEO - - -#endif // PHONON_VIDEOWIDGETINTERFACE_H diff --git a/src/phonon/volumefadereffect.cpp b/src/phonon/volumefadereffect.cpp deleted file mode 100644 index 0559093da..000000000 --- a/src/phonon/volumefadereffect.cpp +++ /dev/null @@ -1,105 +0,0 @@ -/* This file is part of the KDE project - Copyright (C) 2006 Matthias Kretz - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), Nokia Corporation - (or its successors, if any) and the KDE Free Qt Foundation, which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . - -*/ - -#include "volumefadereffect.h" -#include "volumefadereffect_p.h" -#include "volumefaderinterface.h" -#include "factory_p.h" - -#include - -#define PHONON_CLASSNAME VolumeFaderEffect -#define PHONON_INTERFACENAME VolumeFaderInterface - -#ifndef QT_NO_PHONON_VOLUMEFADEREFFECT - -namespace Phonon -{ -PHONON_HEIR_IMPL(Effect) - -PHONON_INTERFACE_GETTER(float, volume, d->currentVolume) -PHONON_INTERFACE_SETTER(setVolume, currentVolume, float) -PHONON_INTERFACE_GETTER(Phonon::VolumeFaderEffect::FadeCurve, fadeCurve, d->fadeCurve) -PHONON_INTERFACE_SETTER(setFadeCurve, fadeCurve, Phonon::VolumeFaderEffect::FadeCurve) - -#ifndef PHONON_LOG10OVER20 -#define PHONON_LOG10OVER20 -static const double log10over20 = 0.1151292546497022842; // ln(10) / 20 -#endif // PHONON_LOG10OVER20 - -double VolumeFaderEffect::volumeDecibel() const -{ - return log(volume()) / log10over20; -} - -void VolumeFaderEffect::setVolumeDecibel(double newVolumeDecibel) -{ - setVolume(exp(newVolumeDecibel * log10over20)); -} - - -void VolumeFaderEffect::fadeIn(int fadeTime) -{ - fadeTo(1.0, fadeTime); -} - -void VolumeFaderEffect::fadeOut(int fadeTime) -{ - fadeTo(0.0, fadeTime); -} - -void VolumeFaderEffect::fadeTo(float volume, int fadeTime) -{ - P_D(VolumeFaderEffect); - if (k_ptr->backendObject()) - INTERFACE_CALL(fadeTo(volume, fadeTime)); - else - d->currentVolume = volume; -} - -bool VolumeFaderEffectPrivate::aboutToDeleteBackendObject() -{ - if (m_backendObject) { - currentVolume = pINTERFACE_CALL(volume()); - fadeCurve = pINTERFACE_CALL(fadeCurve()); - } - return true; -} - -void VolumeFaderEffectPrivate::setupBackendObject() -{ - Q_ASSERT(m_backendObject); - - // set up attributes - pINTERFACE_CALL(setVolume(currentVolume)); - pINTERFACE_CALL(setFadeCurve(fadeCurve)); -} -} - - -#endif //QT_NO_PHONON_VOLUMEFADEREFFECT - -#include "moc_volumefadereffect.cpp" - -#undef PHONON_CLASSNAME -// vim: sw=4 ts=4 -#include "moc_volumefadereffect.h" diff --git a/src/phonon/volumefadereffect.h b/src/phonon/volumefadereffect.h deleted file mode 100644 index b572049f1..000000000 --- a/src/phonon/volumefadereffect.h +++ /dev/null @@ -1,174 +0,0 @@ -/* This file is part of the KDE project - Copyright (C) 2006 Matthias Kretz - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), Nokia Corporation - (or its successors, if any) and the KDE Free Qt Foundation, which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . - -*/ - -#ifndef PHONON_VOLUMEFADEREFFECT_H -#define PHONON_VOLUMEFADEREFFECT_H - -#include "phonon_export.h" -#include "effect.h" - - -#ifndef QT_NO_PHONON_VOLUMEFADEREFFECT - -namespace Phonon -{ - class VolumeFaderEffectPrivate; - - /** \class VolumeFaderEffect volumefadereffect.h phonon/VolumeFaderEffect - * Audio effect to gradually fade the audio volume. - * - * This effect differs from gradually changing the output volume in that - * a dedicated effect can change the volume in the smallest possible - * steps while every other volume control will make more or less - * noticeable steps. - * - * \ingroup PhononEffects - * \author Matthias Kretz - * \see AudioOutput::volume - */ - class PHONON_EXPORT VolumeFaderEffect : public Effect - { - Q_OBJECT - P_DECLARE_PRIVATE(VolumeFaderEffect) - PHONON_HEIR(VolumeFaderEffect) - Q_ENUMS(FadeCurve) - /** - * This is the current volume of the output as voltage factor. - * Setting this property changes the volume immediately. - * - * 1.0 means 100%, 0.5 means 50% voltage/25% power, 0.0 means 0% - * - * \see volumeDecibel - */ - Q_PROPERTY(float volume READ volume WRITE setVolume) - /** - * This is the current volume of the output in decibel. - * Setting this property changes the volume immediately. - * - * 0 dB means no change in volume, -6dB means an attenuation of the - * voltage to 50% and an attenuation of the power to 25%, -inf dB means - * silence. - * - * \see volume - */ - Q_PROPERTY(double volumeDecibel READ volumeDecibel WRITE setVolumeDecibel) - /** - * This property holds the fade curve to be used for the fadeIn(), fadeOut() - * and fadeTo() slots. - * - * Defaults to Fade3Decibel. - * - * \see FadeCurve - */ - Q_PROPERTY(FadeCurve fadeCurve READ fadeCurve WRITE setFadeCurve) - public: - /** - * Determines the curve of the volume change. - */ - enum FadeCurve { - /** - * "Crossfade curve" / "fast" fade out - * - * Often the best fade for a crossfade, as after half of the - * time the volume reached -3dB. This means that half the - * possible power (which is proportional to the square of the - * voltage) is reached. Summed, the maximum power of two audio - * signals fading with a -3dB curve will always be equal. - * - * For fading in or out the -3dB curve is too abrupt in the end. - * - * This is the default fade curve. - */ - Fade3Decibel, - /** - * "Linear" fade out - * - * With a -6dB fade curve after half of the fading time -6dB has - * been reached. -6dB is equal to half of the voltage meaning - * that the voltage multiplier changes linearly from the start - * of the fade to the end. - */ - Fade6Decibel, - /** - * "slow" fade out - * - * After half of the fade time -9dB are reached. So the fade is - * fast in the beginning and slow in the end. This is a good - * fade for ending music. - */ - Fade9Decibel, - /** - * more extreme version of the -9dB fade - */ - Fade12Decibel - }; - - float volume() const; - double volumeDecibel() const; - - FadeCurve fadeCurve() const; - - public Q_SLOTS: - /** - * Tells the Fader to change the volume from the current volume to 100% - * in \p fadeTime milliseconds. - * Short for \c fadeTo(1.0, fadeTime). - * - * \param fadeTime the fade duration in milliseconds - * - * \see fadeTo - * \see volume - */ - void fadeIn(int fadeTime); - - /** - * Tells the Fader to change the volume from the current volume to 0% - * in \p fadeTime milliseconds. - * Short for \c fadeTo(0.0, fadeTime). - * - * \param fadeTime the fade duration in milliseconds - * - * \see fadeTo - */ - void fadeOut(int fadeTime); - - void setVolume(float volume); - void setVolumeDecibel(double volumeDecibel); - - void setFadeCurve(FadeCurve curve); - - /** - * Tells the Fader to change the volume from the current value to - * \p volume in \p fadeTime milliseconds - * - * \see fadeIn - * \see fadeOut - */ - void fadeTo(float volume, int fadeTime); - }; -} //namespace Phonon - -#endif //QT_NO_PHONON_VOLUMEFADEREFFECT - - -// vim: sw=4 ts=4 tw=80 -#endif // PHONON_VOLUMEFADEREFFECT_H diff --git a/src/phonon/volumefadereffect_p.h b/src/phonon/volumefadereffect_p.h deleted file mode 100644 index 8582ba74f..000000000 --- a/src/phonon/volumefadereffect_p.h +++ /dev/null @@ -1,54 +0,0 @@ -/* This file is part of the KDE project - Copyright (C) 2006 Matthias Kretz - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), Nokia Corporation - (or its successors, if any) and the KDE Free Qt Foundation, which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . - -*/ - -#ifndef PHONON_VOLUMEFADEREFFECT_P_H -#define PHONON_VOLUMEFADEREFFECT_P_H - -#include "effect_p.h" -#include "volumefadereffect.h" - -#ifndef QT_NO_PHONON_VOLUMEFADEREFFECT - -namespace Phonon -{ -class VolumeFaderEffectPrivate : public EffectPrivate -{ - P_DECLARE_PUBLIC(VolumeFaderEffect) - PHONON_PRIVATECLASS - protected: - VolumeFaderEffectPrivate() - : currentVolume(1.0) - , fadeCurve(VolumeFaderEffect::Fade3Decibel) - { - // invalid EffectDescription - // ############# parameter functions are incorrect - } - - float currentVolume; - VolumeFaderEffect::FadeCurve fadeCurve; -}; -} - -#endif //QT_NO_PHONON_VOLUMEFADEREFFECT - -#endif // PHONON_VOLUMEFADEREFFECT_P_H -// vim: sw=4 ts=4 tw=80 diff --git a/src/phonon/volumefaderinterface.h b/src/phonon/volumefaderinterface.h deleted file mode 100644 index 7854bfb93..000000000 --- a/src/phonon/volumefaderinterface.h +++ /dev/null @@ -1,54 +0,0 @@ -/* This file is part of the KDE project - Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), Nokia Corporation - (or its successors, if any) and the KDE Free Qt Foundation, which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . - -*/ - -#ifndef PHONON_VOLUMEFADERINTERFACE_H -#define PHONON_VOLUMEFADERINTERFACE_H - -#include "volumefadereffect.h" -#include - - -#ifndef QT_NO_PHONON_VOLUMEFADEREFFECT - -namespace Phonon -{ -class VolumeFaderInterface -{ - public: - virtual ~VolumeFaderInterface() {} - - virtual float volume() const { return 1.0; } - virtual void setVolume(float) {} - virtual Phonon::VolumeFaderEffect::FadeCurve fadeCurve() const { - return VolumeFaderEffect::Fade3Decibel; - } - virtual void setFadeCurve(Phonon::VolumeFaderEffect::FadeCurve) {} - virtual void fadeTo(float, int) {} -}; -} - -Q_DECLARE_INTERFACE(Phonon::VolumeFaderInterface, "VolumeFaderInterface4.phonon.kde.org") - -#endif //QT_NO_PHONON_VOLUMEFADEREFFECT - - -#endif // PHONON_VOLUMEFADERINTERFACE_H diff --git a/src/phonon/volumeslider.cpp b/src/phonon/volumeslider.cpp deleted file mode 100644 index 2e9cc2ac0..000000000 --- a/src/phonon/volumeslider.cpp +++ /dev/null @@ -1,292 +0,0 @@ -/* This file is part of the KDE project - Copyright (C) 2006-2007 Matthias Kretz - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), Nokia Corporation - (or its successors, if any) and the KDE Free Qt Foundation, which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . - -*/ - -#include "volumeslider.h" -#include "volumeslider_p.h" -#include "audiooutput.h" -#include "phonondefs_p.h" -#include "phononnamespace_p.h" -#include "factory_p.h" - -#ifndef QT_NO_PHONON_VOLUMESLIDER - -namespace Phonon -{ -VolumeSlider::VolumeSlider(QWidget *parent) - : QWidget(parent), - k_ptr(new VolumeSliderPrivate(this)) -{ - P_D(VolumeSlider); -#ifndef QT_NO_TOOLTIP - setToolTip(tr("Volume: %1%").arg(100)); -#endif -#ifndef QT_NO_WHATSTHIS - setWhatsThis(tr("Use this slider to adjust the volume. The leftmost position is 0%, the rightmost is %1%").arg(100)); -#endif - - connect(&d->slider, SIGNAL(valueChanged(int)), SLOT(_k_sliderChanged(int))); - connect(&d->slider, SIGNAL(sliderPressed()), this, SLOT(_k_sliderPressed())); - connect(&d->slider, SIGNAL(sliderReleased()), this, SLOT(_k_sliderReleased())); - connect(&d->slider, SIGNAL(scrollStart()), this, SLOT(_k_sliderPressed())); - connect(&d->slider, SIGNAL(scrollEnd()), this, SLOT(_k_sliderReleased())); - connect(&d->muteButton, SIGNAL(clicked()), SLOT(_k_buttonClicked())); - - setFocusProxy(&d->slider); -} - -VolumeSlider::VolumeSlider(AudioOutput *output, QWidget *parent) - : QWidget(parent), - k_ptr(new VolumeSliderPrivate(this)) -{ - P_D(VolumeSlider); -#ifndef QT_NO_TOOLTIP - setToolTip(tr("Volume: %1%").arg(100)); -#endif -#ifndef QT_NO_WHATSTHIS - setWhatsThis(tr("Use this slider to adjust the volume. The leftmost position is 0%, the rightmost is %1%").arg(100)); -#endif - - connect(&d->slider, SIGNAL(valueChanged(int)), SLOT(_k_sliderChanged(int))); - connect(&d->slider, SIGNAL(sliderPressed()), this, SLOT(_k_sliderPressed())); - connect(&d->slider, SIGNAL(sliderReleased()), this, SLOT(_k_sliderReleased())); - connect(&d->slider, SIGNAL(scrollStart()), this, SLOT(_k_sliderPressed())); - connect(&d->slider, SIGNAL(scrollEnd()), this, SLOT(_k_sliderReleased())); - connect(&d->muteButton, SIGNAL(clicked()), SLOT(_k_buttonClicked())); - - if (output) { - d->output = output; - d->slider.setValue(qRound(100 * output->volume())); - d->slider.setEnabled(true); - d->muteButton.setEnabled(true); - connect(output, SIGNAL(volumeChanged(qreal)), SLOT(_k_volumeChanged(qreal))); - connect(output, SIGNAL(mutedChanged(bool)), SLOT(_k_mutedChanged(bool))); - } - - setFocusProxy(&d->slider); -} - -VolumeSlider::~VolumeSlider() -{ - delete k_ptr; -} - -bool VolumeSlider::isMuteVisible() const -{ - return !k_ptr->muteButton.isHidden(); -} - -void VolumeSlider::setMuteVisible(bool visible) -{ - k_ptr->muteButton.setVisible(visible); -} - -QSize VolumeSlider::iconSize() const -{ - return k_ptr->muteButton.iconSize(); -} - -void VolumeSlider::setIconSize(const QSize &iconSize) -{ - pDebug() << Q_FUNC_INFO << iconSize; - k_ptr->muteButton.setIconSize(iconSize); -} - -qreal VolumeSlider::maximumVolume() const -{ - return k_ptr->slider.maximum() * 0.01; -} - -void VolumeSlider::setMaximumVolume(qreal volume) -{ - int max = static_cast(volume * 100); - k_ptr->slider.setMaximum(max); -#ifndef QT_NO_WHATSTHIS - setWhatsThis(tr("Use this slider to adjust the volume. The leftmost position is 0%, the rightmost is %1%") - .arg(max)); -#endif -} - -Qt::Orientation VolumeSlider::orientation() const -{ - return k_ptr->slider.orientation(); -} - -void VolumeSlider::setOrientation(Qt::Orientation o) -{ - P_D(VolumeSlider); - Qt::Alignment align = (o == Qt::Horizontal ? Qt::AlignVCenter : Qt::AlignHCenter); - d->layout.setAlignment(&d->muteButton, align); - d->layout.setAlignment(&d->slider, align); - d->layout.setDirection(o == Qt::Horizontal ? QBoxLayout::LeftToRight : QBoxLayout::TopToBottom); - d->slider.setOrientation(o); -} - -AudioOutput *VolumeSlider::audioOutput() const -{ - P_D(const VolumeSlider); - return d->output; -} - -void VolumeSlider::setAudioOutput(AudioOutput *output) -{ - P_D(VolumeSlider); - if (d->output) { - disconnect(d->output, 0, this, 0); - } - d->output = output; - if (output) { - d->slider.setValue(qRound(100 * output->volume())); - d->slider.setEnabled(true); - d->muteButton.setEnabled(true); - - d->_k_volumeChanged(output->volume()); - d->_k_mutedChanged(output->isMuted()); - - connect(output, SIGNAL(volumeChanged(qreal)), SLOT(_k_volumeChanged(qreal))); - connect(output, SIGNAL(mutedChanged(bool)), SLOT(_k_mutedChanged(bool))); - } else { - d->slider.setValue(100); - d->slider.setEnabled(false); - d->muteButton.setEnabled(false); - } -} - -void VolumeSliderPrivate::_k_buttonClicked() -{ - if (output) { - output->setMuted(!output->isMuted()); - } else { - slider.setEnabled(false); - muteButton.setEnabled(false); - } -} - -void VolumeSliderPrivate::_k_sliderPressed() -{ - sliderPressed = true; -} - -void VolumeSliderPrivate::_k_sliderReleased() -{ - sliderPressed = false; - if (output) { - _k_volumeChanged(output->volume()); - } -} - -void VolumeSliderPrivate::_k_mutedChanged(bool muted) -{ -#ifndef QT_NO_TOOLTIP - P_Q(VolumeSlider); -#endif - if (muted) { -#ifndef QT_NO_TOOLTIP - q->setToolTip(VolumeSlider::tr("Muted")); -#endif - muteButton.setIcon(mutedIcon); - } else { -#ifndef QT_NO_TOOLTIP - q->setToolTip(VolumeSlider::tr("Volume: %1%").arg(static_cast(output->volume() * 100.0))); -#endif - muteButton.setIcon(volumeIcon); - } -} - -void VolumeSliderPrivate::_k_sliderChanged(int value) -{ -#ifndef QT_NO_TOOLTIP - P_Q(VolumeSlider); -#endif - - if (output) { -#ifndef QT_NO_TOOLTIP - if (!output->isMuted()) { - q->setToolTip(VolumeSlider::tr("Volume: %1%").arg(value)); - } -#endif - - qreal newvolume = (static_cast(value)) * 0.01; - if (!ignoreVolumeChangeObserve && output->volume() != newvolume) { - ignoreVolumeChangeAction = true; - output->setVolume(newvolume); - } - } else { - slider.setEnabled(false); - muteButton.setEnabled(false); - } - - ignoreVolumeChangeObserve = false; -} - -void VolumeSliderPrivate::_k_volumeChanged(qreal value) -{ - if (sliderPressed) { - return; - } - - int newslidervalue = qRound(100 * value); - if (!ignoreVolumeChangeAction && slider.value() != newslidervalue) { - ignoreVolumeChangeObserve = true; - slider.setValue(newslidervalue); - } - - ignoreVolumeChangeAction = false; -} - -bool VolumeSlider::hasTracking() const -{ - return k_ptr->slider.hasTracking(); -} - -void VolumeSlider::setTracking(bool tracking) -{ - k_ptr->slider.setTracking(tracking); -} - -int VolumeSlider::pageStep() const -{ - return k_ptr->slider.pageStep(); -} - -void VolumeSlider::setPageStep(int milliseconds) -{ - k_ptr->slider.setPageStep(milliseconds); -} - -int VolumeSlider::singleStep() const -{ - return k_ptr->slider.singleStep(); -} - -void VolumeSlider::setSingleStep(int milliseconds) -{ - k_ptr->slider.setSingleStep(milliseconds); -} - -} // namespace Phonon - -#endif //QT_NO_PHONON_VOLUMESLIDER - -#include "moc_volumeslider.cpp" - -// vim: sw=4 et -#include "moc_volumeslider.h" diff --git a/src/phonon/volumeslider.h b/src/phonon/volumeslider.h deleted file mode 100644 index 942f56807..000000000 --- a/src/phonon/volumeslider.h +++ /dev/null @@ -1,153 +0,0 @@ -/* This file is part of the KDE project - Copyright (C) 2006-2007 Matthias Kretz - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), Nokia Corporation - (or its successors, if any) and the KDE Free Qt Foundation, which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . - -*/ - -#ifndef PHONON_UI_VOLUMESLIDER_H -#define PHONON_UI_VOLUMESLIDER_H - -#include "phonon_export.h" -#include "phonondefs.h" -#include - - -#ifndef QT_NO_PHONON_VOLUMESLIDER - -namespace Phonon -{ -class AudioOutput; -class VolumeSliderPrivate; - -/** \class VolumeSlider volumeslider.h phonon/VolumeSlider - * \short Widget providing a slider to control the volume of an AudioOutput. - * - * \ingroup PhononWidgets - * \author Matthias Kretz - */ -class PHONON_EXPORT VolumeSlider : public QWidget -{ - Q_OBJECT - P_DECLARE_PRIVATE(VolumeSlider) - /** - * This property holds the maximum volume that can be set with this slider. - * - * By default the maximum value is 1.0 (100%). - */ - Q_PROPERTY(qreal maximumVolume READ maximumVolume WRITE setMaximumVolume) - /** - * This property holds the orientation of the slider. - * - * The orientation must be Qt::Vertical (the default) or Qt::Horizontal. - */ - Q_PROPERTY(Qt::Orientation orientation READ orientation WRITE setOrientation) - - /** - * This property holds whether slider tracking is enabled. - * - * If tracking is enabled (the default), the volume changes - * while the slider is being dragged. If tracking is - * disabled, the volume changes only when the user - * releases the slider. - */ - Q_PROPERTY(bool tracking READ hasTracking WRITE setTracking) - - /** - * This property holds the page step. - * - * The larger of two natural steps that a slider provides and - * typically corresponds to the user pressing PageUp or PageDown. - * - * Defaults to 5 (5% of the voltage). - */ - Q_PROPERTY(int pageStep READ pageStep WRITE setPageStep) - - /** - * This property holds the single step. - * - * The smaller of two natural steps that a slider provides and - * typically corresponds to the user pressing an arrow key. - * - * Defaults to 1 (1% of the voltage). - */ - Q_PROPERTY(int singleStep READ singleStep WRITE setSingleStep) - - /** - * This property holds whether the mute button/icon next to the slider is visible. - * - * By default the mute button/icon is visible. - */ - Q_PROPERTY(bool muteVisible READ isMuteVisible WRITE setMuteVisible) - - /** - * \brief the icon size used for the mute button/icon. - * - * The default size is defined by the GUI style. - */ - Q_PROPERTY(QSize iconSize READ iconSize WRITE setIconSize) - public: - /** - * Constructs a new volume slider with a \p parent. - */ - explicit VolumeSlider(QWidget *parent = 0); - explicit VolumeSlider(AudioOutput *, QWidget *parent = 0); - ~VolumeSlider(); - - bool hasTracking() const; - void setTracking(bool tracking); - int pageStep() const; - void setPageStep(int milliseconds); - int singleStep() const; - void setSingleStep(int milliseconds); - bool isMuteVisible() const; - QSize iconSize() const; - qreal maximumVolume() const; - Qt::Orientation orientation() const; - AudioOutput *audioOutput() const; - - public Q_SLOTS: - void setMaximumVolume(qreal); - void setOrientation(Qt::Orientation); - void setMuteVisible(bool); - void setIconSize(const QSize &size); - - /** - * Sets the audio output object to be controlled by this slider. - */ - void setAudioOutput(Phonon::AudioOutput *); - - protected: - VolumeSliderPrivate *const k_ptr; - - private: - Q_PRIVATE_SLOT(k_ptr, void _k_sliderChanged(int)) - Q_PRIVATE_SLOT(k_ptr, void _k_volumeChanged(qreal)) - Q_PRIVATE_SLOT(k_ptr, void _k_mutedChanged(bool)) - Q_PRIVATE_SLOT(k_ptr, void _k_buttonClicked()) - Q_PRIVATE_SLOT(k_ptr, void _k_sliderPressed()) - Q_PRIVATE_SLOT(k_ptr, void _k_sliderReleased()) -}; - -} // namespace Phonon - -#endif //QT_NO_PHONON_VOLUMESLIDER - - -// vim: sw=4 ts=4 et -#endif // PHONON_UI_VOLUMESLIDER_H diff --git a/src/phonon/volumeslider_p.h b/src/phonon/volumeslider_p.h deleted file mode 100644 index 9473110bb..000000000 --- a/src/phonon/volumeslider_p.h +++ /dev/null @@ -1,104 +0,0 @@ -/* This file is part of the KDE project - Copyright (C) 2006-2007 Matthias Kretz - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), Nokia Corporation - (or its successors, if any) and the KDE Free Qt Foundation, which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . - -*/ - -#ifndef VOLUMESLIDER_P_H -#define VOLUMESLIDER_P_H - -#include -#include -#include -#include -#include -#include -#include - -#include "factory_p.h" -#include "phonondefs_p.h" -#include "platform_p.h" -#include "swiftslider_p.h" - -#ifndef QT_NO_PHONON_VOLUMESLIDER - -namespace Phonon -{ -class VolumeSliderPrivate -{ - P_DECLARE_PUBLIC(VolumeSlider) - protected: - VolumeSliderPrivate(VolumeSlider *parent) - : q_ptr(parent), - layout(QBoxLayout::LeftToRight, parent), - slider(Qt::Horizontal, parent), - muteButton(parent), - volumeIcon(Platform::icon(QLatin1String("player-volume"), parent->style())), - mutedIcon(Platform::icon(QLatin1String("player-volume-muted"), parent->style())), - output(0), - ignoreVolumeChangeAction(false), - ignoreVolumeChangeObserve(true), - sliderPressed(false) - { - slider.setRange(0, 100); - slider.setPageStep(5); - slider.setSingleStep(1); - - muteButton.setIcon(volumeIcon); - muteButton.setAutoRaise(true); - layout.setMargin(0); - layout.setSpacing(2); - layout.addWidget(&muteButton, 0, Qt::AlignVCenter); - layout.addWidget(&slider, 0, Qt::AlignVCenter); - - slider.setEnabled(false); - muteButton.setEnabled(false); - - if (volumeIcon.isNull()) { - muteButton.setVisible(false); - } - } - - VolumeSlider *q_ptr; - - void _k_sliderChanged(int); - void _k_volumeChanged(qreal); - void _k_mutedChanged(bool); - void _k_buttonClicked(); - void _k_sliderPressed(); - void _k_sliderReleased(); - - private: - QBoxLayout layout; - SwiftSlider slider; - QToolButton muteButton; - QIcon volumeIcon; - QIcon mutedIcon; - - QPointer output; - bool ignoreVolumeChangeAction; - bool ignoreVolumeChangeObserve; - bool sliderPressed; -}; -} // namespace Phonon - -#endif //QT_NO_PHONON_VOLUMESLIDER - -#endif // VOLUMESLIDER_P_H -// vim: sw=4 sts=4 et tw=100 diff --git a/src/plugins/CMakeLists.txt b/src/plugins/CMakeLists.txt index 0b63c8b11..daef6c22f 100644 --- a/src/plugins/CMakeLists.txt +++ b/src/plugins/CMakeLists.txt @@ -26,8 +26,6 @@ include_directories( ${CMAKE_BINARY_DIR}/privateinclude/QtOpenGL ${CMAKE_BINARY_DIR}/include/QtSvg ${CMAKE_BINARY_DIR}/privateinclude/QtSvg - ${CMAKE_BINARY_DIR}/include/Phonon - ${CMAKE_BINARY_DIR}/privateinclude/Phonon ${CMAKE_CURRENT_SOURCE_DIR}/script ${CMAKE_CURRENT_SOURCE_DIR}/codecs ${CMAKE_CURRENT_SOURCE_DIR}/imageformats @@ -134,4 +132,3 @@ endif() include(designer/qdeclarativeview/qdeclarativeview.cmake) -include(designer/phonon/phonon.cmake) \ No newline at end of file diff --git a/src/plugins/designer/phonon/images/seekslider.png b/src/plugins/designer/phonon/images/seekslider.png deleted file mode 100644 index a1f4cb0d5..000000000 Binary files a/src/plugins/designer/phonon/images/seekslider.png and /dev/null differ diff --git a/src/plugins/designer/phonon/images/videoplayer.png b/src/plugins/designer/phonon/images/videoplayer.png deleted file mode 100644 index 55d86a6d3..000000000 Binary files a/src/plugins/designer/phonon/images/videoplayer.png and /dev/null differ diff --git a/src/plugins/designer/phonon/images/videowidget.png b/src/plugins/designer/phonon/images/videowidget.png deleted file mode 100644 index 3e8706e45..000000000 Binary files a/src/plugins/designer/phonon/images/videowidget.png and /dev/null differ diff --git a/src/plugins/designer/phonon/images/volumeslider.png b/src/plugins/designer/phonon/images/volumeslider.png deleted file mode 100644 index ea81dd2a1..000000000 Binary files a/src/plugins/designer/phonon/images/volumeslider.png and /dev/null differ diff --git a/src/plugins/designer/phonon/phonon.cmake b/src/plugins/designer/phonon/phonon.cmake deleted file mode 100644 index 5a31ce87f..000000000 --- a/src/plugins/designer/phonon/phonon.cmake +++ /dev/null @@ -1,35 +0,0 @@ -include_directories( - ${CMAKE_CURRENT_BINARY_DIR}/designer/phonon -) - -set(PHONONWIDGETSLUGIN_SOURCES - ${PHONONWIDGETSLUGIN_SOURCES} - ${CMAKE_CURRENT_SOURCE_DIR}/designer/phonon/phononcollection.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/designer/phonon/seeksliderplugin.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/designer/phonon/videoplayerplugin.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/designer/phonon/videoplayertaskmenu.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/designer/phonon/videowidgetplugin.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/designer/phonon/volumesliderplugin.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/designer/phonon/phononwidgets.qrc -) - -set(PHONONWIDGETSLUGIN_HEADERS - ${PHONONWIDGETSLUGIN_HEADERS} - ${CMAKE_CURRENT_SOURCE_DIR}/designer/phonon/seeksliderplugin.h - ${CMAKE_CURRENT_SOURCE_DIR}/designer/phonon/volumesliderplugin.h - ${CMAKE_CURRENT_SOURCE_DIR}/designer/phonon/videoplayerplugin.h - ${CMAKE_CURRENT_SOURCE_DIR}/designer/phonon/videowidgetplugin.h - ${CMAKE_CURRENT_SOURCE_DIR}/designer/phonon/videoplayertaskmenu.h -) - -katie_resources(${PHONONWIDGETSLUGIN_SOURCES}) -katie_resources(${PHONONWIDGETSLUGIN_HEADERS}) - -add_library(phononwidgetsplugin ${KATIE_TYPE} ${PHONONWIDGETSLUGIN_SOURCES} ${PHONONWIDGETSLUGIN_HEADERS}) -target_link_libraries(phononwidgetsplugin KtCore KtGui KtPhonon KtDesigner) -set_target_properties(phononwidgetsplugin PROPERTIES OUTPUT_NAME phononwidgets) - -install( - TARGETS phononwidgetsplugin - DESTINATION ${QT_PLUGINS_PATH_INST}/designer -) diff --git a/src/plugins/designer/phonon/phononcollection.cpp b/src/plugins/designer/phonon/phononcollection.cpp deleted file mode 100644 index 6327177ea..000000000 --- a/src/plugins/designer/phonon/phononcollection.cpp +++ /dev/null @@ -1,101 +0,0 @@ -/* - Copyright (C) 2011 Harald Sitter - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), Nokia Corporation - (or its successors, if any) and the KDE Free Qt Foundation, which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . -*/ - -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the Qt Designer of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial Usage -** Licensees holding valid Qt Commercial licenses may use this file in -** accordance with the Qt Commercial License Agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Nokia. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** If you have questions regarding the use of this file, please contact -** Nokia at qt-info@nokia.com. -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "seeksliderplugin.h" -#include "videoplayerplugin.h" -#include "videowidgetplugin.h" -#include "volumesliderplugin.h" - -#include -#include - -class PhononCollection: public QObject, public QDesignerCustomWidgetCollectionInterface -{ - Q_OBJECT - Q_INTERFACES(QDesignerCustomWidgetCollectionInterface) -public: - explicit PhononCollection(QObject *parent = 0); - - virtual QList customWidgets() const; - -private: - QList m_plugins; -}; - -PhononCollection::PhononCollection(QObject *parent) : - QObject(parent) -{ - const QString group = QLatin1String("Phonon"); - m_plugins.push_back(new SeekSliderPlugin(group, this)); - m_plugins.push_back(new VideoPlayerPlugin(group, this)); - m_plugins.push_back(new VideoWidgetPlugin(group, this)); - m_plugins.push_back(new VolumeSliderPlugin(group, this)); -} - -QList PhononCollection::customWidgets() const -{ - return m_plugins; -} - -Q_EXPORT_PLUGIN(PhononCollection) - -#include "moc_phononcollection.cpp" diff --git a/src/plugins/designer/phonon/phononwidgets.qrc b/src/plugins/designer/phonon/phononwidgets.qrc deleted file mode 100644 index aa51330fd..000000000 --- a/src/plugins/designer/phonon/phononwidgets.qrc +++ /dev/null @@ -1,8 +0,0 @@ - - - images/videoplayer.png - images/videowidget.png - images/seekslider.png - images/volumeslider.png - - diff --git a/src/plugins/designer/phonon/seeksliderplugin.cpp b/src/plugins/designer/phonon/seeksliderplugin.cpp deleted file mode 100644 index 2479c7ce5..000000000 --- a/src/plugins/designer/phonon/seeksliderplugin.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 Designer of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial Usage -** Licensees holding valid Qt Commercial licenses may use this file in -** accordance with the Qt Commercial License Agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Nokia. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** If you have questions regarding the use of this file, please contact -** Nokia at qt-info@nokia.com. -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "seeksliderplugin.h" - -#include - -static const char *toolTipC = "Phonon Seek Slider"; - -SeekSliderPlugin::SeekSliderPlugin(const QString &group, QObject *parent) : - QObject(parent), - m_group(group), - m_initialized(false) -{ -} - -QString SeekSliderPlugin::name() const -{ - return QLatin1String("Phonon::SeekSlider"); -} - -QString SeekSliderPlugin::group() const -{ - return m_group; -} - -QString SeekSliderPlugin::toolTip() const -{ - return QString(QLatin1String(toolTipC)); -} - -QString SeekSliderPlugin::whatsThis() const -{ - return QString(QLatin1String(toolTipC)); -} - -QString SeekSliderPlugin::includeFile() const -{ - return QLatin1String(""); -} - -QIcon SeekSliderPlugin::icon() const -{ - return QIcon(QLatin1String(":/trolltech/phononwidgets/images/seekslider.png")); -} - -bool SeekSliderPlugin::isContainer() const -{ - return false; -} - -QWidget *SeekSliderPlugin::createWidget(QWidget *parent) -{ - return new Phonon::SeekSlider(parent); -} - -bool SeekSliderPlugin::isInitialized() const -{ - return m_initialized; -} - -void SeekSliderPlugin::initialize(QDesignerFormEditorInterface *) -{ - if (m_initialized) - return; - m_initialized = true; -} - -QString SeekSliderPlugin::domXml() const -{ - return QLatin1String("\ - \ - \ - "); -} -#include "moc_seeksliderplugin.h" diff --git a/src/plugins/designer/phonon/seeksliderplugin.h b/src/plugins/designer/phonon/seeksliderplugin.h deleted file mode 100644 index e8ee40f2a..000000000 --- a/src/plugins/designer/phonon/seeksliderplugin.h +++ /dev/null @@ -1,71 +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 Designer of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial Usage -** Licensees holding valid Qt Commercial licenses may use this file in -** accordance with the Qt Commercial License Agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Nokia. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** If you have questions regarding the use of this file, please contact -** Nokia at qt-info@nokia.com. -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef SEEKSLIDER_PLUGIN_H -#define SEEKSLIDER_PLUGIN_H - -#include - -class SeekSliderPlugin: public QObject, public QDesignerCustomWidgetInterface -{ - Q_OBJECT - Q_INTERFACES(QDesignerCustomWidgetInterface) -public: - explicit SeekSliderPlugin(const QString &group, QObject *parent = 0); - - virtual QString name() const; - virtual QString group() const; - virtual QString toolTip() const; - virtual QString whatsThis() const; - virtual QString includeFile() const; - virtual QIcon icon() const; - virtual bool isContainer() const; - virtual QWidget *createWidget(QWidget *parent); - virtual bool isInitialized() const; - virtual void initialize(QDesignerFormEditorInterface *core); - virtual QString domXml() const; - -private: - const QString m_group; - bool m_initialized; -}; - -#endif // SEEKSLIDER_PLUGIN_H diff --git a/src/plugins/designer/phonon/videoplayerplugin.cpp b/src/plugins/designer/phonon/videoplayerplugin.cpp deleted file mode 100644 index f9701b2d7..000000000 --- a/src/plugins/designer/phonon/videoplayerplugin.cpp +++ /dev/null @@ -1,157 +0,0 @@ -/* - Copyright (C) 2011 Harald Sitter - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), Nokia Corporation - (or its successors, if any) and the KDE Free Qt Foundation, which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . -*/ - -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the Qt Designer of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial Usage -** Licensees holding valid Qt Commercial licenses may use this file in -** accordance with the Qt Commercial License Agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Nokia. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** If you have questions regarding the use of this file, please contact -** Nokia at qt-info@nokia.com. -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "videoplayerplugin.h" -#include "videoplayertaskmenu.h" - -#include -#include -#include - -#include -#include - -static const char *toolTipC = "Phonon Video Player"; - -VideoPlayerPlugin::VideoPlayerPlugin(const QString &group, QObject *parent) : - QObject(parent), - m_group(group), - m_initialized(false) -{ -} - -QString VideoPlayerPlugin::name() const -{ - return QLatin1String("Phonon::VideoPlayer"); -} - -QString VideoPlayerPlugin::group() const -{ - return m_group; -} - -QString VideoPlayerPlugin::toolTip() const -{ - return QString(QLatin1String(toolTipC)); -} - -QString VideoPlayerPlugin::whatsThis() const -{ - return QString(QLatin1String(toolTipC)); -} - -QString VideoPlayerPlugin::includeFile() const -{ - return QLatin1String(""); -} - -QIcon VideoPlayerPlugin::icon() const -{ - return QIcon(QLatin1String(":/trolltech/phononwidgets/images/videoplayer.png")); -} - -bool VideoPlayerPlugin::isContainer() const -{ - return false; -} - -QWidget *VideoPlayerPlugin::createWidget(QWidget *parent) -{ - return new Phonon::VideoPlayer(Phonon::NoCategory, parent); -} - -bool VideoPlayerPlugin::isInitialized() const -{ - return m_initialized; -} - -void VideoPlayerPlugin::initialize(QDesignerFormEditorInterface *formEditor) -{ - if (m_initialized) - return; - - QExtensionManager *manager = formEditor->extensionManager(); - Q_ASSERT(manager != 0); - - manager->registerExtensions(new VideoPlayerTaskMenuFactory(manager), - Q_TYPEID(QDesignerTaskMenuExtension)); - - m_initialized = true; -} - -QString VideoPlayerPlugin::domXml() const -{ - return QLatin1String("\ - \ - \ - \ - \ - 0\ - 0\ - 300\ - 200\ - \ - \ - \ - "); -} -#include "moc_videoplayerplugin.h" diff --git a/src/plugins/designer/phonon/videoplayerplugin.h b/src/plugins/designer/phonon/videoplayerplugin.h deleted file mode 100644 index 3e2db5b7b..000000000 --- a/src/plugins/designer/phonon/videoplayerplugin.h +++ /dev/null @@ -1,71 +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 Designer of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial Usage -** Licensees holding valid Qt Commercial licenses may use this file in -** accordance with the Qt Commercial License Agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Nokia. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** If you have questions regarding the use of this file, please contact -** Nokia at qt-info@nokia.com. -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef VIDEOPLAYER_PLUGIN_H -#define VIDEOPLAYER_PLUGIN_H - -#include - -class VideoPlayerPlugin: public QObject, public QDesignerCustomWidgetInterface -{ - Q_OBJECT - Q_INTERFACES(QDesignerCustomWidgetInterface) -public: - explicit VideoPlayerPlugin(const QString &group, QObject *parent = 0); - - virtual QString name() const; - virtual QString group() const; - virtual QString toolTip() const; - virtual QString whatsThis() const; - virtual QString includeFile() const; - virtual QIcon icon() const; - virtual bool isContainer() const; - virtual QWidget *createWidget(QWidget *parent); - virtual bool isInitialized() const; - virtual void initialize(QDesignerFormEditorInterface *core); - virtual QString domXml() const; - -private: - const QString m_group; - bool m_initialized; -}; - -#endif // VIDEOPLAYER_PLUGIN_H diff --git a/src/plugins/designer/phonon/videoplayertaskmenu.cpp b/src/plugins/designer/phonon/videoplayertaskmenu.cpp deleted file mode 100644 index 5f4a2800b..000000000 --- a/src/plugins/designer/phonon/videoplayertaskmenu.cpp +++ /dev/null @@ -1,191 +0,0 @@ -/* - Copyright (C) 2011 Harald Sitter - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), Nokia Corporation - (or its successors, if any) and the KDE Free Qt Foundation, which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . -*/ - -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the Qt Designer of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial Usage -** Licensees holding valid Qt Commercial licenses may use this file in -** accordance with the Qt Commercial License Agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Nokia. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** If you have questions regarding the use of this file, please contact -** Nokia at qt-info@nokia.com. -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "videoplayertaskmenu.h" - -#include -#include -#include -#include - -#include -#include -#include - -#include -#include -#include -#include -#include -#include - -// ----------------- MimeTypeDialog: Display mime types in scrollable text - -class MimeTypeDialog : public QDialog { - Q_DISABLE_COPY(MimeTypeDialog) -public: - explicit MimeTypeDialog(QWidget *parent = 0); - - void setMimeTypes(const QStringList &); - -private: - QPlainTextEdit *m_plainTextEdit; -}; - -MimeTypeDialog::MimeTypeDialog(QWidget *parent) : - QDialog(parent), - m_plainTextEdit(new QPlainTextEdit) -{ - setModal(true); - setWindowTitle(VideoPlayerTaskMenu::tr("Available Mime Types")); - setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint); - - QVBoxLayout *layout = new QVBoxLayout; - m_plainTextEdit->setReadOnly(true); - layout->addWidget(m_plainTextEdit); - - QDialogButtonBox *buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok); - connect(buttonBox, SIGNAL(accepted()), this, SLOT(accept())); - connect(buttonBox, SIGNAL(rejected()), this, SLOT(reject())); - layout->addWidget(buttonBox); - - setLayout(layout); -} - -void MimeTypeDialog::setMimeTypes(const QStringList &l) -{ - m_plainTextEdit->setPlainText(l.join(QString(1, QLatin1Char('\n')))); -} - -// ----------------- VideoPlayerTaskMenu -VideoPlayerTaskMenu::VideoPlayerTaskMenu(Phonon::VideoPlayer *object, QObject *parent) : - QObject(parent), - m_widget(object), - m_displayMimeTypesAction(new QAction(tr("Display supported mime types..."), this)), - m_loadAction(new QAction(tr("Load..."), this)), - m_playAction(new QAction(tr("Play"), this)), - m_pauseAction(new QAction(tr("Pause"), this)), - m_stopAction(new QAction(tr("Stop"), this)) -{ - m_taskActions << m_displayMimeTypesAction << m_loadAction << m_playAction << m_pauseAction << m_stopAction; - - connect(m_widget->mediaObject(), SIGNAL(stateChanged(Phonon::State,Phonon::State)), this, SLOT(mediaObjectStateChanged(Phonon::State,Phonon::State))); - connect(m_displayMimeTypesAction, SIGNAL(triggered()), this, SLOT(slotMimeTypes())); - connect(m_loadAction, SIGNAL(triggered()), this, SLOT(slotLoad())); - connect(m_playAction, SIGNAL(triggered()), object, SLOT(play())); - connect(m_pauseAction, SIGNAL(triggered()), object, SLOT(pause())); - connect(m_stopAction, SIGNAL(triggered()), object, SLOT(stop())); -} - -QList VideoPlayerTaskMenu::taskActions() const -{ - const bool isPlaying = m_widget->isPlaying(); - const bool isPaused = m_widget->isPlaying(); - m_loadAction->setEnabled(!isPlaying && !isPaused); - m_playAction->setEnabled(!isPlaying); - m_pauseAction->setEnabled(isPlaying); - m_stopAction->setEnabled(isPlaying || isPaused); - return m_taskActions; -} - -void VideoPlayerTaskMenu::slotMimeTypes() -{ - MimeTypeDialog mimeTypeDialog(m_widget->window()); - mimeTypeDialog.setMimeTypes(Phonon::BackendCapabilities::availableMimeTypes()); - mimeTypeDialog.exec(); -} - -void VideoPlayerTaskMenu::slotLoad() -{ - const QUrl fileName = QUrl::fromLocalFile(QFileDialog::getOpenFileName(m_widget->window(), tr("Choose Video Player Media Source"))); - if (fileName.isEmpty()) - return; - m_widget->load(Phonon::MediaSource(fileName)); - -} - -void VideoPlayerTaskMenu::mediaObjectStateChanged(Phonon::State newstate, Phonon::State /* oldstate */) -{ - if (newstate == Phonon::ErrorState) { - const QString msg = tr("An error has occurred in '%1': %2").arg(m_widget->objectName(), m_widget->mediaObject()->errorString()); - QMessageBox::warning(m_widget->window(), tr("Video Player Error"), msg); - } -} - -// ----------------- VideoPlayerTaskMenuFactory -VideoPlayerTaskMenuFactory::VideoPlayerTaskMenuFactory(QExtensionManager *parent) : - QExtensionFactory(parent) -{ -} - -QObject *VideoPlayerTaskMenuFactory::createExtension(QObject *object, - const QString &iid, QObject *parent) const -{ - if (iid != Q_TYPEID(QDesignerTaskMenuExtension)) - return 0; - - if (Phonon::VideoPlayer *widget = qobject_cast(object)) - return new VideoPlayerTaskMenu(widget, parent); - - return 0; -} -#include "moc_videoplayertaskmenu.h" diff --git a/src/plugins/designer/phonon/videoplayertaskmenu.h b/src/plugins/designer/phonon/videoplayertaskmenu.h deleted file mode 100644 index 0e62b5bc4..000000000 --- a/src/plugins/designer/phonon/videoplayertaskmenu.h +++ /dev/null @@ -1,112 +0,0 @@ -/* - Copyright (C) 2011 Harald Sitter - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), Nokia Corporation - (or its successors, if any) and the KDE Free Qt Foundation, which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . -*/ - -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the Qt Designer of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial Usage -** Licensees holding valid Qt Commercial licenses may use this file in -** accordance with the Qt Commercial License Agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Nokia. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** If you have questions regarding the use of this file, please contact -** Nokia at qt-info@nokia.com. -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef VIDEOPLAYERTASKMENU_H -#define VIDEOPLAYERTASKMENU_H - -#include -#include -#include - -#include - -namespace Phonon -{ -class VideoPlayer; -} - -class VideoPlayerTaskMenu: public QObject, public QDesignerTaskMenuExtension -{ - Q_OBJECT - Q_INTERFACES(QDesignerTaskMenuExtension) -public: - explicit VideoPlayerTaskMenu(Phonon::VideoPlayer *object, QObject *parent = 0); - virtual QList taskActions() const; - -private slots: - void slotLoad(); - void slotMimeTypes(); - void mediaObjectStateChanged(Phonon::State newstate, Phonon::State oldstate); - -private: - Phonon::VideoPlayer *m_widget; - QAction *m_displayMimeTypesAction; - QAction *m_loadAction; - QAction *m_playAction; - QAction *m_pauseAction; - QAction *m_stopAction; - - QList m_taskActions; -}; - -class VideoPlayerTaskMenuFactory : public QExtensionFactory -{ - Q_OBJECT -public: - VideoPlayerTaskMenuFactory(QExtensionManager *parent = 0); - -protected: - QObject *createExtension(QObject *object, - const QString &iid, QObject *parent) const; -}; - -#endif // VIDEOPLAYERTASKMENU_H diff --git a/src/plugins/designer/phonon/videowidgetplugin.cpp b/src/plugins/designer/phonon/videowidgetplugin.cpp deleted file mode 100644 index a10b49a0d..000000000 --- a/src/plugins/designer/phonon/videowidgetplugin.cpp +++ /dev/null @@ -1,111 +0,0 @@ -/* - Copyright (C) 2011 Harald Sitter - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), Nokia Corporation - (or its successors, if any) and the KDE Free Qt Foundation, which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . -*/ - -#include "videowidgetplugin.h" - -#include -#include -#include - -#include - -#include - -static const char *toolTipC = "Phonon Video Widget"; - -VideoWidgetPlugin::VideoWidgetPlugin(const QString &group, QObject *parent) : - QObject(parent), - m_group(group), - m_initialized(false) -{ -} - -QString VideoWidgetPlugin::name() const -{ - return QLatin1String("Phonon::VideoWidget"); -} - -QString VideoWidgetPlugin::group() const -{ - return m_group; -} - -QString VideoWidgetPlugin::toolTip() const -{ - return QString(QLatin1String(toolTipC)); -} - -QString VideoWidgetPlugin::whatsThis() const -{ - return QString(QLatin1String(toolTipC)); -} - -QString VideoWidgetPlugin::includeFile() const -{ - return QLatin1String(""); -} - -QIcon VideoWidgetPlugin::icon() const -{ - // TODO: icon - return QIcon(); -} - -bool VideoWidgetPlugin::isContainer() const -{ - return false; -} - -QWidget *VideoWidgetPlugin::createWidget(QWidget *parent) -{ - return new Phonon::VideoWidget(parent); -} - -bool VideoWidgetPlugin::isInitialized() const -{ - return m_initialized; -} - -void VideoWidgetPlugin::initialize(QDesignerFormEditorInterface *formEditor) -{ - Q_UNUSED(formEditor); - if (m_initialized) - return; - m_initialized = true; -} - -QString VideoWidgetPlugin::domXml() const -{ - return QLatin1String("\ - \ - \ - \ - \ - 0\ - 0\ - 300\ - 200\ - \ - \ - \ - "); -} -#include "moc_videowidgetplugin.h" diff --git a/src/plugins/designer/phonon/videowidgetplugin.h b/src/plugins/designer/phonon/videowidgetplugin.h deleted file mode 100644 index 14d684ca1..000000000 --- a/src/plugins/designer/phonon/videowidgetplugin.h +++ /dev/null @@ -1,51 +0,0 @@ -/* - Copyright (C) 2011 Harald Sitter - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), Nokia Corporation - (or its successors, if any) and the KDE Free Qt Foundation, which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . -*/ - -#ifndef VIDEOWIDGET_PLUGIN_H -#define VIDEOWIDGET_PLUGIN_H - -#include - -class VideoWidgetPlugin: public QObject, public QDesignerCustomWidgetInterface -{ - Q_OBJECT - Q_INTERFACES(QDesignerCustomWidgetInterface) -public: - explicit VideoWidgetPlugin(const QString &group, QObject *parent = 0); - - virtual QString name() const; - virtual QString group() const; - virtual QString toolTip() const; - virtual QString whatsThis() const; - virtual QString includeFile() const; - virtual QIcon icon() const; - virtual bool isContainer() const; - virtual QWidget *createWidget(QWidget *parent); - virtual bool isInitialized() const; - virtual void initialize(QDesignerFormEditorInterface *core); - virtual QString domXml() const; - -private: - const QString m_group; - bool m_initialized; -}; - -#endif // VIDEOWIDGET_PLUGIN_H diff --git a/src/plugins/designer/phonon/volumesliderplugin.cpp b/src/plugins/designer/phonon/volumesliderplugin.cpp deleted file mode 100644 index d7dd525a0..000000000 --- a/src/plugins/designer/phonon/volumesliderplugin.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 Designer of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial Usage -** Licensees holding valid Qt Commercial licenses may use this file in -** accordance with the Qt Commercial License Agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Nokia. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** If you have questions regarding the use of this file, please contact -** Nokia at qt-info@nokia.com. -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "volumesliderplugin.h" - -#include - -static const char *toolTipC = "Phonon Volume Slider"; - -VolumeSliderPlugin::VolumeSliderPlugin(const QString &group, QObject *parent) : - QObject(parent), - m_group(group), - m_initialized(false) -{ -} - -QString VolumeSliderPlugin::name() const -{ - return QLatin1String("Phonon::VolumeSlider"); -} - -QString VolumeSliderPlugin::group() const -{ - return m_group; -} - -QString VolumeSliderPlugin::toolTip() const -{ - return QString(QLatin1String(toolTipC)); -} - -QString VolumeSliderPlugin::whatsThis() const -{ - return QString(QLatin1String(toolTipC)); -} - -QString VolumeSliderPlugin::includeFile() const -{ - return QLatin1String(""); -} - -QIcon VolumeSliderPlugin::icon() const -{ - return QIcon(QLatin1String(":/trolltech/phononwidgets/images/volumeslider.png")); -} - -bool VolumeSliderPlugin::isContainer() const -{ - return false; -} - -QWidget *VolumeSliderPlugin::createWidget(QWidget *parent) -{ - return new Phonon::VolumeSlider(parent); -} - -bool VolumeSliderPlugin::isInitialized() const -{ - return m_initialized; -} - -void VolumeSliderPlugin::initialize(QDesignerFormEditorInterface *) -{ - if (m_initialized) - return; - m_initialized = true; -} - -QString VolumeSliderPlugin::domXml() const -{ - return QLatin1String("\ - \ - \ - "); -} -#include "moc_volumesliderplugin.h" diff --git a/src/plugins/designer/phonon/volumesliderplugin.h b/src/plugins/designer/phonon/volumesliderplugin.h deleted file mode 100644 index 351a765f0..000000000 --- a/src/plugins/designer/phonon/volumesliderplugin.h +++ /dev/null @@ -1,71 +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 Designer of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial Usage -** Licensees holding valid Qt Commercial licenses may use this file in -** accordance with the Qt Commercial License Agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Nokia. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** If you have questions regarding the use of this file, please contact -** Nokia at qt-info@nokia.com. -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef VOLUMESLIDER_PLUGIN_H -#define VOLUMESLIDER_PLUGIN_H - -#include - -class VolumeSliderPlugin: public QObject, public QDesignerCustomWidgetInterface -{ - Q_OBJECT - Q_INTERFACES(QDesignerCustomWidgetInterface) -public: - explicit VolumeSliderPlugin(const QString &group, QObject *parent = 0); - - virtual QString name() const; - virtual QString group() const; - virtual QString toolTip() const; - virtual QString whatsThis() const; - virtual QString includeFile() const; - virtual QIcon icon() const; - virtual bool isContainer() const; - virtual QWidget *createWidget(QWidget *parent); - virtual bool isInitialized() const; - virtual void initialize(QDesignerFormEditorInterface *core); - virtual QString domXml() const; - -private: - const QString m_group; - bool m_initialized; -}; - -#endif // VOLUMESLIDER_PLUGIN_H diff --git a/translations/qt_ar.ts b/translations/qt_ar.ts index 56c1ed096..9a1870d6f 100644 --- a/translations/qt_ar.ts +++ b/translations/qt_ar.ts @@ -12134,54 +12134,6 @@ to - - VideoPlayerTaskMenu - - - Available Mime Types - - - - - Display supported mime types... - - - - - Load... - - - - - Play - تشغيل - - - - Pause - تعليق - - - - Stop - وقف - - - - Choose Video Player Media Source - - - - - An error has occurred in '%1': %2 - - - - - Video Player Error - - - WidgetDataBase diff --git a/translations/qt_cs.ts b/translations/qt_cs.ts index bf33bca3d..e00f25141 100644 --- a/translations/qt_cs.ts +++ b/translations/qt_cs.ts @@ -12125,54 +12125,6 @@ to - - VideoPlayerTaskMenu - - - Available Mime Types - - - - - Display supported mime types... - - - - - Load... - - - - - Play - Přehrát - - - - Pause - Pause - - - - Stop - Stop - - - - Choose Video Player Media Source - - - - - An error has occurred in '%1': %2 - - - - - Video Player Error - - - WidgetDataBase diff --git a/translations/qt_da.ts b/translations/qt_da.ts index 3acb92748..fd9348ded 100644 --- a/translations/qt_da.ts +++ b/translations/qt_da.ts @@ -12119,54 +12119,6 @@ to - - VideoPlayerTaskMenu - - - Available Mime Types - - - - - Display supported mime types... - - - - - Load... - - - - - Play - - - - - Pause - - - - - Stop - Stop - - - - Choose Video Player Media Source - - - - - An error has occurred in '%1': %2 - - - - - Video Player Error - - - WidgetDataBase diff --git a/translations/qt_de.ts b/translations/qt_de.ts index 52ad742f0..78bb90b15 100644 --- a/translations/qt_de.ts +++ b/translations/qt_de.ts @@ -12119,54 +12119,6 @@ to - - VideoPlayerTaskMenu - - - Available Mime Types - - - - - Display supported mime types... - - - - - Load... - - - - - Play - - - - - Pause - Pause - - - - Stop - Abbrechen - - - - Choose Video Player Media Source - - - - - An error has occurred in '%1': %2 - - - - - Video Player Error - - - WidgetDataBase diff --git a/translations/qt_es.ts b/translations/qt_es.ts index 37b22c4ea..42cc7cc96 100644 --- a/translations/qt_es.ts +++ b/translations/qt_es.ts @@ -12119,54 +12119,6 @@ to - - VideoPlayerTaskMenu - - - Available Mime Types - - - - - Display supported mime types... - - - - - Load... - - - - - Play - - - - - Pause - Pausa - - - - Stop - Detener - - - - Choose Video Player Media Source - - - - - An error has occurred in '%1': %2 - - - - - Video Player Error - - - WidgetDataBase diff --git a/translations/qt_eu.ts b/translations/qt_eu.ts index 4eb7a6ba7..12243a8c0 100644 --- a/translations/qt_eu.ts +++ b/translations/qt_eu.ts @@ -12119,54 +12119,6 @@ to - - VideoPlayerTaskMenu - - - Available Mime Types - - - - - Display supported mime types... - - - - - Load... - - - - - Play - Irakurri - - - - Pause - Pausatu - - - - Stop - Gelditu - - - - Choose Video Player Media Source - - - - - An error has occurred in '%1': %2 - - - - - Video Player Error - - - WidgetDataBase diff --git a/translations/qt_fa.ts b/translations/qt_fa.ts index 8f5194d45..3535fe5bb 100644 --- a/translations/qt_fa.ts +++ b/translations/qt_fa.ts @@ -12114,54 +12114,6 @@ to - - VideoPlayerTaskMenu - - - Available Mime Types - - - - - Display supported mime types... - - - - - Load... - - - - - Play - شروع - - - - Pause - Pause - - - - Stop - Stop - - - - Choose Video Player Media Source - - - - - An error has occurred in '%1': %2 - - - - - Video Player Error - - - WidgetDataBase diff --git a/translations/qt_fr.ts b/translations/qt_fr.ts index 1a7c5376b..9fb6db07a 100644 --- a/translations/qt_fr.ts +++ b/translations/qt_fr.ts @@ -12137,54 +12137,6 @@ to - - VideoPlayerTaskMenu - - - Available Mime Types - - - - - Display supported mime types... - - - - - Load... - - - - - Play - - - - - Pause - Pause - - - - Stop - Arrêter - - - - Choose Video Player Media Source - - - - - An error has occurred in '%1': %2 - - - - - Video Player Error - - - WidgetDataBase diff --git a/translations/qt_gl.ts b/translations/qt_gl.ts index 364c86a48..33000fffc 100644 --- a/translations/qt_gl.ts +++ b/translations/qt_gl.ts @@ -12123,54 +12123,6 @@ to - - VideoPlayerTaskMenu - - - Available Mime Types - - - - - Display supported mime types... - - - - - Load... - - - - - Play - Reproducir - - - - Pause - Pausa - - - - Stop - Deter - - - - Choose Video Player Media Source - - - - - An error has occurred in '%1': %2 - - - - - Video Player Error - - - WidgetDataBase diff --git a/translations/qt_he.ts b/translations/qt_he.ts index bb9ee21ec..94ecaea64 100644 --- a/translations/qt_he.ts +++ b/translations/qt_he.ts @@ -12125,54 +12125,6 @@ to - - VideoPlayerTaskMenu - - - Available Mime Types - - - - - Display supported mime types... - - - - - Load... - - - - - Play - נגן - - - - Pause - Pause - - - - Stop - עצור - - - - Choose Video Player Media Source - - - - - An error has occurred in '%1': %2 - - - - - Video Player Error - - - WidgetDataBase diff --git a/translations/qt_hu.ts b/translations/qt_hu.ts index d8b97f50c..20a274161 100644 --- a/translations/qt_hu.ts +++ b/translations/qt_hu.ts @@ -12134,54 +12134,6 @@ to - - VideoPlayerTaskMenu - - - Available Mime Types - - - - - Display supported mime types... - - - - - Load... - - - - - Play - - - - - Pause - - - - - Stop - Stop - - - - Choose Video Player Media Source - - - - - An error has occurred in '%1': %2 - - - - - Video Player Error - - - WidgetDataBase diff --git a/translations/qt_ja.ts b/translations/qt_ja.ts index 80be44a22..52ac7f5bc 100644 --- a/translations/qt_ja.ts +++ b/translations/qt_ja.ts @@ -12123,54 +12123,6 @@ to - - VideoPlayerTaskMenu - - - Available Mime Types - - - - - Display supported mime types... - - - - - Load... - - - - - Play - 再生 - - - - Pause - 一時停止 - - - - Stop - 停止 - - - - Choose Video Player Media Source - - - - - An error has occurred in '%1': %2 - - - - - Video Player Error - - - WidgetDataBase diff --git a/translations/qt_ko.ts b/translations/qt_ko.ts index 683db72c4..b2229f29b 100644 --- a/translations/qt_ko.ts +++ b/translations/qt_ko.ts @@ -12113,54 +12113,6 @@ to - - VideoPlayerTaskMenu - - - Available Mime Types - - - - - Display supported mime types... - - - - - Load... - - - - - Play - 재생 - - - - Pause - Pause - - - - Stop - 정지 - - - - Choose Video Player Media Source - - - - - An error has occurred in '%1': %2 - - - - - Video Player Error - - - WidgetDataBase diff --git a/translations/qt_lt.ts b/translations/qt_lt.ts index ed2757bf3..620c46b20 100644 --- a/translations/qt_lt.ts +++ b/translations/qt_lt.ts @@ -12125,54 +12125,6 @@ to - - VideoPlayerTaskMenu - - - Available Mime Types - - - - - Display supported mime types... - - - - - Load... - - - - - Play - Groti - - - - Pause - Pauzė - - - - Stop - Stabdyti - - - - Choose Video Player Media Source - - - - - An error has occurred in '%1': %2 - - - - - Video Player Error - - - WidgetDataBase diff --git a/translations/qt_pl.ts b/translations/qt_pl.ts index 87d69a6d3..2b696cb4f 100644 --- a/translations/qt_pl.ts +++ b/translations/qt_pl.ts @@ -12128,54 +12128,6 @@ to - - VideoPlayerTaskMenu - - - Available Mime Types - - - - - Display supported mime types... - - - - - Load... - - - - - Play - Odtwórz - - - - Pause - Pauza - - - - Stop - Zatrzymaj - - - - Choose Video Player Media Source - - - - - An error has occurred in '%1': %2 - - - - - Video Player Error - - - WidgetDataBase diff --git a/translations/qt_pt.ts b/translations/qt_pt.ts index d8bd19ce1..955be07c4 100644 --- a/translations/qt_pt.ts +++ b/translations/qt_pt.ts @@ -12118,54 +12118,6 @@ to - - VideoPlayerTaskMenu - - - Available Mime Types - - - - - Display supported mime types... - - - - - Load... - - - - - Play - - - - - Pause - Pause - - - - Stop - Parar - - - - Choose Video Player Media Source - - - - - An error has occurred in '%1': %2 - - - - - Video Player Error - - - WidgetDataBase diff --git a/translations/qt_ru.ts b/translations/qt_ru.ts index 2a8cf19d7..225dd067c 100644 --- a/translations/qt_ru.ts +++ b/translations/qt_ru.ts @@ -12127,54 +12127,6 @@ to - - VideoPlayerTaskMenu - - - Available Mime Types - - - - - Display supported mime types... - - - - - Load... - - - - - Play - Воспроизвести - - - - Pause - Pause - - - - Stop - Остановить - - - - Choose Video Player Media Source - - - - - An error has occurred in '%1': %2 - - - - - Video Player Error - - - WidgetDataBase diff --git a/translations/qt_sk.ts b/translations/qt_sk.ts index 4ac5fac39..b801d087c 100644 --- a/translations/qt_sk.ts +++ b/translations/qt_sk.ts @@ -12125,54 +12125,6 @@ to - - VideoPlayerTaskMenu - - - Available Mime Types - - - - - Display supported mime types... - - - - - Load... - - - - - Play - Prehrať - - - - Pause - Pauza - - - - Stop - Stop - - - - Choose Video Player Media Source - - - - - An error has occurred in '%1': %2 - - - - - Video Player Error - - - WidgetDataBase diff --git a/translations/qt_sl.ts b/translations/qt_sl.ts index f3a06e22f..517fef4d5 100644 --- a/translations/qt_sl.ts +++ b/translations/qt_sl.ts @@ -12131,54 +12131,6 @@ to - - VideoPlayerTaskMenu - - - Available Mime Types - - - - - Display supported mime types... - - - - - Load... - - - - - Play - - - - - Pause - Premor - - - - Stop - Ustavi - - - - Choose Video Player Media Source - - - - - An error has occurred in '%1': %2 - - - - - Video Player Error - - - WidgetDataBase diff --git a/translations/qt_sv.ts b/translations/qt_sv.ts index 9ab508752..2e44a34af 100644 --- a/translations/qt_sv.ts +++ b/translations/qt_sv.ts @@ -12112,54 +12112,6 @@ to - - VideoPlayerTaskMenu - - - Available Mime Types - - - - - Display supported mime types... - - - - - Load... - - - - - Play - - - - - Pause - Pause - - - - Stop - Stoppa - - - - Choose Video Player Media Source - - - - - An error has occurred in '%1': %2 - - - - - Video Player Error - - - WidgetDataBase diff --git a/translations/qt_uk.ts b/translations/qt_uk.ts index dc9d39ee2..c94b71efc 100644 --- a/translations/qt_uk.ts +++ b/translations/qt_uk.ts @@ -12125,54 +12125,6 @@ to - - VideoPlayerTaskMenu - - - Available Mime Types - - - - - Display supported mime types... - - - - - Load... - - - - - Play - Грати - - - - Pause - Pause - - - - Stop - Стоп - - - - Choose Video Player Media Source - - - - - An error has occurred in '%1': %2 - - - - - Video Player Error - - - WidgetDataBase diff --git a/translations/qt_zh_CN.ts b/translations/qt_zh_CN.ts index 2fe0e213b..ee1faf8e0 100644 --- a/translations/qt_zh_CN.ts +++ b/translations/qt_zh_CN.ts @@ -12113,54 +12113,6 @@ to - - VideoPlayerTaskMenu - - - Available Mime Types - - - - - Display supported mime types... - - - - - Load... - - - - - Play - - - - - Pause - Pause - - - - Stop - 停止 - - - - Choose Video Player Media Source - - - - - An error has occurred in '%1': %2 - - - - - Video Player Error - - - WidgetDataBase diff --git a/translations/qt_zh_TW.ts b/translations/qt_zh_TW.ts index d85e72a03..0ce254f59 100644 --- a/translations/qt_zh_TW.ts +++ b/translations/qt_zh_TW.ts @@ -12114,54 +12114,6 @@ to - - VideoPlayerTaskMenu - - - Available Mime Types - - - - - Display supported mime types... - - - - - Load... - - - - - Play - - - - - Pause - Pause - - - - Stop - 停止 - - - - Choose Video Player Media Source - - - - - An error has occurred in '%1': %2 - - - - - Video Player Error - - - WidgetDataBase