2020-01-24 23:31:01 +01:00
|
|
|
#include "screencast_common.h"
|
2020-04-16 10:21:55 +02:00
|
|
|
#include <assert.h>
|
2020-01-24 23:31:01 +01:00
|
|
|
|
2020-04-16 10:21:55 +02:00
|
|
|
void randname(char *buf) {
|
|
|
|
struct timespec ts;
|
|
|
|
clock_gettime(CLOCK_REALTIME, &ts);
|
|
|
|
long r = ts.tv_nsec;
|
|
|
|
for (int i = 0; i < 6; ++i) {
|
|
|
|
assert(buf[i] == 'X');
|
|
|
|
buf[i] = 'A'+(r&15)+(r&16)*2;
|
|
|
|
r >>= 5;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-05-03 16:33:45 +02:00
|
|
|
enum spa_video_format xdpw_format_pw_from_wl_shm(
|
|
|
|
struct xdpw_screencast_instance *cast) {
|
2020-04-16 10:21:55 +02:00
|
|
|
switch (cast->simple_frame.format) {
|
2020-03-13 17:43:24 +01:00
|
|
|
case WL_SHM_FORMAT_ARGB8888:
|
2020-03-13 23:19:19 +01:00
|
|
|
return SPA_VIDEO_FORMAT_BGRA;
|
2020-03-13 17:43:24 +01:00
|
|
|
case WL_SHM_FORMAT_XRGB8888:
|
2020-03-13 23:19:19 +01:00
|
|
|
return SPA_VIDEO_FORMAT_BGRx;
|
2020-03-13 17:43:24 +01:00
|
|
|
case WL_SHM_FORMAT_RGBA8888:
|
2020-03-13 23:19:19 +01:00
|
|
|
return SPA_VIDEO_FORMAT_ABGR;
|
2020-03-13 17:43:24 +01:00
|
|
|
case WL_SHM_FORMAT_RGBX8888:
|
2020-03-13 23:19:19 +01:00
|
|
|
return SPA_VIDEO_FORMAT_xBGR;
|
2020-03-13 17:43:24 +01:00
|
|
|
case WL_SHM_FORMAT_ABGR8888:
|
2020-03-13 23:19:19 +01:00
|
|
|
return SPA_VIDEO_FORMAT_RGBA;
|
2020-03-13 17:43:24 +01:00
|
|
|
case WL_SHM_FORMAT_XBGR8888:
|
2020-03-13 23:19:19 +01:00
|
|
|
return SPA_VIDEO_FORMAT_RGBx;
|
2020-03-13 17:43:24 +01:00
|
|
|
case WL_SHM_FORMAT_BGRA8888:
|
2020-03-13 23:19:19 +01:00
|
|
|
return SPA_VIDEO_FORMAT_ARGB;
|
2020-03-13 17:43:24 +01:00
|
|
|
case WL_SHM_FORMAT_BGRX8888:
|
2020-03-13 23:19:19 +01:00
|
|
|
return SPA_VIDEO_FORMAT_xRGB;
|
2020-03-13 17:43:24 +01:00
|
|
|
case WL_SHM_FORMAT_NV12:
|
2020-03-13 23:19:19 +01:00
|
|
|
return SPA_VIDEO_FORMAT_NV12;
|
2020-03-13 17:43:24 +01:00
|
|
|
default:
|
|
|
|
abort();
|
2020-01-24 23:31:01 +01:00
|
|
|
}
|
|
|
|
}
|
2020-05-03 16:33:45 +02:00
|
|
|
|
|
|
|
enum spa_video_format xdpw_format_pw_strip_alpha(enum spa_video_format format) {
|
|
|
|
switch (format) {
|
|
|
|
case SPA_VIDEO_FORMAT_BGRA:
|
|
|
|
return SPA_VIDEO_FORMAT_BGRx;
|
|
|
|
case SPA_VIDEO_FORMAT_ABGR:
|
|
|
|
return SPA_VIDEO_FORMAT_xBGR;
|
|
|
|
case SPA_VIDEO_FORMAT_RGBA:
|
|
|
|
return SPA_VIDEO_FORMAT_RGBx;
|
|
|
|
case SPA_VIDEO_FORMAT_ARGB:
|
|
|
|
return SPA_VIDEO_FORMAT_xRGB;
|
|
|
|
default:
|
|
|
|
return SPA_VIDEO_FORMAT_UNKNOWN;
|
|
|
|
}
|
|
|
|
}
|