Manage in-meeting annotation

The code on this page only works with the default UI.

When users start sharing their screens, others can annotate on top of the shared video feed. Through the Meeting SDK, you can manage many settings related to the appearance and availability of annotation.

Annotation settings

Before starting to annotate, check the meeting settings in the web portal to confirm that it is currently enabled. Check synchronously through the annotation controller, or receive updates asynchronously through the IMeetingAnnotationSupportEvent.

class MyAnnotationSupportEvent : public ZOOM_SDK_NAMESPACE::IMeetingAnnotationSupportEvent {
public:
    void onSupportAnnotationStatus(unsigned int nShareSourceID, bool bSupportAnnotation) override {
        if (bSupportAnnotation) {
            // Annotations are enabled
        }
        // currentShareID = nShareSourceID;
    }
};
void CheckDefaultAnnotation(ZOOM_SDK_NAMESPACE::IMeetingService* meetingService) {
    ZOOM_SDK_NAMESPACE::IAnnotationController* annotationController =
        meetingService ? meetingService->GetAnnotationController() : nullptr;
    static MyAnnotationSupportEvent annotationSupportEvent;
    if (annotationController) {
        annotationController->SetEvent(&annotationSupportEvent);
    }
    bool canDoAnno = false;
    if (annotationController &&
        !annotationController->IsAnnotationDisable() &&
        annotationController->CanDoAnnotation(ZOOM_SDK_NAMESPACE::SDK_FIRST_VIEW, canDoAnno) == ZOOM_SDK_NAMESPACE::SDKERR_SUCCESS &&
        canDoAnno) {
        // Annotations can be performed
    }
}

If the current user is sharing their screen, they can enable or disable viewers to annotate the shared screen.

bool canDisableAnnotation = false;
if (annotationController &&
    annotationController->CanDisableViewerAnnotation(ZOOM_SDK_NAMESPACE::SDK_FIRST_VIEW, canDisableAnnotation) == ZOOM_SDK_NAMESPACE::SDKERR_SUCCESS &&
    canDisableAnnotation) {
    bool isAnnotationDisabled = false;
    if (annotationController->IsViewerAnnotationDisabled(ZOOM_SDK_NAMESPACE::SDK_FIRST_VIEW, isAnnotationDisabled) == ZOOM_SDK_NAMESPACE::SDKERR_SUCCESS) {
        // Depending on the isAnnotationDisabled value, then disable/enable viewer annotation
        annotationController->DisableViewerAnnotation(ZOOM_SDK_NAMESPACE::SDK_FIRST_VIEW, false); // Or true
    }
}

Control annotation properties

In some scenarios, the SDK by default shows an annotation toolbar overlay when it is possible for users to annotate. Replace this with your own UI using the concepts described here. Before doing so, you can optionally hide the default overlay.

In default UI mode, the annotation toolbar displays only after using the IAnnotationController to manage annotations.

To start annotating, call StartAnnotation. When annotation is finished, use StopAnnotation.

if (annotationController &&
    annotationController->StartAnnotation(ZOOM_SDK_NAMESPACE::SDK_FIRST_VIEW) == ZOOM_SDK_NAMESPACE::SDKERR_SUCCESS) {
    // You can begin using the annotation tool
}
if (annotationController) {
    annotationController->StopAnnotation(ZOOM_SDK_NAMESPACE::SDK_FIRST_VIEW);
}

Optionally, after verifying that annotation started based on the return value of StartAnnotation, modify the annotation appearance programmatically.

annotationController->SetColor(ZOOM_SDK_NAMESPACE::SDK_FIRST_VIEW, RGB(255, 255, 255)); // color: RGB
annotationController->SetTool(ZOOM_SDK_NAMESPACE::SDK_FIRST_VIEW, ZOOM_SDK_NAMESPACE::ANNOTOOL_PEN); // type: AnnotationToolType
annotationController->SetLineWidth(ZOOM_SDK_NAMESPACE::SDK_FIRST_VIEW, 1); // lineWidth: long

Interact with annotations users create by undoing, redoing or clear annotations.

annotationController->Undo(ZOOM_SDK_NAMESPACE::SDK_FIRST_VIEW);
annotationController->Redo(ZOOM_SDK_NAMESPACE::SDK_FIRST_VIEW);
annotationController->Clear(ZOOM_SDK_NAMESPACE::SDK_FIRST_VIEW, ZOOM_SDK_NAMESPACE::ANNOCLEAR_ALL); // AnnotationClearType: all, self, others.