class P1::CameraSdk::Listener

Overview

Class that allows you to receive notifications for events. More…

#include <P1CameraListener.hpp>

class Listener
{
public:
    // methods

    EXPORT_API void EnableNotification(
        const Camera& camera,
        const uint32_t propertyId,
        bool isSpecificationChange = false
        );

    EXPORT_API void EnableNotification(
        const Camera& camera,
        const CameraEventId eventId
        );

    EXPORT_API void EnableNotification(const SdkEventId sdkEventId);

    EXPORT_API void DisableNotification(
        const Camera& camera,
        const uint32_t propertyId,
        bool isSpecificationChange = false
        );

    EXPORT_API void DisableNotification(
        const Camera& camera,
        const CameraEventId eventId
        );

    EXPORT_API void DisableNotification(const SdkEventId sdkEventId);
    EXPORT_API void EnableCatchAllNotifications();
    EXPORT_API void DisableCatchAllNotifications();

    EXPORT_API bool WaitForNotification(
        NotificationEvent& arrivedNotification,
        uint32_t timeoutMs = 0
        );

    EXPORT_API void WakeUpWaitingThread();
};

Detailed Documentation

Class that allows you to receive notifications for events.

The Listener is notification subscription and receive context. You enable notifications on a Listener object, and wait for incoming notifications on the same Listener.

You can create multiple listener objects, and enable different sets of notifications on them. Each listener will receive only notifications explicitly enable on each one of them.

One exception is if you enable “catch all” notifications on the listener. Then all notification generated by the CameraSDK, will be sent to the listener, even without a single call to EnableNotification(…).

When disable the “catch all” state on the listener, it returns to the normal operating state, delivering only enabled notifications.

Methods

EXPORT_API void EnableNotification(
    const Camera& camera,
    const uint32_t propertyId,
    bool isSpecificationChange = false
    )

Enables receiving a specific property notification.

All properties belongs to a Camera. Therefore you must provide the camera from which you would like to receive notifications.

Further, there are two kind of property changes that can be enabled: value change and specification changes. Value changes are changes to a property’s current value. Specification changes are changes to the PropertySpecification object, and may changes such as read-only, range and value list state.

The default options is to enable value change notifications.

Parameters:

camera

The camera who’s property we wish to receive notifications for

propertyId

The Id of the property we wish to receive notification for

isSpecificationChange

Set to true if you want only specification state change notifications

EXPORT_API void EnableNotification(
    const Camera& camera,
    const CameraEventId eventId
    )

Enables receiving notifications for Camera events.

Parameters:

camera

The camera to enable the camera event notification on

eventId

The CameraEventId enum for the event type to receive notifications for

EXPORT_API void EnableNotification(const SdkEventId sdkEventId)

Enables receiving notifications for SDK related events.

Parameters:

sdkEventId

The SdkEventId enum for the event type to receive notifications for

EXPORT_API void DisableNotification(
    const Camera& camera,
    const uint32_t propertyId,
    bool isSpecificationChange = false
    )

Disable receiving property change notifications.

This causes the listener to stop receiving new notification for the specific property change event.

Parameters:

camera

The camera who’s property to stop receiving notifications for

propertyId

The Id of the property to stop receiving notification for

isSpecificationChange

Set to true to disable specification change notifications, false for value change

EXPORT_API void DisableNotification(
    const Camera& camera,
    const CameraEventId eventId
    )

Disable receiving camera event notifications.

EXPORT_API void DisableNotification(const SdkEventId sdkEventId)

Disable receiving SDK event notifications.

EXPORT_API void EnableCatchAllNotifications()

Enable “catch all” state on this listener.

In “catch all” state, every notification generated by the SDK is delivered to this listener. (Across all opened cameras!)

This also has the effect of enabling notifications for properties that are not currently visible on the cameras. (Due to the cameras state.)

EXPORT_API void DisableCatchAllNotifications()

Disable “catch all” state on the listener.

This deactivates the delivery of all types of notifications to this listener. The listener state is returned to normal, where only enabled notification will be delivered. (The ones enabled calling EnableNotification)

Any explicitly enabled notifications will be preserved, and are thus not affected by disabling “catch all” state.

EXPORT_API bool WaitForNotification(
    NotificationEvent& arrivedNotification,
    uint32_t timeoutMs = 0
    )

Block until the next notification is received.

Parameters:

arrivedNotification

Out-parameter for the notification that is received, if any

timeoutMs

Time in milliseconds to wait for next notification, before giving up

Returns:

true if a notification was received, false if timed out

EXPORT_API void WakeUpWaitingThread()

Wakes up any thread that may be bocked in the WaitForNotification call.