• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2011 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 
18 #include <VideoEditorClasses.h>
19 #include <VideoEditorJava.h>
20 #include <VideoEditorLogging.h>
21 #include <VideoEditorOsal.h>
22 
23 extern "C" {
24 #include <M4OSA_Clock.h>
25 #include <M4OSA_CharStar.h>
26 #include <M4OSA_FileCommon.h>
27 #include <M4OSA_FileReader.h>
28 #include <M4OSA_FileWriter.h>
29 #include <M4OSA_Memory.h>
30 #include <M4OSA_Debug.h>
31 #include <M4OSA_Thread.h>
32 #include <M4VSS3GPP_API.h>
33 #include <M4xVSS_API.h>
34 #include <M4VSS3GPP_ErrorCodes.h>
35 #include <M4MCS_ErrorCodes.h>
36 #include <M4READER_Common.h>
37 #include <M4WRITER_common.h>
38 #include <M4DECODER_Common.h>
39 };
40 
41 #define VIDEOEDIT_PROP_JAVA_RESULT_STRING_MAX                     (128)
42 
43 #define VIDEOEDIT_JAVA__RESULT_STRING_MAX                     (128)
44 
VIDEOEDIT_JAVA_DEFINE_CONSTANTS(AudioEffect)45 VIDEOEDIT_JAVA_DEFINE_CONSTANTS(AudioEffect)
46 {
47     VIDEOEDIT_JAVA_CONSTANT_INIT("NONE",     M4VSS3GPP_kAudioEffectType_None),
48     VIDEOEDIT_JAVA_CONSTANT_INIT("FADE_IN",  M4VSS3GPP_kAudioEffectType_FadeIn),
49     VIDEOEDIT_JAVA_CONSTANT_INIT("FADE_OUT", M4VSS3GPP_kAudioEffectType_FadeOut)
50 };
51 
VIDEOEDIT_JAVA_DEFINE_CONSTANT_CLASS(AudioEffect,AUDIO_EFFECT_CLASS_NAME,M4OSA_NULL,M4OSA_NULL)52 VIDEOEDIT_JAVA_DEFINE_CONSTANT_CLASS(AudioEffect, AUDIO_EFFECT_CLASS_NAME, M4OSA_NULL, M4OSA_NULL)
53 
54 
55 VIDEOEDIT_JAVA_DEFINE_CONSTANTS(AudioFormat)
56 {
57     VIDEOEDIT_JAVA_CONSTANT_INIT("NO_AUDIO",          M4VIDEOEDITING_kNoneAudio),
58     VIDEOEDIT_JAVA_CONSTANT_INIT("AMR_NB",            M4VIDEOEDITING_kAMR_NB),
59     VIDEOEDIT_JAVA_CONSTANT_INIT("AAC",               M4VIDEOEDITING_kAAC),
60     VIDEOEDIT_JAVA_CONSTANT_INIT("AAC_PLUS",          M4VIDEOEDITING_kAACplus),
61     VIDEOEDIT_JAVA_CONSTANT_INIT("ENHANCED_AAC_PLUS", M4VIDEOEDITING_keAACplus),
62     VIDEOEDIT_JAVA_CONSTANT_INIT("MP3",               M4VIDEOEDITING_kMP3),
63     VIDEOEDIT_JAVA_CONSTANT_INIT("EVRC",              M4VIDEOEDITING_kEVRC),
64     VIDEOEDIT_JAVA_CONSTANT_INIT("PCM",               M4VIDEOEDITING_kPCM),
65     VIDEOEDIT_JAVA_CONSTANT_INIT("NULL_AUDIO",        M4VIDEOEDITING_kNullAudio),
66     VIDEOEDIT_JAVA_CONSTANT_INIT("UNSUPPORTED_AUDIO", M4VIDEOEDITING_kUnsupportedAudio)
67 };
68 
VIDEOEDIT_JAVA_DEFINE_CONSTANT_CLASS(AudioFormat,AUDIO_FORMAT_CLASS_NAME,M4OSA_NULL,M4OSA_NULL)69 VIDEOEDIT_JAVA_DEFINE_CONSTANT_CLASS(AudioFormat, AUDIO_FORMAT_CLASS_NAME, M4OSA_NULL, M4OSA_NULL)
70 
71 
72 VIDEOEDIT_JAVA_DEFINE_CONSTANTS(AudioSamplingFrequency)
73 {
74     VIDEOEDIT_JAVA_CONSTANT_INIT("FREQ_DEFAULT", M4VIDEOEDITING_kDefault_ASF),
75     VIDEOEDIT_JAVA_CONSTANT_INIT("FREQ_8000",    M4VIDEOEDITING_k8000_ASF),
76     VIDEOEDIT_JAVA_CONSTANT_INIT("FREQ_16000",   M4VIDEOEDITING_k16000_ASF),
77     VIDEOEDIT_JAVA_CONSTANT_INIT("FREQ_22050",   M4VIDEOEDITING_k22050_ASF),
78     VIDEOEDIT_JAVA_CONSTANT_INIT("FREQ_24000",   M4VIDEOEDITING_k24000_ASF),
79     VIDEOEDIT_JAVA_CONSTANT_INIT("FREQ_32000",   M4VIDEOEDITING_k32000_ASF),
80     VIDEOEDIT_JAVA_CONSTANT_INIT("FREQ_44100",   M4VIDEOEDITING_k44100_ASF),
81     VIDEOEDIT_JAVA_CONSTANT_INIT("FREQ_48000",   M4VIDEOEDITING_k48000_ASF)
82 };
83 
VIDEOEDIT_JAVA_DEFINE_CONSTANT_CLASS(AudioSamplingFrequency,AUDIO_SAMPLING_FREQUENCY_CLASS_NAME,M4OSA_NULL,M4OSA_NULL)84 VIDEOEDIT_JAVA_DEFINE_CONSTANT_CLASS(AudioSamplingFrequency,AUDIO_SAMPLING_FREQUENCY_CLASS_NAME,
85                                      M4OSA_NULL, M4OSA_NULL)
86 
87 
88 VIDEOEDIT_JAVA_DEFINE_CONSTANTS(AudioTransition)
89 {
90     VIDEOEDIT_JAVA_CONSTANT_INIT("NONE",       M4VSS3GPP_kAudioTransitionType_None),
91     VIDEOEDIT_JAVA_CONSTANT_INIT("CROSS_FADE", M4VSS3GPP_kAudioTransitionType_CrossFade)
92 };
93 
VIDEOEDIT_JAVA_DEFINE_CONSTANT_CLASS(AudioTransition,AUDIO_TRANSITION_CLASS_NAME,M4OSA_NULL,M4OSA_NULL) const94 VIDEOEDIT_JAVA_DEFINE_CONSTANT_CLASS(AudioTransition, AUDIO_TRANSITION_CLASS_NAME, M4OSA_NULL,
95                                      M4OSA_NULL)
96 
97 
98 static const char*
99 videoEditClasses_getUnknownBitrateString(int bitrate)
100 {
101     static char string[VIDEOEDIT_JAVA__RESULT_STRING_MAX] = "";
102 
103     M4OSA_chrSPrintf((M4OSA_Char *)string, sizeof(string) - 1, (M4OSA_Char*)"%d", bitrate);
104 
105     // Return the bitrate string.
106     return(string);
107 }
108 
VIDEOEDIT_JAVA_DEFINE_CONSTANTS(Bitrate)109 VIDEOEDIT_JAVA_DEFINE_CONSTANTS(Bitrate)
110 {
111     VIDEOEDIT_JAVA_CONSTANT_INIT("VARIABLE",     M4VIDEOEDITING_kVARIABLE_KBPS),
112     VIDEOEDIT_JAVA_CONSTANT_INIT("UNDEFINED",    M4VIDEOEDITING_kUndefinedBitrate),
113     VIDEOEDIT_JAVA_CONSTANT_INIT("BR_9_2_KBPS",  M4VIDEOEDITING_k9_2_KBPS),
114     VIDEOEDIT_JAVA_CONSTANT_INIT("BR_12_2_KBPS", M4VIDEOEDITING_k12_2_KBPS),
115     VIDEOEDIT_JAVA_CONSTANT_INIT("BR_16_KBPS",   M4VIDEOEDITING_k16_KBPS),
116     VIDEOEDIT_JAVA_CONSTANT_INIT("BR_24_KBPS",   M4VIDEOEDITING_k24_KBPS),
117     VIDEOEDIT_JAVA_CONSTANT_INIT("BR_32_KBPS",   M4VIDEOEDITING_k32_KBPS),
118     VIDEOEDIT_JAVA_CONSTANT_INIT("BR_48_KBPS",   M4VIDEOEDITING_k48_KBPS),
119     VIDEOEDIT_JAVA_CONSTANT_INIT("BR_64_KBPS",   M4VIDEOEDITING_k64_KBPS),
120     VIDEOEDIT_JAVA_CONSTANT_INIT("BR_96_KBPS",   M4VIDEOEDITING_k96_KBPS),
121     VIDEOEDIT_JAVA_CONSTANT_INIT("BR_128_KBPS",  M4VIDEOEDITING_k128_KBPS),
122     VIDEOEDIT_JAVA_CONSTANT_INIT("BR_192_KBPS",  M4VIDEOEDITING_k192_KBPS),
123     VIDEOEDIT_JAVA_CONSTANT_INIT("BR_256_KBPS",  M4VIDEOEDITING_k256_KBPS),
124     VIDEOEDIT_JAVA_CONSTANT_INIT("BR_288_KBPS",  M4VIDEOEDITING_k288_KBPS),
125     VIDEOEDIT_JAVA_CONSTANT_INIT("BR_384_KBPS",  M4VIDEOEDITING_k384_KBPS),
126     VIDEOEDIT_JAVA_CONSTANT_INIT("BR_512_KBPS",  M4VIDEOEDITING_k512_KBPS),
127     VIDEOEDIT_JAVA_CONSTANT_INIT("BR_800_KBPS",  M4VIDEOEDITING_k800_KBPS),
128 /*+ New Encoder bitrates */
129     VIDEOEDIT_JAVA_CONSTANT_INIT("BR_2_MBPS",  M4VIDEOEDITING_k2_MBPS),
130     VIDEOEDIT_JAVA_CONSTANT_INIT("BR_5_MBPS",  M4VIDEOEDITING_k5_MBPS),
131     VIDEOEDIT_JAVA_CONSTANT_INIT("BR_8_MBPS",  M4VIDEOEDITING_k8_MBPS)
132 /*- New Encoder bitrates */
133 };
134 
VIDEOEDIT_JAVA_DEFINE_CONSTANT_CLASS(Bitrate,BITRATE_CLASS_NAME,videoEditClasses_getUnknownBitrateString,videoEditClasses_getUnknownBitrateString)135 VIDEOEDIT_JAVA_DEFINE_CONSTANT_CLASS(Bitrate, BITRATE_CLASS_NAME,
136  videoEditClasses_getUnknownBitrateString, videoEditClasses_getUnknownBitrateString)
137 
138 
139 VIDEOEDIT_JAVA_DEFINE_CONSTANTS(ClipType)
140 {
141     VIDEOEDIT_JAVA_CONSTANT_INIT("THREE_GPP",   M4VIDEOEDITING_kFileType_3GPP),
142     VIDEOEDIT_JAVA_CONSTANT_INIT("MP4",         M4VIDEOEDITING_kFileType_MP4),
143     VIDEOEDIT_JAVA_CONSTANT_INIT("AMR",         M4VIDEOEDITING_kFileType_AMR),
144     VIDEOEDIT_JAVA_CONSTANT_INIT("MP3",         M4VIDEOEDITING_kFileType_MP3),
145     VIDEOEDIT_JAVA_CONSTANT_INIT("PCM",         M4VIDEOEDITING_kFileType_PCM),
146     VIDEOEDIT_JAVA_CONSTANT_INIT("JPG",         M4VIDEOEDITING_kFileType_JPG),
147     VIDEOEDIT_JAVA_CONSTANT_INIT("PNG",         M4VIDEOEDITING_kFileType_PNG),
148     VIDEOEDIT_JAVA_CONSTANT_INIT("M4V",         M4VIDEOEDITING_kFileType_M4V),
149     VIDEOEDIT_JAVA_CONSTANT_INIT("UNSUPPORTED", M4VIDEOEDITING_kFileType_Unsupported)
150 };
151 
VIDEOEDIT_JAVA_DEFINE_CONSTANT_CLASS(ClipType,FILE_TYPE_CLASS_NAME,M4OSA_NULL,M4OSA_NULL)152 VIDEOEDIT_JAVA_DEFINE_CONSTANT_CLASS(ClipType, FILE_TYPE_CLASS_NAME, M4OSA_NULL, M4OSA_NULL)
153 
154 
155 VIDEOEDIT_JAVA_DEFINE_CONSTANTS(Engine)
156 {
157     VIDEOEDIT_JAVA_CONSTANT_INIT("TASK_LOADING_SETTINGS",    TASK_LOADING_SETTINGS),
158     VIDEOEDIT_JAVA_CONSTANT_INIT("TASK_ENCODING",            TASK_ENCODING)
159 };
160 
VIDEOEDIT_JAVA_DEFINE_CONSTANT_CLASS(Engine,MANUAL_EDIT_ENGINE_CLASS_NAME,M4OSA_NULL,M4OSA_NULL) const161 VIDEOEDIT_JAVA_DEFINE_CONSTANT_CLASS(Engine, MANUAL_EDIT_ENGINE_CLASS_NAME, M4OSA_NULL,
162                                      M4OSA_NULL)
163 
164 
165 static const char*
166 videoEditClasses_getUnknownErrorName(int error)
167 {
168     static char string[VIDEOEDIT_JAVA__RESULT_STRING_MAX] = "ERR_INTERNAL";
169 
170     // Format the unknown error string.
171     M4OSA_chrSPrintf((M4OSA_Char *)string, sizeof(string) - 1, (M4OSA_Char*)"ERR_INTERNAL(%s)",
172                     videoEditOsal_getResultString(error));
173 
174     // Return the error string.
175     return(string);
176 }
177 
178 static const char*
videoEditClasses_getUnknownErrorString(int error)179 videoEditClasses_getUnknownErrorString(int error)
180 {
181     // Return the result string.
182     return(videoEditOsal_getResultString(error));
183 }
184 
VIDEOEDIT_JAVA_DEFINE_CONSTANTS(Error)185 VIDEOEDIT_JAVA_DEFINE_CONSTANTS(Error)
186 {
187     // M4OSA_Clock.h
188     VIDEOEDIT_JAVA_CONSTANT_INIT("WAR_TIMESCALE_TOO_BIG",                   \
189           M4WAR_TIMESCALE_TOO_BIG                               ),
190     VIDEOEDIT_JAVA_CONSTANT_INIT("ERR_CLOCK_BAD_REF_YEAR",                  \
191           M4ERR_CLOCK_BAD_REF_YEAR                              ),
192     VIDEOEDIT_JAVA_CONSTANT_INIT("ERR_FILE_NOT_FOUND",                      \
193           M4ERR_FILE_NOT_FOUND                                  ),
194     VIDEOEDIT_JAVA_CONSTANT_INIT("WAR_TRANSCODING_NECESSARY",               \
195           M4VSS3GPP_WAR_TRANSCODING_NECESSARY                   ),
196     VIDEOEDIT_JAVA_CONSTANT_INIT("WAR_MAX_OUTPUT_SIZE_EXCEEDED",            \
197           M4VSS3GPP_WAR_OUTPUTFILESIZE_EXCEED                   ),
198     VIDEOEDIT_JAVA_CONSTANT_INIT("ERR_BUFFER_OUT_TOO_SMALL",                \
199           M4xVSSWAR_BUFFER_OUT_TOO_SMALL                        ),
200     VIDEOEDIT_JAVA_CONSTANT_INIT("ERR_NOMORE_SPACE_FOR_FILE",               \
201           M4xVSSERR_NO_MORE_SPACE                               ),
202     VIDEOEDIT_JAVA_CONSTANT_INIT("ERR_INVALID_FILE_TYPE",                   \
203           M4VSS3GPP_ERR_INVALID_FILE_TYPE                       ),
204     VIDEOEDIT_JAVA_CONSTANT_INIT("ERR_INVALID_EFFECT_KIND",                 \
205           M4VSS3GPP_ERR_INVALID_EFFECT_KIND                     ),
206     VIDEOEDIT_JAVA_CONSTANT_INIT("ERR_INVALID_VIDEO_EFFECT_TYPE",           \
207           M4VSS3GPP_ERR_INVALID_VIDEO_EFFECT_TYPE               ),
208     VIDEOEDIT_JAVA_CONSTANT_INIT("ERR_INVALID_AUDIO_EFFECT_TYPE",           \
209           M4VSS3GPP_ERR_INVALID_AUDIO_EFFECT_TYPE               ),
210     VIDEOEDIT_JAVA_CONSTANT_INIT("ERR_INVALID_VIDEO_TRANSITION_TYPE",       \
211           M4VSS3GPP_ERR_INVALID_VIDEO_TRANSITION_TYPE           ),
212     VIDEOEDIT_JAVA_CONSTANT_INIT("ERR_INVALID_AUDIO_TRANSITION_TYPE",       \
213           M4VSS3GPP_ERR_INVALID_AUDIO_TRANSITION_TYPE           ),
214     VIDEOEDIT_JAVA_CONSTANT_INIT("ERR_INVALID_VIDEO_ENCODING_FRAME_RATE",   \
215           M4VSS3GPP_ERR_INVALID_VIDEO_ENCODING_FRAME_RATE       ),
216     VIDEOEDIT_JAVA_CONSTANT_INIT("ERR_EXTERNAL_EFFECT_NULL",                \
217           M4VSS3GPP_ERR_EXTERNAL_EFFECT_NULL                    ),
218     VIDEOEDIT_JAVA_CONSTANT_INIT("ERR_EXTERNAL_TRANSITION_NULL",            \
219           M4VSS3GPP_ERR_EXTERNAL_TRANSITION_NULL                ),
220     VIDEOEDIT_JAVA_CONSTANT_INIT("ERR_BEGIN_CUT_LARGER_THAN_DURATION",      \
221           M4VSS3GPP_ERR_BEGIN_CUT_LARGER_THAN_DURATION          ),
222     VIDEOEDIT_JAVA_CONSTANT_INIT("ERR_BEGIN_CUT_LARGER_THAN_END_CUT",       \
223           M4VSS3GPP_ERR_BEGIN_CUT_LARGER_THAN_END_CUT           ),
224     VIDEOEDIT_JAVA_CONSTANT_INIT("ERR_OVERLAPPING_TRANSITIONS",             \
225          M4VSS3GPP_ERR_OVERLAPPING_TRANSITIONS                  ),
226 #ifdef M4VSS3GPP_ERR_ANALYSIS_DATA_SIZE_TOO_SMALL
227     VIDEOEDIT_JAVA_CONSTANT_INIT("ERR_ANALYSIS_DATA_SIZE_TOO_SMALL",        \
228           M4VSS3GPP_ERR_ANALYSIS_DATA_SIZE_TOO_SMALL            ),
229 #endif
230     VIDEOEDIT_JAVA_CONSTANT_INIT("ERR_INVALID_3GPP_FILE",                     \
231         M4VSS3GPP_ERR_INVALID_3GPP_FILE                         ),
232     VIDEOEDIT_JAVA_CONSTANT_INIT("ERR_UNSUPPORTED_INPUT_VIDEO_FORMAT",        \
233         M4VSS3GPP_ERR_UNSUPPORTED_INPUT_VIDEO_FORMAT            ),
234     VIDEOEDIT_JAVA_CONSTANT_INIT("ERR_UNSUPPORTED_INPUT_AUDIO_FORMAT",        \
235         M4VSS3GPP_ERR_UNSUPPORTED_INPUT_AUDIO_FORMAT            ),
236     VIDEOEDIT_JAVA_CONSTANT_INIT("ERR_AMR_EDITING_UNSUPPORTED",               \
237         M4VSS3GPP_ERR_AMR_EDITING_UNSUPPORTED                   ),
238     VIDEOEDIT_JAVA_CONSTANT_INIT("ERR_INPUT_VIDEO_AU_TOO_LARGE",              \
239         M4VSS3GPP_ERR_INPUT_VIDEO_AU_TOO_LARGE                  ),
240     VIDEOEDIT_JAVA_CONSTANT_INIT("ERR_INPUT_AUDIO_AU_TOO_LARGE",              \
241         M4VSS3GPP_ERR_INPUT_AUDIO_AU_TOO_LARGE                  ),
242     VIDEOEDIT_JAVA_CONSTANT_INIT("ERR_INPUT_AUDIO_CORRUPTED_AU",              \
243         M4VSS3GPP_ERR_INPUT_AUDIO_CORRUPTED_AU                  ),
244 #ifdef M4VSS3GPP_ERR_INPUT_AUDIO_CORRUPTED_AMR_AU
245     VIDEOEDIT_JAVA_CONSTANT_INIT("ERR_INPUT_AUDIO_CORRUPTED_AU",              \
246         M4VSS3GPP_ERR_INPUT_AUDIO_CORRUPTED_AMR_AU              ),
247 #endif
248     VIDEOEDIT_JAVA_CONSTANT_INIT("ERR_ENCODER_ACCES_UNIT_ERROR",              \
249         M4VSS3GPP_ERR_ENCODER_ACCES_UNIT_ERROR                  ),
250     VIDEOEDIT_JAVA_CONSTANT_INIT("ERR_EDITING_UNSUPPORTED_VIDEO_FORMAT",      \
251         M4VSS3GPP_ERR_EDITING_UNSUPPORTED_VIDEO_FORMAT          ),
252     VIDEOEDIT_JAVA_CONSTANT_INIT("ERR_EDITING_UNSUPPORTED_H263_PROFILE",      \
253         M4VSS3GPP_ERR_EDITING_UNSUPPORTED_H263_PROFILE          ),
254     VIDEOEDIT_JAVA_CONSTANT_INIT("ERR_EDITING_UNSUPPORTED_MPEG4_PROFILE",     \
255         M4VSS3GPP_ERR_EDITING_UNSUPPORTED_MPEG4_PROFILE         ),
256     VIDEOEDIT_JAVA_CONSTANT_INIT("ERR_EDITING_UNSUPPORTED_MPEG4_RVLC",        \
257         M4VSS3GPP_ERR_EDITING_UNSUPPORTED_MPEG4_RVLC            ),
258     VIDEOEDIT_JAVA_CONSTANT_INIT("ERR_EDITING_UNSUPPORTED_AUDIO_FORMAT",      \
259         M4VSS3GPP_ERR_EDITING_UNSUPPORTED_AUDIO_FORMAT          ),
260     VIDEOEDIT_JAVA_CONSTANT_INIT("ERR_EDITING_NO_SUPPORTED_STREAM_IN_FILE",   \
261         M4VSS3GPP_ERR_EDITING_NO_SUPPORTED_STREAM_IN_FILE       ),
262     VIDEOEDIT_JAVA_CONSTANT_INIT("ERR_EDITING_NO_SUPPORTED_VIDEO_STREAM_IN_FILE",\
263      M4VSS3GPP_ERR_EDITING_NO_SUPPORTED_VIDEO_STREAM_IN_FILE),
264     VIDEOEDIT_JAVA_CONSTANT_INIT("ERR_INVALID_CLIP_ANALYSIS_VERSION",        \
265          M4VSS3GPP_ERR_INVALID_CLIP_ANALYSIS_VERSION            ),
266 #ifdef M4VSS3GPP_ERR_INVALID_CLIP_ANALYSIS_PLATFORM
267     VIDEOEDIT_JAVA_CONSTANT_INIT("ERR_INVALID_CLIP_ANALYSIS_PLATFORM",       \
268         M4VSS3GPP_ERR_INVALID_CLIP_ANALYSIS_PLATFORM            ),
269 #endif
270     VIDEOEDIT_JAVA_CONSTANT_INIT("ERR_INCOMPATIBLE_VIDEO_FORMAT",            \
271          M4VSS3GPP_ERR_INCOMPATIBLE_VIDEO_FORMAT                ),
272     VIDEOEDIT_JAVA_CONSTANT_INIT("ERR_INCOMPATIBLE_VIDEO_FRAME_SIZE",        \
273          M4VSS3GPP_ERR_INCOMPATIBLE_VIDEO_FRAME_SIZE            ),
274     VIDEOEDIT_JAVA_CONSTANT_INIT("ERR_INCOMPATIBLE_VIDEO_TIME_SCALE",        \
275          M4VSS3GPP_ERR_INCOMPATIBLE_VIDEO_TIME_SCALE            ),
276     VIDEOEDIT_JAVA_CONSTANT_INIT("ERR_INCOMPATIBLE_VIDEO_DATA_PARTITIONING", \
277          M4VSS3GPP_ERR_INCOMPATIBLE_VIDEO_DATA_PARTITIONING     ),
278     VIDEOEDIT_JAVA_CONSTANT_INIT("ERR_UNSUPPORTED_MP3_ASSEMBLY",             \
279          M4VSS3GPP_ERR_UNSUPPORTED_MP3_ASSEMBLY                 ),
280     VIDEOEDIT_JAVA_CONSTANT_INIT("ERR_NO_SUPPORTED_STREAM_IN_FILE",          \
281          M4VSS3GPP_ERR_NO_SUPPORTED_STREAM_IN_FILE              ),
282     VIDEOEDIT_JAVA_CONSTANT_INIT("ERR_ADDVOLUME_EQUALS_ZERO",                \
283          M4VSS3GPP_ERR_ADDVOLUME_EQUALS_ZERO                    ),
284     VIDEOEDIT_JAVA_CONSTANT_INIT("ERR_ADDCTS_HIGHER_THAN_VIDEO_DURATION",    \
285          M4VSS3GPP_ERR_ADDCTS_HIGHER_THAN_VIDEO_DURATION        ),
286     VIDEOEDIT_JAVA_CONSTANT_INIT("ERR_UNDEFINED_AUDIO_TRACK_FILE_FORMAT",    \
287          M4VSS3GPP_ERR_UNDEFINED_AUDIO_TRACK_FILE_FORMAT        ),
288     VIDEOEDIT_JAVA_CONSTANT_INIT("ERR_UNSUPPORTED_ADDED_AUDIO_STREAM",       \
289          M4VSS3GPP_ERR_UNSUPPORTED_ADDED_AUDIO_STREAM           ),
290     VIDEOEDIT_JAVA_CONSTANT_INIT("ERR_AUDIO_MIXING_UNSUPPORTED",             \
291          M4VSS3GPP_ERR_AUDIO_MIXING_UNSUPPORTED                 ),
292 #ifdef M4VSS3GPP_ERR_AUDIO_MIXING_MP3_UNSUPPORTED
293     VIDEOEDIT_JAVA_CONSTANT_INIT("ERR_AUDIO_MIXING_MP3_UNSUPPORTED",         \
294           M4VSS3GPP_ERR_AUDIO_MIXING_MP3_UNSUPPORTED            ),
295 #endif
296     VIDEOEDIT_JAVA_CONSTANT_INIT("ERR_FEATURE_UNSUPPORTED_WITH_AUDIO_TRACK", \
297       M4VSS3GPP_ERR_FEATURE_UNSUPPORTED_WITH_AUDIO_TRACK        ),
298 #ifdef M4VSS3GPP_ERR_FEATURE_UNSUPPORTED_WITH_AAC
299     VIDEOEDIT_JAVA_CONSTANT_INIT("ERR_FEATURE_UNSUPPORTED_WITH_AAC",         \
300        M4VSS3GPP_ERR_FEATURE_UNSUPPORTED_WITH_AAC               ),
301 #endif
302     VIDEOEDIT_JAVA_CONSTANT_INIT("ERR_AUDIO_CANNOT_BE_MIXED",                \
303         M4VSS3GPP_ERR_AUDIO_CANNOT_BE_MIXED                     ),
304 #ifdef M4VSS3GPP_ERR_ONLY_AMRNB_INPUT_CAN_BE_MIXED
305     VIDEOEDIT_JAVA_CONSTANT_INIT("ERR_ONLY_AMRNB_INPUT_CAN_BE_MIXED",        \
306          M4VSS3GPP_ERR_ONLY_AMRNB_INPUT_CAN_BE_MIXED            ),
307 #endif
308 #ifdef M4VSS3GPP_ERR_FEATURE_UNSUPPORTED_WITH_EVRC
309     VIDEOEDIT_JAVA_CONSTANT_INIT("ERR_FEATURE_UNSUPPORTED_WITH_EVRC",        \
310           M4VSS3GPP_ERR_FEATURE_UNSUPPORTED_WITH_EVRC           ),
311 #endif
312     VIDEOEDIT_JAVA_CONSTANT_INIT("ERR_H263_PROFILE_NOT_SUPPORTED",           \
313           M4VSS3GPP_ERR_H263_PROFILE_NOT_SUPPORTED              ),
314     VIDEOEDIT_JAVA_CONSTANT_INIT("ERR_NO_SUPPORTED_VIDEO_STREAM_IN_FILE",    \
315           M4VSS3GPP_ERR_NO_SUPPORTED_VIDEO_STREAM_IN_FILE       ),
316     VIDEOEDIT_JAVA_CONSTANT_INIT("ERR_INTERNAL",                             \
317           M4NO_ERROR                                            ),
318 };
319 
VIDEOEDIT_JAVA_DEFINE_CONSTANT_CLASS(Error,ERROR_CLASS_NAME,videoEditClasses_getUnknownErrorName,videoEditClasses_getUnknownErrorString)320 VIDEOEDIT_JAVA_DEFINE_CONSTANT_CLASS(Error, ERROR_CLASS_NAME,
321  videoEditClasses_getUnknownErrorName, videoEditClasses_getUnknownErrorString)
322 
323 
324 VIDEOEDIT_JAVA_DEFINE_CONSTANTS(FileType)
325 {
326     VIDEOEDIT_JAVA_CONSTANT_INIT("THREE_GPP",   VideoEditClasses_kFileType_3GPP),
327     VIDEOEDIT_JAVA_CONSTANT_INIT("MP4",         VideoEditClasses_kFileType_MP4),
328     VIDEOEDIT_JAVA_CONSTANT_INIT("AMR",         VideoEditClasses_kFileType_AMR),
329     VIDEOEDIT_JAVA_CONSTANT_INIT("MP3",         VideoEditClasses_kFileType_MP3),
330     VIDEOEDIT_JAVA_CONSTANT_INIT("PCM",         VideoEditClasses_kFileType_PCM),
331     VIDEOEDIT_JAVA_CONSTANT_INIT("JPG",         VideoEditClasses_kFileType_JPG),
332     VIDEOEDIT_JAVA_CONSTANT_INIT("GIF",         VideoEditClasses_kFileType_GIF),
333     VIDEOEDIT_JAVA_CONSTANT_INIT("PNG",         VideoEditClasses_kFileType_PNG),
334     VIDEOEDIT_JAVA_CONSTANT_INIT("M4V",         VideoEditClasses_kFileType_M4V),
335     VIDEOEDIT_JAVA_CONSTANT_INIT("UNSUPPORTED", VideoEditClasses_kFileType_Unsupported)
336 };
337 
VIDEOEDIT_JAVA_DEFINE_CONSTANT_CLASS(FileType,FILE_TYPE_CLASS_NAME,M4OSA_NULL,M4OSA_NULL)338 VIDEOEDIT_JAVA_DEFINE_CONSTANT_CLASS(FileType, FILE_TYPE_CLASS_NAME, M4OSA_NULL, M4OSA_NULL)
339 
340 
341 VIDEOEDIT_JAVA_DEFINE_CONSTANTS(MediaRendering)
342 {
343     VIDEOEDIT_JAVA_CONSTANT_INIT("RESIZING",      M4xVSS_kResizing),
344     VIDEOEDIT_JAVA_CONSTANT_INIT("CROPPING",      M4xVSS_kCropping),
345     VIDEOEDIT_JAVA_CONSTANT_INIT("BLACK_BORDERS", M4xVSS_kBlackBorders)
346 };
347 
VIDEOEDIT_JAVA_DEFINE_CONSTANT_CLASS(MediaRendering,MEDIA_RENDERING_CLASS_NAME,M4OSA_NULL,M4OSA_NULL)348 VIDEOEDIT_JAVA_DEFINE_CONSTANT_CLASS(MediaRendering, MEDIA_RENDERING_CLASS_NAME,
349  M4OSA_NULL, M4OSA_NULL)
350 
351 
352 VIDEOEDIT_JAVA_DEFINE_CONSTANTS(SlideDirection)
353 {
354     VIDEOEDIT_JAVA_CONSTANT_INIT("RIGHT_OUT_LEFT_IN", M4xVSS_SlideTransition_RightOutLeftIn),
355     VIDEOEDIT_JAVA_CONSTANT_INIT("LEFT_OUT_RIGTH_IN", M4xVSS_SlideTransition_LeftOutRightIn),
356     VIDEOEDIT_JAVA_CONSTANT_INIT("TOP_OUT_BOTTOM_IN", M4xVSS_SlideTransition_TopOutBottomIn),
357     VIDEOEDIT_JAVA_CONSTANT_INIT("BOTTOM_OUT_TOP_IN", M4xVSS_SlideTransition_BottomOutTopIn)
358 };
359 
VIDEOEDIT_JAVA_DEFINE_CONSTANT_CLASS(SlideDirection,SLIDE_DIRECTION_CLASS_NAME,M4OSA_NULL,M4OSA_NULL)360 VIDEOEDIT_JAVA_DEFINE_CONSTANT_CLASS(SlideDirection, SLIDE_DIRECTION_CLASS_NAME,
361  M4OSA_NULL, M4OSA_NULL)
362 
363 
364 VIDEOEDIT_JAVA_DEFINE_CONSTANTS(TransitionBehaviour)
365 {
366     VIDEOEDIT_JAVA_CONSTANT_INIT("SPEED_UP",    M4VSS3GPP_TransitionBehaviour_SpeedUp),
367     VIDEOEDIT_JAVA_CONSTANT_INIT("LINEAR",      M4VSS3GPP_TransitionBehaviour_Linear),
368     VIDEOEDIT_JAVA_CONSTANT_INIT("SPEED_DOWN",  M4VSS3GPP_TransitionBehaviour_SpeedDown),
369     VIDEOEDIT_JAVA_CONSTANT_INIT("SLOW_MIDDLE", M4VSS3GPP_TransitionBehaviour_SlowMiddle),
370     VIDEOEDIT_JAVA_CONSTANT_INIT("FAST_MIDDLE", M4VSS3GPP_TransitionBehaviour_FastMiddle)
371 };
372 
VIDEOEDIT_JAVA_DEFINE_CONSTANT_CLASS(TransitionBehaviour,TRANSITION_BEHAVIOUR_CLASS_NAME,M4OSA_NULL,M4OSA_NULL)373 VIDEOEDIT_JAVA_DEFINE_CONSTANT_CLASS(TransitionBehaviour, TRANSITION_BEHAVIOUR_CLASS_NAME,
374  M4OSA_NULL, M4OSA_NULL)
375 
376 
377 VIDEOEDIT_JAVA_DEFINE_CONSTANTS(VideoEffect)
378 {
379     VIDEOEDIT_JAVA_CONSTANT_INIT("NONE",            M4VSS3GPP_kVideoEffectType_None),
380     VIDEOEDIT_JAVA_CONSTANT_INIT("FADE_FROM_BLACK", M4VSS3GPP_kVideoEffectType_FadeFromBlack),
381     VIDEOEDIT_JAVA_CONSTANT_INIT("FADE_TO_BLACK",   M4VSS3GPP_kVideoEffectType_FadeToBlack),
382     VIDEOEDIT_JAVA_CONSTANT_INIT("EXTERNAL",        M4VSS3GPP_kVideoEffectType_External),
383     VIDEOEDIT_JAVA_CONSTANT_INIT("BLACK_AND_WHITE", M4xVSS_kVideoEffectType_BlackAndWhite),
384     VIDEOEDIT_JAVA_CONSTANT_INIT("PINK",            M4xVSS_kVideoEffectType_Pink),
385     VIDEOEDIT_JAVA_CONSTANT_INIT("GREEN",           M4xVSS_kVideoEffectType_Green),
386     VIDEOEDIT_JAVA_CONSTANT_INIT("SEPIA",           M4xVSS_kVideoEffectType_Sepia),
387     VIDEOEDIT_JAVA_CONSTANT_INIT("NEGATIVE",        M4xVSS_kVideoEffectType_Negative),
388     VIDEOEDIT_JAVA_CONSTANT_INIT("FRAMING",         M4xVSS_kVideoEffectType_Framing),
389     VIDEOEDIT_JAVA_CONSTANT_INIT("TEXT",            M4xVSS_kVideoEffectType_Text),
390     VIDEOEDIT_JAVA_CONSTANT_INIT("ZOOM_IN",         M4xVSS_kVideoEffectType_ZoomIn),
391     VIDEOEDIT_JAVA_CONSTANT_INIT("ZOOM_OUT",        M4xVSS_kVideoEffectType_ZoomOut),
392     VIDEOEDIT_JAVA_CONSTANT_INIT("FIFTIES",         M4xVSS_kVideoEffectType_Fifties),
393     VIDEOEDIT_JAVA_CONSTANT_INIT("COLORRGB16",      M4xVSS_kVideoEffectType_ColorRGB16),
394     VIDEOEDIT_JAVA_CONSTANT_INIT("GRADIENT",        M4xVSS_kVideoEffectType_Gradient),
395 };
396 
VIDEOEDIT_JAVA_DEFINE_CONSTANT_CLASS(VideoEffect,VIDEO_EFFECT_CLASS_NAME,M4OSA_NULL,M4OSA_NULL)397 VIDEOEDIT_JAVA_DEFINE_CONSTANT_CLASS(VideoEffect, VIDEO_EFFECT_CLASS_NAME, M4OSA_NULL, M4OSA_NULL)
398 
399 
400 VIDEOEDIT_JAVA_DEFINE_CONSTANTS(VideoFormat)
401 {
402     VIDEOEDIT_JAVA_CONSTANT_INIT("NO_VIDEO",    M4VIDEOEDITING_kNoneVideo),
403     VIDEOEDIT_JAVA_CONSTANT_INIT("H263",        M4VIDEOEDITING_kH263),
404     VIDEOEDIT_JAVA_CONSTANT_INIT("MPEG4",       M4VIDEOEDITING_kMPEG4),
405     VIDEOEDIT_JAVA_CONSTANT_INIT("H264",        M4VIDEOEDITING_kH264),
406     VIDEOEDIT_JAVA_CONSTANT_INIT("NULL_VIDEO",  M4VIDEOEDITING_kNullVideo),
407     VIDEOEDIT_JAVA_CONSTANT_INIT("UNSUPPORTED", M4VIDEOEDITING_kUnsupportedVideo),
408 };
409 
VIDEOEDIT_JAVA_DEFINE_CONSTANT_CLASS(VideoFormat,VIDEO_FORMAT_CLASS_NAME,M4OSA_NULL,M4OSA_NULL)410 VIDEOEDIT_JAVA_DEFINE_CONSTANT_CLASS(VideoFormat, VIDEO_FORMAT_CLASS_NAME, M4OSA_NULL, M4OSA_NULL)
411 
412 
413 VIDEOEDIT_JAVA_DEFINE_CONSTANTS(VideoFrameRate)
414 {
415     VIDEOEDIT_JAVA_CONSTANT_INIT("FR_5_FPS",    M4VIDEOEDITING_k5_FPS),
416     VIDEOEDIT_JAVA_CONSTANT_INIT("FR_7_5_FPS",  M4VIDEOEDITING_k7_5_FPS),
417     VIDEOEDIT_JAVA_CONSTANT_INIT("FR_10_FPS",   M4VIDEOEDITING_k10_FPS),
418     VIDEOEDIT_JAVA_CONSTANT_INIT("FR_12_5_FPS", M4VIDEOEDITING_k12_5_FPS),
419     VIDEOEDIT_JAVA_CONSTANT_INIT("FR_15_FPS",   M4VIDEOEDITING_k15_FPS),
420     VIDEOEDIT_JAVA_CONSTANT_INIT("FR_20_FPS",   M4VIDEOEDITING_k20_FPS),
421     VIDEOEDIT_JAVA_CONSTANT_INIT("FR_25_FPS",   M4VIDEOEDITING_k25_FPS),
422     VIDEOEDIT_JAVA_CONSTANT_INIT("FR_30_FPS",   M4VIDEOEDITING_k30_FPS)
423 };
424 
VIDEOEDIT_JAVA_DEFINE_CONSTANT_CLASS(VideoFrameRate,VIDEO_FRAME_RATE_CLASS_NAME,M4OSA_NULL,M4OSA_NULL)425 VIDEOEDIT_JAVA_DEFINE_CONSTANT_CLASS(VideoFrameRate, VIDEO_FRAME_RATE_CLASS_NAME,
426  M4OSA_NULL, M4OSA_NULL)
427 
428 
429 VIDEOEDIT_JAVA_DEFINE_CONSTANTS(VideoFrameSize)
430 {
431     VIDEOEDIT_JAVA_CONSTANT_INIT("SQCIF", M4VIDEOEDITING_kSQCIF),
432     VIDEOEDIT_JAVA_CONSTANT_INIT("QQVGA", M4VIDEOEDITING_kQQVGA),
433     VIDEOEDIT_JAVA_CONSTANT_INIT("QCIF",  M4VIDEOEDITING_kQCIF),
434     VIDEOEDIT_JAVA_CONSTANT_INIT("QVGA",  M4VIDEOEDITING_kQVGA),
435     VIDEOEDIT_JAVA_CONSTANT_INIT("CIF",   M4VIDEOEDITING_kCIF),
436     VIDEOEDIT_JAVA_CONSTANT_INIT("VGA",   M4VIDEOEDITING_kVGA),
437     VIDEOEDIT_JAVA_CONSTANT_INIT("WVGA", M4VIDEOEDITING_kWVGA),
438     VIDEOEDIT_JAVA_CONSTANT_INIT("NTSC", M4VIDEOEDITING_kNTSC),
439     VIDEOEDIT_JAVA_CONSTANT_INIT("nHD", M4VIDEOEDITING_k640_360),
440     VIDEOEDIT_JAVA_CONSTANT_INIT("WVGA16x9", M4VIDEOEDITING_k854_480),
441     VIDEOEDIT_JAVA_CONSTANT_INIT("V720p", M4VIDEOEDITING_k1280_720),
442     VIDEOEDIT_JAVA_CONSTANT_INIT("W720p", M4VIDEOEDITING_k1080_720),
443     VIDEOEDIT_JAVA_CONSTANT_INIT("S720p", M4VIDEOEDITING_k960_720),
444     VIDEOEDIT_JAVA_CONSTANT_INIT("V1080p", M4VIDEOEDITING_k1920_1080)
445 };
446 
VIDEOEDIT_JAVA_DEFINE_CONSTANT_CLASS(VideoFrameSize,VIDEO_FRAME_SIZE_CLASS_NAME,M4OSA_NULL,M4OSA_NULL)447 VIDEOEDIT_JAVA_DEFINE_CONSTANT_CLASS(VideoFrameSize, VIDEO_FRAME_SIZE_CLASS_NAME,
448  M4OSA_NULL, M4OSA_NULL)
449 
450 VIDEOEDIT_JAVA_DEFINE_CONSTANTS(VideoTransition)
451 {
452     VIDEOEDIT_JAVA_CONSTANT_INIT("NONE",             M4VSS3GPP_kVideoTransitionType_None),
453     VIDEOEDIT_JAVA_CONSTANT_INIT("CROSS_FADE",       M4VSS3GPP_kVideoTransitionType_CrossFade),
454     VIDEOEDIT_JAVA_CONSTANT_INIT("EXTERNAL",         M4VSS3GPP_kVideoTransitionType_External),
455     VIDEOEDIT_JAVA_CONSTANT_INIT("ALPHA_MAGIC",      M4xVSS_kVideoTransitionType_AlphaMagic),
456     VIDEOEDIT_JAVA_CONSTANT_INIT("SLIDE_TRANSITION", M4xVSS_kVideoTransitionType_SlideTransition),
457     VIDEOEDIT_JAVA_CONSTANT_INIT("FADE_BLACK",       M4xVSS_kVideoTransitionType_FadeBlack)
458 };
459 
VIDEOEDIT_JAVA_DEFINE_CONSTANT_CLASS(VideoTransition,VIDEO_TRANSITION_CLASS_NAME,M4OSA_NULL,M4OSA_NULL)460 VIDEOEDIT_JAVA_DEFINE_CONSTANT_CLASS(VideoTransition, VIDEO_TRANSITION_CLASS_NAME,
461                                      M4OSA_NULL, M4OSA_NULL)
462 
463 
464 VIDEOEDIT_JAVA_DEFINE_FIELDS(AlphaMagic)
465 {
466     VIDEOEDIT_JAVA_FIELD_INIT("file",            "Ljava/lang/String;"),
467     VIDEOEDIT_JAVA_FIELD_INIT("blendingPercent", "I"                 ),
468     VIDEOEDIT_JAVA_FIELD_INIT("invertRotation",  "Z"                 ),
469     VIDEOEDIT_JAVA_FIELD_INIT("rgbWidth",  "I"                 ),
470     VIDEOEDIT_JAVA_FIELD_INIT("rgbHeight",  "I"                 )
471 };
472 
VIDEOEDIT_JAVA_DEFINE_FIELD_CLASS(AlphaMagic,ALPHA_MAGIC_SETTINGS_CLASS_NAME)473 VIDEOEDIT_JAVA_DEFINE_FIELD_CLASS(AlphaMagic, ALPHA_MAGIC_SETTINGS_CLASS_NAME)
474 
475 VIDEOEDIT_JAVA_DEFINE_FIELDS(Properties)
476 {
477     VIDEOEDIT_JAVA_FIELD_INIT("duration",               "I"),
478     VIDEOEDIT_JAVA_FIELD_INIT("fileType",               "I"),
479     VIDEOEDIT_JAVA_FIELD_INIT("videoFormat",            "I"),
480     VIDEOEDIT_JAVA_FIELD_INIT("videoDuration",          "I"),
481     VIDEOEDIT_JAVA_FIELD_INIT("videoBitrate",           "I"),
482     VIDEOEDIT_JAVA_FIELD_INIT("width",                  "I"),
483     VIDEOEDIT_JAVA_FIELD_INIT("height",                 "I"),
484     VIDEOEDIT_JAVA_FIELD_INIT("averageFrameRate",       "F"),
485     VIDEOEDIT_JAVA_FIELD_INIT("profile",                "I"),
486     VIDEOEDIT_JAVA_FIELD_INIT("level",                  "I"),
487     VIDEOEDIT_JAVA_FIELD_INIT("profileSupported",       "Z"),
488     VIDEOEDIT_JAVA_FIELD_INIT("levelSupported",         "Z"),
489     VIDEOEDIT_JAVA_FIELD_INIT("audioFormat",            "I"),
490     VIDEOEDIT_JAVA_FIELD_INIT("audioDuration",          "I"),
491     VIDEOEDIT_JAVA_FIELD_INIT("audioBitrate",           "I"),
492     VIDEOEDIT_JAVA_FIELD_INIT("audioChannels",          "I"),
493     VIDEOEDIT_JAVA_FIELD_INIT("audioSamplingFrequency", "I"),
494     VIDEOEDIT_JAVA_FIELD_INIT("videoRotation",          "I")
495 };
496 
VIDEOEDIT_JAVA_DEFINE_FIELD_CLASS(Properties,PROPERTIES_CLASS_NAME)497 VIDEOEDIT_JAVA_DEFINE_FIELD_CLASS(Properties, PROPERTIES_CLASS_NAME)
498 
499 VIDEOEDIT_JAVA_DEFINE_FIELDS(BackgroundMusic)
500 {
501     VIDEOEDIT_JAVA_FIELD_INIT("file",          "Ljava/lang/String;"),
502     VIDEOEDIT_JAVA_FIELD_INIT("fileType",      "I"                 ),
503     VIDEOEDIT_JAVA_FIELD_INIT("insertionTime", "J"                 ),
504     VIDEOEDIT_JAVA_FIELD_INIT("volumePercent", "I"                 ),
505     VIDEOEDIT_JAVA_FIELD_INIT("beginLoop",     "J"                 ),
506     VIDEOEDIT_JAVA_FIELD_INIT("endLoop",       "J"                 ),
507     VIDEOEDIT_JAVA_FIELD_INIT("enableDucking",   "Z"               ),
508     VIDEOEDIT_JAVA_FIELD_INIT("duckingThreshold","I"               ),
509     VIDEOEDIT_JAVA_FIELD_INIT("lowVolume",         "I"             ),
510     VIDEOEDIT_JAVA_FIELD_INIT("isLooping",         "Z"             )
511 };
512 
VIDEOEDIT_JAVA_DEFINE_FIELD_CLASS(BackgroundMusic,BACKGROUND_MUSIC_SETTINGS_CLASS_NAME)513 VIDEOEDIT_JAVA_DEFINE_FIELD_CLASS(BackgroundMusic, BACKGROUND_MUSIC_SETTINGS_CLASS_NAME)
514 
515 /*
516 VIDEOEDIT_JAVA_DEFINE_FIELDS(BestEditSettings)
517 {
518     VIDEOEDIT_JAVA_FIELD_INIT("videoFormat",    "I"),
519     VIDEOEDIT_JAVA_FIELD_INIT("videoFrameSize", "I"),
520     VIDEOEDIT_JAVA_FIELD_INIT("audioFormat",    "I"),
521     VIDEOEDIT_JAVA_FIELD_INIT("audioChannels",  "I")
522 };
523 
524 VIDEOEDIT_JAVA_DEFINE_FIELD_CLASS(BestEditSettings, BEST_EDIT_SETTINGS_CLASS_NAME)
525 */
526 
527 VIDEOEDIT_JAVA_DEFINE_FIELDS(ClipSettings)
528 {
529     VIDEOEDIT_JAVA_FIELD_INIT("clipPath",             "Ljava/lang/String;"),
530     VIDEOEDIT_JAVA_FIELD_INIT("fileType",             "I"                 ),
531     VIDEOEDIT_JAVA_FIELD_INIT("beginCutTime",         "I"                 ),
532     VIDEOEDIT_JAVA_FIELD_INIT("endCutTime",           "I"                 ),
533     VIDEOEDIT_JAVA_FIELD_INIT("beginCutPercent",      "I"                 ),
534     VIDEOEDIT_JAVA_FIELD_INIT("endCutPercent",        "I"                 ),
535     VIDEOEDIT_JAVA_FIELD_INIT("panZoomEnabled",       "Z"                 ),
536     VIDEOEDIT_JAVA_FIELD_INIT("panZoomPercentStart",  "I"                 ),
537     VIDEOEDIT_JAVA_FIELD_INIT("panZoomTopLeftXStart", "I"                 ),
538     VIDEOEDIT_JAVA_FIELD_INIT("panZoomTopLeftYStart", "I"                 ),
539     VIDEOEDIT_JAVA_FIELD_INIT("panZoomPercentEnd",    "I"                 ),
540     VIDEOEDIT_JAVA_FIELD_INIT("panZoomTopLeftXEnd",   "I"                 ),
541     VIDEOEDIT_JAVA_FIELD_INIT("panZoomTopLeftYEnd",   "I"                 ),
542     VIDEOEDIT_JAVA_FIELD_INIT("mediaRendering",       "I"                 ),
543     VIDEOEDIT_JAVA_FIELD_INIT("rgbWidth",           "I"                 ),
544     VIDEOEDIT_JAVA_FIELD_INIT("rgbHeight",          "I"                 ),
545     VIDEOEDIT_JAVA_FIELD_INIT("rotationDegree",     "I"                 )
546 };
547 
VIDEOEDIT_JAVA_DEFINE_FIELD_CLASS(ClipSettings,CLIP_SETTINGS_CLASS_NAME)548 VIDEOEDIT_JAVA_DEFINE_FIELD_CLASS(ClipSettings, CLIP_SETTINGS_CLASS_NAME)
549 
550 
551 VIDEOEDIT_JAVA_DEFINE_FIELDS(EditSettings)
552 {
553     VIDEOEDIT_JAVA_FIELD_INIT("clipSettingsArray",       "[L"CLIP_SETTINGS_CLASS_NAME";"         ),
554     VIDEOEDIT_JAVA_FIELD_INIT("transitionSettingsArray", "[L"TRANSITION_SETTINGS_CLASS_NAME";"   ),
555     VIDEOEDIT_JAVA_FIELD_INIT("effectSettingsArray",     "[L"EFFECT_SETTINGS_CLASS_NAME";"       ),
556     VIDEOEDIT_JAVA_FIELD_INIT("videoFrameRate",          "I"                                     ),
557     VIDEOEDIT_JAVA_FIELD_INIT("outputFile",              "Ljava/lang/String;"                    ),
558     VIDEOEDIT_JAVA_FIELD_INIT("videoFrameSize",          "I"                                     ),
559     VIDEOEDIT_JAVA_FIELD_INIT("videoFormat",             "I"                                     ),
560     VIDEOEDIT_JAVA_FIELD_INIT("videoProfile",            "I"                                     ),
561     VIDEOEDIT_JAVA_FIELD_INIT("videoLevel",              "I"                                     ),
562     VIDEOEDIT_JAVA_FIELD_INIT("audioFormat",             "I"                                     ),
563     VIDEOEDIT_JAVA_FIELD_INIT("audioSamplingFreq",       "I"                                     ),
564     VIDEOEDIT_JAVA_FIELD_INIT("maxFileSize",             "I"                                     ),
565     VIDEOEDIT_JAVA_FIELD_INIT("audioChannels",           "I"                                     ),
566     VIDEOEDIT_JAVA_FIELD_INIT("videoBitrate",            "I"                                     ),
567     VIDEOEDIT_JAVA_FIELD_INIT("audioBitrate",            "I"                                     ),
568     VIDEOEDIT_JAVA_FIELD_INIT("backgroundMusicSettings",\
569     "L"BACKGROUND_MUSIC_SETTINGS_CLASS_NAME";"),
570     VIDEOEDIT_JAVA_FIELD_INIT("primaryTrackVolume",            "I"                               )
571 };
572 
VIDEOEDIT_JAVA_DEFINE_FIELD_CLASS(EditSettings,EDIT_SETTINGS_CLASS_NAME)573 VIDEOEDIT_JAVA_DEFINE_FIELD_CLASS(EditSettings, EDIT_SETTINGS_CLASS_NAME)
574 
575 
576 VIDEOEDIT_JAVA_DEFINE_FIELDS(EffectSettings)
577 {
578     VIDEOEDIT_JAVA_FIELD_INIT("startTime",                       "I"                 ),
579     VIDEOEDIT_JAVA_FIELD_INIT("duration",                        "I"                 ),
580     VIDEOEDIT_JAVA_FIELD_INIT("videoEffectType",                 "I"                 ),
581     VIDEOEDIT_JAVA_FIELD_INIT("audioEffectType",                 "I"                 ),
582     VIDEOEDIT_JAVA_FIELD_INIT("startPercent",                    "I"                 ),
583     VIDEOEDIT_JAVA_FIELD_INIT("durationPercent",                 "I"                 ),
584     VIDEOEDIT_JAVA_FIELD_INIT("framingFile",                     "Ljava/lang/String;"),
585     VIDEOEDIT_JAVA_FIELD_INIT("framingBuffer",                   "[I"                ),
586     VIDEOEDIT_JAVA_FIELD_INIT("bitmapType",                      "I"                 ),
587     VIDEOEDIT_JAVA_FIELD_INIT("width",                           "I"                 ),
588     VIDEOEDIT_JAVA_FIELD_INIT("height",                          "I"                 ),
589     VIDEOEDIT_JAVA_FIELD_INIT("topLeftX",                        "I"                 ),
590     VIDEOEDIT_JAVA_FIELD_INIT("topLeftY",                        "I"                 ),
591     VIDEOEDIT_JAVA_FIELD_INIT("framingResize",                   "Z"                 ),
592     VIDEOEDIT_JAVA_FIELD_INIT("framingScaledSize",               "I"                 ),
593     VIDEOEDIT_JAVA_FIELD_INIT("text",                            "Ljava/lang/String;"),
594     VIDEOEDIT_JAVA_FIELD_INIT("textRenderingData",               "Ljava/lang/String;"),
595     VIDEOEDIT_JAVA_FIELD_INIT("textBufferWidth",                 "I"                 ),
596     VIDEOEDIT_JAVA_FIELD_INIT("textBufferHeight",                "I"                 ),
597     VIDEOEDIT_JAVA_FIELD_INIT("fiftiesFrameRate",                "I"                 ),
598     VIDEOEDIT_JAVA_FIELD_INIT("rgb16InputColor",                 "I"                 ),
599     VIDEOEDIT_JAVA_FIELD_INIT("alphaBlendingStartPercent",       "I"                 ),
600     VIDEOEDIT_JAVA_FIELD_INIT("alphaBlendingMiddlePercent",      "I"                 ),
601     VIDEOEDIT_JAVA_FIELD_INIT("alphaBlendingEndPercent",         "I"                 ),
602     VIDEOEDIT_JAVA_FIELD_INIT("alphaBlendingFadeInTimePercent",  "I"                 ),
603     VIDEOEDIT_JAVA_FIELD_INIT("alphaBlendingFadeOutTimePercent", "I"                 )
604 };
605 
VIDEOEDIT_JAVA_DEFINE_FIELD_CLASS(EffectSettings,EFFECT_SETTINGS_CLASS_NAME)606 VIDEOEDIT_JAVA_DEFINE_FIELD_CLASS(EffectSettings, EFFECT_SETTINGS_CLASS_NAME)
607 
608 
609 VIDEOEDIT_JAVA_DEFINE_FIELDS(Engine)
610 {
611     VIDEOEDIT_JAVA_FIELD_INIT("mManualEditContext", "I")
612 };
613 
VIDEOEDIT_JAVA_DEFINE_FIELD_CLASS(Engine,MANUAL_EDIT_ENGINE_CLASS_NAME)614 VIDEOEDIT_JAVA_DEFINE_FIELD_CLASS(Engine, MANUAL_EDIT_ENGINE_CLASS_NAME)
615 
616 
617 VIDEOEDIT_JAVA_DEFINE_FIELDS(SlideTransitionSettings)
618 {
619     VIDEOEDIT_JAVA_FIELD_INIT("direction", "I")
620 };
621 
VIDEOEDIT_JAVA_DEFINE_FIELD_CLASS(SlideTransitionSettings,SLIDE_TRANSITION_SETTINGS_CLASS_NAME)622 VIDEOEDIT_JAVA_DEFINE_FIELD_CLASS(SlideTransitionSettings, SLIDE_TRANSITION_SETTINGS_CLASS_NAME)
623 
624 
625 VIDEOEDIT_JAVA_DEFINE_FIELDS(TransitionSettings)
626 {
627     VIDEOEDIT_JAVA_FIELD_INIT("duration",            "I"                                       ),
628     VIDEOEDIT_JAVA_FIELD_INIT("videoTransitionType", "I"                                       ),
629     VIDEOEDIT_JAVA_FIELD_INIT("audioTransitionType", "I"                                       ),
630     VIDEOEDIT_JAVA_FIELD_INIT("transitionBehaviour", "I"                                       ),
631     VIDEOEDIT_JAVA_FIELD_INIT("alphaSettings",       "L"ALPHA_MAGIC_SETTINGS_CLASS_NAME";"     ),
632     VIDEOEDIT_JAVA_FIELD_INIT("slideSettings",       "L"SLIDE_TRANSITION_SETTINGS_CLASS_NAME";")
633 };
634 
VIDEOEDIT_JAVA_DEFINE_FIELD_CLASS(TransitionSettings,TRANSITION_SETTINGS_CLASS_NAME)635 VIDEOEDIT_JAVA_DEFINE_FIELD_CLASS(TransitionSettings, TRANSITION_SETTINGS_CLASS_NAME)
636 
637 
638 VIDEOEDIT_JAVA_DEFINE_FIELDS(Version)
639 {
640     VIDEOEDIT_JAVA_FIELD_INIT("major",    "I"),
641     VIDEOEDIT_JAVA_FIELD_INIT("minor",    "I"),
642     VIDEOEDIT_JAVA_FIELD_INIT("revision", "I")
643 };
644 
VIDEOEDIT_JAVA_DEFINE_FIELD_CLASS(Version,VERSION_CLASS_NAME)645 VIDEOEDIT_JAVA_DEFINE_FIELD_CLASS(Version, VERSION_CLASS_NAME)
646 
647 
648 VIDEOEDIT_JAVA_DEFINE_METHODS(Engine)
649 {
650     VIDEOEDIT_JAVA_METHOD_INIT("onProgressUpdate", "(II)V")
651 };
652 
VIDEOEDIT_JAVA_DEFINE_METHOD_CLASS(Engine,MANUAL_EDIT_ENGINE_CLASS_NAME) const653 VIDEOEDIT_JAVA_DEFINE_METHOD_CLASS(Engine, MANUAL_EDIT_ENGINE_CLASS_NAME)
654 
655 
656 static const char*
657 videoEditClasses_getBrandString(M4OSA_UInt32 brand)
658 {
659     static char         brandString[11] = "0x00000000";
660            const char*  pBrandString    = M4OSA_NULL;
661            M4OSA_UInt8* pBrand          = (M4OSA_UInt8*)&brand;
662            M4OSA_UInt32 brandHost       = 0;
663 
664     // Convert the brand from big endian to host.
665     brandHost =  pBrand[0];
666     brandHost =  brandHost << 8;
667     brandHost += pBrand[1];
668     brandHost =  brandHost << 8;
669     brandHost += pBrand[2];
670     brandHost =  brandHost << 8;
671     brandHost += pBrand[3];
672 
673     switch (brandHost)
674     {
675     case M4VIDEOEDITING_BRAND_0000:
676         pBrandString = "0000";
677         break;
678     case M4VIDEOEDITING_BRAND_3G2A:
679         pBrandString = "3G2A";
680         break;
681     case M4VIDEOEDITING_BRAND_3GP4:
682         pBrandString = "3GP4";
683         break;
684     case M4VIDEOEDITING_BRAND_3GP5:
685         pBrandString = "3GP5";
686         break;
687     case M4VIDEOEDITING_BRAND_3GP6:
688         pBrandString = "3GP6";
689         break;
690     case M4VIDEOEDITING_BRAND_AVC1:
691         pBrandString = "AVC1";
692         break;
693     case M4VIDEOEDITING_BRAND_EMP:
694         pBrandString = "EMP";
695         break;
696     case M4VIDEOEDITING_BRAND_ISOM:
697         pBrandString = "ISOM";
698         break;
699     case M4VIDEOEDITING_BRAND_MP41:
700         pBrandString = "MP41";
701         break;
702     case M4VIDEOEDITING_BRAND_MP42:
703         pBrandString = "MP42";
704         break;
705     case M4VIDEOEDITING_BRAND_VFJ1:
706         pBrandString = "VFJ1";
707         break;
708     default:
709         M4OSA_chrSPrintf((M4OSA_Char *)brandString,
710                          sizeof(brandString) - 1,
711                          (M4OSA_Char*)"0x%08X", brandHost);
712         pBrandString = brandString;
713         break;
714     }
715 
716     // Return the brand string.
717     return(pBrandString);
718 }
719 
720 #ifdef VIDEOEDIT_LOGGING_ENABLED
721 static void
videoEditClasses_logFtypBox(M4VIDEOEDITING_FtypBox * pBox,int indentation)722 videoEditClasses_logFtypBox(
723                 M4VIDEOEDITING_FtypBox*             pBox,
724                 int                                 indentation)
725 {
726     // Check if memory was allocated for the FtypBox.
727     if (M4OSA_NULL != pBox)
728     {
729         VIDEOEDIT_LOG_SETTING(ANDROID_LOG_INFO, "VIDEO_EDITOR_CLASSES",
730                 "%*c major_brand:        %s",    indentation, ' ',
731                  videoEditClasses_getBrandString(pBox->major_brand));
732         VIDEOEDIT_LOG_SETTING(ANDROID_LOG_INFO, "VIDEO_EDITOR_CLASSES",
733                 "%*c minor_version:      %08X",  indentation, ' ',
734                 (unsigned int)pBox->minor_version);
735         VIDEOEDIT_LOG_SETTING(ANDROID_LOG_INFO, "VIDEO_EDITOR_CLASSES",
736                 "%*c nbCompatibleBrands: %u",    indentation, ' ',
737                 (unsigned int)pBox->nbCompatibleBrands);
738         VIDEOEDIT_LOG_SETTING(ANDROID_LOG_INFO, "VIDEO_EDITOR_CLASSES",
739                 "%*c compatible_brands:", indentation, ' ');
740                 indentation += VIDEOEDIT_LOG_INDENTATION;
741         for (int i = 0; (i < (int)pBox->nbCompatibleBrands) &&\
742          (i < M4VIDEOEDITING_MAX_COMPATIBLE_BRANDS); i++)
743         {
744             VIDEOEDIT_LOG_SETTING(ANDROID_LOG_INFO, "VIDEO_EDITOR_CLASSES",
745                     "%*c compatible_brand[%d]: %s",    indentation, ' ',
746                     i, videoEditClasses_getBrandString(pBox->compatible_brands[i]));
747         }
748         indentation -= VIDEOEDIT_LOG_INDENTATION;
749     }
750     else
751     {
752         VIDEOEDIT_LOG_SETTING(ANDROID_LOG_INFO, "VIDEO_EDITOR_CLASSES", "%*c <null>",
753                  indentation, ' ');
754     }
755 }
756 #endif
757 
758 
759 void
videoEditClasses_init(bool * pResult,JNIEnv * pEnv)760 videoEditClasses_init(
761                 bool*                               pResult,
762                 JNIEnv*                             pEnv)
763 {
764     // Check if the previous action succeeded.
765     if (*pResult)
766     {
767         // Log the function call.
768         VIDEOEDIT_LOG_FUNCTION(ANDROID_LOG_INFO, "VIDEO_EDITOR_CLASSES",\
769         "videoEditClasses_init()");
770 
771         // Initialize the constants.
772         videoEditJava_initAudioEffectConstants(pResult, pEnv);
773         videoEditJava_initAudioFormatConstants(pResult, pEnv);
774         videoEditJava_initAudioSamplingFrequencyConstants(pResult, pEnv);
775         videoEditJava_initAudioTransitionConstants(pResult, pEnv);
776         videoEditJava_initBitrateConstants(pResult, pEnv);
777         videoEditJava_initClipTypeConstants(pResult, pEnv);
778         videoEditJava_initEngineConstants(pResult, pEnv);
779         videoEditJava_initErrorConstants(pResult, pEnv);
780         videoEditJava_initFileTypeConstants(pResult, pEnv);
781         videoEditJava_initMediaRenderingConstants(pResult, pEnv);
782         videoEditJava_initSlideDirectionConstants(pResult, pEnv);
783         videoEditJava_initTransitionBehaviourConstants(pResult, pEnv);
784         videoEditJava_initVideoEffectConstants(pResult, pEnv);
785         videoEditJava_initVideoFormatConstants(pResult, pEnv);
786         videoEditJava_initVideoFrameRateConstants(pResult, pEnv);
787         videoEditJava_initVideoFrameSizeConstants(pResult, pEnv);
788         videoEditJava_initVideoTransitionConstants(pResult, pEnv);
789 
790         // Initialize the fields.
791         videoEditJava_initAlphaMagicFields(pResult, pEnv);
792         videoEditJava_initBackgroundMusicFields(pResult, pEnv);
793         videoEditJava_initClipSettingsFields(pResult, pEnv);
794         videoEditJava_initEditSettingsFields(pResult, pEnv);
795         videoEditJava_initEffectSettingsFields(pResult, pEnv);
796         videoEditJava_initEngineFields(pResult, pEnv);
797         videoEditJava_initSlideTransitionSettingsFields(pResult, pEnv);
798         videoEditJava_initTransitionSettingsFields(pResult, pEnv);
799         videoEditJava_initVersionFields(pResult, pEnv);
800         // Initialize the methods.
801         videoEditJava_initEngineMethods(pResult, pEnv);
802     }
803 }
804 
805 void
videoEditPropClass_init(bool * pResult,JNIEnv * pEnv)806 videoEditPropClass_init(
807                 bool*                               pResult,
808                 JNIEnv*                             pEnv)
809 {
810     // Check if the previous action succeeded.
811     if (*pResult)
812     {
813         // Log the function call.
814         VIDEOEDIT_LOG_FUNCTION(ANDROID_LOG_INFO, "VIDEO_EDITOR_PROP_CLASSES",\
815             "videoEditPropClass_init()");
816 
817         // Initialize the constants.
818         videoEditJava_initAudioFormatConstants(pResult, pEnv);
819         videoEditJava_initErrorConstants(pResult, pEnv);
820         videoEditJava_initFileTypeConstants(pResult, pEnv);
821         videoEditJava_initVideoFormatConstants(pResult, pEnv);
822 
823         // Initialize the fields.
824         videoEditJava_initPropertiesFields(pResult, pEnv);
825     }
826 }
827 
828 void
videoEditClasses_getAlphaMagicSettings(bool * pResult,JNIEnv * pEnv,jobject object,M4xVSS_AlphaMagicSettings ** ppSettings)829 videoEditClasses_getAlphaMagicSettings(
830                 bool*                               pResult,
831                 JNIEnv*                             pEnv,
832                 jobject                             object,
833                 M4xVSS_AlphaMagicSettings**         ppSettings)
834 {
835     VideoEditJava_AlphaMagicFieldIds fieldIds;
836     M4xVSS_AlphaMagicSettings* pSettings = M4OSA_NULL;
837     memset(&fieldIds, 0, sizeof(VideoEditJava_AlphaMagicFieldIds));
838 
839     // Check if the previous action succeeded.
840     if (*pResult)
841     {
842         // Log the function call.
843         VIDEOEDIT_LOG_FUNCTION(ANDROID_LOG_INFO, "VIDEO_EDITOR_CLASSES",
844                    "videoEditClasses_getAlphaMagicSettings()");
845 
846         // Retrieve the field ids.
847         videoEditJava_getAlphaMagicFieldIds(pResult, pEnv, &fieldIds);
848     }
849 
850     // Only validate the AlphaMagicSettings if the fields could be located.
851     if (*pResult)
852     {
853         // Check if the clip is set.
854         videoEditJava_checkAndThrowIllegalArgumentException(pResult, pEnv,
855                                                     (NULL == object),
856                                                     "alphaSettings is null");
857     }
858 
859     // Only retrieve the AlphaMagicSettings if the fields could be located and validated.
860     if (*pResult)
861     {
862         // Allocate memory for the AlphaMagicSettings.
863         pSettings = (M4xVSS_AlphaMagicSettings*)videoEditOsal_alloc(pResult, pEnv,
864                 sizeof(M4xVSS_AlphaMagicSettings), "AlphaMagicSettings");
865 
866         // Check if memory could be allocated for the AlphaMagicSettings.
867         if (*pResult)
868         {
869             // Set the alpha magic file path (JPG file).
870             pSettings->pAlphaFilePath = (M4OSA_Char*)videoEditJava_getString(pResult, pEnv, object,
871                     fieldIds.file, M4OSA_NULL);
872 
873             // Check if the alpha magic file path is valid.
874             videoEditJava_checkAndThrowIllegalArgumentException(pResult, pEnv,
875                     (M4OSA_NULL == pSettings->pAlphaFilePath), "alphaSettings.file is null");
876         }
877 
878         // Check if the alpha file path could be retrieved.
879         if (*pResult)
880         {
881             // Set the blending percentage between 0 and 100.
882             pSettings->blendingPercent = (M4OSA_UInt8)pEnv->GetIntField(object,
883                     fieldIds.blendingPercent);
884 
885             // Set the direct effect or reverse.
886             pSettings->isreverse = (M4OSA_Bool)pEnv->GetBooleanField(object,
887                     fieldIds.invertRotation);
888 
889             // Get the rgb width
890             pSettings->width = (M4OSA_UInt32) pEnv->GetIntField(object, fieldIds.rgbWidth );
891 
892             pSettings->height = (M4OSA_UInt32) pEnv->GetIntField(object, fieldIds.rgbHeight );
893 
894              VIDEOEDIT_LOG_FUNCTION(ANDROID_LOG_INFO, "VIDEO_EDITOR_CLASSES",
895                     "((((((((((path %s", pSettings->pAlphaFilePath);
896 
897             VIDEOEDIT_LOG_FUNCTION(ANDROID_LOG_INFO, "VIDEO_EDITOR_CLASSES",
898                     "------- getAlphaMagicSettings width %d", pEnv->GetIntField(object,
899                     fieldIds.rgbWidth ));
900             VIDEOEDIT_LOG_FUNCTION(ANDROID_LOG_INFO, "VIDEO_EDITOR_CLASSES",
901                    "-------- getAlphaMagicSettings Height %d",
902                    pEnv->GetIntField(object, fieldIds.rgbHeight ));
903         }
904 
905         // Check if settings could be set.
906         if (*pResult)
907         {
908             // Return the settings.
909             (*ppSettings) = pSettings;
910         }
911         else
912         {
913             // Free the settings.
914             videoEditClasses_freeAlphaMagicSettings(&pSettings);
915         }
916     }
917 }
918 
919 void
videoEditClasses_freeAlphaMagicSettings(M4xVSS_AlphaMagicSettings ** ppSettings)920 videoEditClasses_freeAlphaMagicSettings(
921                 M4xVSS_AlphaMagicSettings**         ppSettings)
922 {
923     // Check if memory was allocated for the AlphaMagicSettings.
924     if (M4OSA_NULL != (*ppSettings))
925     {
926         // Log the function call.
927         VIDEOEDIT_LOG_FUNCTION(ANDROID_LOG_INFO, "VIDEO_EDITOR_CLASSES",
928                   "videoEditClasses_freeAlphaMagicSettings()");
929 
930         // Free the alpha file path.
931         videoEditOsal_free((*ppSettings)->pAlphaFilePath);
932         (*ppSettings)->pAlphaFilePath = M4OSA_NULL;
933 
934         // Free the settings structure.
935         videoEditOsal_free((*ppSettings));
936         (*ppSettings) = M4OSA_NULL;
937     }
938 }
939 
940 #ifdef VIDEOEDIT_LOGGING_ENABLED
941 void
videoEditClasses_logAlphaMagicSettings(M4xVSS_AlphaMagicSettings * pSettings,int indentation)942 videoEditClasses_logAlphaMagicSettings(
943                 M4xVSS_AlphaMagicSettings*          pSettings,
944                 int                                 indentation)
945 {
946     // Check if memory was allocated for the AlphaMagicSettings.
947     if (M4OSA_NULL != pSettings)
948     {
949         VIDEOEDIT_LOG_SETTING(ANDROID_LOG_INFO, "VIDEO_EDITOR_CLASSES",
950              "%*c pAlphaFilePath:  %s",    indentation, ' ',
951             (M4OSA_NULL != pSettings->pAlphaFilePath) ? \
952             (char *)pSettings->pAlphaFilePath : "<null>");
953         VIDEOEDIT_LOG_SETTING(ANDROID_LOG_INFO, "VIDEO_EDITOR_CLASSES",
954              "%*c blendingPercent: %u %%", indentation, ' ',
955             (unsigned int)pSettings->blendingPercent);
956         VIDEOEDIT_LOG_SETTING(ANDROID_LOG_INFO, "VIDEO_EDITOR_CLASSES",
957             "%*c isreverse:       %s",    indentation, ' ',
958             pSettings->isreverse ? "true" : "false");
959     }
960     else
961     {
962         VIDEOEDIT_LOG_SETTING(ANDROID_LOG_INFO, "VIDEO_EDITOR_CLASSES",
963             "%*c <null>", indentation, ' ');
964     }
965 }
966 #endif
967 
968 
969 void
videoEditClasses_getBackgroundMusicSettings(bool * pResult,JNIEnv * pEnv,jobject object,M4xVSS_BGMSettings ** ppSettings)970 videoEditClasses_getBackgroundMusicSettings(
971                 bool*                               pResult,
972                 JNIEnv*                             pEnv,
973                 jobject                             object,
974                 M4xVSS_BGMSettings**                ppSettings)
975 {
976     VideoEditJava_BackgroundMusicFieldIds fieldIds;
977     M4xVSS_BGMSettings*           pSettings = M4OSA_NULL;
978     bool                          converted = true;
979     memset(&fieldIds, 0, sizeof(VideoEditJava_BackgroundMusicFieldIds));
980     // Check if the previous action succeeded.
981     if (*pResult)
982     {
983         // Log the function call.
984         VIDEOEDIT_LOG_FUNCTION(ANDROID_LOG_INFO, "VIDEO_EDITOR_CLASSES",
985                "videoEditClasses_getBackgroundMusicSettings()");
986 
987         // Retrieve the field ids.
988         videoEditJava_getBackgroundMusicFieldIds(pResult, pEnv, &fieldIds);
989     }
990 
991     // Only retrieve the BackgroundMusicSettings if the fields could be located.
992     if (*pResult)
993     {
994         // Check if the object is valid.
995         if (NULL != object)
996         {
997             // Allocate memory for the BackgroundMusicSettings.
998             pSettings = (M4xVSS_BGMSettings*)videoEditOsal_alloc(pResult, pEnv,
999                 sizeof(M4xVSS_BGMSettings), "BackgroundMusicSettings");
1000 
1001             // Check if memory could be allocated for the BackgroundMusicSettings.
1002             if (*pResult)
1003             {
1004                 // Set the input file path.
1005                 pSettings->pFile = (M4OSA_Char*)videoEditJava_getString(pResult, pEnv, object,
1006                         fieldIds.file, M4OSA_NULL);
1007 
1008                 // Check if the input file path is valid.
1009                 videoEditJava_checkAndThrowIllegalArgumentException(pResult, pEnv,
1010                         (M4OSA_NULL == pSettings->pFile), "backgroundMusicSettings.file is null");
1011             }
1012 
1013             // Check if the input file path could be retrieved.
1014             if (*pResult)
1015             {
1016                 // Set the file type .3gp, .amr, .mp3.
1017                 pSettings->FileType = M4VIDEOEDITING_kFileType_PCM;
1018                 /*(M4VIDEOEDITING_FileType)videoEditJava_getClipTypeJavaToC(
1019                  &converted, pEnv->GetIntField(object, fieldIds.fileType));*/
1020 
1021                 // Check if the file type is valid.
1022                 videoEditJava_checkAndThrowIllegalArgumentException(pResult, pEnv,
1023                         !converted, "backgroundMusicSettings.fileType is invalid");
1024             }
1025 
1026             // Check if the file type could be retrieved.
1027             if (*pResult)
1028             {
1029                 // Set the time, in milliseconds, at which the added audio track is inserted.
1030                 pSettings->uiAddCts = (M4OSA_UInt32)pEnv->GetLongField(object,
1031                         fieldIds.insertionTime);
1032 
1033                 // Set the volume, in percentage (0..100), of the added audio track.
1034                 pSettings->uiAddVolume = (M4OSA_UInt32)pEnv->GetIntField(object,
1035                         fieldIds.volumePercent);
1036 
1037                 // Set the start time of the loop in milli seconds.
1038                 pSettings->uiBeginLoop = (M4OSA_UInt32)pEnv->GetLongField(object,
1039                         fieldIds.beginLoop);
1040 
1041                 // Set the end time of the loop in milli seconds.
1042                 pSettings->uiEndLoop = (M4OSA_UInt32)pEnv->GetLongField(object,
1043                         fieldIds.endLoop);
1044                 // Set the end time of the loop in milli seconds.
1045                 pSettings->b_DuckingNeedeed =
1046                         (M4OSA_Bool)pEnv->GetBooleanField(object, fieldIds.enableDucking);
1047 
1048                 // Set the end time of the loop in milli seconds.
1049                 pSettings->InDucking_threshold =
1050                         (M4OSA_Int32)pEnv->GetIntField(object, fieldIds.duckingThreshold);
1051 
1052                 // Set the end time of the loop in milli seconds.
1053                 pSettings->lowVolume =
1054                         (M4OSA_Float)(((M4OSA_Float)pEnv->GetIntField(object, fieldIds.lowVolume)));
1055 
1056                 // Set the end time of the loop in milli seconds.
1057                 pSettings->bLoop = (M4OSA_Bool)pEnv->GetBooleanField(object, fieldIds.isLooping);
1058 
1059                 // Set sampling freq and channels
1060                 pSettings->uiSamplingFrequency = M4VIDEOEDITING_k32000_ASF;
1061                 pSettings->uiNumChannels = 2;
1062             }
1063 
1064             // Check if settings could be set.
1065             if (*pResult)
1066             {
1067                 // Return the settings.
1068                 (*ppSettings) = pSettings;
1069             }
1070             else
1071             {
1072                 // Free the settings.
1073                 videoEditClasses_freeBackgroundMusicSettings(&pSettings);
1074             }
1075         }
1076     }
1077 }
1078 
1079 void
videoEditClasses_freeBackgroundMusicSettings(M4xVSS_BGMSettings ** ppSettings)1080 videoEditClasses_freeBackgroundMusicSettings(
1081                 M4xVSS_BGMSettings**                ppSettings)
1082 {
1083     // Check if memory was allocated for the BackgroundMusicSettings.
1084     if (M4OSA_NULL != (*ppSettings))
1085     {
1086         // Log the function call.
1087         VIDEOEDIT_LOG_FUNCTION(ANDROID_LOG_INFO, "VIDEO_EDITOR_CLASSES",
1088          "videoEditClasses_freeBackgroundMusicSettings()");
1089 
1090         // Free the input file path.
1091         videoEditOsal_free((*ppSettings)->pFile);
1092         (*ppSettings)->pFile = M4OSA_NULL;
1093 
1094         // Free the settings structure.
1095         videoEditOsal_free((*ppSettings));
1096         (*ppSettings) = M4OSA_NULL;
1097     }
1098 }
1099 
1100 #ifdef VIDEOEDIT_LOGGING_ENABLED
1101 void
videoEditClasses_logBackgroundMusicSettings(M4xVSS_BGMSettings * pSettings,int indentation)1102 videoEditClasses_logBackgroundMusicSettings(
1103                 M4xVSS_BGMSettings*                 pSettings,
1104                 int                                 indentation)
1105 {
1106     // Check if memory was allocated for the BackgroundMusicSettings.
1107     if (M4OSA_NULL != pSettings)
1108     {
1109         VIDEOEDIT_LOG_SETTING(ANDROID_LOG_INFO, "VIDEO_EDITOR_CLASSES", "%*c pFile:       %s",
1110             indentation, ' ',
1111             (M4OSA_NULL != pSettings->pFile) ? (char *)pSettings->pFile : "<null>");
1112         VIDEOEDIT_LOG_SETTING(ANDROID_LOG_INFO, "VIDEO_EDITOR_CLASSES",
1113             "%*c FileType:    %s",    indentation, ' ',
1114             videoEditJava_getClipTypeString(pSettings->FileType));
1115 
1116         VIDEOEDIT_LOG_SETTING(ANDROID_LOG_INFO, "VIDEO_EDITOR_CLASSES", "%*c uiAddCts:    %u ms",
1117             indentation, ' ', (unsigned int)pSettings->uiAddCts);
1118         VIDEOEDIT_LOG_SETTING(ANDROID_LOG_INFO, "VIDEO_EDITOR_CLASSES", "%*c uiAddVolume: %u %%",
1119             indentation, ' ', (unsigned int)pSettings->uiAddVolume);
1120         VIDEOEDIT_LOG_SETTING(ANDROID_LOG_INFO, "VIDEO_EDITOR_CLASSES", "%*c uiBeginLoop: %u ms",
1121             indentation, ' ', (unsigned int)pSettings->uiBeginLoop);
1122         VIDEOEDIT_LOG_SETTING(ANDROID_LOG_INFO, "VIDEO_EDITOR_CLASSES", "%*c uiEndLoop:   %u ms",
1123             indentation, ' ', (unsigned int)pSettings->uiEndLoop);
1124         VIDEOEDIT_LOG_SETTING(ANDROID_LOG_INFO, "VIDEO_EDITOR_CLASSES", "%*c b_DuckingNeedeed:\
1125             %u ", indentation, ' ', (bool)pSettings->b_DuckingNeedeed);
1126         VIDEOEDIT_LOG_SETTING(ANDROID_LOG_INFO, "VIDEO_EDITOR_CLASSES", "%*c InDucking_threshold: \
1127             %u ms", indentation, ' ', (unsigned int)pSettings->InDucking_threshold);
1128         VIDEOEDIT_LOG_SETTING(ANDROID_LOG_INFO, "VIDEO_EDITOR_CLASSES", "%*c lowVolume:   %2.2f ",\
1129             indentation, ' ', (float)pSettings->lowVolume);
1130         VIDEOEDIT_LOG_SETTING(ANDROID_LOG_INFO, "VIDEO_EDITOR_CLASSES", "%*c bLoop:   %u ms",\
1131             indentation, ' ', (bool)pSettings->bLoop);
1132     }
1133     else
1134     {
1135         VIDEOEDIT_LOG_SETTING(ANDROID_LOG_INFO, "VIDEO_EDITOR_CLASSES", "%*c <null>",
1136             indentation, ' ');
1137     }
1138 }
1139 #endif
1140 
1141 #ifdef VIDEOEDIT_LOGGING_ENABLED
1142 void
videoEditClasses_logClipProperties(M4VIDEOEDITING_ClipProperties * pProperties,int indentation)1143 videoEditClasses_logClipProperties(
1144                 M4VIDEOEDITING_ClipProperties*      pProperties,
1145                 int                                 indentation)
1146 {
1147     // Check if memory was allocated for the ClipProperties.
1148     if (M4OSA_NULL != pProperties)
1149     {
1150         VIDEOEDIT_LOG_SETTING(ANDROID_LOG_INFO, "VIDEO_EDITOR_CLASSES",
1151             "%*c bAnalysed:                        %s",       indentation, ' ',
1152             pProperties->bAnalysed ? "true" : "false");
1153         VIDEOEDIT_LOG_SETTING(ANDROID_LOG_INFO, "VIDEO_EDITOR_CLASSES",
1154             "%*c Version:                          %d.%d.%d", indentation, ' ',
1155             pProperties->Version[0], pProperties->Version[1], pProperties->Version[2]);
1156         VIDEOEDIT_LOG_SETTING(ANDROID_LOG_INFO, "VIDEO_EDITOR_CLASSES",
1157             "%*c uiClipDuration:                   %u",       indentation, ' ',
1158             (unsigned int)pProperties->uiClipDuration);
1159         VIDEOEDIT_LOG_SETTING(ANDROID_LOG_INFO, "VIDEO_EDITOR_CLASSES",
1160             "%*c FileType:                         %s",       indentation, ' ',
1161             videoEditJava_getClipTypeString(pProperties->FileType));
1162         VIDEOEDIT_LOG_SETTING(ANDROID_LOG_INFO, "VIDEO_EDITOR_CLASSES", "%*c ftyp:",
1163                                               indentation, ' ');
1164         videoEditClasses_logFtypBox(&pProperties->ftyp, indentation + VIDEOEDIT_LOG_INDENTATION);
1165 
1166         VIDEOEDIT_LOG_SETTING(ANDROID_LOG_INFO, "VIDEO_EDITOR_CLASSES",
1167             "%*c VideoStreamType:                  %s",       indentation, ' ',
1168             videoEditJava_getVideoFormatString(pProperties->VideoStreamType));
1169         VIDEOEDIT_LOG_SETTING(ANDROID_LOG_INFO, "VIDEO_EDITOR_CLASSES",
1170             "%*c uiClipVideoDuration:              %u",       indentation, ' ',
1171             (unsigned int)pProperties->uiClipVideoDuration);
1172         VIDEOEDIT_LOG_SETTING(ANDROID_LOG_INFO, "VIDEO_EDITOR_CLASSES",
1173             "%*c uiVideoBitrate:                   %s",       indentation, ' ',
1174             videoEditJava_getBitrateString(pProperties->uiVideoBitrate));
1175         VIDEOEDIT_LOG_SETTING(ANDROID_LOG_INFO, "VIDEO_EDITOR_CLASSES",
1176             "%*c uiVideoMaxAuSize:                 %u",       indentation, ' ',
1177             (unsigned int)pProperties->uiVideoMaxAuSize);
1178         VIDEOEDIT_LOG_SETTING(ANDROID_LOG_INFO, "VIDEO_EDITOR_CLASSES",
1179             "%*c uiVideoWidth:                     %u",       indentation, ' ',
1180             (unsigned int)pProperties->uiVideoWidth);
1181         VIDEOEDIT_LOG_SETTING(ANDROID_LOG_INFO, "VIDEO_EDITOR_CLASSES",
1182             "%*c uiVideoHeight:                    %u",       indentation, ' ',
1183             (unsigned int)(unsigned int)pProperties->uiVideoHeight);
1184         VIDEOEDIT_LOG_SETTING(ANDROID_LOG_INFO, "VIDEO_EDITOR_CLASSES",
1185             "%*c uiVideoTimeScale:                 %u",       indentation, ' ',
1186             (unsigned int)pProperties->uiVideoTimeScale);
1187         VIDEOEDIT_LOG_SETTING(ANDROID_LOG_INFO, "VIDEO_EDITOR_CLASSES",
1188             "%*c fAverageFrameRate:                %.3f",     indentation, ' ',
1189             pProperties->fAverageFrameRate);
1190         VIDEOEDIT_LOG_SETTING(ANDROID_LOG_INFO, "VIDEO_EDITOR_CLASSES",
1191             "%*c bMPEG4dataPartition:              %s",       indentation, ' ',
1192             pProperties->bMPEG4dataPartition ? "true" : "false");
1193         VIDEOEDIT_LOG_SETTING(ANDROID_LOG_INFO, "VIDEO_EDITOR_CLASSES",
1194             "%*c bMPEG4rvlc:                       %s",       indentation, ' ',
1195             pProperties->bMPEG4rvlc ? "true" : "false");
1196         VIDEOEDIT_LOG_SETTING(ANDROID_LOG_INFO, "VIDEO_EDITOR_CLASSES",
1197             "%*c bMPEG4resynchMarker:              %s",       indentation, ' ',
1198             pProperties->bMPEG4resynchMarker ? "true" : "false");
1199         VIDEOEDIT_LOG_SETTING(ANDROID_LOG_INFO, "VIDEO_EDITOR_CLASSES",
1200             "%*c AudioStreamType:                  %s",       indentation, ' ',
1201             videoEditJava_getAudioFormatString(pProperties->AudioStreamType));
1202         VIDEOEDIT_LOG_SETTING(ANDROID_LOG_INFO, "VIDEO_EDITOR_CLASSES",
1203             "%*c uiClipAudioDuration:              %u",       indentation, ' ',
1204             (unsigned int)pProperties->uiClipAudioDuration);
1205         VIDEOEDIT_LOG_SETTING(ANDROID_LOG_INFO, "VIDEO_EDITOR_CLASSES",
1206             "%*c uiAudioBitrate:                   %s",       indentation, ' ',
1207             videoEditJava_getBitrateString(pProperties->uiAudioBitrate));
1208         VIDEOEDIT_LOG_SETTING(ANDROID_LOG_INFO, "VIDEO_EDITOR_CLASSES",
1209             "%*c uiAudioMaxAuSize:                 %u",       indentation, ' ',
1210             (unsigned int)pProperties->uiAudioMaxAuSize);
1211         VIDEOEDIT_LOG_SETTING(ANDROID_LOG_INFO, "VIDEO_EDITOR_CLASSES",
1212             "%*c uiNbChannels:                     %u",       indentation, ' ',
1213             (unsigned int)pProperties->uiNbChannels);
1214         VIDEOEDIT_LOG_SETTING(ANDROID_LOG_INFO, "VIDEO_EDITOR_CLASSES",
1215             "%*c uiSamplingFrequency:              %u",       indentation, ' ',
1216             (unsigned int)pProperties->uiSamplingFrequency);
1217         VIDEOEDIT_LOG_SETTING(ANDROID_LOG_INFO, "VIDEO_EDITOR_CLASSES",
1218             "%*c uiExtendedSamplingFrequency:      %u",       indentation, ' ',
1219             (unsigned int)pProperties->uiExtendedSamplingFrequency);
1220         VIDEOEDIT_LOG_SETTING(ANDROID_LOG_INFO, "VIDEO_EDITOR_CLASSES",
1221             "%*c uiDecodedPcmSize:                 %u",       indentation, ' ',
1222             (unsigned int)pProperties->uiDecodedPcmSize);
1223         VIDEOEDIT_LOG_SETTING(ANDROID_LOG_INFO, "VIDEO_EDITOR_CLASSES",
1224             "%*c bVideoIsEditable:                 %s",       indentation, ' ',
1225             pProperties->bVideoIsEditable ? "true" : "false");
1226         VIDEOEDIT_LOG_SETTING(ANDROID_LOG_INFO, "VIDEO_EDITOR_CLASSES",
1227             "%*c bAudioIsEditable:                 %s",       indentation, ' ',
1228             pProperties->bAudioIsEditable ? "true" : "false");
1229         VIDEOEDIT_LOG_SETTING(ANDROID_LOG_INFO, "VIDEO_EDITOR_CLASSES",
1230             "%*c bVideoIsCompatibleWithMasterClip: %s",       indentation, ' ',
1231             pProperties->bVideoIsCompatibleWithMasterClip ? "true" : "false");
1232         VIDEOEDIT_LOG_SETTING(ANDROID_LOG_INFO, "VIDEO_EDITOR_CLASSES",
1233             "%*c bAudioIsCompatibleWithMasterClip: %s",       indentation, ' ',
1234             pProperties->bAudioIsCompatibleWithMasterClip ? "true" : "false");
1235         VIDEOEDIT_LOG_SETTING(ANDROID_LOG_INFO, "VIDEO_EDITOR_CLASSES",
1236             "%*c uiClipAudioVolumePercentage:      %d",       indentation, ' ',
1237                         pProperties->uiClipAudioVolumePercentage);
1238     }
1239     else
1240     {
1241         VIDEOEDIT_LOG_SETTING(ANDROID_LOG_INFO, "VIDEO_EDITOR_CLASSES", "%*c <null>",
1242             indentation, ' ');
1243     }
1244 }
1245 #endif
1246 
1247 void
videoEditClasses_getClipSettings(bool * pResult,JNIEnv * pEnv,jobject object,M4VSS3GPP_ClipSettings ** ppSettings)1248 videoEditClasses_getClipSettings(
1249                 bool*                               pResult,
1250                 JNIEnv*                             pEnv,
1251                 jobject                             object,
1252                 M4VSS3GPP_ClipSettings**            ppSettings)
1253 {
1254 
1255     VideoEditJava_ClipSettingsFieldIds fieldIds;
1256     M4VSS3GPP_ClipSettings*    pSettings = M4OSA_NULL;
1257     M4OSA_ERR                  result    = M4NO_ERROR;
1258     bool                       converted = true;
1259     memset(&fieldIds, 0, sizeof(VideoEditJava_ClipSettingsFieldIds));
1260     // Check if the previous action succeeded.
1261     if (*pResult)
1262     {
1263         // Log the function call.
1264         VIDEOEDIT_LOG_FUNCTION(ANDROID_LOG_INFO, "VIDEO_EDITOR_CLASSES",
1265             "videoEditClasses_getClipSettings()");
1266 
1267         // Retrieve the field ids.
1268         videoEditJava_getClipSettingsFieldIds(pResult, pEnv, &fieldIds);
1269     }
1270 
1271     // Only validate the ClipSettings if the fields could be located.
1272     if (*pResult)
1273     {
1274         // Check if the clip is set.
1275         videoEditJava_checkAndThrowIllegalArgumentException(pResult, pEnv,
1276                                                     (NULL == object),
1277                                                     "clip is null");
1278     }
1279 
1280     // Only retrieve the ClipSettings if the fields could be located and validated.
1281     if (*pResult)
1282     {
1283         // Allocate memory for the ClipSettings.
1284         pSettings = (M4VSS3GPP_ClipSettings *)videoEditOsal_alloc(pResult, pEnv,
1285             sizeof(M4VSS3GPP_ClipSettings), "ClipSettings");
1286 
1287         // Check if memory could be allocated for the ClipSettings.
1288         if (*pResult)
1289         {
1290             // Log the API call.
1291             VIDEOEDIT_LOG_API(ANDROID_LOG_INFO, "VIDEO_EDITOR", "M4xVSS_CreateClipSettings()");
1292 
1293             // Initialize the ClipSettings.
1294             result = M4xVSS_CreateClipSettings(pSettings, NULL, 0, 0);
1295 
1296             // Log the result.
1297             VIDEOEDIT_LOG_RESULT(ANDROID_LOG_INFO, "VIDEO_EDITOR",
1298                 videoEditOsal_getResultString(result));
1299 
1300             // Check if the initialization succeeded.
1301             videoEditJava_checkAndThrowRuntimeException(pResult, pEnv,
1302                 (M4NO_ERROR != result), result);
1303         }
1304 
1305         // Check if the allocation and initialization succeeded
1306         //(required because pSettings is dereferenced).
1307         if (*pResult)
1308         {
1309             // Set the input file path.
1310             pSettings->pFile = (M4OSA_Char*)videoEditJava_getString(pResult, pEnv, object,
1311                 fieldIds.clipPath, &pSettings->filePathSize);
1312 
1313             // Check if the file path is valid.
1314             videoEditJava_checkAndThrowIllegalArgumentException(pResult, pEnv,
1315                     (M4OSA_NULL == pSettings->pFile), "clip.clipPath is null");
1316         }
1317 
1318         // Check if the input file could be retrieved.
1319         if (*pResult)
1320         {
1321             // Set the file type .3gp, .amr, .mp3.
1322             pSettings->FileType = (M4VIDEOEDITING_FileType)videoEditJava_getClipTypeJavaToC(
1323                                         &converted, pEnv->GetIntField(object, fieldIds.fileType));
1324 
1325             if (( pSettings->FileType == M4VIDEOEDITING_kFileType_JPG) ||
1326                  ( pSettings->FileType == M4VIDEOEDITING_kFileType_PNG)) {
1327                  pSettings->FileType = M4VIDEOEDITING_kFileType_ARGB8888;
1328             }
1329 
1330             // Check if the file type is valid.
1331             videoEditJava_checkAndThrowIllegalArgumentException(pResult, pEnv,
1332                     !converted, "clip.fileType is invalid");
1333         }
1334 
1335         // Check if the file type could be retrieved.
1336         if (*pResult)
1337         {
1338             // Set the begin cut time, in milliseconds.
1339             pSettings->uiBeginCutTime =
1340                 (M4OSA_UInt32)pEnv->GetIntField(object, fieldIds.beginCutTime);
1341 
1342             // Set the end cut time, in milliseconds.
1343             pSettings->uiEndCutTime = (M4OSA_UInt32)pEnv->GetIntField(object, fieldIds.endCutTime);
1344 
1345             // Set the begin cut time, in percent of clip duration (only for 3GPP clip !).
1346             pSettings->xVSS.uiBeginCutPercent =
1347                 (M4OSA_UInt32)pEnv->GetIntField(object, fieldIds.beginCutPercent);
1348 
1349             // Set the end cut time, in percent of clip duration (only for 3GPP clip !).
1350             pSettings->xVSS.uiEndCutPercent =
1351                 (M4OSA_UInt32)pEnv->GetIntField(object, fieldIds.endCutPercent);
1352 
1353             // Set the duration of the clip, if different from 0,
1354             // has priority on uiEndCutTime or uiEndCutPercent.
1355             pSettings->xVSS.uiDuration = 0;
1356 
1357             // Set whether or not the pan and zoom mode is enabled.
1358             pSettings->xVSS.isPanZoom =
1359                 (M4OSA_Bool)pEnv->GetBooleanField(object, fieldIds.panZoomEnabled);
1360 
1361             // Set the pan and zoom start zoom percentage.
1362             pSettings->xVSS.PanZoomXa        =
1363                 (M4OSA_UInt16)pEnv->GetIntField(object, fieldIds.panZoomPercentStart);
1364 
1365             // Set the pan and zoom start x.
1366             pSettings->xVSS.PanZoomTopleftXa =
1367                 (M4OSA_UInt16)pEnv->GetIntField(object, fieldIds.panZoomTopLeftXStart);
1368 
1369             // Set the pan and zoom start y.
1370             pSettings->xVSS.PanZoomTopleftYa =
1371                 (M4OSA_UInt16)pEnv->GetIntField(object, fieldIds.panZoomTopLeftYStart);
1372 
1373             // Set the pan and zoom end zoom percentage.
1374             pSettings->xVSS.PanZoomXb        =
1375                 (M4OSA_UInt16)pEnv->GetIntField(object, fieldIds.panZoomPercentEnd);
1376 
1377             // Set the pan and zoom end x.
1378             pSettings->xVSS.PanZoomTopleftXb =
1379                 (M4OSA_UInt16)pEnv->GetIntField(object, fieldIds.panZoomTopLeftXEnd);
1380 
1381             // Set the pan and zoom end y.
1382             pSettings->xVSS.PanZoomTopleftYb =
1383                 (M4OSA_UInt16)pEnv->GetIntField(object, fieldIds.panZoomTopLeftYEnd);
1384 
1385             // Set the media rendering mode, only used with JPEG to crop, resize,
1386             // or render black borders.
1387             pSettings->xVSS.MediaRendering =
1388                 (M4xVSS_MediaRendering)videoEditJava_getMediaRenderingJavaToC(
1389                     &converted, pEnv->GetIntField(object,fieldIds.mediaRendering));
1390 
1391             // Check if the media rendering is valid.
1392             videoEditJava_checkAndThrowIllegalArgumentException(pResult, pEnv, !converted,
1393                 "clip.mediaRendering is invalid");
1394 
1395              // Capture the rgb file width and height
1396             pSettings->ClipProperties.uiStillPicWidth =
1397                 (M4OSA_UInt16)pEnv->GetIntField(object, fieldIds.rgbFileWidth);
1398             pSettings->ClipProperties.uiStillPicHeight  =
1399                 (M4OSA_UInt16)pEnv->GetIntField(object, fieldIds.rgbFileHeight);
1400 
1401             VIDEOEDIT_LOG_FUNCTION(ANDROID_LOG_INFO, "VIDEO_EDITOR", \
1402                 "getClipSettings-- rgbFileWidth %d ",
1403                 pSettings->ClipProperties.uiStillPicWidth);
1404             VIDEOEDIT_LOG_FUNCTION(ANDROID_LOG_INFO, "VIDEO_EDITOR", \
1405                 "getClipSettings-- rgbFileHeight %d ",
1406                 pSettings->ClipProperties.uiStillPicHeight);
1407 
1408             // Set the video rotation degree
1409             pSettings->ClipProperties.videoRotationDegrees =
1410                 (M4OSA_UInt32)pEnv->GetIntField(object, fieldIds.rotationDegree);
1411         }
1412 
1413         // Check if settings could be set.
1414         if (*pResult)
1415         {
1416             // Return the settings.
1417             (*ppSettings) = pSettings;
1418         }
1419         else
1420         {
1421             // Free the settings.
1422             videoEditClasses_freeClipSettings(&pSettings);
1423         }
1424     }
1425 }
1426 
1427 void
videoEditClasses_createClipSettings(bool * pResult,JNIEnv * pEnv,M4VSS3GPP_ClipSettings * pSettings,jobject * pObject)1428 videoEditClasses_createClipSettings(
1429                 bool*                               pResult,
1430                 JNIEnv*                             pEnv,
1431                 M4VSS3GPP_ClipSettings*             pSettings,
1432                 jobject*                            pObject)
1433 {
1434     VideoEditJava_ClipSettingsFieldIds fieldIds;
1435     jclass                     clazz    = NULL;
1436     jobject                    object   = NULL;
1437     memset(&fieldIds, 0, sizeof(VideoEditJava_ClipSettingsFieldIds));
1438 
1439     // Check if the previous action succeeded.
1440     if (*pResult)
1441     {
1442         // Log the function call.
1443         VIDEOEDIT_LOG_FUNCTION(ANDROID_LOG_INFO, "VIDEO_EDITOR_CLASSES",
1444             "videoEditClasses_createClipSettings()");
1445 
1446         // Retrieve the class.
1447         videoEditJava_getClipSettingsClass(pResult, pEnv, &clazz);
1448 
1449         // Retrieve the field ids.
1450         videoEditJava_getClipSettingsFieldIds(pResult, pEnv, &fieldIds);
1451     }
1452 
1453     // Only create an object if the class and fields could be located.
1454     if (*pResult)
1455     {
1456         // Allocate a new object.
1457         object = pEnv->AllocObject(clazz);
1458         if (NULL != object)
1459         {
1460             // Set the clipPath field.
1461             pEnv->SetObjectField(object, fieldIds.clipPath, NULL);
1462 
1463             // Set the fileType field.
1464             pEnv->SetIntField(object, fieldIds.fileType, videoEditJava_getClipTypeCToJava(
1465                                                                     pSettings->FileType));
1466 
1467             // Set the beginCutTime field.
1468             pEnv->SetIntField(object, fieldIds.beginCutTime, pSettings->uiBeginCutTime);
1469 
1470             // Set the endCutTime field.
1471             pEnv->SetIntField(object, fieldIds.endCutTime, pSettings->uiEndCutTime);
1472 
1473             // Set the beginCutPercent field.
1474             pEnv->SetIntField(object, fieldIds.beginCutPercent, pSettings->xVSS.uiBeginCutPercent);
1475 
1476             // Set the endCutPercent field.
1477             pEnv->SetIntField(object, fieldIds.endCutPercent, pSettings->xVSS.uiEndCutPercent);
1478 
1479             // Set the panZoomEnabled field.
1480             pEnv->SetBooleanField(object, fieldIds.panZoomEnabled, pSettings->xVSS.isPanZoom);
1481 
1482             // Set the panZoomPercentStart field.
1483             pEnv->SetIntField(object, fieldIds.panZoomPercentStart,
1484                 (1000 - pSettings->xVSS.PanZoomXa));
1485 
1486             // Set the panZoomTopLeftXStart field.
1487             pEnv->SetIntField(object, fieldIds.panZoomTopLeftXStart,
1488                 pSettings->xVSS.PanZoomTopleftXa);
1489 
1490             // Set the panZoomTopLeftYStart field.
1491             pEnv->SetIntField(object, fieldIds.panZoomTopLeftYStart,
1492                 pSettings->xVSS.PanZoomTopleftYa);
1493 
1494             // Set the panZoomPercentEnd field.
1495             pEnv->SetIntField(object, fieldIds.panZoomPercentEnd,
1496                 (1000 - pSettings->xVSS.PanZoomXb));
1497 
1498             // Set the panZoomTopLeftXEnd field.
1499             pEnv->SetIntField(object, fieldIds.panZoomTopLeftXEnd,
1500                 pSettings->xVSS.PanZoomTopleftXb);
1501 
1502             // Set the panZoomTopLeftYEnd field.
1503             pEnv->SetIntField(object, fieldIds.panZoomTopLeftYEnd,
1504                 pSettings->xVSS.PanZoomTopleftYb);
1505 
1506             // Set the mediaRendering field.
1507             pEnv->SetIntField(object, fieldIds.mediaRendering,
1508                 videoEditJava_getMediaRenderingCToJava(pSettings->xVSS.MediaRendering));
1509 
1510             // Set the rgb file width and height
1511             pEnv->SetIntField(object, fieldIds.rgbFileWidth,
1512                 pSettings->ClipProperties.uiStillPicWidth );
1513 
1514             pEnv->SetIntField(object, fieldIds.rgbFileHeight,
1515                 pSettings->ClipProperties.uiStillPicHeight );
1516 
1517             VIDEOEDIT_LOG_FUNCTION(ANDROID_LOG_INFO, "VIDEO_EDITOR_CLASSES",
1518                 "rgbFileWeight %d rgbFileHeight %d ",
1519                 pSettings->ClipProperties.uiStillPicWidth ,
1520                 pSettings->ClipProperties.uiStillPicHeight);
1521 
1522             // Set the video rotation
1523             pEnv->SetIntField(object, fieldIds.rotationDegree,
1524                 pSettings->ClipProperties.videoRotationDegrees);
1525 
1526             // Return the object.
1527             (*pObject) = object;
1528         }
1529     }
1530 }
1531 void
videoEditPropClass_createProperties(bool * pResult,JNIEnv * pEnv,VideoEditPropClass_Properties * pProperties,jobject * pObject)1532 videoEditPropClass_createProperties(
1533                 bool*                               pResult,
1534                 JNIEnv*                             pEnv,
1535                 VideoEditPropClass_Properties*      pProperties,
1536                 jobject*                            pObject)
1537 {
1538     VideoEditJava_PropertiesFieldIds fieldIds;
1539     jclass                   clazz    = NULL;
1540     jobject                  object   = NULL;
1541     memset(&fieldIds, 0, sizeof(VideoEditJava_PropertiesFieldIds));
1542     // Check if the previous action succeeded.
1543     if (*pResult)
1544     {
1545         // Log the function call.
1546         VIDEOEDIT_LOG_FUNCTION(ANDROID_LOG_INFO, "VIDEO_EDITOR_PROP_CLASSES",
1547                 "videoEditPropClass_createProperties()");
1548 
1549         // Retrieve the class.
1550         videoEditJava_getPropertiesClass(pResult, pEnv, &clazz);
1551 
1552         // Retrieve the field ids.
1553         videoEditJava_getPropertiesFieldIds(pResult, pEnv, &fieldIds);
1554     }
1555 
1556     // Only create an object if the class and fields could be located.
1557     if (*pResult)
1558     {
1559         // Allocate a new object.
1560         object = pEnv->AllocObject(clazz);
1561         if (NULL != object)
1562         {
1563             // Set the duration field.
1564             pEnv->SetIntField(object, fieldIds.duration, pProperties->uiClipDuration);
1565 
1566             // Set the fileType field.
1567             pEnv->SetIntField(object, fieldIds.fileType,
1568                 videoEditJava_getFileTypeCToJava(pProperties->FileType));
1569 
1570             // Set the videoFormat field.
1571             pEnv->SetIntField(object, fieldIds.videoFormat,
1572                 videoEditJava_getVideoFormatCToJava(pProperties->VideoStreamType));
1573 
1574             // Set the videoDuration field.
1575             pEnv->SetIntField(object, fieldIds.videoDuration, pProperties->uiClipVideoDuration);
1576 
1577             // Set the videoBitrate field.
1578             pEnv->SetIntField(object, fieldIds.videoBitrate, pProperties->uiVideoBitrate);
1579 
1580             // Set the width field.
1581             pEnv->SetIntField(object, fieldIds.width, pProperties->uiVideoWidth);
1582 
1583             // Set the height field.
1584             pEnv->SetIntField(object, fieldIds.height, pProperties->uiVideoHeight);
1585 
1586             // Set the averageFrameRate field.
1587             pEnv->SetFloatField(object, fieldIds.averageFrameRate, pProperties->fAverageFrameRate);
1588 
1589             // Set the profile field.
1590             pEnv->SetIntField(object, fieldIds.profile,
1591                 pProperties->uiVideoProfile);
1592 
1593             // Set the level field.
1594             pEnv->SetIntField(object, fieldIds.level,
1595                 pProperties->uiVideoLevel);
1596 
1597             // Set whether profile supported
1598             pEnv->SetBooleanField(object, fieldIds.profileSupported,
1599                 pProperties->bProfileSupported);
1600 
1601             // Set whether level supported
1602             pEnv->SetBooleanField(object, fieldIds.levelSupported,
1603                 pProperties->bLevelSupported);
1604 
1605             // Set the audioFormat field.
1606             pEnv->SetIntField(object, fieldIds.audioFormat,
1607                 videoEditJava_getAudioFormatCToJava(pProperties->AudioStreamType));
1608 
1609             // Set the audioDuration field.
1610             pEnv->SetIntField(object, fieldIds.audioDuration, pProperties->uiClipAudioDuration);
1611 
1612             // Set the audioBitrate field.
1613             pEnv->SetIntField(object, fieldIds.audioBitrate, pProperties->uiAudioBitrate);
1614 
1615             // Set the audioChannels field.
1616             pEnv->SetIntField(object, fieldIds.audioChannels, pProperties->uiNbChannels);
1617 
1618             // Set the audioSamplingFrequency field.
1619             pEnv->SetIntField(object, fieldIds.audioSamplingFrequency,
1620                 pProperties->uiSamplingFrequency);
1621 
1622             // Set the video rotation field.
1623             pEnv->SetIntField(object, fieldIds.videoRotation, pProperties->uiRotation);
1624 
1625             // Return the object.
1626             (*pObject) = object;
1627         }
1628     }
1629 }
1630 
1631 void
videoEditClasses_freeClipSettings(M4VSS3GPP_ClipSettings ** ppSettings)1632 videoEditClasses_freeClipSettings(
1633                 M4VSS3GPP_ClipSettings**            ppSettings)
1634 {
1635     // Check if memory was allocated for the ClipSettings.
1636     if (M4OSA_NULL != (*ppSettings))
1637     {
1638         // Log the function call.
1639         VIDEOEDIT_LOG_FUNCTION(ANDROID_LOG_INFO, "VIDEO_EDITOR_CLASSES",
1640             "videoEditClasses_freeClipSettings()");
1641 
1642         // Free the input file path.
1643         videoEditOsal_free((*ppSettings)->pFile);
1644         (*ppSettings)->pFile = M4OSA_NULL;
1645         (*ppSettings)->filePathSize = 0;
1646 
1647         // Free the clip settings.
1648         M4xVSS_FreeClipSettings((*ppSettings));
1649 
1650         // Free the settings structure.
1651         videoEditOsal_free((*ppSettings));
1652         (*ppSettings) = M4OSA_NULL;
1653     }
1654 }
1655 
1656 #ifdef VIDEOEDIT_LOGGING_ENABLED
1657 void
videoEditClasses_logClipSettings(M4VSS3GPP_ClipSettings * pSettings,int indentation)1658 videoEditClasses_logClipSettings(
1659                 M4VSS3GPP_ClipSettings*             pSettings,
1660                 int                                 indentation)
1661 {
1662     // Check if memory was allocated for the ClipSettings.
1663     if (M4OSA_NULL != pSettings)
1664     {
1665         VIDEOEDIT_LOG_SETTING(ANDROID_LOG_INFO, "VIDEO_EDITOR_CLASSES",
1666             "%*c pFile:           %s", indentation, ' ',
1667             (M4OSA_NULL != pSettings->pFile) ? (char*)pSettings->pFile : "<null>");
1668         VIDEOEDIT_LOG_SETTING(ANDROID_LOG_INFO, "VIDEO_EDITOR_CLASSES",
1669             "%*c FileType:        %s", indentation, ' ',
1670             videoEditJava_getClipTypeString(pSettings->FileType));
1671         VIDEOEDIT_LOG_SETTING(ANDROID_LOG_INFO, "VIDEO_EDITOR_CLASSES",
1672             "%*c filePathSize:    %u", indentation, ' ',
1673             (unsigned int)pSettings->filePathSize);
1674         VIDEOEDIT_LOG_SETTING(ANDROID_LOG_INFO, "VIDEO_EDITOR_CLASSES",
1675             "%*c ClipProperties:",  indentation, ' ');
1676         videoEditClasses_logClipProperties(&pSettings->ClipProperties,
1677             indentation + VIDEOEDIT_LOG_INDENTATION);
1678         VIDEOEDIT_LOG_SETTING(ANDROID_LOG_INFO, "VIDEO_EDITOR_CLASSES",
1679             "%*c uiBeginCutTime:    %u ms", indentation, ' ',
1680             (unsigned int)pSettings->uiBeginCutTime);
1681         VIDEOEDIT_LOG_SETTING(ANDROID_LOG_INFO, "VIDEO_EDITOR_CLASSES",
1682             "%*c uiEndCutTime:      %u ms", indentation, ' ',
1683             (unsigned int)pSettings->uiEndCutTime);
1684         VIDEOEDIT_LOG_SETTING(ANDROID_LOG_INFO, "VIDEO_EDITOR_CLASSES",
1685             "%*c uiBeginCutPercent: %u %%", indentation, ' ',
1686             (unsigned int)pSettings->xVSS.uiBeginCutPercent);
1687         VIDEOEDIT_LOG_SETTING(ANDROID_LOG_INFO, "VIDEO_EDITOR_CLASSES",
1688             "%*c uiEndCutPercent:   %u %%", indentation, ' ',
1689             (unsigned int)pSettings->xVSS.uiEndCutPercent);
1690         VIDEOEDIT_LOG_SETTING(ANDROID_LOG_INFO, "VIDEO_EDITOR_CLASSES",
1691             "%*c uiDuration:        %u ms", indentation, ' ',
1692             (unsigned int)pSettings->xVSS.uiDuration);
1693         VIDEOEDIT_LOG_SETTING(ANDROID_LOG_INFO, "VIDEO_EDITOR_CLASSES",
1694             "%*c isPanZoom:         %s",    indentation, ' ',
1695             pSettings->xVSS.isPanZoom ? "true" : "false");
1696         VIDEOEDIT_LOG_SETTING(ANDROID_LOG_INFO, "VIDEO_EDITOR_CLASSES",
1697             "%*c PanZoomXa:         %d ms", indentation, ' ',
1698             pSettings->xVSS.PanZoomXa);
1699         VIDEOEDIT_LOG_SETTING(ANDROID_LOG_INFO, "VIDEO_EDITOR_CLASSES",
1700             "%*c PanZoomTopleftXa:  %d ms", indentation, ' ',
1701             pSettings->xVSS.PanZoomTopleftXa);
1702         VIDEOEDIT_LOG_SETTING(ANDROID_LOG_INFO, "VIDEO_EDITOR_CLASSES",
1703             "%*c PanZoomTopleftYa:  %d ms", indentation, ' ',
1704             pSettings->xVSS.PanZoomTopleftYa);
1705         VIDEOEDIT_LOG_SETTING(ANDROID_LOG_INFO, "VIDEO_EDITOR_CLASSES",
1706             "%*c PanZoomXb:         %d ms", indentation, ' ',
1707             pSettings->xVSS.PanZoomXb);
1708         VIDEOEDIT_LOG_SETTING(ANDROID_LOG_INFO, "VIDEO_EDITOR_CLASSES",
1709             "%*c PanZoomTopleftXb:  %d ms", indentation, ' ',
1710             pSettings->xVSS.PanZoomTopleftXb);
1711         VIDEOEDIT_LOG_SETTING(ANDROID_LOG_INFO, "VIDEO_EDITOR_CLASSES",
1712             "%*c PanZoomTopleftYb:  %d ms", indentation, ' ',
1713             pSettings->xVSS.PanZoomTopleftYb);
1714         VIDEOEDIT_LOG_SETTING(ANDROID_LOG_INFO, "VIDEO_EDITOR_CLASSES",
1715             "%*c MediaRendering:    %s",    indentation, ' ',
1716             videoEditJava_getMediaRenderingString(pSettings->xVSS.MediaRendering));
1717     }
1718     else
1719     {
1720         VIDEOEDIT_LOG_SETTING(ANDROID_LOG_INFO, "VIDEO_EDITOR_CLASSES",
1721             "%*c <null>", indentation, ' ');
1722     }
1723 }
1724 #endif
1725 
1726 
1727 void
videoEditClasses_getEditSettings(bool * pResult,JNIEnv * pEnv,jobject object,M4VSS3GPP_EditSettings ** ppSettings,bool flag)1728 videoEditClasses_getEditSettings(
1729                 bool*                               pResult,
1730                 JNIEnv*                             pEnv,
1731                 jobject                             object,
1732                 M4VSS3GPP_EditSettings**            ppSettings,
1733                 bool                                flag)
1734 {
1735     VideoEditJava_EditSettingsFieldIds fieldIds;
1736     jobjectArray               clipSettingsArray           = NULL;
1737     jsize                      clipSettingsArraySize       = 0;
1738     jobject                    clipSettings                = NULL;
1739     jobjectArray               transitionSettingsArray     = NULL;
1740     jsize                      transitionSettingsArraySize = 0;
1741     jobject                    transitionSettings          = NULL;
1742     jobjectArray               effectSettingsArray         = NULL;
1743     jsize                      effectSettingsArraySize     = 0;
1744     jobject                    effectSettings              = NULL;
1745     jobject                    backgroundMusicSettings     = NULL;
1746     int                        audioChannels               = 0;
1747     M4VSS3GPP_EditSettings*    pSettings                   = M4OSA_NULL;
1748     bool                       converted                   = true;
1749     memset(&fieldIds, 0, sizeof(VideoEditJava_EditSettingsFieldIds));
1750     // Check if the previous action succeeded.
1751     if (*pResult)
1752     {
1753         // Log the function call.
1754         VIDEOEDIT_LOG_FUNCTION(ANDROID_LOG_INFO, "VIDEO_EDITOR_CLASSES",
1755                 "videoEditClasses_getEditSettings()");
1756 
1757         // Retrieve the field ids.
1758         videoEditJava_getEditSettingsFieldIds(pResult, pEnv, &fieldIds);
1759     }
1760 
1761     // Only retrieve the EditSettings if the previous action succeeded.
1762     if (*pResult)
1763     {
1764         // Check if the object is valid.
1765         if (NULL != object)
1766         {
1767             // Retrieve the clipSettingsArray.
1768             videoEditJava_getArray(pResult, pEnv, object,
1769                            fieldIds.clipSettingsArray,
1770                            &clipSettingsArray,
1771                            &clipSettingsArraySize);
1772 
1773             // Retrieve the transitionSettingsArray.
1774             videoEditJava_getArray(pResult, pEnv, object,
1775                            fieldIds.transitionSettingsArray,
1776                            &transitionSettingsArray,
1777                            &transitionSettingsArraySize);
1778 
1779             // Retrieve the effectSettingsArray.
1780             videoEditJava_getArray(pResult, pEnv, object,
1781                            fieldIds.effectSettingsArray,
1782                            &effectSettingsArray,
1783                            &effectSettingsArraySize);
1784 
1785             // Retrieve the backgroundMusicSettings.
1786             videoEditJava_getObject(pResult, pEnv, object, fieldIds.backgroundMusicSettings,
1787                     &backgroundMusicSettings);
1788 
1789             // Check if the arrays and background music settings object could be retrieved.
1790             if (*pResult)
1791             {
1792                 // Retrieve the number of channels.
1793                 audioChannels = pEnv->GetIntField(object, fieldIds.audioChannels);
1794             }
1795         }
1796     }
1797 
1798     // Only validate the EditSettings if the fields could be located.
1799     if (*pResult)
1800     {
1801         // Check if there is at least one clip.
1802         //videoEditJava_checkAndThrowIllegalArgumentException(pResult, pEnv,
1803          //                                          (clipSettingsArraySize < 1),
1804          //                                          "there should be at least one clip");
1805         if(clipSettingsArraySize < 1) {
1806             return;
1807         }
1808         if(flag)
1809         {
1810             // Check if there are clips.
1811             if ((clipSettingsArraySize != 0) || (transitionSettingsArraySize != 0))
1812             {
1813                 // The number of transitions must be equal to the number of clips - 1.
1814                 videoEditJava_checkAndThrowIllegalArgumentException(pResult, pEnv,
1815                          (clipSettingsArraySize != (transitionSettingsArraySize + 1)),
1816                          "the number of transitions should be equal to the number of clips - 1");
1817             }
1818         }
1819     }
1820 
1821     // Only retrieve the EditSettings if the fields could be located.
1822     if (*pResult)
1823     {
1824         // Check if the object is valid.
1825         if (NULL != object)
1826         {
1827             // Allocate memory for the EditSettings.
1828             pSettings = (M4VSS3GPP_EditSettings*)videoEditOsal_alloc(pResult, pEnv,
1829                     sizeof(M4VSS3GPP_EditSettings), "EditSettings");
1830 
1831             // Check if memory could be allocated for the EditSettings.
1832             if (*pResult)
1833             {
1834                 // Set the number of clips that will be edited.
1835                 pSettings->uiClipNumber = clipSettingsArraySize;
1836 
1837                 // Check if the clip settings array contains items.
1838                 if (clipSettingsArraySize > 0)
1839                 {
1840                     // Allocate memory for the clip settings array.
1841                     pSettings->pClipList = (M4VSS3GPP_ClipSettings **)videoEditOsal_alloc(pResult,
1842                                 pEnv,
1843                                 clipSettingsArraySize * sizeof(M4VSS3GPP_ClipSettings *),
1844                                 "ClipSettingsArray");
1845                     if (*pResult)
1846                     {
1847                         // Loop over all clip settings objects.
1848                         for (int i = 0; ((*pResult) && (i < clipSettingsArraySize)); i++)
1849                         {
1850                             // Get the clip settings object.
1851                             clipSettings = pEnv->GetObjectArrayElement(clipSettingsArray, i);
1852 
1853                             // Get the clip settings.
1854                             videoEditClasses_getClipSettings(pResult, pEnv, clipSettings,
1855                                 &pSettings->pClipList[i]);
1856 
1857                             // Free the local references to avoid memory leaks
1858                             pEnv->DeleteLocalRef(clipSettings);
1859                         }
1860                     }
1861                 }
1862 
1863                 // Check if the transition settings array contains items.
1864                 if (transitionSettingsArraySize > 0)
1865                 {
1866                     // Allocate memory for the transition settings array.
1867                     pSettings->pTransitionList =
1868                             (M4VSS3GPP_TransitionSettings **)videoEditOsal_alloc(pResult,
1869                                 pEnv, transitionSettingsArraySize * sizeof(M4VSS3GPP_TransitionSettings *),
1870                                 "TransitionSettingsArray");
1871                     if (*pResult)
1872                     {
1873                         // Loop over all transition settings objects.
1874                         for (int i = 0; ((*pResult) && (i < transitionSettingsArraySize)); i++)
1875                         {
1876                             // Get the transition settings object.
1877                             transitionSettings =
1878                                     pEnv->GetObjectArrayElement(transitionSettingsArray, i);
1879 
1880                             // Get the transition settings.
1881                             videoEditClasses_getTransitionSettings(pResult, pEnv,
1882                                     transitionSettings, &pSettings->pTransitionList[i]);
1883 
1884                             // Free the local references to avoid memory leaks
1885                             pEnv->DeleteLocalRef(transitionSettings);
1886                         }
1887                     }
1888                 }
1889 
1890                 // Check if the effect settings array contains items.
1891                 if (effectSettingsArraySize > 0)
1892                 {
1893                     // Allocate memory for the effect settings array.
1894                     pSettings->Effects = (M4VSS3GPP_EffectSettings*)videoEditOsal_alloc(pResult,
1895                                 pEnv,
1896                                 effectSettingsArraySize * sizeof(M4VSS3GPP_EffectSettings),
1897                                 "EffectSettingsArray");
1898                     if (*pResult)
1899                     {
1900                         // Loop over all effect settings objects.
1901                         for (int i = 0; ((*pResult) && (i < effectSettingsArraySize)); i++)
1902                         {
1903                             // Get the effect settings object.
1904                             effectSettings = pEnv->GetObjectArrayElement(effectSettingsArray, i);
1905 
1906                             // Get the effect settings.
1907                             videoEditClasses_getEffectSettings(pResult, pEnv, effectSettings,
1908                                     &pSettings->Effects[i]);
1909 
1910                             // Free the local references to avoid memory leaks
1911                             pEnv->DeleteLocalRef(effectSettings);
1912                         }
1913                     }
1914                 }
1915 
1916                 // Check if the clips, transitions and effects could be set.
1917                 if (*pResult)
1918                 {
1919                     // Set the number of effects in the clip.
1920                     pSettings->nbEffects = (M4OSA_UInt8)effectSettingsArraySize;
1921 
1922                     // Set the frame rate of the output video.
1923                     pSettings->videoFrameRate =
1924                         (M4VIDEOEDITING_VideoFramerate)videoEditJava_getVideoFrameRateJavaToC(
1925                              &converted, pEnv->GetIntField(object, fieldIds.videoFrameRate));
1926 
1927                     // Check if the frame rate is valid.
1928                     videoEditJava_checkAndThrowIllegalArgumentException(pResult, pEnv,
1929                         !converted, "editSettings.videoFrameRate is invalid");
1930                 }
1931 
1932                 // Check if the frame rate could be set.
1933                 if (*pResult)
1934                 {
1935                     // Set the path of the output file.
1936                     pSettings->pOutputFile = (M4OSA_Char*)videoEditJava_getString(pResult, pEnv,
1937                         object, fieldIds.outputFile, &pSettings->uiOutputPathSize);
1938                 }
1939 
1940                 // Check if path of the output file could be set.
1941                 if (*pResult)
1942                 {
1943                     // Set the path of the temporary file produced when using
1944                     // the constant memory 3gp writer.
1945                     pSettings->pTemporaryFile = M4OSA_NULL;
1946 
1947                     // Set the output video size.
1948                     pSettings->xVSS.outputVideoSize =
1949                         (M4VIDEOEDITING_VideoFrameSize)videoEditJava_getVideoFrameSizeJavaToC(
1950                                 &converted, pEnv->GetIntField(object, fieldIds.videoFrameSize));
1951 
1952                     // Check if the output video size is valid.
1953                     videoEditJava_checkAndThrowIllegalArgumentException(pResult, pEnv,
1954                         !converted, "editSettings.videoFrameSize is invalid");
1955                 }
1956 
1957                 // Check if the output video size could be set.
1958                 if (*pResult)
1959                 {
1960                     // Set the output video format.
1961                     pSettings->xVSS.outputVideoFormat =
1962                         (M4VIDEOEDITING_VideoFormat)videoEditJava_getVideoFormatJavaToC(
1963                                &converted, pEnv->GetIntField(object, fieldIds.videoFormat));
1964 
1965                     // Check if the output video format is valid.
1966                     videoEditJava_checkAndThrowIllegalArgumentException(pResult, pEnv,
1967                         !converted, "editSettings.videoFormat is invalid");
1968                 }
1969 
1970                 // Check if the output video format could be set.
1971                 if (*pResult)
1972                 {
1973                     // Set the output audio format.
1974                     pSettings->xVSS.outputAudioFormat =
1975                             (M4VIDEOEDITING_AudioFormat)videoEditJava_getAudioFormatJavaToC(
1976                                   &converted, pEnv->GetIntField(object, fieldIds.audioFormat));
1977 
1978                     // Check if the output audio format is valid.
1979                     videoEditJava_checkAndThrowIllegalArgumentException(pResult, pEnv,
1980                             !converted, "editSettings.audioFormat is invalid");
1981                 }
1982 
1983                 // Check if the output audio format could be set.
1984                 if (*pResult)
1985                 {
1986                     // Set the output audio sampling frequency when not replacing the audio,
1987                     // or replacing it with MP3 audio.
1988                     pSettings->xVSS.outputAudioSamplFreq =
1989                         (M4VIDEOEDITING_AudioSamplingFrequency)\
1990                             videoEditJava_getAudioSamplingFrequencyJavaToC(
1991                                 &converted, pEnv->GetIntField(object, fieldIds.audioSamplingFreq));
1992 
1993                     // Check if the output audio sampling frequency is valid.
1994                     videoEditJava_checkAndThrowIllegalArgumentException(pResult, pEnv,
1995                             !converted, "editSettings.audioSamplingFreq is invalid");
1996                 }
1997 
1998                 // Check if the output audio sampling frequency could be set.
1999                 if (*pResult)
2000                 {
2001                     // Check if the number of audio channels is valid.
2002                     videoEditJava_checkAndThrowIllegalArgumentException(pResult, pEnv,
2003                         ((0 != audioChannels ) ||
2004                         ((M4VIDEOEDITING_kNoneAudio != pSettings->xVSS.outputAudioFormat) &&
2005                         (M4VIDEOEDITING_kNullAudio != pSettings->xVSS.outputAudioFormat) ) ) &&
2006                         (1 != audioChannels ) &&
2007                         (2 != audioChannels ),
2008                         "editSettings.audioChannels must be set to 0, 1 or 2");
2009                 }
2010 
2011                 // Check if the number of audio channels is valid.
2012                 if (*pResult)
2013                 {
2014                     // Set the maximum output file size (MMS usecase).
2015                     pSettings->xVSS.outputFileSize = (M4OSA_UInt32)pEnv->GetIntField(object,
2016                             fieldIds.maxFileSize);
2017 
2018                     // Whether or not the audio is mono, only valid for AAC.
2019                     pSettings->xVSS.bAudioMono = (M4OSA_Bool)(1 == audioChannels);
2020 
2021                     // Set the output video bitrate.
2022                     pSettings->xVSS.outputVideoBitrate = (M4OSA_UInt32)pEnv->GetIntField(object,
2023                             fieldIds.videoBitrate);
2024 
2025                     // Set the output video profile.
2026                     pSettings->xVSS.outputVideoProfile = (M4OSA_UInt32)pEnv->GetIntField(object,
2027                             fieldIds.videoProfile);
2028 
2029                     // Set the output video level.
2030                     pSettings->xVSS.outputVideoLevel = (M4OSA_UInt32)pEnv->GetIntField(object,
2031                             fieldIds.videoLevel);
2032 
2033                     // Set the output audio bitrate.
2034                     pSettings->xVSS.outputAudioBitrate = (M4OSA_UInt32)pEnv->GetIntField(object,
2035                             fieldIds.audioBitrate);
2036 
2037                     // Set the background music settings.
2038                     videoEditClasses_getBackgroundMusicSettings(pResult, pEnv,
2039                             backgroundMusicSettings, &pSettings->xVSS.pBGMtrack);
2040 
2041                     // Set the text rendering function (will be set elsewhere).
2042                     pSettings->xVSS.pTextRenderingFct = M4OSA_NULL;
2043                     pSettings->PTVolLevel =
2044                             (M4OSA_Float)pEnv->GetIntField(object, fieldIds.primaryTrackVolume);
2045                 }
2046             }
2047 
2048             // Check if settings could be set.
2049             if (*pResult)
2050             {
2051                 // Return the settings.
2052                 (*ppSettings) = pSettings;
2053             }
2054             else
2055             {
2056                 // Free the settings.
2057                 videoEditClasses_freeEditSettings(&pSettings);
2058             }
2059         }
2060     }
2061 }
2062 
2063 void
videoEditClasses_freeEditSettings(M4VSS3GPP_EditSettings ** ppSettings)2064 videoEditClasses_freeEditSettings(
2065                 M4VSS3GPP_EditSettings**            ppSettings)
2066 {
2067     // Check if memory was allocated for the EditSettings.
2068     if (M4OSA_NULL != (*ppSettings))
2069     {
2070         // Log the function call.
2071         VIDEOEDIT_LOG_FUNCTION(ANDROID_LOG_INFO, "VIDEO_EDITOR_CLASSES",
2072                 "videoEditClasses_freeEditSettings()");
2073 
2074         // Free the background music settings.
2075         videoEditClasses_freeBackgroundMusicSettings(&(*ppSettings)->xVSS.pBGMtrack);
2076 
2077         // Free the path of the output file.
2078         videoEditOsal_free((*ppSettings)->pOutputFile);
2079         (*ppSettings)->pOutputFile = M4OSA_NULL;
2080         (*ppSettings)->uiOutputPathSize = 0;
2081 
2082         // Check if the EffectSettings should be freed.
2083         if (M4OSA_NULL != (*ppSettings)->Effects)
2084         {
2085             // Loop over all effect settings.
2086             for (int i = 0; i < (*ppSettings)->nbEffects; i++)
2087             {
2088                 // Free the effect settings.
2089                 videoEditClasses_freeEffectSettings(&(*ppSettings)->Effects[i]);
2090             }
2091 
2092             // Free the memory for the effect settings array.
2093             videoEditOsal_free((*ppSettings)->Effects);
2094             (*ppSettings)->Effects = M4OSA_NULL;
2095         }
2096 
2097         // Reset the number of effects in the clip.
2098         (*ppSettings)->nbEffects = 0;
2099 
2100         // Check if there are clips.
2101         if (0 < (*ppSettings)->uiClipNumber)
2102         {
2103             // Check if the TransitionSettings should be freed.
2104             if (M4OSA_NULL != (*ppSettings)->pTransitionList)
2105             {
2106                 // Loop over all transition settings.
2107                 for (int i = 0; i < ((*ppSettings)->uiClipNumber - 1); i++)
2108                 {
2109                     // Free the transition settings.
2110                     videoEditClasses_freeTransitionSettings(&(*ppSettings)->pTransitionList[i]);
2111                 }
2112 
2113                 // Free the memory for the transition settings array.
2114                 videoEditOsal_free((*ppSettings)->pTransitionList);
2115                 (*ppSettings)->pTransitionList = M4OSA_NULL;
2116             }
2117 
2118             // Check if the ClipSettings should be freed.
2119             if (M4OSA_NULL != (*ppSettings)->pClipList)
2120             {
2121                 // Loop over all clip settings.
2122                 for (int i = 0; i < (*ppSettings)->uiClipNumber; i++)
2123                 {
2124                     // Free the clip settings.
2125                     videoEditClasses_freeClipSettings(&(*ppSettings)->pClipList[i]);
2126                 }
2127 
2128                 // Free the memory for the clip settings array.
2129                 videoEditOsal_free((*ppSettings)->pClipList);
2130                 (*ppSettings)->pClipList = M4OSA_NULL;
2131             }
2132         }
2133 
2134         // Reset the number of clips.
2135         (*ppSettings)->uiClipNumber = 0;
2136 
2137         // Free the settings structure.
2138         videoEditOsal_free((*ppSettings));
2139         (*ppSettings) = M4OSA_NULL;
2140     }
2141 }
2142 
2143 #ifdef VIDEOEDIT_LOGGING_ENABLED
2144 void
videoEditClasses_logEditSettings(M4VSS3GPP_EditSettings * pSettings,int indentation)2145 videoEditClasses_logEditSettings(
2146                 M4VSS3GPP_EditSettings*             pSettings,
2147                 int                                 indentation)
2148 {
2149     // Check if memory was allocated for the EditSettings.
2150     if (M4OSA_NULL != pSettings)
2151     {
2152         VIDEOEDIT_LOG_SETTING(ANDROID_LOG_INFO, "VIDEO_EDITOR_CLASSES",
2153             "%*c uiClipNumber:         %d", indentation, ' ',
2154             pSettings->uiClipNumber);
2155         VIDEOEDIT_LOG_SETTING(ANDROID_LOG_INFO, "VIDEO_EDITOR_CLASSES",
2156             "%*c uiMasterClip:         %d", indentation, ' ',
2157             pSettings->uiMasterClip);
2158         VIDEOEDIT_LOG_SETTING(ANDROID_LOG_INFO, "VIDEO_EDITOR_CLASSES",
2159             "%*c pClipList:            %s", indentation, ' ',
2160             (M4OSA_NULL != pSettings->pClipList) ? " " : "<null>");
2161         if (M4OSA_NULL != pSettings->pClipList)
2162         {
2163             indentation += VIDEOEDIT_LOG_INDENTATION;
2164             for (int i = 0; i < pSettings->uiClipNumber; i++)
2165             {
2166                 VIDEOEDIT_LOG_SETTING(ANDROID_LOG_INFO, "VIDEO_EDITOR_CLASSES",
2167                     "%*c pClipList[%d]:", indentation, ' ',
2168                     i);
2169                 videoEditClasses_logClipSettings(pSettings->pClipList[i],
2170                     indentation + VIDEOEDIT_LOG_INDENTATION);
2171             }
2172             indentation -= VIDEOEDIT_LOG_INDENTATION;
2173         }
2174         VIDEOEDIT_LOG_SETTING(ANDROID_LOG_INFO, "VIDEO_EDITOR_CLASSES",
2175             "%*c pTransitionList:      %s", indentation, ' ',
2176             (M4OSA_NULL != pSettings->pTransitionList) ? " " : "<null>");
2177         if (M4OSA_NULL != pSettings->pTransitionList)
2178         {
2179             indentation += VIDEOEDIT_LOG_INDENTATION;
2180             for (int i = 0; i < (pSettings->uiClipNumber - 1); i++)
2181             {
2182                 VIDEOEDIT_LOG_SETTING(ANDROID_LOG_INFO, "VIDEO_EDITOR_CLASSES",
2183                     "%*c pTransitionList[%d]:", indentation, ' ', i);
2184                 videoEditClasses_logTransitionSettings(pSettings->pTransitionList[i],
2185                     indentation + VIDEOEDIT_LOG_INDENTATION);
2186             }
2187             indentation -= VIDEOEDIT_LOG_INDENTATION;
2188         }
2189         VIDEOEDIT_LOG_SETTING(ANDROID_LOG_INFO, "VIDEO_EDITOR_CLASSES",
2190             "%*c Effects:              %s", indentation, ' ',
2191             (M4OSA_NULL != pSettings->Effects)   ? " " : "<null>");
2192         if (M4OSA_NULL != pSettings->Effects)
2193         {
2194             indentation += VIDEOEDIT_LOG_INDENTATION;
2195             for (int i = 0; i < pSettings->nbEffects; i++)
2196             {
2197                 VIDEOEDIT_LOG_SETTING(ANDROID_LOG_INFO, "VIDEO_EDITOR_CLASSES",
2198                     "%*c Effects[%d]:", indentation, ' ',  i);
2199                 videoEditClasses_logEffectSettings(&pSettings->Effects[i],
2200                     indentation + VIDEOEDIT_LOG_INDENTATION);
2201             }
2202             indentation -= VIDEOEDIT_LOG_INDENTATION;
2203         }
2204         VIDEOEDIT_LOG_SETTING(ANDROID_LOG_INFO, "VIDEO_EDITOR_CLASSES",
2205             "%*c nbEffects:            %d", indentation, ' ',
2206             pSettings->nbEffects);
2207         VIDEOEDIT_LOG_SETTING(ANDROID_LOG_INFO, "VIDEO_EDITOR_CLASSES",
2208             "%*c videoFrameRate:       %s", indentation, ' ',
2209             videoEditJava_getVideoFrameRateString(pSettings->videoFrameRate));
2210         VIDEOEDIT_LOG_SETTING(ANDROID_LOG_INFO, "VIDEO_EDITOR_CLASSES",
2211             "%*c pOutputFile:          %s", indentation, ' ',
2212             (M4OSA_NULL != pSettings->pOutputFile) ? (char*)pSettings->pOutputFile : "<null>");
2213         VIDEOEDIT_LOG_SETTING(ANDROID_LOG_INFO, "VIDEO_EDITOR_CLASSES",
2214             "%*c uiOutputPathSize:     %u", indentation, ' ',
2215             (unsigned int)pSettings->uiOutputPathSize);
2216         VIDEOEDIT_LOG_SETTING(ANDROID_LOG_INFO, "VIDEO_EDITOR_CLASSES",
2217             "%*c pTemporaryFile:       %s", indentation, ' ',
2218             (M4OSA_NULL != pSettings->pTemporaryFile) ?\
2219              (char*)pSettings->pTemporaryFile : "<null>");
2220         VIDEOEDIT_LOG_SETTING(ANDROID_LOG_INFO, "VIDEO_EDITOR_CLASSES",
2221             "%*c outputVideoSize:      %s", indentation, ' ',
2222             videoEditJava_getVideoFrameSizeString(pSettings->xVSS.outputVideoSize));
2223         VIDEOEDIT_LOG_SETTING(ANDROID_LOG_INFO, "VIDEO_EDITOR_CLASSES",
2224             "%*c outputVideoFormat:    %s", indentation, ' ',
2225             videoEditJava_getVideoFormatString(pSettings->xVSS.outputVideoFormat));
2226         VIDEOEDIT_LOG_SETTING(ANDROID_LOG_INFO, "VIDEO_EDITOR_CLASSES",
2227             "%*c outputVideoProfile:    %u", indentation, ' ',
2228             videoEditJava_getVideoFormatString(pSettings->xVSS.outputVideoProfile));
2229         VIDEOEDIT_LOG_SETTING(ANDROID_LOG_INFO, "VIDEO_EDITOR_CLASSES",
2230             "%*c outputVideoLevel:    %u", indentation, ' ',
2231             videoEditJava_getVideoFormatString(pSettings->xVSS.outputVideoLevel));
2232         VIDEOEDIT_LOG_SETTING(ANDROID_LOG_INFO, "VIDEO_EDITOR_CLASSES",
2233             "%*c outputAudioFormat:    %s", indentation, ' ',
2234             videoEditJava_getAudioFormatString(pSettings->xVSS.outputAudioFormat));
2235         VIDEOEDIT_LOG_SETTING(ANDROID_LOG_INFO, "VIDEO_EDITOR_CLASSES",
2236             "%*c outputAudioSamplFreq: %s", indentation, ' ',
2237             videoEditJava_getAudioSamplingFrequencyString(pSettings->xVSS.outputAudioSamplFreq));
2238         VIDEOEDIT_LOG_SETTING(ANDROID_LOG_INFO, "VIDEO_EDITOR_CLASSES",
2239             "%*c outputFileSize:       %u", indentation, ' ',
2240             (unsigned int)pSettings->xVSS.outputFileSize);
2241         VIDEOEDIT_LOG_SETTING(ANDROID_LOG_INFO, "VIDEO_EDITOR_CLASSES",
2242             "%*c bAudioMono:           %s", indentation, ' ',
2243             pSettings->xVSS.bAudioMono ? "true" : "false");
2244         VIDEOEDIT_LOG_SETTING(ANDROID_LOG_INFO, "VIDEO_EDITOR_CLASSES",
2245             "%*c outputVideoBitrate:   %s", indentation, ' ',
2246             videoEditJava_getBitrateString(pSettings->xVSS.outputVideoBitrate));
2247         VIDEOEDIT_LOG_SETTING(ANDROID_LOG_INFO, "VIDEO_EDITOR_CLASSES",
2248             "%*c outputAudioBitrate:   %s", indentation, ' ',
2249             videoEditJava_getBitrateString(pSettings->xVSS.outputAudioBitrate));
2250         VIDEOEDIT_LOG_SETTING(ANDROID_LOG_INFO, "VIDEO_EDITOR_CLASSES",
2251             "%*c pBGMtrack:",               indentation, ' ');
2252         videoEditClasses_logBackgroundMusicSettings(pSettings->xVSS.pBGMtrack,
2253             indentation + VIDEOEDIT_LOG_INDENTATION);
2254         VIDEOEDIT_LOG_SETTING(ANDROID_LOG_INFO, "VIDEO_EDITOR_CLASSES",
2255             "%*c pTextRenderingFct:    %s", indentation, ' ',
2256             (M4OSA_NULL != pSettings->xVSS.pTextRenderingFct) ? "set" : "<null>");
2257         VIDEOEDIT_LOG_SETTING(ANDROID_LOG_INFO, "VIDEO_EDITOR_CLASSES",
2258             "%*c PTVolLevel:       %u", indentation, ' ',
2259             (unsigned int)pSettings->PTVolLevel);
2260     }
2261     else
2262     {
2263         VIDEOEDIT_LOG_SETTING(ANDROID_LOG_INFO, "VIDEO_EDITOR_CLASSES",
2264             "%*c <null>", indentation, ' ');
2265     }
2266 }
2267 #endif
2268 
2269 
2270 void
videoEditClasses_getEffectSettings(bool * pResult,JNIEnv * pEnv,jobject object,M4VSS3GPP_EffectSettings * pSettings)2271 videoEditClasses_getEffectSettings(
2272                 bool*                               pResult,
2273                 JNIEnv*                             pEnv,
2274                 jobject                             object,
2275                 M4VSS3GPP_EffectSettings*           pSettings)
2276 {
2277 
2278     VideoEditJava_EffectSettingsFieldIds fieldIds;
2279     bool                         converted = true;
2280     memset(&fieldIds, 0, sizeof(VideoEditJava_EffectSettingsFieldIds));
2281 
2282     // Check if the previous action succeeded.
2283     if (*pResult)
2284     {
2285         // Log the function call.
2286         VIDEOEDIT_LOG_FUNCTION(ANDROID_LOG_INFO, "VIDEO_EDITOR_CLASSES",
2287          "videoEditClasses_getEffectSettings()");
2288 
2289         // Retrieve the field ids.
2290         videoEditJava_getEffectSettingsFieldIds(pResult, pEnv, &fieldIds);
2291     }
2292 
2293     // Only validate the EffectSettings if the fields could be located.
2294     if (*pResult)
2295     {
2296         // Check if the effect is set.
2297         videoEditJava_checkAndThrowIllegalArgumentException(pResult, pEnv,
2298                                                     (NULL == object),
2299                                                     "effect is null");
2300     }
2301 
2302     // Only retrieve the EffectSettings if the fields could be located and validated.
2303     if (*pResult)
2304     {
2305         // Set the start time in milliseconds.
2306         pSettings->uiStartTime = (M4OSA_UInt32)pEnv->GetIntField(object, fieldIds.startTime);
2307 
2308         // Set the duration in milliseconds.
2309         pSettings->uiDuration = (M4OSA_UInt32)pEnv->GetIntField(object, fieldIds.duration);
2310 
2311         // Set the video effect type, None, FadeIn, FadeOut, etc.
2312         pSettings->VideoEffectType =
2313                 (M4VSS3GPP_VideoEffectType)videoEditJava_getVideoEffectJavaToC(
2314                               &converted, pEnv->GetIntField(object, fieldIds.videoEffectType));
2315 
2316         // Check if the video effect type is valid.
2317         videoEditJava_checkAndThrowIllegalArgumentException(pResult, pEnv,
2318                 !converted, "effect.videoEffectType is invalid");
2319     }
2320 
2321     // Check if the video effect type could be set.
2322     if (*pResult)
2323     {
2324         // Set the external effect function.
2325         pSettings->ExtVideoEffectFct = M4OSA_NULL;
2326 
2327         // Set the context given to the external effect function.
2328         pSettings->pExtVideoEffectFctCtxt = M4OSA_NULL;
2329 
2330         // Set the audio effect type, None, FadeIn, FadeOut.
2331         pSettings->AudioEffectType =
2332                 (M4VSS3GPP_AudioEffectType)videoEditJava_getAudioEffectJavaToC(
2333                         &converted, pEnv->GetIntField(object, fieldIds.audioEffectType));
2334 
2335         // Check if the audio effect type is valid.
2336         videoEditJava_checkAndThrowIllegalArgumentException(pResult, pEnv,
2337                 !converted, "effect.audioEffectType is invalid");
2338     }
2339 
2340     // Check if the audio effect type could be set.
2341     if (*pResult)
2342     {
2343         // Set the start in percentage of the cut clip duration.
2344         pSettings->xVSS.uiStartPercent = (M4OSA_UInt32)pEnv->GetIntField(object,
2345                 fieldIds.startPercent);
2346 
2347         // Set the duration in percentage of the ((clip duration) - (effect starttime)).
2348         pSettings->xVSS.uiDurationPercent = (M4OSA_UInt32)pEnv->GetIntField(object,
2349                 fieldIds.durationPercent);
2350 
2351         // Set the framing file path (GIF/PNG file).
2352         pSettings->xVSS.pFramingFilePath = (M4OSA_Char*)videoEditJava_getString(pResult, pEnv,
2353                 object, fieldIds.framingFile, M4OSA_NULL);
2354 
2355         // Check if this is a framing effect.
2356         if (M4xVSS_kVideoEffectType_Framing == (M4xVSS_VideoEffectType)pSettings->VideoEffectType)
2357         {
2358             // Check if the framing file path is valid.
2359             videoEditJava_checkAndThrowIllegalArgumentException(pResult, pEnv,
2360                     (M4OSA_NULL == pSettings->xVSS.pFramingFilePath), "effect.framingFile is null");
2361         }
2362     }
2363 
2364     // Check if the framing file path could be retrieved.
2365     if (*pResult)
2366     {
2367         // Set the Framing RGB565 buffer.
2368         pSettings->xVSS.pFramingBuffer = M4OSA_NULL;
2369 
2370         // Set the top-left X coordinate in the output picture
2371         // where the added frame will be displayed.
2372         pSettings->xVSS.topleft_x = (M4OSA_UInt32)pEnv->GetIntField(object, fieldIds.topLeftX);
2373 
2374         // Set the top-left Y coordinate in the output picture
2375         // where the added frame will be displayed.
2376         pSettings->xVSS.topleft_y = (M4OSA_UInt32)pEnv->GetIntField(object, fieldIds.topLeftY);
2377 
2378         // Set whether or not the framing image is resized to output video size.
2379         pSettings->xVSS.bResize =
2380                 (M4OSA_Bool)pEnv->GetBooleanField(object, fieldIds.framingResize);
2381 
2382         // Set the new size to which framing buffer needs to be resized to
2383         pSettings->xVSS.framingScaledSize =
2384                 (M4VIDEOEDITING_VideoFrameSize)pEnv->GetIntField(object, fieldIds.framingScaledSize);
2385 
2386         // Set the text buffer.
2387         pSettings->xVSS.pTextBuffer = (M4OSA_Char*)videoEditJava_getString(pResult, pEnv, object,
2388                 fieldIds.text, &pSettings->xVSS.textBufferSize);
2389     }
2390 
2391     // Check if the text buffer could be retrieved.
2392     if (*pResult)
2393     {
2394         // Set the data used by the font engine (size, color...).
2395         pSettings->xVSS.pRenderingData = (M4OSA_Char*)videoEditJava_getString(pResult, pEnv,
2396                 object, fieldIds.textRenderingData, M4OSA_NULL);
2397     }
2398 
2399     // Check if the text rendering data could be retrieved.
2400     if (*pResult)
2401     {
2402         // Set the text plane width.
2403         pSettings->xVSS.uiTextBufferWidth = (M4OSA_UInt32)pEnv->GetIntField(object,
2404                 fieldIds.textBufferWidth);
2405 
2406         // Set the text plane height.
2407         pSettings->xVSS.uiTextBufferHeight = (M4OSA_UInt32)pEnv->GetIntField(object,
2408                 fieldIds.textBufferHeight);
2409 
2410         // Set the processing rate of the effect added when using the Fifties effect.
2411         pSettings->xVSS.uiFiftiesOutFrameRate = (M4OSA_UInt32)pEnv->GetIntField(object,
2412                 fieldIds.fiftiesFrameRate);
2413 
2414         // Set the RGB16 input color of the effect added when using the rgb16 color effect.
2415         pSettings->xVSS.uiRgb16InputColor = (M4OSA_UInt16)pEnv->GetIntField(object,
2416                 fieldIds.rgb16InputColor);
2417 
2418         // Set the start percentage of Alpha blending.
2419         pSettings->xVSS.uialphaBlendingStart = (M4OSA_UInt8)pEnv->GetIntField(object,
2420                 fieldIds.alphaBlendingStartPercent);
2421 
2422         // Set the middle percentage of Alpha blending.
2423         pSettings->xVSS.uialphaBlendingMiddle = (M4OSA_UInt8)pEnv->GetIntField(object,
2424                 fieldIds.alphaBlendingMiddlePercent);
2425 
2426         // Set the end percentage of Alpha blending.
2427         pSettings->xVSS.uialphaBlendingEnd = (M4OSA_UInt8)pEnv->GetIntField(object,
2428                 fieldIds.alphaBlendingEndPercent);
2429 
2430         // Set the duration, in percentage of effect duration, of the FadeIn phase.
2431         pSettings->xVSS.uialphaBlendingFadeInTime = (M4OSA_UInt8)pEnv->GetIntField(object,
2432                 fieldIds.alphaBlendingFadeInTimePercent);
2433 
2434         // Set the duration, in percentage of effect duration, of the FadeOut phase.
2435         pSettings->xVSS.uialphaBlendingFadeOutTime = (M4OSA_UInt8)pEnv->GetIntField(object,
2436                 fieldIds.alphaBlendingFadeOutTimePercent);
2437 
2438         if (pSettings->xVSS.pFramingFilePath != M4OSA_NULL)
2439         {
2440             pSettings->xVSS.pFramingBuffer =
2441                 (M4VIFI_ImagePlane *)M4OSA_32bitAlignedMalloc(sizeof(M4VIFI_ImagePlane),
2442                 0x00,(M4OSA_Char *)"framing buffer");
2443         }
2444 
2445         if (pSettings->xVSS.pFramingBuffer != M4OSA_NULL)
2446         {
2447              // OverFrame height and width
2448             pSettings->xVSS.pFramingBuffer->u_width = pEnv->GetIntField(object,
2449              fieldIds.width);
2450 
2451             pSettings->xVSS.pFramingBuffer->u_height = pEnv->GetIntField(object,
2452              fieldIds.height);
2453 
2454             pSettings->xVSS.width = pSettings->xVSS.pFramingBuffer->u_width;
2455             pSettings->xVSS.height = pSettings->xVSS.pFramingBuffer->u_height;
2456             pSettings->xVSS.rgbType = M4VSS3GPP_kRGB565;
2457 
2458             VIDEOEDIT_LOG_FUNCTION(ANDROID_LOG_INFO, "VIDEO_EDITOR_CLASSES",
2459                     "pFramingBuffer u_width %d ", pSettings->xVSS.pFramingBuffer->u_width);
2460             VIDEOEDIT_LOG_FUNCTION(ANDROID_LOG_INFO, "VIDEO_EDITOR_CLASSES",
2461                     "pFramingBuffer u_height %d", pSettings->xVSS.pFramingBuffer->u_height);
2462 
2463         }
2464 
2465         // Check if settings could be set.
2466         if (!(*pResult))
2467         {
2468             // Free the settings.
2469             videoEditClasses_freeEffectSettings(pSettings);
2470         }
2471     }
2472 }
2473 
2474 void
videoEditClasses_freeEffectSettings(M4VSS3GPP_EffectSettings * pSettings)2475 videoEditClasses_freeEffectSettings(
2476                 M4VSS3GPP_EffectSettings*           pSettings)
2477 {
2478     // Check if memory was allocated for the EffectSettings.
2479     if (M4OSA_NULL != pSettings)
2480     {
2481         // Log the function call.
2482         VIDEOEDIT_LOG_FUNCTION(ANDROID_LOG_INFO, "VIDEO_EDITOR_CLASSES",
2483                 "videoEditClasses_freeEffectSettings()");
2484 
2485         // Free the data used by the font engine (size, color...).
2486         videoEditOsal_free(pSettings->xVSS.pRenderingData);
2487         pSettings->xVSS.pRenderingData = M4OSA_NULL;
2488 
2489         // Free the text buffer.
2490         videoEditOsal_free(pSettings->xVSS.pTextBuffer);
2491         pSettings->xVSS.pTextBuffer = M4OSA_NULL;
2492         pSettings->xVSS.textBufferSize = 0;
2493 
2494         // Free the framing file path.
2495         videoEditOsal_free(pSettings->xVSS.pFramingFilePath);
2496         pSettings->xVSS.pFramingFilePath = M4OSA_NULL;
2497     }
2498 }
2499 
2500 #ifdef VIDEOEDIT_LOGGING_ENABLED
2501 void
videoEditClasses_logEffectSettings(M4VSS3GPP_EffectSettings * pSettings,int indentation)2502 videoEditClasses_logEffectSettings(
2503                 M4VSS3GPP_EffectSettings*           pSettings,
2504                 int                                 indentation)
2505 {
2506     // Check if memory was allocated for the EffectSettings.
2507     if (M4OSA_NULL != pSettings)
2508     {
2509         VIDEOEDIT_LOG_SETTING(ANDROID_LOG_INFO, "VIDEO_EDITOR_CLASSES",
2510             "%*c uiStartTime:                %u ms", indentation, ' ',
2511             (unsigned int)pSettings->uiStartTime);
2512         VIDEOEDIT_LOG_SETTING(ANDROID_LOG_INFO, "VIDEO_EDITOR_CLASSES",
2513             "%*c uiDuration:                 %u ms", indentation, ' ',
2514             (unsigned int)pSettings->uiDuration);
2515         VIDEOEDIT_LOG_SETTING(ANDROID_LOG_INFO, "VIDEO_EDITOR_CLASSES",
2516             "%*c VideoEffectType:            %s",    indentation, ' ',
2517             videoEditJava_getVideoEffectString(pSettings->VideoEffectType));
2518         VIDEOEDIT_LOG_SETTING(ANDROID_LOG_INFO, "VIDEO_EDITOR_CLASSES",
2519              "%*c ExtVideoEffectFct:          %s",    indentation, ' ',
2520             (M4OSA_NULL != pSettings->ExtVideoEffectFct) ? "set" : "<null>");
2521         VIDEOEDIT_LOG_SETTING(ANDROID_LOG_INFO, "VIDEO_EDITOR_CLASSES",
2522             "%*c pExtVideoEffectFctCtxt:     %s",    indentation, ' ',
2523             (M4OSA_NULL != pSettings->pExtVideoEffectFctCtxt) ? "set" : "<null>");
2524         VIDEOEDIT_LOG_SETTING(ANDROID_LOG_INFO, "VIDEO_EDITOR_CLASSES",
2525             "%*c AudioEffectType:            %s",    indentation, ' ',
2526             videoEditJava_getAudioEffectString(pSettings->AudioEffectType));
2527         VIDEOEDIT_LOG_SETTING(ANDROID_LOG_INFO, "VIDEO_EDITOR_CLASSES",
2528             "%*c uiStartPercent:             %u %%", indentation, ' ',
2529             (unsigned int)pSettings->xVSS.uiStartPercent);
2530         VIDEOEDIT_LOG_SETTING(ANDROID_LOG_INFO, "VIDEO_EDITOR_CLASSES",
2531             "%*c uiDurationPercent:          %u %%", indentation, ' ',
2532             (unsigned int)pSettings->xVSS.uiDurationPercent);
2533         VIDEOEDIT_LOG_SETTING(ANDROID_LOG_INFO, "VIDEO_EDITOR_CLASSES",
2534             "%*c pFramingFilePath:           %s",    indentation, ' ',
2535             (M4OSA_NULL != pSettings->xVSS.pFramingFilePath) ?\
2536              (char*)pSettings->xVSS.pFramingFilePath : "<null>");
2537         VIDEOEDIT_LOG_SETTING(ANDROID_LOG_INFO, "VIDEO_EDITOR_CLASSES",
2538             "%*c pFramingBuffer:             %s",    indentation, ' ',
2539             (M4OSA_NULL != pSettings->xVSS.pFramingBuffer) ? "set" : "<null>");
2540         VIDEOEDIT_LOG_SETTING(ANDROID_LOG_INFO, "VIDEO_EDITOR_CLASSES",
2541             "%*c topleft_x:                  %u",    indentation, ' ',
2542             (unsigned int)pSettings->xVSS.topleft_x);
2543         VIDEOEDIT_LOG_SETTING(ANDROID_LOG_INFO, "VIDEO_EDITOR_CLASSES",
2544             "%*c topleft_y:                  %u",    indentation, ' ',
2545             (unsigned int)pSettings->xVSS.topleft_y);
2546         VIDEOEDIT_LOG_SETTING(ANDROID_LOG_INFO, "VIDEO_EDITOR_CLASSES",
2547             "%*c bResize:                    %s",    indentation, ' ',
2548             pSettings->xVSS.bResize ? "true" : "false");
2549         VIDEOEDIT_LOG_SETTING(ANDROID_LOG_INFO, "VIDEO_EDITOR_CLASSES",
2550             "%*c pTextBuffer:                %s",    indentation, ' ',
2551             (M4OSA_NULL != pSettings->xVSS.pTextBuffer) ?\
2552              (char*)pSettings->xVSS.pTextBuffer : "<null>");
2553         VIDEOEDIT_LOG_SETTING(ANDROID_LOG_INFO, "VIDEO_EDITOR_CLASSES",
2554             "%*c textBufferSize:             %u",    indentation, ' ',
2555             (unsigned int)pSettings->xVSS.textBufferSize);
2556         VIDEOEDIT_LOG_SETTING(ANDROID_LOG_INFO, "VIDEO_EDITOR_CLASSES",
2557             "%*c pRenderingData:             %s",    indentation, ' ',
2558             (M4OSA_NULL != pSettings->xVSS.pRenderingData) ?\
2559              (char*)pSettings->xVSS.pRenderingData : "<null>");
2560         VIDEOEDIT_LOG_SETTING(ANDROID_LOG_INFO, "VIDEO_EDITOR_CLASSES",
2561             "%*c uiTextBufferWidth:          %u",    indentation, ' ',
2562             (unsigned int)pSettings->xVSS.uiTextBufferWidth);
2563         VIDEOEDIT_LOG_SETTING(ANDROID_LOG_INFO, "VIDEO_EDITOR_CLASSES",
2564              "%*c uiTextBufferHeight:         %u",    indentation, ' ',
2565             (unsigned int)pSettings->xVSS.uiTextBufferHeight);
2566         VIDEOEDIT_LOG_SETTING(ANDROID_LOG_INFO, "VIDEO_EDITOR_CLASSES",
2567             "%*c uiFiftiesOutFrameRate:      %u",    indentation, ' ',
2568             (unsigned int)pSettings->xVSS.uiFiftiesOutFrameRate);
2569         VIDEOEDIT_LOG_SETTING(ANDROID_LOG_INFO, "VIDEO_EDITOR_CLASSES",
2570             "%*c uiRgb16InputColor:          %d",    indentation, ' ',
2571             pSettings->xVSS.uiRgb16InputColor);
2572         VIDEOEDIT_LOG_SETTING(ANDROID_LOG_INFO, "VIDEO_EDITOR_CLASSES",
2573             "%*c uialphaBlendingStart:       %d %%", indentation, ' ',
2574             pSettings->xVSS.uialphaBlendingStart);
2575         VIDEOEDIT_LOG_SETTING(ANDROID_LOG_INFO, "VIDEO_EDITOR_CLASSES",
2576             "%*c uialphaBlendingMiddle:      %d %%", indentation, ' ',
2577             pSettings->xVSS.uialphaBlendingMiddle);
2578         VIDEOEDIT_LOG_SETTING(ANDROID_LOG_INFO, "VIDEO_EDITOR_CLASSES",
2579             "%*c uialphaBlendingEnd:         %d %%", indentation, ' ',
2580             pSettings->xVSS.uialphaBlendingEnd);
2581         VIDEOEDIT_LOG_SETTING(ANDROID_LOG_INFO, "VIDEO_EDITOR_CLASSES",
2582             "%*c uialphaBlendingFadeInTime:  %d %%", indentation, ' ',
2583             pSettings->xVSS.uialphaBlendingFadeInTime);
2584         VIDEOEDIT_LOG_SETTING(ANDROID_LOG_INFO, "VIDEO_EDITOR_CLASSES",
2585             "%*c uialphaBlendingFadeOutTime: %d %%", indentation, ' ',
2586             pSettings->xVSS.uialphaBlendingFadeOutTime);
2587     }
2588     else
2589     {
2590         VIDEOEDIT_LOG_SETTING(ANDROID_LOG_INFO, "VIDEO_EDITOR_CLASSES",
2591             "%*c <null>", indentation, ' ');
2592     }
2593 }
2594 #endif
2595 
2596 
2597 void
videoEditClasses_getSlideTransitionSettings(bool * pResult,JNIEnv * pEnv,jobject object,M4xVSS_SlideTransitionSettings ** ppSettings)2598 videoEditClasses_getSlideTransitionSettings(
2599                 bool*                               pResult,
2600                 JNIEnv*                             pEnv,
2601                 jobject                             object,
2602                 M4xVSS_SlideTransitionSettings**    ppSettings)
2603 {
2604     VideoEditJava_SlideTransitionSettingsFieldIds fieldIds  = {NULL};
2605     M4xVSS_SlideTransitionSettings*       pSettings = M4OSA_NULL;
2606     bool                                  converted = true;
2607 
2608     // Check if the previous action succeeded.
2609     if (*pResult)
2610     {
2611         // Log the function call.
2612         VIDEOEDIT_LOG_FUNCTION(ANDROID_LOG_INFO, "VIDEO_EDITOR_CLASSES",
2613                 "videoEditClasses_getSlideTransitionSettings()");
2614 
2615         // Retrieve the field ids.
2616         videoEditJava_getSlideTransitionSettingsFieldIds(pResult, pEnv, &fieldIds);
2617     }
2618 
2619 
2620     // Only validate the SlideTransitionSettings if the fields could be located.
2621     if (*pResult)
2622     {
2623         // Check if the clip is set.
2624         videoEditJava_checkAndThrowIllegalArgumentException(pResult, pEnv,
2625                                                     (NULL == object),
2626                                                     "slideSettings is null");
2627     }
2628 
2629     // Only retrieve the SlideTransitionSettings if the fields could be located and validated.
2630     if (*pResult)
2631     {
2632         // Allocate memory for the SlideTransitionSettings.
2633         pSettings = (M4xVSS_SlideTransitionSettings*)videoEditOsal_alloc(pResult, pEnv,
2634                 sizeof(M4xVSS_SlideTransitionSettings), "SlideTransitionSettings");
2635 
2636         // Check if memory could be allocated for the SlideTransitionSettings.
2637         if (*pResult)
2638         {
2639             // Set the direction of the slide.
2640             pSettings->direction =
2641                     (M4xVSS_SlideTransition_Direction)videoEditJava_getSlideDirectionJavaToC(
2642                             &converted, pEnv->GetIntField(object, fieldIds.direction));
2643 
2644             // Check if the direction is valid.
2645             videoEditJava_checkAndThrowIllegalArgumentException(pResult, pEnv,
2646                     !converted, "slideSettings.direction is invalid");
2647         }
2648 
2649         // Check if settings could be set.
2650         if (*pResult)
2651         {
2652             // Return the settings.
2653             (*ppSettings) = pSettings;
2654         }
2655         else
2656         {
2657             // Free the settings.
2658             videoEditClasses_freeSlideTransitionSettings(&pSettings);
2659         }
2660     }
2661 }
2662 
2663 void
videoEditClasses_freeSlideTransitionSettings(M4xVSS_SlideTransitionSettings ** ppSettings)2664 videoEditClasses_freeSlideTransitionSettings(
2665                 M4xVSS_SlideTransitionSettings**    ppSettings)
2666 {
2667     // Check if memory was allocated for the SlideTransitionSettings.
2668     if (M4OSA_NULL != (*ppSettings))
2669     {
2670         // Log the function call.
2671         VIDEOEDIT_LOG_FUNCTION(ANDROID_LOG_INFO, "VIDEO_EDITOR_CLASSES",
2672                 "videoEditClasses_freeSlideTransitionSettings()");
2673 
2674         // Free the settings structure.
2675         videoEditOsal_free((*ppSettings));
2676         (*ppSettings) = M4OSA_NULL;
2677     }
2678 }
2679 
2680 #ifdef VIDEOEDIT_LOGGING_ENABLED
2681 void
videoEditClasses_logSlideTransitionSettings(M4xVSS_SlideTransitionSettings * pSettings,int indentation)2682 videoEditClasses_logSlideTransitionSettings(
2683                 M4xVSS_SlideTransitionSettings*     pSettings,
2684                 int                                 indentation)
2685 {
2686     // Check if memory was allocated for the SlideTransitionSettings.
2687     if (M4OSA_NULL != pSettings)
2688     {
2689         VIDEOEDIT_LOG_SETTING(ANDROID_LOG_INFO, "VIDEO_EDITOR_CLASSES",
2690             "%*c direction: %s", indentation, ' ',
2691             videoEditJava_getSlideDirectionString(pSettings->direction));
2692     }
2693     else
2694     {
2695         VIDEOEDIT_LOG_SETTING(ANDROID_LOG_INFO, "VIDEO_EDITOR_CLASSES",
2696             "%*c <null>", indentation, ' ');
2697     }
2698 }
2699 #endif
2700 
2701 
2702 void
videoEditClasses_getTransitionSettings(bool * pResult,JNIEnv * pEnv,jobject object,M4VSS3GPP_TransitionSettings ** ppSettings)2703 videoEditClasses_getTransitionSettings(
2704                 bool*                               pResult,
2705                 JNIEnv*                             pEnv,
2706                 jobject                             object,
2707                 M4VSS3GPP_TransitionSettings**      ppSettings)
2708 {
2709 
2710     VideoEditJava_TransitionSettingsFieldIds fieldIds;
2711     jobject                          alphaSettings = NULL;
2712     jobject                          slideSettings = NULL;
2713     M4VSS3GPP_TransitionSettings*    pSettings     = M4OSA_NULL;
2714     bool                             converted     = true;
2715     memset(&fieldIds, 0, sizeof(VideoEditJava_TransitionSettingsFieldIds));
2716 
2717     // Check if the previous action succeeded.
2718     if (*pResult)
2719     {
2720         // Log the function call.
2721         VIDEOEDIT_LOG_FUNCTION(ANDROID_LOG_INFO, "VIDEO_EDITOR_CLASSES",
2722                "videoEditClasses_getTransitionSettings()");
2723 
2724         // Retrieve the field ids.
2725         videoEditJava_getTransitionSettingsFieldIds(pResult, pEnv, &fieldIds);
2726     }
2727 
2728     // Only validate the TransitionSettings if the fields could be located.
2729     if (*pResult)
2730     {
2731         // Check if the transition is set.
2732         videoEditJava_checkAndThrowIllegalArgumentException(pResult, pEnv,
2733                                                     (NULL == object),
2734                                                     "transition is null");
2735     }
2736 
2737     // Check if the field ids could be located and validated.
2738     if (*pResult)
2739     {
2740         // Retrieve the alphaSettings.
2741         videoEditJava_getObject(pResult, pEnv, object, fieldIds.alphaSettings, &alphaSettings);
2742 
2743         // Retrieve the slideSettings.
2744         videoEditJava_getObject(pResult, pEnv, object, fieldIds.slideSettings, &slideSettings);
2745     }
2746 
2747     // Only retrieve the TransitionSettings if the fields could be located.
2748     if (*pResult)
2749     {
2750         // Allocate memory for the TransitionSettings.
2751         pSettings = (M4VSS3GPP_TransitionSettings*)videoEditOsal_alloc(pResult,
2752                 pEnv, sizeof(M4VSS3GPP_TransitionSettings), "TransitionSettings");
2753 
2754         // Check if memory could be allocated for the TransitionSettings.
2755         if (*pResult)
2756         {
2757             // Set the duration of the transition, in milliseconds (set to 0 to get no transition).
2758             pSettings->uiTransitionDuration = (M4OSA_UInt32)pEnv->GetIntField(object,
2759                     fieldIds.duration);
2760 
2761             // Set the type of the video transition.
2762             pSettings->VideoTransitionType =
2763                     (M4VSS3GPP_VideoTransitionType)videoEditJava_getVideoTransitionJavaToC(
2764                              &converted, pEnv->GetIntField(object, fieldIds.videoTransitionType));
2765 
2766             // Check if the video transition type is valid.
2767             videoEditJava_checkAndThrowIllegalArgumentException(pResult, pEnv, !converted,
2768                             "transition.videoTransitionType is invalid");
2769         }
2770 
2771         // Check if the video transition type could be set.
2772         if (*pResult)
2773         {
2774             // Set the external transition video effect function.
2775             pSettings->ExtVideoTransitionFct = M4OSA_NULL;
2776 
2777             // Set the context of the external transition video effect function.
2778             pSettings->pExtVideoTransitionFctCtxt = M4OSA_NULL;
2779 
2780             // Set the type of the audio transition.
2781             pSettings->AudioTransitionType =
2782                     (M4VSS3GPP_AudioTransitionType)videoEditJava_getAudioTransitionJavaToC(
2783                             &converted, pEnv->GetIntField(object, fieldIds.audioTransitionType));
2784 
2785             // Check if the audio transition type is valid.
2786             videoEditJava_checkAndThrowIllegalArgumentException(pResult, pEnv, !converted,
2787                              "transition.audioTransitionType is invalid");
2788         }
2789 
2790         // Check if the audio transition type could be set.
2791         if (*pResult)
2792         {
2793             // Set the transition behaviour.
2794             pSettings->TransitionBehaviour =
2795                     (M4VSS3GPP_TransitionBehaviour)videoEditJava_getTransitionBehaviourJavaToC(
2796                             &converted, pEnv->GetIntField(object, fieldIds.transitionBehaviour));
2797 
2798             // Check if the transition behaviour is valid.
2799             videoEditJava_checkAndThrowIllegalArgumentException(pResult, pEnv, !converted,
2800                                                     "transition.transitionBehaviour is invalid");
2801         }
2802 
2803         // Check if the audio transition behaviour could be set.
2804         if (*pResult)
2805         {
2806             // Check if a slide transition or alpha magic setting object is expected.
2807             if ((int)pSettings->VideoTransitionType == M4xVSS_kVideoTransitionType_SlideTransition)
2808             {
2809                 // Set the slide transition settings.
2810                 videoEditClasses_getSlideTransitionSettings(pResult, pEnv, slideSettings,
2811                                      &pSettings->xVSS.transitionSpecific.pSlideTransitionSettings);
2812             }
2813             else if ((int)pSettings->VideoTransitionType == M4xVSS_kVideoTransitionType_AlphaMagic)
2814             {
2815                 // Set the alpha magic settings.
2816                 videoEditClasses_getAlphaMagicSettings(pResult, pEnv, alphaSettings,
2817                                   &pSettings->xVSS.transitionSpecific.pAlphaMagicSettings);
2818             }
2819         }
2820 
2821         // Check if settings could be set.
2822         if (*pResult)
2823         {
2824             // Return the settings.
2825             (*ppSettings) = pSettings;
2826         }
2827         else
2828         {
2829             // Free the settings.
2830             videoEditClasses_freeTransitionSettings(&pSettings);
2831         }
2832     }
2833 }
2834 
2835 void
videoEditClasses_freeTransitionSettings(M4VSS3GPP_TransitionSettings ** ppSettings)2836 videoEditClasses_freeTransitionSettings(
2837                 M4VSS3GPP_TransitionSettings**      ppSettings)
2838 {
2839     // Check if memory was allocated for the TransitionSettings.
2840     if (M4OSA_NULL != (*ppSettings))
2841     {
2842         // Log the function call.
2843         VIDEOEDIT_LOG_FUNCTION(ANDROID_LOG_INFO, "VIDEO_EDITOR_CLASSES",
2844                                "videoEditClasses_freeTransitionSettings()");
2845 
2846         // Check if a slide transition or alpha magic setting structure is expected.
2847         if ((int)(*ppSettings)->VideoTransitionType == M4xVSS_kVideoTransitionType_SlideTransition)
2848         {
2849             // Free the slide transition settings.
2850             videoEditClasses_freeSlideTransitionSettings(
2851                                &(*ppSettings)->xVSS.transitionSpecific.pSlideTransitionSettings);
2852         }
2853         else
2854         {
2855             // Free the alpha magic settings.
2856             videoEditClasses_freeAlphaMagicSettings(
2857                               &(*ppSettings)->xVSS.transitionSpecific.pAlphaMagicSettings);
2858         }
2859 
2860         // Free the settings structure.
2861         videoEditOsal_free((*ppSettings));
2862         (*ppSettings) = M4OSA_NULL;
2863     }
2864 }
2865 
2866 #ifdef VIDEOEDIT_LOGGING_ENABLED
2867 void
videoEditClasses_logTransitionSettings(M4VSS3GPP_TransitionSettings * pSettings,int indentation)2868 videoEditClasses_logTransitionSettings(
2869                 M4VSS3GPP_TransitionSettings*       pSettings,
2870                 int                                 indentation)
2871 {
2872     // Check if memory was allocated for the TransitionSettings.
2873     if (M4OSA_NULL != pSettings)
2874     {
2875         VIDEOEDIT_LOG_SETTING(ANDROID_LOG_INFO, "VIDEO_EDITOR_CLASSES",
2876                                "%*c uiTransitionDuration:       %u ms", indentation, ' ',
2877                                   (unsigned int)pSettings->uiTransitionDuration);
2878         VIDEOEDIT_LOG_SETTING(ANDROID_LOG_INFO, "VIDEO_EDITOR_CLASSES",
2879                            "%*c VideoTransitionType:        %s",    indentation, ' ',
2880                            videoEditJava_getVideoTransitionString(pSettings->VideoTransitionType));
2881         VIDEOEDIT_LOG_SETTING(ANDROID_LOG_INFO, "VIDEO_EDITOR_CLASSES",
2882                               "%*c ExtVideoTransitionFct:      %s",    indentation, ' ',
2883                               (M4OSA_NULL != pSettings->ExtVideoTransitionFct) ? "set" : "<null>");
2884         VIDEOEDIT_LOG_SETTING(ANDROID_LOG_INFO, "VIDEO_EDITOR_CLASSES",
2885                          "%*c pExtVideoTransitionFctCtxt: %s",    indentation, ' ',
2886                          (M4OSA_NULL != pSettings->pExtVideoTransitionFctCtxt) ? "set" : "<null>");
2887         VIDEOEDIT_LOG_SETTING(ANDROID_LOG_INFO, "VIDEO_EDITOR_CLASSES",
2888                          "%*c AudioTransitionType:        %s",    indentation, ' ',
2889                           videoEditJava_getAudioTransitionString(pSettings->AudioTransitionType));
2890         VIDEOEDIT_LOG_SETTING(ANDROID_LOG_INFO, "VIDEO_EDITOR_CLASSES",
2891                       "%*c TransitionBehaviour:        %s",    indentation, ' ',
2892                       videoEditJava_getTransitionBehaviourString(pSettings->TransitionBehaviour));
2893 
2894         // Check if a slide transition or alpha magic setting structure is expected.
2895         if ((int)pSettings->VideoTransitionType == M4xVSS_kVideoTransitionType_SlideTransition)
2896         {
2897             // Log the slide transition settings.
2898             VIDEOEDIT_LOG_SETTING(ANDROID_LOG_INFO, "VIDEO_EDITOR_CLASSES",
2899                                    "%*c pSlideTransitionSettings:", indentation, ' ');
2900             videoEditClasses_logSlideTransitionSettings\
2901             (pSettings->xVSS.transitionSpecific.pSlideTransitionSettings,
2902             indentation + VIDEOEDIT_LOG_INDENTATION);
2903         }
2904         else
2905         {
2906             // Log the alpha magic settings.
2907             VIDEOEDIT_LOG_SETTING(ANDROID_LOG_INFO, "VIDEO_EDITOR_CLASSES",
2908                                    "%*c pAlphaMagicSettings:", indentation, ' ');
2909             videoEditClasses_logAlphaMagicSettings\
2910             (pSettings->xVSS.transitionSpecific.pAlphaMagicSettings,
2911             indentation + VIDEOEDIT_LOG_INDENTATION);
2912         }
2913     }
2914     else
2915     {
2916         VIDEOEDIT_LOG_SETTING(ANDROID_LOG_INFO, "VIDEO_EDITOR_CLASSES",
2917                                "%*c <null>", indentation, ' ');
2918     }
2919 }
2920 #endif
2921 #ifdef VIDEOEDIT_LOGGING_ENABLED
2922 void
videoEditPropClass_logProperties(VideoEditPropClass_Properties * pProperties,int indentation)2923 videoEditPropClass_logProperties(
2924                 VideoEditPropClass_Properties*                   pProperties,
2925                 int                                 indentation)
2926 {
2927     // Check if memory was allocated for the Properties.
2928     if (M4OSA_NULL != pProperties)
2929     {
2930         VIDEOEDIT_LOG_SETTING(ANDROID_LOG_INFO, "VIDEO_EDITOR_PROP_CLASSES",
2931             "%*c uiClipDuration:                   %u",       indentation, ' ',
2932             (unsigned int)pProperties->uiClipDuration);
2933         VIDEOEDIT_LOG_SETTING(ANDROID_LOG_INFO, "VIDEO_EDITOR_PROP_CLASSES",
2934             "%*c FileType:                         %s",       indentation, ' ',
2935             videoEditJava_getFileTypeString(pProperties->FileType));
2936 
2937         VIDEOEDIT_LOG_SETTING(ANDROID_LOG_INFO, "VIDEO_EDITOR_PROP_CLASSES",
2938             "%*c VideoStreamType:                  %s",       indentation, ' ',
2939             videoEditJava_getVideoFormatString(pProperties->VideoStreamType));
2940         VIDEOEDIT_LOG_SETTING(ANDROID_LOG_INFO, "VIDEO_EDITOR_PROP_CLASSES",
2941             "%*c uiClipVideoDuration:              %u",       indentation, ' ',
2942             (unsigned int)pProperties->uiClipVideoDuration);
2943 
2944         VIDEOEDIT_LOG_SETTING(ANDROID_LOG_INFO, "VIDEO_EDITOR_PROP_CLASSES",
2945             "%*c uiVideoBitrate:                   %s",       indentation, ' ',
2946             videoEditJava_getBitrateString(pProperties->uiVideoBitrate));
2947 
2948         VIDEOEDIT_LOG_SETTING(ANDROID_LOG_INFO, "VIDEO_EDITOR_PROP_CLASSES",
2949             "%*c uiVideoWidth:                     %u",       indentation, ' ',
2950             (unsigned int)pProperties->uiVideoWidth);
2951 
2952         VIDEOEDIT_LOG_SETTING(ANDROID_LOG_INFO, "VIDEO_EDITOR_PROP_CLASSES",
2953             "%*c uiVideoHeight:                    %u",       indentation, ' ',
2954             (unsigned int)(unsigned int)pProperties->uiVideoHeight);
2955 
2956         VIDEOEDIT_LOG_SETTING(ANDROID_LOG_INFO, "VIDEO_EDITOR_PROP_CLASSES",
2957             "%*c fAverageFrameRate:                %.3f",     indentation, ' ',
2958             pProperties->fAverageFrameRate);
2959 
2960         VIDEOEDIT_LOG_SETTING(ANDROID_LOG_INFO, "VIDEO_EDITOR_PROP_CLASSES",
2961             "%*c AudioStreamType:                  %s",       indentation, ' ',
2962             videoEditJava_getAudioFormatString(pProperties->AudioStreamType));
2963 
2964         VIDEOEDIT_LOG_SETTING(ANDROID_LOG_INFO, "VIDEO_EDITOR_PROP_CLASSES",
2965             "%*c uiClipAudioDuration:              %u",       indentation, ' ',
2966             (unsigned int)pProperties->uiClipAudioDuration);
2967 
2968         VIDEOEDIT_LOG_SETTING(ANDROID_LOG_INFO, "VIDEO_EDITOR_PROP_CLASSES",
2969             "%*c uiAudioBitrate:                   %s",       indentation, ' ',
2970             videoEditJava_getBitrateString(pProperties->uiAudioBitrate));
2971 
2972         VIDEOEDIT_LOG_SETTING(ANDROID_LOG_INFO, "VIDEO_EDITOR_PROP_CLASSES",
2973             "%*c uiNbChannels:                     %u",       indentation, ' ',
2974             (unsigned int)pProperties->uiNbChannels);
2975 
2976         VIDEOEDIT_LOG_SETTING(ANDROID_LOG_INFO, "VIDEO_EDITOR_PROP_CLASSES",
2977              "%*c uiSamplingFrequency:              %u",       indentation, ' ',
2978             (unsigned int)pProperties->uiSamplingFrequency);
2979     }
2980     else
2981     {
2982         VIDEOEDIT_LOG_SETTING(ANDROID_LOG_INFO, "VIDEO_EDITOR_PROP_CLASSES",
2983             "%*c <null>", indentation, ' ');
2984     }
2985 }
2986 #endif
2987 
2988 
2989 void
videoEditClasses_createVersion(bool * pResult,JNIEnv * pEnv,M4_VersionInfo * pVersionInfo,jobject * pObject)2990 videoEditClasses_createVersion(
2991                 bool*                               pResult,
2992                 JNIEnv*                             pEnv,
2993                 M4_VersionInfo*                     pVersionInfo,
2994                 jobject*                            pObject)
2995 {
2996 
2997     VideoEditJava_VersionFieldIds fieldIds;
2998     jclass                clazz    = NULL;
2999     jobject               object   = NULL;
3000     memset(&fieldIds, 0, sizeof(VideoEditJava_VersionFieldIds));
3001     // Check if the previous action succeeded.
3002     if (*pResult)
3003     {
3004         // Log the function call.
3005         VIDEOEDIT_LOG_FUNCTION(ANDROID_LOG_INFO, "VIDEO_EDITOR_CLASSES",
3006                                "videoEditClasses_createVersion()");
3007 
3008         // Retrieve the class.
3009         videoEditJava_getVersionClass(pResult, pEnv, &clazz);
3010 
3011         // Retrieve the field ids.
3012         videoEditJava_getVersionFieldIds(pResult, pEnv, &fieldIds);
3013     }
3014 
3015     // Only create an object if the class and fields could be located.
3016     if (*pResult)
3017     {
3018         // Allocate a new object.
3019         object = pEnv->AllocObject(clazz);
3020 
3021         // check if alloc is done
3022         videoEditJava_checkAndThrowRuntimeException(pResult, pEnv,
3023                                                     (NULL == object),
3024                                                     M4ERR_ALLOC);
3025         if (NULL != object)
3026         {
3027             // Set the major field.
3028             pEnv->SetIntField(object, fieldIds.major, pVersionInfo->m_major);
3029 
3030             // Set the minor field.
3031             pEnv->SetIntField(object, fieldIds.minor, pVersionInfo->m_minor);
3032 
3033             // Set the revision field.
3034             pEnv->SetIntField(object, fieldIds.revision, pVersionInfo->m_revision);
3035 
3036             // Return the object.
3037             (*pObject) = object;
3038         }
3039     }
3040 }
3041 
3042 #ifdef VIDEOEDIT_LOGGING_ENABLED
3043 void
videoEditClasses_logVersion(M4_VersionInfo * pVersionInfo,int indentation)3044 videoEditClasses_logVersion(
3045                 M4_VersionInfo*                     pVersionInfo,
3046                 int                                 indentation)
3047 {
3048     // Check if memory was allocated for the Version.
3049     if (M4OSA_NULL != pVersionInfo)
3050     {
3051         VIDEOEDIT_LOG_SETTING(ANDROID_LOG_INFO, "VIDEO_EDITOR_CLASSES",
3052                              "%*c major:    %u ms", indentation, ' ',
3053                              (unsigned int)pVersionInfo->m_major);
3054         VIDEOEDIT_LOG_SETTING(ANDROID_LOG_INFO, "VIDEO_EDITOR_CLASSES",
3055                               "%*c minor:    %u",    indentation, ' ',
3056                               (unsigned int)pVersionInfo->m_minor);
3057         VIDEOEDIT_LOG_SETTING(ANDROID_LOG_INFO, "VIDEO_EDITOR_CLASSES",
3058                              "%*c revision: %u",    indentation, ' ',
3059                              (unsigned int)pVersionInfo->m_revision);
3060     }
3061     else
3062     {
3063         VIDEOEDIT_LOG_SETTING(ANDROID_LOG_INFO, "VIDEO_EDITOR_CLASSES",
3064                               "%*c <null>", indentation, ' ');
3065     }
3066 }
3067 #endif
3068 
3069 
3070 void*
videoEditClasses_getContext(bool * pResult,JNIEnv * pEnv,jobject object)3071 videoEditClasses_getContext(
3072                 bool*                               pResult,
3073                 JNIEnv*                             pEnv,
3074                 jobject                             object)
3075 {
3076     void*                pContext = M4OSA_NULL;
3077     jclass               clazz    = NULL;
3078     VideoEditJava_EngineFieldIds fieldIds = {NULL};
3079 
3080     // Check if the previous action succeeded.
3081     if (*pResult)
3082     {
3083         // Log the function call.
3084         VIDEOEDIT_LOG_FUNCTION(ANDROID_LOG_INFO, "VIDEO_EDITOR_CLASSES",
3085                                "videoEditClasses_getContext()");
3086 
3087         // Retrieve the class.
3088         videoEditJava_getEngineClass(pResult, pEnv, &clazz);
3089 
3090         // Retrieve the field ids.
3091         videoEditJava_getEngineFieldIds(pResult, pEnv, &fieldIds);
3092     }
3093 
3094     // Check if the class and field ids could be located.
3095     if (*pResult)
3096     {
3097         // Retrieve the context pointer.
3098         pContext = (void *)pEnv->GetIntField(object, fieldIds.context);
3099     }
3100 
3101     // Return the context pointer.
3102     return(pContext);
3103 }
3104 
3105 void
videoEditClasses_setContext(bool * pResult,JNIEnv * pEnv,jobject object,void * pContext)3106 videoEditClasses_setContext(
3107                 bool*                               pResult,
3108                 JNIEnv*                             pEnv,
3109                 jobject                             object,
3110                 void*                               pContext)
3111 {
3112     jclass               clazz    = NULL;
3113     VideoEditJava_EngineFieldIds fieldIds = {NULL};
3114 
3115     // Check if the previous action succeeded.
3116     if (*pResult)
3117     {
3118         // Log the function call.
3119         VIDEOEDIT_LOG_FUNCTION(ANDROID_LOG_INFO, "VIDEO_EDITOR_CLASSES",
3120                                "videoEditClasses_setContext()");
3121 
3122         // Retrieve the class.
3123         videoEditJava_getEngineClass(pResult, pEnv, &clazz);
3124 
3125         // Retrieve the field ids.
3126         videoEditJava_getEngineFieldIds(pResult, pEnv, &fieldIds);
3127     }
3128 
3129     // Check if the class and field ids could be located.
3130     if (*pResult)
3131     {
3132         // Set the context field.
3133         VIDEOEDIT_LOG_FUNCTION(ANDROID_LOG_INFO, "VIDEO_EDITOR_CLASSES",
3134                         "The context value from JAVA before setting is = 0x%x",
3135                         pEnv->GetIntField(object, fieldIds.context));
3136 
3137         pEnv->SetIntField(object, fieldIds.context, (int)pContext);
3138         M4OSA_TRACE1_1("The context value in JNI is = 0x%x",pContext);
3139 
3140         VIDEOEDIT_LOG_FUNCTION(ANDROID_LOG_INFO, "VIDEO_EDITOR_CLASSES",
3141                          "The context value from JAVA after setting is = 0x%x",
3142                          pEnv->GetIntField(object, fieldIds.context));
3143     }
3144 }
3145 
3146