Created
April 6, 2020 10:57
-
-
Save kyawhtut-cu/fb955ac762061de787071d70c506de03 to your computer and use it in GitHub Desktop.
Dash file helper
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// Decompiled by Procyon - 6961ms | |
// | |
package com.conax.client.integrationlayer.internal; | |
import com.conax.client.integrationlayer.api.PlaybackErrorListener; | |
import com.google.android.exoplayer2.source.MediaSource; | |
import com.google.android.exoplayer2.source.dash.DashChunkSource$Factory; | |
import com.google.android.exoplayer2.source.dash.DashMediaSource$Factory; | |
import com.google.android.exoplayer2.source.dash.DefaultDashChunkSource$Factory; | |
import com.google.android.exoplayer2.upstream.DataSource$Factory; | |
import com.google.android.exoplayer2.upstream.DefaultDataSourceFactory; | |
import com.google.android.exoplayer2.upstream.TransferListener; | |
import com.google.android.exoplayer2.upstream.DefaultHttpDataSourceFactory; | |
import com.google.android.exoplayer2.text.TextOutput; | |
import com.google.android.exoplayer2.analytics.AnalyticsListener; | |
import com.google.android.exoplayer2.trackselection.MappingTrackSelector; | |
import com.google.android.exoplayer2.drm.DrmSessionManager; | |
import com.google.android.exoplayer2.LoadControl; | |
import com.google.android.exoplayer2.trackselection.TrackSelector; | |
import com.google.android.exoplayer2.RenderersFactory; | |
import com.google.android.exoplayer2.ExoPlayerFactory; | |
import com.google.android.exoplayer2.DefaultLoadControl; | |
import com.google.android.exoplayer2.DefaultRenderersFactory; | |
import com.google.android.exoplayer2.util.Util; | |
import com.google.android.exoplayer2.trackselection.TrackSelection$Factory; | |
import com.google.android.exoplayer2.upstream.BandwidthMeter; | |
import com.google.android.exoplayer2.trackselection.TrackSelectionArray; | |
import com.google.android.exoplayer2.Timeline; | |
import com.google.android.exoplayer2.ExoPlaybackException; | |
import android.util.Log; | |
import com.google.android.exoplayer2.PlaybackParameters; | |
import com.google.android.exoplayer2.Player$EventListener$-CC; | |
import com.google.android.exoplayer2.text.Cue; | |
import com.google.android.exoplayer2.Timeline$Window; | |
import java.util.Iterator; | |
import java.util.Collection; | |
import java.util.ArrayList; | |
import com.google.android.exoplayer2.trackselection.DefaultTrackSelector$ParametersBuilder; | |
import com.google.android.exoplayer2.source.TrackGroupArray; | |
import com.google.android.exoplayer2.trackselection.DefaultTrackSelector$SelectionOverride; | |
import com.conax.client.integrationlayer.api.BaseTrack; | |
import com.google.android.exoplayer2.source.MediaSourceEventListener; | |
import tv.broadpeak.analytics.SmartLib; | |
import com.google.android.exoplayer2.source.dash.DashMediaSource; | |
import java.net.MalformedURLException; | |
import java.net.URL; | |
import com.conax.client.integrationlayer.api.VideoPlayerEventListener; | |
import com.conax.client.integrationlayer.api.Logger; | |
import com.conax.client.integrationlayer.R$string; | |
import com.google.android.exoplayer2.drm.UnsupportedDrmException; | |
import com.google.android.exoplayer2.drm.DefaultDrmSessionEventListener; | |
import java.util.HashMap; | |
import com.google.android.exoplayer2.drm.MediaDrmCallback; | |
import com.google.android.exoplayer2.drm.ExoMediaDrm; | |
import com.google.android.exoplayer2.drm.FrameworkMediaDrm; | |
import com.google.android.exoplayer2.C; | |
import com.google.android.exoplayer2.drm.FrameworkMediaCrypto; | |
import com.google.android.exoplayer2.drm.DefaultDrmSessionManager; | |
import java.net.CookieHandler; | |
import android.net.ConnectivityManager; | |
import java.util.Collections; | |
import java.net.CookiePolicy; | |
import com.conax.client.integrationlayer.api.VideoPlayerConfig; | |
import com.google.android.exoplayer2.trackselection.DefaultTrackSelector; | |
import android.view.Surface; | |
import com.google.android.exoplayer2.SimpleExoPlayer; | |
import android.os.Handler; | |
import com.conax.client.integrationlayer.api.DrmConfig; | |
import com.conax.client.integrationlayer.api.SubtitleTrack; | |
import com.conax.client.integrationlayer.api.AudioTrack; | |
import java.util.List; | |
import android.net.Uri; | |
import android.content.Context; | |
import java.net.CookieManager; | |
import com.google.android.exoplayer2.upstream.DefaultBandwidthMeter; | |
import com.google.android.exoplayer2.text.TextRenderer$Output; | |
import com.google.android.exoplayer2.Player$EventListener; | |
import com.conax.client.integrationlayer.api.VideoPlayerManager; | |
public class VideoPlayerManagerImpl implements VideoPlayerManager, Player$EventListener, TextRenderer$Output | |
{ | |
private static final DefaultBandwidthMeter BANDWIDTH_METER; | |
private static final String TAG = "VideoPlayerManagerImpl"; | |
private static final CookieManager defaultCookieManager; | |
private final Context activityContext; | |
private Uri contentUri; | |
private List<AudioTrack> currentAudioTrackList; | |
private List<SubtitleTrack> currentSubtitleTrackList; | |
private final DrmConfig drmConfig; | |
private EventLogger eventLogger; | |
private boolean isOffline; | |
private VideoPlayerManagerImpl.VideoPlayerManagerImpl$LimitUpperBitrateControlImpl limitUpperBitrateControl; | |
private Handler mainHandler; | |
private SimpleExoPlayer player; | |
private PlaybackErrorListenerProxy playerErrorListenerFacade; | |
private final StateChangeHandler stateChangeHandler; | |
private Handler stateHandler; | |
private Surface surface; | |
private DefaultTrackSelector trackSelector; | |
private final VideoPlayerConfig videoPlayerConfig; | |
static { | |
BANDWIDTH_METER = new DefaultBandwidthMeter(); | |
(defaultCookieManager = new CookieManager()).setCookiePolicy(CookiePolicy.ACCEPT_ORIGINAL_SERVER); | |
} | |
public VideoPlayerManagerImpl(final VideoPlayerConfig videoPlayerConfig, final DrmConfig drmConfig, final Context activityContext) { | |
this.currentSubtitleTrackList = Collections.emptyList(); | |
this.currentAudioTrackList = Collections.emptyList(); | |
this.activityContext = activityContext; | |
this.videoPlayerConfig = videoPlayerConfig; | |
this.drmConfig = drmConfig; | |
this.stateChangeHandler = new StateChangeHandler(videoPlayerConfig.getVideoPlayerEventListener()); | |
this.limitUpperBitrateControl = new VideoPlayerManagerImpl.VideoPlayerManagerImpl$LimitUpperBitrateControlImpl(this, PlayerSettings.getInstance(activityContext), (ConnectivityManager)activityContext.getSystemService("connectivity"), (VideoPlayerManagerImpl$1)null); | |
final CookieHandler default1 = CookieHandler.getDefault(); | |
final CookieManager defaultCookieManager = VideoPlayerManagerImpl.defaultCookieManager; | |
if (default1 != defaultCookieManager) { | |
CookieHandler.setDefault(defaultCookieManager); | |
} | |
} | |
private void checkAudioTracksAvailability(final boolean b) { | |
if (this.videoPlayerConfig.getVideoPlayerEventListener() == null) { | |
return; | |
} | |
final List access$300 = VideoPlayerManagerImpl.VideoPlayerManagerImpl$TracksProvider.access$300(new VideoPlayerManagerImpl.VideoPlayerManagerImpl$TracksProvider(this, (VideoPlayerManagerImpl$1)null), b, 1, (VideoPlayerManagerImpl.VideoPlayerManagerImpl$TrackFactory)new VideoPlayerManagerImpl$3(this)); | |
if (trackListChanged(this.currentAudioTrackList, access$300)) { | |
this.currentAudioTrackList = (List<AudioTrack>)access$300; | |
this.videoPlayerConfig.getVideoPlayerEventListener().onAudioListChanged(access$300); | |
} | |
} | |
private void checkSubtitleTracksAvailability(final boolean b) { | |
if (this.videoPlayerConfig.getVideoPlayerEventListener() == null) { | |
return; | |
} | |
final List access$300 = VideoPlayerManagerImpl.VideoPlayerManagerImpl$TracksProvider.access$300(new VideoPlayerManagerImpl.VideoPlayerManagerImpl$TracksProvider(this, (VideoPlayerManagerImpl$1)null), b, 3, (VideoPlayerManagerImpl.VideoPlayerManagerImpl$TrackFactory)new VideoPlayerManagerImpl$2(this)); | |
if (trackListChanged(this.currentSubtitleTrackList, access$300)) { | |
this.currentSubtitleTrackList = (List<SubtitleTrack>)access$300; | |
this.videoPlayerConfig.getVideoPlayerEventListener().onSubtitleListChanged(access$300); | |
} | |
} | |
private void checkTracksAvailability(final boolean b) { | |
this.checkSubtitleTracksAvailability(b); | |
this.checkAudioTracksAvailability(b); | |
} | |
private DefaultDrmSessionManager<FrameworkMediaCrypto> getDrmSessionManager(final WidevineMediaDrmCallback widevineMediaDrmCallback) { | |
DefaultDrmSessionManager<FrameworkMediaCrypto> defaultDrmSessionManager2; | |
Exception ex = null; | |
try { | |
final DefaultDrmSessionManager defaultDrmSessionManager = new DefaultDrmSessionManager(C.WIDEVINE_UUID, (ExoMediaDrm)FrameworkMediaDrm.newInstance(C.WIDEVINE_UUID), (MediaDrmCallback)widevineMediaDrmCallback, (HashMap)null, true); | |
try { | |
defaultDrmSessionManager.addListener(this.mainHandler, (DefaultDrmSessionEventListener)new VideoPlayerManagerImpl$1(this)); | |
defaultDrmSessionManager2 = (DefaultDrmSessionManager<FrameworkMediaCrypto>)defaultDrmSessionManager; | |
} | |
catch (UnsupportedDrmException ex2) { | |
defaultDrmSessionManager2 = (DefaultDrmSessionManager<FrameworkMediaCrypto>)defaultDrmSessionManager; | |
ex = (Exception)ex2; | |
} | |
} | |
catch (UnsupportedDrmException ex) { | |
defaultDrmSessionManager2 = null; | |
} | |
String s; | |
if (((UnsupportedDrmException)ex).reason == 1) { | |
s = this.activityContext.getString(R$string.integration_layer_error_drm_unsupported_scheme); | |
} | |
else { | |
s = this.activityContext.getString(R$string.integration_layer_error_drm_unknown); | |
} | |
final StringBuilder sb = new StringBuilder(); | |
sb.append("UnsupportedDrmException occurred, type = "); | |
sb.append(s); | |
Logger.e("VideoPlayerManagerImpl", sb.toString(), (Throwable)ex); | |
final PlaybackErrorListenerProxy playerErrorListenerFacade = this.playerErrorListenerFacade; | |
if (playerErrorListenerFacade != null) { | |
playerErrorListenerFacade.onDrmSessionManagerError(ex); | |
} | |
else { | |
Logger.e("VideoPlayerManagerImpl", "UnsupportedDrmException has not been handled - playerErrorListenerFacade is null"); | |
} | |
return defaultDrmSessionManager2; | |
} | |
private VideoPlayerEventListener getVideoPlayerEventListener() { | |
return this.videoPlayerConfig.getVideoPlayerEventListener(); | |
} | |
private boolean isValidUri(final Uri uri) { | |
final String scheme = uri.getScheme(); | |
boolean b; | |
if (scheme != null && (scheme.equals("http") || scheme.equals("https"))) { | |
b = true; | |
} | |
else { | |
Logger.e("VideoPlayerManagerImpl", "isValidUri = false: Invalid http(s) address"); | |
b = false; | |
} | |
try { | |
new URL(uri.toString()); | |
} | |
catch (MalformedURLException ex) { | |
Logger.e("VideoPlayerManagerImpl", "isValidUri = false: Invalid http(s) address"); | |
b = false; | |
} | |
return b; | |
} | |
private void loadStreamInternal(final Uri uri, final String s, final String s2, final DashMediaSource dashMediaSource, final byte[] array, final boolean b) { | |
if (uri != null) { | |
this.releasePlayer(); | |
this.preparePlayer(uri, s, s2, dashMediaSource, array, b); | |
} | |
} | |
private void logStateChange(final boolean b, final int n) { | |
final StringBuilder sb = new StringBuilder(); | |
sb.append("playWhenReady="); | |
sb.append(b); | |
sb.append(", playbackState="); | |
final String string = sb.toString(); | |
String s; | |
if (n != 1) { | |
if (n != 2) { | |
if (n != 3) { | |
if (n != 4) { | |
final StringBuilder sb2 = new StringBuilder(); | |
sb2.append(string); | |
sb2.append("unknown"); | |
s = sb2.toString(); | |
} | |
else { | |
final StringBuilder sb3 = new StringBuilder(); | |
sb3.append(string); | |
sb3.append("ended"); | |
s = sb3.toString(); | |
} | |
} | |
else { | |
final StringBuilder sb4 = new StringBuilder(); | |
sb4.append(string); | |
sb4.append("ready"); | |
s = sb4.toString(); | |
} | |
} | |
else { | |
final StringBuilder sb5 = new StringBuilder(); | |
sb5.append(string); | |
sb5.append("buffering"); | |
s = sb5.toString(); | |
} | |
} | |
else { | |
final StringBuilder sb6 = new StringBuilder(); | |
sb6.append(string); | |
sb6.append("idle"); | |
s = sb6.toString(); | |
} | |
Logger.d("VideoPlayerManagerImpl", s); | |
} | |
private void maybeInitBroadpeakLibrary(final Uri uri, final DashMediaSource dashMediaSource) { | |
if (this.contentUri.equals((Object)uri)) { | |
return; | |
} | |
SmartLib.getInstance().setContext(this.activityContext); | |
SmartLib.getInstance().init((Object)this.player, (Object)null, (String)null, false, true, "", ""); | |
SmartLib.getInstance().setUserAgent("Android"); | |
dashMediaSource.addEventListener(new Handler(), (MediaSourceEventListener)SmartLib.getInstance().getListener()); | |
SmartLib.getInstance().startStreamingSession(this.contentUri.toString(), uri.toString()); | |
} | |
private void releasePlayer() { | |
final SimpleExoPlayer player = this.player; | |
if (player != null) { | |
player.removeListener((Player$EventListener)this); | |
final Handler stateHandler = this.stateHandler; | |
if (stateHandler != null) { | |
stateHandler.removeCallbacksAndMessages((Object)null); | |
this.stateHandler = null; | |
} | |
this.stateChangeHandler.setPlayerEventListener((VideoPlayerEventListener)null); | |
this.stateChangeHandler.reset(); | |
this.currentSubtitleTrackList = Collections.emptyList(); | |
this.currentAudioTrackList = Collections.emptyList(); | |
this.player.release(); | |
this.player = null; | |
if (this.eventLogger != null) { | |
this.eventLogger = null; | |
} | |
final PlaybackErrorListenerProxy playerErrorListenerFacade = this.playerErrorListenerFacade; | |
if (playerErrorListenerFacade != null) { | |
playerErrorListenerFacade.endSession(); | |
this.playerErrorListenerFacade = null; | |
} | |
if (this.getVideoPlayerEventListener() != null) { | |
this.getVideoPlayerEventListener().onPlayerDestroyed(); | |
} | |
SmartLib.getInstance().stopStreamingSession(); | |
} | |
} | |
private void setSelectedTrack(final BaseTrack baseTrack, final BaseTrack baseTrack2, final int n) { | |
if (this.player != null) { | |
final DefaultTrackSelector trackSelector = this.trackSelector; | |
if (trackSelector != null && trackSelector.getCurrentMappedTrackInfo() != null) { | |
final int n2 = -1; | |
int rendererIndex; | |
if (!baseTrack2.equals((Object)baseTrack)) { | |
rendererIndex = baseTrack.getRendererIndex(); | |
} | |
else { | |
int n3 = 0; | |
while (true) { | |
rendererIndex = n2; | |
if (n3 >= this.player.getRendererCount()) { | |
break; | |
} | |
if (this.player.getRendererType(n3) == n) { | |
rendererIndex = n3; | |
break; | |
} | |
++n3; | |
} | |
} | |
if (rendererIndex < 0) { | |
Logger.e("VideoPlayerManagerImpl", "setSelectedTrack() failed: rendererIndex is invalid"); | |
return; | |
} | |
DefaultTrackSelector$SelectionOverride defaultTrackSelector$SelectionOverride; | |
if (baseTrack2.equals((Object)baseTrack)) { | |
defaultTrackSelector$SelectionOverride = null; | |
} | |
else { | |
defaultTrackSelector$SelectionOverride = new DefaultTrackSelector$SelectionOverride(baseTrack.getGroupIndex(), new int[] { baseTrack.getTrackIndex() }); | |
} | |
final TrackGroupArray trackGroups = this.trackSelector.getCurrentMappedTrackInfo().getTrackGroups(rendererIndex); | |
final DefaultTrackSelector$ParametersBuilder buildUponParameters = this.trackSelector.buildUponParameters(); | |
buildUponParameters.setRendererDisabled(rendererIndex, false); | |
if (defaultTrackSelector$SelectionOverride != null) { | |
buildUponParameters.setSelectionOverride(rendererIndex, trackGroups, defaultTrackSelector$SelectionOverride); | |
} | |
else { | |
buildUponParameters.clearSelectionOverrides(rendererIndex); | |
} | |
this.trackSelector.setParameters(buildUponParameters); | |
return; | |
} | |
} | |
Logger.w("VideoPlayerManagerImpl", "setSelectedTrack() failed: player or trackSelector is null"); | |
} | |
protected static <M extends BaseTrack> boolean trackListChanged(final List<M> list, final List<M> list2) { | |
if (list == null) { | |
return true; | |
} | |
final ArrayList list3 = new ArrayList((Collection<? extends E>)list); | |
final Iterator<M> iterator = list2.iterator(); | |
while (iterator.hasNext()) { | |
if (!list3.remove(iterator.next())) { | |
return true; | |
} | |
} | |
return list3.isEmpty() ^ true; | |
} | |
public boolean canPlayWithoutPrepare() { | |
final SimpleExoPlayer player = this.player; | |
boolean b = false; | |
if (player != null) { | |
final int playbackState = player.getPlaybackState(); | |
if (playbackState != 2 && playbackState != 3) { | |
b = b; | |
if (playbackState != 4) { | |
return b; | |
} | |
} | |
b = true; | |
} | |
return b; | |
} | |
public void clearSurface() { | |
Logger.d("VideoPlayerManagerImpl", "#clearSurface() called"); | |
this.surface = null; | |
final SimpleExoPlayer player = this.player; | |
if (player != null) { | |
player.setVideoSurface((Surface)null); | |
} | |
} | |
public void destroyPlayer() { | |
this.releasePlayer(); | |
} | |
public long getAbsoluteTimeAtMinPos() { | |
final SimpleExoPlayer player = this.player; | |
if (player != null && player.getCurrentTimeline() != null) { | |
try { | |
final Timeline$Window timeline$Window = new Timeline$Window(); | |
this.player.getCurrentTimeline().getWindow(this.player.getCurrentWindowIndex(), timeline$Window); | |
return timeline$Window.windowStartTimeMs; | |
} | |
catch (IndexOutOfBoundsException ex) { | |
Logger.e("VideoPlayerManagerImpl", "Can't get window start time", (Throwable)ex); | |
} | |
} | |
return -9223372036854775807L; | |
} | |
public List<AudioTrack> getAudioTrackList() { | |
return this.currentAudioTrackList; | |
} | |
public long getCurrentPositionMs() { | |
final SimpleExoPlayer player = this.player; | |
if (player != null) { | |
return player.getCurrentPosition(); | |
} | |
return -9223372036854775807L; | |
} | |
public Uri getCurrentUri() { | |
return this.contentUri; | |
} | |
public long getDurationMs() { | |
final SimpleExoPlayer player = this.player; | |
if (player != null) { | |
return player.getDuration(); | |
} | |
return -9223372036854775807L; | |
} | |
public AudioTrack getSelectedAudioTrack() { | |
final List<AudioTrack> currentAudioTrackList = this.currentAudioTrackList; | |
if (currentAudioTrackList != null && currentAudioTrackList.size() > 0) { | |
final int rendererIndex = this.currentAudioTrackList.get(0).getRendererIndex(); | |
final DefaultTrackSelector$SelectionOverride selectionOverride = this.trackSelector.getParameters().getSelectionOverride(rendererIndex, this.trackSelector.getCurrentMappedTrackInfo().getTrackGroups(rendererIndex)); | |
if (selectionOverride != null) { | |
final int groupIndex = selectionOverride.groupIndex; | |
for (final AudioTrack audioTrack : this.currentAudioTrackList) { | |
if (audioTrack.getGroupIndex() == groupIndex && selectionOverride.containsTrack(audioTrack.getTrackIndex())) { | |
return audioTrack; | |
} | |
} | |
} | |
} | |
return AudioTrack.DISABLED_TRACK; | |
} | |
public SubtitleTrack getSelectedSubtitleTrack() { | |
final List<SubtitleTrack> currentSubtitleTrackList = this.currentSubtitleTrackList; | |
if (currentSubtitleTrackList != null && currentSubtitleTrackList.size() > 0) { | |
final int rendererIndex = this.currentSubtitleTrackList.get(0).getRendererIndex(); | |
final DefaultTrackSelector$SelectionOverride selectionOverride = this.trackSelector.getParameters().getSelectionOverride(rendererIndex, this.trackSelector.getCurrentMappedTrackInfo().getTrackGroups(rendererIndex)); | |
if (selectionOverride != null) { | |
final int groupIndex = selectionOverride.groupIndex; | |
for (final SubtitleTrack subtitleTrack : this.currentSubtitleTrackList) { | |
if (subtitleTrack.getGroupIndex() == groupIndex && selectionOverride.containsTrack(subtitleTrack.getTrackIndex())) { | |
return subtitleTrack; | |
} | |
} | |
} | |
} | |
return SubtitleTrack.DISABLED_TRACK; | |
} | |
public List<SubtitleTrack> getSubtitleTrackList() { | |
return this.currentSubtitleTrackList; | |
} | |
public boolean isBuffering() { | |
final SimpleExoPlayer player = this.player; | |
return player != null && player.getPlaybackState() == 2; | |
} | |
public boolean isOffline() { | |
return this.isOffline; | |
} | |
public boolean isPlaying() { | |
final SimpleExoPlayer player = this.player; | |
return player != null && player.getPlayWhenReady(); | |
} | |
public void onCues(final List<Cue> list) { | |
if (this.videoPlayerConfig.getVideoPlayerEventListener() != null) { | |
this.videoPlayerConfig.getVideoPlayerEventListener().onCuesReceived((List)list); | |
} | |
} | |
public void onLoadingChanged(final boolean b) { | |
final StringBuilder sb = new StringBuilder(); | |
sb.append("onLoadingChanged("); | |
sb.append(b); | |
sb.append(")"); | |
Logger.d("VideoPlayerManagerImpl", sb.toString()); | |
} | |
public void onPlaybackParametersChanged(final PlaybackParameters playbackParameters) { | |
final StringBuilder sb = new StringBuilder(); | |
sb.append("playbackParameters "); | |
sb.append(String.format("[speed=%.2f, pitch=%.2f]", playbackParameters.speed, playbackParameters.pitch)); | |
Log.d("VideoPlayerManagerImpl", sb.toString()); | |
} | |
public void onPlayerError(final ExoPlaybackException ex) { | |
final PlaybackErrorListenerProxy playerErrorListenerFacade = this.playerErrorListenerFacade; | |
if (playerErrorListenerFacade != null) { | |
playerErrorListenerFacade.onPlayerError((Exception)ex); | |
} | |
} | |
public void onPlayerStateChanged(final boolean b, final int n) { | |
this.logStateChange(b, n); | |
final Handler stateHandler = this.stateHandler; | |
if (stateHandler != null) { | |
stateHandler.post((Runnable)new VideoPlayerManagerImpl$4(this, b, n)); | |
} | |
boolean b2 = true; | |
if (n != 1) { | |
b2 = false; | |
} | |
this.checkTracksAvailability(b2); | |
} | |
public void onPositionDiscontinuity(final int n) { | |
final StringBuilder sb = new StringBuilder(); | |
sb.append("onPositionDiscontinuity("); | |
sb.append(n); | |
sb.append(")"); | |
Logger.d("VideoPlayerManagerImpl", sb.toString()); | |
} | |
public void onRepeatModeChanged(final int n) { | |
final StringBuilder sb = new StringBuilder(); | |
sb.append("onRepeatModeChanged("); | |
sb.append(n); | |
sb.append(")"); | |
Logger.d("VideoPlayerManagerImpl", sb.toString()); | |
} | |
public void onSeekProcessed() { | |
Logger.d("VideoPlayerManagerImpl", "onSeekProcessed()"); | |
} | |
public void onShuffleModeEnabledChanged(final boolean b) { | |
final StringBuilder sb = new StringBuilder(); | |
sb.append("onShuffleModeEnabledChanged("); | |
sb.append(b); | |
sb.append(")"); | |
Logger.d("VideoPlayerManagerImpl", sb.toString()); | |
} | |
public void onTimelineChanged(final Timeline timeline, final Object o, final int n) { | |
final StringBuilder sb = new StringBuilder(); | |
sb.append("onTimelineChanged("); | |
sb.append(timeline); | |
sb.append(")"); | |
Logger.d("VideoPlayerManagerImpl", sb.toString()); | |
} | |
public void onTracksChanged(final TrackGroupArray trackGroupArray, final TrackSelectionArray trackSelectionArray) { | |
} | |
public void pausePlayback() { | |
final SimpleExoPlayer player = this.player; | |
if (player != null) { | |
player.setPlayWhenReady(false); | |
} | |
} | |
public void preparePlayer(final Uri uri, final String s, final String s2, final DashMediaSource dashMediaSource, final byte[] array, final boolean b) { | |
this.stateHandler = new Handler(); | |
this.mainHandler = new Handler(); | |
this.stateChangeHandler.setPlayerEventListener(this.videoPlayerConfig.getVideoPlayerEventListener()); | |
final StringBuilder sb = new StringBuilder(); | |
sb.append("preparePlayer() called, uri:"); | |
sb.append(uri); | |
Logger.d("VideoPlayerManagerImpl", sb.toString()); | |
this.playerErrorListenerFacade = new PlaybackErrorListenerProxy(this.videoPlayerConfig.getPlayerErrorListener()); | |
this.trackSelector = new DefaultTrackSelector((TrackSelection$Factory)new LimitedBitrateTrackSelection$Factory((BandwidthMeter)VideoPlayerManagerImpl.BANDWIDTH_METER, (LimitedBitrateTrackSelection$LimitUpperBitrateControl)this.limitUpperBitrateControl, this.videoPlayerConfig.getLimitedBitrate())); | |
final String userAgent = Util.getUserAgent(this.activityContext, this.videoPlayerConfig.getApplicationName()); | |
final DefaultDrmSessionManager<FrameworkMediaCrypto> drmSessionManager = this.getDrmSessionManager(new WidevineMediaDrmCallback(this.drmConfig.getLicenseServerUrl(), this.drmConfig.getDeviceId(), this.drmConfig.getTokenAcquirer(), userAgent, s, s2)); | |
(this.player = ExoPlayerFactory.newSimpleInstance(this.activityContext, (RenderersFactory)new DefaultRenderersFactory(this.activityContext), (TrackSelector)this.trackSelector, (LoadControl)new DefaultLoadControl(), (DrmSessionManager)drmSessionManager)).addListener((Player$EventListener)this); | |
this.eventLogger = new EventLogger((MappingTrackSelector)this.trackSelector, this.videoPlayerConfig.getVideoPlayerEventListener()); | |
this.player.addAnalyticsListener((AnalyticsListener)this.eventLogger); | |
this.player.addTextOutput((TextOutput)this); | |
final Surface surface = this.surface; | |
if (surface != null && surface.isValid()) { | |
Logger.d("VideoPlayerManagerImpl", "#preparePlayer()#player.setSurface(..)"); | |
this.player.setVideoSurface(this.surface); | |
} | |
DashMediaSource dashMediaSource2; | |
if (b && dashMediaSource != null) { | |
drmSessionManager.setMode(0, array); | |
dashMediaSource2 = dashMediaSource; | |
} | |
else { | |
final Context activityContext = this.activityContext; | |
final DefaultBandwidthMeter bandwidth_METER = VideoPlayerManagerImpl.BANDWIDTH_METER; | |
final DashMediaSource mediaSource = new DashMediaSource$Factory((DashChunkSource$Factory)new DefaultDashChunkSource$Factory((DataSource$Factory)new DefaultDataSourceFactory(activityContext, (TransferListener)bandwidth_METER, (DataSource$Factory)new DefaultHttpDataSourceFactory("buildHttpDataSourceFactory Agent", (TransferListener)bandwidth_METER))), (DataSource$Factory)new DefaultDataSourceFactory(this.activityContext, (TransferListener)null, (DataSource$Factory)new DefaultHttpDataSourceFactory(userAgent))).createMediaSource(uri); | |
this.maybeInitBroadpeakLibrary(uri, mediaSource); | |
dashMediaSource2 = mediaSource; | |
} | |
this.player.prepare((MediaSource)dashMediaSource2); | |
this.checkTracksAvailability(false); | |
} | |
public void prepareStreamAsync(final Uri contentUri, final Uri uri, final String s, final String s2) { | |
if (!this.isValidUri(uri)) { | |
return; | |
} | |
this.contentUri = contentUri; | |
this.loadStreamInternal(uri, s, s2, null, null, false); | |
} | |
public void prepareStreamAsync(final Uri contentUri, final String s, final String s2, final DashMediaSource dashMediaSource, final byte[] array, final boolean isOffline) { | |
if (!this.isValidUri(contentUri)) { | |
return; | |
} | |
this.contentUri = contentUri; | |
this.isOffline = isOffline; | |
this.loadStreamInternal(this.contentUri, s, s2, dashMediaSource, array, isOffline); | |
} | |
public void removeSurface(final Surface surface) { | |
Logger.d("VideoPlayerManagerImpl", "#removeSurface() called"); | |
if (this.player != null && surface == this.surface) { | |
Logger.d("VideoPlayerManagerImpl", "#removeSurface() called: surface removed"); | |
this.surface = null; | |
this.player.setVideoSurface((Surface)null); | |
} | |
} | |
public void seekToPositionMs(final long n) { | |
final StringBuilder sb = new StringBuilder(); | |
sb.append("#seekToPositionMs("); | |
sb.append(n); | |
sb.append(") called"); | |
Logger.d("VideoPlayerManagerImpl", sb.toString()); | |
final SimpleExoPlayer player = this.player; | |
if (player != null) { | |
player.seekTo(n); | |
} | |
} | |
public void setPlaybackErrorListener(final PlaybackErrorListener playbackErrorListener) { | |
this.videoPlayerConfig.setPlayerErrorListener(playbackErrorListener); | |
final PlaybackErrorListenerProxy playerErrorListenerFacade = this.playerErrorListenerFacade; | |
if (playerErrorListenerFacade != null) { | |
playerErrorListenerFacade.setDelegate(playbackErrorListener); | |
} | |
} | |
public void setSelectedAudioTrack(final AudioTrack audioTrack) { | |
this.setSelectedTrack((BaseTrack)audioTrack, (BaseTrack)AudioTrack.DISABLED_TRACK, 1); | |
} | |
public void setSelectedSubtitleTrack(final SubtitleTrack subtitleTrack) { | |
this.setSelectedTrack((BaseTrack)subtitleTrack, (BaseTrack)SubtitleTrack.DISABLED_TRACK, 3); | |
} | |
public void setSurface(final Surface surface) { | |
Logger.d("VideoPlayerManagerImpl", "#setSurface() called"); | |
if (!surface.isValid()) { | |
Logger.e("VideoPlayerManagerImpl", "Surface is not valid according to Surface#isValid"); | |
this.clearSurface(); | |
} | |
else { | |
this.surface = surface; | |
final SimpleExoPlayer player = this.player; | |
if (player != null) { | |
player.setVideoSurface(surface); | |
} | |
else { | |
Logger.d("VideoPlayerManagerImpl", "#setSurface() action postponed: player is null"); | |
} | |
} | |
} | |
public void setVideoPlayerEventListener(final VideoPlayerEventListener videoPlayerEventListener) { | |
this.stateChangeHandler.setPlayerEventListener(videoPlayerEventListener); | |
this.videoPlayerConfig.setVideoPlayerEventListener(videoPlayerEventListener); | |
} | |
public void startPlayback() { | |
final SimpleExoPlayer player = this.player; | |
if (player != null) { | |
player.setPlayWhenReady(true); | |
} | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment