Skip to content

Commit 5da960a

Browse files
committed
refactor(iceserver): replace iceServers by iceServer (without s)
- This is to be consistent with webrtc-client parameter - SourceController: use the connectParams.iceServer if set
1 parent c91af4a commit 5da960a

File tree

4 files changed

+35
-24
lines changed

4 files changed

+35
-24
lines changed

README.md

+19-11
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ This plugin contains :
2020
- [Parameters](#parameters)
2121
- [**src**](#src)
2222
- [**type**](#type)
23-
- [**iceservers**](#iceservers)
23+
- [**iceserver**](#iceserver)
2424
- [**audiobutton**](#audiobutton)
2525
- [**data**](#data)
2626
- [Source Object](#source-object)
@@ -86,11 +86,13 @@ The following options can be set in the query:
8686

8787
**It is important for the MIME-type to be empty to use the WebRTC source.**
8888

89-
#### **iceservers**
89+
#### **iceserver**
9090

91-
Ice-servers (STUN, TURN) structure in JSON string format to establish a WebRTC connection.
91+
[Ice-server](https://developer.mozilla.org/en-US/docs/Web/API/RTCPeerConnection/RTCPeerConnection#iceservers) structure in JSON string format with TURN URL used to establish the WebRTC connection, mainly for TCP fallback.
9292

93-
**Note:** Do not enclose the object in an array.
93+
> Do not enclose the object in an array.
94+
> If you have multiple TURN servers, you can add them in the `urls` array.
95+
> **If not set, the plugin will use the default TURN server of the Ceeblue Cloud.**
9496
9597
**Example:**
9698

@@ -130,7 +132,7 @@ Call the `player.src()` method with a WebRTC URL.
130132
const player = videojs('video-tag');
131133
player.src({
132134
src: 'wss://<ceeblue-host>/<streamId>',
133-
iceservers: '{
135+
iceserver: '{
134136
"urls": ["turn:<ceeblue-host>?transport=tcp", "turn:<ceeblue-host>:3478"],
135137
"username": "csc_demo",
136138
"credential": "UtrAFClFFO"
@@ -157,7 +159,7 @@ The WebRTC source can be set directly in the HTML Source tag.
157159
<div id="video_container">
158160
<video id=video-player width=960 height=540 class="video-js vjs-default-skin" controls>
159161
<source src="wss://<ceeblue-host>/webrtc/<streamId>"
160-
iceServers='{"urls": ["turn:<ceeblue-host>?transport=tcp", "turn:<ceeblue-host>:3478"], "username": "csc_demo", "credential": "UtrAFClFFO"}'>
162+
iceserver='{"urls": ["turn:<ceeblue-host>?transport=tcp", "turn:<ceeblue-host>:3478"], "username": "csc_demo", "credential": "UtrAFClFFO"}'>
161163
</video>
162164
</div>
163165
<script>
@@ -208,13 +210,19 @@ To start the `SourceController` call the `start()` function with the following a
208210
streamName: '<streamId>'
209211
query: 'id=<accessToken>'
210212
},
211-
[{
213+
[
214+
{
215+
// A WebRTC source with custom options
212216
src: 'wss://<ceeblue-host>/<streamId>',
213-
iceservers: '{"urls": ["turn:<ceeblue-host>?transport=tcp", "turn:<ceeblue-host>:3478"], "username": "csc_demo", "credential": "UtrAFClFFO"}',
214-
},
217+
iceserver: '{"urls": ["turn:<ceeblue-host>?transport=tcp", "turn:<ceeblue-host>:3478"], "username": "csc_demo", "credential": "UtrAFClFFO"}',
218+
},
215219
'llhls',
216-
'dash',
217-
'hls'
220+
'dash',
221+
{
222+
// A fallback source with a custom type
223+
src: 'http://vjs.zencdn.net/v/oceans.mp4',
224+
type: 'video/mp4'
225+
}
218226
]);
219227
```
220228

examples/player.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,7 @@ <h5>Timed Metadatas</h5>
265265
source = {
266266
src: Connect.buildURL(ConnectType.WEBRTC, connectParams, protocol).toString(),
267267
// Ceeblue specific options
268-
iceservers: {
268+
iceserver: {
269269
urls: ['turn:' + this.host.domain + ':3478?transport=tcp', 'turn:' + this.host.domain + ':3478'],
270270
username: 'csc_demo',
271271
credential: 'UtrAFClFFO'

src/controllers/SourceController.js

+10-7
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ export class SourceController extends EventEmitter {
128128
source.sourceType = SourceType.DASH;
129129
break;
130130
default:
131-
videojs.log.warning('Unknown source type ' + source.type + ' using the MIME type instead');
131+
videojs.log.warn('Unknown source type ' + source.type + ' using the MIME type instead');
132132
source.sourceType = source.type;
133133
break;
134134
}
@@ -165,12 +165,15 @@ export class SourceController extends EventEmitter {
165165
const protocol = connectParams.host.startsWith('https://') ? 'https' : 'wss';
166166

167167
result.src = Connect.buildURL(ConnectType.WEBRTC, connectParams, protocol).toString();
168-
// Use the default ICE servers structure
169-
result.iceServers = {
170-
urls: ['turn:' + domain + ':3478?transport=tcp', 'turn:' + domain + ':3478'],
171-
username: 'csc_demo',
172-
credential: 'UtrAFClFFO'
173-
};
168+
result.iceserver = connectParams.iceServer;
169+
if (!result.iceserver) {
170+
// Use the default ICE servers structure
171+
result.iceserver = {
172+
urls: ['turn:' + domain + ':3478?transport=tcp', 'turn:' + domain + ':3478'],
173+
username: 'csc_demo',
174+
credential: 'UtrAFClFFO'
175+
};
176+
}
174177
break;
175178
default:
176179
videojs.log.error('Unknown source type ' + source);

src/sources/WebRTCSource.js

+5-5
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ export class WebRTCSource extends Component {
1313
* Create a WebRTC source handler instance.
1414
*
1515
* @param {Object} source Source object that is given in the DOM, includes the stream URL
16-
* and the source options : {iceservers: string|Object, audiobutton: true|false, data: true|false}
16+
* and the source options : {iceserver: string|Object, audiobutton: true|false, data: true|false}
1717
* @param {Object} tech The videojs tech object
1818
* @param {Object} options The videojs options object
1919
*/
@@ -30,10 +30,10 @@ export class WebRTCSource extends Component {
3030
return;
3131
}
3232

33-
// Parse iceServers
33+
// Parse iceServer
3434
try {
35-
if (typeof source.iceservers === 'string') {
36-
this.source.iceservers = JSON.parse(source.iceservers);
35+
if (typeof source.iceserver === 'string') {
36+
this.source.iceserver = JSON.parse(source.iceserver);
3737
}
3838
} catch (e) {
3939
videojs.log('Malformated JSON : ', e && e.message);
@@ -75,7 +75,7 @@ export class WebRTCSource extends Component {
7575
this.webRTCPlayer.on('log', log => {
7676
videojs.log('onLog', log);
7777
}, this._abortController);
78-
this.webRTCPlayer.start({host: url.host, streamName, iceServer: this.source.iceservers, query: Util.objectFrom(url.searchParams)});
78+
this.webRTCPlayer.start({host: url.host, streamName, iceServer: this.source.iceserver, query: Util.objectFrom(url.searchParams)});
7979

8080
// Create the tracks controller
8181
this._tracksController = new WebRTCTracksController(this);

0 commit comments

Comments
 (0)