Skip to content

Commit

Permalink
Forward error and log messages to obs
Browse files Browse the repository at this point in the history
  • Loading branch information
norihiro committed Jul 23, 2024
1 parent 200ac94 commit 50cfc60
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 0 deletions.
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,11 @@ As a workaround of multi-display, the plugin provides settings `Skip update (lef
these settings will avoid tranfering unnecessary picture.
It is recommended to set the same values to the Crop settings in Scene Item Transform of your source.

## Trouble-shooting

If something wrong happened, check the log file by navigating `Help` -> `Log Files` -> `View Current Log`.
Messages from this plugin will be marked as `[obs-vnc]` and `[obs-vnc/libvncclient]`.

## Furture plan

* configurations for hide cursor, user-name, etc.,
Expand Down
38 changes: 38 additions & 0 deletions src/obs-vnc-source-thread.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
#include <obs-module.h>
#include <util/platform.h>
#include <util/threading.h>
#include <util/dstr.h>
#ifndef _WIN32
#include <sys/time.h>
#include <sys/resource.h>
Expand All @@ -38,6 +39,40 @@
#define debug(fmt, ...) (void)0
// #define debug(fmt, ...) fprintf(stderr, fmt, ##__VA_ARGS__)

static char *blog_format(const char *format)
{
struct dstr msg = {0};
dstr_init_copy(&msg, "[" PLUGIN_NAME "/libvncclient] ");

size_t len = strlen(format);
if (len > 0 && format[len - 1] == '\n')
len--;

dstr_ncat(&msg, format, len);

return msg.array;
}

static void rfb_log_info(const char *format, ...)
{
char *fmt = blog_format(format);
va_list args;
va_start(args, format);
blogva(LOG_INFO, fmt, args);
va_end(args);
bfree(fmt);
}

static void rfb_log_error(const char *format, ...)
{
char *fmt = blog_format(format);
va_list args;
va_start(args, format);
blogva(LOG_ERROR, fmt, args);
va_end(args);
bfree(fmt);
}

static inline int max_int(int a, int b)
{
return (a < b) ? b : a;
Expand Down Expand Up @@ -842,6 +877,9 @@ static void interrupt_thread(struct vnc_source *src)

void vncsrc_thread_start(struct vnc_source *src)
{
rfbClientLog = rfb_log_info;
rfbClientErr = rfb_log_error;

#ifndef _WIN32
if (!sig_hander_set) {
struct sigaction sig_handler, prev;
Expand Down

0 comments on commit 50cfc60

Please sign in to comment.