• 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                     }
1858                 }
1859 
1860                 // Check if the transition settings array contains items.
1861                 if (transitionSettingsArraySize > 0)
1862                 {
1863                     // Allocate memory for the transition settings array.
1864                     pSettings->pTransitionList =
1865                             (M4VSS3GPP_TransitionSettings **)videoEditOsal_alloc(pResult,
1866                                 pEnv, transitionSettingsArraySize * sizeof(M4VSS3GPP_TransitionSettings *),
1867                                 "TransitionSettingsArray");
1868                     if (*pResult)
1869                     {
1870                         // Loop over all transition settings objects.
1871                         for (int i = 0; ((*pResult) && (i < transitionSettingsArraySize)); i++)
1872                         {
1873                             // Get the transition settings object.
1874                             transitionSettings =
1875                                     pEnv->GetObjectArrayElement(transitionSettingsArray, i);
1876 
1877                             // Get the transition settings.
1878                             videoEditClasses_getTransitionSettings(pResult, pEnv,
1879                                     transitionSettings, &pSettings->pTransitionList[i]);
1880                         }
1881                     }
1882                 }
1883 
1884                 // Check if the effect settings array contains items.
1885                 if (effectSettingsArraySize > 0)
1886                 {
1887                     // Allocate memory for the effect settings array.
1888                     pSettings->Effects = (M4VSS3GPP_EffectSettings*)videoEditOsal_alloc(pResult,
1889                                 pEnv,
1890                                 effectSettingsArraySize * sizeof(M4VSS3GPP_EffectSettings),
1891                                 "EffectSettingsArray");
1892                     if (*pResult)
1893                     {
1894                         // Loop over all effect settings objects.
1895                         for (int i = 0; ((*pResult) && (i < effectSettingsArraySize)); i++)
1896                         {
1897                             // Get the effect settings object.
1898                             effectSettings = pEnv->GetObjectArrayElement(effectSettingsArray, i);
1899 
1900                             // Get the effect settings.
1901                             videoEditClasses_getEffectSettings(pResult, pEnv, effectSettings,
1902                                     &pSettings->Effects[i]);
1903                         }
1904                     }
1905                 }
1906 
1907                 // Check if the clips, transitions and effects could be set.
1908                 if (*pResult)
1909                 {
1910                     // Set the number of effects in the clip.
1911                     pSettings->nbEffects = (M4OSA_UInt8)effectSettingsArraySize;
1912 
1913                     // Set the frame rate of the output video.
1914                     pSettings->videoFrameRate =
1915                         (M4VIDEOEDITING_VideoFramerate)videoEditJava_getVideoFrameRateJavaToC(
1916                              &converted, pEnv->GetIntField(object, fieldIds.videoFrameRate));
1917 
1918                     // Check if the frame rate is valid.
1919                     videoEditJava_checkAndThrowIllegalArgumentException(pResult, pEnv,
1920                         !converted, "editSettings.videoFrameRate is invalid");
1921                 }
1922 
1923                 // Check if the frame rate could be set.
1924                 if (*pResult)
1925                 {
1926                     // Set the path of the output file.
1927                     pSettings->pOutputFile = (M4OSA_Char*)videoEditJava_getString(pResult, pEnv,
1928                         object, fieldIds.outputFile, &pSettings->uiOutputPathSize);
1929                 }
1930 
1931                 // Check if path of the output file could be set.
1932                 if (*pResult)
1933                 {
1934                     // Set the path of the temporary file produced when using
1935                     // the constant memory 3gp writer.
1936                     pSettings->pTemporaryFile = M4OSA_NULL;
1937 
1938                     // Set the output video size.
1939                     pSettings->xVSS.outputVideoSize =
1940                         (M4VIDEOEDITING_VideoFrameSize)videoEditJava_getVideoFrameSizeJavaToC(
1941                                 &converted, pEnv->GetIntField(object, fieldIds.videoFrameSize));
1942 
1943                     // Check if the output video size is valid.
1944                     videoEditJava_checkAndThrowIllegalArgumentException(pResult, pEnv,
1945                         !converted, "editSettings.videoFrameSize is invalid");
1946                 }
1947 
1948                 // Check if the output video size could be set.
1949                 if (*pResult)
1950                 {
1951                     // Set the output video format.
1952                     pSettings->xVSS.outputVideoFormat =
1953                         (M4VIDEOEDITING_VideoFormat)videoEditJava_getVideoFormatJavaToC(
1954                                &converted, pEnv->GetIntField(object, fieldIds.videoFormat));
1955 
1956                     // Check if the output video format is valid.
1957                     videoEditJava_checkAndThrowIllegalArgumentException(pResult, pEnv,
1958                         !converted, "editSettings.videoFormat is invalid");
1959                 }
1960 
1961                 // Check if the output video format could be set.
1962                 if (*pResult)
1963                 {
1964                     // Set the output audio format.
1965                     pSettings->xVSS.outputAudioFormat =
1966                             (M4VIDEOEDITING_AudioFormat)videoEditJava_getAudioFormatJavaToC(
1967                                   &converted, pEnv->GetIntField(object, fieldIds.audioFormat));
1968 
1969                     // Check if the output audio format is valid.
1970                     videoEditJava_checkAndThrowIllegalArgumentException(pResult, pEnv,
1971                             !converted, "editSettings.audioFormat is invalid");
1972                 }
1973 
1974                 // Check if the output audio format could be set.
1975                 if (*pResult)
1976                 {
1977                     // Set the output audio sampling frequency when not replacing the audio,
1978                     // or replacing it with MP3 audio.
1979                     pSettings->xVSS.outputAudioSamplFreq =
1980                         (M4VIDEOEDITING_AudioSamplingFrequency)\
1981                             videoEditJava_getAudioSamplingFrequencyJavaToC(
1982                                 &converted, pEnv->GetIntField(object, fieldIds.audioSamplingFreq));
1983 
1984                     // Check if the output audio sampling frequency is valid.
1985                     videoEditJava_checkAndThrowIllegalArgumentException(pResult, pEnv,
1986                             !converted, "editSettings.audioSamplingFreq is invalid");
1987                 }
1988 
1989                 // Check if the output audio sampling frequency could be set.
1990                 if (*pResult)
1991                 {
1992                     // Check if the number of audio channels is valid.
1993                     videoEditJava_checkAndThrowIllegalArgumentException(pResult, pEnv,
1994                         ((0 != audioChannels ) ||
1995                         ((M4VIDEOEDITING_kNoneAudio != pSettings->xVSS.outputAudioFormat) &&
1996                         (M4VIDEOEDITING_kNullAudio != pSettings->xVSS.outputAudioFormat) ) ) &&
1997                         (1 != audioChannels ) &&
1998                         (2 != audioChannels ),
1999                         "editSettings.audioChannels must be set to 0, 1 or 2");
2000                 }
2001 
2002                 // Check if the number of audio channels is valid.
2003                 if (*pResult)
2004                 {
2005                     // Set the maximum output file size (MMS usecase).
2006                     pSettings->xVSS.outputFileSize = (M4OSA_UInt32)pEnv->GetIntField(object,
2007                             fieldIds.maxFileSize);
2008 
2009                     // Whether or not the audio is mono, only valid for AAC.
2010                     pSettings->xVSS.bAudioMono = (M4OSA_Bool)(1 == audioChannels);
2011 
2012                     // Set the output video bitrate.
2013                     pSettings->xVSS.outputVideoBitrate = (M4OSA_UInt32)pEnv->GetIntField(object,
2014                             fieldIds.videoBitrate);
2015 
2016                     // Set the output video profile.
2017                     pSettings->xVSS.outputVideoProfile = (M4OSA_UInt32)pEnv->GetIntField(object,
2018                             fieldIds.videoProfile);
2019 
2020                     // Set the output video level.
2021                     pSettings->xVSS.outputVideoLevel = (M4OSA_UInt32)pEnv->GetIntField(object,
2022                             fieldIds.videoLevel);
2023 
2024                     // Set the output audio bitrate.
2025                     pSettings->xVSS.outputAudioBitrate = (M4OSA_UInt32)pEnv->GetIntField(object,
2026                             fieldIds.audioBitrate);
2027 
2028                     // Set the background music settings.
2029                     videoEditClasses_getBackgroundMusicSettings(pResult, pEnv,
2030                             backgroundMusicSettings, &pSettings->xVSS.pBGMtrack);
2031 
2032                     // Set the text rendering function (will be set elsewhere).
2033                     pSettings->xVSS.pTextRenderingFct = M4OSA_NULL;
2034                     pSettings->PTVolLevel =
2035                             (M4OSA_Float)pEnv->GetIntField(object, fieldIds.primaryTrackVolume);
2036                 }
2037             }
2038 
2039             // Check if settings could be set.
2040             if (*pResult)
2041             {
2042                 // Return the settings.
2043                 (*ppSettings) = pSettings;
2044             }
2045             else
2046             {
2047                 // Free the settings.
2048                 videoEditClasses_freeEditSettings(&pSettings);
2049             }
2050         }
2051     }
2052 }
2053 
2054 void
videoEditClasses_freeEditSettings(M4VSS3GPP_EditSettings ** ppSettings)2055 videoEditClasses_freeEditSettings(
2056                 M4VSS3GPP_EditSettings**            ppSettings)
2057 {
2058     // Check if memory was allocated for the EditSettings.
2059     if (M4OSA_NULL != (*ppSettings))
2060     {
2061         // Log the function call.
2062         VIDEOEDIT_LOG_FUNCTION(ANDROID_LOG_INFO, "VIDEO_EDITOR_CLASSES",
2063                 "videoEditClasses_freeEditSettings()");
2064 
2065         // Free the background music settings.
2066         videoEditClasses_freeBackgroundMusicSettings(&(*ppSettings)->xVSS.pBGMtrack);
2067 
2068         // Free the path of the output file.
2069         videoEditOsal_free((*ppSettings)->pOutputFile);
2070         (*ppSettings)->pOutputFile = M4OSA_NULL;
2071         (*ppSettings)->uiOutputPathSize = 0;
2072 
2073         // Check if the EffectSettings should be freed.
2074         if (M4OSA_NULL != (*ppSettings)->Effects)
2075         {
2076             // Loop over all effect settings.
2077             for (int i = 0; i < (*ppSettings)->nbEffects; i++)
2078             {
2079                 // Free the effect settings.
2080                 videoEditClasses_freeEffectSettings(&(*ppSettings)->Effects[i]);
2081             }
2082 
2083             // Free the memory for the effect settings array.
2084             videoEditOsal_free((*ppSettings)->Effects);
2085             (*ppSettings)->Effects = M4OSA_NULL;
2086         }
2087 
2088         // Reset the number of effects in the clip.
2089         (*ppSettings)->nbEffects = 0;
2090 
2091         // Check if there are clips.
2092         if (0 < (*ppSettings)->uiClipNumber)
2093         {
2094             // Check if the TransitionSettings should be freed.
2095             if (M4OSA_NULL != (*ppSettings)->pTransitionList)
2096             {
2097                 // Loop over all transition settings.
2098                 for (int i = 0; i < ((*ppSettings)->uiClipNumber - 1); i++)
2099                 {
2100                     // Free the transition settings.
2101                     videoEditClasses_freeTransitionSettings(&(*ppSettings)->pTransitionList[i]);
2102                 }
2103 
2104                 // Free the memory for the transition settings array.
2105                 videoEditOsal_free((*ppSettings)->pTransitionList);
2106                 (*ppSettings)->pTransitionList = M4OSA_NULL;
2107             }
2108 
2109             // Check if the ClipSettings should be freed.
2110             if (M4OSA_NULL != (*ppSettings)->pClipList)
2111             {
2112                 // Loop over all clip settings.
2113                 for (int i = 0; i < (*ppSettings)->uiClipNumber; i++)
2114                 {
2115                     // Free the clip settings.
2116                     videoEditClasses_freeClipSettings(&(*ppSettings)->pClipList[i]);
2117                 }
2118 
2119                 // Free the memory for the clip settings array.
2120                 videoEditOsal_free((*ppSettings)->pClipList);
2121                 (*ppSettings)->pClipList = M4OSA_NULL;
2122             }
2123         }
2124 
2125         // Reset the number of clips.
2126         (*ppSettings)->uiClipNumber = 0;
2127 
2128         // Free the settings structure.
2129         videoEditOsal_free((*ppSettings));
2130         (*ppSettings) = M4OSA_NULL;
2131     }
2132 }
2133 
2134 #ifdef VIDEOEDIT_LOGGING_ENABLED
2135 void
videoEditClasses_logEditSettings(M4VSS3GPP_EditSettings * pSettings,int indentation)2136 videoEditClasses_logEditSettings(
2137                 M4VSS3GPP_EditSettings*             pSettings,
2138                 int                                 indentation)
2139 {
2140     // Check if memory was allocated for the EditSettings.
2141     if (M4OSA_NULL != pSettings)
2142     {
2143         VIDEOEDIT_LOG_SETTING(ANDROID_LOG_INFO, "VIDEO_EDITOR_CLASSES",
2144             "%*c uiClipNumber:         %d", indentation, ' ',
2145             pSettings->uiClipNumber);
2146         VIDEOEDIT_LOG_SETTING(ANDROID_LOG_INFO, "VIDEO_EDITOR_CLASSES",
2147             "%*c uiMasterClip:         %d", indentation, ' ',
2148             pSettings->uiMasterClip);
2149         VIDEOEDIT_LOG_SETTING(ANDROID_LOG_INFO, "VIDEO_EDITOR_CLASSES",
2150             "%*c pClipList:            %s", indentation, ' ',
2151             (M4OSA_NULL != pSettings->pClipList) ? " " : "<null>");
2152         if (M4OSA_NULL != pSettings->pClipList)
2153         {
2154             indentation += VIDEOEDIT_LOG_INDENTATION;
2155             for (int i = 0; i < pSettings->uiClipNumber; i++)
2156             {
2157                 VIDEOEDIT_LOG_SETTING(ANDROID_LOG_INFO, "VIDEO_EDITOR_CLASSES",
2158                     "%*c pClipList[%d]:", indentation, ' ',
2159                     i);
2160                 videoEditClasses_logClipSettings(pSettings->pClipList[i],
2161                     indentation + VIDEOEDIT_LOG_INDENTATION);
2162             }
2163             indentation -= VIDEOEDIT_LOG_INDENTATION;
2164         }
2165         VIDEOEDIT_LOG_SETTING(ANDROID_LOG_INFO, "VIDEO_EDITOR_CLASSES",
2166             "%*c pTransitionList:      %s", indentation, ' ',
2167             (M4OSA_NULL != pSettings->pTransitionList) ? " " : "<null>");
2168         if (M4OSA_NULL != pSettings->pTransitionList)
2169         {
2170             indentation += VIDEOEDIT_LOG_INDENTATION;
2171             for (int i = 0; i < (pSettings->uiClipNumber - 1); i++)
2172             {
2173                 VIDEOEDIT_LOG_SETTING(ANDROID_LOG_INFO, "VIDEO_EDITOR_CLASSES",
2174                     "%*c pTransitionList[%d]:", indentation, ' ', i);
2175                 videoEditClasses_logTransitionSettings(pSettings->pTransitionList[i],
2176                     indentation + VIDEOEDIT_LOG_INDENTATION);
2177             }
2178             indentation -= VIDEOEDIT_LOG_INDENTATION;
2179         }
2180         VIDEOEDIT_LOG_SETTING(ANDROID_LOG_INFO, "VIDEO_EDITOR_CLASSES",
2181             "%*c Effects:              %s", indentation, ' ',
2182             (M4OSA_NULL != pSettings->Effects)   ? " " : "<null>");
2183         if (M4OSA_NULL != pSettings->Effects)
2184         {
2185             indentation += VIDEOEDIT_LOG_INDENTATION;
2186             for (int i = 0; i < pSettings->nbEffects; i++)
2187             {
2188                 VIDEOEDIT_LOG_SETTING(ANDROID_LOG_INFO, "VIDEO_EDITOR_CLASSES",
2189                     "%*c Effects[%d]:", indentation, ' ',  i);
2190                 videoEditClasses_logEffectSettings(&pSettings->Effects[i],
2191                     indentation + VIDEOEDIT_LOG_INDENTATION);
2192             }
2193             indentation -= VIDEOEDIT_LOG_INDENTATION;
2194         }
2195         VIDEOEDIT_LOG_SETTING(ANDROID_LOG_INFO, "VIDEO_EDITOR_CLASSES",
2196             "%*c nbEffects:            %d", indentation, ' ',
2197             pSettings->nbEffects);
2198         VIDEOEDIT_LOG_SETTING(ANDROID_LOG_INFO, "VIDEO_EDITOR_CLASSES",
2199             "%*c videoFrameRate:       %s", indentation, ' ',
2200             videoEditJava_getVideoFrameRateString(pSettings->videoFrameRate));
2201         VIDEOEDIT_LOG_SETTING(ANDROID_LOG_INFO, "VIDEO_EDITOR_CLASSES",
2202             "%*c pOutputFile:          %s", indentation, ' ',
2203             (M4OSA_NULL != pSettings->pOutputFile) ? (char*)pSettings->pOutputFile : "<null>");
2204         VIDEOEDIT_LOG_SETTING(ANDROID_LOG_INFO, "VIDEO_EDITOR_CLASSES",
2205             "%*c uiOutputPathSize:     %u", indentation, ' ',
2206             (unsigned int)pSettings->uiOutputPathSize);
2207         VIDEOEDIT_LOG_SETTING(ANDROID_LOG_INFO, "VIDEO_EDITOR_CLASSES",
2208             "%*c pTemporaryFile:       %s", indentation, ' ',
2209             (M4OSA_NULL != pSettings->pTemporaryFile) ?\
2210              (char*)pSettings->pTemporaryFile : "<null>");
2211         VIDEOEDIT_LOG_SETTING(ANDROID_LOG_INFO, "VIDEO_EDITOR_CLASSES",
2212             "%*c outputVideoSize:      %s", indentation, ' ',
2213             videoEditJava_getVideoFrameSizeString(pSettings->xVSS.outputVideoSize));
2214         VIDEOEDIT_LOG_SETTING(ANDROID_LOG_INFO, "VIDEO_EDITOR_CLASSES",
2215             "%*c outputVideoFormat:    %s", indentation, ' ',
2216             videoEditJava_getVideoFormatString(pSettings->xVSS.outputVideoFormat));
2217         VIDEOEDIT_LOG_SETTING(ANDROID_LOG_INFO, "VIDEO_EDITOR_CLASSES",
2218             "%*c outputVideoProfile:    %u", indentation, ' ',
2219             videoEditJava_getVideoFormatString(pSettings->xVSS.outputVideoProfile));
2220         VIDEOEDIT_LOG_SETTING(ANDROID_LOG_INFO, "VIDEO_EDITOR_CLASSES",
2221             "%*c outputVideoLevel:    %u", indentation, ' ',
2222             videoEditJava_getVideoFormatString(pSettings->xVSS.outputVideoLevel));
2223         VIDEOEDIT_LOG_SETTING(ANDROID_LOG_INFO, "VIDEO_EDITOR_CLASSES",
2224             "%*c outputAudioFormat:    %s", indentation, ' ',
2225             videoEditJava_getAudioFormatString(pSettings->xVSS.outputAudioFormat));
2226         VIDEOEDIT_LOG_SETTING(ANDROID_LOG_INFO, "VIDEO_EDITOR_CLASSES",
2227             "%*c outputAudioSamplFreq: %s", indentation, ' ',
2228             videoEditJava_getAudioSamplingFrequencyString(pSettings->xVSS.outputAudioSamplFreq));
2229         VIDEOEDIT_LOG_SETTING(ANDROID_LOG_INFO, "VIDEO_EDITOR_CLASSES",
2230             "%*c outputFileSize:       %u", indentation, ' ',
2231             (unsigned int)pSettings->xVSS.outputFileSize);
2232         VIDEOEDIT_LOG_SETTING(ANDROID_LOG_INFO, "VIDEO_EDITOR_CLASSES",
2233             "%*c bAudioMono:           %s", indentation, ' ',
2234             pSettings->xVSS.bAudioMono ? "true" : "false");
2235         VIDEOEDIT_LOG_SETTING(ANDROID_LOG_INFO, "VIDEO_EDITOR_CLASSES",
2236             "%*c outputVideoBitrate:   %s", indentation, ' ',
2237             videoEditJava_getBitrateString(pSettings->xVSS.outputVideoBitrate));
2238         VIDEOEDIT_LOG_SETTING(ANDROID_LOG_INFO, "VIDEO_EDITOR_CLASSES",
2239             "%*c outputAudioBitrate:   %s", indentation, ' ',
2240             videoEditJava_getBitrateString(pSettings->xVSS.outputAudioBitrate));
2241         VIDEOEDIT_LOG_SETTING(ANDROID_LOG_INFO, "VIDEO_EDITOR_CLASSES",
2242             "%*c pBGMtrack:",               indentation, ' ');
2243         videoEditClasses_logBackgroundMusicSettings(pSettings->xVSS.pBGMtrack,
2244             indentation + VIDEOEDIT_LOG_INDENTATION);
2245         VIDEOEDIT_LOG_SETTING(ANDROID_LOG_INFO, "VIDEO_EDITOR_CLASSES",
2246             "%*c pTextRenderingFct:    %s", indentation, ' ',
2247             (M4OSA_NULL != pSettings->xVSS.pTextRenderingFct) ? "set" : "<null>");
2248         VIDEOEDIT_LOG_SETTING(ANDROID_LOG_INFO, "VIDEO_EDITOR_CLASSES",
2249             "%*c PTVolLevel:       %u", indentation, ' ',
2250             (unsigned int)pSettings->PTVolLevel);
2251     }
2252     else
2253     {
2254         VIDEOEDIT_LOG_SETTING(ANDROID_LOG_INFO, "VIDEO_EDITOR_CLASSES",
2255             "%*c <null>", indentation, ' ');
2256     }
2257 }
2258 #endif
2259 
2260 
2261 void
videoEditClasses_getEffectSettings(bool * pResult,JNIEnv * pEnv,jobject object,M4VSS3GPP_EffectSettings * pSettings)2262 videoEditClasses_getEffectSettings(
2263                 bool*                               pResult,
2264                 JNIEnv*                             pEnv,
2265                 jobject                             object,
2266                 M4VSS3GPP_EffectSettings*           pSettings)
2267 {
2268 
2269     VideoEditJava_EffectSettingsFieldIds fieldIds;
2270     bool                         converted = true;
2271     memset(&fieldIds, 0, sizeof(VideoEditJava_EffectSettingsFieldIds));
2272 
2273     // Check if the previous action succeeded.
2274     if (*pResult)
2275     {
2276         // Log the function call.
2277         VIDEOEDIT_LOG_FUNCTION(ANDROID_LOG_INFO, "VIDEO_EDITOR_CLASSES",
2278          "videoEditClasses_getEffectSettings()");
2279 
2280         // Retrieve the field ids.
2281         videoEditJava_getEffectSettingsFieldIds(pResult, pEnv, &fieldIds);
2282     }
2283 
2284     // Only validate the EffectSettings if the fields could be located.
2285     if (*pResult)
2286     {
2287         // Check if the effect is set.
2288         videoEditJava_checkAndThrowIllegalArgumentException(pResult, pEnv,
2289                                                     (NULL == object),
2290                                                     "effect is null");
2291     }
2292 
2293     // Only retrieve the EffectSettings if the fields could be located and validated.
2294     if (*pResult)
2295     {
2296         // Set the start time in milliseconds.
2297         pSettings->uiStartTime = (M4OSA_UInt32)pEnv->GetIntField(object, fieldIds.startTime);
2298 
2299         // Set the duration in milliseconds.
2300         pSettings->uiDuration = (M4OSA_UInt32)pEnv->GetIntField(object, fieldIds.duration);
2301 
2302         // Set the video effect type, None, FadeIn, FadeOut, etc.
2303         pSettings->VideoEffectType =
2304                 (M4VSS3GPP_VideoEffectType)videoEditJava_getVideoEffectJavaToC(
2305                               &converted, pEnv->GetIntField(object, fieldIds.videoEffectType));
2306 
2307         // Check if the video effect type is valid.
2308         videoEditJava_checkAndThrowIllegalArgumentException(pResult, pEnv,
2309                 !converted, "effect.videoEffectType is invalid");
2310     }
2311 
2312     // Check if the video effect type could be set.
2313     if (*pResult)
2314     {
2315         // Set the external effect function.
2316         pSettings->ExtVideoEffectFct = M4OSA_NULL;
2317 
2318         // Set the context given to the external effect function.
2319         pSettings->pExtVideoEffectFctCtxt = M4OSA_NULL;
2320 
2321         // Set the audio effect type, None, FadeIn, FadeOut.
2322         pSettings->AudioEffectType =
2323                 (M4VSS3GPP_AudioEffectType)videoEditJava_getAudioEffectJavaToC(
2324                         &converted, pEnv->GetIntField(object, fieldIds.audioEffectType));
2325 
2326         // Check if the audio effect type is valid.
2327         videoEditJava_checkAndThrowIllegalArgumentException(pResult, pEnv,
2328                 !converted, "effect.audioEffectType is invalid");
2329     }
2330 
2331     // Check if the audio effect type could be set.
2332     if (*pResult)
2333     {
2334         // Set the start in percentage of the cut clip duration.
2335         pSettings->xVSS.uiStartPercent = (M4OSA_UInt32)pEnv->GetIntField(object,
2336                 fieldIds.startPercent);
2337 
2338         // Set the duration in percentage of the ((clip duration) - (effect starttime)).
2339         pSettings->xVSS.uiDurationPercent = (M4OSA_UInt32)pEnv->GetIntField(object,
2340                 fieldIds.durationPercent);
2341 
2342         // Set the framing file path (GIF/PNG file).
2343         pSettings->xVSS.pFramingFilePath = (M4OSA_Char*)videoEditJava_getString(pResult, pEnv,
2344                 object, fieldIds.framingFile, M4OSA_NULL);
2345 
2346         // Check if this is a framing effect.
2347         if (M4xVSS_kVideoEffectType_Framing == (M4xVSS_VideoEffectType)pSettings->VideoEffectType)
2348         {
2349             // Check if the framing file path is valid.
2350             videoEditJava_checkAndThrowIllegalArgumentException(pResult, pEnv,
2351                     (M4OSA_NULL == pSettings->xVSS.pFramingFilePath), "effect.framingFile is null");
2352         }
2353     }
2354 
2355     // Check if the framing file path could be retrieved.
2356     if (*pResult)
2357     {
2358         // Set the Framing RGB565 buffer.
2359         pSettings->xVSS.pFramingBuffer = M4OSA_NULL;
2360 
2361         // Set the top-left X coordinate in the output picture
2362         // where the added frame will be displayed.
2363         pSettings->xVSS.topleft_x = (M4OSA_UInt32)pEnv->GetIntField(object, fieldIds.topLeftX);
2364 
2365         // Set the top-left Y coordinate in the output picture
2366         // where the added frame will be displayed.
2367         pSettings->xVSS.topleft_y = (M4OSA_UInt32)pEnv->GetIntField(object, fieldIds.topLeftY);
2368 
2369         // Set whether or not the framing image is resized to output video size.
2370         pSettings->xVSS.bResize =
2371                 (M4OSA_Bool)pEnv->GetBooleanField(object, fieldIds.framingResize);
2372 
2373         // Set the new size to which framing buffer needs to be resized to
2374         pSettings->xVSS.framingScaledSize =
2375                 (M4VIDEOEDITING_VideoFrameSize)pEnv->GetIntField(object, fieldIds.framingScaledSize);
2376 
2377         // Set the text buffer.
2378         pSettings->xVSS.pTextBuffer = (M4OSA_Char*)videoEditJava_getString(pResult, pEnv, object,
2379                 fieldIds.text, &pSettings->xVSS.textBufferSize);
2380     }
2381 
2382     // Check if the text buffer could be retrieved.
2383     if (*pResult)
2384     {
2385         // Set the data used by the font engine (size, color...).
2386         pSettings->xVSS.pRenderingData = (M4OSA_Char*)videoEditJava_getString(pResult, pEnv,
2387                 object, fieldIds.textRenderingData, M4OSA_NULL);
2388     }
2389 
2390     // Check if the text rendering data could be retrieved.
2391     if (*pResult)
2392     {
2393         // Set the text plane width.
2394         pSettings->xVSS.uiTextBufferWidth = (M4OSA_UInt32)pEnv->GetIntField(object,
2395                 fieldIds.textBufferWidth);
2396 
2397         // Set the text plane height.
2398         pSettings->xVSS.uiTextBufferHeight = (M4OSA_UInt32)pEnv->GetIntField(object,
2399                 fieldIds.textBufferHeight);
2400 
2401         // Set the processing rate of the effect added when using the Fifties effect.
2402         pSettings->xVSS.uiFiftiesOutFrameRate = (M4OSA_UInt32)pEnv->GetIntField(object,
2403                 fieldIds.fiftiesFrameRate);
2404 
2405         // Set the RGB16 input color of the effect added when using the rgb16 color effect.
2406         pSettings->xVSS.uiRgb16InputColor = (M4OSA_UInt16)pEnv->GetIntField(object,
2407                 fieldIds.rgb16InputColor);
2408 
2409         // Set the start percentage of Alpha blending.
2410         pSettings->xVSS.uialphaBlendingStart = (M4OSA_UInt8)pEnv->GetIntField(object,
2411                 fieldIds.alphaBlendingStartPercent);
2412 
2413         // Set the middle percentage of Alpha blending.
2414         pSettings->xVSS.uialphaBlendingMiddle = (M4OSA_UInt8)pEnv->GetIntField(object,
2415                 fieldIds.alphaBlendingMiddlePercent);
2416 
2417         // Set the end percentage of Alpha blending.
2418         pSettings->xVSS.uialphaBlendingEnd = (M4OSA_UInt8)pEnv->GetIntField(object,
2419                 fieldIds.alphaBlendingEndPercent);
2420 
2421         // Set the duration, in percentage of effect duration, of the FadeIn phase.
2422         pSettings->xVSS.uialphaBlendingFadeInTime = (M4OSA_UInt8)pEnv->GetIntField(object,
2423                 fieldIds.alphaBlendingFadeInTimePercent);
2424 
2425         // Set the duration, in percentage of effect duration, of the FadeOut phase.
2426         pSettings->xVSS.uialphaBlendingFadeOutTime = (M4OSA_UInt8)pEnv->GetIntField(object,
2427                 fieldIds.alphaBlendingFadeOutTimePercent);
2428 
2429         if (pSettings->xVSS.pFramingFilePath != M4OSA_NULL)
2430         {
2431             pSettings->xVSS.pFramingBuffer =
2432                 (M4VIFI_ImagePlane *)M4OSA_32bitAlignedMalloc(sizeof(M4VIFI_ImagePlane),
2433                 0x00,(M4OSA_Char *)"framing buffer");
2434         }
2435 
2436         if (pSettings->xVSS.pFramingBuffer != M4OSA_NULL)
2437         {
2438              // OverFrame height and width
2439             pSettings->xVSS.pFramingBuffer->u_width = pEnv->GetIntField(object,
2440              fieldIds.width);
2441 
2442             pSettings->xVSS.pFramingBuffer->u_height = pEnv->GetIntField(object,
2443              fieldIds.height);
2444 
2445             pSettings->xVSS.width = pSettings->xVSS.pFramingBuffer->u_width;
2446             pSettings->xVSS.height = pSettings->xVSS.pFramingBuffer->u_height;
2447             pSettings->xVSS.rgbType = M4VSS3GPP_kRGB565;
2448 
2449             VIDEOEDIT_LOG_FUNCTION(ANDROID_LOG_INFO, "VIDEO_EDITOR_CLASSES",
2450                     "pFramingBuffer u_width %d ", pSettings->xVSS.pFramingBuffer->u_width);
2451             VIDEOEDIT_LOG_FUNCTION(ANDROID_LOG_INFO, "VIDEO_EDITOR_CLASSES",
2452                     "pFramingBuffer u_height %d", pSettings->xVSS.pFramingBuffer->u_height);
2453 
2454         }
2455 
2456         // Check if settings could be set.
2457         if (!(*pResult))
2458         {
2459             // Free the settings.
2460             videoEditClasses_freeEffectSettings(pSettings);
2461         }
2462     }
2463 }
2464 
2465 void
videoEditClasses_freeEffectSettings(M4VSS3GPP_EffectSettings * pSettings)2466 videoEditClasses_freeEffectSettings(
2467                 M4VSS3GPP_EffectSettings*           pSettings)
2468 {
2469     // Check if memory was allocated for the EffectSettings.
2470     if (M4OSA_NULL != pSettings)
2471     {
2472         // Log the function call.
2473         VIDEOEDIT_LOG_FUNCTION(ANDROID_LOG_INFO, "VIDEO_EDITOR_CLASSES",
2474                 "videoEditClasses_freeEffectSettings()");
2475 
2476         // Free the data used by the font engine (size, color...).
2477         videoEditOsal_free(pSettings->xVSS.pRenderingData);
2478         pSettings->xVSS.pRenderingData = M4OSA_NULL;
2479 
2480         // Free the text buffer.
2481         videoEditOsal_free(pSettings->xVSS.pTextBuffer);
2482         pSettings->xVSS.pTextBuffer = M4OSA_NULL;
2483         pSettings->xVSS.textBufferSize = 0;
2484 
2485         // Free the framing file path.
2486         videoEditOsal_free(pSettings->xVSS.pFramingFilePath);
2487         pSettings->xVSS.pFramingFilePath = M4OSA_NULL;
2488     }
2489 }
2490 
2491 #ifdef VIDEOEDIT_LOGGING_ENABLED
2492 void
videoEditClasses_logEffectSettings(M4VSS3GPP_EffectSettings * pSettings,int indentation)2493 videoEditClasses_logEffectSettings(
2494                 M4VSS3GPP_EffectSettings*           pSettings,
2495                 int                                 indentation)
2496 {
2497     // Check if memory was allocated for the EffectSettings.
2498     if (M4OSA_NULL != pSettings)
2499     {
2500         VIDEOEDIT_LOG_SETTING(ANDROID_LOG_INFO, "VIDEO_EDITOR_CLASSES",
2501             "%*c uiStartTime:                %u ms", indentation, ' ',
2502             (unsigned int)pSettings->uiStartTime);
2503         VIDEOEDIT_LOG_SETTING(ANDROID_LOG_INFO, "VIDEO_EDITOR_CLASSES",
2504             "%*c uiDuration:                 %u ms", indentation, ' ',
2505             (unsigned int)pSettings->uiDuration);
2506         VIDEOEDIT_LOG_SETTING(ANDROID_LOG_INFO, "VIDEO_EDITOR_CLASSES",
2507             "%*c VideoEffectType:            %s",    indentation, ' ',
2508             videoEditJava_getVideoEffectString(pSettings->VideoEffectType));
2509         VIDEOEDIT_LOG_SETTING(ANDROID_LOG_INFO, "VIDEO_EDITOR_CLASSES",
2510              "%*c ExtVideoEffectFct:          %s",    indentation, ' ',
2511             (M4OSA_NULL != pSettings->ExtVideoEffectFct) ? "set" : "<null>");
2512         VIDEOEDIT_LOG_SETTING(ANDROID_LOG_INFO, "VIDEO_EDITOR_CLASSES",
2513             "%*c pExtVideoEffectFctCtxt:     %s",    indentation, ' ',
2514             (M4OSA_NULL != pSettings->pExtVideoEffectFctCtxt) ? "set" : "<null>");
2515         VIDEOEDIT_LOG_SETTING(ANDROID_LOG_INFO, "VIDEO_EDITOR_CLASSES",
2516             "%*c AudioEffectType:            %s",    indentation, ' ',
2517             videoEditJava_getAudioEffectString(pSettings->AudioEffectType));
2518         VIDEOEDIT_LOG_SETTING(ANDROID_LOG_INFO, "VIDEO_EDITOR_CLASSES",
2519             "%*c uiStartPercent:             %u %%", indentation, ' ',
2520             (unsigned int)pSettings->xVSS.uiStartPercent);
2521         VIDEOEDIT_LOG_SETTING(ANDROID_LOG_INFO, "VIDEO_EDITOR_CLASSES",
2522             "%*c uiDurationPercent:          %u %%", indentation, ' ',
2523             (unsigned int)pSettings->xVSS.uiDurationPercent);
2524         VIDEOEDIT_LOG_SETTING(ANDROID_LOG_INFO, "VIDEO_EDITOR_CLASSES",
2525             "%*c pFramingFilePath:           %s",    indentation, ' ',
2526             (M4OSA_NULL != pSettings->xVSS.pFramingFilePath) ?\
2527              (char*)pSettings->xVSS.pFramingFilePath : "<null>");
2528         VIDEOEDIT_LOG_SETTING(ANDROID_LOG_INFO, "VIDEO_EDITOR_CLASSES",
2529             "%*c pFramingBuffer:             %s",    indentation, ' ',
2530             (M4OSA_NULL != pSettings->xVSS.pFramingBuffer) ? "set" : "<null>");
2531         VIDEOEDIT_LOG_SETTING(ANDROID_LOG_INFO, "VIDEO_EDITOR_CLASSES",
2532             "%*c topleft_x:                  %u",    indentation, ' ',
2533             (unsigned int)pSettings->xVSS.topleft_x);
2534         VIDEOEDIT_LOG_SETTING(ANDROID_LOG_INFO, "VIDEO_EDITOR_CLASSES",
2535             "%*c topleft_y:                  %u",    indentation, ' ',
2536             (unsigned int)pSettings->xVSS.topleft_y);
2537         VIDEOEDIT_LOG_SETTING(ANDROID_LOG_INFO, "VIDEO_EDITOR_CLASSES",
2538             "%*c bResize:                    %s",    indentation, ' ',
2539             pSettings->xVSS.bResize ? "true" : "false");
2540         VIDEOEDIT_LOG_SETTING(ANDROID_LOG_INFO, "VIDEO_EDITOR_CLASSES",
2541             "%*c pTextBuffer:                %s",    indentation, ' ',
2542             (M4OSA_NULL != pSettings->xVSS.pTextBuffer) ?\
2543              (char*)pSettings->xVSS.pTextBuffer : "<null>");
2544         VIDEOEDIT_LOG_SETTING(ANDROID_LOG_INFO, "VIDEO_EDITOR_CLASSES",
2545             "%*c textBufferSize:             %u",    indentation, ' ',
2546             (unsigned int)pSettings->xVSS.textBufferSize);
2547         VIDEOEDIT_LOG_SETTING(ANDROID_LOG_INFO, "VIDEO_EDITOR_CLASSES",
2548             "%*c pRenderingData:             %s",    indentation, ' ',
2549             (M4OSA_NULL != pSettings->xVSS.pRenderingData) ?\
2550              (char*)pSettings->xVSS.pRenderingData : "<null>");
2551         VIDEOEDIT_LOG_SETTING(ANDROID_LOG_INFO, "VIDEO_EDITOR_CLASSES",
2552             "%*c uiTextBufferWidth:          %u",    indentation, ' ',
2553             (unsigned int)pSettings->xVSS.uiTextBufferWidth);
2554         VIDEOEDIT_LOG_SETTING(ANDROID_LOG_INFO, "VIDEO_EDITOR_CLASSES",
2555              "%*c uiTextBufferHeight:         %u",    indentation, ' ',
2556             (unsigned int)pSettings->xVSS.uiTextBufferHeight);
2557         VIDEOEDIT_LOG_SETTING(ANDROID_LOG_INFO, "VIDEO_EDITOR_CLASSES",
2558             "%*c uiFiftiesOutFrameRate:      %u",    indentation, ' ',
2559             (unsigned int)pSettings->xVSS.uiFiftiesOutFrameRate);
2560         VIDEOEDIT_LOG_SETTING(ANDROID_LOG_INFO, "VIDEO_EDITOR_CLASSES",
2561             "%*c uiRgb16InputColor:          %d",    indentation, ' ',
2562             pSettings->xVSS.uiRgb16InputColor);
2563         VIDEOEDIT_LOG_SETTING(ANDROID_LOG_INFO, "VIDEO_EDITOR_CLASSES",
2564             "%*c uialphaBlendingStart:       %d %%", indentation, ' ',
2565             pSettings->xVSS.uialphaBlendingStart);
2566         VIDEOEDIT_LOG_SETTING(ANDROID_LOG_INFO, "VIDEO_EDITOR_CLASSES",
2567             "%*c uialphaBlendingMiddle:      %d %%", indentation, ' ',
2568             pSettings->xVSS.uialphaBlendingMiddle);
2569         VIDEOEDIT_LOG_SETTING(ANDROID_LOG_INFO, "VIDEO_EDITOR_CLASSES",
2570             "%*c uialphaBlendingEnd:         %d %%", indentation, ' ',
2571             pSettings->xVSS.uialphaBlendingEnd);
2572         VIDEOEDIT_LOG_SETTING(ANDROID_LOG_INFO, "VIDEO_EDITOR_CLASSES",
2573             "%*c uialphaBlendingFadeInTime:  %d %%", indentation, ' ',
2574             pSettings->xVSS.uialphaBlendingFadeInTime);
2575         VIDEOEDIT_LOG_SETTING(ANDROID_LOG_INFO, "VIDEO_EDITOR_CLASSES",
2576             "%*c uialphaBlendingFadeOutTime: %d %%", indentation, ' ',
2577             pSettings->xVSS.uialphaBlendingFadeOutTime);
2578     }
2579     else
2580     {
2581         VIDEOEDIT_LOG_SETTING(ANDROID_LOG_INFO, "VIDEO_EDITOR_CLASSES",
2582             "%*c <null>", indentation, ' ');
2583     }
2584 }
2585 #endif
2586 
2587 
2588 void
videoEditClasses_getSlideTransitionSettings(bool * pResult,JNIEnv * pEnv,jobject object,M4xVSS_SlideTransitionSettings ** ppSettings)2589 videoEditClasses_getSlideTransitionSettings(
2590                 bool*                               pResult,
2591                 JNIEnv*                             pEnv,
2592                 jobject                             object,
2593                 M4xVSS_SlideTransitionSettings**    ppSettings)
2594 {
2595     VideoEditJava_SlideTransitionSettingsFieldIds fieldIds  = {NULL};
2596     M4xVSS_SlideTransitionSettings*       pSettings = M4OSA_NULL;
2597     bool                                  converted = true;
2598 
2599     // Check if the previous action succeeded.
2600     if (*pResult)
2601     {
2602         // Log the function call.
2603         VIDEOEDIT_LOG_FUNCTION(ANDROID_LOG_INFO, "VIDEO_EDITOR_CLASSES",
2604                 "videoEditClasses_getSlideTransitionSettings()");
2605 
2606         // Retrieve the field ids.
2607         videoEditJava_getSlideTransitionSettingsFieldIds(pResult, pEnv, &fieldIds);
2608     }
2609 
2610 
2611     // Only validate the SlideTransitionSettings if the fields could be located.
2612     if (*pResult)
2613     {
2614         // Check if the clip is set.
2615         videoEditJava_checkAndThrowIllegalArgumentException(pResult, pEnv,
2616                                                     (NULL == object),
2617                                                     "slideSettings is null");
2618     }
2619 
2620     // Only retrieve the SlideTransitionSettings if the fields could be located and validated.
2621     if (*pResult)
2622     {
2623         // Allocate memory for the SlideTransitionSettings.
2624         pSettings = (M4xVSS_SlideTransitionSettings*)videoEditOsal_alloc(pResult, pEnv,
2625                 sizeof(M4xVSS_SlideTransitionSettings), "SlideTransitionSettings");
2626 
2627         // Check if memory could be allocated for the SlideTransitionSettings.
2628         if (*pResult)
2629         {
2630             // Set the direction of the slide.
2631             pSettings->direction =
2632                     (M4xVSS_SlideTransition_Direction)videoEditJava_getSlideDirectionJavaToC(
2633                             &converted, pEnv->GetIntField(object, fieldIds.direction));
2634 
2635             // Check if the direction is valid.
2636             videoEditJava_checkAndThrowIllegalArgumentException(pResult, pEnv,
2637                     !converted, "slideSettings.direction is invalid");
2638         }
2639 
2640         // Check if settings could be set.
2641         if (*pResult)
2642         {
2643             // Return the settings.
2644             (*ppSettings) = pSettings;
2645         }
2646         else
2647         {
2648             // Free the settings.
2649             videoEditClasses_freeSlideTransitionSettings(&pSettings);
2650         }
2651     }
2652 }
2653 
2654 void
videoEditClasses_freeSlideTransitionSettings(M4xVSS_SlideTransitionSettings ** ppSettings)2655 videoEditClasses_freeSlideTransitionSettings(
2656                 M4xVSS_SlideTransitionSettings**    ppSettings)
2657 {
2658     // Check if memory was allocated for the SlideTransitionSettings.
2659     if (M4OSA_NULL != (*ppSettings))
2660     {
2661         // Log the function call.
2662         VIDEOEDIT_LOG_FUNCTION(ANDROID_LOG_INFO, "VIDEO_EDITOR_CLASSES",
2663                 "videoEditClasses_freeSlideTransitionSettings()");
2664 
2665         // Free the settings structure.
2666         videoEditOsal_free((*ppSettings));
2667         (*ppSettings) = M4OSA_NULL;
2668     }
2669 }
2670 
2671 #ifdef VIDEOEDIT_LOGGING_ENABLED
2672 void
videoEditClasses_logSlideTransitionSettings(M4xVSS_SlideTransitionSettings * pSettings,int indentation)2673 videoEditClasses_logSlideTransitionSettings(
2674                 M4xVSS_SlideTransitionSettings*     pSettings,
2675                 int                                 indentation)
2676 {
2677     // Check if memory was allocated for the SlideTransitionSettings.
2678     if (M4OSA_NULL != pSettings)
2679     {
2680         VIDEOEDIT_LOG_SETTING(ANDROID_LOG_INFO, "VIDEO_EDITOR_CLASSES",
2681             "%*c direction: %s", indentation, ' ',
2682             videoEditJava_getSlideDirectionString(pSettings->direction));
2683     }
2684     else
2685     {
2686         VIDEOEDIT_LOG_SETTING(ANDROID_LOG_INFO, "VIDEO_EDITOR_CLASSES",
2687             "%*c <null>", indentation, ' ');
2688     }
2689 }
2690 #endif
2691 
2692 
2693 void
videoEditClasses_getTransitionSettings(bool * pResult,JNIEnv * pEnv,jobject object,M4VSS3GPP_TransitionSettings ** ppSettings)2694 videoEditClasses_getTransitionSettings(
2695                 bool*                               pResult,
2696                 JNIEnv*                             pEnv,
2697                 jobject                             object,
2698                 M4VSS3GPP_TransitionSettings**      ppSettings)
2699 {
2700 
2701     VideoEditJava_TransitionSettingsFieldIds fieldIds;
2702     jobject                          alphaSettings = NULL;
2703     jobject                          slideSettings = NULL;
2704     M4VSS3GPP_TransitionSettings*    pSettings     = M4OSA_NULL;
2705     bool                             converted     = true;
2706     memset(&fieldIds, 0, sizeof(VideoEditJava_TransitionSettingsFieldIds));
2707 
2708     // Check if the previous action succeeded.
2709     if (*pResult)
2710     {
2711         // Log the function call.
2712         VIDEOEDIT_LOG_FUNCTION(ANDROID_LOG_INFO, "VIDEO_EDITOR_CLASSES",
2713                "videoEditClasses_getTransitionSettings()");
2714 
2715         // Retrieve the field ids.
2716         videoEditJava_getTransitionSettingsFieldIds(pResult, pEnv, &fieldIds);
2717     }
2718 
2719     // Only validate the TransitionSettings if the fields could be located.
2720     if (*pResult)
2721     {
2722         // Check if the transition is set.
2723         videoEditJava_checkAndThrowIllegalArgumentException(pResult, pEnv,
2724                                                     (NULL == object),
2725                                                     "transition is null");
2726     }
2727 
2728     // Check if the field ids could be located and validated.
2729     if (*pResult)
2730     {
2731         // Retrieve the alphaSettings.
2732         videoEditJava_getObject(pResult, pEnv, object, fieldIds.alphaSettings, &alphaSettings);
2733 
2734         // Retrieve the slideSettings.
2735         videoEditJava_getObject(pResult, pEnv, object, fieldIds.slideSettings, &slideSettings);
2736     }
2737 
2738     // Only retrieve the TransitionSettings if the fields could be located.
2739     if (*pResult)
2740     {
2741         // Allocate memory for the TransitionSettings.
2742         pSettings = (M4VSS3GPP_TransitionSettings*)videoEditOsal_alloc(pResult,
2743                 pEnv, sizeof(M4VSS3GPP_TransitionSettings), "TransitionSettings");
2744 
2745         // Check if memory could be allocated for the TransitionSettings.
2746         if (*pResult)
2747         {
2748             // Set the duration of the transition, in milliseconds (set to 0 to get no transition).
2749             pSettings->uiTransitionDuration = (M4OSA_UInt32)pEnv->GetIntField(object,
2750                     fieldIds.duration);
2751 
2752             // Set the type of the video transition.
2753             pSettings->VideoTransitionType =
2754                     (M4VSS3GPP_VideoTransitionType)videoEditJava_getVideoTransitionJavaToC(
2755                              &converted, pEnv->GetIntField(object, fieldIds.videoTransitionType));
2756 
2757             // Check if the video transition type is valid.
2758             videoEditJava_checkAndThrowIllegalArgumentException(pResult, pEnv, !converted,
2759                             "transition.videoTransitionType is invalid");
2760         }
2761 
2762         // Check if the video transition type could be set.
2763         if (*pResult)
2764         {
2765             // Set the external transition video effect function.
2766             pSettings->ExtVideoTransitionFct = M4OSA_NULL;
2767 
2768             // Set the context of the external transition video effect function.
2769             pSettings->pExtVideoTransitionFctCtxt = M4OSA_NULL;
2770 
2771             // Set the type of the audio transition.
2772             pSettings->AudioTransitionType =
2773                     (M4VSS3GPP_AudioTransitionType)videoEditJava_getAudioTransitionJavaToC(
2774                             &converted, pEnv->GetIntField(object, fieldIds.audioTransitionType));
2775 
2776             // Check if the audio transition type is valid.
2777             videoEditJava_checkAndThrowIllegalArgumentException(pResult, pEnv, !converted,
2778                              "transition.audioTransitionType is invalid");
2779         }
2780 
2781         // Check if the audio transition type could be set.
2782         if (*pResult)
2783         {
2784             // Set the transition behaviour.
2785             pSettings->TransitionBehaviour =
2786                     (M4VSS3GPP_TransitionBehaviour)videoEditJava_getTransitionBehaviourJavaToC(
2787                             &converted, pEnv->GetIntField(object, fieldIds.transitionBehaviour));
2788 
2789             // Check if the transition behaviour is valid.
2790             videoEditJava_checkAndThrowIllegalArgumentException(pResult, pEnv, !converted,
2791                                                     "transition.transitionBehaviour is invalid");
2792         }
2793 
2794         // Check if the audio transition behaviour could be set.
2795         if (*pResult)
2796         {
2797             // Check if a slide transition or alpha magic setting object is expected.
2798             if ((int)pSettings->VideoTransitionType == M4xVSS_kVideoTransitionType_SlideTransition)
2799             {
2800                 // Set the slide transition settings.
2801                 videoEditClasses_getSlideTransitionSettings(pResult, pEnv, slideSettings,
2802                                      &pSettings->xVSS.transitionSpecific.pSlideTransitionSettings);
2803             }
2804             else if ((int)pSettings->VideoTransitionType == M4xVSS_kVideoTransitionType_AlphaMagic)
2805             {
2806                 // Set the alpha magic settings.
2807                 videoEditClasses_getAlphaMagicSettings(pResult, pEnv, alphaSettings,
2808                                   &pSettings->xVSS.transitionSpecific.pAlphaMagicSettings);
2809             }
2810         }
2811 
2812         // Check if settings could be set.
2813         if (*pResult)
2814         {
2815             // Return the settings.
2816             (*ppSettings) = pSettings;
2817         }
2818         else
2819         {
2820             // Free the settings.
2821             videoEditClasses_freeTransitionSettings(&pSettings);
2822         }
2823     }
2824 }
2825 
2826 void
videoEditClasses_freeTransitionSettings(M4VSS3GPP_TransitionSettings ** ppSettings)2827 videoEditClasses_freeTransitionSettings(
2828                 M4VSS3GPP_TransitionSettings**      ppSettings)
2829 {
2830     // Check if memory was allocated for the TransitionSettings.
2831     if (M4OSA_NULL != (*ppSettings))
2832     {
2833         // Log the function call.
2834         VIDEOEDIT_LOG_FUNCTION(ANDROID_LOG_INFO, "VIDEO_EDITOR_CLASSES",
2835                                "videoEditClasses_freeTransitionSettings()");
2836 
2837         // Check if a slide transition or alpha magic setting structure is expected.
2838         if ((int)(*ppSettings)->VideoTransitionType == M4xVSS_kVideoTransitionType_SlideTransition)
2839         {
2840             // Free the slide transition settings.
2841             videoEditClasses_freeSlideTransitionSettings(
2842                                &(*ppSettings)->xVSS.transitionSpecific.pSlideTransitionSettings);
2843         }
2844         else
2845         {
2846             // Free the alpha magic settings.
2847             videoEditClasses_freeAlphaMagicSettings(
2848                               &(*ppSettings)->xVSS.transitionSpecific.pAlphaMagicSettings);
2849         }
2850 
2851         // Free the settings structure.
2852         videoEditOsal_free((*ppSettings));
2853         (*ppSettings) = M4OSA_NULL;
2854     }
2855 }
2856 
2857 #ifdef VIDEOEDIT_LOGGING_ENABLED
2858 void
videoEditClasses_logTransitionSettings(M4VSS3GPP_TransitionSettings * pSettings,int indentation)2859 videoEditClasses_logTransitionSettings(
2860                 M4VSS3GPP_TransitionSettings*       pSettings,
2861                 int                                 indentation)
2862 {
2863     // Check if memory was allocated for the TransitionSettings.
2864     if (M4OSA_NULL != pSettings)
2865     {
2866         VIDEOEDIT_LOG_SETTING(ANDROID_LOG_INFO, "VIDEO_EDITOR_CLASSES",
2867                                "%*c uiTransitionDuration:       %u ms", indentation, ' ',
2868                                   (unsigned int)pSettings->uiTransitionDuration);
2869         VIDEOEDIT_LOG_SETTING(ANDROID_LOG_INFO, "VIDEO_EDITOR_CLASSES",
2870                            "%*c VideoTransitionType:        %s",    indentation, ' ',
2871                            videoEditJava_getVideoTransitionString(pSettings->VideoTransitionType));
2872         VIDEOEDIT_LOG_SETTING(ANDROID_LOG_INFO, "VIDEO_EDITOR_CLASSES",
2873                               "%*c ExtVideoTransitionFct:      %s",    indentation, ' ',
2874                               (M4OSA_NULL != pSettings->ExtVideoTransitionFct) ? "set" : "<null>");
2875         VIDEOEDIT_LOG_SETTING(ANDROID_LOG_INFO, "VIDEO_EDITOR_CLASSES",
2876                          "%*c pExtVideoTransitionFctCtxt: %s",    indentation, ' ',
2877                          (M4OSA_NULL != pSettings->pExtVideoTransitionFctCtxt) ? "set" : "<null>");
2878         VIDEOEDIT_LOG_SETTING(ANDROID_LOG_INFO, "VIDEO_EDITOR_CLASSES",
2879                          "%*c AudioTransitionType:        %s",    indentation, ' ',
2880                           videoEditJava_getAudioTransitionString(pSettings->AudioTransitionType));
2881         VIDEOEDIT_LOG_SETTING(ANDROID_LOG_INFO, "VIDEO_EDITOR_CLASSES",
2882                       "%*c TransitionBehaviour:        %s",    indentation, ' ',
2883                       videoEditJava_getTransitionBehaviourString(pSettings->TransitionBehaviour));
2884 
2885         // Check if a slide transition or alpha magic setting structure is expected.
2886         if ((int)pSettings->VideoTransitionType == M4xVSS_kVideoTransitionType_SlideTransition)
2887         {
2888             // Log the slide transition settings.
2889             VIDEOEDIT_LOG_SETTING(ANDROID_LOG_INFO, "VIDEO_EDITOR_CLASSES",
2890                                    "%*c pSlideTransitionSettings:", indentation, ' ');
2891             videoEditClasses_logSlideTransitionSettings\
2892             (pSettings->xVSS.transitionSpecific.pSlideTransitionSettings,
2893             indentation + VIDEOEDIT_LOG_INDENTATION);
2894         }
2895         else
2896         {
2897             // Log the alpha magic settings.
2898             VIDEOEDIT_LOG_SETTING(ANDROID_LOG_INFO, "VIDEO_EDITOR_CLASSES",
2899                                    "%*c pAlphaMagicSettings:", indentation, ' ');
2900             videoEditClasses_logAlphaMagicSettings\
2901             (pSettings->xVSS.transitionSpecific.pAlphaMagicSettings,
2902             indentation + VIDEOEDIT_LOG_INDENTATION);
2903         }
2904     }
2905     else
2906     {
2907         VIDEOEDIT_LOG_SETTING(ANDROID_LOG_INFO, "VIDEO_EDITOR_CLASSES",
2908                                "%*c <null>", indentation, ' ');
2909     }
2910 }
2911 #endif
2912 #ifdef VIDEOEDIT_LOGGING_ENABLED
2913 void
videoEditPropClass_logProperties(VideoEditPropClass_Properties * pProperties,int indentation)2914 videoEditPropClass_logProperties(
2915                 VideoEditPropClass_Properties*                   pProperties,
2916                 int                                 indentation)
2917 {
2918     // Check if memory was allocated for the Properties.
2919     if (M4OSA_NULL != pProperties)
2920     {
2921         VIDEOEDIT_LOG_SETTING(ANDROID_LOG_INFO, "VIDEO_EDITOR_PROP_CLASSES",
2922             "%*c uiClipDuration:                   %u",       indentation, ' ',
2923             (unsigned int)pProperties->uiClipDuration);
2924         VIDEOEDIT_LOG_SETTING(ANDROID_LOG_INFO, "VIDEO_EDITOR_PROP_CLASSES",
2925             "%*c FileType:                         %s",       indentation, ' ',
2926             videoEditJava_getFileTypeString(pProperties->FileType));
2927 
2928         VIDEOEDIT_LOG_SETTING(ANDROID_LOG_INFO, "VIDEO_EDITOR_PROP_CLASSES",
2929             "%*c VideoStreamType:                  %s",       indentation, ' ',
2930             videoEditJava_getVideoFormatString(pProperties->VideoStreamType));
2931         VIDEOEDIT_LOG_SETTING(ANDROID_LOG_INFO, "VIDEO_EDITOR_PROP_CLASSES",
2932             "%*c uiClipVideoDuration:              %u",       indentation, ' ',
2933             (unsigned int)pProperties->uiClipVideoDuration);
2934 
2935         VIDEOEDIT_LOG_SETTING(ANDROID_LOG_INFO, "VIDEO_EDITOR_PROP_CLASSES",
2936             "%*c uiVideoBitrate:                   %s",       indentation, ' ',
2937             videoEditJava_getBitrateString(pProperties->uiVideoBitrate));
2938 
2939         VIDEOEDIT_LOG_SETTING(ANDROID_LOG_INFO, "VIDEO_EDITOR_PROP_CLASSES",
2940             "%*c uiVideoWidth:                     %u",       indentation, ' ',
2941             (unsigned int)pProperties->uiVideoWidth);
2942 
2943         VIDEOEDIT_LOG_SETTING(ANDROID_LOG_INFO, "VIDEO_EDITOR_PROP_CLASSES",
2944             "%*c uiVideoHeight:                    %u",       indentation, ' ',
2945             (unsigned int)(unsigned int)pProperties->uiVideoHeight);
2946 
2947         VIDEOEDIT_LOG_SETTING(ANDROID_LOG_INFO, "VIDEO_EDITOR_PROP_CLASSES",
2948             "%*c fAverageFrameRate:                %.3f",     indentation, ' ',
2949             pProperties->fAverageFrameRate);
2950 
2951         VIDEOEDIT_LOG_SETTING(ANDROID_LOG_INFO, "VIDEO_EDITOR_PROP_CLASSES",
2952             "%*c AudioStreamType:                  %s",       indentation, ' ',
2953             videoEditJava_getAudioFormatString(pProperties->AudioStreamType));
2954 
2955         VIDEOEDIT_LOG_SETTING(ANDROID_LOG_INFO, "VIDEO_EDITOR_PROP_CLASSES",
2956             "%*c uiClipAudioDuration:              %u",       indentation, ' ',
2957             (unsigned int)pProperties->uiClipAudioDuration);
2958 
2959         VIDEOEDIT_LOG_SETTING(ANDROID_LOG_INFO, "VIDEO_EDITOR_PROP_CLASSES",
2960             "%*c uiAudioBitrate:                   %s",       indentation, ' ',
2961             videoEditJava_getBitrateString(pProperties->uiAudioBitrate));
2962 
2963         VIDEOEDIT_LOG_SETTING(ANDROID_LOG_INFO, "VIDEO_EDITOR_PROP_CLASSES",
2964             "%*c uiNbChannels:                     %u",       indentation, ' ',
2965             (unsigned int)pProperties->uiNbChannels);
2966 
2967         VIDEOEDIT_LOG_SETTING(ANDROID_LOG_INFO, "VIDEO_EDITOR_PROP_CLASSES",
2968              "%*c uiSamplingFrequency:              %u",       indentation, ' ',
2969             (unsigned int)pProperties->uiSamplingFrequency);
2970     }
2971     else
2972     {
2973         VIDEOEDIT_LOG_SETTING(ANDROID_LOG_INFO, "VIDEO_EDITOR_PROP_CLASSES",
2974             "%*c <null>", indentation, ' ');
2975     }
2976 }
2977 #endif
2978 
2979 
2980 void
videoEditClasses_createVersion(bool * pResult,JNIEnv * pEnv,M4_VersionInfo * pVersionInfo,jobject * pObject)2981 videoEditClasses_createVersion(
2982                 bool*                               pResult,
2983                 JNIEnv*                             pEnv,
2984                 M4_VersionInfo*                     pVersionInfo,
2985                 jobject*                            pObject)
2986 {
2987 
2988     VideoEditJava_VersionFieldIds fieldIds;
2989     jclass                clazz    = NULL;
2990     jobject               object   = NULL;
2991     memset(&fieldIds, 0, sizeof(VideoEditJava_VersionFieldIds));
2992     // Check if the previous action succeeded.
2993     if (*pResult)
2994     {
2995         // Log the function call.
2996         VIDEOEDIT_LOG_FUNCTION(ANDROID_LOG_INFO, "VIDEO_EDITOR_CLASSES",
2997                                "videoEditClasses_createVersion()");
2998 
2999         // Retrieve the class.
3000         videoEditJava_getVersionClass(pResult, pEnv, &clazz);
3001 
3002         // Retrieve the field ids.
3003         videoEditJava_getVersionFieldIds(pResult, pEnv, &fieldIds);
3004     }
3005 
3006     // Only create an object if the class and fields could be located.
3007     if (*pResult)
3008     {
3009         // Allocate a new object.
3010         object = pEnv->AllocObject(clazz);
3011 
3012         // check if alloc is done
3013         videoEditJava_checkAndThrowRuntimeException(pResult, pEnv,
3014                                                     (NULL == object),
3015                                                     M4ERR_ALLOC);
3016         if (NULL != object)
3017         {
3018             // Set the major field.
3019             pEnv->SetIntField(object, fieldIds.major, pVersionInfo->m_major);
3020 
3021             // Set the minor field.
3022             pEnv->SetIntField(object, fieldIds.minor, pVersionInfo->m_minor);
3023 
3024             // Set the revision field.
3025             pEnv->SetIntField(object, fieldIds.revision, pVersionInfo->m_revision);
3026 
3027             // Return the object.
3028             (*pObject) = object;
3029         }
3030     }
3031 }
3032 
3033 #ifdef VIDEOEDIT_LOGGING_ENABLED
3034 void
videoEditClasses_logVersion(M4_VersionInfo * pVersionInfo,int indentation)3035 videoEditClasses_logVersion(
3036                 M4_VersionInfo*                     pVersionInfo,
3037                 int                                 indentation)
3038 {
3039     // Check if memory was allocated for the Version.
3040     if (M4OSA_NULL != pVersionInfo)
3041     {
3042         VIDEOEDIT_LOG_SETTING(ANDROID_LOG_INFO, "VIDEO_EDITOR_CLASSES",
3043                              "%*c major:    %u ms", indentation, ' ',
3044                              (unsigned int)pVersionInfo->m_major);
3045         VIDEOEDIT_LOG_SETTING(ANDROID_LOG_INFO, "VIDEO_EDITOR_CLASSES",
3046                               "%*c minor:    %u",    indentation, ' ',
3047                               (unsigned int)pVersionInfo->m_minor);
3048         VIDEOEDIT_LOG_SETTING(ANDROID_LOG_INFO, "VIDEO_EDITOR_CLASSES",
3049                              "%*c revision: %u",    indentation, ' ',
3050                              (unsigned int)pVersionInfo->m_revision);
3051     }
3052     else
3053     {
3054         VIDEOEDIT_LOG_SETTING(ANDROID_LOG_INFO, "VIDEO_EDITOR_CLASSES",
3055                               "%*c <null>", indentation, ' ');
3056     }
3057 }
3058 #endif
3059 
3060 
3061 void*
videoEditClasses_getContext(bool * pResult,JNIEnv * pEnv,jobject object)3062 videoEditClasses_getContext(
3063                 bool*                               pResult,
3064                 JNIEnv*                             pEnv,
3065                 jobject                             object)
3066 {
3067     void*                pContext = M4OSA_NULL;
3068     jclass               clazz    = NULL;
3069     VideoEditJava_EngineFieldIds fieldIds = {NULL};
3070 
3071     // Check if the previous action succeeded.
3072     if (*pResult)
3073     {
3074         // Log the function call.
3075         VIDEOEDIT_LOG_FUNCTION(ANDROID_LOG_INFO, "VIDEO_EDITOR_CLASSES",
3076                                "videoEditClasses_getContext()");
3077 
3078         // Retrieve the class.
3079         videoEditJava_getEngineClass(pResult, pEnv, &clazz);
3080 
3081         // Retrieve the field ids.
3082         videoEditJava_getEngineFieldIds(pResult, pEnv, &fieldIds);
3083     }
3084 
3085     // Check if the class and field ids could be located.
3086     if (*pResult)
3087     {
3088         // Retrieve the context pointer.
3089         pContext = (void *)pEnv->GetIntField(object, fieldIds.context);
3090     }
3091 
3092     // Return the context pointer.
3093     return(pContext);
3094 }
3095 
3096 void
videoEditClasses_setContext(bool * pResult,JNIEnv * pEnv,jobject object,void * pContext)3097 videoEditClasses_setContext(
3098                 bool*                               pResult,
3099                 JNIEnv*                             pEnv,
3100                 jobject                             object,
3101                 void*                               pContext)
3102 {
3103     jclass               clazz    = NULL;
3104     VideoEditJava_EngineFieldIds fieldIds = {NULL};
3105 
3106     // Check if the previous action succeeded.
3107     if (*pResult)
3108     {
3109         // Log the function call.
3110         VIDEOEDIT_LOG_FUNCTION(ANDROID_LOG_INFO, "VIDEO_EDITOR_CLASSES",
3111                                "videoEditClasses_setContext()");
3112 
3113         // Retrieve the class.
3114         videoEditJava_getEngineClass(pResult, pEnv, &clazz);
3115 
3116         // Retrieve the field ids.
3117         videoEditJava_getEngineFieldIds(pResult, pEnv, &fieldIds);
3118     }
3119 
3120     // Check if the class and field ids could be located.
3121     if (*pResult)
3122     {
3123         // Set the context field.
3124         VIDEOEDIT_LOG_FUNCTION(ANDROID_LOG_INFO, "VIDEO_EDITOR_CLASSES",
3125                         "The context value from JAVA before setting is = 0x%x",
3126                         pEnv->GetIntField(object, fieldIds.context));
3127 
3128         pEnv->SetIntField(object, fieldIds.context, (int)pContext);
3129         M4OSA_TRACE1_1("The context value in JNI is = 0x%x",pContext);
3130 
3131         VIDEOEDIT_LOG_FUNCTION(ANDROID_LOG_INFO, "VIDEO_EDITOR_CLASSES",
3132                          "The context value from JAVA after setting is = 0x%x",
3133                          pEnv->GetIntField(object, fieldIds.context));
3134     }
3135 }
3136 
3137