Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

REST-method

Example of REST query body

Example of response

Response statuses

Description

/push/startup

Code Block
languagejs
themeRDark
{
"streamName": "name",
"rtmpUrl": "rtmp://localhost:1935/live",
"rtmpTransponderFullUrl": false
"options": {}
}
Code Block
languagejs
themeRDark
{
"mediaSessionId": "eume87rjk3df1i9u14elffga6t",
"streamName": "rtmp_name",
"rtmpUrl": "rtmp://localhost:1935/live",
"width": 320,
"height": 240,
"muted": false,
"soundEnabled": false,
"options": {}
}

400 - Bad request

409 - Conflict

500 - Internal error

Creates a transponder that subscribes to the given stream and sends media traffic to the specified rtmpUrl.


The name of the stream specified in the query can be the name of an already published stream or the name reserved when the SIP call was created (to send media traffic received from SIP).


If a transponder for the given stream and rtmpUrl already exists, 409 Conflict is returned.


If rtmpUrl is not set, or is set incorrectly and cannot be resolved by DNS, 400 Bad request is returned

/push/find

Code Block
languagejs
themeRDark
{
"streamName": "name",
"rtmpUrl": "rtmp://localhost:1935/live",
}
Code Block
languagejs
themeRDark
[{
"mediaSessionId": "eume87rjk3df1i9u14elffga6t",
"streamName": "rtmp_name",
"rtmpUrl": "rtmp://localhost:1935/live",
"width": 320,
"height": 240,
"muted": false,
"soundEnabled": false,
"options": {}
}]

404 - Transponder not found

500 - Internal error

Find transponders by a filter

/push/find_all

 

Code Block
languagejs
themeRDark
[{
"mediaSessionId": "eume87rjk3df1i9u14elffga6t",
"streamName": "rtmp_name",
"rtmpUrl": "rtmp://localhost:1935/live",
"width": 320,
"height": 240,
"muted": false,
"soundEnabled": false,
"options": {}
}]

404 - Not found any transponder

500 - Internal error

Find all transponders

/push/terminate

Code Block
languagejs
themeRDark
{
"mediaSessionId": "eume87rjk3df1i9u14elffga6t"
}

 

404 - Not found transponder

500 - Internal error

Terminate operation of the transponder

/push/mute

Code Block
languagejs
themeRDark
{
"mediaSessionId": "eume87rjk3df1i9u14elffga6t"
}

void

404 - Not found transponder

500 - Internal error

Turn off audio

/push/unmute

Code Block
languagejs
themeRDark
{
"mediaSessionId": "eume87rjk3df1i9u14elffga6t"
}

void

404 - Not found transponder

500 - Internal error

Turn on audio

/push/sound_on

Code Block
languagejs
themeRDark
{
"mediaSessionId": "eume87rjk3df1i9u14elffga6t"
"soundFile": "test.wav"
"loop": true
}

void

404 - Not found transponder

404 - No such file

500 - Internal error

Insert audio from a RIFF WAV file located in the /usr/local/ FlashphonerWebCallServer/media/ directory on the WCS server

/push/sound_off

Code Block
languagejs
themeRDark
{
"mediaSessionId": "eume87rjk3df1i9u14elffga6t"
}

void

404 - Not found transponder

500 - Internal error

Stop inserting audio from the file

...

Parameter name

Description

Example

streamName

Name of the republished stream

streamName

rtmpUrl

URL of the server the stream is republished to

rtmp://localhost:1935/live

rtmpFlashVersionRTMP subscriber Flash versionLNX 76.219.189.0

options

Transponder options

{"action": "mute"}

mediaSessionId

Unique identifier of the transponder

eume87rjk3df1i9u14elffga6t

width

Image width

320

height

Image height

240

bitrateVideo bitrate, kbps500
keyFrameIntervalVideo keyframe interval60
fpsVideo framerate30

muted

Is sound muted

true

soundEnabled

Is sound enabled

true

soundFile

Sound file

test.wav

loop

Loop playback

false

rtmpTransponderFullUrlTake stream name to publish  to RTMP server from RTMP URLfalse

Parameters added since build 5.2.785: rtmpFlashVersion, keyFrameInterval and fps.

Since build 5.2.1043 bitrateparameter is added.

The options parameter can be used to turn off audio or insert audio from a file when creating a transponder.

...

Since build 5.2.785, there are two more parameters enabling transcoding: keyFrameInterval and fps. Stream will be transcoded if either of them, or height is specified.

Set stream name to publish to RTMP server

