Skip to content
This repository has been archived by the owner on Feb 11, 2022. It is now read-only.

ALL-3936/Player Builder #57

Merged
merged 7 commits into from
Jun 28, 2017
Merged

ALL-3936/Player Builder #57

merged 7 commits into from
Jun 28, 2017

Conversation

Mecharyry
Copy link
Contributor

Problem

As per issue #53 and the conversation that took place in https://github.com/novoda/no-player/pull/52/files/4748c1dd02defdb565cd7174a38deb90ee214d9d#diff-d137d202ec4e30de3f26dfb2c0131896 we want to replace the PlayerFactory with a PlayerBuilder as the player has a number of customizations that can be exposed to our clients.

Solution

Create a PlayerBuilder and a PlayerCreator. We have exposed a withDowngradedSecureDecoder to hide the boolean we had before. This boolean is passed down to the ExoPlayer level at which point it is transformed into the necessary MediaCodecSelector. The MediaCodecSelector is not directly exposed in the Builder because it is only necessary for ExoPlayer.

Test(s) added

Updating tests that we broke as a result of these changes.

Screenshots

No UI changes.

Paired with

@ouchadam

@@ -51,6 +52,8 @@ ExoPlayerTwoImpl create(Context context, DrmSessionCreator drmSessionCreator, bo

DefaultTrackSelector trackSelector = new DefaultTrackSelector();

MediaCodecSelector mediaCodecSelector = downgradeSecureDecoder ? SecurityDowngradingCodecSelector.newInstance() : MediaCodecSelector.DEFAULT;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

boolean downgradeSecureDecoder is transformed into the associated MediaCodecSelector.

Copy link
Contributor

Choose a reason for hiding this comment

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

@joetimmins the boolean now lives on PlayerBuilder -> NoPlayerCreator and finally here where it gets converted to the codec selector

import com.novoda.noplayer.exoplayer.drm.DrmSessionCreatorFactory;
import com.novoda.noplayer.mediaplayer.NoPlayerMediaPlayerCreator;

class NoPlayerCreator {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is the old PlayerFactory minus a few wrapper methods, we only expose the one method create and it is used only in the PlayerBuilder.

import java.util.Arrays;
import java.util.List;

public class PlayerBuilder {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Builder party 🎉

@juankysoriano juankysoriano self-requested a review June 27, 2017 15:21
@juankysoriano juankysoriano self-assigned this Jun 27, 2017
return this;
}

public Player build(Context context) {
Copy link
Contributor

Choose a reason for hiding this comment

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

as a user of the library I can still use NoPlayerExoPlayerCreator directly and create it without the builder.

Is this intentional?

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 see how to avoid this without flattening all the packages 😢

Copy link
Contributor

Choose a reason for hiding this comment

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

😢

I have taken a look and I don't see either

Copy link
Contributor

Choose a reason for hiding this comment

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

Can NoPlayerCreator be properly used by the client? if it doesn't make sense for the client to do so, we might have to flatten the packages... java, libraries and packages are not friends, it really sucks :S

Copy link
Contributor

@ouchadam ouchadam Jun 28, 2017

Choose a reason for hiding this comment

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

NoPlayerCreator is not public, it's the individual player creators which are, like NoPlayerExoPlayerCreator

I don't think it's problem or enough of a reason to flatten the entire library.

There's no issue or side effects of a client creating a single player directly via the public player creators, if anything it's an architectural feature. The PlayerBuilder is syntactic sugar around selecting a player for given types, which isn't needed if a client decides to manually use a specific creator

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 the NoPlayerMediaPlayerCreator and NoPlayerExoPlayerCreator that are exposed. They are the sole entry points into the exo-player and media-player packages. Flattening would solve this problem but make maintaining no-player extremely painful.

Copy link
Contributor

Choose a reason for hiding this comment

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

Agreed offline, we'll expose these creators as part of the public API

this.internalMediaCodecUtil = internalMediaCodecUtil;
this.downgradeSecureDecoder = downgradeSecureDecoder;
}

@Override
public MediaCodecInfo getDecoderInfo(String mimeType, boolean contentRequiresSecureDecoder)
Copy link
Contributor

Choose a reason for hiding this comment

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

is contentRequiresSecureDecoder not used anymore? if so... kill it? (if we can, which I don't know)

Copy link
Contributor

Choose a reason for hiding this comment

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

it's from ExoPlayer MediaCodecSelector, we can't remove it, unless you mean rename it?

Copy link
Contributor

Choose a reason for hiding this comment

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

I didn't notice it was from the exoplayer one, ok then 👍

return this;
}

public PlayerBuilder withDowngradedSecureDecoder() {
Copy link
Contributor

Choose a reason for hiding this comment

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

👍

DataPostingModularDrm drmHandler = new DataPostingModularDrm(EXAMPLE_MODULAR_LICENSE_SERVER_PROXY);

player = playerFactory.create(DrmType.WIDEVINE_MODULAR_STREAM, drmHandler);
player = new PlayerBuilder()
Copy link
Contributor

Choose a reason for hiding this comment

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

To be honest I feel the builder is a super cool idea! 💯

Copy link
Contributor

Choose a reason for hiding this comment

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

you can thank @Mecharyry trolling me and @zegnus 😂

Copy link
Contributor

@juankysoriano juankysoriano left a comment

Choose a reason for hiding this comment

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

LGTM, I like the builder

I don't like the NoPlayer creators for media player or exo player being public, but I can't see how to make it better

@Mecharyry Mecharyry changed the base branch from ALL-3936/cues to exo-player-2 June 27, 2017 16:02
@zegnus zegnus self-assigned this Jun 28, 2017
}

@Override
public MediaCodecInfo getDecoderInfo(String mimeType, boolean contentRequiresSecureDecoder)
throws MediaCodecUtil.DecoderQueryException {
return internalMediaCodecUtil.getDecoderInfo(mimeType, contentRequiresSecureDecoder && !downgradeSecureDecoder);
return internalMediaCodecUtil.getDecoderInfo(mimeType, false);
Copy link
Contributor

Choose a reason for hiding this comment

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

can you extract that boolean? I have no idea what's false there :P

@zegnus
Copy link
Contributor

zegnus commented Jun 28, 2017

💯 niiice!

@zegnus zegnus merged commit f422d3e into exo-player-2 Jun 28, 2017
@zegnus zegnus deleted the ALL-3936/builder branch June 28, 2017 10:36
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants