44#include <SpoutLibrary.h>
58#define DEFAULT_FPS 60.0
59#define DEFAULT_CODEC RGB
61#define MOD_NAME "[spout cap.] "
87 col() <<
"\t" <<
TBOLD(
TRED(
"-t spout") <<
"[:name=<server_name>][:fps=<fps>][:codec=<codec>]") <<
"\n";
89 col() <<
"\t" <<
TBOLD(
"name") <<
"\n\t\tSpout server name\n";
92 col() <<
"\nServers:\n";
93 auto receiver = shared_ptr<SPOUTLIBRARY>(GetSpout(), [](
auto s) {s->Release();});
94 int count = receiver->GetSenderCount();
96 for (
int i = 0; i <
count; ++i) {
97 array<char, 256>
name{};
98 if (!receiver->GetSender(i,
name.data(),
name.size())) {
102 unsigned int width = 0;
103 unsigned int height = 0;
104 HANDLE dxShareHandle = 0;
106 if (!receiver->GetSenderInfo(
name.data(), width, height, dxShareHandle, dwFormat)) {
109 col() <<
"\t" <<
TBOLD(<<
name.data() <<) <<
") width: " << width <<
", height: " << height <<
"\n";
125 char *
item, *save_ptr;
128 item = strtok_r(opts,
":", &save_ptr);
130 if (strcmp(
item,
"help") == 0) {
134 }
else if (strstr(
item,
"name=") ==
item) {
135 char *
name =
item + strlen(
"name=");
136 if (strstr(
name,
"urlencoded=") ==
name) {
137 name += strlen(
"urlencoded=");
145 }
else if (strstr(
item,
"fps=") ==
item) {
146 fps = atof(
item + strlen(
"fps="));
147 }
else if (strstr(
item,
"codec=") ==
item) {
154 item = strtok_r(NULL,
":", &save_ptr);
185 s->
spout_state = shared_ptr<SPOUTLIBRARY>(GetSpout(), [](
auto s) {s->Release();});
194 MSG(INFO,
"initialized successfully, waiting for input...\n");
225 MSG(WARNING,
"No signal detected...\n");
233 "Server updated - name: %s, size: %dx%d, fps: "
247 t = std::chrono::steady_clock::now();
248 }
while (std::chrono::duration_cast<std::chrono::duration<double>>(t - s->
last_frame_captured).count() < 1 / out->
fps);
260 auto receiver = shared_ptr<SPOUTLIBRARY>(GetSpout(), [](
auto s) {s->Release();});
262 int sender_count = receiver->GetSenderCount();
265 if (*available_cards ==
nullptr) {
268 *
count = sender_count;
270 for (
int i = 0; i < *
count; ++i) {
271 array<char, 256>
name{};
272 auto& card = (*available_cards)[i];
273 if (!receiver->GetSender(i,
name.data(),
name.size())) {
275 snprintf(card.dev,
sizeof card.dev,
":device=%d", i);
276 snprintf(card.name,
sizeof card.name,
"Spout #%d", i);
278 snprintf(card.dev,
sizeof card.dev,
":name=urlencoded=");
280 sizeof card.dev - strlen(card.dev),
282 snprintf(card.name,
sizeof card.name,
"Spout %s",
name.data());
284 card.repeatable =
true;
struct audio_frame ** audio
int void(** deleter)(void *))
void vf_free(struct video_frame *buf)
Frees video_frame structure.
struct video_frame * vf_alloc_desc_data(struct video_desc desc)
const char * get_codec_name(codec_t codec)
codec_t get_codec_from_name(const char *name)
#define LOG_LEVEL_ERROR
general errors
#define LOG_LEVEL_VERBOSE
#define LOG_LEVEL_WARNING
less severe errors
bool init_gl_context(struct gl_context *context, int which)
initializes specified OpenGL context
void destroy_gl_context(struct gl_context *context)
void gl_context_make_current(struct gl_context *context)
#define VIDCAP_INIT_NOERR
state not initialized, other action performed (typically help)
#define VIDCAP_INIT_OK
initialization successful
#define VIDEO_CAPTURE_ABI_VERSION
#define VIDCAP_INIT_FAIL
error ocured
#define VIDCAP_INIT_AUDIO_NOT_SUPPORTED
card does not support audio
@ LIBRARY_CLASS_VIDEO_CAPTURE
#define REGISTER_MODULE(name, info, lclass, abi)
Registers module to global modules' registry.
static int vidcap_spout_init(struct vidcap_params *params, void **state)
static const struct video_capture_info vidcap_spout_info
static void vidcap_spout_done(void *state)
static void vidcap_spout_probe(device_info **available_cards, int *count, void(**deleter)(void *))
static struct video_frame * vidcap_spout_grab(void *state, struct audio_frame **audio)
void spout_set_log_level(void *s, int ug_level)
struct used to comunicate with audio capture/playback device
std::chrono::steady_clock::time_point last_frame_captured
shared_ptr< SPOUTLIBRARY > spout_state
char * data
Raw tile data. Pointer must be at least 4B aligned.
unsigned int width
width of every tile (!)
unsigned int height
height of every tile (!)
void(* dispose)(struct video_frame *)
Struct video_frame represents a video frame and contains video description.
struct tile tiles[FLEXIBLE_ARRAY_MEMBER]
struct video_frame_callbacks callbacks
@ PROGRESSIVE
progressive frame
@ RGB
RGB 8-bit (packed into 24-bit word)
@ RGBA
RGBA 8-bit, big-endian.
int urlencode_rfc3986_eval(int c)
size_t urldecode(char *out, size_t max_len, const char *in)
size_t urlencode(char *out, size_t max_len, const char *in, int(*eval_pass)(int c), bool space_plus_replace)
This is an umbrella header for video functions.
const char * vidcap_params_get_fmt(const struct vidcap_params *params)
unsigned int vidcap_params_get_flags(const struct vidcap_params *params)
#define VIDCAP_FLAG_AUDIO_ANY