-
Notifications
You must be signed in to change notification settings - Fork 52
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(FEC-7815): Support playManifest redirects for external streams #85
Conversation
src/common/utils/jsonp-helper.js
Outdated
|
||
const uriHost = getParsedUri(uri).hostname; | ||
const flavorUriHost = getParsedUri(data.flavors[0].url).hostname | ||
if (data.flavors.length === 1 && uriHost !== flavorUriHost) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@odedhutzler please document this part inline - since this logic is not very clear at first
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
k
src/common/utils/jsonp-helper.js
Outdated
* @returns {boolean} should or not use jsonp requests on manifests | ||
*/ | ||
function shouldUseJsonp(config: Object): boolean{ | ||
if ((config && config.useJsonp) || Env.browser.name.includes("IE") || Env.browser.name.includes("Edge")){ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@odedhutzler we already know that Panasonic browser need it too - please add
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we do better then browser sniffing?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
beautify
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@OrenMe I can change it to more configured... like
config.playback.options.adapters.forceRedriectBrowsers.includes(Env.browser.name) // "IE,Edge".includes(Env.browser.name)
src/common/utils/jsonp-helper.js
Outdated
function configureJsonp(config: Object): void{ | ||
config.playback = config.playback || {}; | ||
config.playback.options = config.playback.options || {}; | ||
config.playback.options.html5 = config.playback.options.html5 || {}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@odedhutzler we have a function for that please use it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
k
src/common/utils/jsonp-helper.js
Outdated
* @returns {boolean} should or not use jsonp requests on manifests | ||
*/ | ||
function shouldUseJsonp(config: Object): boolean{ | ||
if ((config && config.useJsonp) || Env.browser.name.includes("IE") || Env.browser.name.includes("Edge")){ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we do better then browser sniffing?
src/common/utils/jsonp-helper.js
Outdated
* @returns {void} | ||
*/ | ||
function configureJsonp(config: Object): void{ | ||
config.playback = config.playback || {}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should align this as general adapter config and not via direct and specific HLS or DASH settings.
try to generalise the setting.
src/kaltura-player.js
Outdated
@@ -22,6 +23,7 @@ export default class KalturaPlayer { | |||
constructor(options: KalturaPlayerOptionsObject) { | |||
this._player = loadPlayer(options.player); | |||
this._logger = getLogger('KalturaPlayer' + Utils.Generator.uniqueId(5)); | |||
configureJsonp(this._player._config); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
move to default options getDefaultOptions?
src/kaltura-player.js
Outdated
@@ -22,6 +23,7 @@ export default class KalturaPlayer { | |||
constructor(options: KalturaPlayerOptionsObject) { | |||
this._player = loadPlayer(options.player); | |||
this._logger = getLogger('KalturaPlayer' + Utils.Generator.uniqueId(5)); | |||
configureJsonp(this._player._config); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- You are accessing a private member - you can't do it.
- If you want to manipulate the configuration of the player you need to move the
configureJsonp
to the setup workflow, before the kaltura player has been created.
src/common/utils/jsonp-helper.js
Outdated
* @param {Object} config - configuration relevant to jsonp | ||
* @returns {void} | ||
*/ | ||
function configureJsonp(config: Object): void{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think configureJsonp
is a good name, this is like to call a method configureXHR
. JSONP is a generic method for sending JSON data. Try to think what is the real purpose here (redirect for external streams, for example).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
beautify
src/common/utils/jsonp-helper.js
Outdated
if (shouldUseJsonp(config.playback.options.html5.dash)){ | ||
config.playback.options.html5.dash = config.playback.options.html5.dash || {}; | ||
config.playback.options.html5.dash.useJsonp = true; | ||
config.playback.options.html5.dash.callback = getDirectManfiestUri; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Too generic names for configurations (see my suggestion bellow).
src/common/utils/jsonp-helper.js
Outdated
return { | ||
'hostname': parser.hostname, | ||
'uri': uri | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
missing semicolon
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why to return an object if u use only the hostname field outside?
src/common/utils/jsonp-helper.js
Outdated
*/ | ||
function getDirectManfiestUri(data: Object, uri: string): string { | ||
const getParsedUri = uri => { | ||
const parser = document.createElement('a'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
parser? looks like an element
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it's purpose is to parse the url
src/common/utils/jsonp-helper.js
Outdated
}; | ||
|
||
const uriHost = getParsedUri(uri).hostname; | ||
const flavorUriHost = getParsedUri(data.flavors[0].url).hostname |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
unsafe access to object data.flavors[0].url
. check for existence of fields.
src/common/utils/jsonp-helper.js
Outdated
config.playback.options.html5.dash.useJsonp = true; | ||
config.playback.options.html5.dash.callback = getDirectManfiestUri; | ||
} | ||
if (shouldUseJsonp(config.playback.options.html5.hls)){ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why separate config for hls and dash?
I don't even think its an engine dependent.
{
playback: {
options: {
tryRedirectForExternalStreams: true,
redirectForExternalStreamsHandler: () => {....}
html5: {
}
}
}
}
Not even sure it should be under options, need to discuss the placement of this anyway.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i agree, though i must add the handler to the dash/hls config
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why?
in the createAdapter
method of each adapter you get the whole player config.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thought it gets the specific config, but you are right, i will change it.
src/common/utils/jsonp-helper.js
Outdated
* @returns {boolean} should or not use jsonp requests on manifests | ||
*/ | ||
function shouldUseJsonp(config: Object): boolean{ | ||
if ((config && config.useJsonp) || Env.browser.name.includes("IE") || Env.browser.name.includes("Edge")){ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
beautify
Moving the login into setup.js
src/common/utils/jsonp-helper.js
Outdated
function configureExternalStreamRedirect(config: Object): void { | ||
config.playback.options = config.playback.options || {}; | ||
let adapters = config.playback.options.adapters = config.playback.options.adapters || {}; | ||
if (typeof adapters.forceRedirectExternalStreams !== "boolean") { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@OrenMe
We should discuss those configuration names and placement.
I think it should be forceRedirectToExternalStreams and under sources config (it related directly to sources).
Adapters is internal and technical name that we've given to the MSEs but not should be exposed as external configuration.
Description of the Changes
Added jsonp configuration and a helper module to configure it in the player.
the configuration has 2 fields:
CheckLists