|
16 | 16 | ******************************************************************************/ |
17 | 17 |
|
18 | 18 | #include <obs-module.h> |
| 19 | +#include <util/dstr.h> |
19 | 20 |
|
20 | 21 | #include "browser-source.hpp" |
21 | 22 | #include "browser-manager.hpp" |
@@ -55,19 +56,33 @@ static bool is_local_file_modified(obs_properties_t *props, |
55 | 56 | return true; |
56 | 57 | } |
57 | 58 |
|
58 | | -static obs_properties_t *browser_source_get_properties(void *) |
| 59 | +static obs_properties_t *browser_source_get_properties(void *data) |
59 | 60 | { |
60 | 61 | obs_properties_t *props = obs_properties_create(); |
| 62 | + struct dstr path = { 0 }; |
| 63 | + BrowserSource *bs = static_cast<BrowserSource *>(data); |
61 | 64 |
|
62 | 65 | obs_properties_set_flags(props, OBS_PROPERTIES_DEFER_UPDATE); |
63 | 66 | // use this when obs allows non-readonly paths |
64 | 67 | obs_property_t *prop = obs_properties_add_bool(props, "is_local_file", |
65 | 68 | obs_module_text("Local file")); |
66 | 69 |
|
| 70 | + if (bs && bs->GetUrl() != "") |
| 71 | + { |
| 72 | + const char *slash; |
| 73 | + |
| 74 | + dstr_copy(&path, bs->GetUrl().c_str()); |
| 75 | + dstr_replace(&path, "\\", "/"); |
| 76 | + slash = strrchr(path.array, '/'); |
| 77 | + if (slash) |
| 78 | + dstr_resize(&path, slash - path.array + 1); |
| 79 | + } |
| 80 | + |
| 81 | + |
67 | 82 | obs_property_set_modified_callback(prop, is_local_file_modified); |
68 | 83 | obs_properties_add_path(props, "local_file", |
69 | 84 | obs_module_text("Local file"), OBS_PATH_FILE, "*.*", |
70 | | - nullptr); |
| 85 | + path.array); |
71 | 86 | obs_properties_add_text(props, "url", |
72 | 87 | obs_module_text("URL"), OBS_TEXT_DEFAULT); |
73 | 88 |
|
|
0 commit comments