gpu accelerated
This commit is contained in:
70
tests/module-load-test.c
Normal file
70
tests/module-load-test.c
Normal file
@@ -0,0 +1,70 @@
|
||||
#include <obs/obs.h>
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <sys/stat.h>
|
||||
#include <unistd.h>
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
if (argc != 4) {
|
||||
fprintf(stderr, "usage: %s plugin.so data-directory renderer\n", argv[0]);
|
||||
return 2;
|
||||
}
|
||||
char temporary[] = "/tmp/obs-webkit-module-test-XXXXXX";
|
||||
if (!mkdtemp(temporary)) {
|
||||
perror("mkdtemp");
|
||||
return 2;
|
||||
}
|
||||
char renderer_link[512];
|
||||
char locale_link[512];
|
||||
char locale_source[512];
|
||||
snprintf(renderer_link, sizeof(renderer_link), "%s/obs-webkit-renderer", temporary);
|
||||
snprintf(locale_link, sizeof(locale_link), "%s/locale", temporary);
|
||||
snprintf(locale_source, sizeof(locale_source), "%s/locale", argv[2]);
|
||||
if (symlink(argv[3], renderer_link) || symlink(locale_source, locale_link)) {
|
||||
perror("symlink");
|
||||
return 2;
|
||||
}
|
||||
if (!obs_startup("en-US", NULL, NULL)) {
|
||||
fprintf(stderr, "obs_startup failed\n");
|
||||
return 1;
|
||||
}
|
||||
obs_module_t *module = NULL;
|
||||
int result = obs_open_module(&module, argv[1], temporary);
|
||||
if (result != MODULE_SUCCESS || !obs_init_module(module)) {
|
||||
fprintf(stderr, "module load failed: %d\n", result);
|
||||
obs_shutdown();
|
||||
return 1;
|
||||
}
|
||||
const char *name = obs_source_get_display_name("webkit_browser_source");
|
||||
uint32_t flags = obs_get_source_output_flags("webkit_browser_source");
|
||||
bool valid = name && strstr(name, "WebKit") && (flags & OBS_SOURCE_ASYNC_VIDEO) &&
|
||||
(flags & OBS_SOURCE_INTERACTION);
|
||||
if (!valid)
|
||||
fprintf(stderr, "source registration is incomplete (name=%s, flags=0x%x)\n",
|
||||
name ? name : "(null)", flags);
|
||||
obs_data_t *settings = obs_data_create();
|
||||
obs_data_set_string(settings, "url", "data:text/html,<body style='background:red'></body>");
|
||||
obs_data_set_int(settings, "width", 64);
|
||||
obs_data_set_int(settings, "height", 64);
|
||||
obs_data_set_int(settings, "fps", 10);
|
||||
obs_data_set_bool(settings, "transparent", true);
|
||||
obs_data_set_bool(settings, "hardware_acceleration", false);
|
||||
obs_source_t *source = obs_source_create_private("webkit_browser_source", "smoke", settings);
|
||||
obs_data_release(settings);
|
||||
if (!source || obs_source_get_width(source) != 64 || obs_source_get_height(source) != 64) {
|
||||
fprintf(stderr, "source lifecycle setup failed\n");
|
||||
valid = false;
|
||||
}
|
||||
if (source) {
|
||||
usleep(500000);
|
||||
obs_source_release(source);
|
||||
}
|
||||
obs_shutdown();
|
||||
unlink(renderer_link);
|
||||
unlink(locale_link);
|
||||
rmdir(temporary);
|
||||
return valid ? 0 : 1;
|
||||
}
|
||||
Reference in New Issue
Block a user