javauis/mmapi_akn/baseline/src/framepositioningcontrol.cpp
branchRCL_3
changeset 14 04becd199f91
equal deleted inserted replaced
13:f5050f1da672 14:04becd199f91
       
     1 /*
       
     2 * Copyright (c) 2002 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:  This class has JNI wrappers for CMMAFramePositioningControl
       
    15 *
       
    16 */
       
    17 
       
    18 #include <jutils.h>
       
    19 
       
    20 #include "com_nokia_microedition_media_control_FramePositioningControl.h"
       
    21 #include "cmmaeventsource.h"
       
    22 #include "cmmaframepositioningcontrol.h"
       
    23 #include <jdebug.h>
       
    24 
       
    25 /**
       
    26  * Local function which can be used to call CMMAFramePositioningControl class methods.
       
    27  * Type of of the function pointer must be
       
    28  * TInt CMMAFramePositioningControl::aFunc( TInt )
       
    29  *
       
    30  * @param aFramePositioningControl CMMAFramePositioningControl pointer.
       
    31  * @param aFuncL Pointer to the CMMAFramePositioningControl method.
       
    32  * @param aParam Parameter value for aFuncL method.
       
    33  * @param aReturnValue The return value of the aFunc will
       
    34  *                     be assigned to this parameter.
       
    35  */
       
    36 LOCAL_C void ReturnIntFuncIntL(CMMAFramePositioningControl* aFramePositioningControl,
       
    37                                TInt(CMMAFramePositioningControl::*aFuncL)(TInt aParam),
       
    38                                TInt aParam,
       
    39                                TInt* aReturnValue)
       
    40 {
       
    41     // call TInt CMMAFramePositioningControl::aFunc( TInt ) method.
       
    42     *aReturnValue = (aFramePositioningControl->*aFuncL)(aParam);
       
    43 }
       
    44 
       
    45 //
       
    46 // JNI functions. Prototypes are generated and commented in Java class
       
    47 // com_nokia_microedition_media_control_FramePositioningControl
       
    48 //
       
    49 
       
    50 /**
       
    51  * JNI function from com.nokia.microedition.media.control.FramePositioningControl
       
    52  */
       
    53 JNIEXPORT jint JNICALL
       
    54 Java_com_nokia_microedition_media_control_FramePositioningControl__1seek
       
    55 (JNIEnv*,
       
    56  jobject,
       
    57  jint aControlHandle,
       
    58  jint aEventSourceHandle,
       
    59  jint aFrameNumber)
       
    60 {
       
    61     DEBUG("FramePositioningControl__1seek");
       
    62 
       
    63     // Get pointer to native event source.
       
    64     CMMAEventSource* eventSource =
       
    65         JavaUnhand< CMMAEventSource >(aEventSourceHandle);
       
    66 
       
    67     CMMAFramePositioningControl* FramePositioningControl =
       
    68         JavaUnhand< CMMAFramePositioningControl >(aControlHandle);
       
    69 
       
    70     // Will leave on error. Otherwise returnValue contains frame number
       
    71     // to which the implementation has seeked.
       
    72     TInt returnValue = 0;
       
    73     TInt error = eventSource->ExecuteTrap(&ReturnIntFuncIntL,
       
    74                                           FramePositioningControl,
       
    75                                           &CMMAFramePositioningControl::SeekL,
       
    76                                           aFrameNumber,
       
    77                                           &returnValue);
       
    78 
       
    79     return (error == KErrNone) ? returnValue : error;
       
    80 }
       
    81 
       
    82 /**
       
    83  * JNI function from com.nokia.microedition.media.control.FramePositioningControl
       
    84  */
       
    85 JNIEXPORT jintArray JNICALL
       
    86 Java_com_nokia_microedition_media_control_FramePositioningControl__1skip
       
    87 (JNIEnv* aJniEnv,
       
    88  jobject,
       
    89  jint aControlHandle,
       
    90  jint aEventSourceHandle,
       
    91  jintArray aValues)
       
    92 {
       
    93     DEBUG("FramePositioningControl__1skip");
       
    94 
       
    95     // Get pointer to native event source.
       
    96     CMMAEventSource* eventSource =
       
    97         JavaUnhand< CMMAEventSource >(aEventSourceHandle);
       
    98 
       
    99     CMMAFramePositioningControl* FramePositioningControl =
       
   100         JavaUnhand< CMMAFramePositioningControl >(aControlHandle);
       
   101 
       
   102     TInt value[ 2 ];
       
   103     aJniEnv->GetIntArrayRegion(aValues, 0, 2, &value[ 0 ]);
       
   104 
       
   105     // Will leave on error. Otherwise returnValue contains number of frames
       
   106     // skipped.
       
   107     value[ 1 ] = eventSource->ExecuteTrap(&ReturnIntFuncIntL,
       
   108                                           FramePositioningControl,
       
   109                                           &CMMAFramePositioningControl::SkipL,
       
   110                                           value[ 0 ],
       
   111                                           &value[ 0 ]);
       
   112 
       
   113     if (aValues)
       
   114     {
       
   115         aJniEnv->SetIntArrayRegion(aValues, 0, 2, &value[ 0 ]);
       
   116     }
       
   117 
       
   118     return aValues;
       
   119 }
       
   120 
       
   121 /**
       
   122  * Local function which can be used to call CMMAFramePositioningControl class methods.
       
   123  * Type of of the function pointer must be
       
   124  * void CMMAFramePositioningControl::aFunc( TInt, TInt64* )
       
   125  *
       
   126  * @param aFramePositioningControl CMMAFramePositioningControl pointer.
       
   127  * @param aFuncL Pointer to the CMMAFramePositioningControl method.
       
   128  * @param aParam Parameter value for aFuncL
       
   129  * @param aReturnValue The return value of the aFunc will
       
   130  *                     be assigned to this parameter.
       
   131  */
       
   132 LOCAL_C void VoidFuncInt64L(CMMAFramePositioningControl* aFramePositioningControl,
       
   133                             void (CMMAFramePositioningControl::*aFuncL)(
       
   134                                 TInt aParam,
       
   135                                 TInt64* aReturnValue),
       
   136                             TInt aParam,
       
   137                             TInt64* aReturnValue)
       
   138 {
       
   139     // call void CMMAFramePositioningControl::aFunc( TInt, TInt64 ) method.
       
   140     (aFramePositioningControl->*aFuncL)(aParam, aReturnValue);
       
   141 }
       
   142 
       
   143 /**
       
   144  * JNI function from com.nokia.microedition.media.control.FramePositioningControl
       
   145  */
       
   146 JNIEXPORT jlong JNICALL
       
   147 Java_com_nokia_microedition_media_control_FramePositioningControl__1mapFrameToTime
       
   148 (JNIEnv*,
       
   149  jobject,
       
   150  jint aControlHandle,
       
   151  jint aEventSourceHandle,
       
   152  jint aFrameNumber)
       
   153 {
       
   154     DEBUG("FramePositioningControl__1mapFrameToTime");
       
   155 
       
   156     // Get pointer to native event source.
       
   157     CMMAEventSource* eventSource =
       
   158         JavaUnhand< CMMAEventSource >(aEventSourceHandle);
       
   159 
       
   160     CMMAFramePositioningControl* FramePositioningControl =
       
   161         JavaUnhand< CMMAFramePositioningControl >(aControlHandle);
       
   162 
       
   163     // Will leave on error. Media time of frame in question.
       
   164     TInt64 returnValue(0);
       
   165     TInt error = eventSource->ExecuteTrap(&VoidFuncInt64L,
       
   166                                           FramePositioningControl,
       
   167                                           &CMMAFramePositioningControl::MapFrameToTimeL,
       
   168                                           aFrameNumber,
       
   169                                           &returnValue);
       
   170 
       
   171     return (error == KErrNone) ? returnValue : error;
       
   172 }
       
   173 
       
   174 /**
       
   175  * Local function which can be used to call CMMAFramePositioningControl class methods.
       
   176  * Type of of the function pointer must be
       
   177  * TInt CMMAFramePositioningControl::aFunc( TInt64* )
       
   178  *
       
   179  * @param aFramePositioningControl CMMAFramePositioningControl pointer.
       
   180  * @param aFuncL Pointer to the CMMAFramePositioningControl method.
       
   181  * @param aParam Parameter value for aFuncL method.
       
   182  * @param aReturnValue The return value of the aFunc will
       
   183  *                     be assigned to this parameter.
       
   184  */
       
   185 LOCAL_C void ReturnIntFuncInt64L(CMMAFramePositioningControl* aFramePositioningControl,
       
   186                                  TInt(CMMAFramePositioningControl::*aFuncL)(TInt64* aParam),
       
   187                                  TInt64* aParam,
       
   188                                  TInt* aReturnValue)
       
   189 {
       
   190     // call TInt CMMAFramePositioningControl::aFunc() method.
       
   191     *aReturnValue = (aFramePositioningControl->*aFuncL)(aParam);
       
   192 }
       
   193 
       
   194 /**
       
   195  * JNI function from com.nokia.microedition.media.control.FramePositioningControl
       
   196  */
       
   197 JNIEXPORT jint JNICALL
       
   198 Java_com_nokia_microedition_media_control_FramePositioningControl__1mapTimeToFrame
       
   199 (JNIEnv*,
       
   200  jobject,
       
   201  jint aControlHandle,
       
   202  jint aEventSourceHandle,
       
   203  jlong aMediaTime)
       
   204 {
       
   205     DEBUG("FramePositioningControl__1mapFrameToTime");
       
   206 
       
   207     // Get pointer to native event source.
       
   208     CMMAEventSource* eventSource =
       
   209         JavaUnhand< CMMAEventSource >(aEventSourceHandle);
       
   210 
       
   211     CMMAFramePositioningControl* FramePositioningControl =
       
   212         JavaUnhand< CMMAFramePositioningControl >(aControlHandle);
       
   213 
       
   214     // Will leave on error. Media time of frame in question.
       
   215     TInt returnValue = 0;
       
   216     TInt error = eventSource->ExecuteTrap(&ReturnIntFuncInt64L,
       
   217                                           FramePositioningControl,
       
   218                                           &CMMAFramePositioningControl::MapTimeToFrameL,
       
   219                                           &aMediaTime,
       
   220                                           &returnValue);
       
   221 
       
   222     return (error == KErrNone) ? returnValue : error;
       
   223 }
       
   224 //  END OF FILE