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

ALL-3936/Package restructure #55

Merged
merged 13 commits into from
Jun 27, 2017
Merged
Show file tree
Hide file tree
Changes from 12 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
package com.novoda.noplayer.exoplayer;
package com.novoda.noplayer;

public class AspectRatioChangeCalculator {
class AspectRatioChangeCalculator {

private final Listener listener;

public AspectRatioChangeCalculator(Listener listener) {
AspectRatioChangeCalculator(Listener listener) {
this.listener = listener;
}

public void onVideoSizeChanged(int width, int height, int unappliedRotationDegrees, float pixelWidthHeightRatio) {
public void onVideoSizeChanged(int width, int height, float pixelWidthHeightRatio) {
float aspectRatio = determineAspectRatio(width, height, pixelWidthHeightRatio);
listener.onNewAspectRatio(aspectRatio);
}
Expand All @@ -20,9 +20,8 @@ private float determineAspectRatio(int videoWidth, int videoHeight, float pixelW
return (videoWidth * pixelWidthHeightRatio) / videoHeight;
}

public interface Listener {
interface Listener {

void onNewAspectRatio(float aspectRatio);

}
}
10 changes: 0 additions & 10 deletions core/src/main/java/com/novoda/noplayer/Listeners.java
Original file line number Diff line number Diff line change
@@ -1,14 +1,5 @@
package com.novoda.noplayer;

import com.novoda.noplayer.listeners.BitrateChangedListeners;
import com.novoda.noplayer.listeners.BufferStateListeners;
import com.novoda.noplayer.listeners.CompletionListeners;
import com.novoda.noplayer.listeners.ErrorListeners;
import com.novoda.noplayer.listeners.InfoListeners;
import com.novoda.noplayer.listeners.PreparedListeners;
import com.novoda.noplayer.listeners.StateChangedListeners;
import com.novoda.noplayer.listeners.VideoSizeChangedListeners;

public interface Listeners {

void addErrorListener(Player.ErrorListener errorListener);
Expand Down Expand Up @@ -46,5 +37,4 @@ public interface Listeners {
void addVideoSizeChangedListener(Player.VideoSizeChangedListener videoSizeChangedListener);

void removeVideoSizeChangedListener(Player.VideoSizeChangedListener videoSizeChangedListener);

}
4 changes: 2 additions & 2 deletions core/src/main/java/com/novoda/noplayer/NoPlayerView.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

import com.google.android.exoplayer2.ui.AspectRatioFrameLayout;
import com.google.android.exoplayer2.ui.SubtitleView;
import com.novoda.noplayer.exoplayer.AspectRatioChangeCalculator;
import com.novoda.noplayer.model.TextCues;

public class NoPlayerView extends FrameLayout implements AspectRatioChangeCalculator.Listener, PlayerView {

Expand Down Expand Up @@ -84,7 +84,7 @@ public void setSubtitleCue(TextCues textCues) {
private final Player.VideoSizeChangedListener videoSizeChangedListener = new Player.VideoSizeChangedListener() {
@Override
public void onVideoSizeChanged(int width, int height, int unappliedRotationDegrees, float pixelWidthHeightRatio) {
aspectRatioChangeCalculator.onVideoSizeChanged(width, height, unappliedRotationDegrees, pixelWidthHeightRatio);
aspectRatioChangeCalculator.onVideoSizeChanged(width, height, pixelWidthHeightRatio);
}
};

Expand Down
5 changes: 5 additions & 0 deletions core/src/main/java/com/novoda/noplayer/Player.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@

import android.net.Uri;

import com.novoda.noplayer.model.Bitrate;
import com.novoda.noplayer.model.PlayerAudioTrack;
import com.novoda.noplayer.model.PlayerSubtitleTrack;
import com.novoda.noplayer.model.Timeout;
import com.novoda.noplayer.model.VideoPosition;
import com.novoda.noplayer.player.PlayerInformation;

import java.util.List;
Expand Down
3 changes: 3 additions & 0 deletions core/src/main/java/com/novoda/noplayer/PlayerState.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
package com.novoda.noplayer;

import com.novoda.noplayer.model.VideoDuration;
import com.novoda.noplayer.model.VideoPosition;

public interface PlayerState {

boolean isPlaying();
Expand Down
2 changes: 2 additions & 0 deletions core/src/main/java/com/novoda/noplayer/PlayerView.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

import android.view.View;

import com.novoda.noplayer.model.TextCues;

public interface PlayerView {

View getContainerView();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package com.novoda.noplayer.drm;

import com.novoda.noplayer.model.KeySetId;

public interface DownloadedModularDrm extends DrmHandler {

KeySetId getKeySetId();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@
import java.net.HttpURLConnection;
import java.net.URL;

public class HttpPoster {
class HttpUrlConnectionPoster {

private static final String POST_REQUEST_METHOD = "POST";
private static final int RESPONSE_BUFFER_SIZE = 1024 * 4;

public byte[] post(String url) throws IOException {
byte[] post(String url) throws IOException {
HttpURLConnection urlConnection = null;
try {
urlConnection = (HttpURLConnection) new URL(url).openConnection();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,33 +3,8 @@
import com.novoda.noplayer.drm.ModularDrmProvisionRequest;

import java.io.IOException;
import java.nio.charset.Charset;

public class ProvisionExecutor {
public interface ProvisionExecutor {

private static final String PARAMETER_SIGNED_REQUEST = "&signedRequest=";

private final HttpPoster httpPoster;
private final ProvisioningCapabilities capabilities;

public ProvisionExecutor(HttpPoster httpPoster, ProvisioningCapabilities capabilities) {
this.httpPoster = httpPoster;
this.capabilities = capabilities;
}

public byte[] execute(ModularDrmProvisionRequest request) throws IOException, UnableToProvisionException {
if (isIncapableOfProvisioning()) {
throw new UnableToProvisionException();
}
String provisioningUrl = buildProvisioningUrl(request);
return httpPoster.post(provisioningUrl);
}

private boolean isIncapableOfProvisioning() {
return !capabilities.canProvision();
}

private String buildProvisioningUrl(ModularDrmProvisionRequest request) {
return request.url() + PARAMETER_SIGNED_REQUEST + new String(request.data(), Charset.forName("UTF-8"));
}
byte[] execute(ModularDrmProvisionRequest request) throws IOException, UnableToProvisionException;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package com.novoda.noplayer.drm.provision;

public class ProvisionExecutorCreator {

public ProvisionExecutor create() {
HttpUrlConnectionPoster httpPoster = new HttpUrlConnectionPoster();
ProvisioningCapabilities capabilities = ProvisioningCapabilities.newInstance();
return new ProvisionExecutorImpl(httpPoster, capabilities);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
package com.novoda.noplayer.drm.provision;

import com.novoda.noplayer.drm.ModularDrmProvisionRequest;

import java.io.IOException;
import java.nio.charset.Charset;

class ProvisionExecutorImpl implements ProvisionExecutor {
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 call this something that doesn't end in impl? HttpPostingProvisionExecutor or something maybe?


private static final String PARAMETER_SIGNED_REQUEST = "&signedRequest=";

private final HttpUrlConnectionPoster httpPoster;
private final ProvisioningCapabilities capabilities;

ProvisionExecutorImpl(HttpUrlConnectionPoster httpPoster, ProvisioningCapabilities capabilities) {
this.httpPoster = httpPoster;
this.capabilities = capabilities;
}

@Override
public byte[] execute(ModularDrmProvisionRequest request) throws IOException, UnableToProvisionException {
if (isIncapableOfProvisioning()) {
throw new UnableToProvisionException();
}
String provisioningUrl = buildProvisioningUrl(request);
return httpPoster.post(provisioningUrl);
}

private boolean isIncapableOfProvisioning() {
return !capabilities.canProvision();
}

private String buildProvisioningUrl(ModularDrmProvisionRequest request) {
return request.url() + PARAMETER_SIGNED_REQUEST + new String(request.data(), Charset.forName("UTF-8"));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@

import android.os.Build;

public class ProvisioningCapabilities {
class ProvisioningCapabilities {

private final int deviceOsVersion;

public static ProvisioningCapabilities newInstance() {
static ProvisioningCapabilities newInstance() {
return new ProvisioningCapabilities(Build.VERSION.SDK_INT);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
package com.novoda.noplayer.exoplayer;

import android.content.Context;
import android.support.annotation.NonNull;

import com.google.android.exoplayer2.DefaultLoadControl;
import com.google.android.exoplayer2.ExoPlayerFactory;
import com.google.android.exoplayer2.RenderersFactory;
import com.google.android.exoplayer2.SimpleExoPlayer;
import com.google.android.exoplayer2.drm.DefaultDrmSessionManager;
import com.google.android.exoplayer2.drm.DrmSessionManager;
import com.google.android.exoplayer2.drm.FrameworkMediaCrypto;
import com.google.android.exoplayer2.trackselection.DefaultTrackSelector;
import com.novoda.noplayer.drm.DrmSessionCreator;
import com.novoda.noplayer.exoplayer.forwarder.ExoPlayerDrmSessionEventListener;
import com.novoda.noplayer.exoplayer.drm.DrmSessionCreator;

import static com.novoda.noplayer.exoplayer.SimpleRenderersFactory.EXTENSION_RENDERER_MODE_OFF;

Expand All @@ -27,9 +26,8 @@ class ExoPlayerCreator {
this.trackSelector = trackSelector;
}

@NonNull
public SimpleExoPlayer create(DrmSessionCreator drmSessionCreator, ExoPlayerDrmSessionEventListener exoPlayerDrmSessionEventListener, boolean downgradeSecureDecoder) {
DrmSessionManager<FrameworkMediaCrypto> drmSessionManager = drmSessionCreator.create(exoPlayerDrmSessionEventListener);
public SimpleExoPlayer create(DrmSessionCreator drmSessionCreator, DefaultDrmSessionManager.EventListener drmSessionEventListener, boolean downgradeSecureDecoder) {
DrmSessionManager<FrameworkMediaCrypto> drmSessionManager = drmSessionCreator.create(drmSessionEventListener);
RenderersFactory renderersFactory = new SimpleRenderersFactory(
context,
drmSessionManager,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@
import com.google.android.exoplayer2.SimpleExoPlayer;
import com.google.android.exoplayer2.source.MediaSource;
import com.novoda.noplayer.ContentType;
import com.novoda.noplayer.PlayerAudioTrack;
import com.novoda.noplayer.PlayerSubtitleTrack;
import com.novoda.noplayer.VideoDuration;
import com.novoda.noplayer.VideoPosition;
import com.novoda.noplayer.drm.DrmSessionCreator;
import com.novoda.noplayer.model.PlayerAudioTrack;
import com.novoda.noplayer.model.PlayerSubtitleTrack;
import com.novoda.noplayer.model.VideoDuration;
import com.novoda.noplayer.model.VideoPosition;
import com.novoda.noplayer.exoplayer.drm.DrmSessionCreator;
import com.novoda.noplayer.exoplayer.forwarder.ExoPlayerForwarder;
import com.novoda.noplayer.exoplayer.mediasource.ExoPlayerAudioTrackSelector;
import com.novoda.noplayer.exoplayer.mediasource.ExoPlayerSubtitleTrackSelector;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,24 +6,24 @@

import com.novoda.noplayer.ContentType;
import com.novoda.noplayer.Heart;
import com.novoda.noplayer.LoadTimeout;
import com.novoda.noplayer.model.LoadTimeout;
import com.novoda.noplayer.Player;
import com.novoda.noplayer.PlayerAudioTrack;
import com.novoda.noplayer.model.PlayerAudioTrack;
import com.novoda.noplayer.PlayerListenersHolder;
import com.novoda.noplayer.PlayerState;
import com.novoda.noplayer.PlayerSubtitleTrack;
import com.novoda.noplayer.model.PlayerSubtitleTrack;
import com.novoda.noplayer.PlayerView;
import com.novoda.noplayer.SurfaceHolderRequester;
import com.novoda.noplayer.Timeout;
import com.novoda.noplayer.VideoDuration;
import com.novoda.noplayer.VideoPosition;
import com.novoda.noplayer.drm.DrmSessionCreator;
import com.novoda.noplayer.model.Timeout;
import com.novoda.noplayer.model.VideoDuration;
import com.novoda.noplayer.model.VideoPosition;
import com.novoda.noplayer.exoplayer.drm.DrmSessionCreator;
import com.novoda.noplayer.exoplayer.forwarder.ExoPlayerForwarder;
import com.novoda.noplayer.player.PlayerInformation;

import java.util.List;

public class ExoPlayerTwoImpl implements Player {
class ExoPlayerTwoImpl implements Player {

private final ExoPlayerFacade exoPlayer;
private final PlayerListenersHolder listenersHolder;
Expand Down Expand Up @@ -57,7 +57,7 @@ public class ExoPlayerTwoImpl implements Player {
this.downgradeSecureDecoder = downgradeSecureDecoder;
}

public void initialise() {
void initialise() {
heart.bind(new Heart.Heartbeat<>(listenersHolder.getHeartbeatCallbacks(), this));
forwarder.bind(listenersHolder.getPreparedListeners(), this);
forwarder.bind(listenersHolder.getCompletionListeners(), listenersHolder.getStateChangedListeners());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@
import com.google.android.exoplayer2.trackselection.FixedTrackSelection;
import com.google.android.exoplayer2.upstream.DefaultDataSourceFactory;
import com.novoda.noplayer.Heart;
import com.novoda.noplayer.LoadTimeout;
import com.novoda.noplayer.model.LoadTimeout;
import com.novoda.noplayer.Player;
import com.novoda.noplayer.PlayerListenersHolder;
import com.novoda.noplayer.SystemClock;
import com.novoda.noplayer.drm.DrmSessionCreator;
import com.novoda.noplayer.exoplayer.drm.DrmSessionCreator;
import com.novoda.noplayer.exoplayer.forwarder.ExoPlayerForwarder;
import com.novoda.noplayer.exoplayer.mediasource.ExoPlayerAudioTrackSelector;
import com.novoda.noplayer.exoplayer.mediasource.ExoPlayerSubtitleTrackSelector;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
/**
* Default {@link RenderersFactory} implementation.
*/
public class SimpleRenderersFactory implements RenderersFactory {
class SimpleRenderersFactory implements RenderersFactory {

/**
* Modes for using extension renderers.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import com.google.android.exoplayer2.text.Cue;
import com.google.android.exoplayer2.text.TextRenderer;
import com.novoda.noplayer.PlayerView;
import com.novoda.noplayer.TextCues;
import com.novoda.noplayer.model.TextCues;

import java.util.ArrayList;
import java.util.List;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
package com.novoda.noplayer.drm;
package com.novoda.noplayer.exoplayer.drm;

import android.os.Handler;

import com.google.android.exoplayer2.drm.DefaultDrmSessionManager;
import com.google.android.exoplayer2.drm.DrmSessionManager;
import com.google.android.exoplayer2.drm.FrameworkMediaCrypto;
import com.novoda.noplayer.drm.DownloadedModularDrm;

class DownloadDrmSessionCreator implements DrmSessionCreator {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.novoda.noplayer.drm;
package com.novoda.noplayer.exoplayer.drm;

import android.support.annotation.Nullable;

Expand All @@ -14,11 +14,4 @@ public interface DrmSessionCreator {

@Nullable
DrmSessionManager<FrameworkMediaCrypto> create(DefaultDrmSessionManager.EventListener eventListener);

class DrmSessionManagerCreationException extends RuntimeException {

DrmSessionManagerCreationException(Throwable cause) {
super(cause);
}
}
}
Loading