mirror of
https://github.com/pikvm/ustreamer.git
synced 2026-08-31 23:31:56 +00:00
janus: webcam: check the device state
This commit is contained in:
@@ -77,6 +77,7 @@ us_config_s *us_config_init(const char *config_dir_path) {
|
|||||||
|
|
||||||
config->vplay_sink_name = _get_value(jcfg, "vplay", "sink");
|
config->vplay_sink_name = _get_value(jcfg, "vplay", "sink");
|
||||||
config->vplay_sink_mode = _get_uint(jcfg, "vplay", "sink_mode", 0660, 8);
|
config->vplay_sink_mode = _get_uint(jcfg, "vplay", "sink_mode", 0660, 8);
|
||||||
|
config->vplay_dev_path = _get_value(jcfg, "vplay", "device");
|
||||||
|
|
||||||
goto ok;
|
goto ok;
|
||||||
|
|
||||||
@@ -95,6 +96,7 @@ void us_config_destroy(us_config_s *config) {
|
|||||||
US_DELETE(config->tc358743_dev_path, free);
|
US_DELETE(config->tc358743_dev_path, free);
|
||||||
US_DELETE(config->aplay_dev_name, free);
|
US_DELETE(config->aplay_dev_name, free);
|
||||||
US_DELETE(config->vplay_sink_name, free);
|
US_DELETE(config->vplay_sink_name, free);
|
||||||
|
US_DELETE(config->vplay_dev_path, free);
|
||||||
free(config);
|
free(config);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -37,6 +37,7 @@ typedef struct {
|
|||||||
|
|
||||||
char *vplay_sink_name;
|
char *vplay_sink_name;
|
||||||
uint vplay_sink_mode;
|
uint vplay_sink_mode;
|
||||||
|
char *vplay_dev_path;
|
||||||
} us_config_s;
|
} us_config_s;
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -386,6 +386,7 @@ static void *_aplay_thread(void *arg) {
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static bool _is_camera_enabled(void);
|
||||||
static void _camera_set_active(uint width, uint height, uint fps);
|
static void _camera_set_active(uint width, uint height, uint fps);
|
||||||
static void _camera_set_inactive();
|
static void _camera_set_inactive();
|
||||||
|
|
||||||
@@ -615,6 +616,16 @@ static void _push_camera_event(us_janus_client_s *client, bool requested) {
|
|||||||
json_decref(event);
|
json_decref(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static bool _is_camera_enabled(void) {
|
||||||
|
bool enabled = us_str_is_ok(_g_config->vplay_sink_name);
|
||||||
|
if (enabled && us_str_is_ok(_g_config->vplay_dev_path)) {
|
||||||
|
if (access(_g_config->vplay_dev_path, F_OK) != 0) {
|
||||||
|
enabled = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return enabled;
|
||||||
|
}
|
||||||
|
|
||||||
static void _camera_set_active(uint width, uint height, uint fps) {
|
static void _camera_set_active(uint width, uint height, uint fps) {
|
||||||
_LOCK_VPLAY;
|
_LOCK_VPLAY;
|
||||||
US_A(!_g_camera.active);
|
US_A(!_g_camera.active);
|
||||||
@@ -787,7 +798,7 @@ static struct janus_plugin_result *_plugin_handle_message(
|
|||||||
}
|
}
|
||||||
READ_BOOL(with_acap, "audio", us_au_probe(_g_config->acap_dev_name));
|
READ_BOOL(with_acap, "audio", us_au_probe(_g_config->acap_dev_name));
|
||||||
READ_BOOL(with_aplay, "mic", us_au_probe(_g_config->aplay_dev_name));
|
READ_BOOL(with_aplay, "mic", us_au_probe(_g_config->aplay_dev_name));
|
||||||
READ_BOOL(with_vplay, "camera", us_str_is_ok(_g_config->vplay_sink_name));
|
READ_BOOL(with_vplay, "camera", _is_camera_enabled());
|
||||||
# undef READ_BOOL
|
# undef READ_BOOL
|
||||||
{
|
{
|
||||||
json_t *const obj = json_object_get(params, "orientation");
|
json_t *const obj = json_object_get(params, "orientation");
|
||||||
@@ -858,7 +869,7 @@ static struct janus_plugin_result *_plugin_handle_message(
|
|||||||
"audio", us_au_probe(_g_config->acap_dev_name),
|
"audio", us_au_probe(_g_config->acap_dev_name),
|
||||||
"mic", us_au_probe(_g_config->aplay_dev_name),
|
"mic", us_au_probe(_g_config->aplay_dev_name),
|
||||||
"camera",
|
"camera",
|
||||||
"enabled", us_str_is_ok(_g_config->vplay_sink_name),
|
"enabled", _is_camera_enabled(),
|
||||||
"request", camera_req,
|
"request", camera_req,
|
||||||
"ice",
|
"ice",
|
||||||
"url", (ice_url != NULL ? ice_url : _g_default_ice_url)
|
"url", (ice_url != NULL ? ice_url : _g_default_ice_url)
|
||||||
|
|||||||
Reference in New Issue
Block a user