DSImageSourceAdapter
The ImageSourceAdapter
class is an abstract class representing an adapter for image sources, providing a framework for fetching, buffering, and managing images from various sources. Implementations must provide specific mechanisms for image retrieval and handling.
Definition
Assembly: DynamsoftCore.xcframework
- Objective-C
- Swift
@interface DSImageSourceAdapter : NSObject
class ImageSourceAdapter : NSObject
Methods & Attributes
Attributes | Type | Description |
---|---|---|
bufferEmpty |
BOOL | The read only property determines whether the buffer is currently empty. |
bufferOverflowProtectionMode |
DSBufferOverflowProtectionMode | Sets the behavior for handling new incoming images when the buffer is full. |
colourChannelUsageType |
colourChannelUsageType | Sets the usage type for color channels in images. |
hasNextImageToFetch |
BOOL | Determines whether there are more images available to fetch. |
imageCount |
NSUInteger | The property defines the current number of images in the buffer. |
maxImageCount |
NSUInteger | The property defines the maximum number of images that can be buffered. |
Method | Description |
---|---|
addImageToBuffer |
Adds an image to the internal buffer. |
clearBuffer |
Clears all images from the buffer, resetting the state for new image fetching. |
getImage |
Get a buffered image. Implementing classes should return a Promise that resolves with an instance of DSImageData . |
hasImage |
Checks if an image with the specified ID is present in the buffer. |
setErrorListener |
Sets an error listener to receive notifications about errors that occur during image source operations. |
setNextImageToReturn |
Sets the processing priority of a specific image. This can affect the order in which images are returned by getImage . |
startFetching |
Start fetching images from the source to the Video Buffer of ImageSourceAdapter. |
stopFetching |
Stop fetching images from the source to the Video Buffer of ImageSourceAdapter. |
bufferEmpty
The read only property indicates whether the Video Buffer is empty.
- Objective-C
- Swift
@property (nonatomic, assign, readonly, getter=isBufferEmpty) BOOL bufferEmpty;
var bufferEmpty: Bool { get }
bufferOverflowProtectionMode
Sets a mode that determines the action to take when there is a new incoming image and the buffer is full. You can either block the Video Buffer or push out the oldest image and append a new one.
- Objective-C
- Swift
@property (nonatomic, assign) DSBufferOverflowProtectionMode bufferOverflowProtectionMode;
var bufferOverflowProtectionMode: DSBufferOverflowProtectionMode { get set }
colourChannelUsageType
The usage type of a color channel in an image.
- Objective-C
- Swift
@property (nonatomic, assign) colourChannelUsageType;
var colourChannelUsageType: colourChannelUsageType { get set }
hasNextImageToFetch
Determines whether there are more images left to fetch.
- Objective-C
- Swift
@property (nonatomic, assign) BOOL hasNextImageToFetch;
var hasNextImageToFetch: Bool { get set }
imageCount
The property defines current image count in the Video Buffer.
- Objective-C
- Swift
@property (nonatomic, assign) NSUInteger imageCount;
var imageCount: Int { get set }
maxImageCount
The property defines the maximum capability of the Video Buffer.
- Objective-C
- Swift
@property (nonatomic, assign) NSUInteger maxImageCount;
var maxImageCount: Int { get set }
addImageToBuffer
Adds an image to the internal buffer.
- Objective-C
- Swift
- (void)addImageToBuffer:(DSImageData*)image;
func addImageToBuffer(image: DSImageData)
Parameters
[in] image
: The DSImageData object to add.
clearBuffer
Clears all images from the buffer, resetting the state for new image fetching.
- Objective-C
- Swift
- (void)clearBuffer;
func clearBuffer()
getImage
Get a buffered image. Implementing classes should return a Promise that resolves with an instance of DSImageData
.
- Objective-C
- Swift
- (DSImageData *_Nullable)getImage;
func getImage() -> DSImageData?
Return Value
An object of DSImageData
.
- If an image is set as the “next image” by method setNextImageToReturn, return that image.
- If no image is set as the “next image”, return the latest image.
hasImage
Checks if an image with the specified ID is present in the buffer.
- Objective-C
- Swift
- (BOOL)hasImage:(NSInteger)imageId;
func hasImage(imageId: Int) -> Bool
Parameters
[in] imageId
: The imageId of image you want to check the availability.
Return Value
A BOOL value that indicates whether the specified image is found in the video buffer.
setErrorListener
Sets an error listener to receive notifications about errors that occur during image source operations.
- Objective-C
- Swift
-(void)setErrorListener:(DSImageSourceErrorListener)listener;
func setErrorListener(_ listener:ImageSourceErrorListener)
Parameters
[in] listener
: A delegate object of DSImageSourceErrorListener
to receive the errors that occurs in the ImageSourceAdapter
.
setNextImageToReturn
Sets the processing priority of a specific image. This can affect the order in which images are returned by getImage
.
- Objective-C
- Swift
- (BOOL)setNextImageToReturn:(NSInteger)imageId;
func setNextImageToReturn(imageId: Int) -> Bool
Parameters
[in] imageId
: The imageId of image you want to set as the “next image”.
[in] keepInBuffer
: Set this value to true so that the “next image” is protected from being pushed out before is it returned by method getImage.
Return Value
A BOOL value that indicates whether the specified image is successfully set as the “next image”.
startFetching
Start fetching images from the source to the Video Buffer of ImageSourceAdapter
.
- Objective-C
- Swift
- (void)startFetching;
func startFetching()
stopFetching
Stop fetching images from the source to the Video Buffer of ImageSourceAdapter
.
- Objective-C
- Swift
- (void)stopFetching;
func stopFetching()