By default, a stream will be published to RTMP server with the same name as it is publishing on WCS, and the prefix rtmp_, for example rtmp_test. This behaviour can be changed by the following parameters

Code Block
themeRDark
rtmp_transponder_full_url=true
rtmp_transponder_stream_name_prefix=

But, these settings are applyed to all the republishings, and require server restart. That's why since build 5.2.860 the /push/startup query parameter is added to allow to define full RTMP URL, including stream name on RTMP server, regardless of server settings

Code Block
languagejs
themeRDark
POST /rest-api/push/startup HTTP/1.1
Host: localhost:8081
Content-Type: application/json

{
 "streamName":"stream1",
 "rtmpUrl":"rtmp://rtmp.flashphoner.com:1935/live/test",
 "rtmpTransponderFullUrl":true
}

In this case, the stream will be published to RTMP server with the name defined in RTMP URL even with default WCS settings.

Sending the REST query to the WCS server

To send the REST query to the WCS server, use a REST-client.

JavaScript API

Using Web SDK you can republish a stream to an RTMP server upon creation, similar to the SIP as stream function. Usage example for this method is available in the WebRTC as RTMP web application.

webrtc-as-rtmp-republishing.html

webrtc-as-rtmp-republishing.js

1. When a stream is created, the method session.createStream() receives the parameter rtmpUrl that specifies the URL of the RTMP server that accepts the broadcast. The name of the stream is specified in compliance with rules of the RTMP server.

code:

...

languagejs
themeRDark

...

 Since build 5.2.1043 bitrate parameter is added which also enables stream transcoding while republishing.

Therefore, stream will be transcoded while republishing with any of the following parameters:

Code Block
languagejs
themeRDark
{
"streamName": "name",
"rtmpUrl": "rtmp://localhost:1935/live",
"height": 240,
"keyFrameInterval": 60,
"fps": 30,
"bitrate": 500
}

Set stream name to publish to RTMP server

By default, a stream will be published to RTMP server with the same name as it is publishing on WCS, and the prefix rtmp_, for example rtmp_test. This behaviour can be changed by the following parameters

Code Block
themeRDark
rtmp_transponder_full_url=true
rtmp_transponder_stream_name_prefix=

But, these settings are applyed to all the republishings, and require server restart. That's why since build 5.2.860 the /push/startup query parameter is added to allow to define full RTMP URL, including stream name on RTMP server, regardless of server settings

Code Block
languagejs
themeRDark
POST /rest-api/push/startup HTTP/1.1
Host: localhost:8081
Content-Type: application/json

{
 "streamName":"stream1",
 "rtmpUrl":"rtmp://rtmp.flashphoner.com:1935/live/test",
 "rtmpTransponderFullUrl":true
}

In this case, the stream will be published to RTMP server with the name defined in RTMP URL even with default WCS settings.

Sending the REST query to the WCS server

To send the REST query to the WCS server, use a REST-client.

JavaScript API

Using Web SDK you can republish a stream to an RTMP server upon creation, similar to the SIP as stream function. Usage example for this method is available in the WebRTC as RTMP web application.

webrtc-as-rtmp-republishing.html

webrtc-as-rtmp-republishing.js

1. When a stream is created, the method session.createStream() receives the parameter rtmpUrl that specifies the URL of the RTMP server that accepts the broadcast. The name of the stream is specified in compliance with rules of the RTMP server.

code:

Code Block
languagejs
themeRDark
function startStreaming(session) {
    var streamName = field("streamName");
    var rtmpUrl = field("rtmpUrl");
    session.createStream({
        name: streamName,
        display: localVideo,
        cacheLocalResources: true,
        receiveVideo: false,
        receiveAudio: false,
        rtmpUrl: rtmpUrl
        ...
    }).publish();
}

Republishing of the stream starts directly after it is successfully published on the WCS server.

Server configuration

...

}).publish();
}

Republishing of the stream starts directly after it is successfully published on the WCS server.

Server configuration

When WCS creates an RTMP transponder it automatically adds a prefix to the republished stream as set in the flashphoner.properties file:

Code Block
languagejs
themeRDark
rtmp_transponder_stream_name_prefix=rtmp_

If the server the stream is republished to has certain requirements to the name (FacebookYouTube), this line must be commented out.

The option

Code Block
languagebash
themeRDark
rtmp_transponder_full_url=true

turns on a possibility to pass some request parameters to RTMP server.

A network interface to bind RTMP client for republishing may be set with the following parameter

