orbbec-sdk-sys 0.1.2+2.5.5

Low-level Rust bindings for https://github.com/orbbec/OrbbecSDK_v2
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
// Copyright (c) Orbbec Inc. All Rights Reserved.
// Licensed under the MIT License.

#include "libobsensor/h/Frame.h"

#include "ImplTypes.hpp"
#include "exception/ObException.hpp"
#include "frame/FrameFactory.hpp"

#include "IFrame.hpp"
#include "ISensor.hpp"

#ifdef __cplusplus
extern "C" {
#endif

ob_frame *ob_create_frame(ob_frame_type frame_type, ob_format format, uint32_t data_size, ob_error **error) BEGIN_API_CALL {
    auto innerFrame  = libobsensor::FrameFactory::createFrame(frame_type, format, data_size);
    auto frameImpl   = new ob_frame();
    frameImpl->frame = innerFrame;
    return frameImpl;
}
HANDLE_EXCEPTIONS_AND_RETURN(nullptr, frame_type, format, data_size)

ob_frame *ob_create_frame_from_other_frame(const ob_frame *other_frame, bool should_copy_data, ob_error **error) BEGIN_API_CALL {
    VALIDATE_NOT_NULL(other_frame);
    auto innerFrame  = libobsensor::FrameFactory::createFrameFromOtherFrame(other_frame->frame, should_copy_data);
    auto frameImpl   = new ob_frame();
    frameImpl->frame = innerFrame;
    return frameImpl;
}
HANDLE_EXCEPTIONS_AND_RETURN(nullptr, other_frame, should_copy_data)

ob_frame *ob_create_frame_from_stream_profile(const ob_stream_profile *stream_profile, ob_error **error) BEGIN_API_CALL {
    VALIDATE_NOT_NULL(stream_profile);
    auto innerFrame  = libobsensor::FrameFactory::createFrameFromStreamProfile(stream_profile->profile);
    auto frameImpl   = new ob_frame();
    frameImpl->frame = innerFrame;
    return frameImpl;
}
HANDLE_EXCEPTIONS_AND_RETURN(nullptr, stream_profile)

ob_frame *ob_create_video_frame(ob_frame_type frame_type, ob_format format, uint32_t width, uint32_t height, uint32_t stride_bytes,
                                ob_error **error) BEGIN_API_CALL {

    auto innerFrame = libobsensor::FrameFactory::createVideoFrame(frame_type, format, width, height, stride_bytes);
    if(innerFrame == nullptr) {
        LOG_ERROR("User custom frame create failed!");
        return nullptr;
    }

    auto frameImpl   = new ob_frame();
    frameImpl->frame = innerFrame;

    return frameImpl;
}
HANDLE_EXCEPTIONS_AND_RETURN(nullptr, frame_type, format, width, height, stride_bytes)

ob_frame *ob_create_frame_from_buffer(ob_frame_type frame_type, ob_format format, uint8_t *buffer, uint32_t buffer_size,
                                      ob_frame_destroy_callback *buffer_destroy_cb, void *buffer_destroy_context, ob_error **error) BEGIN_API_CALL {
    auto innerFrame = libobsensor::FrameFactory::createFrameFromUserBuffer(
        frame_type, format, buffer, buffer_size, [buffer_destroy_cb, buffer, buffer_destroy_context]() { buffer_destroy_cb(buffer, buffer_destroy_context); });

    auto frameImpl   = new ob_frame();
    frameImpl->frame = innerFrame;

    return frameImpl;
}
HANDLE_EXCEPTIONS_AND_RETURN(nullptr, frame_type, format, buffer, buffer_size, buffer_destroy_cb, buffer_destroy_context)

ob_frame *ob_create_video_frame_from_buffer(ob_frame_type frame_type, ob_format format, uint32_t width, uint32_t height, uint32_t stride_bytes, uint8_t *buffer,
                                            uint32_t buffer_size, ob_frame_destroy_callback *buffer_destroy_cb, void *buffer_destroy_context,
                                            ob_error **error) BEGIN_API_CALL {
    auto innerFrame = libobsensor::FrameFactory::createVideoFrameFromUserBuffer(
        frame_type, format, width, height, stride_bytes, buffer, buffer_size,
        [buffer_destroy_cb, buffer, buffer_destroy_context]() { buffer_destroy_cb(buffer, buffer_destroy_context); });

    auto frameImpl   = new ob_frame();
    frameImpl->frame = innerFrame;

    return frameImpl;
}
HANDLE_EXCEPTIONS_AND_RETURN(nullptr, frame_type, format, width, height, stride_bytes, buffer, buffer_size, buffer_destroy_cb, buffer_destroy_context)

ob_frame *ob_create_frameset(ob_error **error) BEGIN_API_CALL {
    auto innerFrameSet = libobsensor::FrameFactory::createFrameSet();
    if(innerFrameSet == nullptr) {
        return nullptr;
    }

    auto frameImpl   = new ob_frame();
    frameImpl->frame = innerFrameSet;

    return frameImpl;
}
NO_ARGS_HANDLE_EXCEPTIONS_AND_RETURN(nullptr)

void ob_frame_add_ref(const ob_frame *frame, ob_error **error) BEGIN_API_CALL {
    VALIDATE_NOT_NULL(frame);
    auto unConstFrame = const_cast<ob_frame *>(frame);
    unConstFrame->refCnt += 1;
}
HANDLE_EXCEPTIONS_NO_RETURN(frame)

void ob_delete_frame(const ob_frame *frame, ob_error **error) BEGIN_API_CALL {
    VALIDATE_NOT_NULL(frame);
    auto unConstFrame = const_cast<ob_frame *>(frame);
    if(unConstFrame->refCnt > 1) {
        unConstFrame->refCnt -= 1;
        return;
    }
    delete frame;
}
HANDLE_EXCEPTIONS_NO_RETURN(frame)

void ob_frame_copy_info(const ob_frame *src_frame, ob_frame *dst_frame, ob_error **error) BEGIN_API_CALL {
    VALIDATE_NOT_NULL(src_frame);
    VALIDATE_NOT_NULL(dst_frame);
    dst_frame->frame->copyInfoFromOther(src_frame->frame);
}
HANDLE_EXCEPTIONS_NO_RETURN(src_frame, dst_frame)

uint64_t ob_frame_get_index(const ob_frame *frame, ob_error **error) BEGIN_API_CALL {
    VALIDATE_NOT_NULL(frame);
    return frame->frame->getNumber();
}
HANDLE_EXCEPTIONS_AND_RETURN(uint64_t(0), frame)

uint32_t ob_video_frame_get_width(const ob_frame *frame, ob_error **error) BEGIN_API_CALL {
    VALIDATE_NOT_NULL(frame);
    if(!frame->frame->is<libobsensor::VideoFrame>()) {
        throw libobsensor::unsupported_operation_exception("It's not a video frame!");
    }
    return frame->frame->as<libobsensor::VideoFrame>()->getWidth();
}
HANDLE_EXCEPTIONS_AND_RETURN(uint32_t(0), frame)

uint32_t ob_video_frame_get_height(const ob_frame *frame, ob_error **error) BEGIN_API_CALL {
    VALIDATE_NOT_NULL(frame);
    if(!frame->frame->is<libobsensor::VideoFrame>()) {
        throw libobsensor::unsupported_operation_exception("It's not a video frame!");
    }
    return frame->frame->as<libobsensor::VideoFrame>()->getHeight();
}
HANDLE_EXCEPTIONS_AND_RETURN(uint32_t(0), frame)

ob_format ob_frame_get_format(const ob_frame *frame, ob_error **error) BEGIN_API_CALL {
    VALIDATE_NOT_NULL(frame);
    return frame->frame->getFormat();
}
HANDLE_EXCEPTIONS_AND_RETURN(OB_FORMAT_UNKNOWN, frame)

ob_frame_type ob_frame_get_type(const ob_frame *frame, ob_error **error) BEGIN_API_CALL {
    VALIDATE_NOT_NULL(frame);
    return frame->frame->getType();
}
HANDLE_EXCEPTIONS_AND_RETURN(OB_FRAME_VIDEO, frame)

uint64_t ob_frame_get_timestamp_us(const ob_frame *frame, ob_error **error) BEGIN_API_CALL {
    VALIDATE_NOT_NULL(frame);
    return frame->frame->getTimeStampUsec();
}
HANDLE_EXCEPTIONS_AND_RETURN(uint64_t(0), frame)

uint64_t ob_frame_get_system_timestamp_us(const ob_frame *frame, ob_error **error) BEGIN_API_CALL {
    VALIDATE_NOT_NULL(frame);
    return frame->frame->getSystemTimeStampUsec();
}
HANDLE_EXCEPTIONS_AND_RETURN(uint64_t(0), frame)

void ob_frame_set_timestamp_from_system_time(ob_frame *frame, uint64_t system_timestamp_us, ob_error **error) BEGIN_API_CALL {
    VALIDATE_NOT_NULL(frame);
    auto innerFrame = frame->frame;
    innerFrame->setSystemTimeStampUsec(system_timestamp_us);
}
HANDLE_EXCEPTIONS_NO_RETURN(frame)

uint64_t ob_frame_get_global_timestamp_us(const ob_frame *frame, ob_error **error) BEGIN_API_CALL {
    VALIDATE_NOT_NULL(frame);
    return frame->frame->getGlobalTimeStampUsec();
}
HANDLE_EXCEPTIONS_AND_RETURN(uint64_t(0), frame)

void ob_frame_set_system_timestamp_us(ob_frame *frame, uint64_t timestamp_us, ob_error **error) BEGIN_API_CALL {
    VALIDATE_NOT_NULL(frame);
    auto innerFrame = frame->frame;
    innerFrame->setSystemTimeStampUsec(timestamp_us);
}
HANDLE_EXCEPTIONS_NO_RETURN(frame)

void ob_frame_set_timestamp_us(ob_frame *frame, uint64_t timestamp_us, ob_error **error) BEGIN_API_CALL {
    VALIDATE_NOT_NULL(frame);
    auto innerFrame = frame->frame;
    innerFrame->setTimeStampUsec(timestamp_us);
}
HANDLE_EXCEPTIONS_NO_RETURN(frame)

float ob_depth_frame_get_value_scale(const ob_frame *frame, ob_error **error) BEGIN_API_CALL {
    VALIDATE_NOT_NULL(frame);
    auto depthFrame = frame->frame->as<libobsensor::DepthFrame>();
    return depthFrame->getValueScale();
}
HANDLE_EXCEPTIONS_AND_RETURN(-1.0f, frame)

void ob_depth_frame_set_value_scale(ob_frame *frame, float value_scale, ob_error **error) BEGIN_API_CALL {
    VALIDATE_NOT_NULL(frame);
    auto depthFrame = frame->frame->as<libobsensor::DepthFrame>();
    depthFrame->setValueScale(value_scale);
}
HANDLE_EXCEPTIONS_NO_RETURN(frame)

float ob_points_frame_get_coordinate_value_scale(const ob_frame *frame, ob_error **error) BEGIN_API_CALL {
    VALIDATE_NOT_NULL(frame);
    auto pointsFrame = frame->frame->as<libobsensor::PointsFrame>();
    return pointsFrame->getCoordinateValueScale();
}
HANDLE_EXCEPTIONS_AND_RETURN(-1.0f, frame)

uint8_t *ob_frame_get_data(const ob_frame *frame, ob_error **error) BEGIN_API_CALL {
    VALIDATE_NOT_NULL(frame);
    return const_cast<uint8_t *>(frame->frame->getData());
}
HANDLE_EXCEPTIONS_AND_RETURN(nullptr, frame)

void ob_frame_update_data(ob_frame *frame, const uint8_t *data, uint32_t data_size, ob_error **error) BEGIN_API_CALL {
    VALIDATE_NOT_NULL(frame);
    VALIDATE_NOT_NULL(data);
    auto innerFrame = frame->frame;
    innerFrame->updateData(data, data_size);
}
HANDLE_EXCEPTIONS_NO_RETURN(frame, data, data_size)

uint32_t ob_frame_get_data_size(const ob_frame *frame, ob_error **error) BEGIN_API_CALL {
    VALIDATE_NOT_NULL(frame);
    return (uint32_t)frame->frame->getDataSize();
}
HANDLE_EXCEPTIONS_AND_RETURN(uint32_t(0), frame)

uint8_t *ob_frame_get_metadata(const ob_frame *frame, ob_error **error) BEGIN_API_CALL {
    VALIDATE_NOT_NULL(frame);
    return const_cast<uint8_t *>(frame->frame->getMetadata());
}
HANDLE_EXCEPTIONS_AND_RETURN(nullptr, frame)

uint32_t ob_frame_get_metadata_size(const ob_frame *frame, ob_error **error) BEGIN_API_CALL {
    VALIDATE_NOT_NULL(frame);
    return (uint32_t)frame->frame->getMetadataSize();
}
HANDLE_EXCEPTIONS_AND_RETURN(uint32_t(0), frame)

void ob_frame_update_metadata(ob_frame *frame, const uint8_t *metadata, uint32_t metadata_size, ob_error **error) BEGIN_API_CALL {
    VALIDATE_NOT_NULL(frame);
    VALIDATE_NOT_NULL(metadata);
    auto innerFrame = frame->frame;
    innerFrame->updateMetadata(metadata, metadata_size);
}
HANDLE_EXCEPTIONS_NO_RETURN(frame, metadata_size)

bool ob_frame_has_metadata(const ob_frame *frame, ob_frame_metadata_type type, ob_error **error) BEGIN_API_CALL {
    VALIDATE_NOT_NULL(frame);
    return frame->frame->hasMetadata(type);
}
HANDLE_EXCEPTIONS_AND_RETURN(false, frame)

int64_t ob_frame_get_metadata_value(const ob_frame *frame, ob_frame_metadata_type type, ob_error **error) BEGIN_API_CALL {
    VALIDATE_NOT_NULL(frame);
    return frame->frame->as<libobsensor::VideoFrame>()->getMetadataValue(type);
}
HANDLE_EXCEPTIONS_AND_RETURN(-1, frame)

ob_stream_profile *ob_frame_get_stream_profile(const ob_frame *frame, ob_error **error) BEGIN_API_CALL {
    VALIDATE_NOT_NULL(frame);
    auto innerProfile = frame->frame->getStreamProfile();
    if(!innerProfile) {
        return nullptr;
    }
    auto impl     = new ob_stream_profile();
    impl->profile = innerProfile;
    return impl;
}
HANDLE_EXCEPTIONS_AND_RETURN(nullptr, frame)

void ob_frame_set_stream_profile(ob_frame *frame, const ob_stream_profile *stream_profile, ob_error **error) BEGIN_API_CALL {
    VALIDATE_NOT_NULL(frame);
    VALIDATE_NOT_NULL(stream_profile);
    auto innerFrame   = frame->frame;
    auto innerProfile = stream_profile->profile;
    innerFrame->setStreamProfile(innerProfile);
}
HANDLE_EXCEPTIONS_NO_RETURN(frame, stream_profile)

ob_sensor *ob_frame_get_sensor(const ob_frame *frame, ob_error **error) BEGIN_API_CALL {
    VALIDATE_NOT_NULL(frame);
    auto innerProfile = frame->frame->getStreamProfile();
    if(!innerProfile) {
        throw libobsensor::invalid_value_exception("Frame has no owner stream profile!");
    }

    auto lazySensor = innerProfile->getOwner();
    if(!lazySensor) {
        throw libobsensor::invalid_value_exception("Frame has no owner sensor!");
    }

    std::shared_ptr<libobsensor::IDevice> device;
    try {
        device = lazySensor->device->shared_from_this();
    }
    catch(...) {
        throw libobsensor::wrong_api_call_sequence_exception("The device of the frame has been released!");
    }

    auto sensorImpl    = new ob_sensor();
    sensorImpl->device = device;
    sensorImpl->type   = lazySensor->sensorType;
    return sensorImpl;
}
HANDLE_EXCEPTIONS_AND_RETURN(nullptr, frame)

ob_device *ob_frame_get_device(const ob_frame *frame, ob_error **error) BEGIN_API_CALL {
    VALIDATE_NOT_NULL(frame);
    auto innerProfile = frame->frame->getStreamProfile();
    if(!innerProfile) {
        throw libobsensor::invalid_value_exception("Frame has no owner stream profile!");
    }

    auto lazySensor = innerProfile->getOwner();
    if(!lazySensor) {
        throw libobsensor::invalid_value_exception("Frame has no owner sensor!");
    }

    std::shared_ptr<libobsensor::IDevice> device;
    try {
        device = lazySensor->device->shared_from_this();
    }
    catch(...) {
        throw libobsensor::wrong_api_call_sequence_exception("The device of the frame has been released!");
    }

    auto deviceImpl    = new ob_device();
    deviceImpl->device = device;
    return deviceImpl;
}
HANDLE_EXCEPTIONS_AND_RETURN(nullptr, frame)

ob_pixel_type ob_video_frame_get_pixel_type(const ob_frame *frame, ob_error **error) BEGIN_API_CALL {
    VALIDATE_NOT_NULL(frame);
    return frame->frame->as<libobsensor::VideoFrame>()->getPixelType();
}
HANDLE_EXCEPTIONS_AND_RETURN(OB_PIXEL_UNKNOWN, frame)

void ob_video_frame_set_pixel_type(ob_frame *frame, ob_pixel_type pixel_type, ob_error **error) BEGIN_API_CALL {
    VALIDATE_NOT_NULL(frame);
    frame->frame->as<libobsensor::VideoFrame>()->setPixelType(pixel_type);
}
HANDLE_EXCEPTIONS_NO_RETURN(frame)

uint8_t ob_video_frame_get_pixel_available_bit_size(const ob_frame *frame, ob_error **error) BEGIN_API_CALL {
    VALIDATE_NOT_NULL(frame);
    return frame->frame->as<libobsensor::VideoFrame>()->getPixelAvailableBitSize();
}
HANDLE_EXCEPTIONS_AND_RETURN(uint8_t(0), frame)

void ob_video_frame_set_pixel_available_bit_size(ob_frame *frame, uint8_t bit_size, ob_error **error) BEGIN_API_CALL {
    VALIDATE_NOT_NULL(frame);
    frame->frame->as<libobsensor::VideoFrame>()->setPixelAvailableBitSize(bit_size);
}
HANDLE_EXCEPTIONS_NO_RETURN(frame)

ob_sensor_type ob_ir_frame_get_data_source(const ob_frame *frame, ob_error **error) BEGIN_API_CALL {
    VALIDATE_NOT_NULL(frame);
    auto type = frame->frame->as<libobsensor::VideoFrame>()->getType();
    if(type == OB_FRAME_IR) {
        return OB_SENSOR_IR;
    }
    if(type == OB_FRAME_IR_LEFT) {
        return OB_SENSOR_IR_LEFT;
    }
    if(type == OB_FRAME_IR_RIGHT) {
        return OB_SENSOR_IR_RIGHT;
    }
    throw libobsensor::invalid_value_exception("invalid ir frame type type: " + std::to_string(type));
}
HANDLE_EXCEPTIONS_AND_RETURN(OB_SENSOR_UNKNOWN, frame)

ob_accel_value ob_accel_frame_get_value(const ob_frame *frame, ob_error **error) BEGIN_API_CALL {
    VALIDATE_NOT_NULL(frame);
    if(!frame->frame->is<libobsensor::AccelFrame>()) {
        throw libobsensor::unsupported_operation_exception("It's not a accel frame!");
    }
    return frame->frame->as<libobsensor::AccelFrame>()->value();
}
HANDLE_EXCEPTIONS_AND_RETURN(ob_accel_value(), frame)

float ob_accel_frame_get_temperature(const ob_frame *frame, ob_error **error) BEGIN_API_CALL {
    VALIDATE_NOT_NULL(frame);
    if(!frame->frame->is<libobsensor::AccelFrame>()) {
        throw libobsensor::unsupported_operation_exception("It's not a accel frame!");
    }
    return frame->frame->as<libobsensor::AccelFrame>()->temperature();
}
HANDLE_EXCEPTIONS_AND_RETURN(0.0f, frame)

ob_gyro_value ob_gyro_frame_get_value(const ob_frame *frame, ob_error **error) BEGIN_API_CALL {
    VALIDATE_NOT_NULL(frame);
    if(!frame->frame->is<libobsensor::GyroFrame>()) {
        throw libobsensor::unsupported_operation_exception("It's not a gyro frame!");
    }
    return frame->frame->as<libobsensor::GyroFrame>()->value();
}
HANDLE_EXCEPTIONS_AND_RETURN(ob_gyro_value(), frame)

float ob_gyro_frame_get_temperature(const ob_frame *frame, ob_error **error) BEGIN_API_CALL {
    VALIDATE_NOT_NULL(frame);
    if(!frame->frame->is<libobsensor::GyroFrame>()) {
        throw libobsensor::unsupported_operation_exception("It's not a gyro frame!");
    }
    return frame->frame->as<libobsensor::GyroFrame>()->temperature();
}
HANDLE_EXCEPTIONS_AND_RETURN(0.0f, frame)

uint32_t ob_frameset_get_count(const ob_frame *frameset, ob_error **error) BEGIN_API_CALL {
    VALIDATE_NOT_NULL(frameset);
    if(!frameset->frame->is<libobsensor::FrameSet>()) {
        throw libobsensor::unsupported_operation_exception("It's not a frameset!");
    }
    return frameset->frame->as<libobsensor::FrameSet>()->getCount();
}
HANDLE_EXCEPTIONS_AND_RETURN(uint32_t(0), frameset)

ob_frame *ob_frameset_get_depth_frame(const ob_frame *frameset, ob_error **error) BEGIN_API_CALL {
    VALIDATE_NOT_NULL(frameset);
    if(!frameset->frame->is<libobsensor::FrameSet>()) {
        throw libobsensor::unsupported_operation_exception("It's not a frameset!");
    }
    auto innerFrame = frameset->frame->as<libobsensor::FrameSet>()->getFrame(OB_FRAME_DEPTH);
    if(innerFrame == nullptr) {
        return nullptr;
    }
    auto impl   = new ob_frame();
    impl->frame = std::const_pointer_cast<libobsensor::Frame>(innerFrame);  // todo: it's not safe to cast const to non-const, fix it;
    return impl;
}
HANDLE_EXCEPTIONS_AND_RETURN(nullptr, frameset)

ob_frame *ob_frameset_get_color_frame(const ob_frame *frameset, ob_error **error) BEGIN_API_CALL {
    VALIDATE_NOT_NULL(frameset);
    if(!frameset->frame->is<libobsensor::FrameSet>()) {
        throw libobsensor::unsupported_operation_exception("It's not a frameset!");
    }
    auto innerFrame = frameset->frame->as<libobsensor::FrameSet>()->getFrame(OB_FRAME_COLOR);
    if(innerFrame == nullptr) {
        return nullptr;
    }
    auto impl   = new ob_frame();
    impl->frame = std::const_pointer_cast<libobsensor::Frame>(innerFrame);  // todo: it's not safe to cast const to non-const, fix it;
    return impl;
}
HANDLE_EXCEPTIONS_AND_RETURN(nullptr, frameset)

ob_frame *ob_frameset_get_ir_frame(const ob_frame *frameset, ob_error **error) BEGIN_API_CALL {
    VALIDATE_NOT_NULL(frameset);
    if(!frameset->frame->is<libobsensor::FrameSet>()) {
        throw libobsensor::unsupported_operation_exception("It's not a frameset!");
    }
    auto innerFrame = frameset->frame->as<libobsensor::FrameSet>()->getFrame(OB_FRAME_IR);
    if(innerFrame == nullptr) {
        return nullptr;
    }
    auto impl   = new ob_frame();
    impl->frame = std::const_pointer_cast<libobsensor::Frame>(innerFrame);  // todo: it's not safe to cast const to non-const, fix it;
    return impl;
}
HANDLE_EXCEPTIONS_AND_RETURN(nullptr, frameset)

ob_frame *ob_frameset_get_points_frame(const ob_frame *frameset, ob_error **error) BEGIN_API_CALL {
    VALIDATE_NOT_NULL(frameset);
    if(!frameset->frame->is<libobsensor::FrameSet>()) {
        throw libobsensor::unsupported_operation_exception("It's not a frameset!");
    }
    auto innerFrame = frameset->frame->as<libobsensor::FrameSet>()->getFrame(OB_FRAME_POINTS);
    if(innerFrame == nullptr) {
        return nullptr;
    }
    auto impl   = new ob_frame();
    impl->frame = std::const_pointer_cast<libobsensor::Frame>(innerFrame);  // todo: it's not safe to cast const to non-const, fix it;
    return impl;
}
HANDLE_EXCEPTIONS_AND_RETURN(nullptr, frameset)

ob_frame *ob_frameset_get_frame(const ob_frame *frameset, ob_frame_type frame_type, ob_error **error) BEGIN_API_CALL {
    VALIDATE_NOT_NULL(frameset);
    if(!frameset->frame->is<libobsensor::FrameSet>()) {
        throw libobsensor::unsupported_operation_exception("It's not a frameset!");
    }
    auto innerFrame = frameset->frame->as<libobsensor::FrameSet>()->getFrame(frame_type);
    if(innerFrame == nullptr) {
        return nullptr;
    }
    auto impl   = new ob_frame();
    impl->frame = std::const_pointer_cast<libobsensor::Frame>(innerFrame);  // todo: it's not safe to cast const to non-const, fix it
    return impl;
}
HANDLE_EXCEPTIONS_AND_RETURN(nullptr, frameset)

ob_frame *ob_frameset_get_frame_by_index(const ob_frame *frameset, uint32_t index, ob_error **error) BEGIN_API_CALL {
    VALIDATE_NOT_NULL(frameset);
    if(!frameset->frame->is<libobsensor::FrameSet>()) {
        throw libobsensor::unsupported_operation_exception("It's not a frameset!");
    }
    auto innerFrame = frameset->frame->as<libobsensor::FrameSet>()->getFrame(index);
    if(innerFrame == nullptr) {
        return nullptr;
    }
    auto impl   = new ob_frame();
    impl->frame = std::const_pointer_cast<libobsensor::Frame>(innerFrame);  // todo: it's not safe to cast const to non-const, fix it
    return impl;
}
HANDLE_EXCEPTIONS_AND_RETURN(nullptr, frameset)

void ob_frameset_push_frame(ob_frame *frameset, const ob_frame *frame, ob_error **error) BEGIN_API_CALL {
    VALIDATE_NOT_NULL(frameset);
    VALIDATE_NOT_NULL(frame);
    auto innerFrameSet = frameset->frame->as<libobsensor::FrameSet>();
    auto innerFrame    = frame->frame;
    innerFrameSet->pushFrame(std::move(innerFrame));
}
HANDLE_EXCEPTIONS_NO_RETURN(frameset, frame)

uint32_t ob_point_cloud_frame_get_width(const ob_frame *frame, ob_error **error) BEGIN_API_CALL {
    VALIDATE_NOT_NULL(frame);
    if(!frame->frame->is<libobsensor::PointsFrame>()) {
        throw libobsensor::unsupported_operation_exception("It's not a video frame!");
    }
    return frame->frame->as<libobsensor::PointsFrame>()->getWidth();
}
HANDLE_EXCEPTIONS_AND_RETURN(uint32_t(0), frame)

uint32_t ob_point_cloud_frame_get_height(const ob_frame *frame, ob_error **error) BEGIN_API_CALL {
    VALIDATE_NOT_NULL(frame);
    if(!frame->frame->is<libobsensor::PointsFrame>()) {
        throw libobsensor::unsupported_operation_exception("It's not a video frame!");
    }
    return frame->frame->as<libobsensor::PointsFrame>()->getHeight();
}
HANDLE_EXCEPTIONS_AND_RETURN(uint32_t(0), frame)

#ifdef __cplusplus
}
#endif