Imported Upstream version 0.13.2+dsfg1
This commit is contained in:
commit
fb3990e9e5
2036 changed files with 287360 additions and 0 deletions
11
plugins/image-source/CMakeLists.txt
Normal file
11
plugins/image-source/CMakeLists.txt
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
project(image-source)
|
||||
|
||||
set(image-source_SOURCES
|
||||
image-source.c)
|
||||
|
||||
add_library(image-source MODULE
|
||||
${image-source_SOURCES})
|
||||
target_link_libraries(image-source
|
||||
libobs)
|
||||
|
||||
install_obs_plugin_with_data(image-source data)
|
||||
3
plugins/image-source/data/locale/ar-SA.ini
Normal file
3
plugins/image-source/data/locale/ar-SA.ini
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
ImageInput="الصورة"
|
||||
File="ملف الصورة"
|
||||
|
||||
3
plugins/image-source/data/locale/bg-BG.ini
Normal file
3
plugins/image-source/data/locale/bg-BG.ini
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
ImageInput="Изображение"
|
||||
File="Файл с изображение"
|
||||
|
||||
4
plugins/image-source/data/locale/ca-ES.ini
Normal file
4
plugins/image-source/data/locale/ca-ES.ini
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
ImageInput="Imatge"
|
||||
File="Fitxer de la imatge"
|
||||
UnloadWhenNotShowing="Descarrega la imatge de la memòria quan no es mostri"
|
||||
|
||||
4
plugins/image-source/data/locale/cs-CZ.ini
Normal file
4
plugins/image-source/data/locale/cs-CZ.ini
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
ImageInput="Obrázek"
|
||||
File="Soubor obrázku"
|
||||
UnloadWhenNotShowing="Nenačítat při skrytém"
|
||||
|
||||
4
plugins/image-source/data/locale/da-DK.ini
Normal file
4
plugins/image-source/data/locale/da-DK.ini
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
ImageInput="Billede"
|
||||
File="Billedfil"
|
||||
UnloadWhenNotShowing="Fjern billede fra hukommelsen når det ikke vises"
|
||||
|
||||
4
plugins/image-source/data/locale/de-DE.ini
Normal file
4
plugins/image-source/data/locale/de-DE.ini
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
ImageInput="Bild"
|
||||
File="Bilddatei"
|
||||
UnloadWhenNotShowing="Entlade Bild, wenn es nicht angezeigt wird"
|
||||
|
||||
4
plugins/image-source/data/locale/el-GR.ini
Normal file
4
plugins/image-source/data/locale/el-GR.ini
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
ImageInput="Εικόνα"
|
||||
File="Αρχείο εικόνας"
|
||||
UnloadWhenNotShowing="Ξεφόρτωση εικόνας όταν δεν εμφανίζεται"
|
||||
|
||||
3
plugins/image-source/data/locale/en-US.ini
Normal file
3
plugins/image-source/data/locale/en-US.ini
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
ImageInput="Image"
|
||||
File="Image File"
|
||||
UnloadWhenNotShowing="Unload image when not showing"
|
||||
4
plugins/image-source/data/locale/es-ES.ini
Normal file
4
plugins/image-source/data/locale/es-ES.ini
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
ImageInput="Imagen"
|
||||
File="Archivo de imagen"
|
||||
UnloadWhenNotShowing="Descargar la imagen mientras no se muestre"
|
||||
|
||||
4
plugins/image-source/data/locale/eu-ES.ini
Normal file
4
plugins/image-source/data/locale/eu-ES.ini
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
ImageInput="Irudia"
|
||||
File="Irudi Agiria"
|
||||
UnloadWhenNotShowing="Desgertatu irudia erakusten ez denean"
|
||||
|
||||
4
plugins/image-source/data/locale/fi-FI.ini
Normal file
4
plugins/image-source/data/locale/fi-FI.ini
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
ImageInput="Kuva"
|
||||
File="Kuvatiedosto"
|
||||
UnloadWhenNotShowing="Vapauta kuva muistista, kun se ei ole näkyvissä"
|
||||
|
||||
4
plugins/image-source/data/locale/fr-FR.ini
Normal file
4
plugins/image-source/data/locale/fr-FR.ini
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
ImageInput="Image"
|
||||
File="Fichier image"
|
||||
UnloadWhenNotShowing="Décharger l'image quand elle n'est pas affichée"
|
||||
|
||||
4
plugins/image-source/data/locale/gl-ES.ini
Normal file
4
plugins/image-source/data/locale/gl-ES.ini
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
ImageInput="Imaxe"
|
||||
File="Ficheiro de imaxe"
|
||||
UnloadWhenNotShowing="Non descargar a imaxe cando non se mostre"
|
||||
|
||||
4
plugins/image-source/data/locale/hr-HR.ini
Normal file
4
plugins/image-source/data/locale/hr-HR.ini
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
ImageInput="Slika"
|
||||
File="Datoteka slike"
|
||||
UnloadWhenNotShowing="Ukloni sliku iz memorije kada se ne prikazuje"
|
||||
|
||||
4
plugins/image-source/data/locale/hu-HU.ini
Normal file
4
plugins/image-source/data/locale/hu-HU.ini
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
ImageInput="Kép"
|
||||
File="Képfájl"
|
||||
UnloadWhenNotShowing="Kép kitöltése mikor nem jelenik meg"
|
||||
|
||||
4
plugins/image-source/data/locale/it-IT.ini
Normal file
4
plugins/image-source/data/locale/it-IT.ini
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
ImageInput="Immagine"
|
||||
File="File Immagine"
|
||||
UnloadWhenNotShowing="Non caricare immagine se non si vede"
|
||||
|
||||
4
plugins/image-source/data/locale/ja-JP.ini
Normal file
4
plugins/image-source/data/locale/ja-JP.ini
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
ImageInput="画像"
|
||||
File="画像ファイル"
|
||||
UnloadWhenNotShowing="表示中でない画像は読み込まない"
|
||||
|
||||
4
plugins/image-source/data/locale/ko-KR.ini
Normal file
4
plugins/image-source/data/locale/ko-KR.ini
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
ImageInput="이미지"
|
||||
File="이미지 파일"
|
||||
UnloadWhenNotShowing="이미지가 표시되지 않을 경우 비디오 메모리에서 읽지 않기"
|
||||
|
||||
4
plugins/image-source/data/locale/nb-NO.ini
Normal file
4
plugins/image-source/data/locale/nb-NO.ini
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
ImageInput="Bilde"
|
||||
File="Bildefil"
|
||||
UnloadWhenNotShowing="Avlast bilde når det ikke vises"
|
||||
|
||||
4
plugins/image-source/data/locale/nl-NL.ini
Normal file
4
plugins/image-source/data/locale/nl-NL.ini
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
ImageInput="Afbeelding"
|
||||
File="Afbeeldingsbestand"
|
||||
UnloadWhenNotShowing="Niet getoonde afbeeldingen uit het geheugen verwijderen"
|
||||
|
||||
4
plugins/image-source/data/locale/pl-PL.ini
Normal file
4
plugins/image-source/data/locale/pl-PL.ini
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
ImageInput="Obraz"
|
||||
File="Plik obrazu"
|
||||
UnloadWhenNotShowing="Usuń obraz z pamięci, gdy nie jest pokazywany"
|
||||
|
||||
4
plugins/image-source/data/locale/pt-BR.ini
Normal file
4
plugins/image-source/data/locale/pt-BR.ini
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
ImageInput="Imagem"
|
||||
File="Arquivo de Imagem"
|
||||
UnloadWhenNotShowing="Descarregar imagem quando não estiver em exibição"
|
||||
|
||||
4
plugins/image-source/data/locale/pt-PT.ini
Normal file
4
plugins/image-source/data/locale/pt-PT.ini
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
ImageInput="Imagem"
|
||||
File="Ficheiro de Imagem"
|
||||
UnloadWhenNotShowing="Descarregar imagem quando não estiver em visualização"
|
||||
|
||||
4
plugins/image-source/data/locale/ro-RO.ini
Normal file
4
plugins/image-source/data/locale/ro-RO.ini
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
ImageInput="Imagine"
|
||||
File="Fișier Imagine"
|
||||
UnloadWhenNotShowing="Descarca imaginea din memorie cand nu este utilizata"
|
||||
|
||||
4
plugins/image-source/data/locale/ru-RU.ini
Normal file
4
plugins/image-source/data/locale/ru-RU.ini
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
ImageInput="Изображение"
|
||||
File="Файл изображения"
|
||||
UnloadWhenNotShowing="Выгружать изображения, которые не показываются"
|
||||
|
||||
4
plugins/image-source/data/locale/sk-SK.ini
Normal file
4
plugins/image-source/data/locale/sk-SK.ini
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
ImageInput="Obrázok"
|
||||
File="Súbor s obrázkom"
|
||||
UnloadWhenNotShowing="Uvoľniť obrázok, ak nie je zobrazený"
|
||||
|
||||
4
plugins/image-source/data/locale/sl-SI.ini
Normal file
4
plugins/image-source/data/locale/sl-SI.ini
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
ImageInput="Slika"
|
||||
File="Slikovna datoteka"
|
||||
UnloadWhenNotShowing="Ne naloži slike, ko ni prikazana"
|
||||
|
||||
4
plugins/image-source/data/locale/sr-CS.ini
Normal file
4
plugins/image-source/data/locale/sr-CS.ini
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
ImageInput="Slika"
|
||||
File="Datoteka slike"
|
||||
UnloadWhenNotShowing="Ukloni sliku iz memorije kada se ne prikazuje"
|
||||
|
||||
4
plugins/image-source/data/locale/sr-SP.ini
Normal file
4
plugins/image-source/data/locale/sr-SP.ini
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
ImageInput="Слика"
|
||||
File="Датотека слике"
|
||||
UnloadWhenNotShowing="Уклони слику из меморије када се не приказује"
|
||||
|
||||
4
plugins/image-source/data/locale/sv-SE.ini
Normal file
4
plugins/image-source/data/locale/sv-SE.ini
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
ImageInput="Bild"
|
||||
File="Bildfil"
|
||||
UnloadWhenNotShowing="Ta bort bild från VRAM när den inte visas"
|
||||
|
||||
3
plugins/image-source/data/locale/th-TH.ini
Normal file
3
plugins/image-source/data/locale/th-TH.ini
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
ImageInput="รูปภาพ"
|
||||
File="ไฟล์รูปภาพ"
|
||||
|
||||
4
plugins/image-source/data/locale/tr-TR.ini
Normal file
4
plugins/image-source/data/locale/tr-TR.ini
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
ImageInput="Görüntü"
|
||||
File="Görüntü Dosyası"
|
||||
UnloadWhenNotShowing="Resim gösterilmediğinde bellekten kaldır"
|
||||
|
||||
4
plugins/image-source/data/locale/zh-CN.ini
Normal file
4
plugins/image-source/data/locale/zh-CN.ini
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
ImageInput="图像"
|
||||
File="图像文件"
|
||||
UnloadWhenNotShowing="当不显示时卸载图像"
|
||||
|
||||
4
plugins/image-source/data/locale/zh-TW.ini
Normal file
4
plugins/image-source/data/locale/zh-TW.ini
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
ImageInput="圖片"
|
||||
File="圖片檔案"
|
||||
UnloadWhenNotShowing="當不顯示圖片時卸載"
|
||||
|
||||
239
plugins/image-source/image-source.c
Normal file
239
plugins/image-source/image-source.c
Normal file
|
|
@ -0,0 +1,239 @@
|
|||
#include <obs-module.h>
|
||||
#include <graphics/image-file.h>
|
||||
#include <util/platform.h>
|
||||
#include <sys/stat.h>
|
||||
|
||||
#define blog(log_level, format, ...) \
|
||||
blog(log_level, "[image_source: '%s'] " format, \
|
||||
obs_source_get_name(context->source), ##__VA_ARGS__)
|
||||
|
||||
#define debug(format, ...) \
|
||||
blog(LOG_DEBUG, format, ##__VA_ARGS__)
|
||||
#define info(format, ...) \
|
||||
blog(LOG_INFO, format, ##__VA_ARGS__)
|
||||
#define warn(format, ...) \
|
||||
blog(LOG_WARNING, format, ##__VA_ARGS__)
|
||||
|
||||
struct image_source {
|
||||
obs_source_t *source;
|
||||
|
||||
char *file;
|
||||
bool persistent;
|
||||
time_t file_timestamp;
|
||||
float update_time_elapsed;
|
||||
uint64_t last_time;
|
||||
|
||||
gs_image_file_t image;
|
||||
};
|
||||
|
||||
|
||||
static time_t get_modified_timestamp(const char *filename)
|
||||
{
|
||||
struct stat stats;
|
||||
stat(filename, &stats);
|
||||
return stats.st_mtime;
|
||||
}
|
||||
|
||||
static const char *image_source_get_name(void *unused)
|
||||
{
|
||||
UNUSED_PARAMETER(unused);
|
||||
return obs_module_text("ImageInput");
|
||||
}
|
||||
|
||||
static void image_source_load(struct image_source *context)
|
||||
{
|
||||
char *file = context->file;
|
||||
|
||||
obs_enter_graphics();
|
||||
gs_image_file_free(&context->image);
|
||||
obs_leave_graphics();
|
||||
|
||||
if (file && *file) {
|
||||
debug("loading texture '%s'", file);
|
||||
context->file_timestamp = get_modified_timestamp(file);
|
||||
gs_image_file_init(&context->image, file);
|
||||
context->update_time_elapsed = 0;
|
||||
|
||||
obs_enter_graphics();
|
||||
gs_image_file_init_texture(&context->image);
|
||||
obs_leave_graphics();
|
||||
|
||||
if (!context->image.loaded)
|
||||
warn("failed to load texture '%s'", file);
|
||||
}
|
||||
}
|
||||
|
||||
static void image_source_unload(struct image_source *context)
|
||||
{
|
||||
obs_enter_graphics();
|
||||
gs_image_file_free(&context->image);
|
||||
obs_leave_graphics();
|
||||
}
|
||||
|
||||
static void image_source_update(void *data, obs_data_t *settings)
|
||||
{
|
||||
struct image_source *context = data;
|
||||
const char *file = obs_data_get_string(settings, "file");
|
||||
const bool unload = obs_data_get_bool(settings, "unload");
|
||||
|
||||
if (context->file)
|
||||
bfree(context->file);
|
||||
context->file = bstrdup(file);
|
||||
context->persistent = !unload;
|
||||
|
||||
/* Load the image if the source is persistent or showing */
|
||||
if (context->persistent || obs_source_showing(context->source))
|
||||
image_source_load(data);
|
||||
else
|
||||
image_source_unload(data);
|
||||
}
|
||||
|
||||
static void image_source_defaults(obs_data_t *settings)
|
||||
{
|
||||
obs_data_set_default_bool(settings, "unload", false);
|
||||
}
|
||||
|
||||
static void image_source_show(void *data)
|
||||
{
|
||||
struct image_source *context = data;
|
||||
|
||||
if (!context->persistent)
|
||||
image_source_load(context);
|
||||
}
|
||||
|
||||
static void image_source_hide(void *data)
|
||||
{
|
||||
struct image_source *context = data;
|
||||
|
||||
if (!context->persistent)
|
||||
image_source_unload(context);
|
||||
}
|
||||
|
||||
static void *image_source_create(obs_data_t *settings, obs_source_t *source)
|
||||
{
|
||||
struct image_source *context = bzalloc(sizeof(struct image_source));
|
||||
context->source = source;
|
||||
|
||||
image_source_update(context, settings);
|
||||
return context;
|
||||
}
|
||||
|
||||
static void image_source_destroy(void *data)
|
||||
{
|
||||
struct image_source *context = data;
|
||||
|
||||
image_source_unload(context);
|
||||
|
||||
if (context->file)
|
||||
bfree(context->file);
|
||||
bfree(context);
|
||||
}
|
||||
|
||||
static uint32_t image_source_getwidth(void *data)
|
||||
{
|
||||
struct image_source *context = data;
|
||||
return context->image.cx;
|
||||
}
|
||||
|
||||
static uint32_t image_source_getheight(void *data)
|
||||
{
|
||||
struct image_source *context = data;
|
||||
return context->image.cy;
|
||||
}
|
||||
|
||||
static void image_source_render(void *data, gs_effect_t *effect)
|
||||
{
|
||||
struct image_source *context = data;
|
||||
|
||||
if (!context->image.texture)
|
||||
return;
|
||||
|
||||
gs_reset_blend_state();
|
||||
gs_effect_set_texture(gs_effect_get_param_by_name(effect, "image"),
|
||||
context->image.texture);
|
||||
gs_draw_sprite(context->image.texture, 0,
|
||||
context->image.cx, context->image.cy);
|
||||
}
|
||||
|
||||
static void image_source_tick(void *data, float seconds)
|
||||
{
|
||||
struct image_source *context = data;
|
||||
uint64_t frame_time = obs_get_video_frame_time();
|
||||
|
||||
if (context->last_time && context->image.is_animated_gif) {
|
||||
uint64_t elapsed = frame_time - context->last_time;
|
||||
bool updated = gs_image_file_tick(&context->image, elapsed);
|
||||
|
||||
if (updated) {
|
||||
obs_enter_graphics();
|
||||
gs_image_file_update_texture(&context->image);
|
||||
obs_leave_graphics();
|
||||
}
|
||||
}
|
||||
|
||||
context->last_time = frame_time;
|
||||
|
||||
if (!obs_source_showing(context->source)) return;
|
||||
|
||||
context->update_time_elapsed += seconds;
|
||||
|
||||
if (context->update_time_elapsed >= 1.0f) {
|
||||
time_t t = get_modified_timestamp(context->file);
|
||||
context->update_time_elapsed = 0.0f;
|
||||
|
||||
if (context->file_timestamp < t) {
|
||||
image_source_load(context);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static const char *image_filter =
|
||||
"All formats (*.bmp *.tga *.png *.jpeg *.jpg *.gif);;"
|
||||
"BMP Files (*.bmp);;"
|
||||
"Targa Files (*.tga);;"
|
||||
"PNG Files (*.png);;"
|
||||
"JPEG Files (*.jpeg *.jpg);;"
|
||||
"GIF Files (*.gif)";
|
||||
|
||||
static obs_properties_t *image_source_properties(void *unused)
|
||||
{
|
||||
UNUSED_PARAMETER(unused);
|
||||
|
||||
obs_properties_t *props = obs_properties_create();
|
||||
|
||||
obs_properties_add_path(props,
|
||||
"file", obs_module_text("File"),
|
||||
OBS_PATH_FILE, image_filter, NULL);
|
||||
obs_properties_add_bool(props,
|
||||
"unload", obs_module_text("UnloadWhenNotShowing"));
|
||||
|
||||
return props;
|
||||
}
|
||||
|
||||
static struct obs_source_info image_source_info = {
|
||||
.id = "image_source",
|
||||
.type = OBS_SOURCE_TYPE_INPUT,
|
||||
.output_flags = OBS_SOURCE_VIDEO,
|
||||
.get_name = image_source_get_name,
|
||||
.create = image_source_create,
|
||||
.destroy = image_source_destroy,
|
||||
.update = image_source_update,
|
||||
.get_defaults = image_source_defaults,
|
||||
.show = image_source_show,
|
||||
.hide = image_source_hide,
|
||||
.get_width = image_source_getwidth,
|
||||
.get_height = image_source_getheight,
|
||||
.video_render = image_source_render,
|
||||
.video_tick = image_source_tick,
|
||||
.get_properties = image_source_properties
|
||||
};
|
||||
|
||||
OBS_DECLARE_MODULE()
|
||||
OBS_MODULE_USE_DEFAULT_LOCALE("image-source", "en-US")
|
||||
|
||||
bool obs_module_load(void)
|
||||
{
|
||||
obs_register_source(&image_source_info);
|
||||
return true;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue