From 3c6e487547e7692fe7e7fd30d4531a496680ee7d Mon Sep 17 00:00:00 2001 From: asanoaozora Date: Thu, 15 Dec 2016 17:37:28 +0100 Subject: apply patch for layer manager update --- .../genivi_mapviewer_mapviewercontrol.cxx | 79 +++++++++++----------- .../genivi_mapviewer_mapviewercontrol.cxx | 78 ++++++++++----------- src/speech/CMakeLists.txt | 4 +- src/speech/README.md | 45 ++++++++++++ src/speech/build.sh | 69 +++++++++++++++++++ src/speech/main.cpp | 24 ++++++- src/speech/run.sh | 3 + src/speech/test-speech-capi.py | 15 ++-- 8 files changed, 227 insertions(+), 90 deletions(-) create mode 100644 src/speech/README.md create mode 100755 src/speech/build.sh create mode 100755 src/speech/run.sh (limited to 'src') diff --git a/src/navigation/map-viewer/mapviewercontrol-plugin/genivi_mapviewer_mapviewercontrol.cxx b/src/navigation/map-viewer/mapviewercontrol-plugin/genivi_mapviewer_mapviewercontrol.cxx index e7db76f..b1c2f76 100644 --- a/src/navigation/map-viewer/mapviewercontrol-plugin/genivi_mapviewer_mapviewercontrol.cxx +++ b/src/navigation/map-viewer/mapviewercontrol-plugin/genivi_mapviewer_mapviewercontrol.cxx @@ -32,9 +32,10 @@ #include #include #include -#ifndef FSA_LAYER -#define FSA_LAYER 600 -#define HMI_LAYER 700 +//Align with Qt Surfaces = 8000 + Layer. +#ifndef FSA_SURFACE +#define SURFACE_OFFSET 8000 +#define FSA_SURFACE SURFACE_OFFSET + getpid() #endif #endif @@ -1432,24 +1433,49 @@ static void callbackFunction(ilmObjectType object, t_ilm_uint surfaceId, t_ilm_b (void)user_data; struct ilmSurfaceProperties sp; + t_ilm_int pLength = 0; + t_ilm_layer* ppArray = NULL; + struct ilmSurfaceProperties pSurfaceProperties; + t_ilm_layer renderOrder[2]; + if (object == ILM_SURFACE) { if (created) { - //m_handle not propageted here but it is m_handle=1. - if (surfaceId == FSA_LAYER+1) { + if (surfaceId == FSA_SURFACE) { //Configure map surface if (ilm_getPropertiesOfSurface(surfaceId, &sp) != ILM_SUCCESS) { dbg(lvl_error,"error on ilm_getPropertiesOfSurface\n"); } - if (ilm_layerAddSurface(FSA_LAYER, surfaceId) != ILM_SUCCESS) { - dbg(lvl_error,"error on ilm_layerAddSurface\n"); - } - if (ilm_surfaceSetSourceRectangle(surfaceId, 0, 0, sp.origSourceWidth, sp.origSourceHeight) != ILM_SUCCESS) { dbg(lvl_error,"error on ilm_surfaceSetSourceRectangle\n"); } - if (ilm_surfaceSetDestinationRectangle(surfaceId, 0, 0, sp.origSourceWidth, sp.origSourceHeight) != ILM_SUCCESS) { + //RenderOrder with the hmi-launcher Qt surface + /* + * ilm_getLayerIDsOnScreen will give the layer attached + * to the hmi-launcher Qt surface following hmi-launcher Qt surface + */ + if (ilm_getLayerIDsOnScreen(0, &pLength, &ppArray) != ILM_SUCCESS) { + dbg(lvl_error, "error on ilm_getLayerIDsOnScreen\n"); + } + + /* The last one is the hmi-launcher layer and thus surface. + * Then hmi-launcher surface toped the map surface into the hmi-launcher layer. + */ + renderOrder[1] = SURFACE_OFFSET + ppArray[pLength - 1]; + renderOrder[0] = FSA_SURFACE; + + if (ilm_layerSetRenderOrder(ppArray[pLength - 1],renderOrder,2) != ILM_SUCCESS) { + dbg(lvl_error,"error on ilm_layerSetRenderOrder\n"); + } + + //Put the map at the same resolution as the hmi-launcher + if (ilm_getPropertiesOfSurface(SURFACE_OFFSET + ppArray[pLength - 1], &pSurfaceProperties) != ILM_SUCCESS) { + dbg(lvl_error,"error on ilm_getPropertiesOfSurface\n"); + } + + if (ilm_surfaceSetDestinationRectangle(surfaceId, pSurfaceProperties.destX, pSurfaceProperties.destY, + pSurfaceProperties.destWidth, pSurfaceProperties.destHeight) != ILM_SUCCESS) { dbg(lvl_error,"error on ilm_surfaceSetDestinationRectangle\n"); } @@ -1537,6 +1563,7 @@ MapViewerControlObj::MapViewerControlObj(MapViewerControl *mapviewercontrol, uin navit_init(m_navit.u.navit); graphics_get_data(m_graphics.u.graphics,"window"); + struct transformation *trans=navit_get_trans(m_navit.u.navit); struct map_selection sel; memset(&sel, 0, sizeof(sel)); @@ -1552,29 +1579,7 @@ MapViewerControlObj::MapViewerControlObj(MapViewerControl *mapviewercontrol, uin } t_ilm_nativehandle nativehandle=(t_ilm_nativehandle)graphics_get_data(m_graphics.u.graphics,"xwindow_id"); - t_ilm_surface surfaceId=FSA_LAYER+m_handle; - t_ilm_layer layerId=FSA_LAYER; - - //Configure Screen for FSA - t_ilm_layer renderOrder[1]; - renderOrder[0] = FSA_LAYER; - renderOrder[1] = HMI_LAYER; - if (ilm_displaySetRenderOrder(0,renderOrder,2) != ILM_SUCCESS) { - dbg(lvl_error,"error on ilm_displaySetRenderOrder\n"); - } - - //Configure the FSA layer dimensions & visibility - if (ilm_layerSetSourceRectangle(layerId, 0, 0, MapViewSize._1, MapViewSize._2) != ILM_SUCCESS) { - dbg(lvl_error,"error on ilm_layerSetSourceRectangle\n"); - } - - if (ilm_layerSetDestinationRectangle(layerId, 0, 0, MapViewSize._1, MapViewSize._2) != ILM_SUCCESS) { - dbg(lvl_error,"error on ilm_layerSetDestinationRectangle\n"); - } - - if (ilm_layerSetVisibility(layerId, ILM_TRUE) != ILM_SUCCESS) { - dbg(lvl_error,"error on ilm_layerSetVisibility\n"); - } + t_ilm_surface surfaceId=FSA_SURFACE; //Register Notification if (ilm_registerNotification(callbackFunction, NULL) != ILM_SUCCESS) { @@ -1597,14 +1602,12 @@ MapViewerControlObj::MapViewerControlObj(MapViewerControl *mapviewercontrol, uin MapViewerControlObj::~MapViewerControlObj() { #if LM - t_ilm_surface surfaceId=FSA_LAYER+m_handle; - t_ilm_layer layerId=FSA_LAYER; + t_ilm_surface surfaceId=FSA_SURFACE; + if (ilm_surfaceRemove(surfaceId) != ILM_SUCCESS) { dbg(lvl_error,"error on ilm_surfaceRemove\n"); } - if (ilm_layerRemoveSurface(layerId, surfaceId) != ILM_SUCCESS) { - dbg(lvl_error,"error on ilm_layerAddSurface\n"); - } + if (ilm_commitChanges() != ILM_SUCCESS) { dbg(lvl_error,"error on ilm_commitChanges\n"); } diff --git a/src/navigation/map-viewer/mapviewercontrol-server-plugin/genivi_mapviewer_mapviewercontrol.cxx b/src/navigation/map-viewer/mapviewercontrol-server-plugin/genivi_mapviewer_mapviewercontrol.cxx index e538be1..62a7b0f 100644 --- a/src/navigation/map-viewer/mapviewercontrol-server-plugin/genivi_mapviewer_mapviewercontrol.cxx +++ b/src/navigation/map-viewer/mapviewercontrol-server-plugin/genivi_mapviewer_mapviewercontrol.cxx @@ -31,9 +31,10 @@ #include #include #include -#ifndef FSA_LAYER -#define FSA_LAYER 600 -#define HMI_LAYER 700 +//Align with Qt Surfaces = 8000 + Layer. +#ifndef FSA_SURFACE +#define SURFACE_OFFSET 8000 +#define FSA_SURFACE SURFACE_OFFSET + getpid() #endif #endif @@ -1582,24 +1583,49 @@ static void callbackFunction(ilmObjectType object, t_ilm_uint surfaceId, t_ilm_b (void)user_data; struct ilmSurfaceProperties sp; + t_ilm_int pLength = 0; + t_ilm_layer* ppArray = NULL; + struct ilmSurfaceProperties pSurfaceProperties; + t_ilm_layer renderOrder[2]; + if (object == ILM_SURFACE) { if (created) { - //m_handle not propageted here but it is m_handle=1. - if (surfaceId == FSA_LAYER+1) { + if (surfaceId == FSA_SURFACE) { //Configure map surface if (ilm_getPropertiesOfSurface(surfaceId, &sp) != ILM_SUCCESS) { dbg(lvl_error,"error on ilm_getPropertiesOfSurface\n"); } - if (ilm_layerAddSurface(FSA_LAYER, surfaceId) != ILM_SUCCESS) { - dbg(lvl_error,"error on ilm_layerAddSurface\n"); - } - if (ilm_surfaceSetSourceRectangle(surfaceId, 0, 0, sp.origSourceWidth, sp.origSourceHeight) != ILM_SUCCESS) { dbg(lvl_error,"error on ilm_surfaceSetSourceRectangle\n"); } - if (ilm_surfaceSetDestinationRectangle(surfaceId, 0, 0, sp.origSourceWidth, sp.origSourceHeight) != ILM_SUCCESS) { + //RenderOrder with the hmi-launcher Qt surface + /* + * ilm_getLayerIDsOnScreen will give the layer attached + * to the hmi-launcher Qt surface following hmi-launcher Qt surface + */ + if (ilm_getLayerIDsOnScreen(0, &pLength, &ppArray) != ILM_SUCCESS) { + dbg(lvl_error, "error on ilm_getLayerIDsOnScreen\n"); + } + + /* The last one is the hmi-launcher layer and thus surface. + * Then hmi-launcher surface toped the map surface into the hmi-launcher layer. + */ + renderOrder[1] = SURFACE_OFFSET + ppArray[pLength - 1]; + renderOrder[0] = FSA_SURFACE; + + if (ilm_layerSetRenderOrder(ppArray[pLength - 1],renderOrder,2) != ILM_SUCCESS) { + dbg(lvl_error,"error on ilm_layerSetRenderOrder\n"); + } + + //Put the map at the same resolution as the hmi-launcher + if (ilm_getPropertiesOfSurface(SURFACE_OFFSET + ppArray[pLength - 1], &pSurfaceProperties) != ILM_SUCCESS) { + dbg(lvl_error,"error on ilm_getPropertiesOfSurface\n"); + } + + if (ilm_surfaceSetDestinationRectangle(surfaceId, pSurfaceProperties.destX, pSurfaceProperties.destY, + pSurfaceProperties.destWidth, pSurfaceProperties.destHeight) != ILM_SUCCESS) { dbg(lvl_error,"error on ilm_surfaceSetDestinationRectangle\n"); } @@ -1709,29 +1735,7 @@ MapViewerControlObj::MapViewerControlObj(MapViewerControlServerStub *mapviewerco } t_ilm_nativehandle nativehandle=(t_ilm_nativehandle)graphics_get_data(m_graphics.u.graphics,"xwindow_id"); - t_ilm_surface surfaceId=FSA_LAYER+m_handle; - t_ilm_layer layerId=FSA_LAYER; - - //Configure Screen for FSA - t_ilm_layer renderOrder[1]; - renderOrder[0] = FSA_LAYER; - renderOrder[1] = HMI_LAYER; - if (ilm_displaySetRenderOrder(0,renderOrder,2) != ILM_SUCCESS) { - dbg(lvl_error,"error on ilm_displaySetRenderOrder\n"); - } - - //Configure the FSA layer dimensions & visibility - if (ilm_layerSetSourceRectangle(layerId, 0, 0, MapViewSize._1, MapViewSize._2) != ILM_SUCCESS) { - dbg(lvl_error,"error on ilm_layerSetSourceRectangle\n"); - } - - if (ilm_layerSetDestinationRectangle(layerId, 0, 0, MapViewSize._1, MapViewSize._2) != ILM_SUCCESS) { - dbg(lvl_error,"error on ilm_layerSetDestinationRectangle\n"); - } - - if (ilm_layerSetVisibility(layerId, ILM_TRUE) != ILM_SUCCESS) { - dbg(lvl_error,"error on ilm_layerSetVisibility\n"); - } + t_ilm_surface surfaceId=FSA_SURFACE; //Register Notification if (ilm_registerNotification(callbackFunction, NULL) != ILM_SUCCESS) { @@ -1754,14 +1758,12 @@ MapViewerControlObj::MapViewerControlObj(MapViewerControlServerStub *mapviewerco MapViewerControlObj::~MapViewerControlObj() { #if LM - t_ilm_surface surfaceId=FSA_LAYER+m_handle; - t_ilm_layer layerId=FSA_LAYER; + t_ilm_surface surfaceId=FSA_SURFACE; + if (ilm_surfaceRemove(surfaceId) != ILM_SUCCESS) { dbg(lvl_error,"error on ilm_surfaceRemove\n"); } - if (ilm_layerRemoveSurface(layerId, surfaceId) != ILM_SUCCESS) { - dbg(lvl_error,"error on ilm_layerAddSurface\n"); - } + if (ilm_commitChanges() != ILM_SUCCESS) { dbg(lvl_error,"error on ilm_commitChanges\n"); } diff --git a/src/speech/CMakeLists.txt b/src/speech/CMakeLists.txt index 5e092ba..f8d73ab 100644 --- a/src/speech/CMakeLists.txt +++ b/src/speech/CMakeLists.txt @@ -40,8 +40,8 @@ endif() # Packages find_package(PkgConfig REQUIRED) -find_package(CommonAPI 3.1.5 REQUIRED) -find_package(CommonAPI-DBus 3.1.5 REQUIRED) +find_package(CommonAPI) +find_package(CommonAPI) #pkg_check_modules(DBUS "dbus-1 >= 1.8.4") // #to be fixed, it doesn't work so the paths are set manually (see above) pkg_check_modules(COMMONAPI "CommonAPI >= 3.1.5") diff --git a/src/speech/README.md b/src/speech/README.md new file mode 100644 index 0000000..4d64503 --- /dev/null +++ b/src/speech/README.md @@ -0,0 +1,45 @@ +# Speech Output Service middleware: CommonAPI based POC + +## Synopsis +This folder contains the server part of the proof of concepts (POC) for the Speech Output Service interfaces, based on CommonAPI + +##Tested targets +Desktop: Tested under Ubuntu 16.04 LTS 64 bits + +## Prerequisites +You need CommonAPI 3.1.9 and Franca 0.9.1 installed +For the Ubuntu 64 bits, due to the use of symbol versioning LIBDBUS_1_0 by CommonAPI-DBus, the patched version of DBus has to be >= 1.10.0 +NB: In case you migrate from 3.1.5 to 3.1.9, due to a cmake issue (wrong management of micro version), it's necessary to do: +``` +sudo mv /usr/local/lib/cmake/CommonAPI-3.1.5 /usr/local/lib/cmake/oldCommonAPI-3.1.5 +``` +Symbolic links are also not well managed, so you need to fix it: +``` +sudo ln -sfn /usr/local/lib/libCommonAPI.so.3.1.9 /usr/local/lib/libCommonAPI.so.3 +sudo ln -sfn /usr/local/lib/libCommonAPI-DBus.so.3.1.9 /usr/local/lib/libCommonAPI-DBus.so.3 +``` + +NB: the patch common-api-dbus-runtime/src/dbus-patches/capi-dbus-add-support-for-custom-marshalling.patch may fail a little bit, in that case it's needed to update the dbus/dbus-string.h manually + +## How to build +First it's required to set some paths: +``` +export DBUS_LIB_PATH= +export COMMONAPI_DBUS_TOOL_DIR= +export COMMONAPI_TOOL_DIR= +``` +A script allows either: +to clean and rebuild all (including invoking cmake) +```./build.sh -c``` +or to build updated parts +```./build.sh``` + +## How To Run +```./run.sh &``` + +## How To Test +```./test-speech-capi.py``` + +## License + +Mozilla Public License Version 2.0 diff --git a/src/speech/build.sh b/src/speech/build.sh new file mode 100755 index 0000000..0533402 --- /dev/null +++ b/src/speech/build.sh @@ -0,0 +1,69 @@ +#!/bin/bash + +commonapi_tools_option="" +clean=0 + +while getopts cdh opt +do + case $opt in + c) + clean=1 + ;; + d) + debug="ON" + ;; + h) + echo "Usage:" + echo "$0 [-cd]" + echo "-c: Rebuild with clean" + echo "-d: Enable the debug messages" + exit 1 + esac +done +set -e + +if [ ! $COMMONAPI_TOOL_DIR ] +then + echo 'Set the dir of the common api tools' + echo 'export COMMONAPI_TOOL_DIR=' + exit 1 +fi + +if [ ! $COMMONAPI_DBUS_TOOL_DIR ] +then + echo 'Set the dir of the common api dbus tools' + echo 'export COMMONAPI_DBUS_TOOL_DIR=' + exit 1 +fi + +if [ ! $DBUS_LIB_PATH ] +then + echo 'Set the dir of the patched dbus' + echo 'export DBUS_LIB_PATH=' + exit 1 +fi + +commonapi_tools_option="-DDBUS_LIB_PATH="$DBUS_LIB_PATH" -DCOMMONAPI_DBUS_TOOL_DIR="$COMMONAPI_DBUS_TOOL_DIR" -DCOMMONAPI_TOOL_DIR="$COMMONAPI_TOOL_DIR + + +if [ "$clean" = 1 ] +then + echo 'clean up the build folder' + if [ -d "./build" ] + then + find ./build ! -name '*.cbp' -type f -exec rm -f {} + + fi +fi + + +mkdir -p build +cd build + +echo 'build speech-output-server' +if [ "$clean" = 1 ] +then + cmake $commonapi_tools_option -DWITH_DEBUG=$debug ../ +fi +make + + diff --git a/src/speech/main.cpp b/src/speech/main.cpp index bddada8..261cd5a 100644 --- a/src/speech/main.cpp +++ b/src/speech/main.cpp @@ -2,13 +2,15 @@ * @licence app begin@ * SPDX-License-Identifier: MPL-2.0 * -* \copyright Copyright (C) 2013-2014, PCA Peugeot Citroen +* \copyright Copyright (C) 2013-2017, PCA Peugeot Citroen * * \file main.cpp * * \brief This file is part of the speech proof of concept. * * \author Philippe Colliot +* \brief Some parts of the code has been inspired by the following people: +* \brief Mario Thielert, David Kämpf, Dominique Massonie * * \version 1.1 * @@ -97,6 +99,22 @@ static std::string m_chunkBuffer; /** max size = MAX_CHUNK_SIZE*MAX_SLOT_COUNT * int last, cst_audio_streaming_info_struct *asi) { printf("\n>>> [server] fliteCallback()\n"); + printf("start: %d size: %d last: %d \n",start,size,last); + static cst_audiodev *ad = 0; + + if (start == 0) + ad = audio_open(w->sample_rate,w->num_channels,CST_AUDIO_LINEAR16); + + audio_write(ad,&w->samples[start],size*sizeof(short)); + + if (last == 1) + { + audio_close(ad); + ad = NULL; + } + + /* if you want to stop return CST_AUDIO_STREAM_STOP */ + return CST_AUDIO_STREAM_CONT; } class SpeechOutputServerStub @@ -117,11 +135,11 @@ public: flite_init(); mp_voice = register_cmu_us_kal(NULL); -/* mp_asi = new_audio_streaming_info(); + mp_asi = new_audio_streaming_info(); mp_asi->asc = fliteCallback; feat_set(mp_voice->features,"streaming_info",audio_streaming_info_val(mp_asi)); -*/ + } ~SpeechOutputServerStub() { diff --git a/src/speech/run.sh b/src/speech/run.sh new file mode 100755 index 0000000..6a6126d --- /dev/null +++ b/src/speech/run.sh @@ -0,0 +1,3 @@ +#!/bin/bash +./bin/speech-output-server + diff --git a/src/speech/test-speech-capi.py b/src/speech/test-speech-capi.py index 3ed92e1..7fc4bb0 100755 --- a/src/speech/test-speech-capi.py +++ b/src/speech/test-speech-capi.py @@ -33,9 +33,6 @@ import time import pdb; #pdb.set_trace() #constants as defined in the Navigation API -GENIVI_Configuration_Settings_LOCALE = 37 -GENIVI_SearchStatusState_FINISHED = 1298 -GENIVI_SearchStatusState_NOT_STARTED = 1296 #constants used into the script TIME_OUT = 10000 @@ -65,20 +62,20 @@ if __name__ == '__main__': bus = dbus.SessionBus() bus.add_signal_receiver(catch_speech_notifyConnectionStatus_signal_handler, \ - dbus_interface = "org.genivi.hmi.speechoutputservice.SpeechOutput", \ + dbus_interface = "org.genivi.hmi.speechoutputservice.SpeechOutput.v4_0", \ signal_name = "notifyConnectionStatus") bus.add_signal_receiver(catch_speech_notifyMarkerReached_signal_handler, \ - dbus_interface = "org.genivi.hmi.speechoutputservice.SpeechOutput", \ + dbus_interface = "org.genivi.hmi.speechoutputservice.SpeechOutput.v4_0", \ signal_name = "notifyMarkerReached") bus.add_signal_receiver(catch_speech_notifyQueueStatus_signal_handler, \ - dbus_interface = "org.genivi.hmi.speechoutputservice.SpeechOutput", \ + dbus_interface = "org.genivi.hmi.speechoutputservice.SpeechOutput.v4_0", \ signal_name = "notifyQueueStatus") bus.add_signal_receiver(catch_speech_notifyTTSStatus_signal_handler, \ - dbus_interface = "org.genivi.hmi.speechoutputservice.SpeechOutput", \ + dbus_interface = "org.genivi.hmi.speechoutputservice.SpeechOutput.v4_0", \ signal_name = "notifyTTSStatus") -speech = bus.get_object('org.genivi.hmi.speechoutputservice.SpeechOutput_SpeechOutput','/SpeechOutput') -g_speech_interface = dbus.Interface(speech, dbus_interface='org.genivi.hmi.speechoutputservice.SpeechOutput') +speech = bus.get_object('org.genivi.hmi.speechoutputservice.SpeechOutput.v4_0_SpeechOutput','/SpeechOutput') +g_speech_interface = dbus.Interface(speech, dbus_interface='org.genivi.hmi.speechoutputservice.SpeechOutput.v4_0') g_speech_interface.addTextChunk(dbus.String("Hello")) -- cgit v1.2.1