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 #ifndef VIDEO_EDITOR_CLASSES_H 18 #define VIDEO_EDITOR_CLASSES_H 19 20 #include <VideoEditorJava.h> 21 #include <VideoEditorClasses.h> 22 /** 23 ************************************************************************ 24 * @file VideoEditorClasses.h 25 * @brief Interface for JNI methods/defines that have specific 26 * access to class, objects and method Ids defined in Java layer 27 ************************************************************************ 28 */ 29 30 31 extern "C" { 32 #include <M4xVSS_API.h> 33 #include <M4VSS3GPP_API.h> 34 #include <M4VSS3GPP_ErrorCodes.h> 35 #include <M4MCS_ErrorCodes.h> 36 #include <M4READER_Common.h> 37 #include <M4WRITER_common.h> 38 }; 39 40 /* 41 * Java layer class/object name strings 42 */ 43 #define PACKAGE_NAME "android/media/videoeditor" 44 45 #define MANUAL_EDIT_ENGINE_CLASS_NAME PACKAGE_NAME"/MediaArtistNativeHelper" 46 #define MEDIA_PROPERTIES_ENGINE_CLASS_NAME PACKAGE_NAME"/MediaArtistNativeHelper" 47 48 #define AUDIO_FORMAT_CLASS_NAME MANUAL_EDIT_ENGINE_CLASS_NAME"$AudioFormat" 49 #define RESULTS_CLASS_NAME MANUAL_EDIT_ENGINE_CLASS_NAME"$Results" 50 #define VERSION_CLASS_NAME MANUAL_EDIT_ENGINE_CLASS_NAME"$Version" 51 #define AUDIO_SAMPLING_FREQUENCY_CLASS_NAME MANUAL_EDIT_ENGINE_CLASS_NAME"$AudioSamplingFrequency" 52 #define BITRATE_CLASS_NAME MANUAL_EDIT_ENGINE_CLASS_NAME"$Bitrate" 53 #define ERROR_CLASS_NAME MANUAL_EDIT_ENGINE_CLASS_NAME"$Result" 54 #define FILE_TYPE_CLASS_NAME MANUAL_EDIT_ENGINE_CLASS_NAME"$FileType" 55 #define MEDIA_RENDERING_CLASS_NAME MANUAL_EDIT_ENGINE_CLASS_NAME"$MediaRendering" 56 #define VIDEO_FORMAT_CLASS_NAME MANUAL_EDIT_ENGINE_CLASS_NAME"$VideoFormat" 57 #define VIDEO_FRAME_RATE_CLASS_NAME MANUAL_EDIT_ENGINE_CLASS_NAME"$VideoFrameRate" 58 #define VIDEO_FRAME_SIZE_CLASS_NAME MANUAL_EDIT_ENGINE_CLASS_NAME"$VideoFrameSize" 59 #define VIDEO_PROFILE_CLASS_NAME MANUAL_EDIT_ENGINE_CLASS_NAME"$VideoProfile" 60 #define ALPHA_MAGIC_SETTINGS_CLASS_NAME MANUAL_EDIT_ENGINE_CLASS_NAME"$AlphaMagicSettings" 61 #define AUDIO_EFFECT_CLASS_NAME MANUAL_EDIT_ENGINE_CLASS_NAME"$AudioEffect" 62 #define AUDIO_TRANSITION_CLASS_NAME MANUAL_EDIT_ENGINE_CLASS_NAME"$AudioTransition" 63 #define BACKGROUND_MUSIC_SETTINGS_CLASS_NAME MANUAL_EDIT_ENGINE_CLASS_NAME"$BackgroundMusicSettings" 64 #define CLIP_SETTINGS_CLASS_NAME MANUAL_EDIT_ENGINE_CLASS_NAME"$ClipSettings" 65 #define EDIT_SETTINGS_CLASS_NAME MANUAL_EDIT_ENGINE_CLASS_NAME"$EditSettings" 66 #define EFFECT_SETTINGS_CLASS_NAME MANUAL_EDIT_ENGINE_CLASS_NAME"$EffectSettings" 67 #define SLIDE_DIRECTION_CLASS_NAME MANUAL_EDIT_ENGINE_CLASS_NAME"$SlideDirection" 68 #define SLIDE_TRANSITION_SETTINGS_CLASS_NAME MANUAL_EDIT_ENGINE_CLASS_NAME"$SlideTransitionSettings" 69 #define TRANSITION_BEHAVIOUR_CLASS_NAME MANUAL_EDIT_ENGINE_CLASS_NAME"$TransitionBehaviour" 70 #define TRANSITION_SETTINGS_CLASS_NAME MANUAL_EDIT_ENGINE_CLASS_NAME"$TransitionSettings" 71 #define VIDEO_EFFECT_CLASS_NAME MANUAL_EDIT_ENGINE_CLASS_NAME"$VideoEffect" 72 #define VIDEO_TRANSITION_CLASS_NAME MANUAL_EDIT_ENGINE_CLASS_NAME"$VideoTransition" 73 #define PREVIEW_CLIPS_CLASS_NAME MANUAL_EDIT_ENGINE_CLASS_NAME"$PreviewClips" 74 #define PREVIEW_SETTING_CLASS_NAME MANUAL_EDIT_ENGINE_CLASS_NAME"$PreviewSettings" 75 #define PREVIEW_PROPERTIES_CLASS_NAME MANUAL_EDIT_ENGINE_CLASS_NAME"$PreviewClipProperties" 76 #define AUDIO_SETTINGS_CLASS_NAME MANUAL_EDIT_ENGINE_CLASS_NAME"$AudioSettings" 77 #define PROPERTIES_CLASS_NAME MANUAL_EDIT_ENGINE_CLASS_NAME"$Properties" 78 79 #define TASK_IDLE 0 80 #define TASK_LOADING_SETTINGS 1 81 #define TASK_ENCODING 2 82 83 /* 84 * File type enum 85 */ 86 typedef enum 87 { 88 VideoEditClasses_kFileType_3GPP, 89 VideoEditClasses_kFileType_MP4, 90 VideoEditClasses_kFileType_AMR, 91 VideoEditClasses_kFileType_MP3, 92 VideoEditClasses_kFileType_PCM, 93 VideoEditClasses_kFileType_JPG, 94 VideoEditClasses_kFileType_BMP, 95 VideoEditClasses_kFileType_GIF, 96 VideoEditClasses_kFileType_PNG, 97 VideoEditClasses_kFileType_ARGB8888, 98 VideoEditClasses_kFileType_M4V, 99 VideoEditClasses_kFileType_Unsupported 100 } VideoEditClasses_FileType; 101 102 /* 103 * Alpha magic transition structure 104 */ 105 typedef struct 106 { 107 jfieldID file; 108 jfieldID blendingPercent; 109 jfieldID invertRotation; 110 jfieldID rgbWidth; 111 jfieldID rgbHeight; 112 } VideoEditJava_AlphaMagicFieldIds; 113 114 typedef struct 115 { 116 jfieldID file; 117 jfieldID fileType; 118 jfieldID insertionTime; 119 jfieldID volumePercent; 120 jfieldID beginLoop; 121 jfieldID endLoop; 122 jfieldID enableDucking; 123 jfieldID duckingThreshold; 124 jfieldID lowVolume; 125 jfieldID isLooping; 126 } VideoEditJava_BackgroundMusicFieldIds; 127 /* 128 * Structure to hold media properties from native layer 129 */ 130 typedef struct { 131 M4OSA_UInt32 uiClipDuration; 132 VideoEditClasses_FileType FileType; 133 M4VIDEOEDITING_VideoFormat VideoStreamType; 134 M4OSA_UInt32 uiClipVideoDuration; 135 M4OSA_UInt32 uiVideoBitrate; 136 M4OSA_UInt32 uiVideoWidth; 137 M4OSA_UInt32 uiVideoHeight; 138 M4OSA_Float fAverageFrameRate; 139 M4OSA_UInt32 uiVideoProfile; /**< H263 or MPEG-4 or H264 profile(from core decoder) */ 140 M4OSA_UInt32 uiVideoLevel; /**< H263 or MPEG-4 or H264 level*/ 141 M4OSA_Bool bProfileSupported; 142 M4OSA_Bool bLevelSupported; 143 M4VIDEOEDITING_AudioFormat AudioStreamType; 144 M4OSA_UInt32 uiClipAudioDuration; 145 M4OSA_UInt32 uiAudioBitrate; 146 M4OSA_UInt32 uiNbChannels; 147 M4OSA_UInt32 uiSamplingFrequency; 148 M4OSA_UInt32 uiRotation; 149 } VideoEditPropClass_Properties; 150 151 typedef struct 152 { 153 jfieldID duration; 154 jfieldID fileType; 155 jfieldID videoFormat; 156 jfieldID videoDuration; 157 jfieldID videoBitrate; 158 jfieldID width; 159 jfieldID height; 160 jfieldID averageFrameRate; 161 jfieldID profile; 162 jfieldID level; 163 jfieldID profileSupported; 164 jfieldID levelSupported; 165 jfieldID audioFormat; 166 jfieldID audioDuration; 167 jfieldID audioBitrate; 168 jfieldID audioChannels; 169 jfieldID audioSamplingFrequency; 170 jfieldID videoRotation; 171 } VideoEditJava_PropertiesFieldIds; 172 173 174 typedef struct 175 { 176 jfieldID clipPath; 177 jfieldID fileType; 178 jfieldID beginCutTime; 179 jfieldID endCutTime; 180 jfieldID beginCutPercent; 181 jfieldID endCutPercent; 182 jfieldID panZoomEnabled; 183 jfieldID panZoomPercentStart; 184 jfieldID panZoomTopLeftXStart; 185 jfieldID panZoomTopLeftYStart; 186 jfieldID panZoomPercentEnd; 187 jfieldID panZoomTopLeftXEnd; 188 jfieldID panZoomTopLeftYEnd; 189 jfieldID mediaRendering; 190 jfieldID rgbFileWidth; 191 jfieldID rgbFileHeight; 192 jfieldID rotationDegree; 193 } VideoEditJava_ClipSettingsFieldIds; 194 195 typedef struct 196 { 197 jfieldID clipSettingsArray; 198 jfieldID transitionSettingsArray; 199 jfieldID effectSettingsArray; 200 jfieldID videoFrameRate; 201 jfieldID outputFile; 202 jfieldID videoFrameSize; 203 jfieldID videoFormat; 204 jfieldID videoProfile; 205 jfieldID videoLevel; 206 jfieldID audioFormat; 207 jfieldID audioSamplingFreq; 208 jfieldID maxFileSize; 209 jfieldID audioChannels; 210 jfieldID videoBitrate; 211 jfieldID audioBitrate; 212 jfieldID backgroundMusicSettings; 213 jfieldID primaryTrackVolume; 214 } VideoEditJava_EditSettingsFieldIds; 215 216 217 typedef struct 218 { 219 jfieldID startTime; 220 jfieldID duration; 221 jfieldID videoEffectType; 222 jfieldID audioEffectType; 223 jfieldID startPercent; 224 jfieldID durationPercent; 225 jfieldID framingFile; 226 jfieldID framingBuffer; 227 jfieldID bitmapType; 228 jfieldID width; 229 jfieldID height; 230 jfieldID topLeftX; 231 jfieldID topLeftY; 232 jfieldID framingResize; 233 jfieldID framingScaledSize; 234 jfieldID text; 235 jfieldID textRenderingData; 236 jfieldID textBufferWidth; 237 jfieldID textBufferHeight; 238 jfieldID fiftiesFrameRate; 239 jfieldID rgb16InputColor; 240 jfieldID alphaBlendingStartPercent; 241 jfieldID alphaBlendingMiddlePercent; 242 jfieldID alphaBlendingEndPercent; 243 jfieldID alphaBlendingFadeInTimePercent; 244 jfieldID alphaBlendingFadeOutTimePercent; 245 } VideoEditJava_EffectSettingsFieldIds; 246 247 typedef struct 248 { 249 jfieldID context; 250 } VideoEditJava_EngineFieldIds; 251 252 typedef struct 253 { 254 jfieldID direction; 255 } VideoEditJava_SlideTransitionSettingsFieldIds; 256 257 typedef struct 258 { 259 jfieldID duration; 260 jfieldID videoTransitionType; 261 jfieldID audioTransitionType; 262 jfieldID transitionBehaviour; 263 jfieldID alphaSettings; 264 jfieldID slideSettings; 265 } VideoEditJava_TransitionSettingsFieldIds; 266 267 typedef struct 268 { 269 jfieldID major; 270 jfieldID minor; 271 jfieldID revision; 272 } VideoEditJava_VersionFieldIds; 273 274 275 typedef struct 276 { 277 jmethodID onProgressUpdate; 278 } VideoEditJava_EngineMethodIds; 279 280 281 VIDEOEDIT_JAVA_DECLARE_CONSTANT_CLASS(AudioEffect ) 282 VIDEOEDIT_JAVA_DECLARE_CONSTANT_CLASS(AudioFormat ) 283 VIDEOEDIT_JAVA_DECLARE_CONSTANT_CLASS(AudioSamplingFrequency) 284 VIDEOEDIT_JAVA_DECLARE_CONSTANT_CLASS(AudioTransition ) 285 VIDEOEDIT_JAVA_DECLARE_CONSTANT_CLASS(Bitrate ) 286 VIDEOEDIT_JAVA_DECLARE_CONSTANT_CLASS(Engine ) 287 VIDEOEDIT_JAVA_DECLARE_CONSTANT_CLASS(Error ) 288 VIDEOEDIT_JAVA_DECLARE_CONSTANT_CLASS(FileType ) 289 VIDEOEDIT_JAVA_DECLARE_CONSTANT_CLASS(MediaRendering ) 290 VIDEOEDIT_JAVA_DECLARE_CONSTANT_CLASS(SlideDirection ) 291 VIDEOEDIT_JAVA_DECLARE_CONSTANT_CLASS(TransitionBehaviour ) 292 VIDEOEDIT_JAVA_DECLARE_CONSTANT_CLASS(VideoEffect ) 293 VIDEOEDIT_JAVA_DECLARE_CONSTANT_CLASS(VideoFormat ) 294 VIDEOEDIT_JAVA_DECLARE_CONSTANT_CLASS(VideoFrameRate ) 295 VIDEOEDIT_JAVA_DECLARE_CONSTANT_CLASS(VideoFrameSize ) 296 VIDEOEDIT_JAVA_DECLARE_CONSTANT_CLASS(VideoProfile ) 297 VIDEOEDIT_JAVA_DECLARE_CONSTANT_CLASS(VideoTransition ) 298 299 300 VIDEOEDIT_JAVA_DECLARE_FIELD_CLASS(AlphaMagic ) 301 VIDEOEDIT_JAVA_DECLARE_FIELD_CLASS(BackgroundMusic ) 302 VIDEOEDIT_JAVA_DECLARE_FIELD_CLASS(ClipSettings ) 303 VIDEOEDIT_JAVA_DECLARE_FIELD_CLASS(ClipSettings ) 304 VIDEOEDIT_JAVA_DECLARE_FIELD_CLASS(EditSettings ) 305 VIDEOEDIT_JAVA_DECLARE_FIELD_CLASS(EffectSettings ) 306 VIDEOEDIT_JAVA_DECLARE_FIELD_CLASS(Engine ) 307 VIDEOEDIT_JAVA_DECLARE_FIELD_CLASS(SlideTransitionSettings ) 308 VIDEOEDIT_JAVA_DECLARE_FIELD_CLASS(TransitionSettings ) 309 VIDEOEDIT_JAVA_DECLARE_FIELD_CLASS(Version ) 310 311 VIDEOEDIT_JAVA_DECLARE_METHOD_CLASS(Engine ) 312 313 /* 314 * Init all Edit settings related structures 315 */ 316 void 317 videoEditClasses_init( 318 bool* pResult, 319 JNIEnv* pEnv); 320 /** 321 ************************************************************************ 322 * @brief Media Properties init function. 323 * @param pResult (OUT) Pointer to hold result 324 * @param pEnv (IN) JVM Interface pointer 325 ************************************************************************ 326 */ 327 void 328 videoEditPropClass_init( 329 bool* pResult, 330 JNIEnv* pEnv); 331 /** 332 ************************************************************************ 333 * @brief Interface to populate Media Properties. 334 * @param pResult (IN/OUT) Pointer to hold result 335 * @param pEnv (IN) JVM Interface pointer 336 * @param pProperties (IN) Media propeties structure pointer 337 * @param pObject (OUT) Java object to hold media 338 * properties for java layer. 339 ************************************************************************ 340 */ 341 void 342 videoEditPropClass_createProperties( 343 bool* pResult, 344 JNIEnv* pEnv, 345 VideoEditPropClass_Properties* pProperties, 346 jobject* pObject); 347 348 /** 349 ************************************************************************ 350 * @brief Interface to log/display media properties. 351 * @param pProperties (IN) Pointer holding media properties 352 * @param indentation (IN) Indentation to follow in display 353 ************************************************************************ 354 */ 355 void 356 videoEditPropClass_logProperties( 357 VideoEditPropClass_Properties* pProperties, 358 int indentation); 359 360 /* 361 * Get alpha magic transition settings 362 */ 363 void 364 videoEditClasses_getAlphaMagicSettings( 365 bool* pResult, 366 JNIEnv* pEnv, 367 jobject object, 368 M4xVSS_AlphaMagicSettings** ppSettings); 369 370 /* 371 * Free alpha magic transition settings structure 372 */ 373 void 374 videoEditClasses_freeAlphaMagicSettings( 375 M4xVSS_AlphaMagicSettings** ppSettings); 376 377 /* 378 * Log alpha magic transition settings 379 */ 380 void 381 videoEditClasses_logAlphaMagicSettings( 382 M4xVSS_AlphaMagicSettings* pSettings, 383 int indentation); 384 385 /* 386 * Get Background Track settings 387 */ 388 void 389 videoEditClasses_getBackgroundMusicSettings( 390 bool* pResult, 391 JNIEnv* pEnv, 392 jobject object, 393 M4xVSS_BGMSettings** ppSettings); 394 395 /* 396 * Free Background Track settings structure 397 */ 398 void 399 videoEditClasses_freeBackgroundMusicSettings( 400 M4xVSS_BGMSettings** ppSettings); 401 402 /* 403 * Log Background Track settings 404 */ 405 void 406 videoEditClasses_logBackgroundMusicSettings( 407 M4xVSS_BGMSettings* pSettings, 408 int indentation); 409 410 /* 411 * Log clip properties 412 */ 413 void 414 videoEditClasses_logClipProperties( 415 M4VIDEOEDITING_ClipProperties* pProperties, 416 int indentation); 417 418 /* 419 * Get clip settings from Java 420 */ 421 void 422 videoEditClasses_getClipSettings( 423 bool* pResult, 424 JNIEnv* pEnv, 425 jobject object, 426 M4VSS3GPP_ClipSettings** ppSettings); 427 /** 428 ************************************************************************ 429 * @brief Interface function to retrieve media properties for a given 430 * file. 431 * @param pEnv (IN) Pointer holding media properties 432 * @param thiz (IN) Indentation to follow in display 433 * @param file (IN) File path for which media properties has 434 * to be retrieved. 435 ************************************************************************ 436 */ 437 jobject 438 videoEditProp_getProperties( 439 JNIEnv* pEnv, 440 jobject thiz, 441 jstring file); 442 443 /* 444 * Create/Set the clip settings to java Object 445 */ 446 void 447 videoEditClasses_createClipSettings( 448 bool* pResult, 449 JNIEnv* pEnv, 450 M4VSS3GPP_ClipSettings* pSettings, 451 jobject* pObject); 452 453 /* 454 * Free clip settings structure 455 */ 456 void 457 videoEditClasses_freeClipSettings( 458 M4VSS3GPP_ClipSettings** ppSettings); 459 460 /* 461 * Log clip settings structure 462 */ 463 void 464 videoEditClasses_logClipSettings( 465 M4VSS3GPP_ClipSettings* pSettings, 466 int indentation); 467 468 /* 469 * Get Edit settings from Java 470 */ 471 void 472 videoEditClasses_getEditSettings( 473 bool* pResult, 474 JNIEnv* pEnv, 475 jobject object, 476 M4VSS3GPP_EditSettings** ppSettings, 477 bool flag); 478 479 /* 480 * Free Edit Settings structure 481 */ 482 void 483 videoEditClasses_freeEditSettings( 484 M4VSS3GPP_EditSettings** ppSettings); 485 486 /* 487 * Log Edit settings structure 488 */ 489 void 490 videoEditClasses_logEditSettings( 491 M4VSS3GPP_EditSettings* pSettings, 492 int indentation); 493 494 /* 495 * Get Effect settings from Java 496 */ 497 void 498 videoEditClasses_getEffectSettings( 499 bool* pResult, 500 JNIEnv* pEnv, 501 jobject object, 502 M4VSS3GPP_EffectSettings* pSettings); 503 504 /* 505 * Free Effect settings structure 506 */ 507 void 508 videoEditClasses_freeEffectSettings( 509 M4VSS3GPP_EffectSettings* pSettings); 510 511 /* 512 * Log Effect settings 513 */ 514 void 515 videoEditClasses_logEffectSettings( 516 M4VSS3GPP_EffectSettings* pSettings, 517 int indentation); 518 519 /* 520 * Get Transition-Sliding settings from Java 521 */ 522 void 523 videoEditClasses_getSlideTransitionSettings( 524 bool* pResult, 525 JNIEnv* pEnv, 526 jobject object, 527 M4xVSS_SlideTransitionSettings** ppSettings); 528 529 /* 530 * Free Transition-Sliding structure 531 */ 532 void 533 videoEditClasses_freeSlideTransitionSettings( 534 M4xVSS_SlideTransitionSettings** ppSettings); 535 536 /* 537 * Free Transition-Sliding structure 538 */ 539 void 540 videoEditClasses_logSlideTransitionSettings( 541 M4xVSS_SlideTransitionSettings* pSettings, 542 int indentation); 543 544 /* 545 * Get Transition settings from Java 546 */ 547 void 548 videoEditClasses_getTransitionSettings( 549 bool* pResult, 550 JNIEnv* pEnv, 551 jobject object, 552 M4VSS3GPP_TransitionSettings** ppSettings); 553 554 /* 555 * Free Transition settings structure 556 */ 557 void 558 videoEditClasses_freeTransitionSettings( 559 M4VSS3GPP_TransitionSettings** ppSettings); 560 561 /* 562 * Log Transition settings 563 */ 564 void 565 videoEditClasses_logTransitionSettings( 566 M4VSS3GPP_TransitionSettings* pSettings, 567 int indentation); 568 569 /* 570 * Set version information to Java object 571 */ 572 void 573 videoEditClasses_createVersion( 574 bool* pResult, 575 JNIEnv* pEnv, 576 M4_VersionInfo* pVersionInfo, 577 jobject* pObject); 578 579 /* 580 * Log Version information 581 */ 582 void 583 videoEditClasses_logVersion( 584 M4_VersionInfo* pVersionInfo, 585 int indentation); 586 587 588 void* 589 videoEditClasses_getContext( 590 bool* pResult, 591 JNIEnv* pEnv, 592 jobject object); 593 594 void 595 videoEditClasses_setContext( 596 bool* pResult, 597 JNIEnv* pEnv, 598 jobject object, 599 void* pContext); 600 601 602 #endif // VIDEO_EDITOR_CLASSES_H 603 604