6 Replies Latest reply: May 18, 2010 5:40 AM by dheeraj_c RSS

    Issue with responding to AEGP from custom effect.

    dheeraj_c Community Member

      Hi,

          I checked ProjectDumper & Shifter projects. I noticed that ProjectDumper is communicating with Shifter effect through

       

      suites.EffectSuite2()->AEGP_EffectCallGeneric(S_my_id, effectH, &fake_timeT, (void*)"ProjDumper says hello to Shifter");

       

      But when I tried to communicate from Sweetie to Checkout using the AEGP_EffectCallGeneric call, I'm not getting any callbacks.

       

      In the Checkout project I'm handling PF_Cmd_COMPLETELY_GENERAL also. But when AEGP_EffectCallGeneric() is called from Sweetie project, I'm not getting the call to EntryPoint in Checkout project.

       

      This is sample code :

       

      In Sweetie project:

       

      A_Time                    fake_timeT = {0, 100};
         
      suites.EffectSuite2()->AEGP_EffectCallGeneric(      S_my_id,            /* >> */
                                                        effectPH,            /* >> */
                                                        &fake_timeT,//const A_Time        *timePT,                /* >> Use the timebase of the layer to which effect is applied. */
                                                        //PF_Cmd_COMPLETELY_GENERAL,                /* >> new parameter from version 2 */
                                                        (void*)"Hello");

       

      In Checkout project :

       

      DllExport   
      PF_Err
      EntryPointFunc (   
          PF_Cmd            cmd,
          PF_InData        *in_data,
          PF_OutData        *out_data,
          PF_ParamDef        *params[],
          PF_LayerDef        *output,
          void            *extraP )
      {  

           PF_Err        err = PF_Err_NONE;

       

          switch (cmd)

           {

                case PF_Cmd_COMPLETELY_GENERAL:
                 err = RespondToAEGP(in_data,out_data,params,output,extraP);
                 break;

           }
      }

       

       

      Am I missing something? What else should I need to do to get the callback to EntryPointFunc() in Checkout project?

       

      Thanks,

      Dheeraj

        • 1. Re: Issue with responding to AEGP from custom effect.
          shachar carmi Community Member

          the code you psted seems ok,

          so i'll ask some stupid questions.

           

          what effect does the effectPH you're using points to?

          does the AEGP_EffectCallGeneric function return any errors?

           

          p.s.

          AEGP_EffectCallGeneric is for when the AEGP wants to call the effect.

          if you want your effect to contact the AEGP, you should use custom made suites, that are show in the sweety and checkout samples.

          this code is taken from the checkout, in it's global setup:

           

           

           

          if (AEFX_AcquireSuite( in_data,

          out_data,

          kDuckSuite1,

          kDuckSuiteVersion1,

           

          "Couldn't load suite.",

          (

          void**)&dsP)) {

          PF_STRCPY(out_data->return_msg,

          "No Duck Suite! That's OK; check the Sweetie sample for details.");

          }

          else {

           

          if (dsP) {

          dsP->Quack(2);

          ERR(AEFX_ReleaseSuite( in_data,

          out_data,

          kDuckSuite1,

          kDuckSuiteVersion1,

           

          "Couldn't release suite."));

          }

          }

           

          if i remember correctly what you wrote in previous posts, that's what you were looking for and not AEGP_EffectCallGeneric.

          • 2. Re: Issue with responding to AEGP from custom effect.
            dheeraj_c Community Member

            Thank you Shachar for the reply.

             

            You are right I was looking for effect->AEGP communication in the previous post. I got it working after you told me to look into sweetie and checkout projects. Thank you for that  too.

             

            Now this is what I'm doing :

             

            From checkout I'm passing (PF_InData        *in_data) to the Sweetie project.

             

            In the Sweetie project I'm doing this :

             

            As soon I get the callback from the checkout, I'm trying to communicate back to Checkout from Sweetie project.

            This is how I'm trying to communicate:

             

            static SPAPI A_Err   
            CalledFromEffect(void* ptr) //ptr : PF_InData sent from checkout.
            {
                PF_InData* pIndata = static_cast<PF_InData*> (ptr);
               
                AEGP_SuiteHandler    suites(sP);

                 A_Err                 err                    = A_Err_NONE;


                AEGP_EffectRefH effectPH = NULL;
               
                ERR(suites.PFInterfaceSuite1()->AEGP_GetNewEffectForEffect(S_my_id,
                                                                       pIndata->effect_ref,                       //Checkout's effect_ref
                                                                       &effectPH));                                   //this has to give AEGP_EffectRefH corresponding to Checkout right?


                A_Time                    fake_timeT = {0, 100};
               
                ERR(suites.EffectSuite2()->AEGP_EffectCallGeneric(S_my_id,           
                                                              effectPH,           
                                                              &fake_timeT,
                                                              (void*)"Hello"));

             

                return err;
            }

             

            And AEGP_EffectCallGeneric() is not returning any error.

             

            What could be the issue?

            • 3. Re: Issue with responding to AEGP from custom effect.
              shachar carmi Community Member

              //this has to give AEGP_EffectRefH corresponding to Checkout right?

              wrong.

              but let's discuss that later.

               

              let's assume for a moment that you get get a valid effectRefH.

              you say the you call the effect back as soon as the effect calls the AEGP via a suite.

              do you wait until the effect exits from it's call? maybe it' still busy with original call from which it called your AEGP.

              if you want to be sure it's free, you have to wait until the calling effect finished and only then contact it.

              you could do that using idle_hook.

              when the effect calls the AEGP, the AEGP sets a flag and waits until an idle_hook call.

              when that comes, it sees it has a flag on, and initiates the effectCallGenreic at a time in which the effect is surely idle.

               

              another alternative based on the suumption that you reply immeidately without letting the original caller exit first,

              is to reply back via that same suite that did the calling.

              when an effect calls your AEGP via your suite it can pass an empty structure or a pointer to any piece of data, and have the AEGP fill it with data and instructions.

              the process continues with the calling effect without using effectCallGeneric.

               

               

              back to that thing from the beginning.

              as far as i know, the AEGP_GetNewEffectForEffect works for the calling effect, regardless of the pIndata->effect_ref passed to the function.

              you can use that function from within effects with a NULL for an pIndata->effect_ref, and it will still work.

              you'll have to get the effectPH the old fashioned way, using AEGP_GetLayerEffectByIndex.

               

              actually there are a few ways for you to get the AEGP_EffectRefH.

              the first would be to have the effect find out it's own effectRef using GetNewEffectForEffect,

              and have the effect deliver that to the AEGP via your suite.

              that effect ref would be valid as long as the calling effect didn't exit yet. that effect ref will also have to be disposed of.

              after the effect has exited it's call, your can't count on the effectRef bieng valid anymore.

              it could work, but it will fail if any other plug-in has acquired an effectRef in the mean time.

               

              you could have the effect deliver it's LayerH to the AEGP, and have the AEGP search that LayerH for your effect, and get it's reff using AEGP_GetLayerEffectByIndex.

              the LayerH is less likely to change under you than an EffectRefH is, but still, you can't count on it 100%.

               

              sadly, there's no API a project wide, and lasting way of recognising an effect.

              the only full 100% proof solution would be to send the AEGP the itemID of the comp, and the layerID of the correct layer, and have the AEGP look for the matching comp in the project, and the matching layer in the comp, and the correct effect on the layer.

              the itemID and layerID both last for the lifetime of the project, and are stored with the project.

              they will only change is the project is imported into another project.

               

              for short term tracking of effects i personally store the layerH and scan that layer for the correct effect.

              i keep telling myself i have to convert to the full solution, but i guess i'm too lazy to implement it (and it sacns the whole project each time it's used).

              you should decide how much faith you put into having the effectRefH, layerH, or compH not change under you without notice.

              • 4. Re: Issue with responding to AEGP from custom effect.
                dheeraj_c Community Member

                Thank you very much Shachar. I think you have a lot of patience. You have given all possible solutions. I finally got it working. Thank you very much for your reply.

                • 5. Re: Issue with responding to AEGP from custom effect.
                  shachar carmi Community Member

                  how did you solve it eventually?

                  (please contribute to the common knowledge)

                  • 6. Re: Issue with responding to AEGP from custom effect.
                    dheeraj_c Community Member

                    I did it through AEGP_RegisterIdleHook callback method.

                     

                    In the sweetie project I added following code :

                     

                    static A_Err
                    IdleHook(                           
                             AEGP_GlobalRefcon    plugin_refconP, 
                             AEGP_IdleRefcon        refconP,           
                             A_long                 *max_sleepPL)
                    {
                        A_Err                 err                   =      A_Err_NONE;
                       
                        if (!iIsValueChanged) //this is the flag I set when I need to contact the effect.

                        {
                            return err;

                        }
                        else
                        {
                            iIsValueChanged = 0;
                        }
                       
                        AEGP_SuiteHandler    suites(sP);
                           
                        AEGP_LayerH            layerH                     = NULL;
                       
                        AEGP_EffectRefH        effectRefH             = NULL;
                       
                        AEGP_InstalledEffectKey installedKey      = NULL;
                       
                        A_long    num_effectsL                              = 0;
                       
                        char* effectName = new char;
                       
                        ERR(suites.LayerSuite7()->AEGP_GetActiveLayer(&layerH));     //just for now taking the active layer.
                           
                       if (layerH)
                        {
                            ERR(suites.EffectSuite3()->AEGP_GetLayerNumEffects(layerH, &num_effectsL));
                            
                            for (A_long i = 0; i < num_effectsL; ++i)
                            {
                                ERR(suites.EffectSuite3()->AEGP_GetLayerEffectByIndex(S_my_id, layerH, i, &effectRefH));
                               
                                if (effectRefH)
                                {
                                    ERR(suites.EffectSuite3()->AEGP_GetInstalledKeyFromLayerEffect(effectRefH, &installedKey));
                                    ERR(suites.EffectSuite3()->AEGP_GetEffectMatchName(installedKey, effectName));
                                   
                                    if(strcmp(effectName, "ADBE Checkout") == 0)
                                    {
                                        A_Time                    fake_timeT = {0, 100};
                                       
                                        ERR(suites.EffectSuite2()->AEGP_EffectCallGeneric(S_my_id,
                                                                                          effectRefH,           
                                                                                          &fake_timeT,           
                                                                                          "Called from AEGP"));
                                   
                                        delete [] effectName;
                                       
                                        break;
                                    }
                                   
                                }
                            }
                        }
                       
                        return err;
                    }

                     

                    That's it Shachar. Thank you again. Please let me know in case there is a better way of doing this.