javauis/amms_qt/jni/src/dopplercontrol.cpp
changeset 23 98ccebc37403
equal deleted inserted replaced
21:2a9601315dfc 23:98ccebc37403
       
     1 /*
       
     2 * Copyright (c) 2002-2007 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:  JNI file for DopplerControl
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 //#include <jutils.h>
       
    20 
       
    21 #include "com_nokia_amms_control_audio3d_DopplerControl.h"
       
    22 #include <mmafunctionserver.h>
       
    23 #include "cammsdopplercontrolgroup.h"
       
    24 
       
    25 /**
       
    26  * wrapper for CAMMSDopplerControlGroup::SetEnabledL()
       
    27  */
       
    28 static void SetEnabledL(CAMMSDopplerControlGroup* aControl, TBool aEnabled)
       
    29 {
       
    30     aControl->SetEnabledL(aEnabled);
       
    31 }
       
    32 
       
    33 /**
       
    34  * wrapper for CAMMSDopplerControlGroup::SetVelocitySphericalL()
       
    35  */
       
    36 static void SetVelocitySphericalL(CAMMSDopplerControlGroup* aControl,
       
    37                                   TInt aAzimuth, TInt aElevation, TInt aRadius)
       
    38 {
       
    39     aControl->SetVelocitySphericalL(aAzimuth, aElevation, aRadius);
       
    40 }
       
    41 
       
    42 /**
       
    43  * wrapper for CAMMSDopplerControlGroup::VelocityCartesian()
       
    44  */
       
    45 static void GetVelocityCartesianL(
       
    46     CAMMSDopplerControlGroup* aControl,
       
    47     TInt aVelocity[ KAMMSVectorComponents ])
       
    48 {
       
    49     aControl->VelocityCartesianL(aVelocity);
       
    50 }
       
    51 
       
    52 /**
       
    53  * wrapper for CAMMSDopplerControlGroup::Enabled()
       
    54  */
       
    55 static TBool IsEnabled(CAMMSDopplerControlGroup* aControl)
       
    56 {
       
    57     return aControl->Enabled();
       
    58 }
       
    59 
       
    60 /**
       
    61  * wrapper for CAMMSDopplerControlGroup::SetVelocityCartesianL()
       
    62  */
       
    63 static void SetVelocityCartesianL(
       
    64     CAMMSDopplerControlGroup* aControl,
       
    65     TInt aX,
       
    66     TInt aY,
       
    67     TInt aZ)
       
    68 {
       
    69     aControl->SetVelocityCartesianL(aX, aY, aZ);
       
    70 }
       
    71 
       
    72 /*
       
    73  * Class:     com_nokia_amms_control_audio3d_DopplerControl
       
    74  * Method:    _setEnabled
       
    75  * Signature: (IIZ)I
       
    76  */
       
    77 JNIEXPORT jint JNICALL
       
    78 Java_com_nokia_amms_control_audio3d_DopplerControl__1setEnabled(
       
    79     JNIEnv*,
       
    80     jclass,
       
    81     jint aEventSource,
       
    82     jint aDopplerControl,
       
    83     jboolean aEnabled)
       
    84 {
       
    85     MMAFunctionServer* eventSource =
       
    86         reinterpret_cast< MMAFunctionServer* >(aEventSource);
       
    87 
       
    88     CAMMSDopplerControlGroup* dopplerControl =
       
    89         static_cast<CAMMSDopplerControlGroup*>(
       
    90             reinterpret_cast< CAMMSControlGroup* >(aDopplerControl));
       
    91 
       
    92     TInt error;
       
    93     error = eventSource->ExecuteTrap(
       
    94                 SetEnabledL,
       
    95                 dopplerControl,
       
    96                 (TBool) aEnabled);
       
    97     return error;
       
    98 }
       
    99 
       
   100 /*
       
   101  * Class:     com_nokia_amms_control_audio3d_DopplerControl
       
   102  * Method:    _setVelocitySpherical
       
   103  * Signature: (IIIII)I
       
   104  */
       
   105 JNIEXPORT jint JNICALL
       
   106 Java_com_nokia_amms_control_audio3d_DopplerControl__1setVelocitySpherical(
       
   107     JNIEnv*,
       
   108     jclass,
       
   109     jint aEventSource,
       
   110     jint aDopplerControl,
       
   111     jint aAzimuth,
       
   112     jint aElevation,
       
   113     jint aRadius)
       
   114 {
       
   115     MMAFunctionServer* eventSource =
       
   116 		reinterpret_cast< MMAFunctionServer* >(aEventSource);
       
   117 
       
   118     CAMMSDopplerControlGroup* dopplerControl =
       
   119         static_cast<CAMMSDopplerControlGroup*>(
       
   120             reinterpret_cast< CAMMSControlGroup *>(aDopplerControl));
       
   121 
       
   122     TInt error;
       
   123     error = eventSource->ExecuteTrap(SetVelocitySphericalL, dopplerControl,
       
   124                                      (TInt) aAzimuth, (TInt) aElevation, (TInt) aRadius);
       
   125 
       
   126     return error;
       
   127 }
       
   128 
       
   129 /*
       
   130  * Class:     com_nokia_amms_control_audio3d_DopplerControl
       
   131  * Method:    _getVelocityCartesian
       
   132  * Signature: (II)[I
       
   133  */
       
   134 JNIEXPORT jintArray JNICALL
       
   135 Java_com_nokia_amms_control_audio3d_DopplerControl__1getVelocityCartesian(
       
   136     JNIEnv* aJni,
       
   137     jclass,
       
   138     jint aEventSource,
       
   139     jint aDopplerControl,
       
   140     jintArray aError)
       
   141 {
       
   142     MMAFunctionServer* eventSource =
       
   143         reinterpret_cast< MMAFunctionServer *>(aEventSource);
       
   144 
       
   145     CAMMSDopplerControlGroup* dopplerControl =
       
   146         static_cast<CAMMSDopplerControlGroup*>(
       
   147             reinterpret_cast< CAMMSControlGroup* >(aDopplerControl));
       
   148 
       
   149     TInt velocity[ KAMMSVectorComponents ];
       
   150     TInt error = eventSource->ExecuteTrap(GetVelocityCartesianL,
       
   151                                           dopplerControl,
       
   152                                           velocity);
       
   153     // allocate new array
       
   154     jintArray javaArray = aJni->NewIntArray(KAMMSVectorComponents);
       
   155     if (javaArray)
       
   156     {
       
   157         aJni->SetIntArrayRegion(
       
   158             /*destination*/ javaArray,
       
   159             /*first*/ 0,
       
   160             /*count*/ KAMMSVectorComponents,
       
   161             /*source*/ velocity);
       
   162     }
       
   163 
       
   164     jint javaError[ 1 ] = { error };
       
   165     aJni->SetIntArrayRegion(aError, 0, 1, javaError);
       
   166 
       
   167     return javaArray;
       
   168 }
       
   169 
       
   170 /*
       
   171  * Class:     com_nokia_amms_control_audio3d_DopplerControl
       
   172  * Method:    _isEnabled
       
   173  * Signature: (II)Z
       
   174  */
       
   175 JNIEXPORT jboolean JNICALL
       
   176 Java_com_nokia_amms_control_audio3d_DopplerControl__1isEnabled(
       
   177     JNIEnv*,
       
   178     jclass,
       
   179     jint aEventSource,
       
   180     jint aDopplerControl)
       
   181 {
       
   182     MMAFunctionServer* eventSource =
       
   183         reinterpret_cast< MMAFunctionServer* >(aEventSource);
       
   184 
       
   185     CAMMSDopplerControlGroup* dopplerControl =
       
   186         static_cast<CAMMSDopplerControlGroup*>(
       
   187             reinterpret_cast< CAMMSControlGroup* >(aDopplerControl));
       
   188 
       
   189     return (jboolean) eventSource->Execute(IsEnabled, dopplerControl);
       
   190 }
       
   191 
       
   192 /*
       
   193  * Class:     com_nokia_amms_control_audio3d_DopplerControl
       
   194  * Method:    _setVelocityCartesian
       
   195  * Signature: (IIIII)I
       
   196  */
       
   197 JNIEXPORT jint JNICALL
       
   198 Java_com_nokia_amms_control_audio3d_DopplerControl__1setVelocityCartesian(
       
   199     JNIEnv*,
       
   200     jclass,
       
   201     jint aEventSource,
       
   202     jint aDopplerControl,
       
   203     jint aX,
       
   204     jint aY,
       
   205     jint aZ)
       
   206 {
       
   207     MMAFunctionServer* eventSource =
       
   208         reinterpret_cast< MMAFunctionServer* >(aEventSource);
       
   209 
       
   210     CAMMSDopplerControlGroup* dopplerControl =
       
   211         static_cast<CAMMSDopplerControlGroup*>(
       
   212             reinterpret_cast< CAMMSControlGroup* >(aDopplerControl));
       
   213 
       
   214     TInt error;
       
   215     error = eventSource->ExecuteTrap(
       
   216                 SetVelocityCartesianL,
       
   217                 dopplerControl,
       
   218                 (TInt) aX,
       
   219                 (TInt) aY,
       
   220                 (TInt) aZ);
       
   221 
       
   222     return error;
       
   223 }
       
   224 
       
   225 //  End of File