Guest User

Untitled

a guest
Apr 2nd, 2017
1,662
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 6.03 KB | None | 0 0
  1. /*******************************************************************/
  2. /*                                                                 */
  3. /*                      ADOBE CONFIDENTIAL                         */
  4. /*                   _ _ _ _ _ _ _ _ _ _ _ _ _                     */
  5. /*                                                                 */
  6. /* Copyright 2007 Adobe Systems Incorporated                       */
  7. /* All Rights Reserved.                                            */
  8. /*                                                                 */
  9. /* NOTICE:  All information contained herein is, and remains the   */
  10. /* property of Adobe Systems Incorporated and its suppliers, if    */
  11. /* any.  The intellectual and technical concepts contained         */
  12. /* herein are proprietary to Adobe Systems Incorporated and its    */
  13. /* suppliers and may be covered by U.S. and Foreign Patents,       */
  14. /* patents in process, and are protected by trade secret or        */
  15. /* copyright law.  Dissemination of this information or            */
  16. /* reproduction of this material is strictly forbidden unless      */
  17. /* prior written permission is obtained from Adobe Systems         */
  18. /* Incorporated.                                                   */
  19. /*                                                                 */
  20. /*******************************************************************/
  21.  
  22.  
  23. /* 
  24.     Grabba.cpp
  25.  
  26.     Answers the timeless question, "How do I get a rendered frame
  27.     from After Effects?"
  28.    
  29.  
  30.     version     notes                           engineer        date
  31.    
  32.     1.0         First implementation            bbb             8/21/03
  33.    
  34. */
  35.  
  36. #include "Grabba.h"
  37.  
  38. static AEGP_Command         S_Grabba_cmd        =   0L;
  39. static AEGP_PluginID        S_my_id             =   0L;
  40. static A_long               S_idle_count        =   0L;
  41. static SPBasicSuite         *sP                 =   NULL;
  42.  
  43. static A_Err
  44. DeathHook(
  45.     AEGP_GlobalRefcon   plugin_refconP,
  46.     AEGP_DeathRefcon    refconP)
  47. {
  48.     A_Err   err         = A_Err_NONE;
  49.     AEGP_SuiteHandler   suites(sP);
  50.  
  51.     A_char report[AEGP_MAX_ABOUT_STRING_SIZE] = {'\0'};
  52.        
  53.     suites.ANSICallbacksSuite1()->sprintf(report, STR(StrID_IdleCount), S_idle_count);
  54.  
  55.     return err;
  56. }
  57.  
  58. static  A_Err  
  59. IdleHook(
  60.     AEGP_GlobalRefcon   plugin_refconP,
  61.     AEGP_IdleRefcon     refconP,       
  62.     A_long              *max_sleepPL)
  63. {
  64.     A_Err   err         = A_Err_NONE;
  65.     S_idle_count++;
  66.     return err;
  67. }
  68.  
  69. static A_Err
  70. UpdateMenuHook(
  71.     AEGP_GlobalRefcon       plugin_refconPV,    /* >> */
  72.     AEGP_UpdateMenuRefcon   refconPV,           /* >> */
  73.     AEGP_WindowType         active_window)      /* >> */
  74. {
  75.     A_Err               err             =   A_Err_NONE,
  76.                         err2            =   A_Err_NONE;
  77.        
  78.     AEGP_ItemH          active_itemH    =   NULL;
  79.    
  80.     AEGP_ItemType       item_type       =   AEGP_ItemType_NONE;
  81.    
  82.     AEGP_SuiteHandler   suites(sP);
  83.    
  84.     ERR(suites.ItemSuite6()->AEGP_GetActiveItem(&active_itemH));
  85.  
  86.     if (active_itemH){
  87.         ERR(suites.ItemSuite6()->AEGP_GetItemType(active_itemH, &item_type));
  88.        
  89.         if (AEGP_ItemType_COMP      ==  item_type   ||
  90.             AEGP_ItemType_FOOTAGE   ==  item_type)  {
  91.             ERR(suites.CommandSuite1()->AEGP_EnableCommand(S_Grabba_cmd));
  92.         }
  93.     } else {
  94.         ERR2(suites.CommandSuite1()->AEGP_DisableCommand(S_Grabba_cmd));
  95.     }                  
  96.     return err;
  97. }
  98.  
  99. static A_Err
  100. CommandHook(
  101.     AEGP_GlobalRefcon   plugin_refconPV,        /* >> */
  102.     AEGP_CommandRefcon  refconPV,               /* >> */
  103.     AEGP_Command        command,                /* >> */
  104.     AEGP_HookPriority   hook_priority,          /* >> */
  105.     A_Boolean           already_handledB,       /* >> */
  106.     A_Boolean           *handledPB)             /* << */
  107. {
  108.     A_Err           err         =   A_Err_NONE,
  109.                     err2        =   A_Err_NONE;
  110.                    
  111.     AEGP_SuiteHandler   suites(sP);
  112.    
  113.     if (S_Grabba_cmd == command){
  114.  
  115.         AEGP_ItemH          active_itemH    =   NULL;
  116.         AEGP_RenderOptionsH roH             =   NULL;
  117.  
  118.         ERR(suites.ItemSuite6()->AEGP_GetActiveItem(&active_itemH));
  119.        
  120.         if (active_itemH){
  121.             ERR(suites.RenderOptionsSuite1()->AEGP_NewFromItem(S_my_id, active_itemH, &roH));
  122.            
  123.             if (!err && roH){
  124.                 AEGP_FrameReceiptH  receiptH    = NULL;
  125.                 AEGP_WorldH         frameH      = NULL;
  126.                 A_Time              timeT       = {0,1};
  127.                 AEGP_WorldType      type        = AEGP_WorldType_NONE;
  128.                
  129.                 ERR(suites.RenderOptionsSuite1()->AEGP_SetTime(roH, timeT)); // avoid "div by 0"
  130.                 ERR(suites.RenderOptionsSuite1()->AEGP_GetWorldType(roH, &type));
  131.                 ERR(suites.RenderSuite2()->AEGP_RenderAndCheckoutFrame(roH, NULL, NULL, &receiptH));
  132.                
  133.                 if (receiptH){
  134.                     ERR(suites.RenderSuite2()->AEGP_GetReceiptWorld(receiptH, &frameH));
  135.                    
  136.                     //  WooHOO! Pixel Party!
  137.                    
  138.                     //  We Crash, So You Don't Have To...
  139.                     // 
  140.                     //  A nice developer like yourself might instinctually
  141.                     //  AEGP_Dispose() of the frame you just got. Actually,
  142.                     //  After Effects will manage that frame for you. Do
  143.                     //  not dispose! Thanks for being so considerate. Now
  144.                     //  go wash your hands.
  145.  
  146.                     ERR2(suites.RenderSuite2()->AEGP_CheckinFrame(receiptH));
  147.                 }
  148.             }
  149.             ERR(suites.RenderOptionsSuite1()->AEGP_Dispose(roH));
  150.         }
  151.         *handledPB = TRUE; 
  152.     }
  153.     return err;
  154. }
  155.  
  156. A_Err
  157. EntryPointFunc(
  158.     struct SPBasicSuite     *pica_basicP,       /* >> */
  159.     A_long                  major_versionL,     /* >> */       
  160.     A_long                  minor_versionL,     /* >> */       
  161.     AEGP_PluginID           aegp_plugin_id,     /* >> */
  162.     AEGP_GlobalRefcon       *global_refconV)    /* << */
  163. {
  164.     S_my_id                                     = aegp_plugin_id;
  165.     A_Err                   err                 = A_Err_NONE,
  166.                             err2                = A_Err_NONE;
  167.    
  168.     sP = pica_basicP;
  169.    
  170.     AEGP_SuiteHandler suites(pica_basicP);
  171.    
  172.    
  173.     ERR(suites.CommandSuite1()->AEGP_GetUniqueCommand(&S_Grabba_cmd));
  174.    
  175.    
  176.     ERR(suites.CommandSuite1()->AEGP_InsertMenuCommand( S_Grabba_cmd,
  177.                                                         "Grabba",
  178.                                                         AEGP_Menu_EXPORT,
  179.                                                         AEGP_MENU_INSERT_SORTED));
  180.    
  181.     ERR(suites.RegisterSuite5()->AEGP_RegisterCommandHook(  S_my_id,
  182.                                                             AEGP_HP_BeforeAE,
  183.                                                             AEGP_Command_ALL,
  184.                                                             CommandHook,
  185.                                                             0));
  186.     ERR(suites.RegisterSuite5()->AEGP_RegisterDeathHook(    S_my_id, DeathHook, NULL));
  187.  
  188.     ERR(suites.RegisterSuite5()->AEGP_RegisterUpdateMenuHook(S_my_id, UpdateMenuHook, NULL));
  189.  
  190.     ERR(suites.RegisterSuite5()->AEGP_RegisterIdleHook(S_my_id, IdleHook, NULL));
  191.    
  192.     if (err){ // not !err, err!
  193.         ERR2(suites.UtilitySuite3()->AEGP_ReportInfo(S_my_id, "Grabba : Could not register command hook."));
  194.     }
  195.     return err;
  196. }
Advertisement
Add Comment
Please, Sign In to add comment