WVR_RegisterTrackerInfoCallback

WVR_EXPORT WVR_Result WVR_RegisterTrackerInfoCallback(WVR_TrackerInfoNotify_t * notify)

Function to register an info notify of tracker.

Version
API Level 9
Parameters
  • notify: which contains an info callback function. This callback function will be called if a tracker info notify has been triggered by tracker device. (Refer to WVR_TrackerInfoNotify.)
Return Value
  • WVR_Success: start the tracker feature successfully.
  • others: means failure. (Refer to WVR_Result.)

Warning

  • This function only works at API level 9 or later.

How to use

Here is an example for the function:

  1. Header & global variable.
#include <wvr/wvr.h> // for enum WVR_SupportedFeature
#include <wvr/wvr_tracker.h>
#include <wvr/wvr_types.h>

bool gRunningTR = false;
  1. Start tracker feature first if it has not been started yet. (See also WVR Supported Features)
if (WVR_GetSupportedFeatures() & WVR_SupportedFeature_Tracker) { // the tracker feature is supported or not
    WVR_Result res = WVR_StartTracker();
    if (res == WVR_Success) gRunningTR = true;
}
  1. Implement the callback function. (See also WVR_TrackerInfoCallback.)
void CustomizedTrackerInfoCallback(WVR_TrackerId trackerId, const char *cbInfo, uint64_t *cbTimestamp);

void CustomizedTrackerInfoCallback(WVR_TrackerId trackerId, const char *cbInfo, uint64_t *cbTimestamp) {
    LOGD("CustomizedTrackerInfoCallback, WVR_TrackerId(%d), cbInfo(%s), cbTs(%" PRId64 ")", trackerId, cbInfo, *cbTimestamp);

    // TODO: The developer might want to do something corresponding to this function call.
}
  1. Use function WVR_RegisterTrackerInfoCallback to register callback function.
if (gRunningTR) {
    WVR_TrackerInfoNotify_t mTrackerInfoNotify;
    mTrackerInfoNotify.callback = CustomizedTrackerInfoCallback;
    WVR_Result ret = WVR_RegisterTrackerInfoCallback(&mTrackerInfoNotify);
}
  1. Passively waiting for the callback function CustomizedTrackerInfoCallback to be called from Wave runtime (triggered by tracker device). The tracker info (cbInfo, cbTimestamp) will be updated.