javauis/amms_akn/jni/src/ammsplugin.cpp
branchRCL_3
changeset 19 04becd199f91
equal deleted inserted replaced
16:f5050f1da672 19:04becd199f91
       
     1 /*
       
     2 * Copyright (c) 2006 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:  Creates CAMMSPriorityControl and adds it to the player.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #include <jutils.h>
       
    20 #include <jdebug.h>
       
    21 
       
    22 #include "com_nokia_amms_AMMSPlugin.h"
       
    23 #include <cmmaeventsource.h>
       
    24 #include <cmmaplayer.h>
       
    25 #include "cammsprioritycontrol.h"
       
    26 #include "cammsaudiooutputcontrol.h"
       
    27 
       
    28 /**
       
    29  * Creates CAMMSPriorityControl and adds it to the player.
       
    30  * Returns the created control through the given parameter.
       
    31  */
       
    32 static void CreatePriorityControlL(CMMAPlayer* aPlayer,
       
    33                                    CAMMSPriorityControl** aControl)
       
    34 {
       
    35     DEBUG("CreatePriorityControlL +");
       
    36 
       
    37     CAMMSPriorityControl* control = CAMMSPriorityControl::NewLC(aPlayer);
       
    38 
       
    39     aPlayer->AddControlL(control);
       
    40 
       
    41     CleanupStack::Pop(control);
       
    42 
       
    43     *aControl = control;
       
    44 
       
    45     DEBUG("CreatePriorityControlL -");
       
    46 }
       
    47 
       
    48 /**
       
    49 * Creates CAMMSAudioOutputControl and adds it to the player.
       
    50 * Returns the created control through the given parameter.
       
    51 */
       
    52 static void CreateAudioOutputControlL(CMMAPlayer* aPlayer,
       
    53                                       CAMMSAudioOutputControl** aControl)
       
    54 {
       
    55     DEBUG("CreatePriorityControlL +");
       
    56 
       
    57     CAMMSAudioOutputControl* control = CAMMSAudioOutputControl::NewLC(aPlayer);
       
    58 
       
    59     aPlayer->AddControlL(control);
       
    60 
       
    61     CleanupStack::Pop(control);
       
    62 
       
    63     *aControl = control;
       
    64 
       
    65     DEBUG("CAMMSAudioOutputControl -");
       
    66 }
       
    67 /*
       
    68  * Class:     com_nokia_amms_AMMSPlugin
       
    69  * Method:    _createNativePriorityControl
       
    70  *
       
    71  */
       
    72 JNIEXPORT jint JNICALL Java_com_nokia_amms_AMMSPlugin__1createNativePriorityControl(
       
    73     JNIEnv*,
       
    74     jclass,
       
    75     jint aEventSource,
       
    76     jint aPlayer)
       
    77 {
       
    78     DEBUG("AMMS: Java_com_nokia_amms_AMMSPlugin__1createNativePriorityControl + ");
       
    79 
       
    80     CMMAEventSource* eventSource =
       
    81         JavaUnhand< CMMAEventSource >(aEventSource);
       
    82 
       
    83     CMMAPlayer* player = JavaUnhand< CMMAPlayer >(aPlayer);
       
    84 
       
    85 
       
    86     // Create control and add it to the player.
       
    87     CAMMSPriorityControl* control = NULL;
       
    88 
       
    89     TInt handle =
       
    90         eventSource->ExecuteTrap(&CreatePriorityControlL, player, &control);
       
    91 
       
    92     __ASSERT_DEBUG(control, User::Invariant());
       
    93 
       
    94     if (handle == KErrNone)
       
    95     {
       
    96         handle = JavaMakeHandle(control);
       
    97     }
       
    98 
       
    99     DEBUG("AMMS: Java_com_nokia_amms_AMMSPlugin__1createNativePriorityControl - ");
       
   100 
       
   101     return handle;
       
   102 }
       
   103 
       
   104 /*
       
   105 * Class:     com_nokia_amms_AMMSPlugin
       
   106 * Method:    _createNativeAudioOutputControl
       
   107 *
       
   108 */
       
   109 
       
   110 JNIEXPORT jint JNICALL Java_com_nokia_amms_AMMSPlugin__1createNativeAudioOutputControl(
       
   111     JNIEnv*,
       
   112     jclass,
       
   113     jint aEventSource,
       
   114     jint aPlayer)
       
   115 {
       
   116     DEBUG("AMMS: Java_com_nokia_amms_AMMSPlugin__1createNativeAudioOutputControl + ");
       
   117 
       
   118     CMMAEventSource* eventSource =
       
   119         JavaUnhand< CMMAEventSource >(aEventSource);
       
   120 
       
   121     CMMAPlayer* player = JavaUnhand< CMMAPlayer >(aPlayer);
       
   122 
       
   123 
       
   124     // Create control and add it to the player.
       
   125     CAMMSAudioOutputControl* control = NULL;
       
   126 
       
   127     TInt handle =
       
   128         eventSource->ExecuteTrap(&CreateAudioOutputControlL, player, &control);
       
   129 
       
   130     __ASSERT_DEBUG(control, User::Invariant());
       
   131 
       
   132     if (handle == KErrNone)
       
   133     {
       
   134         handle = JavaMakeHandle(control);
       
   135     }
       
   136 
       
   137     DEBUG("AMMS: Java_com_nokia_amms_AMMSPlugin__1createNativeAudioOutputControl - ");
       
   138 
       
   139     return handle;
       
   140 }
       
   141 //  End of File