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