diff options
author | christian linke <christian.linke@bmw.de> | 2012-10-22 16:41:52 +0200 |
---|---|---|
committer | christian linke <christian.linke@bmw.de> | 2012-10-22 16:41:52 +0200 |
commit | 2ba76c5b35f66dc05839d3fd926519f4e7f2a6b7 (patch) | |
tree | 468a16f8572369dcfdbc9267b7e34edc6bcfa4e3 /exampleCode | |
parent | cdbb09b901c695ba55827b53ee43549a4b0b10f6 (diff) | |
download | audiomanager-2ba76c5b35f66dc05839d3fd926519f4e7f2a6b7.tar.gz |
* adding a sample player to the project.
Signed-off-by: christian linke <christian.linke@bmw.de>
Diffstat (limited to 'exampleCode')
-rw-r--r-- | exampleCode/player/Makefile | 336 | ||||
-rw-r--r-- | exampleCode/player/README | 5 | ||||
-rw-r--r-- | exampleCode/player/audiomanagerinteractor.cpp | 77 | ||||
-rw-r--r-- | exampleCode/player/audiomanagerinteractor.h | 76 | ||||
-rwxr-xr-x | exampleCode/player/audiomanagertypes.h | 1243 | ||||
-rw-r--r-- | exampleCode/player/dbushandler.cpp | 742 | ||||
-rw-r--r-- | exampleCode/player/dbushandler.h | 103 | ||||
-rw-r--r-- | exampleCode/player/images/screen.png | bin | 0 -> 4358 bytes | |||
-rw-r--r-- | exampleCode/player/main.cpp | 98 | ||||
-rwxr-xr-x | exampleCode/player/mainwindow.cpp | 14 | ||||
-rwxr-xr-x | exampleCode/player/mainwindow.h | 23 | ||||
-rwxr-xr-x | exampleCode/player/mainwindow.ui | 24 | ||||
-rw-r--r-- | exampleCode/player/mediaplayer.cpp | 970 | ||||
-rw-r--r-- | exampleCode/player/mediaplayer.h | 164 | ||||
-rw-r--r-- | exampleCode/player/mediaplayer.qrc | 5 | ||||
-rwxr-xr-x | exampleCode/player/player.pro | 53 | ||||
-rwxr-xr-x | exampleCode/player/player.pro.user | 365 | ||||
-rw-r--r-- | exampleCode/player/settings.ui | 495 |
18 files changed, 4793 insertions, 0 deletions
diff --git a/exampleCode/player/Makefile b/exampleCode/player/Makefile new file mode 100644 index 0000000..75cbae6 --- /dev/null +++ b/exampleCode/player/Makefile @@ -0,0 +1,336 @@ +############################################################################# +# Makefile for building: qmediaplayer +# Generated by qmake (2.01a) (Qt 4.8.1) on: Mon Jun 4 13:20:55 2012 +# Project: qmediaplayer.pro +# Template: app +# Command: /opt/QtSDK/Desktop/Qt/4.8.1/gcc/bin/qmake -spec /opt/QtSDK/Desktop/Qt/4.8.1/gcc/mkspecs/linux-g++-32 CONFIG+=debug CONFIG+=declarative_debug -o Makefile qmediaplayer.pro +############################################################################# + +####### Compiler, tools and options + +CC = gcc +CXX = g++ +DEFINES = -DQT_PHONON_LIB -DQT_GUI_LIB -DQT_CORE_LIB -DQT_SHARED +CFLAGS = -m32 -pipe -g -Wall -W -D_REENTRANT $(DEFINES) +CXXFLAGS = -m32 -pipe -g -Wall -W -D_REENTRANT $(DEFINES) +INCPATH = -I/opt/QtSDK/Desktop/Qt/4.8.1/gcc/mkspecs/linux-g++-32 -I. -I/opt/QtSDK/Desktop/Qt/4.8.1/gcc/include/QtCore -I/opt/QtSDK/Desktop/Qt/4.8.1/gcc/include/QtGui -I/opt/QtSDK/Desktop/Qt/4.8.1/gcc/include/phonon -I/opt/QtSDK/Desktop/Qt/4.8.1/gcc/include -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -I/usr/include/dbus-1.0 -I/usr/lib/x86_64-linux-gnu/dbus-1.0/include -I/opt/QtSDK/Desktop/Qt/4.8.1/gcc/include/phonon_compat -I. -I. +LINK = g++ +LFLAGS = -m32 -Wl,-rpath,/opt/QtSDK/Desktop/Qt/4.8.1/gcc/lib +LIBS = $(SUBLIBS) -L/opt/QtSDK/Desktop/Qt/4.8.1/gcc/lib -ldbus-glib-1 -ldbus-1 -lrt -lgobject-2.0 -lphonon -L/opt/QtSDK/Desktop/Qt/4.8.1/gcc/lib -lpulse-mainloop-glib -lpulse -lglib-2.0 -lQtDBus -lQtXml -L/usr/X11R6/lib64 -lQtGui -lQtCore -lpthread +AR = ar cqs +RANLIB = +QMAKE = /opt/QtSDK/Desktop/Qt/4.8.1/gcc/bin/qmake +TAR = tar -cf +COMPRESS = gzip -9f +COPY = cp -f +SED = sed +COPY_FILE = $(COPY) +COPY_DIR = $(COPY) -r +STRIP = strip +INSTALL_FILE = install -m 644 -p +INSTALL_DIR = $(COPY_DIR) +INSTALL_PROGRAM = install -m 755 -p +DEL_FILE = rm -f +SYMLINK = ln -f -s +DEL_DIR = rmdir +MOVE = mv -f +CHK_DIR_EXISTS= test -d +MKDIR = mkdir -p + +####### Output directory + +OBJECTS_DIR = ./ + +####### Files + +SOURCES = main.cpp \ + mediaplayer.cpp \ + audiomanagerinteractor.cpp \ + dbushandler.cpp moc_mediaplayer.cpp \ + moc_audiomanagerinteractor.cpp \ + moc_dbushandler.cpp \ + qrc_mediaplayer.cpp +OBJECTS = main.o \ + mediaplayer.o \ + audiomanagerinteractor.o \ + dbushandler.o \ + moc_mediaplayer.o \ + moc_audiomanagerinteractor.o \ + moc_dbushandler.o \ + qrc_mediaplayer.o +DIST = /opt/QtSDK/Desktop/Qt/4.8.1/gcc/mkspecs/common/unix.conf \ + /opt/QtSDK/Desktop/Qt/4.8.1/gcc/mkspecs/common/linux.conf \ + /opt/QtSDK/Desktop/Qt/4.8.1/gcc/mkspecs/common/gcc-base.conf \ + /opt/QtSDK/Desktop/Qt/4.8.1/gcc/mkspecs/common/gcc-base-unix.conf \ + /opt/QtSDK/Desktop/Qt/4.8.1/gcc/mkspecs/common/g++-base.conf \ + /opt/QtSDK/Desktop/Qt/4.8.1/gcc/mkspecs/common/g++-unix.conf \ + /opt/QtSDK/Desktop/Qt/4.8.1/gcc/mkspecs/qconfig.pri \ + /opt/QtSDK/Desktop/Qt/4.8.1/gcc/mkspecs/modules/qt_webkit_version.pri \ + /opt/QtSDK/Desktop/Qt/4.8.1/gcc/mkspecs/features/qt_functions.prf \ + /opt/QtSDK/Desktop/Qt/4.8.1/gcc/mkspecs/features/qt_config.prf \ + /opt/QtSDK/Desktop/Qt/4.8.1/gcc/mkspecs/features/exclusive_builds.prf \ + /opt/QtSDK/Desktop/Qt/4.8.1/gcc/mkspecs/features/default_pre.prf \ + /opt/QtSDK/Desktop/Qt/4.8.1/gcc/mkspecs/features/debug.prf \ + /opt/QtSDK/Desktop/Qt/4.8.1/gcc/mkspecs/features/default_post.prf \ + /opt/QtSDK/Desktop/Qt/4.8.1/gcc/mkspecs/features/link_pkgconfig.prf \ + /opt/QtSDK/Desktop/Qt/4.8.1/gcc/mkspecs/features/declarative_debug.prf \ + /opt/QtSDK/Desktop/Qt/4.8.1/gcc/mkspecs/features/unix/gdb_dwarf_index.prf \ + /opt/QtSDK/Desktop/Qt/4.8.1/gcc/mkspecs/features/warn_on.prf \ + /opt/QtSDK/Desktop/Qt/4.8.1/gcc/mkspecs/features/qt.prf \ + /opt/QtSDK/Desktop/Qt/4.8.1/gcc/mkspecs/features/unix/thread.prf \ + /opt/QtSDK/Desktop/Qt/4.8.1/gcc/mkspecs/features/moc.prf \ + /opt/QtSDK/Desktop/Qt/4.8.1/gcc/mkspecs/features/resources.prf \ + /opt/QtSDK/Desktop/Qt/4.8.1/gcc/mkspecs/features/uic.prf \ + /opt/QtSDK/Desktop/Qt/4.8.1/gcc/mkspecs/features/yacc.prf \ + /opt/QtSDK/Desktop/Qt/4.8.1/gcc/mkspecs/features/lex.prf \ + /opt/QtSDK/Desktop/Qt/4.8.1/gcc/mkspecs/features/include_source_dir.prf \ + qmediaplayer.pro +QMAKE_TARGET = qmediaplayer +DESTDIR = +TARGET = qmediaplayer + +first: all +####### Implicit rules + +.SUFFIXES: .o .c .cpp .cc .cxx .C + +.cpp.o: + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<" + +.cc.o: + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<" + +.cxx.o: + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<" + +.C.o: + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<" + +.c.o: + $(CC) -c $(CFLAGS) $(INCPATH) -o "$@" "$<" + +####### Build rules + +all: Makefile $(TARGET) + +$(TARGET): ui_settings.h $(OBJECTS) + $(LINK) $(LFLAGS) -o $(TARGET) $(OBJECTS) $(OBJCOMP) $(LIBS) + { test -n "$(DESTDIR)" && DESTDIR="$(DESTDIR)" || DESTDIR=.; } && test $$(gdb --version | sed -e 's,[^0-9]\+\([0-9]\)\.\([0-9]\).*,\1\2,;q') -gt 72 && gdb --nx --batch --quiet -ex 'set confirm off' -ex "save gdb-index $$DESTDIR" -ex quit '$(TARGET)' && test -f $(TARGET).gdb-index && objcopy --add-section '.gdb_index=$(TARGET).gdb-index' --set-section-flags '.gdb_index=readonly' '$(TARGET)' '$(TARGET)' && rm -f $(TARGET).gdb-index || true + +Makefile: qmediaplayer.pro /opt/QtSDK/Desktop/Qt/4.8.1/gcc/mkspecs/linux-g++-32/qmake.conf /opt/QtSDK/Desktop/Qt/4.8.1/gcc/mkspecs/common/unix.conf \ + /opt/QtSDK/Desktop/Qt/4.8.1/gcc/mkspecs/common/linux.conf \ + /opt/QtSDK/Desktop/Qt/4.8.1/gcc/mkspecs/common/gcc-base.conf \ + /opt/QtSDK/Desktop/Qt/4.8.1/gcc/mkspecs/common/gcc-base-unix.conf \ + /opt/QtSDK/Desktop/Qt/4.8.1/gcc/mkspecs/common/g++-base.conf \ + /opt/QtSDK/Desktop/Qt/4.8.1/gcc/mkspecs/common/g++-unix.conf \ + /opt/QtSDK/Desktop/Qt/4.8.1/gcc/mkspecs/qconfig.pri \ + /opt/QtSDK/Desktop/Qt/4.8.1/gcc/mkspecs/modules/qt_webkit_version.pri \ + /opt/QtSDK/Desktop/Qt/4.8.1/gcc/mkspecs/features/qt_functions.prf \ + /opt/QtSDK/Desktop/Qt/4.8.1/gcc/mkspecs/features/qt_config.prf \ + /opt/QtSDK/Desktop/Qt/4.8.1/gcc/mkspecs/features/exclusive_builds.prf \ + /opt/QtSDK/Desktop/Qt/4.8.1/gcc/mkspecs/features/default_pre.prf \ + /opt/QtSDK/Desktop/Qt/4.8.1/gcc/mkspecs/features/debug.prf \ + /opt/QtSDK/Desktop/Qt/4.8.1/gcc/mkspecs/features/default_post.prf \ + /opt/QtSDK/Desktop/Qt/4.8.1/gcc/mkspecs/features/link_pkgconfig.prf \ + /opt/QtSDK/Desktop/Qt/4.8.1/gcc/mkspecs/features/declarative_debug.prf \ + /opt/QtSDK/Desktop/Qt/4.8.1/gcc/mkspecs/features/unix/gdb_dwarf_index.prf \ + /opt/QtSDK/Desktop/Qt/4.8.1/gcc/mkspecs/features/warn_on.prf \ + /opt/QtSDK/Desktop/Qt/4.8.1/gcc/mkspecs/features/qt.prf \ + /opt/QtSDK/Desktop/Qt/4.8.1/gcc/mkspecs/features/unix/thread.prf \ + /opt/QtSDK/Desktop/Qt/4.8.1/gcc/mkspecs/features/moc.prf \ + /opt/QtSDK/Desktop/Qt/4.8.1/gcc/mkspecs/features/resources.prf \ + /opt/QtSDK/Desktop/Qt/4.8.1/gcc/mkspecs/features/uic.prf \ + /opt/QtSDK/Desktop/Qt/4.8.1/gcc/mkspecs/features/yacc.prf \ + /opt/QtSDK/Desktop/Qt/4.8.1/gcc/mkspecs/features/lex.prf \ + /opt/QtSDK/Desktop/Qt/4.8.1/gcc/mkspecs/features/include_source_dir.prf \ + /opt/QtSDK/Desktop/Qt/4.8.1/gcc/lib/libphonon.prl \ + /opt/QtSDK/Desktop/Qt/4.8.1/gcc/lib/libQtDBus.prl \ + /opt/QtSDK/Desktop/Qt/4.8.1/gcc/lib/libQtXml.prl \ + /opt/QtSDK/Desktop/Qt/4.8.1/gcc/lib/libQtCore.prl \ + /opt/QtSDK/Desktop/Qt/4.8.1/gcc/lib/libQtGui.prl + $(QMAKE) -spec /opt/QtSDK/Desktop/Qt/4.8.1/gcc/mkspecs/linux-g++-32 CONFIG+=debug CONFIG+=declarative_debug -o Makefile qmediaplayer.pro +/opt/QtSDK/Desktop/Qt/4.8.1/gcc/mkspecs/common/unix.conf: +/opt/QtSDK/Desktop/Qt/4.8.1/gcc/mkspecs/common/linux.conf: +/opt/QtSDK/Desktop/Qt/4.8.1/gcc/mkspecs/common/gcc-base.conf: +/opt/QtSDK/Desktop/Qt/4.8.1/gcc/mkspecs/common/gcc-base-unix.conf: +/opt/QtSDK/Desktop/Qt/4.8.1/gcc/mkspecs/common/g++-base.conf: +/opt/QtSDK/Desktop/Qt/4.8.1/gcc/mkspecs/common/g++-unix.conf: +/opt/QtSDK/Desktop/Qt/4.8.1/gcc/mkspecs/qconfig.pri: +/opt/QtSDK/Desktop/Qt/4.8.1/gcc/mkspecs/modules/qt_webkit_version.pri: +/opt/QtSDK/Desktop/Qt/4.8.1/gcc/mkspecs/features/qt_functions.prf: +/opt/QtSDK/Desktop/Qt/4.8.1/gcc/mkspecs/features/qt_config.prf: +/opt/QtSDK/Desktop/Qt/4.8.1/gcc/mkspecs/features/exclusive_builds.prf: +/opt/QtSDK/Desktop/Qt/4.8.1/gcc/mkspecs/features/default_pre.prf: +/opt/QtSDK/Desktop/Qt/4.8.1/gcc/mkspecs/features/debug.prf: +/opt/QtSDK/Desktop/Qt/4.8.1/gcc/mkspecs/features/default_post.prf: +/opt/QtSDK/Desktop/Qt/4.8.1/gcc/mkspecs/features/link_pkgconfig.prf: +/opt/QtSDK/Desktop/Qt/4.8.1/gcc/mkspecs/features/declarative_debug.prf: +/opt/QtSDK/Desktop/Qt/4.8.1/gcc/mkspecs/features/unix/gdb_dwarf_index.prf: +/opt/QtSDK/Desktop/Qt/4.8.1/gcc/mkspecs/features/warn_on.prf: +/opt/QtSDK/Desktop/Qt/4.8.1/gcc/mkspecs/features/qt.prf: +/opt/QtSDK/Desktop/Qt/4.8.1/gcc/mkspecs/features/unix/thread.prf: +/opt/QtSDK/Desktop/Qt/4.8.1/gcc/mkspecs/features/moc.prf: +/opt/QtSDK/Desktop/Qt/4.8.1/gcc/mkspecs/features/resources.prf: +/opt/QtSDK/Desktop/Qt/4.8.1/gcc/mkspecs/features/uic.prf: +/opt/QtSDK/Desktop/Qt/4.8.1/gcc/mkspecs/features/yacc.prf: +/opt/QtSDK/Desktop/Qt/4.8.1/gcc/mkspecs/features/lex.prf: +/opt/QtSDK/Desktop/Qt/4.8.1/gcc/mkspecs/features/include_source_dir.prf: +/opt/QtSDK/Desktop/Qt/4.8.1/gcc/lib/libphonon.prl: +/opt/QtSDK/Desktop/Qt/4.8.1/gcc/lib/libQtDBus.prl: +/opt/QtSDK/Desktop/Qt/4.8.1/gcc/lib/libQtXml.prl: +/opt/QtSDK/Desktop/Qt/4.8.1/gcc/lib/libQtCore.prl: +/opt/QtSDK/Desktop/Qt/4.8.1/gcc/lib/libQtGui.prl: +qmake: FORCE + @$(QMAKE) -spec /opt/QtSDK/Desktop/Qt/4.8.1/gcc/mkspecs/linux-g++-32 CONFIG+=debug CONFIG+=declarative_debug -o Makefile qmediaplayer.pro + +dist: + @$(CHK_DIR_EXISTS) .tmp/qmediaplayer1.0.0 || $(MKDIR) .tmp/qmediaplayer1.0.0 + $(COPY_FILE) --parents $(SOURCES) $(DIST) .tmp/qmediaplayer1.0.0/ && $(COPY_FILE) --parents mediaplayer.h audiomanagerinteractor.h dbushandler.h audiomanagertypes.h .tmp/qmediaplayer1.0.0/ && $(COPY_FILE) --parents mediaplayer.qrc .tmp/qmediaplayer1.0.0/ && $(COPY_FILE) --parents main.cpp mediaplayer.cpp audiomanagerinteractor.cpp dbushandler.cpp .tmp/qmediaplayer1.0.0/ && $(COPY_FILE) --parents settings.ui .tmp/qmediaplayer1.0.0/ && (cd `dirname .tmp/qmediaplayer1.0.0` && $(TAR) qmediaplayer1.0.0.tar qmediaplayer1.0.0 && $(COMPRESS) qmediaplayer1.0.0.tar) && $(MOVE) `dirname .tmp/qmediaplayer1.0.0`/qmediaplayer1.0.0.tar.gz . && $(DEL_FILE) -r .tmp/qmediaplayer1.0.0 + + +clean:compiler_clean + -$(DEL_FILE) $(OBJECTS) + -$(DEL_FILE) *~ core *.core + + +####### Sub-libraries + +distclean: clean + -$(DEL_FILE) $(TARGET) + -$(DEL_FILE) Makefile + + +check: first + +mocclean: compiler_moc_header_clean compiler_moc_source_clean + +mocables: compiler_moc_header_make_all compiler_moc_source_make_all + +compiler_moc_header_make_all: moc_mediaplayer.cpp moc_audiomanagerinteractor.cpp moc_dbushandler.cpp +compiler_moc_header_clean: + -$(DEL_FILE) moc_mediaplayer.cpp moc_audiomanagerinteractor.cpp moc_dbushandler.cpp +moc_mediaplayer.cpp: mediaplayer.h + /opt/QtSDK/Desktop/Qt/4.8.1/gcc/bin/moc $(DEFINES) $(INCPATH) mediaplayer.h -o moc_mediaplayer.cpp + +moc_audiomanagerinteractor.cpp: dbushandler.h \ + audiomanagertypes.h \ + projecttypes.h \ + audiomanagerinteractor.h + /opt/QtSDK/Desktop/Qt/4.8.1/gcc/bin/moc $(DEFINES) $(INCPATH) audiomanagerinteractor.h -o moc_audiomanagerinteractor.cpp + +moc_dbushandler.cpp: audiomanagertypes.h \ + projecttypes.h \ + dbushandler.h + /opt/QtSDK/Desktop/Qt/4.8.1/gcc/bin/moc $(DEFINES) $(INCPATH) dbushandler.h -o moc_dbushandler.cpp + +compiler_rcc_make_all: qrc_mediaplayer.cpp +compiler_rcc_clean: + -$(DEL_FILE) qrc_mediaplayer.cpp +qrc_mediaplayer.cpp: mediaplayer.qrc \ + images/screen.png + /opt/QtSDK/Desktop/Qt/4.8.1/gcc/bin/rcc -name mediaplayer mediaplayer.qrc -o qrc_mediaplayer.cpp + +compiler_image_collection_make_all: qmake_image_collection.cpp +compiler_image_collection_clean: + -$(DEL_FILE) qmake_image_collection.cpp +compiler_moc_source_make_all: +compiler_moc_source_clean: +compiler_uic_make_all: ui_settings.h +compiler_uic_clean: + -$(DEL_FILE) ui_settings.h +ui_settings.h: settings.ui + /opt/QtSDK/Desktop/Qt/4.8.1/gcc/bin/uic settings.ui -o ui_settings.h + +compiler_yacc_decl_make_all: +compiler_yacc_decl_clean: +compiler_yacc_impl_make_all: +compiler_yacc_impl_clean: +compiler_lex_make_all: +compiler_lex_clean: +compiler_clean: compiler_moc_header_clean compiler_rcc_clean compiler_uic_clean + +####### Compile + +main.o: main.cpp mediaplayer.h \ + dbushandler.h \ + audiomanagertypes.h \ + projecttypes.h \ + audiomanagerinteractor.h + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o main.o main.cpp + +mediaplayer.o: mediaplayer.cpp mediaplayer.h \ + ui_settings.h + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o mediaplayer.o mediaplayer.cpp + +audiomanagerinteractor.o: audiomanagerinteractor.cpp audiomanagerinteractor.h \ + dbushandler.h \ + audiomanagertypes.h \ + projecttypes.h + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o audiomanagerinteractor.o audiomanagerinteractor.cpp + +dbushandler.o: dbushandler.cpp dbushandler.h \ + audiomanagertypes.h \ + projecttypes.h + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o dbushandler.o dbushandler.cpp + +moc_mediaplayer.o: moc_mediaplayer.cpp + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o moc_mediaplayer.o moc_mediaplayer.cpp + +moc_audiomanagerinteractor.o: moc_audiomanagerinteractor.cpp + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o moc_audiomanagerinteractor.o moc_audiomanagerinteractor.cpp + +moc_dbushandler.o: moc_dbushandler.cpp + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o moc_dbushandler.o moc_dbushandler.cpp + +qrc_mediaplayer.o: qrc_mediaplayer.cpp + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o qrc_mediaplayer.o qrc_mediaplayer.cpp + +####### Install + +install_target: first FORCE + @$(CHK_DIR_EXISTS) $(INSTALL_ROOT)/opt/QtSDK/Demos/4.7/qmediaplayer/ || $(MKDIR) $(INSTALL_ROOT)/opt/QtSDK/Demos/4.7/qmediaplayer/ + -$(INSTALL_PROGRAM) "$(QMAKE_TARGET)" "$(INSTALL_ROOT)/opt/QtSDK/Demos/4.7/qmediaplayer/$(QMAKE_TARGET)" + +uninstall_target: FORCE + -$(DEL_FILE) "$(INSTALL_ROOT)/opt/QtSDK/Demos/4.7/qmediaplayer/$(QMAKE_TARGET)" + -$(DEL_DIR) $(INSTALL_ROOT)/opt/QtSDK/Demos/4.7/qmediaplayer/ + + +install_sources: first FORCE + @$(CHK_DIR_EXISTS) $(INSTALL_ROOT)/opt/QtSDK/Demos/4.7/qmediaplayer/ || $(MKDIR) $(INSTALL_ROOT)/opt/QtSDK/Demos/4.7/qmediaplayer/ + -$(INSTALL_FILE) /home/christian/workspace/qmediaplayer/main.cpp $(INSTALL_ROOT)/opt/QtSDK/Demos/4.7/qmediaplayer/ + -$(INSTALL_FILE) /home/christian/workspace/qmediaplayer/mediaplayer.cpp $(INSTALL_ROOT)/opt/QtSDK/Demos/4.7/qmediaplayer/ + -$(INSTALL_FILE) /home/christian/workspace/qmediaplayer/audiomanagerinteractor.cpp $(INSTALL_ROOT)/opt/QtSDK/Demos/4.7/qmediaplayer/ + -$(INSTALL_FILE) /home/christian/workspace/qmediaplayer/dbushandler.cpp $(INSTALL_ROOT)/opt/QtSDK/Demos/4.7/qmediaplayer/ + -$(INSTALL_FILE) /home/christian/workspace/qmediaplayer/mediaplayer.h $(INSTALL_ROOT)/opt/QtSDK/Demos/4.7/qmediaplayer/ + -$(INSTALL_FILE) /home/christian/workspace/qmediaplayer/audiomanagerinteractor.h $(INSTALL_ROOT)/opt/QtSDK/Demos/4.7/qmediaplayer/ + -$(INSTALL_FILE) /home/christian/workspace/qmediaplayer/dbushandler.h $(INSTALL_ROOT)/opt/QtSDK/Demos/4.7/qmediaplayer/ + -$(INSTALL_PROGRAM) /home/christian/workspace/qmediaplayer/audiomanagertypes.h $(INSTALL_ROOT)/opt/QtSDK/Demos/4.7/qmediaplayer/ + -$(INSTALL_FILE) /home/christian/workspace/qmediaplayer/settings.ui $(INSTALL_ROOT)/opt/QtSDK/Demos/4.7/qmediaplayer/ + -$(INSTALL_FILE) /home/christian/workspace/qmediaplayer/mediaplayer.qrc $(INSTALL_ROOT)/opt/QtSDK/Demos/4.7/qmediaplayer/ + -$(INSTALL_FILE) /home/christian/workspace/qmediaplayer/qmediaplayer.pro $(INSTALL_ROOT)/opt/QtSDK/Demos/4.7/qmediaplayer/ + -$(INSTALL_DIR) /home/christian/workspace/qmediaplayer/images $(INSTALL_ROOT)/opt/QtSDK/Demos/4.7/qmediaplayer/ + + +uninstall_sources: FORCE + -$(DEL_FILE) -r $(INSTALL_ROOT)/opt/QtSDK/Demos/4.7/qmediaplayer/main.cpp + -$(DEL_FILE) -r $(INSTALL_ROOT)/opt/QtSDK/Demos/4.7/qmediaplayer/mediaplayer.cpp + -$(DEL_FILE) -r $(INSTALL_ROOT)/opt/QtSDK/Demos/4.7/qmediaplayer/audiomanagerinteractor.cpp + -$(DEL_FILE) -r $(INSTALL_ROOT)/opt/QtSDK/Demos/4.7/qmediaplayer/dbushandler.cpp + -$(DEL_FILE) -r $(INSTALL_ROOT)/opt/QtSDK/Demos/4.7/qmediaplayer/mediaplayer.h + -$(DEL_FILE) -r $(INSTALL_ROOT)/opt/QtSDK/Demos/4.7/qmediaplayer/audiomanagerinteractor.h + -$(DEL_FILE) -r $(INSTALL_ROOT)/opt/QtSDK/Demos/4.7/qmediaplayer/dbushandler.h + -$(DEL_FILE) -r $(INSTALL_ROOT)/opt/QtSDK/Demos/4.7/qmediaplayer/audiomanagertypes.h + -$(DEL_FILE) -r $(INSTALL_ROOT)/opt/QtSDK/Demos/4.7/qmediaplayer/settings.ui + -$(DEL_FILE) -r $(INSTALL_ROOT)/opt/QtSDK/Demos/4.7/qmediaplayer/mediaplayer.qrc + -$(DEL_FILE) -r $(INSTALL_ROOT)/opt/QtSDK/Demos/4.7/qmediaplayer/qmediaplayer.pro + -$(DEL_FILE) -r $(INSTALL_ROOT)/opt/QtSDK/Demos/4.7/qmediaplayer/images + -$(DEL_DIR) $(INSTALL_ROOT)/opt/QtSDK/Demos/4.7/qmediaplayer/ + + +install: install_target install_sources FORCE + +uninstall: uninstall_target uninstall_sources FORCE + +FORCE: + diff --git a/exampleCode/player/README b/exampleCode/player/README new file mode 100644 index 0000000..aa8fca3 --- /dev/null +++ b/exampleCode/player/README @@ -0,0 +1,5 @@ +This code is a sample player for the AudioManager and was used for the POC in 2012. + +It is based on a QT sample player. + +In order to compile it, open it with a QT Creator. diff --git a/exampleCode/player/audiomanagerinteractor.cpp b/exampleCode/player/audiomanagerinteractor.cpp new file mode 100644 index 0000000..528006b --- /dev/null +++ b/exampleCode/player/audiomanagerinteractor.cpp @@ -0,0 +1,77 @@ +/** + * Copyright (C) 2012, BMW AG + * + * + * \copyright + * 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, version 2 + * 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, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * + * \author Christian Mueller, christian.ei.mueller@bmw.de BMW 2011,2012 + * + * + */ + +#include "audiomanagerinteractor.h" +#include <iostream> + +using namespace am; + +AudioManagerInteractor::AudioManagerInteractor(DbusHandler* DbusHandler, am_sourceID_t sourceID, am_sinkID_t sinkID) : + mDbusHandler(DbusHandler), + mSourceID(sourceID), + mSinkID(sinkID), + mConnectionID(0), + mState(Phonon::StoppedState), + mConnectedState(DISCONNECTED) +{ +} + +void AudioManagerInteractor::playPause() +{ + if (mState==Phonon::StoppedState || mState==Phonon::PausedState) + { + mDbusHandler->connect(mSourceID,mSinkID,mConnectionID); + mConnectedState=CONNECTING; + } + else + { + mDbusHandler->disconnect(mConnectionID); + mConnectedState=DISCONNECTED; + } +} + +void AudioManagerInteractor::SourceActivity(am_sourceID_t source,am_SourceState_e state) +{ + std::cout<<"got source activity ID "<<source<<" "<<state<<std::endl; + if (source==mSourceID && state==SS_ON) + emit this->play(); + else if (source==mSourceID && (state==SS_OFF || state==SS_PAUSED)) + emit this->stop(); +} + +void AudioManagerInteractor::getPlayerState(Phonon::State newstate) +{ + mState=newstate; + if (newstate==Phonon::StoppedState && mConnectedState==CONNECTED) + mDbusHandler->disconnect(mConnectionID); + else if (mConnectedState==CONNECTING) + mConnectedState=CONNECTED; +} + + +AudioManagerInteractor::~AudioManagerInteractor() +{ + +} diff --git a/exampleCode/player/audiomanagerinteractor.h b/exampleCode/player/audiomanagerinteractor.h new file mode 100644 index 0000000..77b01eb --- /dev/null +++ b/exampleCode/player/audiomanagerinteractor.h @@ -0,0 +1,76 @@ +/** + * Copyright (C) 2012, BMW AG + * + * + * \copyright + * 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, version 2 + * 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, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * + * \author Christian Mueller, christian.ei.mueller@bmw.de BMW 2011,2012 + * + * + */ + + +#ifndef AUDIOMANAGERINTERACTOR_H +#define AUDIOMANAGERINTERACTOR_H + +#include <dbus/dbus.h> +#include <glib.h> +#include <stdint.h> +#include <dbus/dbus-glib.h> +#include <dbus/dbus-glib-lowlevel.h> +#include <QtGui/QWidget> +#include <QtGui/QApplication> +#include <QtCore/QTimerEvent> +#include <QtGui/QShowEvent> +#include <QtGui/QIcon> +#include <QtCore/QBasicTimer> +#include <QtGui/QAction> +#include <QObject> +#include <phonon/phononnamespace.h> +#include "dbushandler.h" + +class AudioManagerInteractor : public QObject +{ + Q_OBJECT +public: + AudioManagerInteractor(DbusHandler* DbusHandler, am_sourceID_t sourceID, am_sinkID_t sinkID); + ~AudioManagerInteractor(); + +signals: + void play(); + void stop(); + +public slots: + void playPause(); + void SourceActivity(am_sourceID_t source,am_SourceState_e state); + void getPlayerState(Phonon::State newstate); +private: + DbusHandler* mDbusHandler; + am_sourceID_t mSourceID; + am_sinkID_t mSinkID; + am_connectionID_t mConnectionID; + Phonon::State mState; + enum connected_e + { + CONNECTED, + CONNECTING, + DISCONNECTED + }; + connected_e mConnectedState; +}; + +#endif // AUDIOMANAGERINTERACTOR_H diff --git a/exampleCode/player/audiomanagertypes.h b/exampleCode/player/audiomanagertypes.h new file mode 100755 index 0000000..3fa3137 --- /dev/null +++ b/exampleCode/player/audiomanagertypes.h @@ -0,0 +1,1243 @@ +/**
+ * Copyright (C) 2012, BMW AG
+ *
+ *
+ * \copyright
+ * 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, version 2
+ * 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, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ *
+ * \author Christian Mueller, christian.ei.mueller@bmw.de BMW 2011,2012
+ *
+ *
+ */
+#if !defined(EA_F9B4F59D_FED5_44ac_85F2_F9F60549C133__INCLUDED_)
+#define EA_F9B4F59D_FED5_44ac_85F2_F9F60549C133__INCLUDED_
+
+#include <stdint.h>
+#include "projecttypes.h"
+#include <string>
+#include <vector>
+
+#define AM_MUTE -3000
+
+namespace am {
+ /**
+ * a domain ID
+ * @author Christian Mueller
+ * @created 07-Mar-2012 6:06:13 PM
+ */
+ typedef uint16_t am_domainID_t;
+
+ /**
+ * a source ID
+ * @author Christian Mueller
+ * @created 07-Mar-2012 6:06:13 PM
+ */
+ typedef uint16_t am_sourceID_t;
+
+ /**
+ * a sink ID
+ * @author Christian Mueller
+ * @created 07-Mar-2012 6:06:13 PM
+ */
+ typedef uint16_t am_sinkID_t;
+
+ /**
+ * a gateway ID
+ * @author Christian Mueller
+ * @created 07-Mar-2012 6:06:13 PM
+ */
+ typedef uint16_t am_gatewayID_t;
+
+ /**
+ * a crossfader ID
+ * @author Christian Mueller
+ * @created 07-Mar-2012 6:06:13 PM
+ */
+ typedef uint16_t am_crossfaderID_t;
+
+ /**
+ * a connection ID
+ * @author Christian Mueller
+ * @created 07-Mar-2012 6:06:13 PM
+ */
+ typedef uint16_t am_connectionID_t;
+
+ /**
+ * a mainConnection ID
+ * @author Christian Mueller
+ * @created 07-Mar-2012 6:06:13 PM
+ */
+ typedef uint16_t am_mainConnectionID_t;
+
+ /**
+ * speed
+ * @author Christian Mueller
+ * @created 07-Mar-2012 6:06:13 PM
+ */
+ typedef uint16_t am_speed_t;
+
+ /**
+ * The unit is 0.1 db steps,The smallest value -3000 (=AM_MUTE). The minimum and
+ * maximum can be limited by actual project.
+ * @author Christian Mueller
+ * @created 07-Mar-2012 6:06:13 PM
+ */
+ typedef int16_t am_volume_t;
+
+ /**
+ * This is the volume presented on the command interface. It is in the duty of the
+ * Controller to change the volumes given here into meaningful values on the
+ * routing interface.
+ * The range of this type is customer specific.
+ * @author Christian Mueller
+ * @created 07-Mar-2012 6:06:13 PM
+ */
+ typedef int16_t am_mainVolume_t;
+
+ /**
+ * @author Christian Mueller
+ * @created 07-Mar-2012 6:06:13 PM
+ */
+ typedef uint16_t am_sourceClass_t;
+
+ /**
+ * @author Christian Mueller
+ * @created 07-Mar-2012 6:06:13 PM
+ */
+ typedef uint16_t am_sinkClass_t;
+
+ /**
+ * time in ms!
+ * @author Christian Mueller
+ * @created 07-Mar-2012 6:06:13 PM
+ */
+ typedef uint16_t am_time_t;
+
+ /**
+ * offset time that is introduced in milli seconds.
+ * @author Christian Mueller
+ * @created 07-Mar-2012 6:06:13 PM
+ */
+ typedef int16_t am_timeSync_t;
+
+ /**
+ * with the help of this enum, sinks and sources can report their availability
+ * state
+ * @author Christian Mueller
+ * @created 07-Mar-2012 6:06:14 PM
+ */
+ enum am_Availablility_e
+ {
+ /**
+ * default
+ */
+ A_UNKNOWN = 0,
+ /**
+ * The source / sink is available
+ */
+ A_AVAILABLE = 1,
+ /**
+ * the source / sink is not available
+ */
+ A_UNAVAILABLE = 2,
+ A_MAX
+ };
+
+ /**
+ * represents the connection state
+ * @author Christian Mueller
+ * @created 07-Mar-2012 6:06:14 PM
+ */
+ enum am_ConnectionState_e
+ {
+ CS_UNKNOWN = 0,
+ /**
+ * This means the connection is just building up
+ */
+ CS_CONNECTING = 1,
+ /**
+ * the connection is ready to be used
+ */
+ CS_CONNECTED = 2,
+ /**
+ * the connection is in the course to be knocked down
+ */
+ CS_DISCONNECTING = 3,
+ /**
+ * only relevant for connectionStatechanged. Is send after the connection was
+ * removed
+ */
+ CS_DISCONNECTED = 4,
+ /**
+ * this means the connection is still build up but unused at the moment
+ */
+ CS_SUSPENDED = 5,
+ CS_MAX
+ };
+
+ /**
+ * @author Christian Mueller
+ * @created 07-Mar-2012 6:06:14 PM
+ */
+ enum am_DomainState_e
+ {
+ /**
+ * default
+ */
+ DS_UNKNOWN = 0,
+ /**
+ * the domain is controlled by the daemon
+ */
+ DS_CONTROLLED = 1,
+ /**
+ * the domain is independent starting up
+ */
+ DS_INDEPENDENT_STARTUP = 1,
+ /**
+ * the domain is independent running down
+ */
+ DS_INDEPENDENT_RUNDOWN = 2,
+ DS_MAX
+ };
+
+ /**
+ * This enum characterizes the data of the EarlyData_t
+ * @author Christian Mueller
+ * @created 07-Mar-2012 6:06:14 PM
+ */
+ enum am_EarlyDataType_e
+ {
+ /**
+ * default
+ */
+ ES_UNKNOWN = 0,
+ /**
+ * the source volume
+ */
+ ED_SOURCE_VOLUME = 1,
+ /**
+ * the sink volume
+ */
+ ED_SINK_VOLUME = 2,
+ /**
+ * a source property
+ */
+ ED_SOURCE_PROPERTY = 3,
+ /**
+ * a sink property
+ */
+ ED_SINK_PROPERTY = 4,
+ ED_MAX
+ };
+
+ /**
+ * the errors of the audiomanager. All possible errors are in here. This enum is
+ * used widely as return parameter.
+ * @author Christian Mueller
+ * @created 07-Mar-2012 6:06:14 PM
+ */
+ enum am_Error_e
+ {
+ /**
+ * no error - positive reply
+ */
+ E_OK = 0,
+ /**
+ * default
+ */
+ E_UNKNOWN = 1,
+ /**
+ * value out of range
+ */
+ E_OUT_OF_RANGE = 2,
+ /**
+ * not used
+ */
+ E_NOT_USED = 3,
+ /**
+ * a database error occurred
+ */
+ E_DATABASE_ERROR = 4,
+ /**
+ * the desired object already exists
+ */
+ E_ALREADY_EXISTS = 5,
+ /**
+ * there is no change
+ */
+ E_NO_CHANGE = 6,
+ /**
+ * the desired action is not possible
+ */
+ E_NOT_POSSIBLE = 7,
+ /**
+ * the desired object is non existent
+ */
+ E_NON_EXISTENT = 8,
+ /**
+ * the asynchronous action was aborted
+ */
+ E_ABORTED = 9,
+ /**
+ * This error is returned in case a connect is issued with a connectionFormat that
+ * cannot be selected for the connection. This could be either due to the
+ * capabilities of a source or a sink or gateway compatibilities for example
+ */
+ E_WRONG_FORMAT = 10,
+ E_MAX
+ };
+
+ /**
+ * @author Christian Mueller
+ * @created 07-Mar-2012 6:06:14 PM
+ */
+ enum am_MuteState_e
+ {
+ /**
+ * default
+ */
+ MS_UNKNOWN = 0,
+ /**
+ * the source / sink is muted
+ */
+ MS_MUTED = 1,
+ /**
+ * the source / sink is unmuted
+ */
+ MS_UNMUTED = 2,
+ MS_MAX
+ };
+
+ /**
+ * The source state reflects the state of the source
+ * @author Christian Mueller
+ * @created 07-Mar-2012 6:06:14 PM
+ */
+ enum am_SourceState_e
+ {
+ SS_UNKNNOWN = 0,
+ /**
+ * The source can be activly heared
+ */
+ SS_ON = 1,
+ /**
+ * The source cannot be heared
+ */
+ SS_OFF = 2,
+ /**
+ * The source is paused. Meaning it cannot be heared but should be prepared to
+ * play again soon.
+ */
+ SS_PAUSED = 3,
+ SS_MAX
+ };
+
+ /**
+ * This enumeration is used to define the type of the action that is correlated to
+ * a handle.
+ * @author Christian Mueller
+ * @created 07-Mar-2012 6:06:14 PM
+ */
+ enum am_Handle_e
+ {
+ H_UNKNOWN = 0,
+ H_CONNECT = 1,
+ H_DISCONNECT = 2,
+ H_SETSOURCESTATE = 3,
+ H_SETSINKVOLUME = 4,
+ H_SETSOURCEVOLUME = 5,
+ H_SETSINKSOUNDPROPERTY = 6,
+ H_SETSOURCESOUNDPROPERTY = 7,
+ H_SETSINKSOUNDPROPERTIES = 8,
+ H_SETSOURCESOUNDPROPERTIES = 9,
+ H_CROSSFADE = 10,
+ H_MAX
+ };
+
+ /**
+ * @author Christian Mueller
+ * @created 07-Mar-2012 6:06:14 PM
+ */
+ enum am_InterruptState_e
+ {
+ /**
+ * default
+ */
+ IS_UNKNOWN = 0,
+ /**
+ * the interrupt state is off - no interrupt
+ */
+ IS_OFF = 1,
+ /**
+ * the interrupt state is interrupted - the interrupt is active
+ */
+ IS_INTERRUPTED = 2,
+ IS_MAX
+ };
+
+ /**
+ * describes the active sink of a crossfader.
+ * @author Christian Mueller
+ * @created 07-Mar-2012 6:06:14 PM
+ */
+ enum am_HotSink_e
+ {
+ /**
+ * default
+ */
+ HS_UNKNOWN = 0,
+ /**
+ * sinkA is active
+ */
+ HS_SINKA = 1,
+ /**
+ * sinkB is active
+ */
+ HS_SINKB = 2,
+ /**
+ * the crossfader is in the transition state
+ */
+ HS_INTERMEDIATE = 3,
+ HS_MAX
+ };
+
+ /**
+ * this describes the availability of a sink or a source together with the latest
+ * change
+ * @author Christian Mueller
+ * @created 07-Mar-2012 6:06:14 PM
+ */
+ struct am_Availability_s
+ {
+
+ public:
+ /**
+ * the current availability state
+ */
+ am_Availablility_e availability;
+ /**
+ * the reason for the last change. This can be used to trigger events that deal
+ * with state changes.
+ */
+ am_AvailabilityReason_e availabilityReason;
+
+ };
+
+ /**
+ * describes class properties
+ * @author Christian Mueller
+ * @created 07-Mar-2012 6:06:14 PM
+ */
+ struct am_ClassProperty_s
+ {
+
+ public:
+ /**
+ * the property as enum
+ */
+ am_ClassProperty_e classProperty;
+ /**
+ * the value of the property
+ */
+ int16_t value;
+
+ };
+
+ /**
+ * This struct describes the attribiutes of a crossfader.
+ * @author Christian Mueller
+ * @created 07-Mar-2012 6:06:14 PM
+ */
+ struct am_Crossfader_s
+ {
+
+ public:
+ /**
+ * This is the ID of the crossfader, it is unique in the system. There are 2 ways,
+ * ID can be created: either it is assigned during the registration process (in a
+ * dynamic context, uniqueness will be ensured by the AudioManager daemon), or it
+ * is a fixed (the project has to ensure the uniqueness of the ID).
+ */
+ am_crossfaderID_t crossfaderID;
+ /**
+ * The name of the crossfader. Must be unique in the whole system.
+ */
+ std::string name;
+ /**
+ * The sinkID of the SinkA. Sinks shall be registered before registering the
+ * crossfader.
+ */
+ am_sinkID_t sinkID_A;
+ /**
+ * The sinkID of the SinkB. Sinks shall be registered before registering the
+ * crossfader.
+ */
+ am_sinkID_t sinkID_B;
+ /**
+ * The sourceID of the crossfader source. The source shall be registered before
+ * the crossfader.
+ */
+ am_sourceID_t sourceID;
+ /**
+ * This enum can have 3 states:
+ *
+ * HS_SINKA sinkA is the current hot one, sinkB is not audible
+ * HS_SINKB sinkB is the current hot one, sinkB is not audible
+ * HS_INTERMEDIATE the fader is stuck in between a cross-fading action. This
+ * could be due to an abort or an error. Before using the crossfader, it must be
+ * set to either HS_SINKA or HS_SINKB.
+ */
+ am_HotSink_e hotSink;
+
+ };
+
+ /**
+ * This struct describes the attributes of a gateway.
+ * @author Christian Mueller
+ * @created 07-Mar-2012 6:06:14 PM
+ */
+ struct am_Gateway_s
+ {
+
+ public:
+ /**
+ * This is the ID of the gateway, it is unique in the system. There are 2 ways, ID
+ * can be created: either it is assigned during the registration process (in a
+ * dynamic context, uniqueness will be ensured by the AudioManagerDaemon), or it
+ * is a fixed (the project has to ensure the uniqueness of the ID).
+ */
+ am_gatewayID_t gatewayID;
+ /**
+ * The name of the gateway. Must be unique in the whole system.
+ */
+ std::string name;
+ /**
+ * The sinkID of the gateway sink-end. The sink is a full blown sink with
+ * connectionFormats, sinkClassIDs etc... It makes sense to register the sinks of
+ * a gateway as non-visible. Care needs to be taken that the connectionsFormats
+ * match with the ones in the conversionMatrix. If the sink is located in the
+ * controllingDomain, the ID needs to be retrieved by registering the sink before
+ * registering the gateway. In case the sink is in a different domain, the ID
+ * needs to be retrieved via peeking.
+ */
+ am_sinkID_t sinkID;
+ /**
+ * The sourceID of the gateway sink-end. The sink is a full blown source with
+ * connectionFormats, sinkClassIDs etc... It makes sense to register the sources
+ * of a gateway as non-visible. Care needs to be taken that the connectionsFormats
+ * match with the ones in the conversionMatrix. If the source is located in the
+ * controllingDomain, the ID needs to be retrieved by registering the source
+ * before registering the gateway. In case the source is in a different domain,
+ * the ID needs to be retrieved via peeking.
+ */
+ am_sourceID_t sourceID;
+ /**
+ * The ID of the sink. If the domain is the same like the controlling domain, the
+ * ID is known due to registration. If the domain is different, the ID needs to be
+ * retrieved via peeking.
+ */
+ am_domainID_t domainSinkID;
+ /**
+ * The ID of the source. If the domain is the same like the controlling domain,
+ * the ID is known due to registration. If the domain is different, the ID needs
+ * to be retrieved via peeking.
+ */
+ am_domainID_t domainSourceID;
+ /**
+ * This is the ID of the domain that registers the gateway.
+ */
+ am_domainID_t controlDomainID;
+ /**
+ * This is the list of available formats on the source side of the gateway. It is
+ * not defined during the gateway registration but copied from the source
+ * registration.
+ */
+ std::vector<am_ConnectionFormat_e> listSourceFormats;
+ /**
+ * This is the list of available formats on the sink side of the gateway. It is
+ * not defined during the gateway registration but copied from the sink
+ * registration.
+ */
+ std::vector<am_ConnectionFormat_e> listSinkFormats;
+ /**
+ * This is matrix holding information about the conversion capability of the
+ * gateway, it's length is defined by the length(listSinkFormats) x
+ * length(listSourceFormats).
+ * If a SinkFormat can be converted into a SourceFormat, the vector will hold a 1,
+ * if no conversion is possible, a 0.
+ * The data is stored row orientated, where the rows are related to the
+ * sinksFormats and the columns to the sourceFormats. The first value will hold
+ * the conversion information from the first sourceFormat to the first sinkFormat
+ * for example and the seventh value the information about the 3rd sinkFormat to
+ * the 1st sourceFormat in case we would have 3 sourceFormats.
+ *
+ * This matrix
+ * 110 011 000 111 001
+ *
+ * reads as this:
+ * Source
+ * ** 1 2 3
+ * *********************
+ * S 1* 1 1 0
+ * i 2* 0 1 1
+ * n 3* 0 0 0
+ * k 4* 1 1 1
+ * 5* 0 0 1
+ */
+ std::vector<bool> convertionMatrix;
+
+ };
+
+ /**
+ * This represents one "hopp" in a route
+ * @author Christian Mueller
+ * @created 07-Mar-2012 6:06:14 PM
+ */
+ struct am_RoutingElement_s
+ {
+
+ public:
+ /**
+ * the source ID
+ */
+ am_sourceID_t sourceID;
+ /**
+ * the sinkID
+ */
+ am_sinkID_t sinkID;
+ /**
+ * the domainID the routeElement is in
+ */
+ am_domainID_t domainID;
+ /**
+ * the connectionformat that is used for the route
+ */
+ am_ConnectionFormat_e connectionFormat;
+
+ };
+
+ /**
+ * a list of routing elements that lead from source to sink
+ * @author Christian Mueller
+ * @created 07-Mar-2012 6:06:14 PM
+ */
+ struct am_Route_s
+ {
+
+ public:
+ /**
+ * the sourceID where the route starts
+ */
+ am_sourceID_t sourceID;
+ /**
+ * the sinkID where the route ends
+ */
+ am_sinkID_t sinkID;
+ /**
+ * the actual route as list of routing elements
+ */
+ std::vector<am_RoutingElement_s> route;
+
+ };
+
+ /**
+ * struct describing the sound property
+ * @author Christian Mueller
+ * @created 07-Mar-2012 6:06:15 PM
+ */
+ struct am_SoundProperty_s
+ {
+
+ public:
+ /**
+ * the type of the property - a project specific enum
+ */
+ am_SoundPropertyType_e type;
+ /**
+ * the actual value of the property
+ */
+ int16_t value;
+
+ };
+
+ /**
+ * struct describing system properties
+ * @author Christian Mueller
+ * @created 07-Mar-2012 6:06:15 PM
+ */
+ struct am_SystemProperty_s
+ {
+
+ public:
+ /**
+ * the type that is set
+ */
+ am_SystemPropertyType_e type;
+ /**
+ * the value
+ */
+ int16_t value;
+
+ };
+
+ /**
+ * struct describing sinkclasses
+ * @author Christian Mueller
+ * @created 07-Mar-2012 6:06:15 PM
+ */
+ struct am_SinkClass_s
+ {
+
+ public:
+ /**
+ * the ID of the sinkClass
+ */
+ am_sinkClass_t sinkClassID;
+ /**
+ * the name of the sinkClass - must be unique in the system
+ */
+ std::string name;
+ /**
+ * the list of the class properties. These are pairs of a project specific enum
+ * describing the type of the value and an integer holding the real value.
+ */
+ std::vector<am_ClassProperty_s> listClassProperties;
+
+ };
+
+ /**
+ * struct describing source classes
+ * @author Christian Mueller
+ * @created 07-Mar-2012 6:06:15 PM
+ */
+ struct am_SourceClass_s
+ {
+
+ public:
+ /**
+ * the source ID
+ */
+ am_sourceClass_t sourceClassID;
+ /**
+ * the name of the sourceClass - must be unique in the system
+ */
+ std::string name;
+ /**
+ * the list of the class properties. These are pairs of a project specific enum
+ * describing the type of the value and an integer holding the real value.
+ */
+ std::vector<am_ClassProperty_s> listClassProperties;
+
+ };
+
+ /**
+ * this type holds all information of sources relevant to the HMI
+ * @author Christian Mueller
+ * @created 07-Mar-2012 6:06:15 PM
+ */
+ struct am_SourceType_s
+ {
+
+ public:
+ /**
+ * This is the ID of the source, it is unique in the system. There are 2 ways, ID
+ * can be created: either it is assigned during the registration process (in a
+ * dynamic context, uniqueness will be ensured by the AudioManagerDaemon), or it
+ * is a fixed (the project has to ensure the uniqueness of the ID).
+ */
+ am_sourceID_t sourceID;
+ /**
+ * The name of the source. Must be unique in the whole system.
+ */
+ std::string name;
+ /**
+ * the availability of the source
+ */
+ am_Availability_s availability;
+ /**
+ * the sourceClassID, indicates the class the source is in. This information can
+ * be used by the Controller to implement different behaviour for different
+ * classes.
+ */
+ am_sourceClass_t sourceClassID;
+
+ };
+
+ /**
+ * this type holds all information of sinks relevant to the HMI
+ * @author Christian Mueller
+ * @created 07-Mar-2012 6:06:15 PM
+ */
+ struct am_SinkType_s
+ {
+
+ public:
+ /**
+ * This is the ID of the sink, it is unique in the system. There are 2 ways, ID
+ * can be created: either it is assigned during the registration process (in a
+ * dynamic context, uniqueness will be ensured by the AudioManagerDaemon), or it
+ * is a fixed (the project has to ensure the uniqueness of the ID).
+ */
+ am_sinkID_t sinkID;
+ /**
+ * The name of the sink. Must be unique in the whole system.
+ */
+ std::string name;
+ /**
+ * This attribute reflects the availability of the sink. There are several reasons
+ * why a sink could be not available for the moment: for example the shutdown of a
+ * sink because of overtemperature or over- & undervoltage. The availability
+ * consists of two pieces of information:
+ *
+ * Availablility: the status itself, can be A_AVAILABLE, A_UNAVAILABLE or
+ * A_UNKNOWN
+ * AvailabilityReason: this informs about the last reason for a change in
+ * availability. The reasons itself are product specific.
+ */
+ am_Availability_s availability;
+ /**
+ * This is the representation of the Volume for the commandInterface. It is used
+ * by the HMI to set the volume of a sink, the AudioManagerController has to
+ * transform this into real source and sink volumes.
+ */
+ am_mainVolume_t volume;
+ am_MuteState_e muteState;
+ /**
+ * The sinkClassID references to a sinkClass. With the help of classification,
+ * rules can be setup to define the system behaviour.
+ */
+ am_sinkClass_t sinkClassID;
+
+ };
+
+ /**
+ * a handle is used for asynchronous operations and is uniquely assigned for each
+ * of this operations
+ * @author Christian Mueller
+ * @created 07-Mar-2012 6:06:15 PM
+ */
+ struct am_Handle_s
+ {
+
+ public:
+ /**
+ * the handletype
+ */
+ am_Handle_e handleType:4;
+ /**
+ * the handle as value
+ */
+ uint16_t handle:12;
+
+ };
+
+ /**
+ * struct describung mainsound property
+ * @author Christian Mueller
+ * @created 07-Mar-2012 6:06:15 PM
+ */
+ struct am_MainSoundProperty_s
+ {
+
+ public:
+ /**
+ * the type of the property
+ */
+ am_MainSoundPropertyType_e type;
+ /**
+ * the actual value
+ */
+ int16_t value;
+
+ };
+
+ /**
+ * this type holds all information of connections relevant to the HMI
+ * @author Christian Mueller
+ * @created 07-Mar-2012 6:06:15 PM
+ */
+ struct am_MainConnectionType_s
+ {
+
+ public:
+ /**
+ * the ID of the mainconnection
+ */
+ am_mainConnectionID_t mainConnectionID;
+ /**
+ * the sourceID where the connection starts
+ */
+ am_sourceID_t sourceID;
+ /**
+ * the sinkID where the connection ends
+ */
+ am_sinkID_t sinkID;
+ /**
+ * the delay of the mainconnection
+ */
+ am_timeSync_t delay;
+ /**
+ * the current connection state
+ */
+ am_ConnectionState_e connectionState;
+
+ };
+
+ /**
+ * struct that holds attribiutes of a mainconnection
+ * @author Christian Mueller
+ * @created 07-Mar-2012 6:06:16 PM
+ */
+ struct am_MainConnection_s
+ {
+
+ public:
+ /**
+ * the assigned ID
+ */
+ am_mainConnectionID_t mainConnectionID;
+ /**
+ * the current connection state
+ */
+ am_ConnectionState_e connectionState;
+ /**
+ * the sinkID
+ */
+ am_sinkID_t sinkID;
+ /**
+ * the sourceID
+ */
+ am_sourceID_t sourceID;
+ /**
+ * the delay of the connection
+ */
+ am_timeSync_t delay;
+ /**
+ * the list of sub connection IDs the mainconnection consists of
+ */
+ std::vector<am_connectionID_t> listConnectionID;
+
+ };
+
+ /**
+ * This struct describes the attribiutes of a sink
+ * @author Christian Mueller
+ * @created 07-Mar-2012 6:06:16 PM
+ */
+ struct am_Sink_s
+ {
+
+ public:
+ /**
+ * This is the ID of the sink, it is unique in the system. There are 2 ways, ID
+ * can be created: either it is assigned during the registration process (in a
+ * dynamic context, uniqueness will be ensured by the AudioManagerDaemon), or it
+ * is a fixed (the project has to ensure the uniqueness of the ID).
+ */
+ am_sinkID_t sinkID;
+ /**
+ * The name of the sink. Must be unique in the whole system.
+ */
+ std::string name;
+ /**
+ * The domainID is the domain the sink belongs to. A sink can only be in one
+ * domain.
+ */
+ am_domainID_t domainID;
+ /**
+ * The sinkClassID references to a sinkClass. With the help of classification,
+ * rules can be setup to define the system behaviour.
+ */
+ am_sinkClass_t sinkClassID;
+ /**
+ * This is the volume of the sink. It is set by the AudioManagerController.
+ */
+ am_volume_t volume;
+ /**
+ * This Boolean flag indicates whether a sink is visible to the commandInterface
+ * or not. If the User must have the possibility to choose the source in the HMI,
+ * it must be visible. But there are also good reasons for invisible sinks, for
+ * example if the sink is part of a crossfader or gateway. HMI relevant changes in
+ * visible sinks will be automatically reported by the daemon to the
+ * commandInterface.
+ */
+ bool visible;
+ /**
+ * This attribute reflects the availability of the sink. There are several reasons
+ * why a sink could be not available for the moment: for example the shutdown of a
+ * sink because of overtemperature or over- & undervoltage. The availability
+ * consists of two pieces of information:
+ *
+ * Availablility: the status itself, can be A_AVAILABLE, A_UNAVAILABLE or
+ * A_UNKNOWN
+ * AvailabilityReason: this informs about the last reason for a change in
+ * availability. The reasons itself are product specific.
+ */
+ am_Availability_s available;
+ /**
+ * This attribute reflects the muteState of the sink. The information is not the
+ * "real" state of the sink, but the HMI representation for he commandInterface
+ * controlled by the AudioManagerController.
+ */
+ am_MuteState_e muteState;
+ /**
+ * This is the representation of the Volume for the commandInterface. It is used
+ * by the HMI to set the volume of a sink, the AudioManagerController has to
+ * transform this into real source and sink volumes.
+ */
+ am_mainVolume_t mainVolume;
+ /**
+ * This is the list of soundProperties, that the sink is capable of. The
+ * soundProperties itself are project specific. For sinks, a possible
+ * soundProperty could be for example settings.
+ */
+ std::vector<am_SoundProperty_s> listSoundProperties;
+ /**
+ * This list holds information about the formats that the Source is capable of
+ * supporting when delivering audio.
+ */
+ std::vector<am_ConnectionFormat_e> listConnectionFormats;
+ /**
+ * This is the list of the available mainSoundProperties. The principle is the
+ * same than with soundProperties, but they are only visible to the
+ * CommandInterface.
+ */
+ std::vector<am_MainSoundProperty_s> listMainSoundProperties;
+
+ };
+
+ /**
+ * This struct describes the attribiutes of a source
+ * @author Christian Mueller
+ * @created 07-Mar-2012 6:06:16 PM
+ */
+ struct am_Source_s
+ {
+
+ public:
+ /**
+ * This is the ID of the source, it is unique in the system. There are 2 ways, ID
+ * can be created: either it is assigned during the registration process (in a
+ * dynamic context, uniqueness will be ensured by the AudioManagerDaemon), or it
+ * is a fixed (the project has to ensure the uniqueness of the ID).
+ */
+ am_sourceID_t sourceID;
+ /**
+ * The domainID is the domain the source belongs to. A source can only be in one
+ * domain.
+ */
+ am_domainID_t domainID;
+ /**
+ * The name of the source. Must be unique in the whole system.
+ */
+ std::string name;
+ /**
+ * the sourceClassID, indicates the class the source is in. This information can
+ * be used by the Controller to implement different behaviour for different
+ * classes.
+ */
+ am_sourceClass_t sourceClassID;
+ /**
+ * The source state is an indication towards the source if it is actively heard or
+ * not. The source can use this information to implement features like automatic
+ * spin down of CD's in case the CD is not the active source or AF following of a
+ * tuner that is not actively heard. The source state is set by the
+ * AudioManagerController.There are 3 possible states:
+ *
+ * SS_ON: the source is active
+ * SS_OFF: the source is off
+ * SS_PAUSED: the source is paused and not active.
+ */
+ am_SourceState_e sourceState;
+ /**
+ * This is the volume of the source. It is set by the AudioManagerController. It
+ * is used to adopt different audiolevels in a system and mixing of sources (e.g.
+ * navigation hints & music).
+ */
+ am_volume_t volume;
+ /**
+ * This Boolean flag indicates whether a source is visible to the commandInterface
+ * or not. If the User must have the possibility to choose the source in the HMI,
+ * it must be visible. But there are also good reasons for invisible sources, for
+ * example if the source is part of a crossfader or gateway. HMI relevant changes
+ * in visible sources will be automatically reported by the daemon to the
+ * commandInterface.
+ */
+ bool visible;
+ /**
+ * This attribute reflects the availability of the source. There are several
+ * reasons why a source could be not available for the moment. For example a CD
+ * player which has no CD entered in the slot can be unavailable, or a USB player
+ * with no or unreadable stick attached. Other scenarios involve the shutdown of a
+ * source because of overtemperature or over- & undervoltage. The availability
+ * consists of two informations:
+ *
+ * Availablility: the status itself, can be A_AVAILABLE, A_UNAVAILABLE or
+ * A_UNKNOWN
+ * AvailabilityReason: this informs about the last reason for a change in
+ * availability. The reasons itself are product specific.
+ */
+ am_Availability_s available;
+ /**
+ * Some special sources can have special behaviors, the are so called "Low Level
+ * Interrupts". Here the current status is documented. The information can be used
+ * by the AudioManagerController to react to the changes by for example lowering
+ * the volume of the mainSources. The two states are
+ *
+ * IS_OFF: the interrupt is not active at the moment
+ * IS_INTERRUPTED: the interrupt is playing at the moment.
+ */
+ am_InterruptState_e interruptState;
+ /**
+ * This is the list of soundProperties, that the source is capable of. The
+ * soundProperties itself are project specific. For sources, a possible
+ * soundProperty could be navigation volume offset, for example.
+ */
+ std::vector<am_SoundProperty_s> listSoundProperties;
+ /**
+ * This list holds information about the formats that the Source is capable of
+ * supporting when delivering audio.
+ */
+ std::vector<am_ConnectionFormat_e> listConnectionFormats;
+ /**
+ * This is the list of the available mainSoundProperties. The principle is the
+ * same than with soundProperties, but they are only visible to the
+ * CommandInterface.
+ */
+ std::vector<am_MainSoundProperty_s> listMainSoundProperties;
+
+ };
+
+ /**
+ * This struct describes the attribiutes of a domain
+ * @author Christian Mueller
+ * @created 07-Mar-2012 6:06:16 PM
+ */
+ struct am_Domain_s
+ {
+
+ public:
+ /**
+ * the domain ID
+ */
+ am_domainID_t domainID;
+ /**
+ * the name of the domain
+ */
+ std::string name;
+ /**
+ * the busname. This is equal to a plugin name and is used to dispatch messages to
+ * the elements of a plugin
+ */
+ std::string busname;
+ /**
+ * the name of the node
+ */
+ std::string nodename;
+ /**
+ * indicated if the domain is independent at startup or not
+ */
+ bool early;
+ /**
+ * indicates if the domain registration is complete or not
+ */
+ bool complete;
+ /**
+ * the current domain state
+ */
+ am_DomainState_e state;
+
+ };
+
+ /**
+ * a connection
+ * @author Christian Mueller
+ * @created 07-Mar-2012 6:06:16 PM
+ */
+ struct am_Connection_s
+ {
+
+ public:
+ /**
+ * the assigned ID
+ */
+ am_connectionID_t connectionID;
+ /**
+ * the source the audio flows from
+ */
+ am_sourceID_t sourceID;
+ /**
+ * the sink the audio flows to
+ */
+ am_sinkID_t sinkID;
+ /**
+ * the delay of the conneciton
+ */
+ am_timeSync_t delay;
+ /**
+ * the used connectionformat
+ */
+ am_ConnectionFormat_e connectionFormat;
+
+ };
+
+ /**
+ * data type depends of am_EarlyDataType_e:
+ * volume_t in case of ED_SOURCE_VOLUME, ED_SINK_VOLUME
+ * soundProperty_t in case of ED_SOURCE_PROPERTY, ED_SINK_PROPERTY
+ * @author Christian Mueller
+ * @created 07-Mar-2012 6:06:16 PM
+ */
+ union am_EarlyData_u
+ {
+
+ public:
+ am_volume_t volume;
+ am_SoundProperty_s soundProperty;
+
+ };
+
+ /**
+ * data type depends of am_EarlyDataType_e:
+ * sourceID in case of ED_SOURCE_VOLUME, ED_SOURCE_PROPERTY
+ * sinkID in case of ED_SINK_VOLUME, ED_SINK_PROPERTY
+ * @author Christian Mueller
+ * @created 07-Mar-2012 6:06:16 PM
+ */
+ union am_DataType_u
+ {
+
+ public:
+ am_sinkID_t sink;
+ am_sourceID_t source;
+
+ };
+
+ /**
+ * @author Christian Mueller
+ * @created 07-Mar-2012 6:06:17 PM
+ */
+ struct am_EarlyData_s
+ {
+
+ public:
+ am_EarlyDataType_e type;
+ am_DataType_u sinksource;
+ am_EarlyData_u data;
+
+ };
+}
+#endif // !defined(EA_F9B4F59D_FED5_44ac_85F2_F9F60549C133__INCLUDED_)
diff --git a/exampleCode/player/dbushandler.cpp b/exampleCode/player/dbushandler.cpp new file mode 100644 index 0000000..c449d93 --- /dev/null +++ b/exampleCode/player/dbushandler.cpp @@ -0,0 +1,742 @@ +/** + * Copyright (C) 2012, BMW AG + * + * + * \copyright + * 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, version 2 + * 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, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * + * \author Christian Mueller, christian.ei.mueller@bmw.de BMW 2011,2012 + * + * + */ +#include "dbushandler.h" +#include <stdio.h> +#include <stdio.h> +#include <errno.h> +#include <stdlib.h> +#include <string.h> +#include <dbus/dbus.h> +#include <glib.h> +#include <stdint.h> +#include <dbus/dbus-glib.h> +#include <dbus/dbus-glib-lowlevel.h> +#include <pthread.h> + +DBusMessage* DbusHandler::msg; +DBusMessageIter DbusHandler::args; +DBusConnection* DbusHandler::conn; +DBusError DbusHandler::err; +DBusPendingCall* DbusHandler::pending; +gboolean DbusHandler:: ret; +dbus_uint16_t DbusHandler::result; +GMainLoop* DbusHandler::mainloop; + +DbusHandler::DbusHandler() +{ + dbus_error_init(&err); + conn = dbus_bus_get(DBUS_BUS_SESSION, &err); + if (!conn) + printf("did not get connection error %s", err.message); + pthread_t thread1; + int threadid; + threadid = pthread_create(&thread1,NULL,DbusHandler::Initialize,(void*)this); +} + + DBusHandlerResult DbusHandler::signal_filter(DBusConnection *c, DBusMessage *message, void *user_data) +{ + fprintf(stderr,"entered into signal_filter\n"); + + // s_userdata * tempUserdata=static_cast<s_userdata *>(user_data); + // GMainLoop *loop = tempUserdata->Tempmainloop; + DbusHandler * tempHandler=static_cast<DbusHandler *>(user_data); + DBusMessageIter args,args1; + dbus_uint16_t sink; + + + fprintf(stderr,"received: member %s\n",dbus_message_get_member(message)); + + if (dbus_message_is_signal(message, "org.genivi.audiomanager", "VolumeChanged")) + { + dbus_int16_t Vol; + fprintf(stderr,"Message customized received\n"); + if (!dbus_message_iter_init(message, &args)) + fprintf(stderr, "VolumeChanged :Message Has No Parameters\n"); + else + dbus_message_iter_get_basic(&args, &sink); + if (!dbus_message_iter_next(&args)) + fprintf(stderr, "VolumeChanged :Message has too few arguments!\n"); + else + dbus_message_iter_get_basic(&args, &Vol); + emit tempHandler->Volumechanged(sink,Vol); + fprintf(stderr,"Got Signal with value %d ,%d\n", sink, Vol); + return DBUS_HANDLER_RESULT_HANDLED; + } + + if (dbus_message_is_signal(message, "org.genivi.audiomanager", "NumberOfMainConnectionsChanged")) + { + + fprintf(stderr,"Message customized received\n"); + emit tempHandler->NumberOfConnectionsChanged(); + return DBUS_HANDLER_RESULT_HANDLED; + } + if (dbus_message_is_signal(message, "org.genivi.audiomanager", "MainConnectionStateChanged")) + { + + fprintf(stderr,"Message customized received\n"); + emit tempHandler->NumberOfConnectionsChanged(); + return DBUS_HANDLER_RESULT_HANDLED; + } + + if (dbus_message_is_signal(message, "org.genivi.audiomanager", "SinkMuteStateChanged")) + {dbus_int16_t mutestate; + fprintf(stderr,"Message customized received\n"); + if (!dbus_message_iter_init(message, &args)) + fprintf(stderr, "SinkMuteStateChanged :Message Has No Parameters\n"); + else + dbus_message_iter_get_basic(&args, &sink); + if (!dbus_message_iter_next(&args)) + fprintf(stderr, "SinkMuteStateChanged :Message has too few arguments!\n"); + else{ + dbus_message_iter_get_basic(&args, &mutestate); + + emit tempHandler->Mutestatechanged(sink,static_cast<am_MuteState_e>(mutestate)); + } + return DBUS_HANDLER_RESULT_HANDLED; + } + if (dbus_message_is_signal(message, "org.genivi.audiomanager", "MainSinkSoundPropertyChanged")) + {dbus_int16_t type,value; + if (!dbus_message_iter_init(message, &args)) + fprintf(stderr, "SoundProperychanged :Message Has No Parameters\n"); + else + dbus_message_iter_get_basic(&args, &sink); + if (!dbus_message_iter_next(&args)) + fprintf(stderr, "SoundProperychanged :Message has too few arguments!\n"); + else + if (DBUS_TYPE_STRUCT == dbus_message_iter_get_arg_type(&args)) + { + + dbus_message_iter_recurse(&args, &args1); + dbus_message_iter_get_basic(&args1, &type); + fprintf(stderr, "type :%d\n",type); + dbus_message_iter_next(&args1); + dbus_message_iter_get_basic(&args1, &value); + fprintf(stderr, "value :%d\n",value); + } + fprintf(stderr,"Message customized received\n"); + am_MainSoundProperty_s tempsoundproperty; + tempsoundproperty.type=static_cast<am_MainSoundPropertyType_e>(type); + tempsoundproperty.value=value; + emit tempHandler->SoundpropertyChanged(sink,tempsoundproperty); + return DBUS_HANDLER_RESULT_HANDLED; + } + + + const char* interface = dbus_message_get_interface(message); + const char* member = dbus_message_get_member(message); + const char* path = dbus_message_get_path(message); + fprintf(stderr,"path %s\n",path); + + if (strcmp(member,"asyncSetSourceState")==0) + { + uint16_t sourceID=0, handle=0; + int16_t state=0; + if (!dbus_message_iter_init(message, &args)) + fprintf(stderr, "asyncSetSourceState :Message Has No Parameters\n"); + else + dbus_message_iter_get_basic(&args, &handle); + if (!dbus_message_iter_next(&args)) + fprintf(stderr, "asyncSetSourceState :Message has too few arguments!\n"); + else + dbus_message_iter_get_basic(&args, &sourceID); + if (!dbus_message_iter_next(&args)) + fprintf(stderr, "asyncSetSourceState :Message has too few arguments!\n"); + else + dbus_message_iter_get_basic(&args, &state); + + emit tempHandler->SourceActivity(static_cast<am_sourceID_t>(sourceID),static_cast<am_SourceState_e>(state)); + } + return DBUS_HANDLER_RESULT_HANDLED; + } + +void* DbusHandler::Initialize(void * userdata) +{ + // DbusHandler * abc =static_cast<DbusHandler *>(userdata); + static DBusObjectPathVTable vtable_root; + vtable_root.message_function = signal_filter; + mainloop = g_main_loop_new(NULL, FALSE); + dbus_connection_setup_with_g_main (conn, NULL); + dbus_bus_add_match(conn, "type='signal',interface='org.genivi.audiomanager'", &err); + dbus_bus_add_match(conn, "sender='org.genivi.audiomanager',member='asyncSetSourceState'", &err); + if (dbus_error_is_set(&err)) + { + printf("Match Error (%s)\n", err.message); + exit(1); + } + + ret = dbus_connection_add_filter(conn,signal_filter,userdata, NULL); + if (!ret) + { + fprintf(stderr,"dbus_connection_add_filter failed"); + } + + dbus_connection_flush(conn); + if (dbus_error_is_set(&err)) + { + printf("Problem to flush (%s)\n", err.message); + exit(1); + } + + fprintf(stderr,"Match rule sent\n"); + + g_main_loop_run (mainloop); +} +//------------------------------------------------------------------------- +int DbusHandler::Sender() +{ + if (NULL == msg) + { + fprintf(stderr, "Message Null\n"); + exit(1); + } + //sleep(1); + + if (!dbus_connection_send_with_reply(conn, msg, &pending, -1)) + { + fprintf(stderr, "Sender: Out Of Memory!\n"); + exit(1); + } + if (NULL == pending) + { + fprintf(stderr, "Pending Call Null\n"); + exit(1); + } + dbus_connection_flush(conn); + printf("Request Sent\n"); + + dbus_message_unref(msg); + + dbus_pending_call_block(pending); + + msg = dbus_pending_call_steal_reply(pending); + if (NULL == msg) + { + fprintf(stderr, "Reply Null\n"); + exit(1); + } + return 0; +} +//--------------------------------------------------------------------- +int DbusHandler::Sender_forlists() +{ + if (NULL == msg) + { + fprintf(stderr, "Message Null\n"); + exit(1); + } + sleep(1); + + if (!dbus_connection_send_with_reply(conn, msg, &pending, -1)) + { + fprintf(stderr, "Sender: Out Of Memory!\n"); + exit(1); + } + if (NULL == pending) + { + fprintf(stderr, "Pending Call Null\n"); + exit(1); + } + dbus_connection_flush(conn); + printf("Request Sent\n"); + + dbus_message_unref(msg); + + dbus_pending_call_block(pending); + + msg = dbus_pending_call_steal_reply(pending); + if (NULL == msg) + { + fprintf(stderr, "Reply Null\n"); + exit(1); + } + return 0; +} + +//---------------------------------------------------------------- +am_Error_e DbusHandler::connect(am_sourceID_t SourceID,am_sinkID_t SinkID ,am_connectionID_t &ConnectionID) +{ + msg = dbus_message_new_method_call("org.genivi.audiomanager", // target for the method call + "/org/genivi/audiomanager/CommandInterface", // object to call on + "org.genivi.audiomanager.CommandInterface", // interface to call on + "Connect"); + + dbus_message_iter_init_append(msg, &args); + if (!dbus_message_iter_append_basic(&args, DBUS_TYPE_UINT16, &SourceID)) + { + fprintf(stderr, "in Connect 1st Arg Out Of Memory!\n"); + exit(1); + } + if (!dbus_message_iter_append_basic(&args, DBUS_TYPE_UINT16, &SinkID)) + { + fprintf(stderr, "in Connect 2nd Arg Out Of Memory!\n"); + exit(1); + } + Sender(); + dbus_pending_call_unref(pending); + DBusMessageIter iter1 ; + + + if (!dbus_message_iter_init(msg, &iter1)) + fprintf(stderr, "Message Has No Parameters\n"); + if (DBUS_TYPE_INT16!= dbus_message_iter_get_arg_type(&iter1)) + { printf("Incorrect value recieved %c",dbus_message_iter_get_arg_type(&iter1)); + exit(1); + } + dbus_message_iter_get_basic(&iter1, &result); + fprintf(stderr,"Got result ,%d\n", result); + dbus_message_iter_next(&iter1); + if (DBUS_TYPE_UINT16!= dbus_message_iter_get_arg_type(&iter1)) + { printf("Incorrect value recieved %c",dbus_message_iter_get_arg_type(&iter1)); + exit(1); + } + dbus_message_iter_get_basic(&iter1, &ConnectionID); + fprintf(stderr,"Got result ,%d\n", ConnectionID); +return static_cast <am_Error_e>(result); +} + +////------------------------------------------------------------------------------------ +am_Error_e DbusHandler::disconnect(unsigned int ConnectionID) +{ + msg = dbus_message_new_method_call("org.genivi.audiomanager", // target for the method call + "/org/genivi/audiomanager/CommandInterface", // object to call on + "org.genivi.audiomanager.CommandInterface", // interface to call on + "Disconnect"); + dbus_message_iter_init_append(msg, &args); + if (!dbus_message_iter_append_basic(&args, DBUS_TYPE_UINT16, &ConnectionID)) + { + fprintf(stderr, "Out Of Memory!\n"); + exit(1); + } + cout<<"Attempting to send"<<endl; + Sender(); + dbus_pending_call_unref(pending); + DBusMessageIter iter1 ; + if (!dbus_message_iter_init(msg, &iter1)) + fprintf(stderr, "Message Has No Parameters\n"); + if (DBUS_TYPE_INT16!= dbus_message_iter_get_arg_type(&iter1)) + { printf("Incorrect value recieved %c",dbus_message_iter_get_arg_type(&iter1)); + exit(1); + } + dbus_message_iter_get_basic(&iter1, &result); + fprintf(stderr,"Got result ,%d\n", result); + return static_cast <am_Error_e>(result); +} +////---------------------------------------------------------------------------- +am_Error_e DbusHandler:: SetVolume(const am_sinkID_t sinkID, const am_mainVolume_t volume) +{ + msg = dbus_message_new_method_call("org.genivi.audiomanager", // target for the method call + "/org/genivi/audiomanager/CommandInterface", // object to call on + "org.genivi.audiomanager.CommandInterface", // interface to call on + "SetVolume"); + dbus_message_iter_init_append(msg, &args); + if (!dbus_message_iter_append_basic(&args, DBUS_TYPE_UINT16, &sinkID)) + { + fprintf(stderr, "Out Of Memory!\n"); + exit(1); + } + if (!dbus_message_iter_append_basic(&args, DBUS_TYPE_INT16, &volume)) + { + fprintf(stderr, "Out Of Memory!\n"); + exit(1); + } + + Sender(); + dbus_pending_call_unref(pending); + DBusMessageIter iter1 ; + + + if (!dbus_message_iter_init(msg, &iter1)) + fprintf(stderr, "Message Has No Parameters\n"); + if (DBUS_TYPE_INT16!= dbus_message_iter_get_arg_type(&iter1)) + { + printf("Incorrect value recieved %c",dbus_message_iter_get_arg_type(&iter1)); + + exit(1); + } + dbus_message_iter_get_basic(&iter1, &result); + fprintf(stderr,"Got result ,%d\n", result); + return static_cast <am_Error_e>(result); +} +////------------------------------------------------------------------------------------------ + +am_Error_e DbusHandler:: VolumeStep(const am_sinkID_t sinkID, const int16_t volumeStep) +{msg = dbus_message_new_method_call("org.genivi.audiomanager", // target for the method call + "/org/genivi/audiomanager/CommandInterface", // object to call on + "org.genivi.audiomanager.CommandInterface", // interface to call on + "VolumeStep"); +dbus_message_iter_init_append(msg, &args); +if (!dbus_message_iter_append_basic(&args, DBUS_TYPE_UINT16, &sinkID)) +{ + fprintf(stderr, "Out Of Memory!\n"); + exit(1); +} +if (!dbus_message_iter_append_basic(&args, DBUS_TYPE_INT16, &volumeStep)) +{ + fprintf(stderr, "Out Of Memory!\n"); + exit(1); +} + +Sender(); +dbus_pending_call_unref(pending); +DBusMessageIter iter1 ; + + +if (!dbus_message_iter_init(msg, &iter1)) +fprintf(stderr, "Message Has No Parameters\n"); +if (DBUS_TYPE_INT16!= dbus_message_iter_get_arg_type(&iter1)) +{ printf("Incorrect value recieved %c",dbus_message_iter_get_arg_type(&iter1)); +exit(1); +} +dbus_message_iter_get_basic(&iter1, &result); +fprintf(stderr,"Got result ,%d\n", result); +return static_cast <am_Error_e>(result); + +} +////----------------------------------------------------------------------------------------- +am_Error_e DbusHandler:: SetSinkMuteState(const am_sinkID_t sinkID, const am_MuteState_e muteState) +{ + msg = dbus_message_new_method_call("org.genivi.audiomanager", // target for the method call + "/org/genivi/audiomanager/CommandInterface", // object to call on + "org.genivi.audiomanager.CommandInterface", // interface to call on + "SetSinkMuteState"); + dbus_message_iter_init_append(msg, &args); + if (!dbus_message_iter_append_basic(&args, DBUS_TYPE_UINT16, &sinkID)) + { + fprintf(stderr, "Out Of Memory!\n"); + exit(1); + } + int temp_mutestate = static_cast<int>(muteState); + if (!dbus_message_iter_append_basic(&args, DBUS_TYPE_INT16, &temp_mutestate)) + { + fprintf(stderr, "Out Of Memory!\n"); + exit(1); + } + + Sender(); + dbus_pending_call_unref(pending); + DBusMessageIter iter1 ; + + + if (!dbus_message_iter_init(msg, &iter1)) + fprintf(stderr, "Message Has No Parameters\n"); + if (DBUS_TYPE_INT16!= dbus_message_iter_get_arg_type(&iter1)) + { printf("Incorrect value recieved %c",dbus_message_iter_get_arg_type(&iter1)); + exit(1); + } + dbus_message_iter_get_basic(&iter1, &result); + fprintf(stderr,"Got result ,%d\n", result); + return static_cast <am_Error_e>(result); + + +} +////--------------------------------------------------------------------------------------------------- +am_Error_e DbusHandler ::SetMainSinkSoundProperty(const am_sinkID_t sinkID, const am_MainSoundProperty_s &soundProperty) +{ + msg = dbus_message_new_method_call("org.genivi.audiomanager", // target for the method call + "/org/genivi/audiomanager/CommandInterface", // object to call on + "org.genivi.audiomanager.CommandInterface", // interface to call on + "SetMainSinkSoundProperty"); + dbus_message_iter_init_append(msg, &args); + if (!dbus_message_iter_append_basic(&args, DBUS_TYPE_UINT16, &sinkID)) + { + fprintf(stderr, "Out Of Memory!\n"); + exit(1); + } + DBusMessageIter structIter; + dbus_bool_t success = true; + dbus_message_iter_open_container(&args, DBUS_TYPE_STRUCT, NULL, &structIter); + success = success && dbus_message_iter_append_basic(&structIter, DBUS_TYPE_INT16, &soundProperty.type); + success = success && dbus_message_iter_append_basic(&structIter, DBUS_TYPE_INT16, &soundProperty.value); + success = success && dbus_message_iter_close_container(&args, &structIter); + + Sender(); + dbus_pending_call_unref(pending); + DBusMessageIter iter1 ; + if (!dbus_message_iter_init(msg, &iter1)) + fprintf(stderr, "Message Has No Parameters\n"); + if (DBUS_TYPE_INT16!= dbus_message_iter_get_arg_type(&iter1)) + { printf("Incorrect value recieved %c",dbus_message_iter_get_arg_type(&iter1)); + char * abc; + dbus_message_iter_append_basic(&args, DBUS_TYPE_STRING, &abc); + printf("Incorrect value recieved %s",abc); + exit(1); + } + dbus_message_iter_get_basic(&iter1, &result); + fprintf(stderr,"Got result ,%d\n", result); + return static_cast <am_Error_e>(result); + + +} +////---------------------------------------------------------------------------------------------------------------------- +am_Error_e DbusHandler::GetListMainConnections(std::vector<am_MainConnectionType_s *> &listConnections) +{ + msg = dbus_message_new_method_call("org.genivi.audiomanager", // target for the method call + "/org/genivi/audiomanager/CommandInterface", // object to call on + "org.genivi.audiomanager.CommandInterface", // interface to call on + "GetListMainConnections"); + Sender(); + dbus_pending_call_unref(pending); + DBusMessageIter subIter,iter1,iter2 ; + if (!dbus_message_iter_init(msg, &iter1)) + fprintf(stderr, "Message Has No Parameters\n"); + if (DBUS_TYPE_INT16!= dbus_message_iter_get_arg_type(&iter1)) + { printf("Incorrect value recieved"); + exit(1); + } + dbus_message_iter_get_basic(&iter1, &result); + fprintf(stderr,"Got result ,%d\n", result); + dbus_message_iter_next(&iter1); + if (DBUS_TYPE_ARRAY== dbus_message_iter_get_arg_type(&iter1)) + { // fprintf(stderr, "a:%d\n", a); + for (dbus_message_iter_recurse(&iter1, &iter2); + dbus_message_iter_get_arg_type(&iter2) != DBUS_TYPE_INVALID; + dbus_message_iter_next(&iter2)) + { + am_MainConnectionType_s* TempConnection= new am_MainConnectionType_s(); + if (DBUS_TYPE_STRUCT == dbus_message_iter_get_arg_type(&iter2)) + { + dbus_message_iter_recurse(&iter2, &subIter); + dbus_uint16_t ConnID,SourceID,SinkID; + dbus_int16_t Timedelay,ConnectionState; + dbus_message_iter_get_basic(&subIter, &ConnID); + dbus_message_iter_next(&subIter); + dbus_message_iter_get_basic(&subIter, &SourceID); + dbus_message_iter_next(&subIter); + dbus_message_iter_get_basic(&subIter, &SinkID); + dbus_message_iter_next(&subIter); + dbus_message_iter_get_basic(&subIter, &Timedelay); + dbus_message_iter_next(&subIter); + dbus_message_iter_get_basic(&subIter, &ConnectionState); + dbus_message_iter_next(&subIter); + + { + TempConnection->mainConnectionID=ConnID; + TempConnection->sourceID=SourceID; + TempConnection->sinkID=SinkID; + TempConnection->delay=Timedelay; + TempConnection->connectionState=static_cast<am_ConnectionState_e>(ConnectionState); + listConnections.push_back(TempConnection); + } + } + + } + } + + + +return static_cast <am_Error_e>(result); +} +////------------------------------------------------------------Rossini-------------------------------------------------- +am_Error_e DbusHandler::GetListMainSinks(std::vector<am_SinkType_s> &listSinks) +{ msg = dbus_message_new_method_call("org.genivi.audiomanager", // target for the method call + "/org/genivi/audiomanager/CommandInterface", // object to call on + "org.genivi.audiomanager.CommandInterface", // interface to call on + "GetListMainSinks"); + + Sender(); + dbus_pending_call_unref(pending); + DBusMessageIter subIter,iter1,iter2,subsubiter ; + + if (!dbus_message_iter_init(msg, &iter1)) + fprintf(stderr, "Message Has No Parameters\n"); + if (DBUS_TYPE_INT16!= dbus_message_iter_get_arg_type(&iter1)) + { printf("Incorrect value recieved"); + exit(1); + } + dbus_message_iter_get_basic(&iter1, &result); + fprintf(stderr,"Got result ,%d\n", result); + dbus_message_iter_next(&iter1); + if (DBUS_TYPE_ARRAY== dbus_message_iter_get_arg_type(&iter1)) + { // fprintf(stderr, "a:%d\n", a); + for (dbus_message_iter_recurse(&iter1, &iter2); + dbus_message_iter_get_arg_type(&iter2) != DBUS_TYPE_INVALID; + dbus_message_iter_next(&iter2)) + { + am_SinkType_s TempSink; + if (DBUS_TYPE_STRUCT == dbus_message_iter_get_arg_type(&iter2)) + { + dbus_message_iter_recurse(&iter2, &subIter); + dbus_uint16_t SinkID,SinkClassID,availability,availability_reason,volume,mute_state; + char* Sinkname; + dbus_message_iter_get_basic(&subIter, &SinkID); + //fprintf(stderr, "sourceID:%d\n",sourceID); + dbus_message_iter_next(&subIter); + dbus_message_iter_get_basic(&subIter, &Sinkname); + //fprintf(stderr, "name :%s\n",sourcename); + dbus_message_iter_next(&subIter); + if (DBUS_TYPE_STRUCT == dbus_message_iter_get_arg_type(&subIter)) + { + dbus_message_iter_recurse(&subIter, &subsubiter); + dbus_message_iter_get_basic(&subsubiter, &availability); + fprintf(stderr, "availability value:%d\n",availability); + dbus_message_iter_next(&subsubiter); + dbus_message_iter_get_basic(&subsubiter, &availability_reason); + fprintf(stderr, "availability reason value:%d\n",availability_reason); + } + dbus_message_iter_next(&subIter); + dbus_message_iter_get_basic(&subIter, &volume); + dbus_message_iter_next(&subIter); + dbus_message_iter_get_basic(&subIter, &mute_state); + dbus_message_iter_next(&subIter); + dbus_message_iter_get_basic(&subIter, &SinkClassID); + fprintf(stderr, "muteState value:%d\n",SinkClassID); + fprintf(stderr, "*****************************************\n"); + TempSink.sinkID=SinkID; + TempSink.name=Sinkname; + TempSink.availability.availability=static_cast<am_Availablility_e>(availability); + TempSink.availability.availabilityReason=static_cast<am_AvailabilityReason_e>(availability_reason); + TempSink.sinkClassID=SinkClassID; + TempSink.volume=volume; + TempSink.muteState=static_cast<am_MuteState_e>(mute_state); + listSinks.push_back(TempSink); + } + + } + } + return static_cast <am_Error_e>(result); +} +////------------------------------------------------------------------------------------------------- + +am_Error_e DbusHandler::GetListMainSources(std::vector<am_SourceType_s> &listSources) +{ + + msg = dbus_message_new_method_call("org.genivi.audiomanager", // target for the method call + "/org/genivi/audiomanager/CommandInterface", // object to call on + "org.genivi.audiomanager.CommandInterface", // interface to call on + "GetListMainSources"); + + Sender_forlists(); + dbus_pending_call_unref(pending); + DBusMessageIter subIter,iter1,iter2,subsubiter ; + dbus_bool_t success = true; + if (!dbus_message_iter_init(msg, &iter1)) + fprintf(stderr, "Message Has No Parameters\n"); + if (DBUS_TYPE_INT16!= dbus_message_iter_get_arg_type(&iter1)) + { printf("Incorrect value recieved"); + exit(1); + } + dbus_message_iter_get_basic(&iter1, &result); + fprintf(stderr,"Got result ,%d\n", result); + dbus_message_iter_next(&iter1); + if (DBUS_TYPE_ARRAY== dbus_message_iter_get_arg_type(&iter1)) + { // fprintf(stderr, "a:%d\n", a); + for (dbus_message_iter_recurse(&iter1, &iter2); + dbus_message_iter_get_arg_type(&iter2) != DBUS_TYPE_INVALID; + dbus_message_iter_next(&iter2)) + { + am_SourceType_s TempSource; + + if (DBUS_TYPE_STRUCT == dbus_message_iter_get_arg_type(&iter2)) + { + dbus_message_iter_recurse(&iter2, &subIter); + dbus_uint16_t sourceID,SourceClassID,availability,availability_reason; + char* sourcename; + dbus_message_iter_get_basic(&subIter, &sourceID); + //fprintf(stderr, "sourceID:%d\n",sourceID); + dbus_message_iter_next(&subIter); + dbus_message_iter_get_basic(&subIter, &sourcename); + //fprintf(stderr, "name :%s\n",sourcename); + dbus_message_iter_next(&subIter); + if (DBUS_TYPE_STRUCT == dbus_message_iter_get_arg_type(&subIter)) + { + dbus_message_iter_recurse(&subIter, &subsubiter); + dbus_message_iter_get_basic(&subsubiter, &availability); + fprintf(stderr, "availability value:%d\n",availability); + dbus_message_iter_next(&subsubiter); + dbus_message_iter_get_basic(&subsubiter, &availability_reason); + fprintf(stderr, "availability reason value:%d\n",availability_reason); + } + dbus_message_iter_next(&subIter); + dbus_message_iter_get_basic(&subIter, &SourceClassID); + fprintf(stderr, "muteState value:%d\n",SourceClassID); + fprintf(stderr, "*****************************************\n"); + TempSource.sourceID=sourceID; + TempSource.name=sourcename; + TempSource.availability.availability=static_cast<am_Availablility_e>(availability); + TempSource.availability.availabilityReason=static_cast<am_AvailabilityReason_e>(availability_reason); + TempSource.sourceClassID=SourceClassID; + listSources.push_back(TempSource); + } + + } + } + return static_cast <am_Error_e>(result); +} + + +////-------------------------------------------------------------------------------------------------------------------- +am_Error_e DbusHandler::GetListMainSinkSoundProperties(const am_sinkID_t sinkID, std::vector<am_MainSoundProperty_s *> &listSoundProperties) +{ msg = dbus_message_new_method_call("org.genivi.audiomanager", // target for the method call + "/org/genivi/audiomanager/CommandInterface", // object to call on + "org.genivi.audiomanager.CommandInterface", // interface to call on + "GetListMainSinkSoundProperties"); + + + dbus_message_iter_init_append(msg, &args); + if (!dbus_message_iter_append_basic(&args, DBUS_TYPE_UINT16, &sinkID)) + { + fprintf(stderr, "GetListMainSinkSoundProperties Out Of Memory!\n"); + exit(1); + } + Sender(); + dbus_pending_call_unref(pending); + DBusMessageIter subIter,iter1,iter2 ; + + if (!dbus_message_iter_init(msg, &iter1)) + fprintf(stderr, "Message Has No Parameters\n"); + if (DBUS_TYPE_INT16!= dbus_message_iter_get_arg_type(&iter1)) + { printf("Incorrect value recieved,%c",dbus_message_iter_get_arg_type(&iter1)); + exit(1); + } + + dbus_message_iter_get_basic(&iter1, &result); + + dbus_message_iter_next(&iter1); + if (DBUS_TYPE_ARRAY== dbus_message_iter_get_arg_type(&iter1)) + { // fprintf(stderr, "a:%d\n", a); + for (dbus_message_iter_recurse(&iter1, &iter2); + dbus_message_iter_get_arg_type(&iter2) != DBUS_TYPE_INVALID; + dbus_message_iter_next(&iter2)) + {am_MainSoundProperty_s* SoundProperty= new am_MainSoundProperty_s(); + + if (DBUS_TYPE_STRUCT == dbus_message_iter_get_arg_type(&iter2)) + { + dbus_message_iter_recurse(&iter2, &subIter); + dbus_uint16_t Type,Value; + dbus_message_iter_get_basic(&subIter, &Type); + //fprintf(stderr, "sourceID:%d\n",sourceID); + dbus_message_iter_next(&subIter); + dbus_message_iter_get_basic(&subIter, &Value); + SoundProperty->type=static_cast<am_MainSoundPropertyType_e>(Type); + SoundProperty->value=Value; + listSoundProperties.push_back(SoundProperty); + } + + } + } + return static_cast <am_Error_e>(result); + +} + diff --git a/exampleCode/player/dbushandler.h b/exampleCode/player/dbushandler.h new file mode 100644 index 0000000..884f8c1 --- /dev/null +++ b/exampleCode/player/dbushandler.h @@ -0,0 +1,103 @@ +#ifndef DBUSHANDLER_H +#define DBUSHANDLER_H + +/** + * Copyright (C) 2012, BMW AG + * + * + * \copyright + * 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, version 2 + * 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, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * + * \author Christian Mueller, christian.ei.mueller@bmw.de BMW 2011,2012 + * \author Sruthi Mohan + * + * + */ + +/** + * This is the Class that handles dbus message message communication. + * This is implemented using glib-dbus-c binding + * @author Sruthi Mohan + * @version 1.0 + * @created 10-Feb-2012 1:31:06 PM + */ +#include <stdio.h> +#include <stdio.h> +#include <errno.h> +#include <stdlib.h> +#include <string.h> +#include <dbus/dbus.h> +#include <glib.h> +#include <stdint.h> +#include <dbus/dbus-glib.h> +#include "audiomanagertypes.h" +#include <dbus/dbus-glib-bindings.h> +#include <QObject> +#include <iostream> +#include <vector> + +#define SERVICE_NAME "org.genivi.audiomanager" +#define PATH_NAME "/org/genivi/audiomanager/CommandInterface" +#define INTERFACENAME "org.genivi.audiomanager.CommandInterface" + +using namespace std; +using namespace am; +class AudiomanagerHMIController; + +class DbusHandler : public QObject +{ + Q_OBJECT +public: + explicit DbusHandler(); +signals: + void NumberOfConnectionsChanged(); + void Volumechanged(am_sinkID_t,am_volume_t); + void SoundpropertyChanged(am_sinkID_t,am_MainSoundProperty_s); + void Mutestatechanged(am_sinkID_t,am_MuteState_e); + void SourceActivity(am_sourceID_t source,am_SourceState_e state); +public slots: + static void* Initialize(void*); + int Sender(); + int Sender_forlists(); + am_Error_e connect(am_sourceID_t SourceID,am_sinkID_t SinkID ,am_connectionID_t &ConnectionID); + am_Error_e disconnect(unsigned int ConnectionID); + am_Error_e SetVolume(const am_sinkID_t sinkID, const am_mainVolume_t volume) ; + am_Error_e VolumeStep(const am_sinkID_t sinkID, const int16_t volumeStep) ; + am_Error_e SetSinkMuteState(const am_sinkID_t sinkID, const am_MuteState_e muteState) ; + am_Error_e SetMainSinkSoundProperty( const am_sinkID_t sinkID,const am_MainSoundProperty_s& soundProperty) ; + am_Error_e GetListMainConnections(std::vector<am_MainConnectionType_s* >& listConnections) ; + am_Error_e GetListMainSinks(std::vector<am_SinkType_s>& listSinks) ; + am_Error_e GetListMainSources(std::vector<am_SourceType_s>& listSources) ; + am_Error_e GetListMainSinkSoundProperties(const am_sinkID_t sinkID, std::vector<am_MainSoundProperty_s*>& listSoundProperties) ; + static DBusHandlerResult signal_filter(DBusConnection *c, DBusMessage *message, void *user_data); + +private: + static DBusMessage* msg; + static DBusMessageIter args; + static DBusConnection* conn; + static DBusError err; + static DBusPendingCall* pending; + static gboolean ret; + static dbus_uint16_t result; + static GMainLoop* mainloop; +}; +struct s_userdata +{ + GMainLoop* Tempmainloop; + DbusHandler *ptrDbusHanndler; +}; + +#endif // DBUSHANDLER_H diff --git a/exampleCode/player/images/screen.png b/exampleCode/player/images/screen.png Binary files differnew file mode 100644 index 0000000..a15df92 --- /dev/null +++ b/exampleCode/player/images/screen.png diff --git a/exampleCode/player/main.cpp b/exampleCode/player/main.cpp new file mode 100644 index 0000000..20cc021 --- /dev/null +++ b/exampleCode/player/main.cpp @@ -0,0 +1,98 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the demonstration applications of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:GPL$ +** GNU General Public License Usage +** This file is licensed under GPL v2. +** +** +** $QT_END_LICENSE$ +** +***************************************************************************/ + +#include <QtGui> +#include "mediaplayer.h" +#include "dbushandler.h" +#include "audiomanagerinteractor.h" + +const qreal DefaultVolume = -1.0; + +int main (int argc, char *argv[]) +{ + Q_INIT_RESOURCE(mediaplayer); + QApplication app(argc, argv); + + QStringList args = app.arguments(); + app.setApplicationName(args.at(1)); + std::string appName=args.at(1).toStdString(); + std::string targetName=args.at(2).toStdString(); + + app.setOrganizationName("Genivi"); + app.setQuitOnLastWindowClosed(true); + + QString fileName; + qreal volume = DefaultVolume; + bool smallScreen = false; +#ifdef Q_OS_SYMBIAN + smallScreen = true; +#endif + + am_sourceID_t mySourceID=0; + am_sinkID_t targetSinkID=0; + + DbusHandler dbusHandler; + + //first we need to find out our sourceID + std::vector<am_SourceType_s> listSources; + std::vector<am_SinkType_s> listSinks; + dbusHandler.GetListMainSources(listSources); + dbusHandler.GetListMainSinks(listSinks); + + std::vector<am_SourceType_s>::iterator sourceIter(listSources.begin()); + for (;sourceIter!=listSources.end();++sourceIter) + { + if (sourceIter->name.compare(appName)==0) + mySourceID=sourceIter->sourceID; + } + + std::vector<am_SinkType_s>::iterator sinkIter(listSinks.begin()); + for (;sinkIter!=listSinks.end();++sinkIter) + { + + if (sinkIter->name.compare(targetName)==0) + targetSinkID=sinkIter->sinkID; + } + + std::cout<< "SourceID "<<mySourceID<<std::endl; + + QString appNameSourceID=args.at(1)+" sourceID="+QString::number(mySourceID); + + AudioManagerInteractor interActor(&dbusHandler,mySourceID,targetSinkID); + + + MediaPlayer player(appNameSourceID); + player.setSmallScreen(smallScreen); + if (DefaultVolume != volume) + player.setVolume(volume); + if (!fileName.isNull()) + player.setFile(fileName); + + if (smallScreen) + player.showMaximized(); + else + player.show(); + + QObject::connect((const QObject*)player.playButton, SIGNAL(clicked()),&interActor, SLOT(playPause())); + QObject::connect((const QObject*)&dbusHandler, SIGNAL(SourceActivity(am_sourceID_t ,am_SourceState_e )),&interActor, SLOT(SourceActivity(am_sourceID_t ,am_SourceState_e ))); + QObject::connect((const QObject*)&interActor, SIGNAL(play()),&player, SLOT(play())); + QObject::connect((const QObject*)&interActor, SIGNAL(stop()),&player, SLOT(stop())); + QObject::connect((const QObject*)&player, SIGNAL(MediaStateChanged(Phonon::State)),&interActor, SLOT(getPlayerState(Phonon::State))); + + return app.exec(); +} + diff --git a/exampleCode/player/mainwindow.cpp b/exampleCode/player/mainwindow.cpp new file mode 100755 index 0000000..49d64fc --- /dev/null +++ b/exampleCode/player/mainwindow.cpp @@ -0,0 +1,14 @@ +#include "mainwindow.h" +#include "ui_mainwindow.h" + +MainWindow::MainWindow(QWidget *parent) : + QMainWindow(parent), + ui(new Ui::MainWindow) +{ + ui->setupUi(this); +} + +MainWindow::~MainWindow() +{ + delete ui; +} diff --git a/exampleCode/player/mainwindow.h b/exampleCode/player/mainwindow.h new file mode 100755 index 0000000..dc809f8 --- /dev/null +++ b/exampleCode/player/mainwindow.h @@ -0,0 +1,23 @@ + +#ifndef MAINWINDOW_H +#define MAINWINDOW_H + +#include <QMainWindow> + +namespace Ui { +class MainWindow; +} + +class MainWindow : public QMainWindow +{ + Q_OBJECT + +public: + explicit MainWindow(QWidget *parent = 0); + ~MainWindow(); + +private: + Ui::MainWindow *ui; +}; + +#endif // MAINWINDOW_H diff --git a/exampleCode/player/mainwindow.ui b/exampleCode/player/mainwindow.ui new file mode 100755 index 0000000..6050363 --- /dev/null +++ b/exampleCode/player/mainwindow.ui @@ -0,0 +1,24 @@ +<ui version="4.0"> + <class>MainWindow</class> + <widget class="QMainWindow" name="MainWindow" > + <property name="geometry" > + <rect> + <x>0</x> + <y>0</y> + <width>400</width> + <height>300</height> + </rect> + </property> + <property name="windowTitle" > + <string>MainWindow</string> + </property> + <widget class="QMenuBar" name="menuBar" /> + <widget class="QToolBar" name="mainToolBar" /> + <widget class="QWidget" name="centralWidget" /> + <widget class="QStatusBar" name="statusBar" /> + </widget> + <layoutDefault spacing="6" margin="11" /> + <pixmapfunction></pixmapfunction> + <resources/> + <connections/> +</ui> diff --git a/exampleCode/player/mediaplayer.cpp b/exampleCode/player/mediaplayer.cpp new file mode 100644 index 0000000..1939585 --- /dev/null +++ b/exampleCode/player/mediaplayer.cpp @@ -0,0 +1,970 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the demonstration applications of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:GPL$ +** GNU General Public License Usage +** This file is licensed under GPL v2. +** +** +** $QT_END_LICENSE$ +** +***************************************************************************/ + +#include <QtGui> + +#define SLIDER_RANGE 8 + +#include "mediaplayer.h" +#include "ui_settings.h" + +#ifdef Q_OS_SYMBIAN +#include <cdbcols.h> +#include <cdblen.h> +#include <commdb.h> +#endif + +MediaVideoWidget::MediaVideoWidget(MediaPlayer *player, QWidget *parent) : + Phonon::VideoWidget(parent), m_player(player), m_action(this) +{ + m_action.setCheckable(true); + m_action.setChecked(false); + m_action.setShortcut(QKeySequence( Qt::AltModifier + Qt::Key_Return)); + m_action.setShortcutContext(Qt::WindowShortcut); + connect(&m_action, SIGNAL(toggled(bool)), SLOT(setFullScreen(bool))); + addAction(&m_action); + setAcceptDrops(true); +} + +void MediaVideoWidget::setFullScreen(bool enabled) +{ + Phonon::VideoWidget::setFullScreen(enabled); + emit fullScreenChanged(enabled); +} + +void MediaVideoWidget::mouseDoubleClickEvent(QMouseEvent *e) +{ + Phonon::VideoWidget::mouseDoubleClickEvent(e); + setFullScreen(!isFullScreen()); +} + +void MediaVideoWidget::keyPressEvent(QKeyEvent *e) +{ + if(!e->modifiers()) { + // On non-QWERTY Symbian key-based devices, there is no space key. + // The zero key typically is marked with a space character. + if (e->key() == Qt::Key_Space || e->key() == Qt::Key_0) { + //m_player->playPause(); + e->accept(); + return; + } + + // On Symbian devices, there is no key which maps to Qt::Key_Escape + // On devices which lack a backspace key (i.e. non-QWERTY devices), + // the 'C' key maps to Qt::Key_Backspace + else if (e->key() == Qt::Key_Escape || e->key() == Qt::Key_Backspace) { + setFullScreen(false); + e->accept(); + return; + } + } + Phonon::VideoWidget::keyPressEvent(e); +} + +bool MediaVideoWidget::event(QEvent *e) +{ + switch(e->type()) + { + case QEvent::Close: + //we just ignore the cose events on the video widget + //this prevents ALT+F4 from having an effect in fullscreen mode + e->ignore(); + return true; + case QEvent::MouseMove: +#ifndef QT_NO_CURSOR + unsetCursor(); +#endif + //fall through + case QEvent::WindowStateChange: + { + //we just update the state of the checkbox, in case it wasn't already + m_action.setChecked(windowState() & Qt::WindowFullScreen); + const Qt::WindowFlags flags = m_player->windowFlags(); + if (windowState() & Qt::WindowFullScreen) { + m_timer.start(1000, this); + } else { + m_timer.stop(); +#ifndef QT_NO_CURSOR + unsetCursor(); +#endif + } + } + break; + default: + break; + } + + return Phonon::VideoWidget::event(e); +} + +void MediaVideoWidget::timerEvent(QTimerEvent *e) +{ + if (e->timerId() == m_timer.timerId()) { + //let's store the cursor shape +#ifndef QT_NO_CURSOR + setCursor(Qt::BlankCursor); +#endif + } + Phonon::VideoWidget::timerEvent(e); +} + +void MediaVideoWidget::dropEvent(QDropEvent *e) +{ + m_player->handleDrop(e); +} + +void MediaVideoWidget::dragEnterEvent(QDragEnterEvent *e) { + if (e->mimeData()->hasUrls()) + e->acceptProposedAction(); +} + + +MediaPlayer::MediaPlayer(QString AppName) : + playButton(0), nextEffect(0), settingsDialog(0), ui(0), + m_AudioOutput(Phonon::VideoCategory), + m_videoWidget(new MediaVideoWidget(this)) +{ + setWindowTitle(AppName); + setContextMenuPolicy(Qt::CustomContextMenu); + m_videoWidget->setContextMenuPolicy(Qt::CustomContextMenu); + + QSize buttonSize(34, 28); + + QPushButton *openButton = new QPushButton(this); + + openButton->setIcon(style()->standardIcon(QStyle::SP_DialogOpenButton)); + QPalette bpal; + QColor arrowcolor = bpal.buttonText().color(); + if (arrowcolor == Qt::black) + arrowcolor = QColor(80, 80, 80); + bpal.setBrush(QPalette::ButtonText, arrowcolor); + openButton->setPalette(bpal); + + rewindButton = new QPushButton(this); + rewindButton->setIcon(style()->standardIcon(QStyle::SP_MediaSkipBackward)); + + forwardButton = new QPushButton(this); + forwardButton->setIcon(style()->standardIcon(QStyle::SP_MediaSkipForward)); + forwardButton->setEnabled(false); + + playButton = new QPushButton(this); + playIcon = style()->standardIcon(QStyle::SP_MediaPlay); + pauseIcon = style()->standardIcon(QStyle::SP_MediaPause); + playButton->setIcon(playIcon); + + slider = new Phonon::SeekSlider(this); + slider->setMediaObject(&m_MediaObject); + volume = new Phonon::VolumeSlider(&m_AudioOutput); + + QVBoxLayout *vLayout = new QVBoxLayout(this); + vLayout->setContentsMargins(8, 8, 8, 8); + + QHBoxLayout *layout = new QHBoxLayout(); + + info = new QLabel(this); + info->setMinimumHeight(70); + info->setAcceptDrops(false); + info->setMargin(2); + info->setFrameStyle(QFrame::StyledPanel | QFrame::Sunken); + info->setLineWidth(2); + info->setAutoFillBackground(true); + + QPalette palette; + palette.setBrush(QPalette::WindowText, Qt::white); +#ifndef Q_WS_MAC + openButton->setMinimumSize(54, buttonSize.height()); + rewindButton->setMinimumSize(buttonSize); + forwardButton->setMinimumSize(buttonSize); + playButton->setMinimumSize(buttonSize); +#endif + info->setStyleSheet("border-image:url(:/images/screen.png) ; border-width:3px"); + info->setPalette(palette); + info->setText(tr("<center>No media</center>")); + + volume->setFixedWidth(120); + + layout->addWidget(openButton); + layout->addWidget(rewindButton); + layout->addWidget(playButton); + layout->addWidget(forwardButton); + + layout->addStretch(); + layout->addWidget(volume); + + vLayout->addWidget(info); + initVideoWindow(); + vLayout->addWidget(&m_videoWindow); + QVBoxLayout *buttonPanelLayout = new QVBoxLayout(); + m_videoWindow.hide(); + buttonPanelLayout->addLayout(layout); + + timeLabel = new QLabel(this); + progressLabel = new QLabel(this); + QWidget *sliderPanel = new QWidget(this); + QHBoxLayout *sliderLayout = new QHBoxLayout(); + sliderLayout->addWidget(slider); + sliderLayout->addWidget(timeLabel); + sliderLayout->addWidget(progressLabel); + sliderLayout->setContentsMargins(0, 0, 0, 0); + sliderPanel->setLayout(sliderLayout); + + buttonPanelLayout->addWidget(sliderPanel); + buttonPanelLayout->setContentsMargins(0, 0, 0, 0); +#ifdef Q_OS_MAC + layout->setSpacing(4); + buttonPanelLayout->setSpacing(0); + info->setMinimumHeight(100); + info->setFont(QFont("verdana", 15)); + // QStyle *flatButtonStyle = new QWindowsStyle; + openButton->setFocusPolicy(Qt::NoFocus); + // openButton->setStyle(flatButtonStyle); + // playButton->setStyle(flatButtonStyle); + // rewindButton->setStyle(flatButtonStyle); + // forwardButton->setStyle(flatButtonStyle); + #endif + QWidget *buttonPanelWidget = new QWidget(this); + buttonPanelWidget->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed); + buttonPanelWidget->setLayout(buttonPanelLayout); + vLayout->addWidget(buttonPanelWidget); + + QHBoxLayout *labelLayout = new QHBoxLayout(); + + vLayout->addLayout(labelLayout); + setLayout(vLayout); + + // Create menu bar: + fileMenu = new QMenu(this); + QAction *openFileAction = fileMenu->addAction(tr("Open &File...")); + QAction *openUrlAction = fileMenu->addAction(tr("Open &Location...")); +#ifdef Q_OS_SYMBIAN + QAction *selectIAPAction = fileMenu->addAction(tr("Select &IAP...")); + connect(selectIAPAction, SIGNAL(triggered(bool)), this, SLOT(selectIAP())); +#endif + QAction *const openLinkAction = fileMenu->addAction(tr("Open &RAM File...")); + + connect(openLinkAction, SIGNAL(triggered(bool)), this, SLOT(openRamFile())); + + fileMenu->addSeparator(); + QMenu *aspectMenu = fileMenu->addMenu(tr("&Aspect ratio")); + QActionGroup *aspectGroup = new QActionGroup(aspectMenu); + connect(aspectGroup, SIGNAL(triggered(QAction*)), this, SLOT(aspectChanged(QAction*))); + aspectGroup->setExclusive(true); + QAction *aspectActionAuto = aspectMenu->addAction(tr("Auto")); + aspectActionAuto->setCheckable(true); + aspectActionAuto->setChecked(true); + aspectGroup->addAction(aspectActionAuto); + QAction *aspectActionScale = aspectMenu->addAction(tr("Scale")); + aspectActionScale->setCheckable(true); + aspectGroup->addAction(aspectActionScale); + QAction *aspectAction16_9 = aspectMenu->addAction(tr("16/9")); + aspectAction16_9->setCheckable(true); + aspectGroup->addAction(aspectAction16_9); + QAction *aspectAction4_3 = aspectMenu->addAction(tr("4/3")); + aspectAction4_3->setCheckable(true); + aspectGroup->addAction(aspectAction4_3); + + QMenu *scaleMenu = fileMenu->addMenu(tr("&Scale mode")); + QActionGroup *scaleGroup = new QActionGroup(scaleMenu); + connect(scaleGroup, SIGNAL(triggered(QAction*)), this, SLOT(scaleChanged(QAction*))); + scaleGroup->setExclusive(true); + QAction *scaleActionFit = scaleMenu->addAction(tr("Fit in view")); + scaleActionFit->setCheckable(true); + scaleActionFit->setChecked(true); + scaleGroup->addAction(scaleActionFit); + QAction *scaleActionCrop = scaleMenu->addAction(tr("Scale and crop")); + scaleActionCrop->setCheckable(true); + scaleGroup->addAction(scaleActionCrop); + + m_fullScreenAction = fileMenu->addAction(tr("Full screen video")); + m_fullScreenAction->setCheckable(true); + m_fullScreenAction->setEnabled(false); // enabled by hasVideoChanged + bool b = connect(m_fullScreenAction, SIGNAL(toggled(bool)), m_videoWidget, SLOT(setFullScreen(bool))); + Q_ASSERT(b); + b = connect(m_videoWidget, SIGNAL(fullScreenChanged(bool)), m_fullScreenAction, SLOT(setChecked(bool))); + Q_ASSERT(b); + + fileMenu->addSeparator(); + QAction *settingsAction = fileMenu->addAction(tr("&Settings...")); + + // Setup signal connections: + connect(rewindButton, SIGNAL(clicked()), this, SLOT(rewind())); + //connect(openButton, SIGNAL(clicked()), this, SLOT(openFile())); + openButton->setMenu(fileMenu); + + //connect(playButton, SIGNAL(clicked()), this, SLOT(playPause())); + connect(forwardButton, SIGNAL(clicked()), this, SLOT(forward())); + //connect(openButton, SIGNAL(clicked()), this, SLOT(openFile())); + connect(settingsAction, SIGNAL(triggered(bool)), this, SLOT(showSettingsDialog())); + connect(openUrlAction, SIGNAL(triggered(bool)), this, SLOT(openUrl())); + connect(openFileAction, SIGNAL(triggered(bool)), this, SLOT(openFile())); + + connect(m_videoWidget, SIGNAL(customContextMenuRequested(const QPoint &)), SLOT(showContextMenu(const QPoint &))); + connect(this, SIGNAL(customContextMenuRequested(const QPoint &)), SLOT(showContextMenu(const QPoint &))); + connect(&m_MediaObject, SIGNAL(metaDataChanged()), this, SLOT(updateInfo())); + connect(&m_MediaObject, SIGNAL(totalTimeChanged(qint64)), this, SLOT(updateTime())); + connect(&m_MediaObject, SIGNAL(tick(qint64)), this, SLOT(updateTime())); + connect(&m_MediaObject, SIGNAL(finished()), this, SLOT(finished())); + connect(&m_MediaObject, SIGNAL(stateChanged(Phonon::State,Phonon::State)), this, SLOT(stateChanged(Phonon::State,Phonon::State))); + connect(&m_MediaObject, SIGNAL(bufferStatus(int)), this, SLOT(bufferStatus(int))); + connect(&m_MediaObject, SIGNAL(hasVideoChanged(bool)), this, SLOT(hasVideoChanged(bool))); + + rewindButton->setEnabled(false); + playButton->setEnabled(false); + setAcceptDrops(true); + + m_audioOutputPath = Phonon::createPath(&m_MediaObject, &m_AudioOutput); + Phonon::createPath(&m_MediaObject, m_videoWidget); + + resize(minimumSizeHint()); +} + +void MediaPlayer::stateChanged(Phonon::State newstate, Phonon::State oldstate) +{ + Q_UNUSED(oldstate); + + emit this->MediaStateChanged(newstate); + + if (oldstate == Phonon::LoadingState) { + QRect videoHintRect = QRect(QPoint(0, 0), m_videoWindow.sizeHint()); + QRect newVideoRect = QApplication::desktop()->screenGeometry().intersected(videoHintRect); + if (!m_smallScreen) { + if (m_MediaObject.hasVideo()) { + // Flush event que so that sizeHint takes the + // recently shown/hidden m_videoWindow into account: + qApp->processEvents(); + resize(sizeHint()); + } else + resize(minimumSize()); + } + } + + switch (newstate) { + case Phonon::ErrorState: + if (m_MediaObject.errorType() == Phonon::FatalError) { + playButton->setEnabled(false); + rewindButton->setEnabled(false); + } else { + m_MediaObject.pause(); + } + QMessageBox::warning(this, "Phonon Mediaplayer", m_MediaObject.errorString(), QMessageBox::Close); + break; + + case Phonon::StoppedState: + m_videoWidget->setFullScreen(false); + // Fall through + case Phonon::PausedState: + playButton->setIcon(playIcon); + if (m_MediaObject.currentSource().type() != Phonon::MediaSource::Invalid){ + playButton->setEnabled(true); + rewindButton->setEnabled(true); + } else { + playButton->setEnabled(false); + rewindButton->setEnabled(false); + } + break; + case Phonon::PlayingState: + playButton->setEnabled(true); + playButton->setIcon(pauseIcon); + if (m_MediaObject.hasVideo()) + m_videoWindow.show(); + // Fall through + case Phonon::BufferingState: + rewindButton->setEnabled(true); + break; + case Phonon::LoadingState: + rewindButton->setEnabled(false); + break; + } + +} + +void MediaPlayer::initSettingsDialog() +{ + settingsDialog = new QDialog(this); + ui = new Ui_settings(); + ui->setupUi(settingsDialog); + + connect(ui->brightnessSlider, SIGNAL(valueChanged(int)), this, SLOT(setBrightness(int))); + connect(ui->hueSlider, SIGNAL(valueChanged(int)), this, SLOT(setHue(int))); + connect(ui->saturationSlider, SIGNAL(valueChanged(int)), this, SLOT(setSaturation(int))); + connect(ui->contrastSlider , SIGNAL(valueChanged(int)), this, SLOT(setContrast(int))); + connect(ui->aspectCombo, SIGNAL(currentIndexChanged(int)), this, SLOT(setAspect(int))); + connect(ui->scalemodeCombo, SIGNAL(currentIndexChanged(int)), this, SLOT(setScale(int))); + + ui->brightnessSlider->setValue(int(m_videoWidget->brightness() * SLIDER_RANGE)); + ui->hueSlider->setValue(int(m_videoWidget->hue() * SLIDER_RANGE)); + ui->saturationSlider->setValue(int(m_videoWidget->saturation() * SLIDER_RANGE)); + ui->contrastSlider->setValue(int(m_videoWidget->contrast() * SLIDER_RANGE)); + ui->aspectCombo->setCurrentIndex(m_videoWidget->aspectRatio()); + ui->scalemodeCombo->setCurrentIndex(m_videoWidget->scaleMode()); + connect(ui->effectButton, SIGNAL(clicked()), this, SLOT(configureEffect())); + +#ifdef Q_WS_X11 + //Cross fading is not currently implemented in the GStreamer backend + ui->crossFadeSlider->setVisible(false); + ui->crossFadeLabel->setVisible(false); + ui->crossFadeLabel1->setVisible(false); + ui->crossFadeLabel2->setVisible(false); + ui->crossFadeLabel3->setVisible(false); +#endif + ui->crossFadeSlider->setValue((int)(2 * m_MediaObject.transitionTime() / 1000.0f)); + + // Insert audio devices: + QList<Phonon::AudioOutputDevice> devices = Phonon::BackendCapabilities::availableAudioOutputDevices(); + for (int i=0; i<devices.size(); i++){ + QString itemText = devices[i].name(); + if (!devices[i].description().isEmpty()) { + itemText += QString::fromLatin1(" (%1)").arg(devices[i].description()); + } + ui->deviceCombo->addItem(itemText); + if (devices[i] == m_AudioOutput.outputDevice()) + ui->deviceCombo->setCurrentIndex(i); + } + + // Insert audio effects: + ui->audioEffectsCombo->addItem(tr("<no effect>")); + QList<Phonon::Effect *> currEffects = m_audioOutputPath.effects(); + Phonon::Effect *currEffect = currEffects.size() ? currEffects[0] : 0; + QList<Phonon::EffectDescription> availableEffects = Phonon::BackendCapabilities::availableAudioEffects(); + for (int i=0; i<availableEffects.size(); i++){ + ui->audioEffectsCombo->addItem(availableEffects[i].name()); + if (currEffect && availableEffects[i] == currEffect->description()) + ui->audioEffectsCombo->setCurrentIndex(i+1); + } + connect(ui->audioEffectsCombo, SIGNAL(currentIndexChanged(int)), this, SLOT(effectChanged())); + +} + +void MediaPlayer::setVolume(qreal volume) +{ + m_AudioOutput.setVolume(volume); +} + +void MediaPlayer::setSmallScreen(bool smallScreen) +{ + m_smallScreen = smallScreen; +} + +void MediaPlayer::effectChanged() +{ + int currentIndex = ui->audioEffectsCombo->currentIndex(); + if (currentIndex) { + QList<Phonon::EffectDescription> availableEffects = Phonon::BackendCapabilities::availableAudioEffects(); + Phonon::EffectDescription chosenEffect = availableEffects[currentIndex - 1]; + + QList<Phonon::Effect *> currEffects = m_audioOutputPath.effects(); + Phonon::Effect *currentEffect = currEffects.size() ? currEffects[0] : 0; + + // Deleting the running effect will stop playback, it is deleted when removed from path + if (nextEffect && !(currentEffect && (currentEffect->description().name() == nextEffect->description().name()))) + delete nextEffect; + + nextEffect = new Phonon::Effect(chosenEffect); + } + ui->effectButton->setEnabled(currentIndex); +} + +void MediaPlayer::showSettingsDialog() +{ + const bool hasPausedForDialog = playPauseForDialog(); + + if (!settingsDialog) + initSettingsDialog(); + + float oldBrightness = m_videoWidget->brightness(); + float oldHue = m_videoWidget->hue(); + float oldSaturation = m_videoWidget->saturation(); + float oldContrast = m_videoWidget->contrast(); + Phonon::VideoWidget::AspectRatio oldAspect = m_videoWidget->aspectRatio(); + Phonon::VideoWidget::ScaleMode oldScale = m_videoWidget->scaleMode(); + int currentEffect = ui->audioEffectsCombo->currentIndex(); + settingsDialog->exec(); + + if (settingsDialog->result() == QDialog::Accepted){ + m_MediaObject.setTransitionTime((int)(1000 * float(ui->crossFadeSlider->value()) / 2.0f)); + QList<Phonon::AudioOutputDevice> devices = Phonon::BackendCapabilities::availableAudioOutputDevices(); + m_AudioOutput.setOutputDevice(devices[ui->deviceCombo->currentIndex()]); + QList<Phonon::Effect *> currEffects = m_audioOutputPath.effects(); + QList<Phonon::EffectDescription> availableEffects = Phonon::BackendCapabilities::availableAudioEffects(); + + if (ui->audioEffectsCombo->currentIndex() > 0){ + Phonon::Effect *currentEffect = currEffects.size() ? currEffects[0] : 0; + if (!currentEffect || currentEffect->description() != nextEffect->description()){ + foreach(Phonon::Effect *effect, currEffects) { + m_audioOutputPath.removeEffect(effect); + delete effect; + } + m_audioOutputPath.insertEffect(nextEffect); + } + } else { + foreach(Phonon::Effect *effect, currEffects) { + m_audioOutputPath.removeEffect(effect); + delete effect; + nextEffect = 0; + } + } + } else { + // Restore previous settings + m_videoWidget->setBrightness(oldBrightness); + m_videoWidget->setSaturation(oldSaturation); + m_videoWidget->setHue(oldHue); + m_videoWidget->setContrast(oldContrast); + m_videoWidget->setAspectRatio(oldAspect); + m_videoWidget->setScaleMode(oldScale); + ui->audioEffectsCombo->setCurrentIndex(currentEffect); + } + + if (hasPausedForDialog) + m_MediaObject.play(); +} + +void MediaPlayer::initVideoWindow() +{ + QVBoxLayout *videoLayout = new QVBoxLayout(); + videoLayout->addWidget(m_videoWidget); + videoLayout->setContentsMargins(0, 0, 0, 0); + m_videoWindow.setLayout(videoLayout); + m_videoWindow.setMinimumSize(100, 100); +} + + +void MediaPlayer::configureEffect() +{ + if (!nextEffect) + return; + + + QList<Phonon::Effect *> currEffects = m_audioOutputPath.effects(); + const QList<Phonon::EffectDescription> availableEffects = Phonon::BackendCapabilities::availableAudioEffects(); + if (ui->audioEffectsCombo->currentIndex() > 0) { + Phonon::EffectDescription chosenEffect = availableEffects[ui->audioEffectsCombo->currentIndex() - 1]; + + QDialog effectDialog; + effectDialog.setWindowTitle(tr("Configure effect")); + QVBoxLayout *topLayout = new QVBoxLayout(&effectDialog); + + QLabel *description = new QLabel("<b>Description:</b><br>" + chosenEffect.description(), &effectDialog); + description->setWordWrap(true); + topLayout->addWidget(description); + + QScrollArea *scrollArea = new QScrollArea(&effectDialog); + topLayout->addWidget(scrollArea); + + QVariantList savedParamValues; + foreach(Phonon::EffectParameter param, nextEffect->parameters()) { + savedParamValues << nextEffect->parameterValue(param); + } + + QWidget *scrollWidget = new Phonon::EffectWidget(nextEffect); + scrollWidget->setMinimumWidth(320); + scrollWidget->setContentsMargins(10, 10, 10,10); + scrollArea->setWidget(scrollWidget); + + QDialogButtonBox *bbox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel, Qt::Horizontal, &effectDialog); + connect(bbox->button(QDialogButtonBox::Ok), SIGNAL(clicked()), &effectDialog, SLOT(accept())); + connect(bbox->button(QDialogButtonBox::Cancel), SIGNAL(clicked()), &effectDialog, SLOT(reject())); + topLayout->addWidget(bbox); + + effectDialog.exec(); + + if (effectDialog.result() != QDialog::Accepted) { + //we need to restore the parameters values + int currentIndex = 0; + foreach(Phonon::EffectParameter param, nextEffect->parameters()) { + nextEffect->setParameterValue(param, savedParamValues.at(currentIndex++)); + } + + } + } +} + +void MediaPlayer::handleDrop(QDropEvent *e) +{ + QList<QUrl> urls = e->mimeData()->urls(); + if (e->proposedAction() == Qt::MoveAction){ + // Just add to the queue: + for (int i=0; i<urls.size(); i++) + m_MediaObject.enqueue(Phonon::MediaSource(urls[i].toLocalFile())); + } else { + // Create new queue: + m_MediaObject.clearQueue(); + if (urls.size() > 0) { + QString fileName = urls[0].toLocalFile(); + QDir dir(fileName); + if (dir.exists()) { + dir.setFilter(QDir::Files); + QStringList entries = dir.entryList(); + if (entries.size() > 0) { + setFile(fileName + QDir::separator() + entries[0]); + for (int i=1; i< entries.size(); ++i) + m_MediaObject.enqueue(fileName + QDir::separator() + entries[i]); + } + } else { + setFile(fileName); + for (int i=1; i<urls.size(); i++) + m_MediaObject.enqueue(Phonon::MediaSource(urls[i].toLocalFile())); + } + } + } + forwardButton->setEnabled(m_MediaObject.queue().size() > 0); + m_MediaObject.play(); +} + +void MediaPlayer::dropEvent(QDropEvent *e) +{ + if (e->mimeData()->hasUrls() && e->proposedAction() != Qt::LinkAction) { + e->acceptProposedAction(); + handleDrop(e); + } else { + e->ignore(); + } +} + +void MediaPlayer::dragEnterEvent(QDragEnterEvent *e) +{ + dragMoveEvent(e); +} + +void MediaPlayer::dragMoveEvent(QDragMoveEvent *e) +{ + if (e->mimeData()->hasUrls()) { + if (e->proposedAction() == Qt::CopyAction || e->proposedAction() == Qt::MoveAction){ + e->acceptProposedAction(); + } + } +} + +void MediaPlayer::play() +{ + m_MediaObject.play(); +} + +void MediaPlayer::stop() +{ + m_MediaObject.pause(); +} + +void MediaPlayer::setFile(const QString &fileName) +{ + //setWindowTitle(fileName.right(fileName.length() - fileName.lastIndexOf('/') - 1)); + m_MediaObject.setCurrentSource(Phonon::MediaSource(fileName)); +} + +void MediaPlayer::setLocation(const QString& location) +{ + //setWindowTitle(location.right(location.length() - location.lastIndexOf('/') - 1)); + m_MediaObject.setCurrentSource(Phonon::MediaSource(QUrl::fromEncoded(location.toUtf8()))); + //m_MediaObject.play(); +} + +bool MediaPlayer::playPauseForDialog() +{ + // If we're running on a small screen, we want to pause the video when + // popping up dialogs. We neither want to tamper with the state if the + // user has paused. + if (m_smallScreen && m_MediaObject.hasVideo()) { + if (Phonon::PlayingState == m_MediaObject.state()) { + m_MediaObject.pause(); + return true; + } + } + return false; +} + +void MediaPlayer::openFile() +{ + const bool hasPausedForDialog = playPauseForDialog(); + + QStringList fileNames = QFileDialog::getOpenFileNames(this, QString(), + QDesktopServices::storageLocation(QDesktopServices::MusicLocation)); + + if (hasPausedForDialog) + m_MediaObject.play(); + + m_MediaObject.clearQueue(); + if (fileNames.size() > 0) { + QString fileName = fileNames[0]; + setFile(fileName); + for (int i=1; i<fileNames.size(); i++) + m_MediaObject.enqueue(Phonon::MediaSource(fileNames[i])); + } + forwardButton->setEnabled(m_MediaObject.queue().size() > 0); +} + +void MediaPlayer::bufferStatus(int percent) +{ + if (percent == 100) + progressLabel->setText(QString()); + else { + QString str = QString::fromLatin1("(%1%)").arg(percent); + progressLabel->setText(str); + } +} + +void MediaPlayer::setSaturation(int val) +{ + m_videoWidget->setSaturation(val / qreal(SLIDER_RANGE)); +} + +void MediaPlayer::setHue(int val) +{ + m_videoWidget->setHue(val / qreal(SLIDER_RANGE)); +} + +void MediaPlayer::setAspect(int val) +{ + m_videoWidget->setAspectRatio(Phonon::VideoWidget::AspectRatio(val)); +} + +void MediaPlayer::setScale(int val) +{ + m_videoWidget->setScaleMode(Phonon::VideoWidget::ScaleMode(val)); +} + +void MediaPlayer::setBrightness(int val) +{ + m_videoWidget->setBrightness(val / qreal(SLIDER_RANGE)); +} + +void MediaPlayer::setContrast(int val) +{ + m_videoWidget->setContrast(val / qreal(SLIDER_RANGE)); +} + +void MediaPlayer::updateInfo() +{ + int maxLength = 30; + QString font = "<font color=#ffeeaa>"; + QString fontmono = "<font family=\"monospace,courier new\" color=#ffeeaa>"; + + QMap <QString, QString> metaData = m_MediaObject.metaData(); + QString trackArtist = metaData.value("ARTIST"); + if (trackArtist.length() > maxLength) + trackArtist = trackArtist.left(maxLength) + "..."; + + QString trackTitle = metaData.value("TITLE"); + int trackBitrate = metaData.value("BITRATE").toInt(); + + QString fileName; + if (m_MediaObject.currentSource().type() == Phonon::MediaSource::Url) { + fileName = m_MediaObject.currentSource().url().toString(); + } else { + fileName = m_MediaObject.currentSource().fileName(); + fileName = fileName.right(fileName.length() - fileName.lastIndexOf('/') - 1); + if (fileName.length() > maxLength) + fileName = fileName.left(maxLength) + "..."; + } + + QString title; + if (!trackTitle.isEmpty()) { + if (trackTitle.length() > maxLength) + trackTitle = trackTitle.left(maxLength) + "..."; + title = "Title: " + font + trackTitle + "<br></font>"; + } else if (!fileName.isEmpty()) { + if (fileName.length() > maxLength) + fileName = fileName.left(maxLength) + "..."; + title = font + fileName + "</font>"; + if (m_MediaObject.currentSource().type() == Phonon::MediaSource::Url) { + title.prepend("Url: "); + } else { + title.prepend("File: "); + } + } + + QString artist; + if (!trackArtist.isEmpty()) + artist = "Artist: " + font + trackArtist + "</font>"; + + QString bitrate; + if (trackBitrate != 0) + bitrate = "<br>Bitrate: " + font + QString::number(trackBitrate/1000) + "kbit</font>"; + + info->setText(title + artist + bitrate); +} + +void MediaPlayer::updateTime() +{ + long len = m_MediaObject.totalTime(); + long pos = m_MediaObject.currentTime(); + QString timeString; + if (pos || len) + { + int sec = pos/1000; + int min = sec/60; + int hour = min/60; + int msec = pos; + + QTime playTime(hour%60, min%60, sec%60, msec%1000); + sec = len / 1000; + min = sec / 60; + hour = min / 60; + msec = len; + + QTime stopTime(hour%60, min%60, sec%60, msec%1000); + QString timeFormat = "m:ss"; + if (hour > 0) + timeFormat = "h:mm:ss"; + timeString = playTime.toString(timeFormat); + if (len) + timeString += " / " + stopTime.toString(timeFormat); + } + timeLabel->setText(timeString); +} + +void MediaPlayer::rewind() +{ + m_MediaObject.seek(0); +} + +void MediaPlayer::forward() +{ + QList<Phonon::MediaSource> queue = m_MediaObject.queue(); + if (queue.size() > 0) { + m_MediaObject.setCurrentSource(queue[0]); + forwardButton->setEnabled(queue.size() > 1); + m_MediaObject.play(); + } +} + +void MediaPlayer::openUrl() +{ + QSettings settings; + settings.beginGroup(QLatin1String("BrowserMainWindow")); + QString sourceURL = settings.value("location").toString(); + bool ok = false; + sourceURL = QInputDialog::getText(this, tr("Open Location"), tr("Please enter a valid address here:"), QLineEdit::Normal, sourceURL, &ok); + if (ok && !sourceURL.isEmpty()) { + setLocation(sourceURL); + settings.setValue("location", sourceURL); + } +} + +/*! + \since 4.6 + */ +void MediaPlayer::openRamFile() +{ + QSettings settings; + settings.beginGroup(QLatin1String("BrowserMainWindow")); + + const QStringList fileNameList(QFileDialog::getOpenFileNames(this, + QString(), + settings.value("openRamFile").toString(), + QLatin1String("RAM files (*.ram)"))); + + if (fileNameList.isEmpty()) + return; + + QFile linkFile; + QList<QUrl> list; + QByteArray sourceURL; + for (int i = 0; i < fileNameList.count(); i++ ) { + linkFile.setFileName(fileNameList[i]); + if (linkFile.open(QIODevice::ReadOnly | QIODevice::Text)) { + while (!linkFile.atEnd()) { + sourceURL = linkFile.readLine().trimmed(); + if (!sourceURL.isEmpty()) { + const QUrl url(QUrl::fromEncoded(sourceURL)); + if (url.isValid()) + list.append(url); + } + } + linkFile.close(); + } + } + + if (!list.isEmpty()) { + m_MediaObject.clearQueue(); + setLocation(list[0].toString()); + for (int i = 1; i < list.count(); i++) + m_MediaObject.enqueue(Phonon::MediaSource(list[i])); + m_MediaObject.play(); + } + + forwardButton->setEnabled(!m_MediaObject.queue().isEmpty()); + settings.setValue("openRamFile", fileNameList[0]); +} + +void MediaPlayer::finished() +{ +} + +void MediaPlayer::showContextMenu(const QPoint &p) +{ + fileMenu->popup(m_videoWidget->isFullScreen() ? p : mapToGlobal(p)); +} + +void MediaPlayer::scaleChanged(QAction *act) +{ + if (act->text() == tr("Scale and crop")) + m_videoWidget->setScaleMode(Phonon::VideoWidget::ScaleAndCrop); + else + m_videoWidget->setScaleMode(Phonon::VideoWidget::FitInView); +} + +void MediaPlayer::aspectChanged(QAction *act) +{ + if (act->text() == tr("16/9")) + m_videoWidget->setAspectRatio(Phonon::VideoWidget::AspectRatio16_9); + else if (act->text() == tr("Scale")) + m_videoWidget->setAspectRatio(Phonon::VideoWidget::AspectRatioWidget); + else if (act->text() == tr("4/3")) + m_videoWidget->setAspectRatio(Phonon::VideoWidget::AspectRatio4_3); + else + m_videoWidget->setAspectRatio(Phonon::VideoWidget::AspectRatioAuto); +} + +void MediaPlayer::hasVideoChanged(bool bHasVideo) +{ + info->setVisible(!bHasVideo); + m_videoWindow.setVisible(bHasVideo); + m_fullScreenAction->setEnabled(bHasVideo); +} + +#ifdef Q_OS_SYMBIAN +void MediaPlayer::selectIAP() +{ + TRAPD(err, selectIAPL()); + if (KErrNone != err) + QMessageBox::warning(this, "Phonon Mediaplayer", "Error selecting IAP", QMessageBox::Close); +} + +void MediaPlayer::selectIAPL() +{ + QVariant currentIAPValue = m_MediaObject.property("InternetAccessPointName"); + QString currentIAPString = currentIAPValue.toString(); + bool ok = false; + CCommsDatabase *commsDb = CCommsDatabase::NewL(EDatabaseTypeIAP); + CleanupStack::PushL(commsDb); + commsDb->ShowHiddenRecords(); + CCommsDbTableView* view = commsDb->OpenTableLC(TPtrC(IAP)); + QStringList items; + TInt currentIAP = 0; + for (TInt l = view->GotoFirstRecord(), i = 0; l != KErrNotFound; l = view->GotoNextRecord(), i++) { + TBuf<KCommsDbSvrMaxColumnNameLength> iapName; + view->ReadTextL(TPtrC(COMMDB_NAME), iapName); + QString iapString = QString::fromUtf16(iapName.Ptr(), iapName.Length()); + items << iapString; + if (iapString == currentIAPString) + currentIAP = i; + } + currentIAPString = QInputDialog::getItem(this, tr("Select Access Point"), tr("Select Access Point"), items, currentIAP, false, &ok); + if (ok) + m_MediaObject.setProperty("InternetAccessPointName", currentIAPString); + CleanupStack::PopAndDestroy(2); //commsDB, view +} +#endif diff --git a/exampleCode/player/mediaplayer.h b/exampleCode/player/mediaplayer.h new file mode 100644 index 0000000..8dd0602 --- /dev/null +++ b/exampleCode/player/mediaplayer.h @@ -0,0 +1,164 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the demonstration applications of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:GPL$ +** GNU General Public License Usage +** This file is licensed under GPL v2. +** +** +** $QT_END_LICENSE$ +** +***************************************************************************/ + +#ifndef MEDIALAYER_H +#define MEDIAPLAYER_H + +#include <QtGui/QWidget> +#include <QtGui/QApplication> +#include <QtCore/QTimerEvent> +#include <QtGui/QShowEvent> +#include <QtGui/QIcon> +#include <QtCore/QBasicTimer> +#include <QtGui/QAction> + +#include <phonon/audiooutput.h> +#include <phonon/backendcapabilities.h> +#include <phonon/effect.h> +#include <phonon/effectparameter.h> +#include <phonon/effectwidget.h> +#include <phonon/mediaobject.h> +#include <phonon/seekslider.h> +#include <phonon/videowidget.h> +#include <phonon/volumeslider.h> + +QT_BEGIN_NAMESPACE +class QPushButton; +class QLabel; +class QSlider; +class QTextEdit; +class QMenu; +class Ui_settings; +QT_END_NAMESPACE + +class MediaPlayer; + +class MediaVideoWidget : public Phonon::VideoWidget +{ + Q_OBJECT + +public: + MediaVideoWidget(MediaPlayer *player, QWidget *parent = 0); + +public slots: + // Over-riding non-virtual Phonon::VideoWidget slot + void setFullScreen(bool); + +signals: + void fullScreenChanged(bool); + +protected: + void mouseDoubleClickEvent(QMouseEvent *e); + void keyPressEvent(QKeyEvent *e); + bool event(QEvent *e); + void timerEvent(QTimerEvent *e); + void dropEvent(QDropEvent *e); + void dragEnterEvent(QDragEnterEvent *e); + +private: + MediaPlayer *m_player; + QBasicTimer m_timer; + QAction m_action; +}; + +class MediaPlayer : + public QWidget +{ + Q_OBJECT +public: + MediaPlayer(QString AppName); + + void dragEnterEvent(QDragEnterEvent *e); + void dragMoveEvent(QDragMoveEvent *e); + void dropEvent(QDropEvent *e); + void handleDrop(QDropEvent *e); + void setFile(const QString &text); + void setLocation(const QString &location); + void initVideoWindow(); + void initSettingsDialog(); + void setVolume(qreal volume); + void setSmallScreen(bool smallScreen); + + QPushButton *playButton; + +signals: + void MediaStateChanged(Phonon::State newstate); +public slots: + void openFile(); + void rewind(); + void forward(); + void updateInfo(); + void updateTime(); + void finished(); + void play(); + void stop(); + void scaleChanged(QAction *); + void aspectChanged(QAction *); + +private slots: + void setAspect(int); + void setScale(int); + void setSaturation(int); + void setContrast(int); + void setHue(int); + void setBrightness(int); + void stateChanged(Phonon::State newstate, Phonon::State oldstate); + void effectChanged(); + void showSettingsDialog(); + void showContextMenu(const QPoint& point); + void bufferStatus(int percent); + void openUrl(); +#ifdef Q_OS_SYMBIAN + void selectIAP(); +#endif + void openRamFile(); + void configureEffect(); + void hasVideoChanged(bool); + +private: + bool playPauseForDialog(); +#ifdef Q_OS_SYMBIAN + void selectIAPL(); +#endif + + QIcon playIcon; + QIcon pauseIcon; + QMenu *fileMenu; + QPushButton *rewindButton; + QPushButton *forwardButton; + Phonon::SeekSlider *slider; + QLabel *timeLabel; + QLabel *progressLabel; + Phonon::VolumeSlider *volume; + QSlider *m_hueSlider; + QSlider *m_satSlider; + QSlider *m_contSlider; + QLabel *info; + Phonon::Effect *nextEffect; + QDialog *settingsDialog; + Ui_settings *ui; + QAction *m_fullScreenAction; + + QWidget m_videoWindow; + Phonon::MediaObject m_MediaObject; + Phonon::AudioOutput m_AudioOutput; + MediaVideoWidget *m_videoWidget; + Phonon::Path m_audioOutputPath; + bool m_smallScreen; +}; + +#endif //MEDIAPLAYER_H diff --git a/exampleCode/player/mediaplayer.qrc b/exampleCode/player/mediaplayer.qrc new file mode 100644 index 0000000..bcdf404 --- /dev/null +++ b/exampleCode/player/mediaplayer.qrc @@ -0,0 +1,5 @@ +<!DOCTYPE RCC><RCC version="1.0"> +<qresource> + <file>images/screen.png</file> +</qresource> +</RCC> diff --git a/exampleCode/player/player.pro b/exampleCode/player/player.pro new file mode 100755 index 0000000..7feffba --- /dev/null +++ b/exampleCode/player/player.pro @@ -0,0 +1,53 @@ +###################################################################### +# Automatically generated by qmake (2.01a) Thu Aug 23 18:02:14 2007 +###################################################################### + +TEMPLATE = app +DEPENDPATH += . build src ui + +QT += phonon + +FORMS += settings.ui +RESOURCES += mediaplayer.qrc + +!win32:CONFIG += CONSOLE + +SOURCES += main.cpp mediaplayer.cpp \ + audiomanagerinteractor.cpp \ + dbushandler.cpp +HEADERS += mediaplayer.h \ + audiomanagerinteractor.h \ + dbushandler.h \ + audiomanagertypes.h + +target.path = $$[QT_INSTALL_DEMOS]/qmediaplayer +sources.files = $$SOURCES $$HEADERS $$FORMS $$RESOURCES *.pro *.html *.doc images +sources.path = $$[QT_INSTALL_DEMOS]/qmediaplayer +INSTALLS += target sources + +wince*{ +DEPLOYMENT_PLUGIN += phonon_ds9 phonon_waveout +} + +symbian { + TARGET.UID3 = 0xA000C613 + + addFiles.sources = ../embedded/desktopservices/data/sax.mp3 + addFiles.path = /data/sounds/ + DEPLOYMENT += addFiles + + include($$QT_SOURCE_TREE/demos/symbianpkgrules.pri) + + LIBS += -lcommdb + + TARGET.CAPABILITY="NetworkServices" +} + + +unix { + CONFIG += link_pkgconfig + PKGCONFIG += glib-2.0 + PKGCONFIG += dbus-1 + PKGCONFIG += dbus-glib-1 + +} diff --git a/exampleCode/player/player.pro.user b/exampleCode/player/player.pro.user new file mode 100755 index 0000000..5ce0d49 --- /dev/null +++ b/exampleCode/player/player.pro.user @@ -0,0 +1,365 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE QtCreatorProject> +<!-- Written by Qt Creator 2.4.1, 2012-07-04T14:56:51. --> +<qtcreator> + <data> + <variable>ProjectExplorer.Project.ActiveTarget</variable> + <value type="int">0</value> + </data> + <data> + <variable>ProjectExplorer.Project.EditorSettings</variable> + <valuemap type="QVariantMap"> + <value type="bool" key="EditorConfiguration.AutoIndent">true</value> + <value type="bool" key="EditorConfiguration.AutoSpacesForTabs">false</value> + <valuemap type="QVariantMap" key="EditorConfiguration.CodeStyle.0"> + <value type="QString" key="language">Cpp</value> + <valuemap type="QVariantMap" key="value"> + <value type="QString" key="CurrentPreferences">CppGlobal</value> + </valuemap> + </valuemap> + <valuemap type="QVariantMap" key="EditorConfiguration.CodeStyle.1"> + <value type="QString" key="language">QmlJS</value> + <valuemap type="QVariantMap" key="value"> + <value type="QString" key="CurrentPreferences">QmlJSGlobal</value> + </valuemap> + </valuemap> + <value type="int" key="EditorConfiguration.CodeStyle.Count">2</value> + <value type="QByteArray" key="EditorConfiguration.Codec">System</value> + <value type="bool" key="EditorConfiguration.ConstrainTooltips">false</value> + <value type="int" key="EditorConfiguration.IndentSize">4</value> + <value type="bool" key="EditorConfiguration.MouseNavigation">true</value> + <value type="int" key="EditorConfiguration.PaddingMode">1</value> + <value type="bool" key="EditorConfiguration.ScrollWheelZooming">true</value> + <value type="int" key="EditorConfiguration.SmartBackspaceBehavior">0</value> + <value type="bool" key="EditorConfiguration.SpacesForTabs">true</value> + <value type="int" key="EditorConfiguration.TabKeyBehavior">0</value> + <value type="int" key="EditorConfiguration.TabSize">8</value> + <value type="bool" key="EditorConfiguration.UseGlobal">true</value> + <value type="int" key="EditorConfiguration.Utf8BomBehavior">1</value> + <value type="bool" key="EditorConfiguration.addFinalNewLine">true</value> + <value type="bool" key="EditorConfiguration.cleanIndentation">true</value> + <value type="bool" key="EditorConfiguration.cleanWhitespace">true</value> + <value type="bool" key="EditorConfiguration.inEntireDocument">false</value> + </valuemap> + </data> + <data> + <variable>ProjectExplorer.Project.PluginSettings</variable> + <valuemap type="QVariantMap"/> + </data> + <data> + <variable>ProjectExplorer.Project.Target.0</variable> + <valuemap type="QVariantMap"> + <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Desktop</value> + <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Desktop</value> + <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Target.DesktopTarget</value> + <value type="int" key="ProjectExplorer.Target.ActiveBuildConfiguration">3</value> + <value type="int" key="ProjectExplorer.Target.ActiveDeployConfiguration">0</value> + <value type="int" key="ProjectExplorer.Target.ActiveRunConfiguration">0</value> + <valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.0"> + <value type="QString" key="ProjectExplorer.BuildCOnfiguration.ToolChain">INVALID</value> + <valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0"> + <valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0"> + <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">qmake</value> + <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value> + <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">QtProjectManager.QMakeBuildStep</value> + <value type="bool" key="QtProjectManager.QMakeBuildStep.LinkQmlDebuggingLibrary">false</value> + <value type="bool" key="QtProjectManager.QMakeBuildStep.LinkQmlDebuggingLibraryAuto">true</value> + <value type="QString" key="QtProjectManager.QMakeBuildStep.QMakeArguments"></value> + <value type="bool" key="QtProjectManager.QMakeBuildStep.QMakeForced">false</value> + </valuemap> + <valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.1"> + <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Make</value> + <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value> + <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value> + <value type="bool" key="Qt4ProjectManager.MakeStep.Clean">false</value> + <value type="QString" key="Qt4ProjectManager.MakeStep.MakeArguments"></value> + <value type="QString" key="Qt4ProjectManager.MakeStep.MakeCommand"></value> + </valuemap> + <value type="int" key="ProjectExplorer.BuildStepList.StepsCount">2</value> + <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Build</value> + <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value> + <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Build</value> + </valuemap> + <valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.1"> + <valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0"> + <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Make</value> + <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value> + <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value> + <value type="bool" key="Qt4ProjectManager.MakeStep.Clean">true</value> + <value type="QString" key="Qt4ProjectManager.MakeStep.MakeArguments">clean</value> + <value type="QString" key="Qt4ProjectManager.MakeStep.MakeCommand"></value> + </valuemap> + <value type="int" key="ProjectExplorer.BuildStepList.StepsCount">1</value> + <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Clean</value> + <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value> + <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Clean</value> + </valuemap> + <value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">2</value> + <value type="bool" key="ProjectExplorer.BuildConfiguration.ClearSystemEnvironment">false</value> + <valuelist type="QVariantList" key="ProjectExplorer.BuildConfiguration.UserEnvironmentChanges"/> + <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Desktop Qt 4.8.1 for GCC (Qt SDK) Release</value> + <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value> + <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Qt4BuildConfiguration</value> + <value type="int" key="Qt4ProjectManager.Qt4BuildConfiguration.BuildConfiguration">0</value> + <value type="QString" key="Qt4ProjectManager.Qt4BuildConfiguration.BuildDirectory">/home/christian/workspace/player-build-desktop-Desktop_Qt_4_8_1_for_GCC__Qt_SDK__Release</value> + <value type="int" key="Qt4ProjectManager.Qt4BuildConfiguration.QtVersionId">-1</value> + <value type="bool" key="Qt4ProjectManager.Qt4BuildConfiguration.UseShadowBuild">true</value> + </valuemap> + <valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.1"> + <value type="QString" key="ProjectExplorer.BuildCOnfiguration.ToolChain">INVALID</value> + <valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0"> + <valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0"> + <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">qmake</value> + <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value> + <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">QtProjectManager.QMakeBuildStep</value> + <value type="bool" key="QtProjectManager.QMakeBuildStep.LinkQmlDebuggingLibrary">false</value> + <value type="bool" key="QtProjectManager.QMakeBuildStep.LinkQmlDebuggingLibraryAuto">true</value> + <value type="QString" key="QtProjectManager.QMakeBuildStep.QMakeArguments"></value> + <value type="bool" key="QtProjectManager.QMakeBuildStep.QMakeForced">false</value> + </valuemap> + <valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.1"> + <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Make</value> + <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value> + <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value> + <value type="bool" key="Qt4ProjectManager.MakeStep.Clean">false</value> + <value type="QString" key="Qt4ProjectManager.MakeStep.MakeArguments"></value> + <value type="QString" key="Qt4ProjectManager.MakeStep.MakeCommand"></value> + </valuemap> + <value type="int" key="ProjectExplorer.BuildStepList.StepsCount">2</value> + <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Build</value> + <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value> + <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Build</value> + </valuemap> + <valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.1"> + <valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0"> + <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Make</value> + <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value> + <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value> + <value type="bool" key="Qt4ProjectManager.MakeStep.Clean">true</value> + <value type="QString" key="Qt4ProjectManager.MakeStep.MakeArguments">clean</value> + <value type="QString" key="Qt4ProjectManager.MakeStep.MakeCommand"></value> + </valuemap> + <value type="int" key="ProjectExplorer.BuildStepList.StepsCount">1</value> + <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Clean</value> + <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value> + <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Clean</value> + </valuemap> + <value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">2</value> + <value type="bool" key="ProjectExplorer.BuildConfiguration.ClearSystemEnvironment">false</value> + <valuelist type="QVariantList" key="ProjectExplorer.BuildConfiguration.UserEnvironmentChanges"/> + <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Desktop Qt 4.8.1 for GCC (Qt SDK) Debug</value> + <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value> + <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Qt4BuildConfiguration</value> + <value type="int" key="Qt4ProjectManager.Qt4BuildConfiguration.BuildConfiguration">2</value> + <value type="QString" key="Qt4ProjectManager.Qt4BuildConfiguration.BuildDirectory">/home/christian/workspace/player-build-desktop-Desktop_Qt_4_8_1_for_GCC__Qt_SDK__Debug</value> + <value type="int" key="Qt4ProjectManager.Qt4BuildConfiguration.QtVersionId">-1</value> + <value type="bool" key="Qt4ProjectManager.Qt4BuildConfiguration.UseShadowBuild">true</value> + </valuemap> + <valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.2"> + <value type="QString" key="ProjectExplorer.BuildCOnfiguration.ToolChain">INVALID</value> + <valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0"> + <valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0"> + <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">qmake</value> + <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value> + <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">QtProjectManager.QMakeBuildStep</value> + <value type="bool" key="QtProjectManager.QMakeBuildStep.LinkQmlDebuggingLibrary">false</value> + <value type="bool" key="QtProjectManager.QMakeBuildStep.LinkQmlDebuggingLibraryAuto">true</value> + <value type="QString" key="QtProjectManager.QMakeBuildStep.QMakeArguments"></value> + <value type="bool" key="QtProjectManager.QMakeBuildStep.QMakeForced">false</value> + </valuemap> + <valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.1"> + <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Make</value> + <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value> + <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value> + <value type="bool" key="Qt4ProjectManager.MakeStep.Clean">false</value> + <value type="QString" key="Qt4ProjectManager.MakeStep.MakeArguments"></value> + <value type="QString" key="Qt4ProjectManager.MakeStep.MakeCommand"></value> + </valuemap> + <value type="int" key="ProjectExplorer.BuildStepList.StepsCount">2</value> + <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Build</value> + <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value> + <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Build</value> + </valuemap> + <valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.1"> + <valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0"> + <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Make</value> + <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value> + <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value> + <value type="bool" key="Qt4ProjectManager.MakeStep.Clean">true</value> + <value type="QString" key="Qt4ProjectManager.MakeStep.MakeArguments">clean</value> + <value type="QString" key="Qt4ProjectManager.MakeStep.MakeCommand"></value> + </valuemap> + <value type="int" key="ProjectExplorer.BuildStepList.StepsCount">1</value> + <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Clean</value> + <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value> + <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Clean</value> + </valuemap> + <value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">2</value> + <value type="bool" key="ProjectExplorer.BuildConfiguration.ClearSystemEnvironment">false</value> + <valuelist type="QVariantList" key="ProjectExplorer.BuildConfiguration.UserEnvironmentChanges"/> + <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Qt 4.8.1 (System) Release</value> + <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value> + <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Qt4BuildConfiguration</value> + <value type="int" key="Qt4ProjectManager.Qt4BuildConfiguration.BuildConfiguration">0</value> + <value type="QString" key="Qt4ProjectManager.Qt4BuildConfiguration.BuildDirectory">/home/christian/workspace/player-build-desktop-Qt_4_8_1__System__Release</value> + <value type="int" key="Qt4ProjectManager.Qt4BuildConfiguration.QtVersionId">-1</value> + <value type="bool" key="Qt4ProjectManager.Qt4BuildConfiguration.UseShadowBuild">true</value> + </valuemap> + <valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.3"> + <value type="QString" key="ProjectExplorer.BuildCOnfiguration.ToolChain">ProjectExplorer.ToolChain.Gcc:/usr/bin/g++.x86-linux-generic-elf-64bit./usr/bin/gdb</value> + <valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0"> + <valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0"> + <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">qmake</value> + <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value> + <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">QtProjectManager.QMakeBuildStep</value> + <value type="bool" key="QtProjectManager.QMakeBuildStep.LinkQmlDebuggingLibrary">false</value> + <value type="bool" key="QtProjectManager.QMakeBuildStep.LinkQmlDebuggingLibraryAuto">true</value> + <value type="QString" key="QtProjectManager.QMakeBuildStep.QMakeArguments"></value> + <value type="bool" key="QtProjectManager.QMakeBuildStep.QMakeForced">false</value> + </valuemap> + <valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.1"> + <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Make</value> + <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value> + <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value> + <value type="bool" key="Qt4ProjectManager.MakeStep.Clean">false</value> + <value type="QString" key="Qt4ProjectManager.MakeStep.MakeArguments"></value> + <value type="QString" key="Qt4ProjectManager.MakeStep.MakeCommand"></value> + </valuemap> + <value type="int" key="ProjectExplorer.BuildStepList.StepsCount">2</value> + <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Build</value> + <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value> + <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Build</value> + </valuemap> + <valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.1"> + <valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0"> + <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Make</value> + <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value> + <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value> + <value type="bool" key="Qt4ProjectManager.MakeStep.Clean">true</value> + <value type="QString" key="Qt4ProjectManager.MakeStep.MakeArguments">clean</value> + <value type="QString" key="Qt4ProjectManager.MakeStep.MakeCommand"></value> + </valuemap> + <value type="int" key="ProjectExplorer.BuildStepList.StepsCount">1</value> + <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Clean</value> + <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value> + <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Clean</value> + </valuemap> + <value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">2</value> + <value type="bool" key="ProjectExplorer.BuildConfiguration.ClearSystemEnvironment">false</value> + <valuelist type="QVariantList" key="ProjectExplorer.BuildConfiguration.UserEnvironmentChanges"/> + <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Desktop Qt 4.8.1 for GCC (Qt SDK) Debug2</value> + <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value> + <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Qt4BuildConfiguration</value> + <value type="int" key="Qt4ProjectManager.Qt4BuildConfiguration.BuildConfiguration">2</value> + <value type="QString" key="Qt4ProjectManager.Qt4BuildConfiguration.BuildDirectory">/home/christian/workspace/player-build-desktop-Qt_4_8_1__System__Debug</value> + <value type="int" key="Qt4ProjectManager.Qt4BuildConfiguration.QtVersionId">5</value> + <value type="bool" key="Qt4ProjectManager.Qt4BuildConfiguration.UseShadowBuild">true</value> + </valuemap> + <value type="int" key="ProjectExplorer.Target.BuildConfigurationCount">4</value> + <valuemap type="QVariantMap" key="ProjectExplorer.Target.DeployConfiguration.0"> + <valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0"> + <value type="int" key="ProjectExplorer.BuildStepList.StepsCount">0</value> + <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Deploy</value> + <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value> + <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Deploy</value> + </valuemap> + <value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">1</value> + <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">No deployment</value> + <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value> + <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.DefaultDeployConfiguration</value> + </valuemap> + <value type="int" key="ProjectExplorer.Target.DeployConfigurationCount">1</value> + <valuemap type="QVariantMap" key="ProjectExplorer.Target.RunConfiguration.0"> + <value type="bool" key="Analyzer.Project.UseGlobal">true</value> + <value type="bool" key="Analyzer.Project.UseGlobal">true</value> + <valuelist type="QVariantList" key="Analyzer.Valgrind.AddedSuppressionFiles"/> + <valuelist type="QVariantList" key="Analyzer.Valgrind.AddedSuppressionFiles"/> + <value type="bool" key="Analyzer.Valgrind.Callgrind.CollectBusEvents">false</value> + <value type="bool" key="Analyzer.Valgrind.Callgrind.CollectBusEvents">false</value> + <value type="bool" key="Analyzer.Valgrind.Callgrind.CollectSystime">false</value> + <value type="bool" key="Analyzer.Valgrind.Callgrind.CollectSystime">false</value> + <value type="bool" key="Analyzer.Valgrind.Callgrind.EnableBranchSim">false</value> + <value type="bool" key="Analyzer.Valgrind.Callgrind.EnableBranchSim">false</value> + <value type="bool" key="Analyzer.Valgrind.Callgrind.EnableCacheSim">false</value> + <value type="bool" key="Analyzer.Valgrind.Callgrind.EnableCacheSim">false</value> + <value type="bool" key="Analyzer.Valgrind.Callgrind.EnableEventToolTips">true</value> + <value type="bool" key="Analyzer.Valgrind.Callgrind.EnableEventToolTips">true</value> + <value type="double" key="Analyzer.Valgrind.Callgrind.MinimumCostRatio">0.01</value> + <value type="double" key="Analyzer.Valgrind.Callgrind.MinimumCostRatio">0.01</value> + <value type="double" key="Analyzer.Valgrind.Callgrind.VisualisationMinimumCostRatio">10</value> + <value type="double" key="Analyzer.Valgrind.Callgrind.VisualisationMinimumCostRatio">10</value> + <value type="bool" key="Analyzer.Valgrind.FilterExternalIssues">true</value> + <value type="bool" key="Analyzer.Valgrind.FilterExternalIssues">true</value> + <value type="int" key="Analyzer.Valgrind.NumCallers">25</value> + <value type="int" key="Analyzer.Valgrind.NumCallers">25</value> + <valuelist type="QVariantList" key="Analyzer.Valgrind.RemovedSuppressionFiles"/> + <valuelist type="QVariantList" key="Analyzer.Valgrind.RemovedSuppressionFiles"/> + <value type="bool" key="Analyzer.Valgrind.TrackOrigins">true</value> + <value type="bool" key="Analyzer.Valgrind.TrackOrigins">true</value> + <value type="QString" key="Analyzer.Valgrind.ValgrindExecutable">valgrind</value> + <value type="QString" key="Analyzer.Valgrind.ValgrindExecutable">valgrind</value> + <valuelist type="QVariantList" key="Analyzer.Valgrind.VisibleErrorKinds"> + <value type="int">0</value> + <value type="int">1</value> + <value type="int">2</value> + <value type="int">3</value> + <value type="int">4</value> + <value type="int">5</value> + <value type="int">6</value> + <value type="int">7</value> + <value type="int">8</value> + <value type="int">9</value> + <value type="int">10</value> + <value type="int">11</value> + <value type="int">12</value> + <value type="int">13</value> + <value type="int">14</value> + </valuelist> + <valuelist type="QVariantList" key="Analyzer.Valgrind.VisibleErrorKinds"> + <value type="int">0</value> + <value type="int">1</value> + <value type="int">2</value> + <value type="int">3</value> + <value type="int">4</value> + <value type="int">5</value> + <value type="int">6</value> + <value type="int">7</value> + <value type="int">8</value> + <value type="int">9</value> + <value type="int">10</value> + <value type="int">11</value> + <value type="int">12</value> + <value type="int">13</value> + <value type="int">14</value> + </valuelist> + <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">player</value> + <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value> + <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Qt4RunConfiguration</value> + <value type="int" key="Qt4ProjectManager.Qt4RunConfiguration.BaseEnvironmentBase">2</value> + <value type="QString" key="Qt4ProjectManager.Qt4RunConfiguration.CommandLineArguments">player alsa_output.default</value> + <value type="QString" key="Qt4ProjectManager.Qt4RunConfiguration.ProFile">player.pro</value> + <value type="bool" key="Qt4ProjectManager.Qt4RunConfiguration.UseDyldImageSuffix">false</value> + <value type="bool" key="Qt4ProjectManager.Qt4RunConfiguration.UseTerminal">false</value> + <valuelist type="QVariantList" key="Qt4ProjectManager.Qt4RunConfiguration.UserEnvironmentChanges"/> + <value type="QString" key="Qt4ProjectManager.Qt4RunConfiguration.UserWorkingDirectory"></value> + <value type="uint" key="RunConfiguration.QmlDebugServerPort">3768</value> + <value type="bool" key="RunConfiguration.UseCppDebugger">true</value> + <value type="bool" key="RunConfiguration.UseQmlDebugger">false</value> + <value type="bool" key="RunConfiguration.UseQmlDebuggerAuto">false</value> + </valuemap> + <value type="int" key="ProjectExplorer.Target.RunConfigurationCount">1</value> + </valuemap> + </data> + <data> + <variable>ProjectExplorer.Project.TargetCount</variable> + <value type="int">1</value> + </data> + <data> + <variable>ProjectExplorer.Project.Updater.EnvironmentId</variable> + <value type="QString">{ff8ada78-76cc-4ca1-bc41-e44127bd6bd0}</value> + </data> + <data> + <variable>ProjectExplorer.Project.Updater.FileVersion</variable> + <value type="int">10</value> + </data> +</qtcreator> diff --git a/exampleCode/player/settings.ui b/exampleCode/player/settings.ui new file mode 100644 index 0000000..03bd70e --- /dev/null +++ b/exampleCode/player/settings.ui @@ -0,0 +1,495 @@ +<?xml version="1.0" encoding="UTF-8"?> +<ui version="4.0"> + <class>settings</class> + <widget class="QDialog" name="settings"> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>175</width> + <height>397</height> + </rect> + </property> + <property name="windowTitle"> + <string>Settings</string> + </property> + <layout class="QVBoxLayout" name="verticalLayout_2"> + <item> + <widget class="QGroupBox" name="groupBox"> + <property name="title"> + <string>Video options:</string> + </property> + <property name="flat"> + <bool>true</bool> + </property> + <layout class="QGridLayout" name="gridLayout"> + <item row="5" column="2"> + <widget class="QComboBox" name="scalemodeCombo"> + <property name="sizeAdjustPolicy"> + <enum>QComboBox::AdjustToContentsOnFirstShow</enum> + </property> + <item> + <property name="text"> + <string>Fit in view</string> + </property> + </item> + <item> + <property name="text"> + <string>Scale and crop</string> + </property> + </item> + </widget> + </item> + <item row="0" column="0"> + <widget class="QLabel" name="label_9"> + <property name="text"> + <string>Contrast:</string> + </property> + </widget> + </item> + <item row="0" column="1" colspan="2"> + <widget class="QSlider" name="contrastSlider"> + <property name="minimumSize"> + <size> + <width>0</width> + <height>0</height> + </size> + </property> + <property name="minimum"> + <number>-8</number> + </property> + <property name="maximum"> + <number>8</number> + </property> + <property name="orientation"> + <enum>Qt::Horizontal</enum> + </property> + <property name="tickPosition"> + <enum>QSlider::TicksBelow</enum> + </property> + <property name="tickInterval"> + <number>4</number> + </property> + </widget> + </item> + <item row="1" column="0"> + <widget class="QLabel" name="label_8"> + <property name="text"> + <string>Brightness:</string> + </property> + </widget> + </item> + <item row="1" column="1" colspan="2"> + <widget class="QSlider" name="brightnessSlider"> + <property name="minimum"> + <number>-8</number> + </property> + <property name="maximum"> + <number>8</number> + </property> + <property name="orientation"> + <enum>Qt::Horizontal</enum> + </property> + <property name="tickPosition"> + <enum>QSlider::TicksBelow</enum> + </property> + <property name="tickInterval"> + <number>4</number> + </property> + </widget> + </item> + <item row="2" column="0"> + <widget class="QLabel" name="label_7"> + <property name="text"> + <string>Saturation:</string> + </property> + </widget> + </item> + <item row="2" column="1" colspan="2"> + <widget class="QSlider" name="saturationSlider"> + <property name="minimum"> + <number>-8</number> + </property> + <property name="maximum"> + <number>8</number> + </property> + <property name="orientation"> + <enum>Qt::Horizontal</enum> + </property> + <property name="tickPosition"> + <enum>QSlider::TicksBelow</enum> + </property> + <property name="tickInterval"> + <number>4</number> + </property> + </widget> + </item> + <item row="3" column="0"> + <widget class="QLabel" name="label_2"> + <property name="text"> + <string>Hue:</string> + </property> + </widget> + </item> + <item row="3" column="1" colspan="2"> + <widget class="QSlider" name="hueSlider"> + <property name="minimum"> + <number>-8</number> + </property> + <property name="maximum"> + <number>8</number> + </property> + <property name="orientation"> + <enum>Qt::Horizontal</enum> + </property> + <property name="tickPosition"> + <enum>QSlider::TicksBelow</enum> + </property> + <property name="tickInterval"> + <number>4</number> + </property> + </widget> + </item> + <item row="4" column="0" colspan="2"> + <widget class="QLabel" name="label_10"> + <property name="text"> + <string>Aspect ratio:</string> + </property> + </widget> + </item> + <item row="4" column="2"> + <widget class="QComboBox" name="aspectCombo"> + <property name="sizeAdjustPolicy"> + <enum>QComboBox::AdjustToContentsOnFirstShow</enum> + </property> + <item> + <property name="text"> + <string>Auto</string> + </property> + </item> + <item> + <property name="text"> + <string>Stretch</string> + </property> + </item> + <item> + <property name="text"> + <string>4/3</string> + </property> + </item> + <item> + <property name="text"> + <string>16/9</string> + </property> + </item> + </widget> + </item> + <item row="5" column="0" colspan="2"> + <widget class="QLabel" name="label_11"> + <property name="text"> + <string>Scale Mode:</string> + </property> + </widget> + </item> + </layout> + <zorder>scalemodeCombo</zorder> + <zorder>label_9</zorder> + <zorder>contrastSlider</zorder> + <zorder>label_8</zorder> + <zorder>brightnessSlider</zorder> + <zorder>label_7</zorder> + <zorder>saturationSlider</zorder> + <zorder>label_2</zorder> + <zorder>hueSlider</zorder> + <zorder>label_10</zorder> + <zorder>aspectCombo</zorder> + <zorder>label_11</zorder> + </widget> + </item> + <item> + <widget class="QGroupBox" name="groupBox_2"> + <property name="title"> + <string>Audio options:</string> + </property> + <property name="flat"> + <bool>true</bool> + </property> + <layout class="QVBoxLayout" name="verticalLayout"> + <item> + <layout class="QHBoxLayout"> + <item> + <widget class="QLabel" name="label"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Preferred" vsizetype="Preferred"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="minimumSize"> + <size> + <width>10</width> + <height>0</height> + </size> + </property> + <property name="text"> + <string>Audio device:</string> + </property> + <property name="alignment"> + <set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set> + </property> + </widget> + </item> + <item> + <widget class="QComboBox" name="deviceCombo"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Minimum" vsizetype="Fixed"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="minimumSize"> + <size> + <width>10</width> + <height>0</height> + </size> + </property> + <property name="sizeAdjustPolicy"> + <enum>QComboBox::AdjustToMinimumContentsLength</enum> + </property> + </widget> + </item> + </layout> + </item> + <item> + <layout class="QHBoxLayout" name="horizontalLayout"> + <item> + <widget class="QLabel" name="label_6"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Preferred" vsizetype="Preferred"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="minimumSize"> + <size> + <width>10</width> + <height>0</height> + </size> + </property> + <property name="text"> + <string>Audio effect:</string> + </property> + <property name="alignment"> + <set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set> + </property> + </widget> + </item> + <item> + <widget class="QComboBox" name="audioEffectsCombo"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Minimum" vsizetype="Fixed"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="minimumSize"> + <size> + <width>10</width> + <height>0</height> + </size> + </property> + <property name="sizeAdjustPolicy"> + <enum>QComboBox::AdjustToMinimumContentsLength</enum> + </property> + </widget> + </item> + <item> + <widget class="QToolButton" name="effectButton"> + <property name="enabled"> + <bool>false</bool> + </property> + <property name="text"> + <string>Setup</string> + </property> + </widget> + </item> + </layout> + </item> + <item> + <layout class="QHBoxLayout"> + <item> + <widget class="QLabel" name="crossFadeLabel"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Preferred" vsizetype="Preferred"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="minimumSize"> + <size> + <width>10</width> + <height>0</height> + </size> + </property> + <property name="text"> + <string>Cross fade:</string> + </property> + <property name="alignment"> + <set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set> + </property> + </widget> + </item> + <item> + <layout class="QVBoxLayout"> + <item> + <widget class="QSlider" name="crossFadeSlider"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Minimum" vsizetype="Fixed"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="minimum"> + <number>-20</number> + </property> + <property name="maximum"> + <number>20</number> + </property> + <property name="singleStep"> + <number>1</number> + </property> + <property name="pageStep"> + <number>2</number> + </property> + <property name="value"> + <number>0</number> + </property> + <property name="orientation"> + <enum>Qt::Horizontal</enum> + </property> + <property name="tickPosition"> + <enum>QSlider::TicksBelow</enum> + </property> + </widget> + </item> + <item> + <layout class="QHBoxLayout"> + <item> + <widget class="QLabel" name="crossFadeLabel1"> + <property name="font"> + <font> + <pointsize>9</pointsize> + </font> + </property> + <property name="text"> + <string>-10 Sec</string> + </property> + </widget> + </item> + <item> + <spacer> + <property name="orientation"> + <enum>Qt::Horizontal</enum> + </property> + <property name="sizeHint" stdset="0"> + <size> + <width>0</width> + <height>20</height> + </size> + </property> + </spacer> + </item> + <item> + <widget class="QLabel" name="crossFadeLabel2"> + <property name="font"> + <font> + <pointsize>9</pointsize> + </font> + </property> + <property name="text"> + <string>0</string> + </property> + </widget> + </item> + <item> + <spacer> + <property name="orientation"> + <enum>Qt::Horizontal</enum> + </property> + <property name="sizeHint" stdset="0"> + <size> + <width>0</width> + <height>20</height> + </size> + </property> + </spacer> + </item> + <item> + <widget class="QLabel" name="crossFadeLabel3"> + <property name="font"> + <font> + <pointsize>9</pointsize> + </font> + </property> + <property name="text"> + <string>10 Sec </string> + </property> + </widget> + </item> + </layout> + </item> + </layout> + </item> + </layout> + </item> + </layout> + </widget> + </item> + <item> + <widget class="QDialogButtonBox" name="buttonBox"> + <property name="orientation"> + <enum>Qt::Horizontal</enum> + </property> + <property name="standardButtons"> + <set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set> + </property> + </widget> + </item> + </layout> + </widget> + <resources/> + <connections> + <connection> + <sender>buttonBox</sender> + <signal>accepted()</signal> + <receiver>settings</receiver> + <slot>accept()</slot> + <hints> + <hint type="sourcelabel"> + <x>248</x> + <y>254</y> + </hint> + <hint type="destinationlabel"> + <x>157</x> + <y>274</y> + </hint> + </hints> + </connection> + <connection> + <sender>buttonBox</sender> + <signal>rejected()</signal> + <receiver>settings</receiver> + <slot>reject()</slot> + <hints> + <hint type="sourcelabel"> + <x>316</x> + <y>260</y> + </hint> + <hint type="destinationlabel"> + <x>286</x> + <y>274</y> + </hint> + </hints> + </connection> + </connections> +</ui> |