From 8a04fe62f7e9272df43511df2745652737a63f2c Mon Sep 17 00:00:00 2001 From: Ryan Feline Date: Mon, 26 Jun 2017 14:49:24 +0100 Subject: [PATCH 01/11] Move exo-player specific files from noplayer.drm to exoplayer.drm, and reduce scope where possible. --- .../src/main/java/com/novoda/noplayer/drm/SessionId.java | 2 +- .../com/novoda/noplayer/exoplayer/ExoPlayerCreator.java | 2 +- .../com/novoda/noplayer/exoplayer/ExoPlayerFacade.java | 2 +- .../com/novoda/noplayer/exoplayer/ExoPlayerTwoImpl.java | 2 +- .../noplayer/exoplayer/NoPlayerExoPlayerCreator.java | 2 +- .../{ => exoplayer}/drm/DownloadDrmSessionCreator.java | 3 ++- .../noplayer/{ => exoplayer}/drm/DrmSessionCreator.java | 9 +-------- .../{ => exoplayer}/drm/DrmSessionCreatorFactory.java | 6 +++++- .../{ => exoplayer}/drm/FrameworkDrmSession.java | 3 ++- .../{ => exoplayer}/drm/FrameworkMediaDrmCreator.java | 2 +- .../noplayer/{ => exoplayer}/drm/InvalidDrmSession.java | 3 ++- .../noplayer/{ => exoplayer}/drm/LocalDrmSession.java | 4 +++- .../{ => exoplayer}/drm/LocalDrmSessionManager.java | 4 +++- .../{ => exoplayer}/drm/NoDrmSessionCreator.java | 2 +- .../drm/ProvisioningModularDrmCallback.java | 5 ++++- .../{ => exoplayer}/drm/StreamingDrmSessionCreator.java | 2 +- .../java/com/novoda/noplayer/player/PlayerFactory.java | 4 ++-- .../novoda/noplayer/exoplayer/ExoPlayerFacadeTest.java | 2 +- .../novoda/noplayer/exoplayer/ExoPlayerTwoImplTest.java | 2 +- .../noplayer/exoplayer/NoPlayerExoPlayerCreatorTest.java | 2 +- .../drm/DrmSessionCreatorFactoryTest.java | 6 +++++- .../com/novoda/noplayer/player/PlayerFactoryTest.java | 4 ++-- 22 files changed, 42 insertions(+), 31 deletions(-) rename core/src/main/java/com/novoda/noplayer/{ => exoplayer}/drm/DownloadDrmSessionCreator.java (92%) rename core/src/main/java/com/novoda/noplayer/{ => exoplayer}/drm/DrmSessionCreator.java (70%) rename core/src/main/java/com/novoda/noplayer/{ => exoplayer}/drm/DrmSessionCreatorFactory.java (92%) rename core/src/main/java/com/novoda/noplayer/{ => exoplayer}/drm/FrameworkDrmSession.java (72%) rename core/src/main/java/com/novoda/noplayer/{ => exoplayer}/drm/FrameworkMediaDrmCreator.java (93%) rename core/src/main/java/com/novoda/noplayer/{ => exoplayer}/drm/InvalidDrmSession.java (93%) rename core/src/main/java/com/novoda/noplayer/{ => exoplayer}/drm/LocalDrmSession.java (91%) rename core/src/main/java/com/novoda/noplayer/{ => exoplayer}/drm/LocalDrmSessionManager.java (95%) rename core/src/main/java/com/novoda/noplayer/{ => exoplayer}/drm/NoDrmSessionCreator.java (92%) rename core/src/main/java/com/novoda/noplayer/{ => exoplayer}/drm/ProvisioningModularDrmCallback.java (84%) rename core/src/main/java/com/novoda/noplayer/{ => exoplayer}/drm/StreamingDrmSessionCreator.java (97%) rename core/src/test/java/com/novoda/noplayer/{ => exoplayer}/drm/DrmSessionCreatorFactoryTest.java (94%) diff --git a/core/src/main/java/com/novoda/noplayer/drm/SessionId.java b/core/src/main/java/com/novoda/noplayer/drm/SessionId.java index b6bdd388..6f1971b9 100644 --- a/core/src/main/java/com/novoda/noplayer/drm/SessionId.java +++ b/core/src/main/java/com/novoda/noplayer/drm/SessionId.java @@ -2,7 +2,7 @@ import java.util.Arrays; -class SessionId { +public class SessionId { private final byte[] sessionId; diff --git a/core/src/main/java/com/novoda/noplayer/exoplayer/ExoPlayerCreator.java b/core/src/main/java/com/novoda/noplayer/exoplayer/ExoPlayerCreator.java index 6ed01626..2a3d810b 100644 --- a/core/src/main/java/com/novoda/noplayer/exoplayer/ExoPlayerCreator.java +++ b/core/src/main/java/com/novoda/noplayer/exoplayer/ExoPlayerCreator.java @@ -10,7 +10,7 @@ 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.drm.DrmSessionCreator; import com.novoda.noplayer.exoplayer.forwarder.ExoPlayerDrmSessionEventListener; import static com.novoda.noplayer.exoplayer.SimpleRenderersFactory.EXTENSION_RENDERER_MODE_OFF; diff --git a/core/src/main/java/com/novoda/noplayer/exoplayer/ExoPlayerFacade.java b/core/src/main/java/com/novoda/noplayer/exoplayer/ExoPlayerFacade.java index 18294e55..428a7fd0 100644 --- a/core/src/main/java/com/novoda/noplayer/exoplayer/ExoPlayerFacade.java +++ b/core/src/main/java/com/novoda/noplayer/exoplayer/ExoPlayerFacade.java @@ -11,7 +11,7 @@ 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.exoplayer.drm.DrmSessionCreator; import com.novoda.noplayer.exoplayer.forwarder.ExoPlayerForwarder; import com.novoda.noplayer.exoplayer.mediasource.ExoPlayerAudioTrackSelector; import com.novoda.noplayer.exoplayer.mediasource.ExoPlayerSubtitleTrackSelector; diff --git a/core/src/main/java/com/novoda/noplayer/exoplayer/ExoPlayerTwoImpl.java b/core/src/main/java/com/novoda/noplayer/exoplayer/ExoPlayerTwoImpl.java index 22250dcd..fda5e741 100644 --- a/core/src/main/java/com/novoda/noplayer/exoplayer/ExoPlayerTwoImpl.java +++ b/core/src/main/java/com/novoda/noplayer/exoplayer/ExoPlayerTwoImpl.java @@ -17,7 +17,7 @@ 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.exoplayer.drm.DrmSessionCreator; import com.novoda.noplayer.exoplayer.forwarder.ExoPlayerForwarder; import com.novoda.noplayer.player.PlayerInformation; diff --git a/core/src/main/java/com/novoda/noplayer/exoplayer/NoPlayerExoPlayerCreator.java b/core/src/main/java/com/novoda/noplayer/exoplayer/NoPlayerExoPlayerCreator.java index 571a9d16..08e8bef8 100644 --- a/core/src/main/java/com/novoda/noplayer/exoplayer/NoPlayerExoPlayerCreator.java +++ b/core/src/main/java/com/novoda/noplayer/exoplayer/NoPlayerExoPlayerCreator.java @@ -11,7 +11,7 @@ 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; diff --git a/core/src/main/java/com/novoda/noplayer/drm/DownloadDrmSessionCreator.java b/core/src/main/java/com/novoda/noplayer/exoplayer/drm/DownloadDrmSessionCreator.java similarity index 92% rename from core/src/main/java/com/novoda/noplayer/drm/DownloadDrmSessionCreator.java rename to core/src/main/java/com/novoda/noplayer/exoplayer/drm/DownloadDrmSessionCreator.java index 1e590a51..858f3e6d 100644 --- a/core/src/main/java/com/novoda/noplayer/drm/DownloadDrmSessionCreator.java +++ b/core/src/main/java/com/novoda/noplayer/exoplayer/drm/DownloadDrmSessionCreator.java @@ -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 { diff --git a/core/src/main/java/com/novoda/noplayer/drm/DrmSessionCreator.java b/core/src/main/java/com/novoda/noplayer/exoplayer/drm/DrmSessionCreator.java similarity index 70% rename from core/src/main/java/com/novoda/noplayer/drm/DrmSessionCreator.java rename to core/src/main/java/com/novoda/noplayer/exoplayer/drm/DrmSessionCreator.java index 237ce61b..11ff3b40 100644 --- a/core/src/main/java/com/novoda/noplayer/drm/DrmSessionCreator.java +++ b/core/src/main/java/com/novoda/noplayer/exoplayer/drm/DrmSessionCreator.java @@ -1,4 +1,4 @@ -package com.novoda.noplayer.drm; +package com.novoda.noplayer.exoplayer.drm; import android.support.annotation.Nullable; @@ -14,11 +14,4 @@ public interface DrmSessionCreator { @Nullable DrmSessionManager create(DefaultDrmSessionManager.EventListener eventListener); - - class DrmSessionManagerCreationException extends RuntimeException { - - DrmSessionManagerCreationException(Throwable cause) { - super(cause); - } - } } diff --git a/core/src/main/java/com/novoda/noplayer/drm/DrmSessionCreatorFactory.java b/core/src/main/java/com/novoda/noplayer/exoplayer/drm/DrmSessionCreatorFactory.java similarity index 92% rename from core/src/main/java/com/novoda/noplayer/drm/DrmSessionCreatorFactory.java rename to core/src/main/java/com/novoda/noplayer/exoplayer/drm/DrmSessionCreatorFactory.java index 11a09cfb..61fd3670 100644 --- a/core/src/main/java/com/novoda/noplayer/drm/DrmSessionCreatorFactory.java +++ b/core/src/main/java/com/novoda/noplayer/exoplayer/drm/DrmSessionCreatorFactory.java @@ -1,8 +1,12 @@ -package com.novoda.noplayer.drm; +package com.novoda.noplayer.exoplayer.drm; import android.os.Build; import android.os.Handler; +import com.novoda.noplayer.drm.DownloadedModularDrm; +import com.novoda.noplayer.drm.DrmHandler; +import com.novoda.noplayer.drm.DrmType; +import com.novoda.noplayer.drm.StreamingModularDrm; import com.novoda.noplayer.drm.provision.HttpPoster; import com.novoda.noplayer.drm.provision.ProvisionExecutor; import com.novoda.noplayer.drm.provision.ProvisioningCapabilities; diff --git a/core/src/main/java/com/novoda/noplayer/drm/FrameworkDrmSession.java b/core/src/main/java/com/novoda/noplayer/exoplayer/drm/FrameworkDrmSession.java similarity index 72% rename from core/src/main/java/com/novoda/noplayer/drm/FrameworkDrmSession.java rename to core/src/main/java/com/novoda/noplayer/exoplayer/drm/FrameworkDrmSession.java index 9391a1f2..68228b49 100644 --- a/core/src/main/java/com/novoda/noplayer/drm/FrameworkDrmSession.java +++ b/core/src/main/java/com/novoda/noplayer/exoplayer/drm/FrameworkDrmSession.java @@ -1,7 +1,8 @@ -package com.novoda.noplayer.drm; +package com.novoda.noplayer.exoplayer.drm; import com.google.android.exoplayer2.drm.DrmSession; import com.google.android.exoplayer2.drm.FrameworkMediaCrypto; +import com.novoda.noplayer.drm.SessionId; interface FrameworkDrmSession extends DrmSession { diff --git a/core/src/main/java/com/novoda/noplayer/drm/FrameworkMediaDrmCreator.java b/core/src/main/java/com/novoda/noplayer/exoplayer/drm/FrameworkMediaDrmCreator.java similarity index 93% rename from core/src/main/java/com/novoda/noplayer/drm/FrameworkMediaDrmCreator.java rename to core/src/main/java/com/novoda/noplayer/exoplayer/drm/FrameworkMediaDrmCreator.java index f0c6f0f9..b3a13936 100644 --- a/core/src/main/java/com/novoda/noplayer/drm/FrameworkMediaDrmCreator.java +++ b/core/src/main/java/com/novoda/noplayer/exoplayer/drm/FrameworkMediaDrmCreator.java @@ -1,4 +1,4 @@ -package com.novoda.noplayer.drm; +package com.novoda.noplayer.exoplayer.drm; import com.google.android.exoplayer2.drm.FrameworkMediaDrm; import com.google.android.exoplayer2.drm.UnsupportedDrmException; diff --git a/core/src/main/java/com/novoda/noplayer/drm/InvalidDrmSession.java b/core/src/main/java/com/novoda/noplayer/exoplayer/drm/InvalidDrmSession.java similarity index 93% rename from core/src/main/java/com/novoda/noplayer/drm/InvalidDrmSession.java rename to core/src/main/java/com/novoda/noplayer/exoplayer/drm/InvalidDrmSession.java index efcf6019..9ec58bd0 100644 --- a/core/src/main/java/com/novoda/noplayer/drm/InvalidDrmSession.java +++ b/core/src/main/java/com/novoda/noplayer/exoplayer/drm/InvalidDrmSession.java @@ -1,7 +1,8 @@ -package com.novoda.noplayer.drm; +package com.novoda.noplayer.exoplayer.drm; import com.google.android.exoplayer2.drm.DrmSession; import com.google.android.exoplayer2.drm.FrameworkMediaCrypto; +import com.novoda.noplayer.drm.SessionId; import java.util.Map; diff --git a/core/src/main/java/com/novoda/noplayer/drm/LocalDrmSession.java b/core/src/main/java/com/novoda/noplayer/exoplayer/drm/LocalDrmSession.java similarity index 91% rename from core/src/main/java/com/novoda/noplayer/drm/LocalDrmSession.java rename to core/src/main/java/com/novoda/noplayer/exoplayer/drm/LocalDrmSession.java index 1da38d5b..9a527aec 100644 --- a/core/src/main/java/com/novoda/noplayer/drm/LocalDrmSession.java +++ b/core/src/main/java/com/novoda/noplayer/exoplayer/drm/LocalDrmSession.java @@ -1,6 +1,8 @@ -package com.novoda.noplayer.drm; +package com.novoda.noplayer.exoplayer.drm; import com.google.android.exoplayer2.drm.FrameworkMediaCrypto; +import com.novoda.noplayer.drm.KeySetId; +import com.novoda.noplayer.drm.SessionId; import java.util.Collections; import java.util.HashMap; diff --git a/core/src/main/java/com/novoda/noplayer/drm/LocalDrmSessionManager.java b/core/src/main/java/com/novoda/noplayer/exoplayer/drm/LocalDrmSessionManager.java similarity index 95% rename from core/src/main/java/com/novoda/noplayer/drm/LocalDrmSessionManager.java rename to core/src/main/java/com/novoda/noplayer/exoplayer/drm/LocalDrmSessionManager.java index 6a1b6b38..6ca160be 100644 --- a/core/src/main/java/com/novoda/noplayer/drm/LocalDrmSessionManager.java +++ b/core/src/main/java/com/novoda/noplayer/exoplayer/drm/LocalDrmSessionManager.java @@ -1,4 +1,4 @@ -package com.novoda.noplayer.drm; +package com.novoda.noplayer.exoplayer.drm; import android.annotation.TargetApi; import android.media.MediaCryptoException; @@ -14,6 +14,8 @@ import com.google.android.exoplayer2.drm.DrmSessionManager; import com.google.android.exoplayer2.drm.ExoMediaDrm; import com.google.android.exoplayer2.drm.FrameworkMediaCrypto; +import com.novoda.noplayer.drm.KeySetId; +import com.novoda.noplayer.drm.SessionId; import java.util.UUID; diff --git a/core/src/main/java/com/novoda/noplayer/drm/NoDrmSessionCreator.java b/core/src/main/java/com/novoda/noplayer/exoplayer/drm/NoDrmSessionCreator.java similarity index 92% rename from core/src/main/java/com/novoda/noplayer/drm/NoDrmSessionCreator.java rename to core/src/main/java/com/novoda/noplayer/exoplayer/drm/NoDrmSessionCreator.java index 0172c65e..e40c404a 100644 --- a/core/src/main/java/com/novoda/noplayer/drm/NoDrmSessionCreator.java +++ b/core/src/main/java/com/novoda/noplayer/exoplayer/drm/NoDrmSessionCreator.java @@ -1,4 +1,4 @@ -package com.novoda.noplayer.drm; +package com.novoda.noplayer.exoplayer.drm; import android.support.annotation.Nullable; diff --git a/core/src/main/java/com/novoda/noplayer/drm/ProvisioningModularDrmCallback.java b/core/src/main/java/com/novoda/noplayer/exoplayer/drm/ProvisioningModularDrmCallback.java similarity index 84% rename from core/src/main/java/com/novoda/noplayer/drm/ProvisioningModularDrmCallback.java rename to core/src/main/java/com/novoda/noplayer/exoplayer/drm/ProvisioningModularDrmCallback.java index b686eab6..473c544f 100644 --- a/core/src/main/java/com/novoda/noplayer/drm/ProvisioningModularDrmCallback.java +++ b/core/src/main/java/com/novoda/noplayer/exoplayer/drm/ProvisioningModularDrmCallback.java @@ -1,7 +1,10 @@ -package com.novoda.noplayer.drm; +package com.novoda.noplayer.exoplayer.drm; import com.google.android.exoplayer2.drm.ExoMediaDrm; import com.google.android.exoplayer2.drm.MediaDrmCallback; +import com.novoda.noplayer.drm.ModularDrmKeyRequest; +import com.novoda.noplayer.drm.ModularDrmProvisionRequest; +import com.novoda.noplayer.drm.StreamingModularDrm; import com.novoda.noplayer.drm.provision.ProvisionExecutor; import java.util.UUID; diff --git a/core/src/main/java/com/novoda/noplayer/drm/StreamingDrmSessionCreator.java b/core/src/main/java/com/novoda/noplayer/exoplayer/drm/StreamingDrmSessionCreator.java similarity index 97% rename from core/src/main/java/com/novoda/noplayer/drm/StreamingDrmSessionCreator.java rename to core/src/main/java/com/novoda/noplayer/exoplayer/drm/StreamingDrmSessionCreator.java index cbe1bc24..97b28d78 100644 --- a/core/src/main/java/com/novoda/noplayer/drm/StreamingDrmSessionCreator.java +++ b/core/src/main/java/com/novoda/noplayer/exoplayer/drm/StreamingDrmSessionCreator.java @@ -1,4 +1,4 @@ -package com.novoda.noplayer.drm; +package com.novoda.noplayer.exoplayer.drm; import android.os.Handler; diff --git a/core/src/main/java/com/novoda/noplayer/player/PlayerFactory.java b/core/src/main/java/com/novoda/noplayer/player/PlayerFactory.java index 59022ff4..49decd9c 100644 --- a/core/src/main/java/com/novoda/noplayer/player/PlayerFactory.java +++ b/core/src/main/java/com/novoda/noplayer/player/PlayerFactory.java @@ -6,8 +6,8 @@ import com.novoda.noplayer.Player; import com.novoda.noplayer.drm.DrmHandler; -import com.novoda.noplayer.drm.DrmSessionCreator; -import com.novoda.noplayer.drm.DrmSessionCreatorFactory; +import com.novoda.noplayer.exoplayer.drm.DrmSessionCreator; +import com.novoda.noplayer.exoplayer.drm.DrmSessionCreatorFactory; import com.novoda.noplayer.drm.DrmType; import com.novoda.noplayer.exoplayer.NoPlayerExoPlayerCreator; import com.novoda.noplayer.mediaplayer.NoPlayerMediaPlayerCreator; diff --git a/core/src/test/java/com/novoda/noplayer/exoplayer/ExoPlayerFacadeTest.java b/core/src/test/java/com/novoda/noplayer/exoplayer/ExoPlayerFacadeTest.java index 3bbb7e1c..098ff351 100644 --- a/core/src/test/java/com/novoda/noplayer/exoplayer/ExoPlayerFacadeTest.java +++ b/core/src/test/java/com/novoda/noplayer/exoplayer/ExoPlayerFacadeTest.java @@ -10,7 +10,7 @@ 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.exoplayer.drm.DrmSessionCreator; import com.novoda.noplayer.exoplayer.forwarder.ExoPlayerDrmSessionEventListener; import com.novoda.noplayer.exoplayer.forwarder.ExoPlayerForwarder; import com.novoda.noplayer.exoplayer.mediasource.ExoPlayerAudioTrackSelector; diff --git a/core/src/test/java/com/novoda/noplayer/exoplayer/ExoPlayerTwoImplTest.java b/core/src/test/java/com/novoda/noplayer/exoplayer/ExoPlayerTwoImplTest.java index a925d290..9683aced 100644 --- a/core/src/test/java/com/novoda/noplayer/exoplayer/ExoPlayerTwoImplTest.java +++ b/core/src/test/java/com/novoda/noplayer/exoplayer/ExoPlayerTwoImplTest.java @@ -17,7 +17,7 @@ import com.novoda.noplayer.TextCues; import com.novoda.noplayer.Timeout; import com.novoda.noplayer.VideoPosition; -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.ExoPlayerTrackSelector; import com.novoda.noplayer.listeners.BitrateChangedListeners; diff --git a/core/src/test/java/com/novoda/noplayer/exoplayer/NoPlayerExoPlayerCreatorTest.java b/core/src/test/java/com/novoda/noplayer/exoplayer/NoPlayerExoPlayerCreatorTest.java index 6639256f..fdc5f617 100644 --- a/core/src/test/java/com/novoda/noplayer/exoplayer/NoPlayerExoPlayerCreatorTest.java +++ b/core/src/test/java/com/novoda/noplayer/exoplayer/NoPlayerExoPlayerCreatorTest.java @@ -2,7 +2,7 @@ import android.content.Context; -import com.novoda.noplayer.drm.DrmSessionCreator; +import com.novoda.noplayer.exoplayer.drm.DrmSessionCreator; import org.junit.Before; import org.junit.Rule; diff --git a/core/src/test/java/com/novoda/noplayer/drm/DrmSessionCreatorFactoryTest.java b/core/src/test/java/com/novoda/noplayer/exoplayer/drm/DrmSessionCreatorFactoryTest.java similarity index 94% rename from core/src/test/java/com/novoda/noplayer/drm/DrmSessionCreatorFactoryTest.java rename to core/src/test/java/com/novoda/noplayer/exoplayer/drm/DrmSessionCreatorFactoryTest.java index 411db285..ad703538 100644 --- a/core/src/test/java/com/novoda/noplayer/drm/DrmSessionCreatorFactoryTest.java +++ b/core/src/test/java/com/novoda/noplayer/exoplayer/drm/DrmSessionCreatorFactoryTest.java @@ -1,7 +1,11 @@ -package com.novoda.noplayer.drm; +package com.novoda.noplayer.exoplayer.drm; import android.os.Handler; +import com.novoda.noplayer.drm.DownloadedModularDrm; +import com.novoda.noplayer.drm.DrmHandler; +import com.novoda.noplayer.drm.DrmType; +import com.novoda.noplayer.drm.StreamingModularDrm; import com.novoda.noplayer.player.PlayerFactory; import com.novoda.utils.AndroidDeviceVersion; diff --git a/core/src/test/java/com/novoda/noplayer/player/PlayerFactoryTest.java b/core/src/test/java/com/novoda/noplayer/player/PlayerFactoryTest.java index 3bec247c..fa434a1c 100644 --- a/core/src/test/java/com/novoda/noplayer/player/PlayerFactoryTest.java +++ b/core/src/test/java/com/novoda/noplayer/player/PlayerFactoryTest.java @@ -5,8 +5,8 @@ import com.novoda.noplayer.Player; import com.novoda.noplayer.drm.DownloadedModularDrm; import com.novoda.noplayer.drm.DrmHandler; -import com.novoda.noplayer.drm.DrmSessionCreator; -import com.novoda.noplayer.drm.DrmSessionCreatorFactory; +import com.novoda.noplayer.exoplayer.drm.DrmSessionCreator; +import com.novoda.noplayer.exoplayer.drm.DrmSessionCreatorFactory; import com.novoda.noplayer.drm.DrmType; import com.novoda.noplayer.drm.StreamingModularDrm; import com.novoda.noplayer.exoplayer.NoPlayerExoPlayerCreator; From 7a075d79dfcb4319bf4f45d609b74372bbb15278 Mon Sep 17 00:00:00 2001 From: Ryan Feline Date: Mon, 26 Jun 2017 14:59:04 +0100 Subject: [PATCH 02/11] Rescope and move classes in exo-player.forwarders where necessary. --- .../novoda/noplayer/exoplayer/ExoPlayerCreator.java | 8 +++++--- .../{forwarder => }/ExoPlayerErrorFactory.java | 6 +++--- .../forwarder/ExoPlayerDrmSessionEventListener.java | 4 ++-- .../exoplayer/forwarder/ExoPlayerForwarder.java | 12 ++++++++---- .../exoplayer/forwarder/PlayerOnErrorForwarder.java | 1 + .../noplayer/exoplayer/ExoPlayerFacadeTest.java | 4 ++-- 6 files changed, 21 insertions(+), 14 deletions(-) rename core/src/main/java/com/novoda/noplayer/exoplayer/{forwarder => }/ExoPlayerErrorFactory.java (91%) diff --git a/core/src/main/java/com/novoda/noplayer/exoplayer/ExoPlayerCreator.java b/core/src/main/java/com/novoda/noplayer/exoplayer/ExoPlayerCreator.java index 2a3d810b..6e7a681a 100644 --- a/core/src/main/java/com/novoda/noplayer/exoplayer/ExoPlayerCreator.java +++ b/core/src/main/java/com/novoda/noplayer/exoplayer/ExoPlayerCreator.java @@ -7,11 +7,11 @@ 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.exoplayer.drm.DrmSessionCreator; -import com.novoda.noplayer.exoplayer.forwarder.ExoPlayerDrmSessionEventListener; import static com.novoda.noplayer.exoplayer.SimpleRenderersFactory.EXTENSION_RENDERER_MODE_OFF; @@ -28,8 +28,10 @@ class ExoPlayerCreator { } @NonNull - public SimpleExoPlayer create(DrmSessionCreator drmSessionCreator, ExoPlayerDrmSessionEventListener exoPlayerDrmSessionEventListener, boolean useSecureCodec) { - DrmSessionManager drmSessionManager = drmSessionCreator.create(exoPlayerDrmSessionEventListener); + public SimpleExoPlayer create(DrmSessionCreator drmSessionCreator, + DefaultDrmSessionManager.EventListener drmSessionEventListener, + boolean useSecureCodec) { + DrmSessionManager drmSessionManager = drmSessionCreator.create(drmSessionEventListener); RenderersFactory renderersFactory = new SimpleRenderersFactory( context, drmSessionManager, diff --git a/core/src/main/java/com/novoda/noplayer/exoplayer/forwarder/ExoPlayerErrorFactory.java b/core/src/main/java/com/novoda/noplayer/exoplayer/ExoPlayerErrorFactory.java similarity index 91% rename from core/src/main/java/com/novoda/noplayer/exoplayer/forwarder/ExoPlayerErrorFactory.java rename to core/src/main/java/com/novoda/noplayer/exoplayer/ExoPlayerErrorFactory.java index 58e70a9f..1bc0ec03 100644 --- a/core/src/main/java/com/novoda/noplayer/exoplayer/forwarder/ExoPlayerErrorFactory.java +++ b/core/src/main/java/com/novoda/noplayer/exoplayer/ExoPlayerErrorFactory.java @@ -1,4 +1,4 @@ -package com.novoda.noplayer.exoplayer.forwarder; +package com.novoda.noplayer.exoplayer; import android.media.MediaCodec; @@ -15,13 +15,13 @@ import java.io.IOException; -final class ExoPlayerErrorFactory { +public final class ExoPlayerErrorFactory { private ExoPlayerErrorFactory() { // uninstantiable } - static Player.PlayerError errorFor(Exception e) { + public static Player.PlayerError errorFor(Exception e) { if (e instanceof HttpDataSource.InvalidResponseCodeException) { return new InvalidResponseCodeError(e); } diff --git a/core/src/main/java/com/novoda/noplayer/exoplayer/forwarder/ExoPlayerDrmSessionEventListener.java b/core/src/main/java/com/novoda/noplayer/exoplayer/forwarder/ExoPlayerDrmSessionEventListener.java index 70c91aeb..db4b8f5b 100644 --- a/core/src/main/java/com/novoda/noplayer/exoplayer/forwarder/ExoPlayerDrmSessionEventListener.java +++ b/core/src/main/java/com/novoda/noplayer/exoplayer/forwarder/ExoPlayerDrmSessionEventListener.java @@ -5,11 +5,11 @@ import java.util.List; import java.util.concurrent.CopyOnWriteArrayList; -public class ExoPlayerDrmSessionEventListener implements DefaultDrmSessionManager.EventListener { +class ExoPlayerDrmSessionEventListener implements DefaultDrmSessionManager.EventListener { private final List listeners = new CopyOnWriteArrayList<>(); - public void add(DefaultDrmSessionManager.EventListener listener) { + void add(DefaultDrmSessionManager.EventListener listener) { listeners.add(listener); } diff --git a/core/src/main/java/com/novoda/noplayer/exoplayer/forwarder/ExoPlayerForwarder.java b/core/src/main/java/com/novoda/noplayer/exoplayer/forwarder/ExoPlayerForwarder.java index 51c31232..28aaafdd 100644 --- a/core/src/main/java/com/novoda/noplayer/exoplayer/forwarder/ExoPlayerForwarder.java +++ b/core/src/main/java/com/novoda/noplayer/exoplayer/forwarder/ExoPlayerForwarder.java @@ -1,5 +1,9 @@ package com.novoda.noplayer.exoplayer.forwarder; +import com.google.android.exoplayer2.drm.DefaultDrmSessionManager; +import com.google.android.exoplayer2.source.AdaptiveMediaSourceEventListener; +import com.google.android.exoplayer2.source.ExtractorMediaSource; +import com.google.android.exoplayer2.video.VideoRendererEventListener; import com.novoda.noplayer.Player; import com.novoda.noplayer.PlayerState; import com.novoda.noplayer.listeners.BitrateChangedListeners; @@ -31,19 +35,19 @@ public EventListener exoPlayerEventListener() { return exoPlayerEventListener; } - public MediaSourceEventListener mediaSourceEventListener() { + public AdaptiveMediaSourceEventListener mediaSourceEventListener() { return mediaSourceEventListener; } - public ExoPlayerVideoRendererEventListener videoRendererEventListener() { + public VideoRendererEventListener videoRendererEventListener() { return videoRendererEventListener; } - public ExoPlayerExtractorMediaSourceListener extractorMediaSourceListener() { + public ExtractorMediaSource.EventListener extractorMediaSourceListener() { return extractorMediaSourceListener; } - public ExoPlayerDrmSessionEventListener drmSessionEventListener() { + public DefaultDrmSessionManager.EventListener drmSessionEventListener() { return drmSessionEventListener; } diff --git a/core/src/main/java/com/novoda/noplayer/exoplayer/forwarder/PlayerOnErrorForwarder.java b/core/src/main/java/com/novoda/noplayer/exoplayer/forwarder/PlayerOnErrorForwarder.java index 22aabb9c..94d4f2b3 100644 --- a/core/src/main/java/com/novoda/noplayer/exoplayer/forwarder/PlayerOnErrorForwarder.java +++ b/core/src/main/java/com/novoda/noplayer/exoplayer/forwarder/PlayerOnErrorForwarder.java @@ -7,6 +7,7 @@ import com.google.android.exoplayer2.source.TrackGroupArray; import com.google.android.exoplayer2.trackselection.TrackSelectionArray; import com.novoda.noplayer.Player; +import com.novoda.noplayer.exoplayer.ExoPlayerErrorFactory; import com.novoda.noplayer.listeners.ErrorListeners; class PlayerOnErrorForwarder implements ExoPlayer.EventListener { diff --git a/core/src/test/java/com/novoda/noplayer/exoplayer/ExoPlayerFacadeTest.java b/core/src/test/java/com/novoda/noplayer/exoplayer/ExoPlayerFacadeTest.java index 098ff351..70e24be5 100644 --- a/core/src/test/java/com/novoda/noplayer/exoplayer/ExoPlayerFacadeTest.java +++ b/core/src/test/java/com/novoda/noplayer/exoplayer/ExoPlayerFacadeTest.java @@ -4,6 +4,7 @@ import android.view.SurfaceHolder; import com.google.android.exoplayer2.SimpleExoPlayer; +import com.google.android.exoplayer2.drm.DefaultDrmSessionManager; import com.google.android.exoplayer2.source.MediaSource; import com.novoda.noplayer.ContentType; import com.novoda.noplayer.PlayerAudioTrack; @@ -11,7 +12,6 @@ import com.novoda.noplayer.VideoDuration; import com.novoda.noplayer.VideoPosition; import com.novoda.noplayer.exoplayer.drm.DrmSessionCreator; -import com.novoda.noplayer.exoplayer.forwarder.ExoPlayerDrmSessionEventListener; import com.novoda.noplayer.exoplayer.forwarder.ExoPlayerForwarder; import com.novoda.noplayer.exoplayer.mediasource.ExoPlayerAudioTrackSelector; import com.novoda.noplayer.exoplayer.mediasource.ExoPlayerSubtitleTrackSelector; @@ -391,7 +391,7 @@ public abstract static class Base { @Mock DrmSessionCreator drmSessionCreator; @Mock - ExoPlayerDrmSessionEventListener drmSessionEventListener; + DefaultDrmSessionManager.EventListener drmSessionEventListener; ExoPlayerFacade facade; From 7dd769be197b9438eb1621e5e9f85540087d759c Mon Sep 17 00:00:00 2001 From: Ryan Feline Date: Mon, 26 Jun 2017 15:08:50 +0100 Subject: [PATCH 03/11] Rescope and move classes in no-player where necessary. --- .../AspectRatioChangeCalculator.java | 11 ++++----- .../com/novoda/noplayer/NoPlayerView.java | 3 +-- .../noplayer/exoplayer/ExoPlayerTwoImpl.java | 4 ++-- .../exoplayer/SimpleRenderersFactory.java | 2 +- .../forwarder/PlayerOnErrorForwarder.java | 2 +- .../mediasource/ExoPlayerTrackSelector.java | 6 ++--- .../ExoPlayerErrorFactory.java | 8 +------ .../playererror/PlayerCrashError.java | 24 ------------------- 8 files changed, 14 insertions(+), 46 deletions(-) rename core/src/main/java/com/novoda/noplayer/{exoplayer => }/AspectRatioChangeCalculator.java (64%) rename core/src/main/java/com/novoda/noplayer/exoplayer/{ => playererror}/ExoPlayerErrorFactory.java (71%) delete mode 100644 core/src/main/java/com/novoda/noplayer/exoplayer/playererror/PlayerCrashError.java diff --git a/core/src/main/java/com/novoda/noplayer/exoplayer/AspectRatioChangeCalculator.java b/core/src/main/java/com/novoda/noplayer/AspectRatioChangeCalculator.java similarity index 64% rename from core/src/main/java/com/novoda/noplayer/exoplayer/AspectRatioChangeCalculator.java rename to core/src/main/java/com/novoda/noplayer/AspectRatioChangeCalculator.java index 3f82a4c9..b4775948 100644 --- a/core/src/main/java/com/novoda/noplayer/exoplayer/AspectRatioChangeCalculator.java +++ b/core/src/main/java/com/novoda/noplayer/AspectRatioChangeCalculator.java @@ -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); } @@ -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); - } } diff --git a/core/src/main/java/com/novoda/noplayer/NoPlayerView.java b/core/src/main/java/com/novoda/noplayer/NoPlayerView.java index a69c2ab6..e15eb260 100644 --- a/core/src/main/java/com/novoda/noplayer/NoPlayerView.java +++ b/core/src/main/java/com/novoda/noplayer/NoPlayerView.java @@ -8,7 +8,6 @@ import com.google.android.exoplayer2.ui.AspectRatioFrameLayout; import com.google.android.exoplayer2.ui.SubtitleView; -import com.novoda.noplayer.exoplayer.AspectRatioChangeCalculator; public class NoPlayerView extends FrameLayout implements AspectRatioChangeCalculator.Listener, PlayerView { @@ -84,7 +83,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); } }; diff --git a/core/src/main/java/com/novoda/noplayer/exoplayer/ExoPlayerTwoImpl.java b/core/src/main/java/com/novoda/noplayer/exoplayer/ExoPlayerTwoImpl.java index fda5e741..9554c13d 100644 --- a/core/src/main/java/com/novoda/noplayer/exoplayer/ExoPlayerTwoImpl.java +++ b/core/src/main/java/com/novoda/noplayer/exoplayer/ExoPlayerTwoImpl.java @@ -23,7 +23,7 @@ import java.util.List; -public class ExoPlayerTwoImpl implements Player { +class ExoPlayerTwoImpl implements Player { private final ExoPlayerFacade exoPlayer; private final PlayerListenersHolder listenersHolder; @@ -57,7 +57,7 @@ public class ExoPlayerTwoImpl implements Player { this.useSecureCodec = useSecureCodec; } - public void initialise() { + void initialise() { heart.bind(new Heart.Heartbeat<>(listenersHolder.getHeartbeatCallbacks(), this)); forwarder.bind(listenersHolder.getPreparedListeners(), this); forwarder.bind(listenersHolder.getCompletionListeners(), listenersHolder.getStateChangedListeners()); diff --git a/core/src/main/java/com/novoda/noplayer/exoplayer/SimpleRenderersFactory.java b/core/src/main/java/com/novoda/noplayer/exoplayer/SimpleRenderersFactory.java index 694e2479..46831a9c 100644 --- a/core/src/main/java/com/novoda/noplayer/exoplayer/SimpleRenderersFactory.java +++ b/core/src/main/java/com/novoda/noplayer/exoplayer/SimpleRenderersFactory.java @@ -44,7 +44,7 @@ /** * Default {@link RenderersFactory} implementation. */ -public class SimpleRenderersFactory implements RenderersFactory { +class SimpleRenderersFactory implements RenderersFactory { /** * Modes for using extension renderers. diff --git a/core/src/main/java/com/novoda/noplayer/exoplayer/forwarder/PlayerOnErrorForwarder.java b/core/src/main/java/com/novoda/noplayer/exoplayer/forwarder/PlayerOnErrorForwarder.java index 94d4f2b3..d9ab88f5 100644 --- a/core/src/main/java/com/novoda/noplayer/exoplayer/forwarder/PlayerOnErrorForwarder.java +++ b/core/src/main/java/com/novoda/noplayer/exoplayer/forwarder/PlayerOnErrorForwarder.java @@ -7,7 +7,7 @@ import com.google.android.exoplayer2.source.TrackGroupArray; import com.google.android.exoplayer2.trackselection.TrackSelectionArray; import com.novoda.noplayer.Player; -import com.novoda.noplayer.exoplayer.ExoPlayerErrorFactory; +import com.novoda.noplayer.exoplayer.playererror.ExoPlayerErrorFactory; import com.novoda.noplayer.listeners.ErrorListeners; class PlayerOnErrorForwarder implements ExoPlayer.EventListener { diff --git a/core/src/main/java/com/novoda/noplayer/exoplayer/mediasource/ExoPlayerTrackSelector.java b/core/src/main/java/com/novoda/noplayer/exoplayer/mediasource/ExoPlayerTrackSelector.java index b0b23c29..5aba6d56 100644 --- a/core/src/main/java/com/novoda/noplayer/exoplayer/mediasource/ExoPlayerTrackSelector.java +++ b/core/src/main/java/com/novoda/noplayer/exoplayer/mediasource/ExoPlayerTrackSelector.java @@ -17,7 +17,7 @@ public static ExoPlayerTrackSelector newInstance(DefaultTrackSelector trackSelec return new ExoPlayerTrackSelector(trackSelector, rendererTrackIndexExtractor); } - ExoPlayerTrackSelector(DefaultTrackSelector trackSelector, RendererTrackIndexExtractor rendererTrackIndexExtractor) { + private ExoPlayerTrackSelector(DefaultTrackSelector trackSelector, RendererTrackIndexExtractor rendererTrackIndexExtractor) { this.trackSelector = trackSelector; this.rendererTrackIndexExtractor = rendererTrackIndexExtractor; } @@ -27,14 +27,14 @@ TrackGroupArray trackGroups(TrackType trackType, RendererTypeRequester rendererT return audioRendererIndex.isAbsent() ? TrackGroupArray.EMPTY : trackInfo().getTrackGroups(audioRendererIndex.get()); } - public void clearSelectionOverrideFor(TrackType trackType, RendererTypeRequester rendererTypeRequester) { + void clearSelectionOverrideFor(TrackType trackType, RendererTypeRequester rendererTypeRequester) { Optional audioRendererIndex = rendererTrackIndexExtractor.extract(trackType, mappedTrackInfoLength(), rendererTypeRequester); if (audioRendererIndex.isPresent()) { trackSelector.clearSelectionOverrides(audioRendererIndex.get()); } } - public ExoPlayerMappedTrackInfo trackInfo() { + private ExoPlayerMappedTrackInfo trackInfo() { MappingTrackSelector.MappedTrackInfo trackInfo = trackSelector.getCurrentMappedTrackInfo(); if (trackInfo == null) { diff --git a/core/src/main/java/com/novoda/noplayer/exoplayer/ExoPlayerErrorFactory.java b/core/src/main/java/com/novoda/noplayer/exoplayer/playererror/ExoPlayerErrorFactory.java similarity index 71% rename from core/src/main/java/com/novoda/noplayer/exoplayer/ExoPlayerErrorFactory.java rename to core/src/main/java/com/novoda/noplayer/exoplayer/playererror/ExoPlayerErrorFactory.java index 1bc0ec03..c1d3d092 100644 --- a/core/src/main/java/com/novoda/noplayer/exoplayer/ExoPlayerErrorFactory.java +++ b/core/src/main/java/com/novoda/noplayer/exoplayer/playererror/ExoPlayerErrorFactory.java @@ -1,4 +1,4 @@ -package com.novoda.noplayer.exoplayer; +package com.novoda.noplayer.exoplayer.playererror; import android.media.MediaCodec; @@ -6,12 +6,6 @@ import com.google.android.exoplayer2.upstream.HttpDataSource; import com.novoda.noplayer.Player; import com.novoda.noplayer.drm.DrmRequestException; -import com.novoda.noplayer.exoplayer.playererror.ConnectivityError; -import com.novoda.noplayer.exoplayer.playererror.DrmDecryptionError; -import com.novoda.noplayer.exoplayer.playererror.DrmRequestError; -import com.novoda.noplayer.exoplayer.playererror.InvalidResponseCodeError; -import com.novoda.noplayer.exoplayer.playererror.MalformedContentError; -import com.novoda.noplayer.exoplayer.playererror.UnknownError; import java.io.IOException; diff --git a/core/src/main/java/com/novoda/noplayer/exoplayer/playererror/PlayerCrashError.java b/core/src/main/java/com/novoda/noplayer/exoplayer/playererror/PlayerCrashError.java deleted file mode 100644 index 54b7ffaa..00000000 --- a/core/src/main/java/com/novoda/noplayer/exoplayer/playererror/PlayerCrashError.java +++ /dev/null @@ -1,24 +0,0 @@ -package com.novoda.noplayer.exoplayer.playererror; - -import com.novoda.noplayer.Player; - -public class PlayerCrashError implements Player.PlayerError { - - private final String errorCode; - private final Throwable cause; - - public PlayerCrashError(String errorCode, Throwable cause) { - this.errorCode = errorCode; - this.cause = cause; - } - - @Override - public String getType() { - return errorCode; - } - - @Override - public Throwable getCause() { - return cause; - } -} From 771e011ae03d4e6c2ca7f9138d2796c1c6f2b03c Mon Sep 17 00:00:00 2001 From: Ryan Feline Date: Mon, 26 Jun 2017 15:10:53 +0100 Subject: [PATCH 04/11] Rescope and move classes in mediaPlayer.forwarders where necessary. --- .../mediaplayer/forwarder/BufferHeartbeatListener.java | 3 ++- .../noplayer/mediaplayer/forwarder/BufferInfoForwarder.java | 3 +-- .../mediaplayer/forwarder/BufferOnPreparedListener.java | 3 ++- .../noplayer/mediaplayer/forwarder/CompletionForwarder.java | 3 ++- .../mediaplayer/forwarder/CompletionInfoForwarder.java | 2 +- .../novoda/noplayer/mediaplayer/forwarder/ErrorForwarder.java | 2 +- .../noplayer/mediaplayer/forwarder/ErrorInfoForwarder.java | 2 +- .../noplayer/mediaplayer/forwarder/HeartBeatListener.java | 4 ++-- .../mediaplayer/forwarder/MediaPlayerCompletionListener.java | 4 ++-- .../mediaplayer/forwarder/MediaPlayerErrorListener.java | 4 ++-- .../mediaplayer/forwarder/MediaPlayerPreparedListener.java | 4 ++-- .../noplayer/mediaplayer/forwarder/OnPreparedForwarder.java | 3 ++- .../mediaplayer/forwarder/OnPreparedInfoForwarder.java | 2 +- .../mediaplayer/forwarder/VideoSizeChangedInfoForwarder.java | 2 +- 14 files changed, 22 insertions(+), 19 deletions(-) diff --git a/core/src/main/java/com/novoda/noplayer/mediaplayer/forwarder/BufferHeartbeatListener.java b/core/src/main/java/com/novoda/noplayer/mediaplayer/forwarder/BufferHeartbeatListener.java index 93be1ef0..3f2a73d9 100644 --- a/core/src/main/java/com/novoda/noplayer/mediaplayer/forwarder/BufferHeartbeatListener.java +++ b/core/src/main/java/com/novoda/noplayer/mediaplayer/forwarder/BufferHeartbeatListener.java @@ -4,9 +4,10 @@ import com.novoda.noplayer.mediaplayer.CheckBufferHeartbeatCallback; class BufferHeartbeatListener implements CheckBufferHeartbeatCallback.BufferListener { + private final BufferStateListeners bufferStateListeners; - public BufferHeartbeatListener(BufferStateListeners bufferStateListeners) { + BufferHeartbeatListener(BufferStateListeners bufferStateListeners) { this.bufferStateListeners = bufferStateListeners; } diff --git a/core/src/main/java/com/novoda/noplayer/mediaplayer/forwarder/BufferInfoForwarder.java b/core/src/main/java/com/novoda/noplayer/mediaplayer/forwarder/BufferInfoForwarder.java index 159b2987..9b1b0981 100644 --- a/core/src/main/java/com/novoda/noplayer/mediaplayer/forwarder/BufferInfoForwarder.java +++ b/core/src/main/java/com/novoda/noplayer/mediaplayer/forwarder/BufferInfoForwarder.java @@ -9,7 +9,7 @@ class BufferInfoForwarder implements CheckBufferHeartbeatCallback.BufferListener private final InfoListeners infoListeners; - public BufferInfoForwarder(InfoListeners infoListeners) { + BufferInfoForwarder(InfoListeners infoListeners) { this.infoListeners = infoListeners; } @@ -18,7 +18,6 @@ public void onBufferStart() { HashMap callingMethodParameters = new HashMap<>(); infoListeners.onNewInfo("onBufferStart", callingMethodParameters); - } @Override diff --git a/core/src/main/java/com/novoda/noplayer/mediaplayer/forwarder/BufferOnPreparedListener.java b/core/src/main/java/com/novoda/noplayer/mediaplayer/forwarder/BufferOnPreparedListener.java index 6d60f607..8cc26459 100644 --- a/core/src/main/java/com/novoda/noplayer/mediaplayer/forwarder/BufferOnPreparedListener.java +++ b/core/src/main/java/com/novoda/noplayer/mediaplayer/forwarder/BufferOnPreparedListener.java @@ -5,9 +5,10 @@ import com.novoda.noplayer.listeners.BufferStateListeners; class BufferOnPreparedListener implements MediaPlayer.OnPreparedListener { + private final BufferStateListeners bufferStateListeners; - public BufferOnPreparedListener(BufferStateListeners bufferStateListeners) { + BufferOnPreparedListener(BufferStateListeners bufferStateListeners) { this.bufferStateListeners = bufferStateListeners; } diff --git a/core/src/main/java/com/novoda/noplayer/mediaplayer/forwarder/CompletionForwarder.java b/core/src/main/java/com/novoda/noplayer/mediaplayer/forwarder/CompletionForwarder.java index 85eed8b0..25499107 100644 --- a/core/src/main/java/com/novoda/noplayer/mediaplayer/forwarder/CompletionForwarder.java +++ b/core/src/main/java/com/novoda/noplayer/mediaplayer/forwarder/CompletionForwarder.java @@ -5,9 +5,10 @@ import com.novoda.noplayer.listeners.CompletionListeners; class CompletionForwarder implements MediaPlayer.OnCompletionListener { + private final CompletionListeners completionListeners; - public CompletionForwarder(CompletionListeners completionListeners) { + CompletionForwarder(CompletionListeners completionListeners) { this.completionListeners = completionListeners; } diff --git a/core/src/main/java/com/novoda/noplayer/mediaplayer/forwarder/CompletionInfoForwarder.java b/core/src/main/java/com/novoda/noplayer/mediaplayer/forwarder/CompletionInfoForwarder.java index a6950202..2ef660a2 100644 --- a/core/src/main/java/com/novoda/noplayer/mediaplayer/forwarder/CompletionInfoForwarder.java +++ b/core/src/main/java/com/novoda/noplayer/mediaplayer/forwarder/CompletionInfoForwarder.java @@ -10,7 +10,7 @@ class CompletionInfoForwarder implements MediaPlayer.OnCompletionListener { private final InfoListeners infoListeners; - public CompletionInfoForwarder(InfoListeners infoListeners) { + CompletionInfoForwarder(InfoListeners infoListeners) { this.infoListeners = infoListeners; } diff --git a/core/src/main/java/com/novoda/noplayer/mediaplayer/forwarder/ErrorForwarder.java b/core/src/main/java/com/novoda/noplayer/mediaplayer/forwarder/ErrorForwarder.java index ccedb49c..1862c45a 100644 --- a/core/src/main/java/com/novoda/noplayer/mediaplayer/forwarder/ErrorForwarder.java +++ b/core/src/main/java/com/novoda/noplayer/mediaplayer/forwarder/ErrorForwarder.java @@ -13,7 +13,7 @@ class ErrorForwarder implements MediaPlayer.OnErrorListener { private final ErrorListeners errorListeners; private final Player player; - public ErrorForwarder(BufferStateListeners bufferStateListeners, ErrorListeners errorListeners, Player player) { + ErrorForwarder(BufferStateListeners bufferStateListeners, ErrorListeners errorListeners, Player player) { this.bufferStateListeners = bufferStateListeners; this.errorListeners = errorListeners; this.player = player; diff --git a/core/src/main/java/com/novoda/noplayer/mediaplayer/forwarder/ErrorInfoForwarder.java b/core/src/main/java/com/novoda/noplayer/mediaplayer/forwarder/ErrorInfoForwarder.java index 35e8feef..97ca2acd 100644 --- a/core/src/main/java/com/novoda/noplayer/mediaplayer/forwarder/ErrorInfoForwarder.java +++ b/core/src/main/java/com/novoda/noplayer/mediaplayer/forwarder/ErrorInfoForwarder.java @@ -10,7 +10,7 @@ class ErrorInfoForwarder implements MediaPlayer.OnErrorListener { private final InfoListeners infoListeners; - public ErrorInfoForwarder(InfoListeners infoListeners) { + ErrorInfoForwarder(InfoListeners infoListeners) { this.infoListeners = infoListeners; } diff --git a/core/src/main/java/com/novoda/noplayer/mediaplayer/forwarder/HeartBeatListener.java b/core/src/main/java/com/novoda/noplayer/mediaplayer/forwarder/HeartBeatListener.java index dd2fceab..724f4b82 100644 --- a/core/src/main/java/com/novoda/noplayer/mediaplayer/forwarder/HeartBeatListener.java +++ b/core/src/main/java/com/novoda/noplayer/mediaplayer/forwarder/HeartBeatListener.java @@ -5,11 +5,11 @@ import java.util.List; import java.util.concurrent.CopyOnWriteArrayList; -public class HeartBeatListener implements CheckBufferHeartbeatCallback.BufferListener { +class HeartBeatListener implements CheckBufferHeartbeatCallback.BufferListener { private final List listeners = new CopyOnWriteArrayList<>(); - public void add(CheckBufferHeartbeatCallback.BufferListener listener) { + void add(CheckBufferHeartbeatCallback.BufferListener listener) { listeners.add(listener); } diff --git a/core/src/main/java/com/novoda/noplayer/mediaplayer/forwarder/MediaPlayerCompletionListener.java b/core/src/main/java/com/novoda/noplayer/mediaplayer/forwarder/MediaPlayerCompletionListener.java index 4b9f5e7b..0318fadb 100644 --- a/core/src/main/java/com/novoda/noplayer/mediaplayer/forwarder/MediaPlayerCompletionListener.java +++ b/core/src/main/java/com/novoda/noplayer/mediaplayer/forwarder/MediaPlayerCompletionListener.java @@ -5,11 +5,11 @@ import java.util.List; import java.util.concurrent.CopyOnWriteArrayList; -public class MediaPlayerCompletionListener implements MediaPlayer.OnCompletionListener { +class MediaPlayerCompletionListener implements MediaPlayer.OnCompletionListener { private final List listeners = new CopyOnWriteArrayList<>(); - public void add(MediaPlayer.OnCompletionListener listener) { + void add(MediaPlayer.OnCompletionListener listener) { listeners.add(listener); } diff --git a/core/src/main/java/com/novoda/noplayer/mediaplayer/forwarder/MediaPlayerErrorListener.java b/core/src/main/java/com/novoda/noplayer/mediaplayer/forwarder/MediaPlayerErrorListener.java index f4a1f3f1..4855398c 100644 --- a/core/src/main/java/com/novoda/noplayer/mediaplayer/forwarder/MediaPlayerErrorListener.java +++ b/core/src/main/java/com/novoda/noplayer/mediaplayer/forwarder/MediaPlayerErrorListener.java @@ -5,11 +5,11 @@ import java.util.List; import java.util.concurrent.CopyOnWriteArrayList; -public class MediaPlayerErrorListener implements MediaPlayer.OnErrorListener { +class MediaPlayerErrorListener implements MediaPlayer.OnErrorListener { private final List listeners = new CopyOnWriteArrayList<>(); - public void add(MediaPlayer.OnErrorListener listener) { + void add(MediaPlayer.OnErrorListener listener) { listeners.add(listener); } diff --git a/core/src/main/java/com/novoda/noplayer/mediaplayer/forwarder/MediaPlayerPreparedListener.java b/core/src/main/java/com/novoda/noplayer/mediaplayer/forwarder/MediaPlayerPreparedListener.java index 47276596..b29cbcd0 100644 --- a/core/src/main/java/com/novoda/noplayer/mediaplayer/forwarder/MediaPlayerPreparedListener.java +++ b/core/src/main/java/com/novoda/noplayer/mediaplayer/forwarder/MediaPlayerPreparedListener.java @@ -5,11 +5,11 @@ import java.util.List; import java.util.concurrent.CopyOnWriteArrayList; -public class MediaPlayerPreparedListener implements MediaPlayer.OnPreparedListener { +class MediaPlayerPreparedListener implements MediaPlayer.OnPreparedListener { private final List listeners = new CopyOnWriteArrayList<>(); - public void add(MediaPlayer.OnPreparedListener listener) { + void add(MediaPlayer.OnPreparedListener listener) { listeners.add(listener); } diff --git a/core/src/main/java/com/novoda/noplayer/mediaplayer/forwarder/OnPreparedForwarder.java b/core/src/main/java/com/novoda/noplayer/mediaplayer/forwarder/OnPreparedForwarder.java index 7fbfe539..11d95465 100644 --- a/core/src/main/java/com/novoda/noplayer/mediaplayer/forwarder/OnPreparedForwarder.java +++ b/core/src/main/java/com/novoda/noplayer/mediaplayer/forwarder/OnPreparedForwarder.java @@ -6,10 +6,11 @@ import com.novoda.noplayer.listeners.PreparedListeners; class OnPreparedForwarder implements MediaPlayer.OnPreparedListener { + private final PreparedListeners preparedListeners; private final PlayerState playerState; - public OnPreparedForwarder(PreparedListeners preparedListeners, PlayerState playerState) { + OnPreparedForwarder(PreparedListeners preparedListeners, PlayerState playerState) { this.preparedListeners = preparedListeners; this.playerState = playerState; } diff --git a/core/src/main/java/com/novoda/noplayer/mediaplayer/forwarder/OnPreparedInfoForwarder.java b/core/src/main/java/com/novoda/noplayer/mediaplayer/forwarder/OnPreparedInfoForwarder.java index 98b81d96..0f920e56 100644 --- a/core/src/main/java/com/novoda/noplayer/mediaplayer/forwarder/OnPreparedInfoForwarder.java +++ b/core/src/main/java/com/novoda/noplayer/mediaplayer/forwarder/OnPreparedInfoForwarder.java @@ -10,7 +10,7 @@ class OnPreparedInfoForwarder implements MediaPlayer.OnPreparedListener { private final InfoListeners infoListeners; - public OnPreparedInfoForwarder(InfoListeners infoListeners) { + OnPreparedInfoForwarder(InfoListeners infoListeners) { this.infoListeners = infoListeners; } diff --git a/core/src/main/java/com/novoda/noplayer/mediaplayer/forwarder/VideoSizeChangedInfoForwarder.java b/core/src/main/java/com/novoda/noplayer/mediaplayer/forwarder/VideoSizeChangedInfoForwarder.java index 03c1a513..77f39c1f 100644 --- a/core/src/main/java/com/novoda/noplayer/mediaplayer/forwarder/VideoSizeChangedInfoForwarder.java +++ b/core/src/main/java/com/novoda/noplayer/mediaplayer/forwarder/VideoSizeChangedInfoForwarder.java @@ -10,7 +10,7 @@ class VideoSizeChangedInfoForwarder implements MediaPlayer.OnVideoSizeChangedLis private final InfoListeners infoListeners; - public VideoSizeChangedInfoForwarder(InfoListeners infoListeners) { + VideoSizeChangedInfoForwarder(InfoListeners infoListeners) { this.infoListeners = infoListeners; } From e4840b030331cd6f74961fa5cc436c85a5174fa4 Mon Sep 17 00:00:00 2001 From: Ryan Feline Date: Mon, 26 Jun 2017 15:17:12 +0100 Subject: [PATCH 05/11] Rescope and move classes in mediaPlayer where necessary. --- .../mediaplayer/AndroidMediaPlayerFacade.java | 2 +- .../mediaplayer/AndroidMediaPlayerImpl.java | 4 ++-- .../mediaplayer/AndroidMediaPlayerType.java | 5 ++++- .../mediaplayer/BuggyVideoDriverPreventer.java | 4 ++-- .../novoda/noplayer/mediaplayer/ErrorFactory.java | 13 ++++--------- .../noplayer/mediaplayer/MediaPlayerCreator.java | 1 + .../novoda/noplayer/mediaplayer/PlayerChecker.java | 1 - 7 files changed, 14 insertions(+), 16 deletions(-) diff --git a/core/src/main/java/com/novoda/noplayer/mediaplayer/AndroidMediaPlayerFacade.java b/core/src/main/java/com/novoda/noplayer/mediaplayer/AndroidMediaPlayerFacade.java index 885401f8..7ce00a6e 100644 --- a/core/src/main/java/com/novoda/noplayer/mediaplayer/AndroidMediaPlayerFacade.java +++ b/core/src/main/java/com/novoda/noplayer/mediaplayer/AndroidMediaPlayerFacade.java @@ -227,7 +227,7 @@ private void assertIsInPlaybackState() { } } - public boolean hasPlayedContent() { + boolean hasPlayedContent() { return hasPlayer(); } diff --git a/core/src/main/java/com/novoda/noplayer/mediaplayer/AndroidMediaPlayerImpl.java b/core/src/main/java/com/novoda/noplayer/mediaplayer/AndroidMediaPlayerImpl.java index 171caf7f..b53a8c63 100644 --- a/core/src/main/java/com/novoda/noplayer/mediaplayer/AndroidMediaPlayerImpl.java +++ b/core/src/main/java/com/novoda/noplayer/mediaplayer/AndroidMediaPlayerImpl.java @@ -25,7 +25,7 @@ import java.util.Collections; import java.util.List; -public class AndroidMediaPlayerImpl implements Player { +class AndroidMediaPlayerImpl implements Player { private static final VideoPosition NO_SEEK_TO_POSITION = VideoPosition.INVALID; private static final MediaPlayerInformation MEDIA_PLAYER_INFORMATION = new MediaPlayerInformation(); @@ -65,7 +65,7 @@ public class AndroidMediaPlayerImpl implements Player { this.buggyVideoDriverPreventer = buggyVideoDriverPreventer; } - public void initialise() { + void initialise() { forwarder.bind(listenersHolder.getPreparedListeners(), this); forwarder.bind(listenersHolder.getBufferStateListeners(), listenersHolder.getErrorListeners(), this); forwarder.bind(listenersHolder.getCompletionListeners(), listenersHolder.getStateChangedListeners()); diff --git a/core/src/main/java/com/novoda/noplayer/mediaplayer/AndroidMediaPlayerType.java b/core/src/main/java/com/novoda/noplayer/mediaplayer/AndroidMediaPlayerType.java index 52ab1c0c..328be9c2 100644 --- a/core/src/main/java/com/novoda/noplayer/mediaplayer/AndroidMediaPlayerType.java +++ b/core/src/main/java/com/novoda/noplayer/mediaplayer/AndroidMediaPlayerType.java @@ -1,7 +1,10 @@ package com.novoda.noplayer.mediaplayer; public enum AndroidMediaPlayerType { - AWESOME("AwesomePlayer"), NU("NuPlayer"), UNKNOWN("Unknown"); + + AWESOME("AwesomePlayer"), + NU("NuPlayer"), + UNKNOWN("Unknown"); private final String name; diff --git a/core/src/main/java/com/novoda/noplayer/mediaplayer/BuggyVideoDriverPreventer.java b/core/src/main/java/com/novoda/noplayer/mediaplayer/BuggyVideoDriverPreventer.java index fcf086a4..4211cb60 100644 --- a/core/src/main/java/com/novoda/noplayer/mediaplayer/BuggyVideoDriverPreventer.java +++ b/core/src/main/java/com/novoda/noplayer/mediaplayer/BuggyVideoDriverPreventer.java @@ -17,7 +17,7 @@ class BuggyVideoDriverPreventer { private OnPotentialBuggyDriverLayoutListener preventerListener; - public static BuggyVideoDriverPreventer newInstance() { + static BuggyVideoDriverPreventer newInstance() { PlayerChecker playerChecker = PlayerChecker.newInstance(); return new BuggyVideoDriverPreventer(playerChecker); } @@ -41,7 +41,7 @@ private void attemptToCorrectMediaPlayerStatus(Player player, View containerView containerView.addOnLayoutChangeListener(preventerListener); } - public void clear(View containerView) { + void clear(View containerView) { containerView.removeOnLayoutChangeListener(preventerListener); preventerListener = null; } diff --git a/core/src/main/java/com/novoda/noplayer/mediaplayer/ErrorFactory.java b/core/src/main/java/com/novoda/noplayer/mediaplayer/ErrorFactory.java index 795b381d..17086078 100644 --- a/core/src/main/java/com/novoda/noplayer/mediaplayer/ErrorFactory.java +++ b/core/src/main/java/com/novoda/noplayer/mediaplayer/ErrorFactory.java @@ -28,7 +28,7 @@ private abstract static class MediaPlayerError implements Player.PlayerError { private final int type; private final int extra; - protected MediaPlayerError(int type, int extra) { + MediaPlayerError(int type, int extra) { this.type = type; this.extra = extra; } @@ -42,7 +42,6 @@ public String getType() { public Throwable getCause() { return new MediaPlayerErrorThrowable(extra); } - } private static class MediaPlayerErrorThrowable extends Throwable { @@ -54,18 +53,16 @@ private static class MediaPlayerErrorThrowable extends Throwable { public static class StreamedVideoError extends MediaPlayerError { - protected StreamedVideoError(int type, int extra) { + StreamedVideoError(int type, int extra) { super(type, extra); } - } public static class MediaFormatNotRecognizedError extends MediaPlayerError { - protected MediaFormatNotRecognizedError(int type, int extra) { + MediaFormatNotRecognizedError(int type, int extra) { super(type, extra); } - } public static class MediaServerDiedError extends MediaPlayerError { @@ -73,14 +70,12 @@ public static class MediaServerDiedError extends MediaPlayerError { protected MediaServerDiedError(int type, int extra) { super(type, extra); } - } public static class UnknownMediaPlayerError extends MediaPlayerError { - protected UnknownMediaPlayerError(int type, int extra) { + UnknownMediaPlayerError(int type, int extra) { super(type, extra); } - } } diff --git a/core/src/main/java/com/novoda/noplayer/mediaplayer/MediaPlayerCreator.java b/core/src/main/java/com/novoda/noplayer/mediaplayer/MediaPlayerCreator.java index 9d63c0ab..7fb86e4c 100644 --- a/core/src/main/java/com/novoda/noplayer/mediaplayer/MediaPlayerCreator.java +++ b/core/src/main/java/com/novoda/noplayer/mediaplayer/MediaPlayerCreator.java @@ -3,6 +3,7 @@ import android.media.MediaPlayer; class MediaPlayerCreator { + MediaPlayer createMediaPlayer() { return new MediaPlayer(); } diff --git a/core/src/main/java/com/novoda/noplayer/mediaplayer/PlayerChecker.java b/core/src/main/java/com/novoda/noplayer/mediaplayer/PlayerChecker.java index db3d258b..5b2197b0 100644 --- a/core/src/main/java/com/novoda/noplayer/mediaplayer/PlayerChecker.java +++ b/core/src/main/java/com/novoda/noplayer/mediaplayer/PlayerChecker.java @@ -51,5 +51,4 @@ private boolean getBooleanProp(String prop) throws SystemProperties.MissingSyste String value = systemProperties.get(prop); return "true".equalsIgnoreCase(value) || "1".equals(value); } - } From e290369964e2282805685f21ac88ef798e31afc6 Mon Sep 17 00:00:00 2001 From: Ryan Feline Date: Mon, 26 Jun 2017 15:23:48 +0100 Subject: [PATCH 06/11] Rescope and move models to their own package. --- .../src/main/java/com/novoda/noplayer/Listeners.java | 10 ---------- .../main/java/com/novoda/noplayer/NoPlayerView.java | 1 + core/src/main/java/com/novoda/noplayer/Player.java | 5 +++++ .../main/java/com/novoda/noplayer/PlayerState.java | 3 +++ .../main/java/com/novoda/noplayer/PlayerView.java | 2 ++ .../novoda/noplayer/exoplayer/ExoPlayerFacade.java | 8 ++++---- .../novoda/noplayer/exoplayer/ExoPlayerTwoImpl.java | 12 ++++++------ .../noplayer/exoplayer/NoPlayerExoPlayerCreator.java | 2 +- .../noplayer/exoplayer/TextRendererOutput.java | 2 +- .../exoplayer/forwarder/BitrateForwarder.java | 2 +- .../mediasource/ExoPlayerAudioTrackSelector.java | 2 +- .../mediasource/ExoPlayerSubtitleTrackSelector.java | 2 +- .../noplayer/listeners/BitrateChangedListeners.java | 2 +- .../AndroidMediaPlayerAudioTrackSelector.java | 2 +- .../mediaplayer/AndroidMediaPlayerFacade.java | 2 +- .../noplayer/mediaplayer/AndroidMediaPlayerImpl.java | 12 ++++++------ .../mediaplayer/CheckBufferHeartbeatCallback.java | 2 +- .../mediaplayer/NoPlayerMediaPlayerCreator.java | 2 +- .../com/novoda/noplayer/{ => model}/Bitrate.java | 2 +- .../com/novoda/noplayer/{ => model}/LoadTimeout.java | 5 ++++- .../noplayer/{ => model}/PlayerAudioTrack.java | 2 +- .../noplayer/{ => model}/PlayerSubtitleTrack.java | 2 +- .../com/novoda/noplayer/{ => model}/TextCues.java | 4 ++-- .../com/novoda/noplayer/{ => model}/Timeout.java | 2 +- .../novoda/noplayer/{ => model}/VideoDuration.java | 2 +- .../novoda/noplayer/{ => model}/VideoPosition.java | 2 +- .../java/com/novoda/noplayer/LoadTimeoutTest.java | 3 +++ .../noplayer/exoplayer/ExoPlayerFacadeTest.java | 8 ++++---- .../noplayer/exoplayer/ExoPlayerTwoImplTest.java | 10 +++++----- .../exoplayer/PlayerSubtitleTrackFixture.java | 2 +- .../mediasource/ExoPlayerAudioTrackSelectorTest.java | 2 +- .../AndroidMediaPlayerAudioTrackSelectorTest.java | 2 +- .../mediaplayer/AndroidMediaPlayerFacadeTest.java | 2 +- .../mediaplayer/AndroidMediaPlayerImplTest.java | 10 +++++----- .../novoda/noplayer/mediaplayer/LoadTimeoutTest.java | 4 ++-- demo/src/main/java/com/novoda/demo/MainActivity.java | 4 ++-- 36 files changed, 74 insertions(+), 67 deletions(-) rename core/src/main/java/com/novoda/noplayer/{ => model}/Bitrate.java (95%) rename core/src/main/java/com/novoda/noplayer/{ => model}/LoadTimeout.java (92%) rename core/src/main/java/com/novoda/noplayer/{ => model}/PlayerAudioTrack.java (98%) rename core/src/main/java/com/novoda/noplayer/{ => model}/PlayerSubtitleTrack.java (98%) rename core/src/main/java/com/novoda/noplayer/{ => model}/TextCues.java (91%) rename core/src/main/java/com/novoda/noplayer/{ => model}/Timeout.java (93%) rename core/src/main/java/com/novoda/noplayer/{ => model}/VideoDuration.java (98%) rename core/src/main/java/com/novoda/noplayer/{ => model}/VideoPosition.java (98%) diff --git a/core/src/main/java/com/novoda/noplayer/Listeners.java b/core/src/main/java/com/novoda/noplayer/Listeners.java index a952bf94..0a2b0e3f 100644 --- a/core/src/main/java/com/novoda/noplayer/Listeners.java +++ b/core/src/main/java/com/novoda/noplayer/Listeners.java @@ -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); @@ -46,5 +37,4 @@ public interface Listeners { void addVideoSizeChangedListener(Player.VideoSizeChangedListener videoSizeChangedListener); void removeVideoSizeChangedListener(Player.VideoSizeChangedListener videoSizeChangedListener); - } diff --git a/core/src/main/java/com/novoda/noplayer/NoPlayerView.java b/core/src/main/java/com/novoda/noplayer/NoPlayerView.java index e15eb260..577f47c1 100644 --- a/core/src/main/java/com/novoda/noplayer/NoPlayerView.java +++ b/core/src/main/java/com/novoda/noplayer/NoPlayerView.java @@ -8,6 +8,7 @@ import com.google.android.exoplayer2.ui.AspectRatioFrameLayout; import com.google.android.exoplayer2.ui.SubtitleView; +import com.novoda.noplayer.model.TextCues; public class NoPlayerView extends FrameLayout implements AspectRatioChangeCalculator.Listener, PlayerView { diff --git a/core/src/main/java/com/novoda/noplayer/Player.java b/core/src/main/java/com/novoda/noplayer/Player.java index 208a1b74..c5d90fa4 100644 --- a/core/src/main/java/com/novoda/noplayer/Player.java +++ b/core/src/main/java/com/novoda/noplayer/Player.java @@ -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; diff --git a/core/src/main/java/com/novoda/noplayer/PlayerState.java b/core/src/main/java/com/novoda/noplayer/PlayerState.java index 531b711e..831e5598 100644 --- a/core/src/main/java/com/novoda/noplayer/PlayerState.java +++ b/core/src/main/java/com/novoda/noplayer/PlayerState.java @@ -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(); diff --git a/core/src/main/java/com/novoda/noplayer/PlayerView.java b/core/src/main/java/com/novoda/noplayer/PlayerView.java index d37a9391..78898e6f 100644 --- a/core/src/main/java/com/novoda/noplayer/PlayerView.java +++ b/core/src/main/java/com/novoda/noplayer/PlayerView.java @@ -2,6 +2,8 @@ import android.view.View; +import com.novoda.noplayer.model.TextCues; + public interface PlayerView { View getContainerView(); diff --git a/core/src/main/java/com/novoda/noplayer/exoplayer/ExoPlayerFacade.java b/core/src/main/java/com/novoda/noplayer/exoplayer/ExoPlayerFacade.java index 428a7fd0..f9f3f1e1 100644 --- a/core/src/main/java/com/novoda/noplayer/exoplayer/ExoPlayerFacade.java +++ b/core/src/main/java/com/novoda/noplayer/exoplayer/ExoPlayerFacade.java @@ -7,10 +7,10 @@ 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.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; diff --git a/core/src/main/java/com/novoda/noplayer/exoplayer/ExoPlayerTwoImpl.java b/core/src/main/java/com/novoda/noplayer/exoplayer/ExoPlayerTwoImpl.java index 9554c13d..6fd12ed2 100644 --- a/core/src/main/java/com/novoda/noplayer/exoplayer/ExoPlayerTwoImpl.java +++ b/core/src/main/java/com/novoda/noplayer/exoplayer/ExoPlayerTwoImpl.java @@ -6,17 +6,17 @@ 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.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; diff --git a/core/src/main/java/com/novoda/noplayer/exoplayer/NoPlayerExoPlayerCreator.java b/core/src/main/java/com/novoda/noplayer/exoplayer/NoPlayerExoPlayerCreator.java index 08e8bef8..eabc267f 100644 --- a/core/src/main/java/com/novoda/noplayer/exoplayer/NoPlayerExoPlayerCreator.java +++ b/core/src/main/java/com/novoda/noplayer/exoplayer/NoPlayerExoPlayerCreator.java @@ -7,7 +7,7 @@ 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; diff --git a/core/src/main/java/com/novoda/noplayer/exoplayer/TextRendererOutput.java b/core/src/main/java/com/novoda/noplayer/exoplayer/TextRendererOutput.java index 6f07a583..2895eb4e 100644 --- a/core/src/main/java/com/novoda/noplayer/exoplayer/TextRendererOutput.java +++ b/core/src/main/java/com/novoda/noplayer/exoplayer/TextRendererOutput.java @@ -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; diff --git a/core/src/main/java/com/novoda/noplayer/exoplayer/forwarder/BitrateForwarder.java b/core/src/main/java/com/novoda/noplayer/exoplayer/forwarder/BitrateForwarder.java index 623d3b16..74b30d80 100644 --- a/core/src/main/java/com/novoda/noplayer/exoplayer/forwarder/BitrateForwarder.java +++ b/core/src/main/java/com/novoda/noplayer/exoplayer/forwarder/BitrateForwarder.java @@ -4,7 +4,7 @@ import com.google.android.exoplayer2.Format; import com.google.android.exoplayer2.source.AdaptiveMediaSourceEventListener; import com.google.android.exoplayer2.upstream.DataSpec; -import com.novoda.noplayer.Bitrate; +import com.novoda.noplayer.model.Bitrate; import com.novoda.noplayer.listeners.BitrateChangedListeners; import java.io.IOException; diff --git a/core/src/main/java/com/novoda/noplayer/exoplayer/mediasource/ExoPlayerAudioTrackSelector.java b/core/src/main/java/com/novoda/noplayer/exoplayer/mediasource/ExoPlayerAudioTrackSelector.java index e0b4a726..b1cbf945 100644 --- a/core/src/main/java/com/novoda/noplayer/exoplayer/mediasource/ExoPlayerAudioTrackSelector.java +++ b/core/src/main/java/com/novoda/noplayer/exoplayer/mediasource/ExoPlayerAudioTrackSelector.java @@ -5,7 +5,7 @@ import com.google.android.exoplayer2.source.TrackGroupArray; import com.google.android.exoplayer2.trackselection.MappingTrackSelector; import com.google.android.exoplayer2.trackselection.TrackSelection; -import com.novoda.noplayer.PlayerAudioTrack; +import com.novoda.noplayer.model.PlayerAudioTrack; import com.novoda.noplayer.exoplayer.RendererTypeRequester; import java.util.ArrayList; diff --git a/core/src/main/java/com/novoda/noplayer/exoplayer/mediasource/ExoPlayerSubtitleTrackSelector.java b/core/src/main/java/com/novoda/noplayer/exoplayer/mediasource/ExoPlayerSubtitleTrackSelector.java index e575dac1..fda407ac 100644 --- a/core/src/main/java/com/novoda/noplayer/exoplayer/mediasource/ExoPlayerSubtitleTrackSelector.java +++ b/core/src/main/java/com/novoda/noplayer/exoplayer/mediasource/ExoPlayerSubtitleTrackSelector.java @@ -5,7 +5,7 @@ import com.google.android.exoplayer2.source.TrackGroupArray; import com.google.android.exoplayer2.trackselection.MappingTrackSelector; import com.google.android.exoplayer2.trackselection.TrackSelection; -import com.novoda.noplayer.PlayerSubtitleTrack; +import com.novoda.noplayer.model.PlayerSubtitleTrack; import com.novoda.noplayer.exoplayer.RendererTypeRequester; import java.util.ArrayList; diff --git a/core/src/main/java/com/novoda/noplayer/listeners/BitrateChangedListeners.java b/core/src/main/java/com/novoda/noplayer/listeners/BitrateChangedListeners.java index 9d456dab..3856f89b 100644 --- a/core/src/main/java/com/novoda/noplayer/listeners/BitrateChangedListeners.java +++ b/core/src/main/java/com/novoda/noplayer/listeners/BitrateChangedListeners.java @@ -1,6 +1,6 @@ package com.novoda.noplayer.listeners; -import com.novoda.noplayer.Bitrate; +import com.novoda.noplayer.model.Bitrate; import com.novoda.noplayer.Player; import java.util.Set; diff --git a/core/src/main/java/com/novoda/noplayer/mediaplayer/AndroidMediaPlayerAudioTrackSelector.java b/core/src/main/java/com/novoda/noplayer/mediaplayer/AndroidMediaPlayerAudioTrackSelector.java index db8ec701..1a3d6d0d 100644 --- a/core/src/main/java/com/novoda/noplayer/mediaplayer/AndroidMediaPlayerAudioTrackSelector.java +++ b/core/src/main/java/com/novoda/noplayer/mediaplayer/AndroidMediaPlayerAudioTrackSelector.java @@ -2,7 +2,7 @@ import android.media.MediaPlayer; -import com.novoda.noplayer.PlayerAudioTrack; +import com.novoda.noplayer.model.PlayerAudioTrack; import java.util.ArrayList; import java.util.List; diff --git a/core/src/main/java/com/novoda/noplayer/mediaplayer/AndroidMediaPlayerFacade.java b/core/src/main/java/com/novoda/noplayer/mediaplayer/AndroidMediaPlayerFacade.java index 7ce00a6e..5afa5db7 100644 --- a/core/src/main/java/com/novoda/noplayer/mediaplayer/AndroidMediaPlayerFacade.java +++ b/core/src/main/java/com/novoda/noplayer/mediaplayer/AndroidMediaPlayerFacade.java @@ -6,7 +6,7 @@ import android.net.Uri; import android.view.SurfaceHolder; -import com.novoda.noplayer.PlayerAudioTrack; +import com.novoda.noplayer.model.PlayerAudioTrack; import com.novoda.noplayer.mediaplayer.PlaybackStateChecker.PlaybackState; import com.novoda.noplayer.mediaplayer.forwarder.MediaPlayerForwarder; import com.novoda.utils.NoPlayerLog; diff --git a/core/src/main/java/com/novoda/noplayer/mediaplayer/AndroidMediaPlayerImpl.java b/core/src/main/java/com/novoda/noplayer/mediaplayer/AndroidMediaPlayerImpl.java index b53a8c63..8a8adbc8 100644 --- a/core/src/main/java/com/novoda/noplayer/mediaplayer/AndroidMediaPlayerImpl.java +++ b/core/src/main/java/com/novoda/noplayer/mediaplayer/AndroidMediaPlayerImpl.java @@ -8,17 +8,17 @@ import com.novoda.noplayer.ContentType; import com.novoda.noplayer.Heart; import com.novoda.noplayer.Listeners; -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.model.Timeout; +import com.novoda.noplayer.model.VideoDuration; +import com.novoda.noplayer.model.VideoPosition; import com.novoda.noplayer.mediaplayer.forwarder.MediaPlayerForwarder; import com.novoda.noplayer.player.PlayerInformation; diff --git a/core/src/main/java/com/novoda/noplayer/mediaplayer/CheckBufferHeartbeatCallback.java b/core/src/main/java/com/novoda/noplayer/mediaplayer/CheckBufferHeartbeatCallback.java index 285dd04a..641eed95 100644 --- a/core/src/main/java/com/novoda/noplayer/mediaplayer/CheckBufferHeartbeatCallback.java +++ b/core/src/main/java/com/novoda/noplayer/mediaplayer/CheckBufferHeartbeatCallback.java @@ -2,7 +2,7 @@ import com.novoda.noplayer.Heart; import com.novoda.noplayer.Player; -import com.novoda.noplayer.VideoPosition; +import com.novoda.noplayer.model.VideoPosition; public class CheckBufferHeartbeatCallback implements Heart.Heartbeat.Callback { diff --git a/core/src/main/java/com/novoda/noplayer/mediaplayer/NoPlayerMediaPlayerCreator.java b/core/src/main/java/com/novoda/noplayer/mediaplayer/NoPlayerMediaPlayerCreator.java index e03788b4..5d1aee6b 100644 --- a/core/src/main/java/com/novoda/noplayer/mediaplayer/NoPlayerMediaPlayerCreator.java +++ b/core/src/main/java/com/novoda/noplayer/mediaplayer/NoPlayerMediaPlayerCreator.java @@ -4,7 +4,7 @@ import android.os.Handler; 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; diff --git a/core/src/main/java/com/novoda/noplayer/Bitrate.java b/core/src/main/java/com/novoda/noplayer/model/Bitrate.java similarity index 95% rename from core/src/main/java/com/novoda/noplayer/Bitrate.java rename to core/src/main/java/com/novoda/noplayer/model/Bitrate.java index d754c7d3..2e2f235f 100644 --- a/core/src/main/java/com/novoda/noplayer/Bitrate.java +++ b/core/src/main/java/com/novoda/noplayer/model/Bitrate.java @@ -1,4 +1,4 @@ -package com.novoda.noplayer; +package com.novoda.noplayer.model; public final class Bitrate { diff --git a/core/src/main/java/com/novoda/noplayer/LoadTimeout.java b/core/src/main/java/com/novoda/noplayer/model/LoadTimeout.java similarity index 92% rename from core/src/main/java/com/novoda/noplayer/LoadTimeout.java rename to core/src/main/java/com/novoda/noplayer/model/LoadTimeout.java index a472a7df..0c3f0035 100644 --- a/core/src/main/java/com/novoda/noplayer/LoadTimeout.java +++ b/core/src/main/java/com/novoda/noplayer/model/LoadTimeout.java @@ -1,7 +1,10 @@ -package com.novoda.noplayer; +package com.novoda.noplayer.model; import android.os.Handler; +import com.novoda.noplayer.Clock; +import com.novoda.noplayer.Player; + public class LoadTimeout { private static final int DELAY_MILLIS = 1000; diff --git a/core/src/main/java/com/novoda/noplayer/PlayerAudioTrack.java b/core/src/main/java/com/novoda/noplayer/model/PlayerAudioTrack.java similarity index 98% rename from core/src/main/java/com/novoda/noplayer/PlayerAudioTrack.java rename to core/src/main/java/com/novoda/noplayer/model/PlayerAudioTrack.java index 9425c7a4..19720167 100644 --- a/core/src/main/java/com/novoda/noplayer/PlayerAudioTrack.java +++ b/core/src/main/java/com/novoda/noplayer/model/PlayerAudioTrack.java @@ -1,4 +1,4 @@ -package com.novoda.noplayer; +package com.novoda.noplayer.model; public class PlayerAudioTrack { diff --git a/core/src/main/java/com/novoda/noplayer/PlayerSubtitleTrack.java b/core/src/main/java/com/novoda/noplayer/model/PlayerSubtitleTrack.java similarity index 98% rename from core/src/main/java/com/novoda/noplayer/PlayerSubtitleTrack.java rename to core/src/main/java/com/novoda/noplayer/model/PlayerSubtitleTrack.java index 718a4f22..77dc1450 100644 --- a/core/src/main/java/com/novoda/noplayer/PlayerSubtitleTrack.java +++ b/core/src/main/java/com/novoda/noplayer/model/PlayerSubtitleTrack.java @@ -1,4 +1,4 @@ -package com.novoda.noplayer; +package com.novoda.noplayer.model; public class PlayerSubtitleTrack { diff --git a/core/src/main/java/com/novoda/noplayer/TextCues.java b/core/src/main/java/com/novoda/noplayer/model/TextCues.java similarity index 91% rename from core/src/main/java/com/novoda/noplayer/TextCues.java rename to core/src/main/java/com/novoda/noplayer/model/TextCues.java index e89fb7a5..80a49d73 100644 --- a/core/src/main/java/com/novoda/noplayer/TextCues.java +++ b/core/src/main/java/com/novoda/noplayer/model/TextCues.java @@ -1,4 +1,4 @@ -package com.novoda.noplayer; +package com.novoda.noplayer.model; import com.google.android.exoplayer2.text.Cue; @@ -12,7 +12,7 @@ public TextCues(List cues) { this.cues = cues; } - List cues() { + public List cues() { return cues; } diff --git a/core/src/main/java/com/novoda/noplayer/Timeout.java b/core/src/main/java/com/novoda/noplayer/model/Timeout.java similarity index 93% rename from core/src/main/java/com/novoda/noplayer/Timeout.java rename to core/src/main/java/com/novoda/noplayer/model/Timeout.java index 53d9fc85..86755cab 100644 --- a/core/src/main/java/com/novoda/noplayer/Timeout.java +++ b/core/src/main/java/com/novoda/noplayer/model/Timeout.java @@ -1,4 +1,4 @@ -package com.novoda.noplayer; +package com.novoda.noplayer.model; import java.util.concurrent.TimeUnit; diff --git a/core/src/main/java/com/novoda/noplayer/VideoDuration.java b/core/src/main/java/com/novoda/noplayer/model/VideoDuration.java similarity index 98% rename from core/src/main/java/com/novoda/noplayer/VideoDuration.java rename to core/src/main/java/com/novoda/noplayer/model/VideoDuration.java index 2d79f4b8..dda764e0 100644 --- a/core/src/main/java/com/novoda/noplayer/VideoDuration.java +++ b/core/src/main/java/com/novoda/noplayer/model/VideoDuration.java @@ -1,4 +1,4 @@ -package com.novoda.noplayer; +package com.novoda.noplayer.model; import java.io.Serializable; import java.util.concurrent.TimeUnit; diff --git a/core/src/main/java/com/novoda/noplayer/VideoPosition.java b/core/src/main/java/com/novoda/noplayer/model/VideoPosition.java similarity index 98% rename from core/src/main/java/com/novoda/noplayer/VideoPosition.java rename to core/src/main/java/com/novoda/noplayer/model/VideoPosition.java index d9bdaea9..fbe73f32 100644 --- a/core/src/main/java/com/novoda/noplayer/VideoPosition.java +++ b/core/src/main/java/com/novoda/noplayer/model/VideoPosition.java @@ -1,4 +1,4 @@ -package com.novoda.noplayer; +package com.novoda.noplayer.model; import java.io.Serializable; import java.util.concurrent.TimeUnit; diff --git a/core/src/test/java/com/novoda/noplayer/LoadTimeoutTest.java b/core/src/test/java/com/novoda/noplayer/LoadTimeoutTest.java index 729dad0e..52b0773e 100644 --- a/core/src/test/java/com/novoda/noplayer/LoadTimeoutTest.java +++ b/core/src/test/java/com/novoda/noplayer/LoadTimeoutTest.java @@ -2,6 +2,9 @@ import android.os.Handler; +import com.novoda.noplayer.model.LoadTimeout; +import com.novoda.noplayer.model.Timeout; + import org.junit.Before; import org.junit.Rule; import org.junit.Test; diff --git a/core/src/test/java/com/novoda/noplayer/exoplayer/ExoPlayerFacadeTest.java b/core/src/test/java/com/novoda/noplayer/exoplayer/ExoPlayerFacadeTest.java index 70e24be5..926f14b1 100644 --- a/core/src/test/java/com/novoda/noplayer/exoplayer/ExoPlayerFacadeTest.java +++ b/core/src/test/java/com/novoda/noplayer/exoplayer/ExoPlayerFacadeTest.java @@ -7,10 +7,10 @@ import com.google.android.exoplayer2.drm.DefaultDrmSessionManager; 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.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; diff --git a/core/src/test/java/com/novoda/noplayer/exoplayer/ExoPlayerTwoImplTest.java b/core/src/test/java/com/novoda/noplayer/exoplayer/ExoPlayerTwoImplTest.java index 9683aced..b420335b 100644 --- a/core/src/test/java/com/novoda/noplayer/exoplayer/ExoPlayerTwoImplTest.java +++ b/core/src/test/java/com/novoda/noplayer/exoplayer/ExoPlayerTwoImplTest.java @@ -7,16 +7,16 @@ import com.google.android.exoplayer2.text.Cue; 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.Player.StateChangedListener; import com.novoda.noplayer.PlayerListenersHolder; -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.TextCues; -import com.novoda.noplayer.Timeout; -import com.novoda.noplayer.VideoPosition; +import com.novoda.noplayer.model.TextCues; +import com.novoda.noplayer.model.Timeout; +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.ExoPlayerTrackSelector; diff --git a/core/src/test/java/com/novoda/noplayer/exoplayer/PlayerSubtitleTrackFixture.java b/core/src/test/java/com/novoda/noplayer/exoplayer/PlayerSubtitleTrackFixture.java index 0a3ee313..24c3049a 100644 --- a/core/src/test/java/com/novoda/noplayer/exoplayer/PlayerSubtitleTrackFixture.java +++ b/core/src/test/java/com/novoda/noplayer/exoplayer/PlayerSubtitleTrackFixture.java @@ -1,6 +1,6 @@ package com.novoda.noplayer.exoplayer; -import com.novoda.noplayer.PlayerSubtitleTrack; +import com.novoda.noplayer.model.PlayerSubtitleTrack; class PlayerSubtitleTrackFixture { diff --git a/core/src/test/java/com/novoda/noplayer/exoplayer/mediasource/ExoPlayerAudioTrackSelectorTest.java b/core/src/test/java/com/novoda/noplayer/exoplayer/mediasource/ExoPlayerAudioTrackSelectorTest.java index f26ba825..99b39cd2 100644 --- a/core/src/test/java/com/novoda/noplayer/exoplayer/mediasource/ExoPlayerAudioTrackSelectorTest.java +++ b/core/src/test/java/com/novoda/noplayer/exoplayer/mediasource/ExoPlayerAudioTrackSelectorTest.java @@ -5,7 +5,7 @@ import com.google.android.exoplayer2.source.TrackGroupArray; import com.google.android.exoplayer2.trackselection.MappingTrackSelector; import com.google.android.exoplayer2.trackselection.TrackSelection; -import com.novoda.noplayer.PlayerAudioTrack; +import com.novoda.noplayer.model.PlayerAudioTrack; import com.novoda.noplayer.exoplayer.RendererTypeRequester; import java.util.Collections; diff --git a/core/src/test/java/com/novoda/noplayer/mediaplayer/AndroidMediaPlayerAudioTrackSelectorTest.java b/core/src/test/java/com/novoda/noplayer/mediaplayer/AndroidMediaPlayerAudioTrackSelectorTest.java index 8dbf761e..091730f6 100644 --- a/core/src/test/java/com/novoda/noplayer/mediaplayer/AndroidMediaPlayerAudioTrackSelectorTest.java +++ b/core/src/test/java/com/novoda/noplayer/mediaplayer/AndroidMediaPlayerAudioTrackSelectorTest.java @@ -3,7 +3,7 @@ import android.media.MediaPlayer; import utils.ExceptionMatcher; -import com.novoda.noplayer.PlayerAudioTrack; +import com.novoda.noplayer.model.PlayerAudioTrack; import java.util.Arrays; import java.util.Collections; diff --git a/core/src/test/java/com/novoda/noplayer/mediaplayer/AndroidMediaPlayerFacadeTest.java b/core/src/test/java/com/novoda/noplayer/mediaplayer/AndroidMediaPlayerFacadeTest.java index 7622abaa..740e18c7 100644 --- a/core/src/test/java/com/novoda/noplayer/mediaplayer/AndroidMediaPlayerFacadeTest.java +++ b/core/src/test/java/com/novoda/noplayer/mediaplayer/AndroidMediaPlayerFacadeTest.java @@ -6,7 +6,7 @@ import android.net.Uri; import android.view.SurfaceHolder; -import com.novoda.noplayer.PlayerAudioTrack; +import com.novoda.noplayer.model.PlayerAudioTrack; import com.novoda.noplayer.SurfaceHolderRequester; import com.novoda.noplayer.mediaplayer.forwarder.MediaPlayerForwarder; import com.novoda.utils.NoPlayerLog; diff --git a/core/src/test/java/com/novoda/noplayer/mediaplayer/AndroidMediaPlayerImplTest.java b/core/src/test/java/com/novoda/noplayer/mediaplayer/AndroidMediaPlayerImplTest.java index 49ae423d..e7d35e54 100644 --- a/core/src/test/java/com/novoda/noplayer/mediaplayer/AndroidMediaPlayerImplTest.java +++ b/core/src/test/java/com/novoda/noplayer/mediaplayer/AndroidMediaPlayerImplTest.java @@ -9,15 +9,15 @@ 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.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.model.Timeout; +import com.novoda.noplayer.model.VideoDuration; +import com.novoda.noplayer.model.VideoPosition; import com.novoda.noplayer.listeners.BufferStateListeners; import com.novoda.noplayer.listeners.CompletionListeners; import com.novoda.noplayer.listeners.ErrorListeners; diff --git a/core/src/test/java/com/novoda/noplayer/mediaplayer/LoadTimeoutTest.java b/core/src/test/java/com/novoda/noplayer/mediaplayer/LoadTimeoutTest.java index bb3b2ca4..a3fd360f 100644 --- a/core/src/test/java/com/novoda/noplayer/mediaplayer/LoadTimeoutTest.java +++ b/core/src/test/java/com/novoda/noplayer/mediaplayer/LoadTimeoutTest.java @@ -3,9 +3,9 @@ import android.os.Handler; import com.novoda.noplayer.Clock; -import com.novoda.noplayer.LoadTimeout; +import com.novoda.noplayer.model.LoadTimeout; import com.novoda.noplayer.Player; -import com.novoda.noplayer.Timeout; +import com.novoda.noplayer.model.Timeout; import org.junit.Before; import org.junit.Test; diff --git a/demo/src/main/java/com/novoda/demo/MainActivity.java b/demo/src/main/java/com/novoda/demo/MainActivity.java index 7dbfd1a7..6c39f47d 100644 --- a/demo/src/main/java/com/novoda/demo/MainActivity.java +++ b/demo/src/main/java/com/novoda/demo/MainActivity.java @@ -11,9 +11,9 @@ import com.novoda.noplayer.ContentType; import com.novoda.noplayer.Player; -import com.novoda.noplayer.PlayerAudioTrack; +import com.novoda.noplayer.model.PlayerAudioTrack; 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.drm.DrmType; import com.novoda.noplayer.player.PlayerFactory; From 6b400cf70694f4722040f0b08470eb013ee9aa55 Mon Sep 17 00:00:00 2001 From: Ryan Feline Date: Tue, 27 Jun 2017 13:54:33 +0100 Subject: [PATCH 07/11] Rename and move ErrorFactory to ErrorMapper. --- .../ExoPlayerErrorMapper.java} | 16 +++++++++++----- .../forwarder/PlayerOnErrorForwarder.java | 3 +-- 2 files changed, 12 insertions(+), 7 deletions(-) rename core/src/main/java/com/novoda/noplayer/exoplayer/{playererror/ExoPlayerErrorFactory.java => forwarder/ExoPlayerErrorMapper.java} (61%) diff --git a/core/src/main/java/com/novoda/noplayer/exoplayer/playererror/ExoPlayerErrorFactory.java b/core/src/main/java/com/novoda/noplayer/exoplayer/forwarder/ExoPlayerErrorMapper.java similarity index 61% rename from core/src/main/java/com/novoda/noplayer/exoplayer/playererror/ExoPlayerErrorFactory.java rename to core/src/main/java/com/novoda/noplayer/exoplayer/forwarder/ExoPlayerErrorMapper.java index c1d3d092..12ca46a4 100644 --- a/core/src/main/java/com/novoda/noplayer/exoplayer/playererror/ExoPlayerErrorFactory.java +++ b/core/src/main/java/com/novoda/noplayer/exoplayer/forwarder/ExoPlayerErrorMapper.java @@ -1,4 +1,4 @@ -package com.novoda.noplayer.exoplayer.playererror; +package com.novoda.noplayer.exoplayer.forwarder; import android.media.MediaCodec; @@ -6,16 +6,22 @@ import com.google.android.exoplayer2.upstream.HttpDataSource; import com.novoda.noplayer.Player; import com.novoda.noplayer.drm.DrmRequestException; +import com.novoda.noplayer.exoplayer.playererror.ConnectivityError; +import com.novoda.noplayer.exoplayer.playererror.DrmDecryptionError; +import com.novoda.noplayer.exoplayer.playererror.DrmRequestError; +import com.novoda.noplayer.exoplayer.playererror.InvalidResponseCodeError; +import com.novoda.noplayer.exoplayer.playererror.MalformedContentError; +import com.novoda.noplayer.exoplayer.playererror.UnknownError; import java.io.IOException; -public final class ExoPlayerErrorFactory { +final class ExoPlayerErrorMapper { - private ExoPlayerErrorFactory() { - // uninstantiable + private ExoPlayerErrorMapper() { + // static class. } - public static Player.PlayerError errorFor(Exception e) { + static Player.PlayerError errorFor(Exception e) { if (e instanceof HttpDataSource.InvalidResponseCodeException) { return new InvalidResponseCodeError(e); } diff --git a/core/src/main/java/com/novoda/noplayer/exoplayer/forwarder/PlayerOnErrorForwarder.java b/core/src/main/java/com/novoda/noplayer/exoplayer/forwarder/PlayerOnErrorForwarder.java index d9ab88f5..69cc905a 100644 --- a/core/src/main/java/com/novoda/noplayer/exoplayer/forwarder/PlayerOnErrorForwarder.java +++ b/core/src/main/java/com/novoda/noplayer/exoplayer/forwarder/PlayerOnErrorForwarder.java @@ -7,7 +7,6 @@ import com.google.android.exoplayer2.source.TrackGroupArray; import com.google.android.exoplayer2.trackselection.TrackSelectionArray; import com.novoda.noplayer.Player; -import com.novoda.noplayer.exoplayer.playererror.ExoPlayerErrorFactory; import com.novoda.noplayer.listeners.ErrorListeners; class PlayerOnErrorForwarder implements ExoPlayer.EventListener { @@ -22,7 +21,7 @@ class PlayerOnErrorForwarder implements ExoPlayer.EventListener { @Override public void onPlayerError(ExoPlaybackException error) { - Player.PlayerError playerError = ExoPlayerErrorFactory.errorFor(error); + Player.PlayerError playerError = ExoPlayerErrorMapper.errorFor(error); errorListeners.onError(player, playerError); } From d8005c5705790110542e5bec27e6d8cb39402bdf Mon Sep 17 00:00:00 2001 From: Ryan Feline Date: Tue, 27 Jun 2017 14:09:33 +0100 Subject: [PATCH 08/11] Rename HttpPoster to expose implementation. --- .../com/novoda/noplayer/drm/DrmSessionCreatorFactory.java | 6 +++--- .../{HttpPoster.java => HttpUrlConnectionPoster.java} | 2 +- .../novoda/noplayer/drm/provision/ProvisionExecutor.java | 8 ++++---- .../noplayer/drm/provision/ProvisionExecutorTest.java | 6 +++--- 4 files changed, 11 insertions(+), 11 deletions(-) rename core/src/main/java/com/novoda/noplayer/drm/provision/{HttpPoster.java => HttpUrlConnectionPoster.java} (97%) diff --git a/core/src/main/java/com/novoda/noplayer/drm/DrmSessionCreatorFactory.java b/core/src/main/java/com/novoda/noplayer/drm/DrmSessionCreatorFactory.java index 68b76be2..9b236bb7 100644 --- a/core/src/main/java/com/novoda/noplayer/drm/DrmSessionCreatorFactory.java +++ b/core/src/main/java/com/novoda/noplayer/drm/DrmSessionCreatorFactory.java @@ -3,7 +3,7 @@ import android.os.Build; import android.os.Handler; -import com.novoda.noplayer.drm.provision.HttpPoster; +import com.novoda.noplayer.drm.provision.HttpUrlConnectionPoster; import com.novoda.noplayer.drm.provision.ProvisionExecutor; import com.novoda.noplayer.drm.provision.ProvisioningCapabilities; import com.novoda.noplayer.player.PlayerFactory; @@ -48,9 +48,9 @@ private void assertThatApiLevelIsJellyBeanEighteenOrAbove(DrmType drmType) { } private DrmSessionCreator createModularStream(StreamingModularDrm drmHandler) { - HttpPoster httpPoster = new HttpPoster(); + HttpUrlConnectionPoster httpUrlConnectionPoster = new HttpUrlConnectionPoster(); ProvisioningCapabilities capabilities = ProvisioningCapabilities.newInstance(); - ProvisionExecutor provisionExecutor = new ProvisionExecutor(httpPoster, capabilities); + ProvisionExecutor provisionExecutor = new ProvisionExecutor(httpUrlConnectionPoster, capabilities); ProvisioningModularDrmCallback mediaDrmCallback = new ProvisioningModularDrmCallback( drmHandler, provisionExecutor diff --git a/core/src/main/java/com/novoda/noplayer/drm/provision/HttpPoster.java b/core/src/main/java/com/novoda/noplayer/drm/provision/HttpUrlConnectionPoster.java similarity index 97% rename from core/src/main/java/com/novoda/noplayer/drm/provision/HttpPoster.java rename to core/src/main/java/com/novoda/noplayer/drm/provision/HttpUrlConnectionPoster.java index 07580bdb..bbbcd071 100644 --- a/core/src/main/java/com/novoda/noplayer/drm/provision/HttpPoster.java +++ b/core/src/main/java/com/novoda/noplayer/drm/provision/HttpUrlConnectionPoster.java @@ -6,7 +6,7 @@ import java.net.HttpURLConnection; import java.net.URL; -public class HttpPoster { +public class HttpUrlConnectionPoster { private static final String POST_REQUEST_METHOD = "POST"; private static final int RESPONSE_BUFFER_SIZE = 1024 * 4; diff --git a/core/src/main/java/com/novoda/noplayer/drm/provision/ProvisionExecutor.java b/core/src/main/java/com/novoda/noplayer/drm/provision/ProvisionExecutor.java index ecee65d8..06d1c5bf 100644 --- a/core/src/main/java/com/novoda/noplayer/drm/provision/ProvisionExecutor.java +++ b/core/src/main/java/com/novoda/noplayer/drm/provision/ProvisionExecutor.java @@ -9,11 +9,11 @@ public class ProvisionExecutor { private static final String PARAMETER_SIGNED_REQUEST = "&signedRequest="; - private final HttpPoster httpPoster; + private final HttpUrlConnectionPoster httpUrlConnectionPoster; private final ProvisioningCapabilities capabilities; - public ProvisionExecutor(HttpPoster httpPoster, ProvisioningCapabilities capabilities) { - this.httpPoster = httpPoster; + public ProvisionExecutor(HttpUrlConnectionPoster httpUrlConnectionPoster, ProvisioningCapabilities capabilities) { + this.httpUrlConnectionPoster = httpUrlConnectionPoster; this.capabilities = capabilities; } @@ -22,7 +22,7 @@ public byte[] execute(ModularDrmProvisionRequest request) throws IOException, Un throw new UnableToProvisionException(); } String provisioningUrl = buildProvisioningUrl(request); - return httpPoster.post(provisioningUrl); + return httpUrlConnectionPoster.post(provisioningUrl); } private boolean isIncapableOfProvisioning() { diff --git a/core/src/test/java/com/novoda/noplayer/drm/provision/ProvisionExecutorTest.java b/core/src/test/java/com/novoda/noplayer/drm/provision/ProvisionExecutorTest.java index 88816121..44022ab5 100644 --- a/core/src/test/java/com/novoda/noplayer/drm/provision/ProvisionExecutorTest.java +++ b/core/src/test/java/com/novoda/noplayer/drm/provision/ProvisionExecutorTest.java @@ -29,14 +29,14 @@ public class ProvisionExecutorTest { private ArgumentCaptor provisionUrlCaptor; @Mock - private HttpPoster httpPoster; + private HttpUrlConnectionPoster httpUrlConnectionPoster; @Mock private ProvisioningCapabilities capabilities; @Before public void setUp() { provisionUrlCaptor = ArgumentCaptor.forClass(String.class); - provisionExecutor = new ProvisionExecutor(httpPoster, capabilities); + provisionExecutor = new ProvisionExecutor(httpUrlConnectionPoster, capabilities); } @Test(expected = UnableToProvisionException.class) @@ -52,7 +52,7 @@ public void givenCapableProvisionCapabilities_whenProvisioning_thenTheRequestUrl String expectedProvisionUrl = PROVISION_URL + "&signedRequest=" + new String(PROVISION_DATA); provisionExecutor.execute(A_PROVISION_REQUEST); - verify(httpPoster).post(provisionUrlCaptor.capture()); + verify(httpUrlConnectionPoster).post(provisionUrlCaptor.capture()); assertThat(provisionUrlCaptor.getValue()).isEqualTo(expectedProvisionUrl); } From 3916278b108c26efdc452ceb3f2ffd6d88915046 Mon Sep 17 00:00:00 2001 From: Ryan Feline Date: Tue, 27 Jun 2017 14:32:38 +0100 Subject: [PATCH 09/11] Stop exposing the ProvisionExecutor. --- .../drm/DrmSessionCreatorFactory.java | 11 +++--- .../provision/HttpUrlConnectionPoster.java | 4 +-- .../drm/provision/ProvisionExecutor.java | 29 ++------------- .../provision/ProvisionExecutorCreator.java | 10 ++++++ .../drm/provision/ProvisionExecutorImpl.java | 36 +++++++++++++++++++ .../provision/ProvisioningCapabilities.java | 4 +-- .../novoda/noplayer/player/PlayerFactory.java | 9 ++++- .../drm/DrmSessionCreatorFactoryTest.java | 9 +++-- ...st.java => ProvisionExecutorImplTest.java} | 14 ++++---- 9 files changed, 78 insertions(+), 48 deletions(-) create mode 100644 core/src/main/java/com/novoda/noplayer/drm/provision/ProvisionExecutorCreator.java create mode 100644 core/src/main/java/com/novoda/noplayer/drm/provision/ProvisionExecutorImpl.java rename core/src/test/java/com/novoda/noplayer/drm/provision/{ProvisionExecutorTest.java => ProvisionExecutorImplTest.java} (80%) diff --git a/core/src/main/java/com/novoda/noplayer/drm/DrmSessionCreatorFactory.java b/core/src/main/java/com/novoda/noplayer/drm/DrmSessionCreatorFactory.java index 9b236bb7..ebab98e8 100644 --- a/core/src/main/java/com/novoda/noplayer/drm/DrmSessionCreatorFactory.java +++ b/core/src/main/java/com/novoda/noplayer/drm/DrmSessionCreatorFactory.java @@ -3,19 +3,20 @@ import android.os.Build; import android.os.Handler; -import com.novoda.noplayer.drm.provision.HttpUrlConnectionPoster; import com.novoda.noplayer.drm.provision.ProvisionExecutor; -import com.novoda.noplayer.drm.provision.ProvisioningCapabilities; +import com.novoda.noplayer.drm.provision.ProvisionExecutorCreator; import com.novoda.noplayer.player.PlayerFactory; import com.novoda.utils.AndroidDeviceVersion; public class DrmSessionCreatorFactory { private final AndroidDeviceVersion androidDeviceVersion; + private final ProvisionExecutorCreator provisionExecutorCreator; private final Handler handler; - public DrmSessionCreatorFactory(AndroidDeviceVersion androidDeviceVersion, Handler handler) { + public DrmSessionCreatorFactory(AndroidDeviceVersion androidDeviceVersion, ProvisionExecutorCreator provisionExecutorCreator, Handler handler) { this.androidDeviceVersion = androidDeviceVersion; + this.provisionExecutorCreator = provisionExecutorCreator; this.handler = handler; } @@ -48,9 +49,7 @@ private void assertThatApiLevelIsJellyBeanEighteenOrAbove(DrmType drmType) { } private DrmSessionCreator createModularStream(StreamingModularDrm drmHandler) { - HttpUrlConnectionPoster httpUrlConnectionPoster = new HttpUrlConnectionPoster(); - ProvisioningCapabilities capabilities = ProvisioningCapabilities.newInstance(); - ProvisionExecutor provisionExecutor = new ProvisionExecutor(httpUrlConnectionPoster, capabilities); + ProvisionExecutor provisionExecutor = provisionExecutorCreator.create(); ProvisioningModularDrmCallback mediaDrmCallback = new ProvisioningModularDrmCallback( drmHandler, provisionExecutor diff --git a/core/src/main/java/com/novoda/noplayer/drm/provision/HttpUrlConnectionPoster.java b/core/src/main/java/com/novoda/noplayer/drm/provision/HttpUrlConnectionPoster.java index bbbcd071..f7c9742c 100644 --- a/core/src/main/java/com/novoda/noplayer/drm/provision/HttpUrlConnectionPoster.java +++ b/core/src/main/java/com/novoda/noplayer/drm/provision/HttpUrlConnectionPoster.java @@ -6,12 +6,12 @@ import java.net.HttpURLConnection; import java.net.URL; -public class HttpUrlConnectionPoster { +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(); diff --git a/core/src/main/java/com/novoda/noplayer/drm/provision/ProvisionExecutor.java b/core/src/main/java/com/novoda/noplayer/drm/provision/ProvisionExecutor.java index 06d1c5bf..3f79f7bd 100644 --- a/core/src/main/java/com/novoda/noplayer/drm/provision/ProvisionExecutor.java +++ b/core/src/main/java/com/novoda/noplayer/drm/provision/ProvisionExecutor.java @@ -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 HttpUrlConnectionPoster httpUrlConnectionPoster; - private final ProvisioningCapabilities capabilities; - - public ProvisionExecutor(HttpUrlConnectionPoster httpUrlConnectionPoster, ProvisioningCapabilities capabilities) { - this.httpUrlConnectionPoster = httpUrlConnectionPoster; - this.capabilities = capabilities; - } - - public byte[] execute(ModularDrmProvisionRequest request) throws IOException, UnableToProvisionException { - if (isIncapableOfProvisioning()) { - throw new UnableToProvisionException(); - } - String provisioningUrl = buildProvisioningUrl(request); - return httpUrlConnectionPoster.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; } diff --git a/core/src/main/java/com/novoda/noplayer/drm/provision/ProvisionExecutorCreator.java b/core/src/main/java/com/novoda/noplayer/drm/provision/ProvisionExecutorCreator.java new file mode 100644 index 00000000..1e047ebd --- /dev/null +++ b/core/src/main/java/com/novoda/noplayer/drm/provision/ProvisionExecutorCreator.java @@ -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); + } +} diff --git a/core/src/main/java/com/novoda/noplayer/drm/provision/ProvisionExecutorImpl.java b/core/src/main/java/com/novoda/noplayer/drm/provision/ProvisionExecutorImpl.java new file mode 100644 index 00000000..14e36ab1 --- /dev/null +++ b/core/src/main/java/com/novoda/noplayer/drm/provision/ProvisionExecutorImpl.java @@ -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 { + + 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")); + } +} diff --git a/core/src/main/java/com/novoda/noplayer/drm/provision/ProvisioningCapabilities.java b/core/src/main/java/com/novoda/noplayer/drm/provision/ProvisioningCapabilities.java index 4cd50c46..cb9ab3e0 100644 --- a/core/src/main/java/com/novoda/noplayer/drm/provision/ProvisioningCapabilities.java +++ b/core/src/main/java/com/novoda/noplayer/drm/provision/ProvisioningCapabilities.java @@ -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); } diff --git a/core/src/main/java/com/novoda/noplayer/player/PlayerFactory.java b/core/src/main/java/com/novoda/noplayer/player/PlayerFactory.java index 312c8899..faa0de24 100644 --- a/core/src/main/java/com/novoda/noplayer/player/PlayerFactory.java +++ b/core/src/main/java/com/novoda/noplayer/player/PlayerFactory.java @@ -9,6 +9,7 @@ import com.novoda.noplayer.drm.DrmSessionCreator; import com.novoda.noplayer.drm.DrmSessionCreatorFactory; import com.novoda.noplayer.drm.DrmType; +import com.novoda.noplayer.drm.provision.ProvisionExecutorCreator; import com.novoda.noplayer.exoplayer.NoPlayerExoPlayerCreator; import com.novoda.noplayer.mediaplayer.NoPlayerMediaPlayerCreator; import com.novoda.utils.AndroidDeviceVersion; @@ -25,7 +26,13 @@ public class PlayerFactory { public static PlayerFactory newInstance(Context context, PrioritizedPlayerTypes prioritizedPlayerTypes) { Handler handler = new Handler(Looper.getMainLooper()); - DrmSessionCreatorFactory drmSessionCreatorFactory = new DrmSessionCreatorFactory(AndroidDeviceVersion.newInstance(), handler); + ProvisionExecutorCreator provisionExecutorCreator = new ProvisionExecutorCreator(); + DrmSessionCreatorFactory drmSessionCreatorFactory = new DrmSessionCreatorFactory( + AndroidDeviceVersion.newInstance(), + provisionExecutorCreator, + handler + ); + return new PlayerFactory( context, prioritizedPlayerTypes, diff --git a/core/src/test/java/com/novoda/noplayer/drm/DrmSessionCreatorFactoryTest.java b/core/src/test/java/com/novoda/noplayer/drm/DrmSessionCreatorFactoryTest.java index 411db285..ebd0f350 100644 --- a/core/src/test/java/com/novoda/noplayer/drm/DrmSessionCreatorFactoryTest.java +++ b/core/src/test/java/com/novoda/noplayer/drm/DrmSessionCreatorFactoryTest.java @@ -2,6 +2,7 @@ import android.os.Handler; +import com.novoda.noplayer.drm.provision.ProvisionExecutorCreator; import com.novoda.noplayer.player.PlayerFactory; import com.novoda.utils.AndroidDeviceVersion; @@ -34,12 +35,14 @@ public class DrmSessionCreatorFactoryTest { private DownloadedModularDrm downloadedModularDrm; @Mock private StreamingModularDrm streamingModularDrm; + @Mock + private ProvisionExecutorCreator provisionExecutorCreator; private DrmSessionCreatorFactory drmSessionCreatorFactory; @Before public void setUp() { - drmSessionCreatorFactory = new DrmSessionCreatorFactory(SUPPORTED_MEDIA_DRM_DEVICE, handler); + drmSessionCreatorFactory = new DrmSessionCreatorFactory(SUPPORTED_MEDIA_DRM_DEVICE, provisionExecutorCreator, handler); } @Test @@ -65,7 +68,7 @@ public void givenDrmTypeWidevineModularStream_whenCreatingDrmSessionCreator_then @Test public void givenDrmTypeWidevineModularStream_andAndroidVersionDoesNotSupportMediaDrmApis_whenCreatingDrmSessionCreator_thenThrowsUnableToCreatePlayerException() { - drmSessionCreatorFactory = new DrmSessionCreatorFactory(UNSUPPORTED_MEDIA_DRM_DEVICE_VERSION, handler); + drmSessionCreatorFactory = new DrmSessionCreatorFactory(UNSUPPORTED_MEDIA_DRM_DEVICE_VERSION, provisionExecutorCreator, handler); String message = "Device must be target: 18 but was: 17 for DRM type: WIDEVINE_MODULAR_STREAM"; thrown.expect(ExceptionMatcher.matches(message, PlayerFactory.UnableToCreatePlayerException.class)); @@ -82,7 +85,7 @@ public void givenDrmTypeWidevineModularDownload_whenCreatingDrmSessionCreator_th @Test public void givenDrmTypeWidevineDownloadStream_andAndroidVersionDoesNotSupportMediaDrmApis_whenCreatingDrmSessionCreator_thenThrowsUnableToCreatePlayerException() { - drmSessionCreatorFactory = new DrmSessionCreatorFactory(UNSUPPORTED_MEDIA_DRM_DEVICE_VERSION, handler); + drmSessionCreatorFactory = new DrmSessionCreatorFactory(UNSUPPORTED_MEDIA_DRM_DEVICE_VERSION, provisionExecutorCreator, handler); String message = "Device must be target: 18 but was: 17 for DRM type: WIDEVINE_MODULAR_DOWNLOAD"; thrown.expect(ExceptionMatcher.matches(message, PlayerFactory.UnableToCreatePlayerException.class)); diff --git a/core/src/test/java/com/novoda/noplayer/drm/provision/ProvisionExecutorTest.java b/core/src/test/java/com/novoda/noplayer/drm/provision/ProvisionExecutorImplTest.java similarity index 80% rename from core/src/test/java/com/novoda/noplayer/drm/provision/ProvisionExecutorTest.java rename to core/src/test/java/com/novoda/noplayer/drm/provision/ProvisionExecutorImplTest.java index 44022ab5..6ac4818f 100644 --- a/core/src/test/java/com/novoda/noplayer/drm/provision/ProvisionExecutorTest.java +++ b/core/src/test/java/com/novoda/noplayer/drm/provision/ProvisionExecutorImplTest.java @@ -16,7 +16,7 @@ import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; -public class ProvisionExecutorTest { +public class ProvisionExecutorImplTest { private static final String PROVISION_URL = "http://provisionurl.com"; private static final byte[] PROVISION_DATA = "provision-payload".getBytes(); @@ -25,25 +25,25 @@ public class ProvisionExecutorTest { @Rule public MockitoRule rule = MockitoJUnit.rule(); - private ProvisionExecutor provisionExecutor; + private ProvisionExecutorImpl provisionExecutorImpl; private ArgumentCaptor provisionUrlCaptor; @Mock - private HttpUrlConnectionPoster httpUrlConnectionPoster; + private HttpUrlConnectionPoster httpPoster; @Mock private ProvisioningCapabilities capabilities; @Before public void setUp() { provisionUrlCaptor = ArgumentCaptor.forClass(String.class); - provisionExecutor = new ProvisionExecutor(httpUrlConnectionPoster, capabilities); + provisionExecutorImpl = new ProvisionExecutorImpl(httpPoster, capabilities); } @Test(expected = UnableToProvisionException.class) public void givenNonCapableProvisionCapabilities_whenProvisioning_thenAnUnableToProvisionExceptionIsThrown() throws IOException, UnableToProvisionException { when(capabilities.canProvision()).thenReturn(false); - provisionExecutor.execute(A_PROVISION_REQUEST); + provisionExecutorImpl.execute(A_PROVISION_REQUEST); } @Test @@ -51,8 +51,8 @@ public void givenCapableProvisionCapabilities_whenProvisioning_thenTheRequestUrl when(capabilities.canProvision()).thenReturn(true); String expectedProvisionUrl = PROVISION_URL + "&signedRequest=" + new String(PROVISION_DATA); - provisionExecutor.execute(A_PROVISION_REQUEST); - verify(httpUrlConnectionPoster).post(provisionUrlCaptor.capture()); + provisionExecutorImpl.execute(A_PROVISION_REQUEST); + verify(httpPoster).post(provisionUrlCaptor.capture()); assertThat(provisionUrlCaptor.getValue()).isEqualTo(expectedProvisionUrl); } From 9b575604c8d0369edcf0ceeb44c16e432f0c42ad Mon Sep 17 00:00:00 2001 From: Ryan Feline Date: Tue, 27 Jun 2017 14:41:30 +0100 Subject: [PATCH 10/11] Move SessionId and KeySetId to more appropriate packages. --- .../com/novoda/noplayer/drm/DownloadedModularDrm.java | 2 ++ .../noplayer/exoplayer/drm/FrameworkDrmSession.java | 1 - .../noplayer/exoplayer/drm/InvalidDrmSession.java | 1 - .../novoda/noplayer/exoplayer/drm/LocalDrmSession.java | 3 +-- .../noplayer/exoplayer/drm/LocalDrmSessionManager.java | 3 +-- .../novoda/noplayer/{ => exoplayer}/drm/SessionId.java | 10 +++++----- .../com/novoda/noplayer/{drm => model}/KeySetId.java | 2 +- 7 files changed, 10 insertions(+), 12 deletions(-) rename core/src/main/java/com/novoda/noplayer/{ => exoplayer}/drm/SessionId.java (83%) rename core/src/main/java/com/novoda/noplayer/{drm => model}/KeySetId.java (96%) diff --git a/core/src/main/java/com/novoda/noplayer/drm/DownloadedModularDrm.java b/core/src/main/java/com/novoda/noplayer/drm/DownloadedModularDrm.java index 2db38450..73c80a88 100644 --- a/core/src/main/java/com/novoda/noplayer/drm/DownloadedModularDrm.java +++ b/core/src/main/java/com/novoda/noplayer/drm/DownloadedModularDrm.java @@ -1,5 +1,7 @@ package com.novoda.noplayer.drm; +import com.novoda.noplayer.model.KeySetId; + public interface DownloadedModularDrm extends DrmHandler { KeySetId getKeySetId(); diff --git a/core/src/main/java/com/novoda/noplayer/exoplayer/drm/FrameworkDrmSession.java b/core/src/main/java/com/novoda/noplayer/exoplayer/drm/FrameworkDrmSession.java index 68228b49..19103449 100644 --- a/core/src/main/java/com/novoda/noplayer/exoplayer/drm/FrameworkDrmSession.java +++ b/core/src/main/java/com/novoda/noplayer/exoplayer/drm/FrameworkDrmSession.java @@ -2,7 +2,6 @@ import com.google.android.exoplayer2.drm.DrmSession; import com.google.android.exoplayer2.drm.FrameworkMediaCrypto; -import com.novoda.noplayer.drm.SessionId; interface FrameworkDrmSession extends DrmSession { diff --git a/core/src/main/java/com/novoda/noplayer/exoplayer/drm/InvalidDrmSession.java b/core/src/main/java/com/novoda/noplayer/exoplayer/drm/InvalidDrmSession.java index 6345849d..e76a5714 100644 --- a/core/src/main/java/com/novoda/noplayer/exoplayer/drm/InvalidDrmSession.java +++ b/core/src/main/java/com/novoda/noplayer/exoplayer/drm/InvalidDrmSession.java @@ -4,7 +4,6 @@ import com.google.android.exoplayer2.drm.DrmSession; import com.google.android.exoplayer2.drm.FrameworkMediaCrypto; -import com.novoda.noplayer.drm.SessionId; import java.util.Map; diff --git a/core/src/main/java/com/novoda/noplayer/exoplayer/drm/LocalDrmSession.java b/core/src/main/java/com/novoda/noplayer/exoplayer/drm/LocalDrmSession.java index b339b09a..34032992 100644 --- a/core/src/main/java/com/novoda/noplayer/exoplayer/drm/LocalDrmSession.java +++ b/core/src/main/java/com/novoda/noplayer/exoplayer/drm/LocalDrmSession.java @@ -3,8 +3,7 @@ import android.support.annotation.Nullable; import com.google.android.exoplayer2.drm.FrameworkMediaCrypto; -import com.novoda.noplayer.drm.KeySetId; -import com.novoda.noplayer.drm.SessionId; +import com.novoda.noplayer.model.KeySetId; import java.util.Collections; import java.util.HashMap; diff --git a/core/src/main/java/com/novoda/noplayer/exoplayer/drm/LocalDrmSessionManager.java b/core/src/main/java/com/novoda/noplayer/exoplayer/drm/LocalDrmSessionManager.java index 81189145..71093a35 100644 --- a/core/src/main/java/com/novoda/noplayer/exoplayer/drm/LocalDrmSessionManager.java +++ b/core/src/main/java/com/novoda/noplayer/exoplayer/drm/LocalDrmSessionManager.java @@ -14,8 +14,7 @@ import com.google.android.exoplayer2.drm.DrmSessionManager; import com.google.android.exoplayer2.drm.ExoMediaDrm; import com.google.android.exoplayer2.drm.FrameworkMediaCrypto; -import com.novoda.noplayer.drm.KeySetId; -import com.novoda.noplayer.drm.SessionId; +import com.novoda.noplayer.model.KeySetId; import java.util.UUID; diff --git a/core/src/main/java/com/novoda/noplayer/drm/SessionId.java b/core/src/main/java/com/novoda/noplayer/exoplayer/drm/SessionId.java similarity index 83% rename from core/src/main/java/com/novoda/noplayer/drm/SessionId.java rename to core/src/main/java/com/novoda/noplayer/exoplayer/drm/SessionId.java index 6f1971b9..46a07931 100644 --- a/core/src/main/java/com/novoda/noplayer/drm/SessionId.java +++ b/core/src/main/java/com/novoda/noplayer/exoplayer/drm/SessionId.java @@ -1,16 +1,16 @@ -package com.novoda.noplayer.drm; +package com.novoda.noplayer.exoplayer.drm; import java.util.Arrays; -public class SessionId { +class SessionId { private final byte[] sessionId; - public static SessionId absent() { + static SessionId absent() { return new SessionId(new byte[0]); } - public static SessionId of(byte[] sessionId) { + static SessionId of(byte[] sessionId) { return new SessionId(Arrays.copyOf(sessionId, sessionId.length)); } @@ -18,7 +18,7 @@ private SessionId(byte[] sessionId) { this.sessionId = sessionId; } - public byte[] asBytes() { + byte[] asBytes() { return sessionId; } diff --git a/core/src/main/java/com/novoda/noplayer/drm/KeySetId.java b/core/src/main/java/com/novoda/noplayer/model/KeySetId.java similarity index 96% rename from core/src/main/java/com/novoda/noplayer/drm/KeySetId.java rename to core/src/main/java/com/novoda/noplayer/model/KeySetId.java index 2a652c9d..f987a0fe 100644 --- a/core/src/main/java/com/novoda/noplayer/drm/KeySetId.java +++ b/core/src/main/java/com/novoda/noplayer/model/KeySetId.java @@ -1,4 +1,4 @@ -package com.novoda.noplayer.drm; +package com.novoda.noplayer.model; import java.util.Arrays; From 9252a5d4e77624d168973000f5388c58f38ee09b Mon Sep 17 00:00:00 2001 From: Ryan Feline Date: Tue, 27 Jun 2017 15:23:27 +0100 Subject: [PATCH 11/11] Remove Impl from ProvisionExecutor. --- ...utorImpl.java => HttpPostingProvisionExecutor.java} | 4 ++-- .../drm/provision/ProvisionExecutorCreator.java | 2 +- ...Test.java => HttpPostingProvisionExecutorTest.java} | 10 +++++----- 3 files changed, 8 insertions(+), 8 deletions(-) rename core/src/main/java/com/novoda/noplayer/drm/provision/{ProvisionExecutorImpl.java => HttpPostingProvisionExecutor.java} (86%) rename core/src/test/java/com/novoda/noplayer/drm/provision/{ProvisionExecutorImplTest.java => HttpPostingProvisionExecutorTest.java} (84%) diff --git a/core/src/main/java/com/novoda/noplayer/drm/provision/ProvisionExecutorImpl.java b/core/src/main/java/com/novoda/noplayer/drm/provision/HttpPostingProvisionExecutor.java similarity index 86% rename from core/src/main/java/com/novoda/noplayer/drm/provision/ProvisionExecutorImpl.java rename to core/src/main/java/com/novoda/noplayer/drm/provision/HttpPostingProvisionExecutor.java index 14e36ab1..7d303484 100644 --- a/core/src/main/java/com/novoda/noplayer/drm/provision/ProvisionExecutorImpl.java +++ b/core/src/main/java/com/novoda/noplayer/drm/provision/HttpPostingProvisionExecutor.java @@ -5,14 +5,14 @@ import java.io.IOException; import java.nio.charset.Charset; -class ProvisionExecutorImpl implements ProvisionExecutor { +class HttpPostingProvisionExecutor implements ProvisionExecutor { private static final String PARAMETER_SIGNED_REQUEST = "&signedRequest="; private final HttpUrlConnectionPoster httpPoster; private final ProvisioningCapabilities capabilities; - ProvisionExecutorImpl(HttpUrlConnectionPoster httpPoster, ProvisioningCapabilities capabilities) { + HttpPostingProvisionExecutor(HttpUrlConnectionPoster httpPoster, ProvisioningCapabilities capabilities) { this.httpPoster = httpPoster; this.capabilities = capabilities; } diff --git a/core/src/main/java/com/novoda/noplayer/drm/provision/ProvisionExecutorCreator.java b/core/src/main/java/com/novoda/noplayer/drm/provision/ProvisionExecutorCreator.java index 1e047ebd..8951ae14 100644 --- a/core/src/main/java/com/novoda/noplayer/drm/provision/ProvisionExecutorCreator.java +++ b/core/src/main/java/com/novoda/noplayer/drm/provision/ProvisionExecutorCreator.java @@ -5,6 +5,6 @@ public class ProvisionExecutorCreator { public ProvisionExecutor create() { HttpUrlConnectionPoster httpPoster = new HttpUrlConnectionPoster(); ProvisioningCapabilities capabilities = ProvisioningCapabilities.newInstance(); - return new ProvisionExecutorImpl(httpPoster, capabilities); + return new HttpPostingProvisionExecutor(httpPoster, capabilities); } } diff --git a/core/src/test/java/com/novoda/noplayer/drm/provision/ProvisionExecutorImplTest.java b/core/src/test/java/com/novoda/noplayer/drm/provision/HttpPostingProvisionExecutorTest.java similarity index 84% rename from core/src/test/java/com/novoda/noplayer/drm/provision/ProvisionExecutorImplTest.java rename to core/src/test/java/com/novoda/noplayer/drm/provision/HttpPostingProvisionExecutorTest.java index 6ac4818f..5e719378 100644 --- a/core/src/test/java/com/novoda/noplayer/drm/provision/ProvisionExecutorImplTest.java +++ b/core/src/test/java/com/novoda/noplayer/drm/provision/HttpPostingProvisionExecutorTest.java @@ -16,7 +16,7 @@ import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; -public class ProvisionExecutorImplTest { +public class HttpPostingProvisionExecutorTest { private static final String PROVISION_URL = "http://provisionurl.com"; private static final byte[] PROVISION_DATA = "provision-payload".getBytes(); @@ -25,7 +25,7 @@ public class ProvisionExecutorImplTest { @Rule public MockitoRule rule = MockitoJUnit.rule(); - private ProvisionExecutorImpl provisionExecutorImpl; + private HttpPostingProvisionExecutor httpPostingProvisionExecutor; private ArgumentCaptor provisionUrlCaptor; @Mock @@ -36,14 +36,14 @@ public class ProvisionExecutorImplTest { @Before public void setUp() { provisionUrlCaptor = ArgumentCaptor.forClass(String.class); - provisionExecutorImpl = new ProvisionExecutorImpl(httpPoster, capabilities); + httpPostingProvisionExecutor = new HttpPostingProvisionExecutor(httpPoster, capabilities); } @Test(expected = UnableToProvisionException.class) public void givenNonCapableProvisionCapabilities_whenProvisioning_thenAnUnableToProvisionExceptionIsThrown() throws IOException, UnableToProvisionException { when(capabilities.canProvision()).thenReturn(false); - provisionExecutorImpl.execute(A_PROVISION_REQUEST); + httpPostingProvisionExecutor.execute(A_PROVISION_REQUEST); } @Test @@ -51,7 +51,7 @@ public void givenCapableProvisionCapabilities_whenProvisioning_thenTheRequestUrl when(capabilities.canProvision()).thenReturn(true); String expectedProvisionUrl = PROVISION_URL + "&signedRequest=" + new String(PROVISION_DATA); - provisionExecutorImpl.execute(A_PROVISION_REQUEST); + httpPostingProvisionExecutor.execute(A_PROVISION_REQUEST); verify(httpPoster).post(provisionUrlCaptor.capture()); assertThat(provisionUrlCaptor.getValue()).isEqualTo(expectedProvisionUrl);