Code Block
themeRDark
rtmp_publisher_ip=127.0.0.1

In this case, RTMP will be republished to localhost only.

Parameters passing in server URL

It is possible to pass some parameters to server. to which a stream should be republished. Parameters to pass are specified in server URL, e.g.

Code Block
languagejs
themeRDark
rtmp_transponder_stream_name_prefix=rtmp_

If the server the stream is republished to has certain requirements to the name (FacebookYouTube), this line must be commented out.

...

://myrtmpserver.com:1935/app_name/?user=user1&pass=pass1

or, if a stream supposed to be published to a specified instance of RTMP server application

Code Block
languagebashjs
themeRDark
rtmp_transponder_full_url=true

turns on a possibility to pass some request parameters to RTMP server.

A network interface to bind RTMP client for republishing may be set with the following parameter

Code Block
themeRDark
rtmp_publisher_ip=127.0.0.1

In this case, RTMP will be republished to localhost only.

Parameters passing in server URL

It is possible to pass some parameters to server. to which a stream should be republished. Parameters to pass are specified in server URL, e.g.

Code Block
languagejs
themeRDark
rtmp://myrtmpserver.com:1935/app_name/?user=user1&pass=pass1

or, if a stream supposed to be published to a specified instance of RTMP server application

Code Block
languagejs
themeRDark
rtmp://myrtmpserver.com:1935/app_name/app_instance/?user=user1&pass=pass1

Where

  • myrtmpserver.com is the RTMP server name
  • app_name is the application on the RTMP server name
  • app_instance is the instance name of the RTMP server application

...

://myrtmpserver.com:1935/app_name/app_instance/?user=user1&pass=pass1

Where

  • myrtmpserver.com is the RTMP server name
  • app_name is the application on the RTMP server name
  • app_instance is the instance name of the RTMP server application

Stream name is set in REST query /push/startup parameter 'streamName' or in corresponding stream creation option.

This is the example on RTMP connection establishing with query parameters passing

Image Added

Stream name passing in server URL

In some cases, a stream publishing name should be passed in the server URL. To do this, the following option must be set in flashphoner.properties file

Code Block
languagebash
themeRDark
rtmp_transponder_full_url=true

Then, the URL to publish should be set in REST query /push/startup parameter 'streamNamertmpUrl' parameter or in corresponding stream creation option.

This is the example on RTMP connection establishing with query parameters passing

Image Removed

Stream name passing in server URL

In some cases, a stream publishing name should be passed in the server URL. To do this, the following option must be set in flashphoner.properties fileoption like this:

Code Block
languagejs
themeRDark
rtmp://myrtmpserver.com:1935/app_name/stream_name

or, to publish to another application instance

Code Block
languagebashjs
themeRDark
rtmp_transponder_full_url=true

...

://myrtmpserver.com:1935/app_name/app_instance/stream_name

In this case, 'streamName' parameter or REST query /push/startup 'rtmpUrl' parameter or in corresponding stream creation option like thisor corresponding stream creation option is ignored.

Automatic republishing to a specified RTMP server

WCS server can automatically republish all the published streams to a specified RTMP server. To activate this feature, set the following options in flashphoner.properties file:

Code Block
languagejsbash
themeRDark
rtmp://myrtmpserver.com:1935/app_name/stream_name

or, to publish to another application instance

Code Block
languagejs
themeRDark
_push_auto_start=true
rtmp_push_auto_start_url=rtmp://myrtmpserverrtmp.server.com:1935/app_name/app_instance/stream_name

In this case, 'streamName' parameter or REST query /push/startup or corresponding stream creation option is ignored.

Automatic republishing to a specified RTMP server (not for production)

WCS server can automatically republish all the published streams to a specified RTMP server. To activate this feature, set the following options in flashphoner.properties file:

Code Block
languagebash
themeRDark
rtmp_push_auto_start=true

where rtmp.server.com is RTMP server name to republish all streams from WCS.

This feature is supposed to be used for debug, not in production.

Since build 5.2.1110 it is possible to set authentication parameters

Code Block
themeRDark
rtmp_push_auto_start_url=rtmp://user:password@rtmp.server.com:1935/live

or

Code Block
themeRDark
rtmp_push_auto_start_url=rtmp://rtmp.server.com:1935/

where rtmp.server.com is RTMP server name to republish all streams from WCS.

...

live?username=user&password=pwd

Parameters will be passed in RTMP connect command.

Known limits

Only one RTMP URL can be used for automatic republishing.

Automatic reconnection when channel is closed

...