Skip to content
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

Merged
merged 29 commits into from
Mar 6, 2018

Conversation

odedhutzler
Copy link
Contributor

@odedhutzler odedhutzler commented Jan 31, 2018

Description of the Changes

Added jsonp configuration and a helper module to configure it in the player.
the configuration has 2 fields:

  1. the jsonp handler function.
  2. should we use the jsonp plugin.

CheckLists

  • changes have been done against master branch, and PR does not conflict
  • new unit / functional tests have been added (whenever applicable)
  • test are passing in local environment
  • Travis tests are passing (or test results are not worse than on master branch :))
  • Docs have been updated

@odedhutzler odedhutzler self-assigned this Jan 31, 2018

const uriHost = getParsedUri(uri).hostname;
const flavorUriHost = getParsedUri(data.flavors[0].url).hostname
if (data.flavors.length === 1 && uriHost !== flavorUriHost) {

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

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

k

* @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")){

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

Copy link
Contributor

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?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

beautify

Copy link
Contributor Author

@odedhutzler odedhutzler Feb 5, 2018

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)

function configureJsonp(config: Object): void{
config.playback = config.playback || {};
config.playback.options = config.playback.options || {};
config.playback.options.html5 = config.playback.options.html5 || {};

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

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

k

* @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")){
Copy link
Contributor

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?

* @returns {void}
*/
function configureJsonp(config: Object): void{
config.playback = config.playback || {};
Copy link
Contributor

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.

@@ -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);
Copy link
Contributor

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?

@@ -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);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. You are accessing a private member - you can't do it.
  2. 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.

* @param {Object} config - configuration relevant to jsonp
* @returns {void}
*/
function configureJsonp(config: Object): void{
Copy link
Contributor

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).

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

beautify

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;
Copy link
Contributor

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).

return {
'hostname': parser.hostname,
'uri': uri
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

missing semicolon

Copy link
Contributor

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?

*/
function getDirectManfiestUri(data: Object, uri: string): string {
const getParsedUri = uri => {
const parser = document.createElement('a');
Copy link
Contributor

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

Copy link
Contributor Author

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

};

const uriHost = getParsedUri(uri).hostname;
const flavorUriHost = getParsedUri(data.flavors[0].url).hostname
Copy link
Contributor

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.

config.playback.options.html5.dash.useJsonp = true;
config.playback.options.html5.dash.callback = getDirectManfiestUri;
}
if (shouldUseJsonp(config.playback.options.html5.hls)){
Copy link
Contributor

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.

Copy link
Contributor Author

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

Copy link
Contributor

@dan-ziv dan-ziv Feb 5, 2018

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.

Copy link
Contributor Author

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.

* @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")){
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

beautify

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") {
Copy link
Contributor

@dan-ziv dan-ziv Feb 28, 2018

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.

OrenMe
OrenMe previously approved these changes Mar 1, 2018
dan-ziv
dan-ziv previously approved these changes Mar 1, 2018
@dan-ziv dan-ziv changed the title fix(FEC-7815): adding jsonp plugin fix(FEC-7815): Support playManifest redirects for external streams Mar 6, 2018
@dan-ziv dan-ziv merged commit cac2bb6 into master Mar 6, 2018
@dan-ziv dan-ziv deleted the FEC-7815 branch March 6, 2018 11:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

4 participants