first commit

This commit is contained in:
jp9000
2013-09-30 19:37:13 -07:00
commit f255ae1922
545 changed files with 95469 additions and 0 deletions

33
test/test-input/makefile Normal file
View File

@@ -0,0 +1,33 @@
include ../../config.mak
.PHONY: all default clean
all: default
SRCFILES=test-filter.c test-input.c test-random.c
SONAME=../../build/test-input.$(SOEXT)
OBJS += $(SRCFILES:%.c=%.$(OBJ))
CPPFLAGS += -iquote../../libobs
LDFLAGS += -L../../build -lobs
default: $(SONAME)
.depend:
@rm -f .depend
@$(foreach SRC, $(addprefix $(SRCPATH)/, $(SRCFILES)), $(CCDEP) \
$(CPPFLAGS) $(SRC) \
-MT $(SRC:$(SRCPATH)/%.c=%.$(OBJ)) -MM 1>> .depend;)
$(SONAME): .depend $(OBJS)
$(LD)$@ $(LDFLAGS) $(OBJS)
depend: .depend
ifneq ($(wildcard .depend),)
include .depend
endif
clean:
rm -f $(OBJS) $(SONAME) *.a *.lib *.exp *.pdb .depend

View File

@@ -0,0 +1,68 @@
#include "test-filter.h"
struct test_filter *test_create(const char *settings, source_t source)
{
struct test_filter *tf = bmalloc(sizeof(struct test_filter));
memset(tf, 0, sizeof(struct test_filter));
tf->source = source;
tf->whatever = gs_create_effect_from_file("test.effect", NULL);
if (!tf->whatever) {
test_destroy(tf);
return NULL;
}
tf->texrender = texrender_create(GS_RGBA, GS_ZS_NONE);
return tf;
}
void test_destroy(struct test_filter *tf)
{
if (tf) {
effect_destroy(tf->whatever);
texrender_destroy(tf->texrender);
bfree(tf);
}
}
uint32_t test_get_output_flags(struct test_filter *tf)
{
return SOURCE_VIDEO;
}
void test_video_tick(struct test_filter *tf, float seconds)
{
texrender_reset(tf->texrender);
}
void test_video_render(struct test_filter *tf)
{
source_t filter_target = filter_gettarget(tf->source);
int cx = source_getwidth(filter_target);
int cy = source_getheight(filter_target);
float fcx = (float)cx;
float fcy = (float)cy;
technique_t tech;
texture_t tex;
if (texrender_begin(tf->texrender, cx, cy)) {
gs_ortho(0.0f, fcx, 0.0f, fcy, -100.0f, 100.0f);
source_video_render(filter_target);
texrender_end(tf->texrender);
}
/* --------------------------- */
tex = texrender_gettexture(tf->texrender);
tech = effect_gettechnique(tf->whatever, "Default");
effect_settexture(tf->whatever, effect_getparambyidx(tf->whatever, 1),
tex);
technique_begin(tech);
technique_beginpass(tech, 0);
gs_draw_sprite(tex);
technique_endpass(tech);
technique_end(tech);
}

View File

@@ -0,0 +1,27 @@
#ifndef FILTER_TEST_H
#define FILTER_TEST_H
#include "obs.h"
#ifdef __cplusplus
extern "C" {
#endif
struct test_filter {
source_t source;
effect_t whatever;
texrender_t texrender;
};
EXPORT struct test_filter *test_create(const char *settings, source_t source);
EXPORT void test_destroy(struct test_filter *rt);
EXPORT uint32_t test_get_output_flags(struct test_filter *rt);
EXPORT void test_video_tick(struct test_filter *rt, float seconds);
EXPORT void test_video_render(struct test_filter *rt);
#ifdef __cplusplus
}
#endif
#endif

View File

@@ -0,0 +1,17 @@
#ifndef OBS_CAPTURE_EXPORTS_H
#define OBS_CAPTURE_EXPORTS_H
#include "util/c99defs.h"
#ifdef __cplusplus
extern "C" {
#endif
EXPORT bool enum_inputs(size_t idx, const char **name);
EXPORT bool enum_filters(size_t idx, const char **name);
#ifdef __cplusplus
}
#endif
#endif

View File

@@ -0,0 +1,22 @@
#include "test-input-exports.h"
const char *inputs[] = {"random"};
const char *filters[] = {"test"};
bool enum_inputs(size_t idx, const char **name)
{
if (idx >= (sizeof(inputs)/sizeof(const char*)))
return false;
*name = inputs[idx];
return true;
}
bool enum_filters(size_t idx, const char **name)
{
if (idx >= (sizeof(filters)/sizeof(const char*)))
return false;
*name = filters[idx];
return true;
}

View File

@@ -0,0 +1,74 @@
#include <stdlib.h>
#include "test-random.h"
struct random_tex *random_create(const char *settings, source_t source)
{
struct random_tex *rt = bmalloc(sizeof(struct random_tex));
uint32_t *pixels = bmalloc(20*20*4);
size_t x, y;
memset(rt, 0, sizeof(struct random_tex));
for (y = 0; y < 20; y++) {
for (x = 0; x < 20; x++) {
uint32_t pixel = 0xFF000000;
pixel |= (rand()%256);
pixel |= (rand()%256) << 8;
pixel |= (rand()%256) << 16;
pixels[y*20 + x] = pixel;
}
}
rt->texture = gs_create_texture(20, 20, GS_RGBA, pixels, 0);
bfree(pixels);
if (!rt->texture) {
random_destroy(rt);
return NULL;
}
rt->whatever = gs_create_effect_from_file("draw.effect", NULL);
if (!rt->whatever) {
random_destroy(rt);
return NULL;
}
return rt;
}
void random_destroy(struct random_tex *rt)
{
if (rt) {
effect_destroy(rt->whatever);
texture_destroy(rt->texture);
bfree(rt);
}
}
uint32_t random_get_output_flags(struct random_tex *rt)
{
return SOURCE_VIDEO;
}
void random_video_render(struct random_tex *rt, source_t filter_target)
{
technique_t tech = effect_gettechnique(rt->whatever, "Default");
effect_settexture(rt->whatever, effect_getparambyidx(rt->whatever, 1), rt->texture);
technique_begin(tech);
technique_beginpass(tech, 0);
gs_draw_sprite(rt->texture);
technique_endpass(tech);
technique_end(tech);
}
int random_getwidth(struct random_tex *rt)
{
return texture_getwidth(rt->texture);
}
int random_getheight(struct random_tex *rt)
{
return texture_getheight(rt->texture);
}

View File

@@ -0,0 +1,28 @@
#ifndef RANDOM_TEX_H
#define RANDOM_TEX_H
#include "obs.h"
#ifdef __cplusplus
extern "C" {
#endif
struct random_tex {
texture_t texture;
effect_t whatever;
};
EXPORT struct random_tex *random_create(const char *settings, source_t source);
EXPORT void random_destroy(struct random_tex *rt);
EXPORT uint32_t random_get_output_flags(struct random_tex *rt);
EXPORT void random_video_render(struct random_tex *rt, source_t filter_target);
EXPORT int random_getwidth(struct random_tex *rt);
EXPORT int random_getheight(struct random_tex *rt);
#ifdef __cplusplus
}
#endif
#endif