aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--README.md2
-rw-r--r--ezlive_config.c3
-rw-r--r--ezlive_config.h1
-rw-r--r--rtmpserver.cpp16
4 files changed, 17 insertions, 5 deletions
diff --git a/README.md b/README.md
index 4f90ed6..7c53c75 100644
--- a/README.md
+++ b/README.md
@@ -31,6 +31,7 @@ s3_path=ezlive/
access_key=YOUR_S3_ACCESS_KEY
secret_key=YOUR_S3_SECRET_KEY
region=auto
+key=your_live_key
```
In the dashboard of your object storage provider, add the domain name of your web HLS player to CORS setting. If you don't know how to setup a web HLS player, just add `https://mistivia.github.io`.
@@ -73,6 +74,7 @@ Create a config file `conf/config`, the config file is nearly the same as the co
access_key=YOUR_S3_ACCESS_KEY
secret_key=YOUR_S3_SECRET_KEY
region=auto
+ key=your_live_key
Start docker container:
diff --git a/ezlive_config.c b/ezlive_config.c
index a8fa258..2b059b0 100644
--- a/ezlive_config.c
+++ b/ezlive_config.c
@@ -27,6 +27,7 @@ void EZLiveConfig_init(EZLiveConfig *self) {
self->access_key = NULL;
self->secret_key = NULL;
self->region = strdup("auto");
+ self->key = strdup("");
}
static void set_field(const char **field, const char *value) {
@@ -77,6 +78,8 @@ void EZLiveConfig_load(EZLiveConfig *self, const char *filename) {
set_field(&self->secret_key, val);
} else if (strcmp(key, "region") == 0) {
set_field(&self->region, val);
+ } else if (strcmp(key, "key") == 0) {
+ set_field(&self->key, val);
}
}
diff --git a/ezlive_config.h b/ezlive_config.h
index a8ba0b7..90dbf8c 100644
--- a/ezlive_config.h
+++ b/ezlive_config.h
@@ -10,6 +10,7 @@ typedef struct {
const char *access_key;
const char *secret_key;
const char *region;
+ const char *key;
} EZLiveConfig;
extern EZLiveConfig *ezlive_config;
diff --git a/rtmpserver.cpp b/rtmpserver.cpp
index 1745434..cb0766e 100644
--- a/rtmpserver.cpp
+++ b/rtmpserver.cpp
@@ -234,12 +234,10 @@ void handle_connect(Client *client, double txid, Decoder *dec)
send_reply(client, txid, version, status);
-/*
uint32_t chunk_len = htonl(1024);
std::string set_chunk((char *) &chunk_len, 4);
- rtmp_send(client, MSG_SET_CHUNK, CONTROL_ID, set_chunk, 0,
- MEDIA_CHANNEL);
-
+ rtmp_send(client, MSG_SET_CHUNK, CONTROL_ID, set_chunk);
+/*
client->chunk_len = 1024;
*/
}
@@ -260,6 +258,14 @@ void handle_fcpublish(Client *client, double txid, Decoder *dec)
std::string path = amf_load_string(dec);
debug("fcpublish %s\n", path.c_str());
+ printf("fcpublish %s\n", path.c_str());
+ if (strlen(ezlive_config->key) > 0) {
+ if (strcmp(ezlive_config->key, path.c_str()) != 0) {
+ publishernum = 0;
+ printf( "wrong live key.\n");
+ throw std::runtime_error{"wrong live key."};
+ }
+ }
client->path = path;
@@ -795,7 +801,7 @@ void do_poll(void)
}
struct timespec ts;
clock_gettime(CLOCK_MONOTONIC, &ts);
- if (client != NULL && ts.tv_sec - client->livets > 90) {
+ if (client != NULL && ts.tv_sec - client->livets > 60) {
fprintf(stderr, "client timeout.\n");
close_client(client, i);
--i;