This repository has been archived by the owner on Apr 14, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 72
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Full containerization of workflow (#14)
* Tweak CES and run it easily inside docker * Code refacto * Override CES defaults only through env * Catch signals (to stop container) * Fix port issue binding * Fix typo in README * Update binary and container name to ces * Update README to move override options section * Update gitignore for new binary name
- Loading branch information
Showing
10 changed files
with
186 additions
and
201 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -33,4 +33,4 @@ | |
|
||
# Build artifacts | ||
build/ | ||
camera_emulation_server | ||
ces |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,55 +1,59 @@ | ||
# CES : Camera Emulation Server 1.0.0 | ||
# CES : Camera Emulation Server 1.1.0 | ||
|
||
[![License](https://img.shields.io/badge/license-Apache-blue.svg)](#license) | ||
[![Latest release](https://img.shields.io/badge/release-1.0.0-green.svg)](https://github.com/EtixLabs/CES/releases/latest) | ||
[![Latest release](https://img.shields.io/badge/release-1.1.0-green.svg)](https://github.com/EtixLabs/CES/releases/latest) | ||
|
||
### RTSP server with authentication for testing purposes | ||
|
||
## Dependencies | ||
|
||
* `docker` | ||
|
||
## Examples of use | ||
## Usage from the official docker repository | ||
|
||
To create a simple test stream, just launch the following command: | ||
`docker run -p 8554:8554 ullaakut/CES` | ||
You can create a stream by launching the official docker image: | ||
`docker run --rm -p 8554:8554 ullaakut/ces` | ||
|
||
You can now access it on the URL `rtsp://0.0.0.0:8554/live.sdp`. | ||
With default options, stream will be available at `rtsp://0.0.0.0:8554/live.sdp` | ||
You can use [override options](#override-options) | ||
|
||
To create a test stream with credentials, just add the RTSP_PASSWORD and RTSP_USERNAME arguments like so: | ||
|
||
`docker run -p 8554:8554 -e RTSP_PASSWORD=mypass -e RTSP_USERNAME=myusername` | ||
|
||
You can now access it on the URL `rtsp://myusername:[email protected]:8554/live.sdp`. | ||
|
||
### Usage | ||
## Override options | ||
|
||
``` | ||
docker run \ | ||
[-e RTSP_LISTEN_ADDRESS=your_listen_address] \ | ||
docker run --rm \ | ||
[-e RTSP_ADDRESS=your_address] \ | ||
[-e RTSP_PORT=your_port] -p your_port:your_port \ | ||
[-e RTSP_PATH=your_path] \ | ||
[-e RTSP_ROUTE=your_route] \ | ||
[-e RTSP_INPUT_FILE=your_input_file] \ | ||
[-e RTSP_USERNAME=your_username] \ | ||
[-e RTSP_PASSWORD=your_password] \ | ||
[-e RTSP_RESOLUTION='your_width'x'your_height'] \ | ||
[-e RTSP_FRAMERATE=your_framerate] \ | ||
[-e GST_DEBUG=your_debug_level] \ | ||
ullaakut/CES | ||
ullaakut/ces | ||
``` | ||
|
||
### Parameters | ||
|
||
All of these options override the default parameters for CES | ||
* `your_listen_address`: The address you want your server to listen on [default: `0.0.0.0`] | ||
* `your_port`: The port that you want your server to listen on [default: `8554`] _Don't forget to also expose the port in your container with the -p option like in the example above_ | ||
* `your_path`: The rtsp path at which you want your stream to be served [default: `/live.sdp`] | ||
* `your_input_file`: The video file you want to broadcast using CES [default: none] | ||
* `your_username`: If you want to enable security on your stream, using this option will allow you to specify the username required to access your stream [default: none] | ||
* `your_password`: If you want to enable security on your stream, using this option will allow you to specify the password required to access your stream [default: none] | ||
* `'your_width'x'your_height'`: The resolution at which you want to stream [default: `352x288`] | ||
* `your_framerate`: The desired output framerate for your stream [default: `25`] | ||
* `your_debug_level`: The desired debug level for GStreamer [default: none] _See [this link](https://gstreamer.freedesktop.org/data/doc/gstreamer/head/gstreamer/html/gst-running.html) for more information on this variable_ | ||
All of these environment variables override the default parameters for CES | ||
* `RTSP_ADDRESS`: The address you want your server to listen on [default: `0.0.0.0`] | ||
* `RTSP_PORT`: The port that you want your server to listen on [default: `8554`] _Don't forget to also expose the port in your container with the -p option like in the example above_ | ||
* `RTSP_ROUTE`: The rtsp route at which you want your stream to be served [default: `/live.sdp`] | ||
* `RTSP_INPUT_FILE`: The video file you want to broadcast using CES [default: none] | ||
* `RTSP_USERNAME`: If you want to enable security on your stream, using this option will allow you to specify the username required to access your stream [default: none] | ||
* `RTSP_PASSWORD`: If you want to enable security on your stream, using this option will allow you to specify the password required to access your stream [default: none] | ||
* `RTSP_RESOLUTION`: The resolution at which you want to stream [default: `352x288`] | ||
* `RTSP_FRAMERATE`: The desired output framerate for your stream [default: `25`] | ||
* `GST_DEBUG`: The desired debug level for GStreamer [default: none] _See [this link](https://gstreamer.freedesktop.org/data/doc/gstreamer/head/gstreamer/html/gst-running.html) for more information on this variable_ | ||
|
||
## Build and tweak yourself | ||
|
||
You can tweak CES and create your own docker image. For this simply run: | ||
`./build.sh` | ||
|
||
Then launch it with: | ||
`docker run --rm -p 8554:8554 ces` | ||
|
||
With default options, stream will be available at `rtsp://0.0.0.0:8554/live.sdp` | ||
You can use [override options](#override-options) | ||
|
||
## License | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,4 +10,4 @@ cmake ../CES | |
make | ||
|
||
# mv CES bin to mounted dir | ||
mv camera_emulation_server ../CES | ||
mv ces ../CES |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
// Copyright 2016 Etix Labs | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
#include "server.h" | ||
#include <csignal> | ||
#include <iostream> | ||
|
||
void signal_handler(int signal) { | ||
std::cout << "Signal " << std::to_string(signal) << " catched" << std::endl; | ||
exit(1); | ||
} | ||
|
||
int main(int argc, char **argv) { | ||
std::signal(SIGINT, signal_handler); | ||
|
||
/* Config parsing from env */ | ||
t_server serv; | ||
std::shared_ptr<t_config> config = std::make_shared<t_config>(); | ||
parse_env(config); | ||
serv.config = config; | ||
|
||
gst_init(NULL, NULL); | ||
init_server_auth(&serv); | ||
return server_launch(&serv); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
// Copyright 2016 Etix Labs | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
#include "server.h" | ||
#include <string.h> | ||
|
||
void parse_env(std::shared_ptr<t_config> config) { | ||
if (const char *route = std::getenv("RTSP_PATH")) | ||
config->route = strdup(route); | ||
else | ||
config->route = strdup("/live.sdp"); | ||
|
||
if (const char *username = std::getenv("RTSP_USERNAME")) | ||
config->username = strdup(username); | ||
else | ||
config->username = strdup(""); | ||
|
||
if (const char *password = std::getenv("RTSP_PASSWORD")) | ||
config->password = strdup(password); | ||
else | ||
config->password = strdup(""); | ||
|
||
if (const char *input = std::getenv("RTSP_INPUT_FILE")) | ||
config->input = strdup(input); | ||
else | ||
config->input = strdup(""); | ||
|
||
if (const char *scale = std::getenv("RTSP_RESOLUTION")) { | ||
size_t pos = 0; | ||
std::string scale_str(scale); | ||
|
||
if ((pos = scale_str.find("x")) == std::string::npos) { | ||
fprintf(stderr, "No x token found between width and height in the scale " | ||
"argument: %s\nUsing default values instead", | ||
scale); | ||
config->scale = | ||
std::make_pair<gchar *, gchar *>(strdup("352"), strdup("288")); | ||
} else { | ||
config->scale = std::make_pair<gchar *, gchar *>( | ||
strdup(scale_str.substr(0, pos).c_str()), | ||
strdup(scale_str.substr(pos + 1).c_str())); | ||
} | ||
} else { | ||
config->scale = | ||
std::make_pair<gchar *, gchar *>(strdup("352"), strdup("288")); | ||
} | ||
|
||
if (const char *framerate = std::getenv("RTSP_FRAMERATE")) | ||
config->framerate = strdup(framerate); | ||
else | ||
config->framerate = strdup("25"); | ||
|
||
if (const char *address = std::getenv("RTSP_ADDRESS")) | ||
config->address = strdup(address); | ||
else | ||
config->address = strdup("0.0.0.0"); | ||
|
||
if (const char *port = std::getenv("RTSP_PORT")) | ||
config->port = strdup(port); | ||
else | ||
config->port = strdup("8554"); | ||
} |
Oops, something went wrong.