Skip to content

Commit

Permalink
[obs] fix compilation for older versions of OBS
Browse files Browse the repository at this point in the history
  • Loading branch information
gnif committed Mar 18, 2024
1 parent fb1d96e commit 0990c59
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions obs/lg.c
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,9 @@ typedef struct
DMAFrameInfo dmaInfo[LGMP_Q_FRAME_LEN];
#endif

#if LIBOBS_API_MAJOR_VER >= 28
enum gs_color_space colorSpace;
#endif

pthread_t frameThread, pointerThread;
os_sem_t * frameSem;
Expand Down Expand Up @@ -681,19 +683,25 @@ static void lgVideoTick(void * data, float seconds)
case FRAME_TYPE_BGRA:
format = GS_BGRA_UNORM;
drm_format = DRM_FORMAT_ARGB8888;
#if LIBOBS_API_MAJOR_VER >= 28
this->colorSpace = GS_CS_SRGB;
#endif
break;

case FRAME_TYPE_RGBA:
format = GS_RGBA_UNORM;
drm_format = DRM_FORMAT_ARGB8888;
#if LIBOBS_API_MAJOR_VER >= 28
this->colorSpace = GS_CS_SRGB;
#endif
break;

case FRAME_TYPE_RGBA10:
format = GS_R10G10B10A2;
drm_format = DRM_FORMAT_BGRA1010102;
#if LIBOBS_API_MAJOR_VER >= 28
this->colorSpace = GS_CS_709_SCRGB;
#endif
break;

case FRAME_TYPE_RGB_24:
Expand All @@ -704,15 +712,19 @@ static void lgVideoTick(void * data, float seconds)
case FRAME_TYPE_BGR_32:
format = GS_BGRA_UNORM;
drm_format = DRM_FORMAT_ARGB8888;
#if LIBOBS_API_MAJOR_VER >= 28
this->colorSpace = GS_CS_SRGB;
#endif
unpack = true;
break;

case FRAME_TYPE_RGBA16F:
this->bpp = 8;
format = GS_RGBA16F;
drm_format = DRM_FORMAT_ABGR16161616F;
#if LIBOBS_API_MAJOR_VER >= 28
this->colorSpace = GS_CS_709_SCRGB;
#endif
break;

default:
Expand Down Expand Up @@ -901,12 +913,14 @@ static void lgVideoRender(void * data, gs_effect_t * effect)
}
}

#if LIBOBS_API_MAJOR_VER >= 28
static enum gs_color_space lgVideoGetColorSpace(void *data, size_t count,
const enum gs_color_space *preferred_spaces)
{
LGPlugin * this = (LGPlugin *)data;
return this->colorSpace;
}
#endif

static uint32_t lgGetWidth(void * data)
{
Expand Down Expand Up @@ -934,7 +948,9 @@ struct obs_source_info lg_source =
.get_properties = lgGetProperties,
.video_tick = lgVideoTick,
.video_render = lgVideoRender,
#if LIBOBS_API_MAJOR_VER >= 28
.video_get_color_space = lgVideoGetColorSpace,
#endif
.get_width = lgGetWidth,
.get_height = lgGetHeight,
.icon_type = OBS_ICON_TYPE_DESKTOP_CAPTURE
Expand Down

0 comments on commit 0990c59

Please sign in to comment.