Sunshine v2025.118.151840
Self-hosted game stream host for Moonlight.
av_img_t.h
Go to the documentation of this file.
1
5#pragma once
6
8
9#include <CoreMedia/CoreMedia.h>
10#include <CoreVideo/CoreVideo.h>
11
12namespace platf {
14 CMSampleBufferRef buf;
15
16 explicit av_sample_buf_t(CMSampleBufferRef buf):
17 buf((CMSampleBufferRef) CFRetain(buf)) {}
18
20 if (buf != nullptr) {
21 CFRelease(buf);
22 }
23 }
24 };
25
27 CVPixelBufferRef buf;
28
29 // Constructor
30 explicit av_pixel_buf_t(CMSampleBufferRef sb):
31 buf(
32 CMSampleBufferGetImageBuffer(sb)) {
33 CVPixelBufferLockBaseAddress(buf, kCVPixelBufferLock_ReadOnly);
34 }
35
36 [[nodiscard]] uint8_t *
37 data() const {
38 return static_cast<uint8_t *>(CVPixelBufferGetBaseAddress(buf));
39 }
40
41 // Destructor
43 if (buf != nullptr) {
44 CVPixelBufferUnlockBaseAddress(buf, kCVPixelBufferLock_ReadOnly);
45 }
46 }
47 };
48
49 struct av_img_t: img_t {
50 std::shared_ptr<av_sample_buf_t> sample_buffer;
51 std::shared_ptr<av_pixel_buf_t> pixel_buffer;
52 };
53
55 std::shared_ptr<av_sample_buf_t> sample_buffer;
56 std::shared_ptr<av_pixel_buf_t> pixel_buffer;
57 uint8_t *data;
58
60 std::shared_ptr<av_sample_buf_t> sb,
61 std::shared_ptr<av_pixel_buf_t> pb,
62 uint8_t *dt):
63 sample_buffer(std::move(sb)),
64 pixel_buffer(std::move(pb)), data(dt) {}
65 };
66} // namespace platf
Declarations for common platform specific utilities.
Definition av_img_t.h:49
Definition av_img_t.h:26
Definition av_img_t.h:13
Definition common.h:341
Definition av_img_t.h:54