Commit 561949a2 by tonihei Committed by Oliver Woodman

Remove AnalyticsCollector.Factory.

This factory was only needed in the past when we didn't have
AnalyticsCollector.setPlayer. Code becomes easier to use without this factory.

PiperOrigin-RevId: 261081860
parent 526cc72e
...@@ -25,6 +25,8 @@ ...@@ -25,6 +25,8 @@
management in playlists. management in playlists.
* Improve text selection logic to always prefer the better language matches * Improve text selection logic to always prefer the better language matches
over other selection parameters. over other selection parameters.
* Remove `AnalyticsCollector.Factory`. Instances can be created directly and
the `Player` set later using `AnalyticsCollector.setPlayer`.
### 2.10.4 ### ### 2.10.4 ###
......
...@@ -244,7 +244,7 @@ public final class ExoPlayerFactory { ...@@ -244,7 +244,7 @@ public final class ExoPlayerFactory {
loadControl, loadControl,
drmSessionManager, drmSessionManager,
bandwidthMeter, bandwidthMeter,
new AnalyticsCollector.Factory(), new AnalyticsCollector(Clock.DEFAULT),
Util.getLooper()); Util.getLooper());
} }
...@@ -257,8 +257,8 @@ public final class ExoPlayerFactory { ...@@ -257,8 +257,8 @@ public final class ExoPlayerFactory {
* @param loadControl The {@link LoadControl} that will be used by the instance. * @param loadControl The {@link LoadControl} that will be used by the instance.
* @param drmSessionManager An optional {@link DrmSessionManager}. May be null if the instance * @param drmSessionManager An optional {@link DrmSessionManager}. May be null if the instance
* will not be used for DRM protected playbacks. * will not be used for DRM protected playbacks.
* @param analyticsCollectorFactory A factory for creating the {@link AnalyticsCollector} that * @param analyticsCollector The {@link AnalyticsCollector} that will collect and forward all
* will collect and forward all player events. * player events.
*/ */
public static SimpleExoPlayer newSimpleInstance( public static SimpleExoPlayer newSimpleInstance(
Context context, Context context,
...@@ -266,14 +266,14 @@ public final class ExoPlayerFactory { ...@@ -266,14 +266,14 @@ public final class ExoPlayerFactory {
TrackSelector trackSelector, TrackSelector trackSelector,
LoadControl loadControl, LoadControl loadControl,
@Nullable DrmSessionManager<FrameworkMediaCrypto> drmSessionManager, @Nullable DrmSessionManager<FrameworkMediaCrypto> drmSessionManager,
AnalyticsCollector.Factory analyticsCollectorFactory) { AnalyticsCollector analyticsCollector) {
return newSimpleInstance( return newSimpleInstance(
context, context,
renderersFactory, renderersFactory,
trackSelector, trackSelector,
loadControl, loadControl,
drmSessionManager, drmSessionManager,
analyticsCollectorFactory, analyticsCollector,
Util.getLooper()); Util.getLooper());
} }
...@@ -302,7 +302,7 @@ public final class ExoPlayerFactory { ...@@ -302,7 +302,7 @@ public final class ExoPlayerFactory {
trackSelector, trackSelector,
loadControl, loadControl,
drmSessionManager, drmSessionManager,
new AnalyticsCollector.Factory(), new AnalyticsCollector(Clock.DEFAULT),
looper); looper);
} }
...@@ -315,8 +315,8 @@ public final class ExoPlayerFactory { ...@@ -315,8 +315,8 @@ public final class ExoPlayerFactory {
* @param loadControl The {@link LoadControl} that will be used by the instance. * @param loadControl The {@link LoadControl} that will be used by the instance.
* @param drmSessionManager An optional {@link DrmSessionManager}. May be null if the instance * @param drmSessionManager An optional {@link DrmSessionManager}. May be null if the instance
* will not be used for DRM protected playbacks. * will not be used for DRM protected playbacks.
* @param analyticsCollectorFactory A factory for creating the {@link AnalyticsCollector} that * @param analyticsCollector The {@link AnalyticsCollector} that will collect and forward all
* will collect and forward all player events. * player events.
* @param looper The {@link Looper} which must be used for all calls to the player and which is * @param looper The {@link Looper} which must be used for all calls to the player and which is
* used to call listeners on. * used to call listeners on.
*/ */
...@@ -326,7 +326,7 @@ public final class ExoPlayerFactory { ...@@ -326,7 +326,7 @@ public final class ExoPlayerFactory {
TrackSelector trackSelector, TrackSelector trackSelector,
LoadControl loadControl, LoadControl loadControl,
@Nullable DrmSessionManager<FrameworkMediaCrypto> drmSessionManager, @Nullable DrmSessionManager<FrameworkMediaCrypto> drmSessionManager,
AnalyticsCollector.Factory analyticsCollectorFactory, AnalyticsCollector analyticsCollector,
Looper looper) { Looper looper) {
return newSimpleInstance( return newSimpleInstance(
context, context,
...@@ -335,7 +335,7 @@ public final class ExoPlayerFactory { ...@@ -335,7 +335,7 @@ public final class ExoPlayerFactory {
loadControl, loadControl,
drmSessionManager, drmSessionManager,
getDefaultBandwidthMeter(context), getDefaultBandwidthMeter(context),
analyticsCollectorFactory, analyticsCollector,
looper); looper);
} }
...@@ -348,8 +348,8 @@ public final class ExoPlayerFactory { ...@@ -348,8 +348,8 @@ public final class ExoPlayerFactory {
* @param loadControl The {@link LoadControl} that will be used by the instance. * @param loadControl The {@link LoadControl} that will be used by the instance.
* @param drmSessionManager An optional {@link DrmSessionManager}. May be null if the instance * @param drmSessionManager An optional {@link DrmSessionManager}. May be null if the instance
* will not be used for DRM protected playbacks. * will not be used for DRM protected playbacks.
* @param analyticsCollectorFactory A factory for creating the {@link AnalyticsCollector} that * @param analyticsCollector The {@link AnalyticsCollector} that will collect and forward all
* will collect and forward all player events. * player events.
* @param looper The {@link Looper} which must be used for all calls to the player and which is * @param looper The {@link Looper} which must be used for all calls to the player and which is
* used to call listeners on. * used to call listeners on.
*/ */
...@@ -360,7 +360,7 @@ public final class ExoPlayerFactory { ...@@ -360,7 +360,7 @@ public final class ExoPlayerFactory {
LoadControl loadControl, LoadControl loadControl,
@Nullable DrmSessionManager<FrameworkMediaCrypto> drmSessionManager, @Nullable DrmSessionManager<FrameworkMediaCrypto> drmSessionManager,
BandwidthMeter bandwidthMeter, BandwidthMeter bandwidthMeter,
AnalyticsCollector.Factory analyticsCollectorFactory, AnalyticsCollector analyticsCollector,
Looper looper) { Looper looper) {
return new SimpleExoPlayer( return new SimpleExoPlayer(
context, context,
...@@ -369,7 +369,7 @@ public final class ExoPlayerFactory { ...@@ -369,7 +369,7 @@ public final class ExoPlayerFactory {
loadControl, loadControl,
drmSessionManager, drmSessionManager,
bandwidthMeter, bandwidthMeter,
analyticsCollectorFactory, analyticsCollector,
looper); looper);
} }
......
...@@ -144,7 +144,7 @@ public class SimpleExoPlayer extends BasePlayer ...@@ -144,7 +144,7 @@ public class SimpleExoPlayer extends BasePlayer
loadControl, loadControl,
drmSessionManager, drmSessionManager,
bandwidthMeter, bandwidthMeter,
new AnalyticsCollector.Factory(), new AnalyticsCollector(Clock.DEFAULT),
looper); looper);
} }
...@@ -156,8 +156,8 @@ public class SimpleExoPlayer extends BasePlayer ...@@ -156,8 +156,8 @@ public class SimpleExoPlayer extends BasePlayer
* @param drmSessionManager An optional {@link DrmSessionManager}. May be null if the instance * @param drmSessionManager An optional {@link DrmSessionManager}. May be null if the instance
* will not be used for DRM protected playbacks. * will not be used for DRM protected playbacks.
* @param bandwidthMeter The {@link BandwidthMeter} that will be used by the instance. * @param bandwidthMeter The {@link BandwidthMeter} that will be used by the instance.
* @param analyticsCollectorFactory A factory for creating the {@link AnalyticsCollector} that * @param analyticsCollector The {@link AnalyticsCollector} that will collect and forward all
* will collect and forward all player events. * player events.
* @param looper The {@link Looper} which must be used for all calls to the player and which is * @param looper The {@link Looper} which must be used for all calls to the player and which is
* used to call listeners on. * used to call listeners on.
*/ */
...@@ -168,7 +168,7 @@ public class SimpleExoPlayer extends BasePlayer ...@@ -168,7 +168,7 @@ public class SimpleExoPlayer extends BasePlayer
LoadControl loadControl, LoadControl loadControl,
@Nullable DrmSessionManager<FrameworkMediaCrypto> drmSessionManager, @Nullable DrmSessionManager<FrameworkMediaCrypto> drmSessionManager,
BandwidthMeter bandwidthMeter, BandwidthMeter bandwidthMeter,
AnalyticsCollector.Factory analyticsCollectorFactory, AnalyticsCollector analyticsCollector,
Looper looper) { Looper looper) {
this( this(
context, context,
...@@ -177,7 +177,7 @@ public class SimpleExoPlayer extends BasePlayer ...@@ -177,7 +177,7 @@ public class SimpleExoPlayer extends BasePlayer
loadControl, loadControl,
drmSessionManager, drmSessionManager,
bandwidthMeter, bandwidthMeter,
analyticsCollectorFactory, analyticsCollector,
Clock.DEFAULT, Clock.DEFAULT,
looper); looper);
} }
...@@ -190,8 +190,8 @@ public class SimpleExoPlayer extends BasePlayer ...@@ -190,8 +190,8 @@ public class SimpleExoPlayer extends BasePlayer
* @param drmSessionManager An optional {@link DrmSessionManager}. May be null if the instance * @param drmSessionManager An optional {@link DrmSessionManager}. May be null if the instance
* will not be used for DRM protected playbacks. * will not be used for DRM protected playbacks.
* @param bandwidthMeter The {@link BandwidthMeter} that will be used by the instance. * @param bandwidthMeter The {@link BandwidthMeter} that will be used by the instance.
* @param analyticsCollectorFactory A factory for creating the {@link AnalyticsCollector} that * @param analyticsCollector The {@link AnalyticsCollector} that will collect and forward all
* will collect and forward all player events. * player events.
* @param clock The {@link Clock} that will be used by the instance. Should always be {@link * @param clock The {@link Clock} that will be used by the instance. Should always be {@link
* Clock#DEFAULT}, unless the player is being used from a test. * Clock#DEFAULT}, unless the player is being used from a test.
* @param looper The {@link Looper} which must be used for all calls to the player and which is * @param looper The {@link Looper} which must be used for all calls to the player and which is
...@@ -204,10 +204,11 @@ public class SimpleExoPlayer extends BasePlayer ...@@ -204,10 +204,11 @@ public class SimpleExoPlayer extends BasePlayer
LoadControl loadControl, LoadControl loadControl,
@Nullable DrmSessionManager<FrameworkMediaCrypto> drmSessionManager, @Nullable DrmSessionManager<FrameworkMediaCrypto> drmSessionManager,
BandwidthMeter bandwidthMeter, BandwidthMeter bandwidthMeter,
AnalyticsCollector.Factory analyticsCollectorFactory, AnalyticsCollector analyticsCollector,
Clock clock, Clock clock,
Looper looper) { Looper looper) {
this.bandwidthMeter = bandwidthMeter; this.bandwidthMeter = bandwidthMeter;
this.analyticsCollector = analyticsCollector;
componentListener = new ComponentListener(); componentListener = new ComponentListener();
videoListeners = new CopyOnWriteArraySet<>(); videoListeners = new CopyOnWriteArraySet<>();
audioListeners = new CopyOnWriteArraySet<>(); audioListeners = new CopyOnWriteArraySet<>();
...@@ -235,7 +236,7 @@ public class SimpleExoPlayer extends BasePlayer ...@@ -235,7 +236,7 @@ public class SimpleExoPlayer extends BasePlayer
// Build the player and associated objects. // Build the player and associated objects.
player = player =
new ExoPlayerImpl(renderers, trackSelector, loadControl, bandwidthMeter, clock, looper); new ExoPlayerImpl(renderers, trackSelector, loadControl, bandwidthMeter, clock, looper);
analyticsCollector = analyticsCollectorFactory.createAnalyticsCollector(player, clock); analyticsCollector.setPlayer(player);
addListener(analyticsCollector); addListener(analyticsCollector);
addListener(componentListener); addListener(componentListener);
videoDebugListeners.add(analyticsCollector); videoDebugListeners.add(analyticsCollector);
......
...@@ -67,23 +67,6 @@ public class AnalyticsCollector ...@@ -67,23 +67,6 @@ public class AnalyticsCollector
VideoListener, VideoListener,
AudioListener { AudioListener {
/** Factory for an analytics collector. */
public static class Factory {
/**
* Creates an analytics collector for the specified player.
*
* @param player The {@link Player} for which data will be collected. Can be null, if the player
* is set by calling {@link AnalyticsCollector#setPlayer(Player)} before using the analytics
* collector.
* @param clock A {@link Clock} used to generate timestamps.
* @return An analytics collector.
*/
public AnalyticsCollector createAnalyticsCollector(@Nullable Player player, Clock clock) {
return new AnalyticsCollector(player, clock);
}
}
private final CopyOnWriteArraySet<AnalyticsListener> listeners; private final CopyOnWriteArraySet<AnalyticsListener> listeners;
private final Clock clock; private final Clock clock;
private final Window window; private final Window window;
...@@ -92,17 +75,11 @@ public class AnalyticsCollector ...@@ -92,17 +75,11 @@ public class AnalyticsCollector
private @MonotonicNonNull Player player; private @MonotonicNonNull Player player;
/** /**
* Creates an analytics collector for the specified player. * Creates an analytics collector.
* *
* @param player The {@link Player} for which data will be collected. Can be null, if the player
* is set by calling {@link AnalyticsCollector#setPlayer(Player)} before using the analytics
* collector.
* @param clock A {@link Clock} used to generate timestamps. * @param clock A {@link Clock} used to generate timestamps.
*/ */
protected AnalyticsCollector(@Nullable Player player, Clock clock) { public AnalyticsCollector(Clock clock) {
if (player != null) {
this.player = player;
}
this.clock = Assertions.checkNotNull(clock); this.clock = Assertions.checkNotNull(clock);
listeners = new CopyOnWriteArraySet<>(); listeners = new CopyOnWriteArraySet<>();
mediaPeriodQueueTracker = new MediaPeriodQueueTracker(); mediaPeriodQueueTracker = new MediaPeriodQueueTracker();
......
...@@ -622,7 +622,7 @@ public final class ExoPlayerTestRunner implements Player.EventListener, ActionSc ...@@ -622,7 +622,7 @@ public final class ExoPlayerTestRunner implements Player.EventListener, ActionSc
loadControl, loadControl,
/* drmSessionManager= */ null, /* drmSessionManager= */ null,
bandwidthMeter, bandwidthMeter,
new AnalyticsCollector.Factory(), new AnalyticsCollector(clock),
clock, clock,
Looper.myLooper()); Looper.myLooper());
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment