Skip to content

Commit

Permalink
Ensure region for kvssink is set either through env or property (#1125)
Browse files Browse the repository at this point in the history
* Ensure region for kvssink is set either through env or property

* Address comments

* Revert log4cplus version

* Fix redme for region setting
  • Loading branch information
disa6302 authored Jan 18, 2024
1 parent be5d85b commit 96115db
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 9 deletions.
10 changes: 9 additions & 1 deletion docs/linux.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,15 @@ Define AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY environment variables with th
export AWS_ACCESS_KEY_ID=YourAccessKeyId
export AWS_SECRET_ACCESS_KEY=YourSecretAccessKey
```
optionally, set `AWS_SESSION_TOKEN` if integrating with temporary token and `AWS_DEFAULT_REGION` for the region other than `us-west-2`
optionally, set `AWS_SESSION_TOKEN` if integrating with temporary token.

#### Setting region

If using kvssink, the region can be set in 2 ways:
1. Set `AWS_DEFAULT_REGION` to the desired region, or,
2. Set the `aws-region` property.

If `aws-region` and `AWS_DEFAULT_REGION` are set, the `aws-region` property would be used instead of the env.

###### Discovering audio and video devices available in your system.
Run the `gst-device-monitor-1.0` command to identify available media devices in your system. An example output as follows:
Expand Down
11 changes: 9 additions & 2 deletions docs/macos.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,14 @@ Define AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY environment variables with th
export AWS_ACCESS_KEY_ID=YourAccessKeyId
export AWS_SECRET_ACCESS_KEY=YourSecretAccessKey
```
optionally, set `AWS_SESSION_TOKEN` if integrating with temporary token and `AWS_DEFAULT_REGION` for the region other than `us-west-2`

#### Setting region

If using kvssink, the region can be set in 2 ways:
1. Set `AWS_DEFAULT_REGION` to the desired region, or,
2. Set the `aws-region` property.

If `aws-region` and `AWS_DEFAULT_REGION` are set, the `aws-region` property would be used instead of the env.

###### Discovering available devices.
Run the `gst-device-monitor-1.0` command to identify available media devices in your system. An example output as follows:
Expand Down Expand Up @@ -139,7 +146,7 @@ gst-launch-1.0 -v souphttpsrc location="https://.../playlist.m3u8" ! hlsdemux n
Change your current working directory to `build`. Launch the sample application with a stream name and a path to the file and it will start streaming.

```
AWS_ACCESS_KEY_ID=YourAccessKeyId AWS_SECRET_ACCESS_KEY=YourSecretAccessKey ./kvs_gstreamer_audio_video_sample <my-stream> </path/to/file>
AWS_ACCESS_KEY_ID=YourAccessKeyId AWS_SECRET_ACCESS_KEY=YourSecretAccessKey AWS_DEFAULT_REGION=YourRegion ./kvs_gstreamer_audio_video_sample <my-stream> </path/to/file>
```

##### Running the GStreamer sample application to stream audio and video from live source
Expand Down
9 changes: 8 additions & 1 deletion docs/raspberry-pi.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,14 @@ Define AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY environment variables with th
export AWS_ACCESS_KEY_ID=YourAccessKeyId
export AWS_SECRET_ACCESS_KEY=YourSecretAccessKey
```
optionally, set `AWS_SESSION_TOKEN` if integrating with temporary token and `AWS_DEFAULT_REGION` for the region other than `us-west-2`

#### Setting region

If using kvssink, the region can be set in 2 ways:
1. Set `AWS_DEFAULT_REGION` to the desired region, or,
2. Set the `aws-region` property.

If `aws-region` and `AWS_DEFAULT_REGION` are set, the `aws-region` property would be used instead of the env.

##### Set GST_PLUGIN_PATH in environment variables
```
Expand Down
7 changes: 7 additions & 0 deletions docs/windows.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ Device found:
wasapi.device.description = "Speakers\ \(Conexant\ ISST\ Audio\)"
```


Start sample application to send video stream to KVS using gstreamer plugin by executing the following command:

1. Before running the demo applications, set the environment by following the instructions below.
Expand Down Expand Up @@ -117,6 +118,12 @@ gst-launch-1.0 -v filesrc location="YourAudioVideo.ts" ! tsdemux name=demux ! q
set AWS_SECRET_ACCESS_KEY=YourSecretAccessKey
```
* If using kvssink, the region can be set in 2 ways:
1. Set `AWS_DEFAULT_REGION` to the desired region, or,
2. Set the `aws-region` property.
If `aws-region` and `AWS_DEFAULT_REGION` are set, the `aws-region` property would be used instead of the env.
* Run the demo
* **Example**:
* Run the sample demo application for sending **webcam video** by executing ` kvs_gstreamer_sample.exe my-test-stream ` or
Expand Down
13 changes: 8 additions & 5 deletions src/gstreamer/gstkvssink.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ GST_DEBUG_CATEGORY_STATIC (gst_kvs_sink_debug);
#define DEFAULT_ACCESS_KEY "access_key"
#define DEFAULT_SECRET_KEY "secret_key"
#define DEFAULT_SESSION_TOKEN "session_token"
#define DEFAULT_REGION "us-west-2"
#define DEFAULT_REGION ""
#define DEFAULT_ROTATION_PERIOD_SECONDS 3600
#define DEFAULT_LOG_FILE_PATH "../kvs_log_configuration"
#define DEFAULT_STORAGE_SIZE_MB 128
Expand Down Expand Up @@ -318,12 +318,15 @@ void kinesis_video_producer_init(GstKvsSink *kvssink)
session_token_str = string(kvssink->session_token);
}

if (nullptr == (default_region = getenv(DEFAULT_REGION_ENV_VAR))) {
region_str = string(kvssink->aws_region);
if (IS_EMPTY_STRING(kvssink->aws_region)) {
if (nullptr == (default_region = getenv(DEFAULT_REGION_ENV_VAR))) {
LOG_AND_THROW("No region set. Either set with env " << DEFAULT_REGION_ENV_VAR << " or set kvssink property aws-region");
} else {
region_str = string(default_region);
}
} else {
region_str = string(default_region); // Use env var if both property and env var are available.
region_str = string(kvssink->aws_region);
}

unique_ptr<CredentialProvider> credential_provider;

if (kvssink->iot_certificate) {
Expand Down

0 comments on commit 96115db

Please sign in to comment.