@@ -41,6 +41,7 @@ const {
41
41
abrLow,
42
42
abrHigh,
43
43
streamManager,
44
+ nodeGroup,
44
45
debugMode,
45
46
intro,
46
47
streams : streamsQueryList ,
@@ -65,6 +66,13 @@ const baseConfig = {
65
66
app : app || 'live' ,
66
67
}
67
68
69
+ // Optional node group configuration for Stream Manager 2.0.
70
+ if ( streamManager ) {
71
+ baseConfig . connectionParams = {
72
+ nodeGroup : nodeGroup || 'default' ,
73
+ }
74
+ }
75
+
68
76
/**
69
77
* Loads and parses the JSON payload from the scriptURL to determine the list of streams to display.
70
78
* @param {String } scriptURL
@@ -78,17 +86,38 @@ const getStreamMapFromScriptURL = async (scriptURL) => {
78
86
// * [ <string> ]
79
87
// * [ { name: <string> } ]
80
88
// * [ { name: <string>, label: <string> } ]
89
+ // * [ { streamGuid: <string>, nodeRole: <string> } ]
81
90
// * { <string>: <string> }
82
91
if ( Object . prototype . toString . call ( json ) === '[object Array]' ) {
83
92
json . forEach ( ( item ) => {
93
+ // SM 1.0 stream list payload.
84
94
if ( typeof item === 'object' && item . name ) {
85
95
if ( ! item . type || ( item . type && item . type !== 'origin' ) ) {
86
96
list . push ( {
87
97
label : item . label || item . name ,
88
98
streamName : item . name ,
89
99
} )
90
100
}
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 ( / ^ e d g e / ) ) {
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
+ }
91
119
} else if ( typeof item === 'string' ) {
120
+ // streams.jsp payload >
92
121
list . push ( { label : item , streamName : item } )
93
122
}
94
123
} )
0 commit comments