Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Md/app configuration #340

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -5,68 +5,101 @@ keywords: [Ant Media Configuration File, Ant Media Server Documentation, Ant Med
sidebar_position: 1
---

# AMS application configuration
# Configuring Ant Media Server Applications

Ant Media Server can be configured either by editing a configuration file or through the application settings tab in the management console.
Ant Media Server Application settings can be configured either by editing the configuration file or through the application settings tab in the management console as well as with REST API calls.

The configuration is set on the application level and is stored in a file located at ```<AMS_DIR>/webapps/<AppName>/WEB-INF/red5-web.properties```.
## Configuration File

The management panel allows changing all the application settings however, the file is much more extensive. See the [Application Settings Javadoc](https://antmedia.io/javadoc/io/antmedia/AppSettings.html) to find a complete list of all available settings.
- Each application's configuration is stored in a file located at ```<AMS_DIR>/webapps/<AppName>/WEB-INF/red5-web.properties.```

## Management panel settings
- While the management console allows you to change most settings, the configuration file contains a more comprehensive list of options. For a complete list of all available settings, refer to the [Application Settings Javadoc](https://antmedia.io/javadoc/io/antmedia/AppSettings.html).

Login to the Ant Media Server dashboard and click on the application you want to configure from the left-hand menu. Then click on the settings tab.
## Managing Settings via the Console

There are two options here: *Basic* and *Advanced*
To configure your application via the management console:

Basic settings have some of the most used application settings and the other application settings are under the Advanced settings option.
1. **Login to the Dashboard**: Access the Ant Media Server dashboard.
2. **Select the Application**: Choose the application you wish to configure from the left-hand menu.
3. **Navigate to Settings**: Click on the "Settings" tab.

Starting from Ant Media Server version 2.6.2, all the application settings for both Standalone mode and Cluster mode of Ant Media Server can be changed from the management panel itself.
You’ll find two categories of settings:
- **Basic Settings**: Contains the most commonly used application settings.
- **Advanced Settings**: Includes additional configuration options.

:::info
Starting from Ant Media Server version 2.6.2, all application settings whether in Standalone or Cluster mode can be managed directly through the management console.
:::

![](@site/static/img/configuration-and-testing/application-settings.png)

**Note**: After changing the application settings, you must restart the streams in order for the changes to be applied to them.


## Application properties file
## Editing the Application Properties File
If you prefer or need to make changes directly to the configuration file:

The application settings can also be modified by editing the configuration file directly. Navigate to the file located at ```<AMS_DIR>/webapps/<AppName>/WEB-INF/red5-web.properties``` and open it using your preferred editor.
1. **Locate the File**: Navigate to ```<AMS_DIR>/webapps/<AppName>/WEB-INF/red5-web.properties.```
2. **Open the File**: Use your preferred text editor to modify the file.

Highlighted below is how to enable VP8 encoding by editing the configuration file.
- For example, to enable VP8 encoding, you can edit the configuration directly in this file.

![](@site/static/img/configuration-and-testing/application-settings-properties.png)

- After editing the file, save the changes.
- Restart the Ant Media Server with ```sudo service antmedia restart```

## Adding additional settings
## Changing Settings with REST API
Ant Media Server application settings can also be changed with the help of REST API calls. The process to change the settings via API calls is lenghty but it finds use in case you want to limit this access completely.

If a configuration setting has not been added to the ```red5-web. properties `` file or under `Advanced` settings, simply append the setting to the configuration file or add it from the management panel.
There are two API calls related to the Applications:

Follow the steps below to add an additional setting:
1. **getSettings**: This [getSettings](https://antmedia.io/rest/?urls.primaryName=2.11.0-management#/default/getSettings) API call lists/returns the specific application settings
2. **changeSettings**: This [changeSettings](https://antmedia.io/rest/?urls.primaryName=2.11.0-management#/default/changeSettings) API call changes the specific application settings

### 1. Find the setting
:::info
These API calls are management panel API call and needs to be called in a different way. Please check this [Management Panel REST API Services document](https://antmedia.io/docs/guides/developer-sdk-and-api/rest-api-guide/management-rest-apis/) to learn how to make the management Panel API calls.
:::

Open the [Javadoc](https://antmedia.io/javadoc/io/antmedia/AppSettings.html) page and find the setting that needs to be added to the configuration file.
- Let's make the ``getSettings``` API call to get the application settings.
```js
curl -X GET "http://localhost:5080/rest/v2/applications/settings/LiveApp"
```
![image](https://github.com/user-attachments/assets/b194d9ad-28e8-43ca-8323-1192a2e1d948)

### 2. Confirm the setting type and value
- Let's make the ```changeSettings``` API call to update the application settings.
```js
curl -X POST -H "Content-Type: application/json" "http://localhost:5080/rest/v2/applications/settings/LiveApp"
```

The description of each setting confirms the type and default value. For example, the setting ```aacEncodingEnabled``` is of type boolean with a default value of ```true```:
There are two ways to update the application settings:
1. Passing all the application settings in the REST API call body and make the changes only for the setting you would like to update.

```java
@Value("${settings.aacEncodingEnabled:true}")
private boolean aacEncodingEnabled
```
![image](https://github.com/user-attachments/assets/4c410e68-c908-496f-a3ca-0400deeb3876)

To confirm the function of the setting, additional information is provided in the description.
2. Passing only the settings that need to be changed/updated.

If aacEncodingEnabled is true, aac encoding will be active even if mp4 or hls muxing is not enabled, If aacEncodingEnabled is false,
aac encoding is only activated if mp4 or hls muxing is enabled in the settings, This value should be true if you're sending a stream to
RTMP endpoints or enable/disable mp4 recording on the fly

![image](https://github.com/user-attachments/assets/b05eb409-f292-4ea3-bc59-d39b75a4f210)

### 3 Update the configuration file
## Adding Additional Settings

If a configuration setting is not present in the ```red5-web.properties``` file or under Advanced settings in the management console, you can manually add it.

**Steps to Add a New Setting**:
1. **Find the Setting**: Refer to the [Javadoc page](https://antmedia.io/javadoc/io/antmedia/AppSettings.html) to locate the setting you wish to add.
2. **Confirm the Setting Type and Value**: Each setting’s description includes its type and default value. For instance, the ```setting aacEncodingEnabled``` is a boolean with a default value of ```true```:

```js
@Value("${settings.aacEncodingEnabled:true}")
private boolean aacEncodingEnabled;
```

To add an additional setting to the configuration file, open the application settings, navigate to Advanced Settings on the management panel, or go to ```red5-web.properties``` file located at ```<AMS_DIR>/webapps/<AppName>/WEB-INF/red5-web.properties```.
**Description**: If ```aacEncodingEnabled``` is ```true```, AAC encoding will be active regardless of MP4 or HLS muxing. If set to ```false```, AAC encoding is only enabled if MP4 or HLS muxing is active. This should be set to ```true``` if you plan to stream to RTMP endpoints or enable/disable MP4 recording on the fly.

Following the example of ```aacEncodingEnabled``` setting, the below can be appended to the file:
3. **Update the Configuration File**:
To add a setting, either use the Advanced Settings in the management console or directly append the setting to the ```red5-web.properties``` file.

```java
- For example, to disable AAC encoding, add the following line under the Advanced Settings of the application:
```js
settings.aacEncodingEnabled=false
```
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ Now restart the Ant Media Server
sudo service antmedia restart
```

REST API for the web panel is listed [Management REST Service](https://antmedia.io/rest/#/ManagementRestService). Web Panel REST methods are binded below `https://SERVER\_FQDN:PORT/rest/`
REST API for the web panel is listed [Management REST Service](https://antmedia.io/rest/?urls.primaryName=2.11.0-management). Web Panel REST methods are binded below `https://SERVER\_FQDN:PORT/rest/`


### Generate JWT Token
Expand All @@ -59,15 +59,15 @@ Let's use the JWT Token in `ProxyAuthorization` header as follows
```
curl -X GET -H "Content-Type: application/json" -H "ProxyAuthorization:eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.e30.tA6sZwz_MvD9Nocf3Xv_DXhJaeTNgfsHPlg3RHEoZRk" "https://example.com:5443/rest/v2/system-resources"
```
Then Ant Media Server responds with system resources information such as CPU Load, Memory, etc. For all REST Methods, please visit the [Management REST Service Reference](https://antmedia.io/rest/#/ManagementRestService)
Then Ant Media Server responds with system resources information such as CPU Load, Memory, etc. For all REST Methods, please visit the [Management REST Service Reference](https://antmedia.io/rest/?urls.primaryName=2.11.0-management)



## Username and Password Authentication

Now, we need to authenticate the username and password.

In order to authenticate the user, we need to pass the login username and password to the [AuthenticateUser](https://antmedia.io/rest/#/ManagementRestService/authenticateUser) API call.
In order to authenticate the user, we need to pass the login username and password to the [AuthenticateUser](https://antmedia.io/rest/?urls.primaryName=2.11.0-management#/default/authenticateUser) API call.

### Convert Password to MD5 Hash

Expand All @@ -87,7 +87,7 @@ The payload in the body can be entered like:

Now that the User is authenticated, we can make the REST API calls for accessing Dashboard REST Services.

Let's get the list of [Applications](https://antmedia.io/rest/#/ManagementRestService/getApplications) from the Server:
Let's get the list of [Applications](https://antmedia.io/rest/?urls.primaryName=2.11.0-management#/default/getApplications) from the Server:

```
curl -X GET -H "Content-Type: application/json" -H "Authorization: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.e30.tA6sZwz_MvD9Nocf3Xv_DXhJaeTNgfsHPlg3RHEoZRk" "https://SERVER_FQDN:5443/rest/v2/applications"
Expand All @@ -99,6 +99,4 @@ The response should be something like
{"applications":["LiveApp","WebRTCAppEE"]}
```

Then, you can use all [Web panel REST methods](https://antmedia.io/rest/#/ManagementRestService) using the header as shown in the sample above.

[](https://antmedia.io/rest/#/ManagementRestService/getApplications)
Then, you can use all [Web panel REST methods](https://antmedia.io/rest/?urls.primaryName=2.11.0-management) using the header as shown in the sample above.