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