Skip to content

Commit dd07bc4

Browse files
committed
updates for SM 2.0
1 parent 5a68b61 commit dd07bc4

File tree

3 files changed

+47
-1
lines changed

3 files changed

+47
-1
lines changed

index.html

+14
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,20 @@
6363
'background: #fff; color: #222'
6464
)
6565
console.log('')
66+
console.log(
67+
'%c [sm] ' +
68+
'%c : The optional flag to notify the client that it will be connecting over a Stream Manager deployment. Default: `false`',
69+
'background: #222; color: #ebefd0',
70+
'background: #fff; color: #222'
71+
)
72+
console.log('')
73+
console.log(
74+
'%c [nodegroup] ' +
75+
'%c : The optional node group name to be used in a Stream Manager deployment. Default: `undefined`',
76+
'background: #222; color: #ebefd0',
77+
'background: #fff; color: #222'
78+
)
79+
console.log('')
6680
console.log(
6781
'%c [vod] ' +
6882
'%c : The option to allow for live seek controls of the main stream. Default: `true`',

script/main.js

+29
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ const {
4141
abrLow,
4242
abrHigh,
4343
streamManager,
44+
nodeGroup,
4445
debugMode,
4546
intro,
4647
streams: streamsQueryList,
@@ -65,6 +66,13 @@ const baseConfig = {
6566
app: app || 'live',
6667
}
6768

69+
// Optional node group configuration for Stream Manager 2.0.
70+
if (streamManager) {
71+
baseConfig.connectionParams = {
72+
nodeGroup: nodeGroup || 'default',
73+
}
74+
}
75+
6876
/**
6977
* Loads and parses the JSON payload from the scriptURL to determine the list of streams to display.
7078
* @param {String} scriptURL
@@ -78,17 +86,38 @@ const getStreamMapFromScriptURL = async (scriptURL) => {
7886
// * [ <string> ]
7987
// * [ { name: <string> } ]
8088
// * [ { name: <string>, label: <string> } ]
89+
// * [ { streamGuid: <string>, nodeRole: <string> } ]
8190
// * { <string>: <string> }
8291
if (Object.prototype.toString.call(json) === '[object Array]') {
8392
json.forEach((item) => {
93+
// SM 1.0 stream list payload.
8494
if (typeof item === 'object' && item.name) {
8595
if (!item.type || (item.type && item.type !== 'origin')) {
8696
list.push({
8797
label: item.label || item.name,
8898
streamName: item.name,
8999
})
90100
}
101+
} else if (typeof item === 'object' && item.streamGuid) {
102+
// SM 2.0 stream list payload >
103+
// If nodeRole matches /^edge/
104+
if (item.nodeRole && item.nodeRole.match(/^edge/)) {
105+
const guid = item.streamGuid
106+
// Split the stream name after the last / in the streamGuid.
107+
let parts = guid.split('/')
108+
if (parts.length > 1) {
109+
const streamName = parts.pop()
110+
const context = parts.join('/')
111+
if (context === app) {
112+
list.push({
113+
label: streamName,
114+
streamName,
115+
})
116+
}
117+
}
118+
}
91119
} else if (typeof item === 'string') {
120+
// streams.jsp payload >
92121
list.push({ label: item, streamName: item })
93122
}
94123
})

script/url-util.js

+4-1
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ const paramExclude = [
4040
'debug',
4141
'embed',
4242
'sm',
43+
'nodegroup',
4344
'abr',
4445
'abrlow',
4546
'abrhigh',
@@ -82,6 +83,7 @@ export const query = () => {
8283
const abrLowOpt = searchParams.get('abrlow')
8384
const abrHighOpt = searchParams.get('abrhigh')
8485
const smOpt = searchParams.get('sm')
86+
const nodeGroupOpt = searchParams.get('nodegroup')
8587
const vodOpt = searchParams.get('vod')
8688
const demoOpt = searchParams.get('demo')
8789
const debugOpt = searchParams.get('debug')
@@ -95,7 +97,7 @@ export const query = () => {
9597
: undefined
9698
let app = searchParams.get('app')
9799
? decodeURIComponent(searchParams.get('app'))
98-
: undefined
100+
: 'live'
99101
const vodBase = searchParams.get('vodbase')
100102
? decodeURIComponent(searchParams.get('vodbase'))
101103
: undefined
@@ -126,6 +128,7 @@ export const query = () => {
126128
abrLow,
127129
abrHigh,
128130
streamManager,
131+
nodeGroup: nodeGroupOpt,
129132
streams,
130133
demoMode,
131134
debugMode,

0 commit comments

Comments
 (0)