|
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 CMMARecordControl |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include <logger.h> |
|
20 |
|
21 #include <JniEnvWrapper.h> |
|
22 |
|
23 #include "com_nokia_microedition_media_control_RecordControl.h" |
|
24 #include "mmafunctionserver.h" |
|
25 #include "cmmarecordcontrol.h" |
|
26 #include "s60commonutils.h" |
|
27 #include "jstringutils.h" |
|
28 using namespace java::util; |
|
29 |
|
30 |
|
31 void VVoidFuncL(CMMARecordControl* aControl, void(CMMARecordControl::*aFunc)()) |
|
32 { |
|
33 (aControl->*aFunc)(); |
|
34 } |
|
35 |
|
36 void TIntFuncL(CMMARecordControl* aControl, TInt(CMMARecordControl::*aFunc)(TInt), |
|
37 TInt* aReturnValue) |
|
38 { |
|
39 *aReturnValue = (aControl->*aFunc)(*aReturnValue); |
|
40 } |
|
41 /* |
|
42 * Class: com_nokia_microedition_media_RecordControl |
|
43 * Method: int _startRecord( int aEventSourceHandle, int aRecordControlHandle ); |
|
44 * Signature: (II)I |
|
45 */ |
|
46 JNIEXPORT jint JNICALL Java_com_nokia_microedition_media_control_RecordControl__1startRecord |
|
47 (JNIEnv *, jclass, jint aEventSourceHandle, jint aRecordControlHandle) |
|
48 { |
|
49 LOG( EJavaMMAPI, EInfo, "Java_com_nokia_microedition_media_control_RecordControl__1startRecord"); |
|
50 |
|
51 MMAFunctionServer* eventSource = |
|
52 reinterpret_cast< MMAFunctionServer* >(aEventSourceHandle); |
|
53 |
|
54 CMMARecordControl* recordControl = |
|
55 reinterpret_cast< CMMARecordControl* >(aRecordControlHandle); |
|
56 |
|
57 return eventSource->ExecuteTrap(&VVoidFuncL, |
|
58 recordControl, |
|
59 &CMMARecordControl::StartRecordL); |
|
60 } |
|
61 |
|
62 /* |
|
63 * Class: com_nokia_microedition_media_RecordControl |
|
64 * Method: int _stopRecord( int aEventSourceHandle, int aRecordControlHandle ); |
|
65 * Signature: (II)I |
|
66 */ |
|
67 JNIEXPORT jint JNICALL Java_com_nokia_microedition_media_control_RecordControl__1stopRecord |
|
68 (JNIEnv *, jclass, jint aEventSourceHandle, jint aRecordControlHandle) |
|
69 { |
|
70 LOG( EJavaMMAPI, EInfo, "Java_com_nokia_microedition_media_control_RecordControl__1stopRecord"); |
|
71 |
|
72 MMAFunctionServer* eventSource = |
|
73 reinterpret_cast< MMAFunctionServer *>(aEventSourceHandle); |
|
74 |
|
75 CMMARecordControl* recordControl = |
|
76 reinterpret_cast< CMMARecordControl* >(aRecordControlHandle); |
|
77 |
|
78 return eventSource->ExecuteTrap(&VVoidFuncL, |
|
79 recordControl, |
|
80 &CMMARecordControl::StopRecordL); |
|
81 } |
|
82 |
|
83 void CMMAOutputStreamFunc(void(CMMARecordControl::*aFunc)(CMMAOutputStream*),CMMARecordControl* aControl, |
|
84 CMMAOutputStream* aOutputStream) |
|
85 { |
|
86 (aControl->*aFunc)(aOutputStream); |
|
87 } |
|
88 /* |
|
89 * Class: com_nokia_microedition_media_RecordControl |
|
90 */ |
|
91 JNIEXPORT jint JNICALL Java_com_nokia_microedition_media_control_RecordControl__1setRecordStream |
|
92 (JNIEnv *aJni, jclass, jint aEventSourceHandle, jint aRecordControlHandle, jobject aOutputWriter) |
|
93 { |
|
94 LOG( EJavaMMAPI, EInfo, "Java_com_nokia_microedition_media_control_RecordControl__1setRecordStream"); |
|
95 |
|
96 MMAFunctionServer* eventSource = |
|
97 reinterpret_cast< MMAFunctionServer *>(aEventSourceHandle); |
|
98 |
|
99 CMMARecordControl* recordControl = |
|
100 reinterpret_cast< CMMARecordControl* >(aRecordControlHandle); |
|
101 |
|
102 jobject writerRef = aJni->NewWeakGlobalRef(aOutputWriter); |
|
103 CMMAOutputStream* outputStream; |
|
104 |
|
105 TInt err = eventSource->ExecuteTrap(CMMAOutputStream::CreateL, |
|
106 &outputStream, |
|
107 eventSource, |
|
108 aJni, |
|
109 (MMMAEventPoster*)eventSource, |
|
110 writerRef); |
|
111 |
|
112 if (err == KErrNone) |
|
113 { |
|
114 eventSource->ExecuteV(&CMMAOutputStreamFunc, |
|
115 &CMMARecordControl::SetRecordStream, |
|
116 recordControl, |
|
117 outputStream); |
|
118 |
|
119 return reinterpret_cast<TInt>(outputStream); |
|
120 } |
|
121 else |
|
122 { |
|
123 aJni->DeleteWeakGlobalRef((jweak)writerRef); |
|
124 return err; |
|
125 } |
|
126 } |
|
127 |
|
128 void HBufCFunc(CMMARecordControl* aControl, HBufC*(CMMARecordControl::*aFunc)(), |
|
129 HBufC** aBuf) |
|
130 { |
|
131 *aBuf = (aControl->*aFunc)(); |
|
132 } |
|
133 |
|
134 /* |
|
135 * Class: com_nokia_microedition_media_RecordControl |
|
136 * Method: String _getContentType( int aEventSourceHandle, int aRecordControlHandle ); |
|
137 * Signature: (II)I |
|
138 */ |
|
139 JNIEXPORT jstring JNICALL Java_com_nokia_microedition_media_control_RecordControl__1getContentType |
|
140 (JNIEnv *aJniEnv, jclass, jint aEventSourceHandle, jint aRecordControlHandle) |
|
141 { |
|
142 LOG( EJavaMMAPI, EInfo, "Java_com_nokia_microedition_media_control_RecordControl__1getContentType"); |
|
143 |
|
144 MMAFunctionServer* eventSource = |
|
145 reinterpret_cast< MMAFunctionServer* >(aEventSourceHandle); |
|
146 |
|
147 CMMARecordControl* recordControl = |
|
148 reinterpret_cast< CMMARecordControl* >(aRecordControlHandle); |
|
149 |
|
150 const HBufC* contentType = NULL; |
|
151 eventSource->ExecuteTrap(&HBufCFunc, |
|
152 recordControl, |
|
153 &CMMARecordControl::GetContentTypeL, |
|
154 (HBufC**)&contentType); |
|
155 |
|
156 if (contentType != NULL) |
|
157 { |
|
158 return S60CommonUtils::NativeToJavaString(*aJniEnv, *contentType); |
|
159 } |
|
160 // ContentType is not known (Player not started?) |
|
161 return S60CommonUtils::NativeToJavaString(*aJniEnv, KNullDesC); |
|
162 } |
|
163 |
|
164 /* |
|
165 * Class: com_nokia_microedition_media_RecordControl |
|
166 * Method: int _commit( int aEventSourceHandle, int aRecordControlHandle ); |
|
167 * Signature: (II)I |
|
168 */ |
|
169 JNIEXPORT jint JNICALL Java_com_nokia_microedition_media_control_RecordControl__1commit |
|
170 (JNIEnv *, jclass, jint aEventSourceHandle, jint aRecordControlHandle) |
|
171 { |
|
172 LOG( EJavaMMAPI, EInfo, "Java_com_nokia_microedition_media_control_RecordControl__1commit"); |
|
173 |
|
174 MMAFunctionServer* eventSource = |
|
175 reinterpret_cast< MMAFunctionServer *>(aEventSourceHandle); |
|
176 |
|
177 CMMARecordControl* recordControl = |
|
178 reinterpret_cast< CMMARecordControl* >(aRecordControlHandle); |
|
179 |
|
180 return eventSource->ExecuteTrap(&VVoidFuncL, |
|
181 recordControl, |
|
182 &CMMARecordControl::CommitL); |
|
183 } |
|
184 |
|
185 /* |
|
186 * Class: com_nokia_microedition_media_RecordControl |
|
187 * Method: int _setRecordSizeLimit( int aEventSourceHandle, int aRecordControlHandle, int aSize ); |
|
188 * Signature: (III)I |
|
189 */ |
|
190 JNIEXPORT jint JNICALL Java_com_nokia_microedition_media_control_RecordControl__1setRecordSizeLimit |
|
191 (JNIEnv *, jclass, jint aEventSourceHandle, jint aRecordControlHandle, jint aSize) |
|
192 { |
|
193 LOG( EJavaMMAPI, EInfo, "Java_com_nokia_microedition_media_control_RecordControl__1setRecordSizeLimit"); |
|
194 |
|
195 MMAFunctionServer* eventSource = |
|
196 reinterpret_cast< MMAFunctionServer *>(aEventSourceHandle); |
|
197 |
|
198 CMMARecordControl* recordControl = |
|
199 reinterpret_cast< CMMARecordControl *>(aRecordControlHandle); |
|
200 |
|
201 TInt err = eventSource->ExecuteTrap(&TIntFuncL, |
|
202 recordControl, |
|
203 &CMMARecordControl::SetRecordSizeLimitL, |
|
204 &aSize); |
|
205 if (err != KErrNone) |
|
206 { |
|
207 return err; |
|
208 } |
|
209 |
|
210 // return size of the set record size |
|
211 return aSize; |
|
212 } |
|
213 |
|
214 /* |
|
215 * Class: com_nokia_microedition_media_RecordControl |
|
216 * Method: int _reset( int aEventSourceHandle, int aRecordControlHandle ); |
|
217 * Signature: (II)I |
|
218 */ |
|
219 JNIEXPORT jint JNICALL Java_com_nokia_microedition_media_control_RecordControl__1reset |
|
220 (JNIEnv *, jclass, jint aEventSourceHandle, jint aRecordControlHandle) |
|
221 { |
|
222 LOG( EJavaMMAPI, EInfo, "Java_com_nokia_microedition_media_control_RecordControl__1reset"); |
|
223 |
|
224 MMAFunctionServer* eventSource = |
|
225 reinterpret_cast< MMAFunctionServer *>(aEventSourceHandle); |
|
226 |
|
227 CMMARecordControl* recordControl = |
|
228 reinterpret_cast< CMMARecordControl *>(aRecordControlHandle); |
|
229 |
|
230 return eventSource->ExecuteTrap(&VVoidFuncL, |
|
231 recordControl, |
|
232 &CMMARecordControl::ResetL); |
|
233 } |
|
234 |
|
235 // END OF FILE |