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

Commit

Permalink
Merge pull request #161 from novoda/update-exoplayer-2.8.1
Browse files Browse the repository at this point in the history
Update ExoPlayer to latest v2.8.1
  • Loading branch information
ouchadam authored Jun 7, 2018
2 parents b2726f6 + 81369a6 commit 96c267c
Show file tree
Hide file tree
Showing 36 changed files with 1,380 additions and 686 deletions.
2 changes: 1 addition & 1 deletion core/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ android {
}

dependencies {
implementation 'com.google.android.exoplayer:exoplayer:2.7.3'
implementation 'com.google.android.exoplayer:exoplayer:2.8.1'

testImplementation 'junit:junit:4.12'
testImplementation 'org.mockito:mockito-core:2.16.0'
Expand Down
1 change: 0 additions & 1 deletion core/src/main/java/com/novoda/noplayer/OptionsBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -59,5 +59,4 @@ public OptionsBuilder withMaxInitialBitrate(int maxInitialBitrate) {
public Options build() {
return new Options(contentType, minDurationBeforeQualityIncreaseInMillis, maxInitialBitrate);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import com.google.android.exoplayer2.trackselection.AdaptiveTrackSelection;
import com.google.android.exoplayer2.trackselection.DefaultTrackSelector;
import com.google.android.exoplayer2.trackselection.FixedTrackSelection;
import com.google.android.exoplayer2.trackselection.TrackSelection;
import com.google.android.exoplayer2.upstream.DefaultBandwidthMeter;
import com.google.android.exoplayer2.util.Clock;
Expand All @@ -14,16 +13,9 @@

class CompositeTrackSelectorCreator {

private final DefaultBandwidthMeter bandwidthMeter;

CompositeTrackSelectorCreator(DefaultBandwidthMeter bandwidthMeter) {
this.bandwidthMeter = bandwidthMeter;
}

CompositeTrackSelector create(Options options) {
CompositeTrackSelector create(Options options, DefaultBandwidthMeter bandwidthMeter) {
TrackSelection.Factory adaptiveTrackSelectionFactory = new AdaptiveTrackSelection.Factory(
bandwidthMeter,
options.maxInitialBitrate(),
options.minDurationBeforeQualityIncreaseInMillis(),
AdaptiveTrackSelection.DEFAULT_MAX_DURATION_FOR_QUALITY_DECREASE_MS,
AdaptiveTrackSelection.DEFAULT_MIN_DURATION_TO_RETAIN_AFTER_DISCARD_MS,
Expand All @@ -35,13 +27,9 @@ CompositeTrackSelector create(Options options) {
DefaultTrackSelector trackSelector = new DefaultTrackSelector(adaptiveTrackSelectionFactory);

ExoPlayerTrackSelector exoPlayerTrackSelector = ExoPlayerTrackSelector.newInstance(trackSelector);
FixedTrackSelection.Factory trackSelectionFactory = new FixedTrackSelection.Factory();
ExoPlayerAudioTrackSelector audioTrackSelector = new ExoPlayerAudioTrackSelector(exoPlayerTrackSelector, trackSelectionFactory);
ExoPlayerVideoTrackSelector videoTrackSelector = new ExoPlayerVideoTrackSelector(exoPlayerTrackSelector, trackSelectionFactory);
ExoPlayerSubtitleTrackSelector subtitleTrackSelector = new ExoPlayerSubtitleTrackSelector(
exoPlayerTrackSelector,
trackSelectionFactory
);
ExoPlayerAudioTrackSelector audioTrackSelector = new ExoPlayerAudioTrackSelector(exoPlayerTrackSelector);
ExoPlayerVideoTrackSelector videoTrackSelector = new ExoPlayerVideoTrackSelector(exoPlayerTrackSelector);
ExoPlayerSubtitleTrackSelector subtitleTrackSelector = new ExoPlayerSubtitleTrackSelector(exoPlayerTrackSelector);
return new CompositeTrackSelector(trackSelector, audioTrackSelector, videoTrackSelector, subtitleTrackSelector);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
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.DefaultDrmSessionEventListener;
import com.google.android.exoplayer2.drm.DrmSessionManager;
import com.google.android.exoplayer2.drm.FrameworkMediaCrypto;
import com.google.android.exoplayer2.mediacodec.MediaCodecSelector;
Expand All @@ -30,21 +30,20 @@ class ExoPlayerCreator {

@NonNull
public SimpleExoPlayer create(DrmSessionCreator drmSessionCreator,
DefaultDrmSessionManager.EventListener drmSessionEventListener,
DefaultDrmSessionEventListener drmSessionEventListener,
MediaCodecSelector mediaCodecSelector,
TrackSelector trackSelector) {
DrmSessionManager<FrameworkMediaCrypto> drmSessionManager = drmSessionCreator.create(drmSessionEventListener);
SubtitleDecoderFactory subtitleDecoderFactory = new NoPlayerSubtitleDecoderFactory();
RenderersFactory renderersFactory = new SimpleRenderersFactory(
context,
drmSessionManager,
EXTENSION_RENDERER_MODE_OFF,
DEFAULT_ALLOWED_VIDEO_JOINING_TIME_MS,
mediaCodecSelector,
subtitleDecoderFactory
);

DefaultLoadControl loadControl = new DefaultLoadControl();
return ExoPlayerFactory.newSimpleInstance(renderersFactory, trackSelector, loadControl);
return ExoPlayerFactory.newSimpleInstance(renderersFactory, trackSelector, loadControl, drmSessionManager);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,13 @@

import android.net.Uri;
import android.support.annotation.Nullable;

import com.google.android.exoplayer2.Player;
import com.google.android.exoplayer2.SimpleExoPlayer;
import com.google.android.exoplayer2.audio.AudioAttributes;
import com.google.android.exoplayer2.mediacodec.MediaCodecSelector;
import com.google.android.exoplayer2.source.MediaSource;
import com.google.android.exoplayer2.upstream.DefaultBandwidthMeter;
import com.novoda.noplayer.Options;
import com.novoda.noplayer.PlayerSurfaceHolder;
import com.novoda.noplayer.internal.exoplayer.drm.DrmSessionCreator;
Expand Down Expand Up @@ -106,7 +108,12 @@ void loadVideo(PlayerSurfaceHolder playerSurfaceHolder,
ExoPlayerForwarder forwarder,
MediaCodecSelector mediaCodecSelector) {
this.options = options;
compositeTrackSelector = trackSelectorCreator.create(options);

DefaultBandwidthMeter bandwidthMeter = new DefaultBandwidthMeter.Builder()
.setInitialBitrateEstimate(options.maxInitialBitrate())
.build();

compositeTrackSelector = trackSelectorCreator.create(options, bandwidthMeter);
exoPlayer = exoPlayerCreator.create(
drmSessionCreator,
forwarder.drmSessionEventListener(),
Expand All @@ -115,15 +122,15 @@ void loadVideo(PlayerSurfaceHolder playerSurfaceHolder,
);
rendererTypeRequester = rendererTypeRequesterCreator.createfrom(exoPlayer);
exoPlayer.addListener(forwarder.exoPlayerEventListener());
exoPlayer.setVideoDebugListener(forwarder.videoRendererEventListener());
exoPlayer.addAnalyticsListener(forwarder.analyticsListener());

setMovieAudioAttributes(exoPlayer);

MediaSource mediaSource = mediaSourceFactory.create(
options.contentType(),
options,
uri,
forwarder.extractorMediaSourceListener(),
forwarder.mediaSourceEventListener()
forwarder.mediaSourceEventListener(),
bandwidthMeter
);
attachToSurface(playerSurfaceHolder);
exoPlayer.prepare(mediaSource, RESET_POSITION, DO_NOT_RESET_STATE);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
import android.os.Handler;

import com.google.android.exoplayer2.mediacodec.MediaCodecSelector;
import com.google.android.exoplayer2.upstream.DefaultBandwidthMeter;
import com.google.android.exoplayer2.upstream.DefaultDataSourceFactory;
import com.novoda.noplayer.NoPlayer;
import com.novoda.noplayer.internal.Heart;
import com.novoda.noplayer.internal.SystemClock;
Expand Down Expand Up @@ -44,15 +42,13 @@ static class InternalCreator {
}

ExoPlayerTwoImpl create(Context context, DrmSessionCreator drmSessionCreator, boolean downgradeSecureDecoder) {
DefaultBandwidthMeter bandwidthMeter = new DefaultBandwidthMeter();
DefaultDataSourceFactory defaultDataSourceFactory = new DefaultDataSourceFactory(context, "user-agent", bandwidthMeter);
MediaSourceFactory mediaSourceFactory = new MediaSourceFactory(defaultDataSourceFactory, handler);
MediaSourceFactory mediaSourceFactory = new MediaSourceFactory(context, handler);

MediaCodecSelector mediaCodecSelector = downgradeSecureDecoder
? SecurityDowngradingCodecSelector.newInstance()
: MediaCodecSelector.DEFAULT;

CompositeTrackSelectorCreator trackSelectorCreator = new CompositeTrackSelectorCreator(bandwidthMeter);
CompositeTrackSelectorCreator trackSelectorCreator = new CompositeTrackSelectorCreator();

ExoPlayerCreator exoPlayerCreator = new ExoPlayerCreator(context);
RendererTypeRequesterCreator rendererTypeRequesterCreator = new RendererTypeRequesterCreator();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import android.os.Handler;
import android.os.Looper;
import android.support.annotation.IntDef;
import android.support.annotation.Nullable;
import android.util.Log;

import com.google.android.exoplayer2.Renderer;
Expand Down Expand Up @@ -90,8 +91,6 @@ class SimpleRenderersFactory implements RenderersFactory {

private final Context context;

private final DrmSessionManager<FrameworkMediaCrypto> drmSessionManager;

@ExtensionRendererMode
private final int extensionRendererMode;

Expand All @@ -101,8 +100,6 @@ class SimpleRenderersFactory implements RenderersFactory {

/**
* @param context A {@link Context}.
* @param drmSessionManager An optional {@link DrmSessionManager}. May be null if DRM protected
* playbacks are not required..
* @param extensionRendererMode The extension renderer mode, which determines if and how
* available extension renderers are used. Note that extensions must be included in the
* application build for them to be considered available.
Expand All @@ -112,13 +109,11 @@ class SimpleRenderersFactory implements RenderersFactory {
* @param subtitleDecoderFactory A factory from which to obtain {@link SubtitleDecoder} instances.
*/
SimpleRenderersFactory(Context context,
DrmSessionManager<FrameworkMediaCrypto> drmSessionManager,
@ExtensionRendererMode int extensionRendererMode,
long allowedVideoJoiningTimeMs,
MediaCodecSelector mediaCodecSelector,
SubtitleDecoderFactory subtitleDecoderFactory) {
this.context = context;
this.drmSessionManager = drmSessionManager;
this.extensionRendererMode = extensionRendererMode;
this.allowedVideoJoiningTimeMs = allowedVideoJoiningTimeMs;
this.mediaCodecSelector = mediaCodecSelector;
Expand All @@ -130,7 +125,8 @@ public Renderer[] createRenderers(Handler eventHandler,
VideoRendererEventListener videoRendererEventListener,
AudioRendererEventListener audioRendererEventListener,
TextOutput textRendererOutput,
MetadataOutput metadataRendererOutput) {
MetadataOutput metadataRendererOutput,
@Nullable DrmSessionManager<FrameworkMediaCrypto> drmSessionManager) {
ArrayList<Renderer> renderersList = new ArrayList<>();
buildVideoRenderers(context, drmSessionManager, allowedVideoJoiningTimeMs,
eventHandler, videoRendererEventListener, extensionRendererMode, renderersList);
Expand Down Expand Up @@ -219,13 +215,18 @@ private void buildAudioRenderers(Context context,
AudioRendererEventListener eventListener,
@ExtensionRendererMode int extensionRendererMode,
List<Renderer> outRenderers) {
outRenderers.add(new MediaCodecAudioRenderer(mediaCodecSelector,
MediaCodecAudioRenderer mediaCodecAudioRenderer = new MediaCodecAudioRenderer(
context,
mediaCodecSelector,
drmSessionManager,
PLAY_CLEAR_SAMPLES_WITHOUT_KEYS,
eventHandler,
eventListener,
AudioCapabilities.getCapabilities(context),
audioProcessors));
audioProcessors
);

outRenderers.add(mediaCodecAudioRenderer);

if (extensionRendererMode == EXTENSION_RENDERER_MODE_OFF) {
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import android.os.Handler;

import com.google.android.exoplayer2.drm.DefaultDrmSessionManager;
import com.google.android.exoplayer2.drm.DefaultDrmSessionEventListener;
import com.google.android.exoplayer2.drm.DrmSessionManager;
import com.google.android.exoplayer2.drm.FrameworkMediaCrypto;
import com.novoda.noplayer.drm.DownloadedModularDrm;
Expand All @@ -20,7 +20,7 @@ class DownloadDrmSessionCreator implements DrmSessionCreator {
}

@Override
public DrmSessionManager<FrameworkMediaCrypto> create(DefaultDrmSessionManager.EventListener eventListener) {
public DrmSessionManager<FrameworkMediaCrypto> create(DefaultDrmSessionEventListener eventListener) {
return new LocalDrmSessionManager(
downloadedModularDrm.getKeySetId(),
mediaDrmCreator.create(WIDEVINE_MODULAR_UUID),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import android.support.annotation.Nullable;

import com.google.android.exoplayer2.drm.DefaultDrmSessionManager;
import com.google.android.exoplayer2.drm.DefaultDrmSessionEventListener;
import com.google.android.exoplayer2.drm.DrmSessionManager;
import com.google.android.exoplayer2.drm.FrameworkMediaCrypto;

Expand All @@ -13,5 +13,5 @@ public interface DrmSessionCreator {
UUID WIDEVINE_MODULAR_UUID = new UUID(0xEDEF8BA979D64ACEL, 0xA3C827DCD51D21EDL);

@Nullable
DrmSessionManager<FrameworkMediaCrypto> create(DefaultDrmSessionManager.EventListener eventListener);
DrmSessionManager<FrameworkMediaCrypto> create(DefaultDrmSessionEventListener eventListener);
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import android.os.Handler;
import android.os.Looper;

import com.google.android.exoplayer2.drm.DefaultDrmSessionManager;
import com.google.android.exoplayer2.drm.DefaultDrmSessionEventListener;
import com.google.android.exoplayer2.drm.DrmInitData;
import com.google.android.exoplayer2.drm.DrmSession;
import com.google.android.exoplayer2.drm.DrmSessionManager;
Expand All @@ -19,15 +19,15 @@ class LocalDrmSessionManager implements DrmSessionManager<FrameworkMediaCrypto>

private final KeySetId keySetIdToRestore;
private final ExoMediaDrm<FrameworkMediaCrypto> mediaDrm;
private final DefaultDrmSessionManager.EventListener eventListener;
private final DefaultDrmSessionEventListener eventListener;
private final UUID drmScheme;
private final Handler handler;

LocalDrmSessionManager(KeySetId keySetIdToRestore,
ExoMediaDrm<FrameworkMediaCrypto> mediaDrm,
UUID drmScheme,
Handler handler,
DefaultDrmSessionManager.EventListener eventListener) {
DefaultDrmSessionEventListener eventListener) {
this.keySetIdToRestore = keySetIdToRestore;
this.mediaDrm = mediaDrm;
this.eventListener = eventListener;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import android.support.annotation.Nullable;

import com.google.android.exoplayer2.drm.DefaultDrmSessionManager;
import com.google.android.exoplayer2.drm.DefaultDrmSessionEventListener;
import com.google.android.exoplayer2.drm.DrmSessionManager;
import com.google.android.exoplayer2.drm.FrameworkMediaCrypto;

Expand All @@ -12,7 +12,7 @@ class NoDrmSessionCreator implements DrmSessionCreator {

@Nullable
@Override
public DrmSessionManager<FrameworkMediaCrypto> create(DefaultDrmSessionManager.EventListener eventListener) {
public DrmSessionManager<FrameworkMediaCrypto> create(DefaultDrmSessionEventListener eventListener) {
return NO_DRM_SESSION;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import android.os.Handler;

import com.google.android.exoplayer2.drm.DefaultDrmSessionEventListener;
import com.google.android.exoplayer2.drm.DefaultDrmSessionManager;
import com.google.android.exoplayer2.drm.DrmSessionManager;
import com.google.android.exoplayer2.drm.FrameworkMediaCrypto;
Expand All @@ -26,16 +27,18 @@ class StreamingDrmSessionCreator implements DrmSessionCreator {
}

@Override
public DrmSessionManager<FrameworkMediaCrypto> create(DefaultDrmSessionManager.EventListener eventListener) {
public DrmSessionManager<FrameworkMediaCrypto> create(DefaultDrmSessionEventListener eventListener) {
FrameworkMediaDrm frameworkMediaDrm = frameworkMediaDrmCreator.create(WIDEVINE_MODULAR_UUID);

return new DefaultDrmSessionManager<>(
DefaultDrmSessionManager<FrameworkMediaCrypto> defaultDrmSessionManager = new DefaultDrmSessionManager<>(
WIDEVINE_MODULAR_UUID,
frameworkMediaDrm,
mediaDrmCallback,
NO_OPTIONAL_PARAMETERS,
handler,
eventListener
NO_OPTIONAL_PARAMETERS
);
defaultDrmSessionManager.removeListener(eventListener);
defaultDrmSessionManager.addListener(handler, eventListener);

return defaultDrmSessionManager;
}
}
Loading

0 comments on commit 96c267c

Please sign in to comment.