CRI Sofdec2  Last Updated: 2022-11-21 16:25 p
Sample: Cuepoints
This sample demonstrates how to use CRI Movie's cuepoint feature. For a general overview of cuepoints, refer to Cue Points .

Program Flow

The basic procedure for cuepoint playback is as follows:
  1. Register the memory allocator function for metadata.
  2. Register the cuepoint callback.
  3. Start playback.

1. Register the Memory Allocator Function for Metadata
/* Player creation */
app_obj->player = criManaPlayer_Create(NULL, 0);
/* [Cuepoints] */
/* A work area for metadata is required to get the cuepoints. */
/* Register an allocator separately for the metadata work area */
criManaPlayer_SetMetaDataWorkAllocator(app_obj->player, user_alloc, user_free, NULL, CRIMANA_META_FLAG_ALL);
CriManaPlayerHn criManaPlayer_Create(void *work, CriSint32 work_size)
Create Mana player (no config specified)
void criManaPlayer_SetMetaDataWorkAllocator(CriManaPlayerHn player, CriManaMetaMallocFunc allocfunc, CriManaMetaFreeFunc freefunc, void *obj, CriManaMetaFlag meta_flag)
Register meta data allocator.
@ CRIMANA_META_FLAG_ALL
Definition: cri_mana.h:342


To perform cuepoint playback, you must use the criManaPlayer_SetMetaDataWorkAllocator function before header analysis to register an allocator for metadata separately from normal allocators. The allocator can be the same as an allocator registered with the ::criMana_UserAllocator function. However, note that during multithreaded operation the allocator for metadata may be called from another thread.


If you do not register an allocator, you will be unable to perform cuepoint playback.

2. Register the Cuepoint Callback
/* [Cuepoints] */
/* Get the list of cuepoints */
app_obj->cueinf = criManaPlayer_GetCuePointInfo(app_obj->player);
if (app_obj->cueinf != NULL) {
user_print_cuepoint_list(app_obj->cueinf);
/* Set the cuepoint notification callback */
criManaPlayer_SetCuePointCallback(app_obj->player, user_cuepoint_callback, (void*)app_obj);
} else {
criFwPrt_DebugPrintf("<NO CUEPOINT INFO FOUND>");
}
CriManaCuePointInfo * criManaPlayer_GetCuePointInfo(CriManaPlayerHn player)
Get a list of Cuepoint information.
void criManaPlayer_SetCuePointCallback(CriManaPlayerHn player, CriManaPlayerCuePointCbFunc func, void *obj)
Set Cuepoint callback.


If there is cuepoint information in the movie, you can get the cuepoint list information via the criManaPlayer_GetCuePointInfo function after header analysis is finished. Once you confirm that cuepoints exist, use the criManaPlayer_SetCuePointCallback function to register an event callback.


3. Start Playback
The following procedure is the same as normal playback to start movie playback. Movie playback proceeds and when the playback time reaches a cuepoint time, an event callback will be triggered from within the criMana_ExecuteMain function. When this event is triggered, any required processing is performed by the application.
/* [Cuepoints] Cuepoint notification callback */
static void user_cuepoint_callback(void* obj, CriManaPlayerHn player, CriManaEventPoint *eventinfo)
{
CriUint64 tcount, tunit;
AppObj *app_obj = (AppObj*)obj;
/* [Note] Processing in Callbacks */
/* Do not call the Mana player's playback control API from within a cuepoint callback. */
/* (For example, Start, DecodeHeader, Stop, Create, Destroy, etc.) */
/* If you want to control the player using this callback as a trigger, save the commands */
/* and call them in the main loop after execution of the callback. */
/* Then, perform the required processing in the application based on this event information. */
}
CriManaPlayerObj * CriManaPlayerHn
Player handle.
Definition: cri_mana.h:571
Event point information.
Definition: cri_mana.h:474