mirror of
https://github.com/gpac/gpac.git
synced 2026-01-12 00:05:22 +08:00
auto-load rmt.js when rmt option is set
This commit is contained in:
@@ -585,7 +585,6 @@ int gpac_main(int _argc, char **_argv)
|
||||
|
||||
gf_sys_init(mem_track, profile);
|
||||
|
||||
|
||||
#ifdef GPAC_CONFIG_ANDROID
|
||||
//prevent destruction of JSRT until we unload the JNI gpac wrapper (see applications/gpac_android/src/main/jni/gpac_jni.cpp)
|
||||
gf_opts_set_key("temp", "static-jsrt", "true");
|
||||
@@ -659,6 +658,11 @@ int gpac_main(int _argc, char **_argv)
|
||||
use_step_mode = GF_TRUE;
|
||||
#endif
|
||||
|
||||
if (gf_opts_get_bool("core", "rmt")) {
|
||||
if (!session_js) session_js = gf_list_new();
|
||||
gf_list_insert(session_js, "$GSHARE/scripts/rmt.js", 0);
|
||||
}
|
||||
|
||||
for (i=1; i<argc; i++) {
|
||||
char szArgName[1024];
|
||||
char *arg = argv[i];
|
||||
@@ -1216,8 +1220,12 @@ restart:
|
||||
const char *js_src = gf_list_get(session_js, ijs);
|
||||
e = gf_fs_load_script(session, js_src);
|
||||
if (e) {
|
||||
GF_LOG(GF_LOG_ERROR, GF_LOG_APP, ("Failed to load JS for session: %s\n", gf_error_to_string(e) ));
|
||||
ERR_EXIT
|
||||
if ((e==GF_URL_ERROR) && strstr(js_src, "/rmt.js")) {
|
||||
GF_LOG(GF_LOG_WARNING, GF_LOG_APP, ("Monitoring script %s not found, check your installation\n Disabling remote monitoring\n", js_src));
|
||||
} else {
|
||||
GF_LOG(GF_LOG_ERROR, GF_LOG_APP, ("Failed to load JS for session: %s\n", gf_error_to_string(e) ));
|
||||
ERR_EXIT
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2077,6 +2077,25 @@ static GF_Err gf_fs_load_script_ex(GF_FilterSession *fs, const char *jsfile, JSC
|
||||
|
||||
if (!fs) return GF_BAD_PARAM;
|
||||
|
||||
//load script
|
||||
if (!strncmp(jsfile, "$GSHARE/", 8)) {
|
||||
char szPath[GF_MAX_PATH];
|
||||
if (gf_opts_default_shared_directory(szPath)) {
|
||||
strcat(szPath, jsfile + 7);
|
||||
e = gf_file_load_data(szPath, &buf, &buf_len);
|
||||
} else {
|
||||
e = GF_URL_ERROR;
|
||||
}
|
||||
} else {
|
||||
e = gf_file_load_data(jsfile, &buf, &buf_len);
|
||||
}
|
||||
if (e) {
|
||||
if (e!=GF_URL_ERROR) {
|
||||
GF_LOG(GF_LOG_ERROR, GF_LOG_SCRIPT, ("[JSF] Error loading script file %s: %s\n", jsfile, gf_error_to_string(e) ));
|
||||
}
|
||||
return e;
|
||||
}
|
||||
|
||||
if (in_ctx) {
|
||||
ctx = in_ctx;
|
||||
} else if (fs->js_ctx) {
|
||||
@@ -2099,25 +2118,6 @@ static GF_Err gf_fs_load_script_ex(GF_FilterSession *fs, const char *jsfile, JSC
|
||||
JS_FreeValue(fs->js_ctx, global_obj);
|
||||
}
|
||||
|
||||
//load script
|
||||
if (!strncmp(jsfile, "$GSHARE/", 8)) {
|
||||
char szPath[GF_MAX_PATH];
|
||||
if (gf_opts_default_shared_directory(szPath)) {
|
||||
strcat(szPath, jsfile + 7);
|
||||
e = gf_file_load_data(szPath, &buf, &buf_len);
|
||||
} else {
|
||||
e = GF_NOT_FOUND;
|
||||
}
|
||||
} else {
|
||||
e = gf_file_load_data(jsfile, &buf, &buf_len);
|
||||
}
|
||||
if (e) {
|
||||
if (e!=GF_NOT_FOUND) {
|
||||
GF_LOG(GF_LOG_ERROR, GF_LOG_SCRIPT, ("[JSF] Error loading script file %s: %s\n", jsfile, gf_error_to_string(e) ));
|
||||
}
|
||||
return e;
|
||||
}
|
||||
|
||||
if (in_ctx || (!gf_opts_get_bool("core", "no-js-mods") && JS_DetectModule((char *)buf, buf_len))) {
|
||||
if (!skip_modules)
|
||||
qjs_init_all_modules(ctx, GF_FALSE, GF_FALSE);
|
||||
|
||||
@@ -3088,6 +3088,9 @@ GF_Err gf_file_load_data(const char *file_name, u8 **out_data, u32 *out_size)
|
||||
FILE *file = gf_fopen(file_name, "rb");
|
||||
|
||||
if (!file) {
|
||||
if (!gf_file_exists(file_name))
|
||||
return GF_URL_ERROR;
|
||||
|
||||
GF_LOG(GF_LOG_ERROR, GF_LOG_CORE, ("[Core] Cannot open file %s\n", file_name));
|
||||
return GF_IO_ERR;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user