...
REST-method | Example of REST query body | Example of response | Response statuses | Description | ||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
/push/startup |
|
| 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 |
|
| 404 - Transponder not found 500 - Internal error | Find transponders by a filter | ||||||||||||||
/push/find_all |
|
| 404 - Not found any transponder 500 - Internal error | Find all transponders | ||||||||||||||
/push/terminate |
|
| 404 - Not found transponder 500 - Internal error | Terminate operation of the transponder | ||||||||||||||
/push/mute |
| void | 404 - Not found transponder 500 - Internal error | Turn off audio | ||||||||||||||
/push/unmute |
| void | 404 - Not found transponder 500 - Internal error | Turn on audio | ||||||||||||||
/push/sound_on |
| 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 |
| 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 | |
rtmpFlashVersion | RTMP subscriber Flash version | LNX 76.219.189.0 |
options | Transponder options | {"action": "mute"} |
mediaSessionId | Unique identifier of the transponder | eume87rjk3df1i9u14elffga6t |
width | Image width | 320 |
height | Image height | 240 |
bitrate | Video bitrate, kbps | 500 |
keyFrameInterval | Video keyframe interval | 60 |
fps | Video framerate | 30 |
muted | Is sound muted | true |
soundEnabled | Is sound enabled | true |
soundFile | Sound file | test.wav |
loop | Loop playback | false |
rtmpTransponderFullUrl | Take stream name to publish to RTMP server from RTMP URL | false |
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 | ||
---|---|---|
| ||
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 | ||||
---|---|---|---|---|
| ||||
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:
...
language | js |
---|---|
theme | RDark |
...
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 | ||||
---|---|---|---|---|
| ||||
{
"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 | ||
---|---|---|
| ||
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 | ||||
---|---|---|---|---|
| ||||
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 | ||||
---|---|---|---|---|
| ||||
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 | ||||
---|---|---|---|---|
| ||||
rtmp_transponder_stream_name_prefix=rtmp_ |
If the server the stream is republished to has certain requirements to the name (Facebook, YouTube), this line must be commented out.
The option
Code Block | ||||
---|---|---|---|---|
| ||||
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 | ||
---|---|---|
| ||
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 | ||||
---|---|---|---|---|
| ||||
rtmp_transponder_stream_name_prefix=rtmp_ |
If the server the stream is republished to has certain requirements to the name (Facebook, YouTube), 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 | ||||
---|---|---|---|---|
| ||||
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 | ||
---|---|---|
| ||
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 | ||||
---|---|---|---|---|
| ||||
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 | ||||
---|---|---|---|---|
| ||||
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
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 | ||||
---|---|---|---|---|
| ||||
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
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 | ||||
---|---|---|---|---|
| ||||
rtmp://myrtmpserver.com:1935/app_name/stream_name |
or, to publish to another application instance
Code Block | ||||
---|---|---|---|---|
| ||||
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 | ||||
---|---|---|---|---|
| ||||
rtmp://myrtmpserver.com:1935/app_name/stream_name |
or, to publish to another application instance
Code Block | ||||
---|---|---|---|---|
| ||||
_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 | ||||
---|---|---|---|---|
| ||||
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 | ||
---|---|---|
| ||
rtmp_push_auto_start_url=rtmp://user:password@rtmp.server.com:1935/live |
or
Code Block | ||
---|---|---|
| ||
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
...