|
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: This class has JNI wrappers for CMMASourceStream |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 //#include "jutils.h" |
|
20 //#include "mmapiutils.h" |
|
21 #include "com_nokia_microedition_media_protocol_SourceStreamReader.h" |
|
22 #include "cmmasourcestream.h" |
|
23 #include "mmafunctionserver.h" |
|
24 |
|
25 // If eventsource is already disposed, then do nothing |
|
26 #define CHECK_HANDLE(x, j) { if ( !( x ) || ( ( x )->Players().Count() == 0 ) ) { return ( j ); } } |
|
27 LOCAL_C void WriteDataL(TInt aSourceStream, |
|
28 TInt aPlayer, |
|
29 MMAFunctionServer* aEventSource, |
|
30 const TUint8* aData, |
|
31 TInt aLength, |
|
32 TInt aState) |
|
33 { |
|
34 if (!aEventSource->FindPlayer(aPlayer)) |
|
35 { |
|
36 // Native object was already deleted |
|
37 User::Leave(KErrBadHandle); |
|
38 } |
|
39 CMMASourceStream* sourceStream = |
|
40 reinterpret_cast< CMMASourceStream *>(aSourceStream); |
|
41 |
|
42 sourceStream->WriteL(aData, aLength, aState); |
|
43 LOG(EJavaMMAPI, EInfo, "jni SourceStreamReader.cpp: WriteDataL() -"); |
|
44 } |
|
45 |
|
46 JNIEXPORT jint JNICALL Java_com_nokia_microedition_media_protocol_SourceStreamReader__1write |
|
47 (JNIEnv* aJni, jclass, jint aSourceStream, jint aEventSource, |
|
48 jbyteArray aData, jint aLength, jint aState, jint aPlayerHandle) |
|
49 { |
|
50 LOG(EJavaMMAPI, EInfo, "SourceStreamReaderjni_write"); |
|
51 MMAFunctionServer* eventSource = |
|
52 reinterpret_cast< MMAFunctionServer* >(aEventSource); |
|
53 |
|
54 CHECK_HANDLE(eventSource, KErrNone); |
|
55 |
|
56 jbyte* data = aJni->GetByteArrayElements(aData, NULL); |
|
57 LOG2(EJavaMMAPI, EInfo, "SourceStreamReaderjni_write , length = %d,state = %d",(TInt)aLength,(TInt)aState); |
|
58 TInt err = eventSource->ExecuteTrap(&WriteDataL, |
|
59 aSourceStream, |
|
60 aPlayerHandle, |
|
61 eventSource, |
|
62 (const TUint8*)data, |
|
63 aLength, |
|
64 aState); |
|
65 ELOG1(EJavaMMAPI, "SourceStreamReaderjni_write , err = %d",err); |
|
66 aJni->ReleaseByteArrayElements(aData, data, JNI_ABORT); |
|
67 return err; |
|
68 } |
|
69 |
|
70 // END OF FILE |