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);
}