PPB_VideoEncoder crashes with GetSupportedProfiles

42 views
Skip to first unread message

Andy Yanok

unread,
Nov 22, 2016, 2:16:22 PM11/22/16
to Native-Client-Discuss
I'm working on adding support to our application to use chromes PPB_VideoEncoder, however even simply attempting to get the video profiles is causing a crash in my nacl module.  Is there anything obvious you see here that would be causing the issue?  Neither the GetProfilesCallback or MyGetDataBuffer is ever hit.  The encoder_context is non 0, and the isVideoEncoder check does return true.  The logging is hit after the GetSupportedProfiles function call returns -1 indicating that is doing an async check.

I also tried to run this on Windows Chrome with the same result.  Am I just missing something really easy here?

Chrome on OSX 56.0.2922.1, using the pepper_49 SDK.

typedef struct MyArrayOutput {


       struct PP_VideoProfileDescription *codec_descriptions;


       int element_count;


    } ;

static void GetProfilesCallback(void* user_data, int32_t result)

{

   LogDebug(DbgP, "Chrome Get Profiles Callback: %i\n", result);

}


static void* MyGetDataBuffer(void* user_data, uint32_t count, uint32_t size)

{
       LogDebug(DbgP, "My Get Data Buffer: %i, %i\n", count, size);

       struct MyArrayOutput* output = (struct MyArrayOutput*)user_data;

      output->element_count = count;

   

      if (size) {

            output->codec_descriptions = (struct PP_VideoProfileDescription*)malloc(count * size);

            if (!output->codec_descriptions)  // Be careful to set size properly on malloc failure.

                  output->element_count = 0;

          } else {

                output->codec_descriptions = NULL;

              }

      return output->codec_descriptions;

}

void CheckProfiles()
{

    PP_Resource encoder_context = ppb_encoder_interface->Create(ppb_encoder_instance);

   if (encoder_context == 0) {

       LogDebug(DbgP, "Chrome Encoder failed to create encoder context.\n");

       return false;

   }

   

   PP_Bool isEncoder = ppb_encoder_interface->IsVideoEncoder(encoder_context);

   if (!isEncoder) {

       LLogDebug(DbgP, "Chrome Encoder created but the resource is not a video encoder.\n");

       return false;

   }

   

   struct MyArrayOutput arr = {NULL, 0};

   struct PP_ArrayOutput suppProfiles = {&MyGetDataBuffer, &arr};

   struct PP_CompletionCallback callback = {GetProfilesCallback, &suppProfiles, PP_COMPLETIONCALLBACK_FLAG_NONE };

   int32_t numProfiles = ppb_encoder_interface->GetSupportedProfiles(encoder_context, suppProfiles, callback);

   

   

   LogDebug(DbgP, "Number of Encoder supported profiles: %i\n", numProfiles);


}



Bill Budge

unread,
Nov 23, 2016, 2:31:46 PM11/23/16
to Native-Client-Discuss
Everything looks OK at a glance. What does your program do after CheckProfiles() returns?

Andy Yanok

unread,
Nov 28, 2016, 11:18:04 AM11/28/16
to Native-Client-Discuss
Essentially all it is doing is that call, I've tried running it on nacl load, and on a different thread.

Bill Budge

unread,
Nov 29, 2016, 4:40:00 PM11/29/16
to Native-Client-Discuss
So you're sure the instance and resource are still alive? The callback should occur after your app returns control to the browser.
Reply all
Reply to author
Forward
0 new messages