]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
FS-10209: [freeswitch-core,mod_av] Add auth params to file handles #resolve
authorAnthony Minessale <anthm@freeswitch.org>
Tue, 4 Apr 2017 16:42:29 +0000 (11:42 -0500)
committerAnthony Minessale <anthm@freeswitch.org>
Tue, 4 Apr 2017 16:42:29 +0000 (11:42 -0500)
src/include/switch_module_interfaces.h
src/mod/applications/mod_av/avformat.c
src/switch_core_file.c

index 98f5e32bf35d856b5b9a2d5a8449095453f2e1de..ac89f3e27674a6a0147f2cbf96fbcf0dfabd8c3a 100644 (file)
@@ -340,6 +340,8 @@ typedef struct switch_mm_s {
        int scale_w;
        int scale_h;
        switch_img_fmt_t fmt;
+       char *auth_username;
+       char *auth_password;
 } switch_mm_t;
 
 /*! an abstract representation of a file handle (some parameters based on compat with libsndfile) */
index 43e2d8c40b0135c3a7b0218b65b6f31a906dd05f..5fd10d95d3a655dffd450b0b5bfafc38bcf4816b 100644 (file)
@@ -391,6 +391,17 @@ static switch_status_t add_stream(MediaStream *mst, AVFormatContext *fc, AVCodec
 
                c->codec_id = codec_id;
 
+               if (mm->auth_username) {
+                       char tmp[256] = "";
+                       switch_snprintf(tmp, sizeof(tmp), "pubUser=%s", mm->auth_username);
+                       av_set_options_string(c, tmp, "=", ":");
+
+                       if (mm->auth_password) {
+                               switch_snprintf(tmp, sizeof(tmp), "pubPasswd=%s", mm->auth_password);
+                               av_set_options_string(c, tmp, "=", ":");
+                       }
+               }
+
                /* Resolution must be a multiple of two. */
                c->width    = mst->width;
                c->height   = mst->height;
index 598876c99f5d95635a06324668c8e42ab23db32a..263e803159b256f0b9e72246a2cb84f225e0a603 100644 (file)
@@ -177,6 +177,14 @@ SWITCH_DECLARE(switch_status_t) switch_core_perform_file_open(const char *file,
                        fh->mm.try_hardware_encoder = switch_true(val);
                }
 
+               if ((val = switch_event_get_header(fh->params, "auth_username"))) {
+                       fh->mm.auth_username = switch_core_strdup(fh->memory_pool, val);
+               }
+
+               if ((val = switch_event_get_header(fh->params, "auth_password"))) {
+                       fh->mm.auth_password = switch_core_strdup(fh->memory_pool, val);
+               }
+
                if ((val = switch_event_get_header(fh->params, "fps"))) {
                        float ftmp = atof(val);
                        if (ftmp > 0.0f) {