//
//  VKTSampleBuffer.h
//  VideoKit
//
//  Created by Yusuf Olokoba on 3/05/2024.
//  Copyright © 2025 Yusuf Olokoba. All rights reserved.
//

#pragma once

#include <stdint.h>
#include <VideoKit/VKTStatus.h>

#pragma region --Types--
/*!
 @struct VKTSampleBuffer
 
 @abstract Sample buffer generated by a media device.

 @discussion Sample buffer generated by a media device.
*/
struct VKTSampleBuffer;
typedef struct VKTSampleBuffer VKTSampleBuffer;

/*!
 @abstract Callback invoked with new sample buffer from a media device.
 
 @param context
 User-provided context.
 
 @param sampleBuffer
 Sample buffer.
*/
typedef void (*VKTSampleBufferHandler) (void* context, VKTSampleBuffer* sampleBuffer);
#pragma endregion


#pragma region --Lifecycle--
/*!
 @function VKTSampleBufferRelease

 @abstract Release a sample buffer.

 @discussion Release a sample buffer.

 @param sampleBuffer
 Sample buffer.
*/
VKT_API VKTStatus VKTSampleBufferRelease (VKTSampleBuffer* sampleBuffer);
#pragma endregion


#pragma region --Operations--
/*!
 @function VKTSampleBufferGetTimestamp

 @abstract Get the timestamp of a sample buffer.

 @discussion Get the timestamp of a sample buffer.

 @param sampleBuffer
 Sample buffer.

 @param timestamp
 Sample buffer timestamp in nanoseconds.
*/
VKT_API VKTStatus VKTSampleBufferGetTimestamp (
    VKTSampleBuffer* sampleBuffer,
    int64_t* timestamp
);

/*!
 @function VKTSampleBufferGetCurrentTimestamp

 @abstract Get the high resolution timestamp.

 @discussion Get the high resolution timestamp.

 @param timestamp
 High resolution timestamp in nanoseconds.

 @returns Status.
*/
VKT_API VKTStatus VKTSampleBufferGetCurrentTimestamp (int64_t* timestamp);
#pragma endregion
