poolTrackResults method Null safety

TrackingData poolTrackResults()

Synchronous method for obtaining tracking results.

Returns the last TrackingCallbackData, TemplateCreatedCallbackData, TrackingLostCallbackData structs.

Implementation

TrackingData poolTrackResults() {
  TrackingData trackData = new TrackingData();

  final storage = poll(_impl, 1);

  if (storage.address == nullptr.address) {
    // developer.log("Storage nullpointer", name: 'my.app.category');
    return trackData;
  }

  final track_callback = getPointer(storage, StructStorageFields.video_worker_tracking_callback_t);

  if (track_callback.address != nullptr.address) {
    final td = _parseTrackingCallback(track_callback);
    trackData.tracking_callback_data = td;
  }

  final templ_create_callback = getPointer(storage, StructStorageFields.video_worker_template_created_callback_t);

  if (templ_create_callback.address != nullptr.address) {
    trackData.template_created_callback_data = _parseTemplateCreatedCallback(templ_create_callback);
  }

  final lost_callback = getPointer(storage, StructStorageFields.video_worker_tracking_lost_callback_t);

  if (lost_callback.address != nullptr.address) {
    trackData.tracking_lost_callback_data = _parseTrackingLostCallback(lost_callback);
  }

  final match_found_callback = getPointer(storage, StructStorageFields.video_worker_match_found_callback_t);
  if (match_found_callback.address != nullptr.address) {
    trackData.tracking_match_found_callback_data = _parseTrackingMatchFoundCallback(match_found_callback);
  }

  final sti_person_callback = getPointer(storage, StructStorageFields.video_worker_tracking_sti_callback_t);
  if (sti_person_callback.address != nullptr.address) {
    trackData.sti_person_outdated_callback_data = _parseStiPersonOutdatedCallbackData(sti_person_callback);
  }

  return trackData;
}