Java Code Examples for com.google.android.exoplayer2.trackselection.DefaultTrackSelector#Parameters
The following examples show how to use
com.google.android.exoplayer2.trackselection.DefaultTrackSelector#Parameters .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DownloadHelper.java From MediaSDK with Apache License 2.0 | 6 votes |
/** * Creates a {@link DownloadHelper} for DASH streams. * * @param uri A manifest {@link Uri}. * @param dataSourceFactory A {@link DataSource.Factory} used to load the manifest. * @param renderersFactory A {@link RenderersFactory} creating the renderers for which tracks are * selected. * @param drmSessionManager An optional {@link DrmSessionManager} used by the renderers created by * {@code renderersFactory}. * @param trackSelectorParameters {@link DefaultTrackSelector.Parameters} for selecting tracks for * downloading. * @return A {@link DownloadHelper} for DASH streams. * @throws IllegalStateException If the DASH module is missing. */ public static DownloadHelper forDash( Uri uri, DataSource.Factory dataSourceFactory, RenderersFactory renderersFactory, @Nullable DrmSessionManager<FrameworkMediaCrypto> drmSessionManager, DefaultTrackSelector.Parameters trackSelectorParameters) { return new DownloadHelper( DownloadRequest.TYPE_DASH, uri, /* cacheKey= */ null, createMediaSourceInternal( DASH_FACTORY_CONSTRUCTOR, uri, dataSourceFactory, /* streamKeys= */ null), trackSelectorParameters, Util.getRendererCapabilities(renderersFactory, drmSessionManager)); }
Example 2
Source File: DownloadHelper.java From Telegram with GNU General Public License v2.0 | 6 votes |
/** * Convenience method to add a selection of tracks to be downloaded for a single renderer. Must * not be called until after preparation completes. * * @param periodIndex The period index the track selection is added for. * @param rendererIndex The renderer index the track selection is added for. * @param trackSelectorParameters The {@link DefaultTrackSelector.Parameters} to obtain the new * selection of tracks. * @param overrides A list of {@link SelectionOverride SelectionOverrides} to apply to the {@code * trackSelectorParameters}. If empty, {@code trackSelectorParameters} are used as they are. */ public void addTrackSelectionForSingleRenderer( int periodIndex, int rendererIndex, DefaultTrackSelector.Parameters trackSelectorParameters, List<SelectionOverride> overrides) { assertPreparedWithMedia(); DefaultTrackSelector.ParametersBuilder builder = trackSelectorParameters.buildUpon(); for (int i = 0; i < mappedTrackInfos[periodIndex].getRendererCount(); i++) { builder.setRendererDisabled(/* rendererIndex= */ i, /* disabled= */ i != rendererIndex); } if (overrides.isEmpty()) { addTrackSelection(periodIndex, builder.build()); } else { TrackGroupArray trackGroupArray = mappedTrackInfos[periodIndex].getTrackGroups(rendererIndex); for (int i = 0; i < overrides.size(); i++) { builder.setSelectionOverride(rendererIndex, trackGroupArray, overrides.get(i)); addTrackSelection(periodIndex, builder.build()); } } }
Example 3
Source File: DownloadHelper.java From MediaSDK with Apache License 2.0 | 6 votes |
/** * Creates a {@link DownloadHelper} for SmoothStreaming streams. * * @param uri A manifest {@link Uri}. * @param dataSourceFactory A {@link DataSource.Factory} used to load the manifest. * @param renderersFactory A {@link RenderersFactory} creating the renderers for which tracks are * selected. * @param drmSessionManager An optional {@link DrmSessionManager} used by the renderers created by * {@code renderersFactory}. * @param trackSelectorParameters {@link DefaultTrackSelector.Parameters} for selecting tracks for * downloading. * @return A {@link DownloadHelper} for SmoothStreaming streams. * @throws IllegalStateException If the SmoothStreaming module is missing. */ public static DownloadHelper forSmoothStreaming( Uri uri, DataSource.Factory dataSourceFactory, RenderersFactory renderersFactory, @Nullable DrmSessionManager<FrameworkMediaCrypto> drmSessionManager, DefaultTrackSelector.Parameters trackSelectorParameters) { return new DownloadHelper( DownloadRequest.TYPE_SS, uri, /* cacheKey= */ null, createMediaSourceInternal( SS_FACTORY_CONSTRUCTOR, uri, dataSourceFactory, /* streamKeys= */ null), trackSelectorParameters, Util.getRendererCapabilities(renderersFactory, drmSessionManager)); }
Example 4
Source File: DownloadHelper.java From MediaSDK with Apache License 2.0 | 6 votes |
/** * Creates download helper. * * @param downloadType A download type. This value will be used as {@link DownloadRequest#type}. * @param uri A {@link Uri}. * @param cacheKey An optional cache key. * @param mediaSource A {@link MediaSource} for which tracks are selected, or null if no track * selection needs to be made. * @param trackSelectorParameters {@link DefaultTrackSelector.Parameters} for selecting tracks for * downloading. * @param rendererCapabilities The {@link RendererCapabilities} of the renderers for which tracks * are selected. */ public DownloadHelper( String downloadType, Uri uri, @Nullable String cacheKey, @Nullable MediaSource mediaSource, DefaultTrackSelector.Parameters trackSelectorParameters, RendererCapabilities[] rendererCapabilities) { this.downloadType = downloadType; this.uri = uri; this.cacheKey = cacheKey; this.mediaSource = mediaSource; this.trackSelector = new DefaultTrackSelector(trackSelectorParameters, new DownloadTrackSelection.Factory()); this.rendererCapabilities = rendererCapabilities; this.scratchSet = new SparseIntArray(); trackSelector.init(/* listener= */ () -> {}, new DummyBandwidthMeter()); callbackHandler = new Handler(Util.getLooper()); window = new Timeline.Window(); }
Example 5
Source File: DownloadHelper.java From MediaSDK with Apache License 2.0 | 6 votes |
/** * Convenience method to add a selection of tracks to be downloaded for a single renderer. Must * not be called until after preparation completes. * * @param periodIndex The period index the track selection is added for. * @param rendererIndex The renderer index the track selection is added for. * @param trackSelectorParameters The {@link DefaultTrackSelector.Parameters} to obtain the new * selection of tracks. * @param overrides A list of {@link SelectionOverride SelectionOverrides} to apply to the {@code * trackSelectorParameters}. If empty, {@code trackSelectorParameters} are used as they are. */ public void addTrackSelectionForSingleRenderer( int periodIndex, int rendererIndex, DefaultTrackSelector.Parameters trackSelectorParameters, List<SelectionOverride> overrides) { assertPreparedWithMedia(); DefaultTrackSelector.ParametersBuilder builder = trackSelectorParameters.buildUpon(); for (int i = 0; i < mappedTrackInfos[periodIndex].getRendererCount(); i++) { builder.setRendererDisabled(/* rendererIndex= */ i, /* disabled= */ i != rendererIndex); } if (overrides.isEmpty()) { addTrackSelection(periodIndex, builder.build()); } else { TrackGroupArray trackGroupArray = mappedTrackInfos[periodIndex].getTrackGroups(rendererIndex); for (int i = 0; i < overrides.size(); i++) { builder.setSelectionOverride(rendererIndex, trackGroupArray, overrides.get(i)); addTrackSelection(periodIndex, builder.build()); } } }
Example 6
Source File: CompositeTrackSelectorCreator.java From no-player with Apache License 2.0 | 6 votes |
CompositeTrackSelector create(Options options, DefaultBandwidthMeter bandwidthMeter) { TrackSelection.Factory adaptiveTrackSelectionFactory = new AdaptiveTrackSelection.Factory( bandwidthMeter, options.minDurationBeforeQualityIncreaseInMillis(), AdaptiveTrackSelection.DEFAULT_MAX_DURATION_FOR_QUALITY_DECREASE_MS, AdaptiveTrackSelection.DEFAULT_MIN_DURATION_TO_RETAIN_AFTER_DISCARD_MS, AdaptiveTrackSelection.DEFAULT_BANDWIDTH_FRACTION, AdaptiveTrackSelection.DEFAULT_BUFFERED_FRACTION_TO_LIVE_EDGE_FOR_QUALITY_INCREASE, AdaptiveTrackSelection.DEFAULT_MIN_TIME_BETWEEN_BUFFER_REEVALUTATION_MS, Clock.DEFAULT ); DefaultTrackSelector trackSelector = new DefaultTrackSelector(adaptiveTrackSelectionFactory); DefaultTrackSelector.Parameters trackSelectorParameters = trackSelector.buildUponParameters() .setMaxVideoBitrate(options.maxVideoBitrate()) .build(); trackSelector.setParameters(trackSelectorParameters); ExoPlayerTrackSelector exoPlayerTrackSelector = ExoPlayerTrackSelector.newInstance(trackSelector); ExoPlayerAudioTrackSelector audioTrackSelector = new ExoPlayerAudioTrackSelector(exoPlayerTrackSelector); ExoPlayerVideoTrackSelector videoTrackSelector = new ExoPlayerVideoTrackSelector(exoPlayerTrackSelector); ExoPlayerSubtitleTrackSelector subtitleTrackSelector = new ExoPlayerSubtitleTrackSelector(exoPlayerTrackSelector); return new CompositeTrackSelector(trackSelector, audioTrackSelector, videoTrackSelector, subtitleTrackSelector); }
Example 7
Source File: DownloadHelper.java From Telegram-FOSS with GNU General Public License v2.0 | 6 votes |
/** * Convenience method to add a selection of tracks to be downloaded for a single renderer. Must * not be called until after preparation completes. * * @param periodIndex The period index the track selection is added for. * @param rendererIndex The renderer index the track selection is added for. * @param trackSelectorParameters The {@link DefaultTrackSelector.Parameters} to obtain the new * selection of tracks. * @param overrides A list of {@link SelectionOverride SelectionOverrides} to apply to the {@code * trackSelectorParameters}. If empty, {@code trackSelectorParameters} are used as they are. */ public void addTrackSelectionForSingleRenderer( int periodIndex, int rendererIndex, DefaultTrackSelector.Parameters trackSelectorParameters, List<SelectionOverride> overrides) { assertPreparedWithMedia(); DefaultTrackSelector.ParametersBuilder builder = trackSelectorParameters.buildUpon(); for (int i = 0; i < mappedTrackInfos[periodIndex].getRendererCount(); i++) { builder.setRendererDisabled(/* rendererIndex= */ i, /* disabled= */ i != rendererIndex); } if (overrides.isEmpty()) { addTrackSelection(periodIndex, builder.build()); } else { TrackGroupArray trackGroupArray = mappedTrackInfos[periodIndex].getTrackGroups(rendererIndex); for (int i = 0; i < overrides.size(); i++) { builder.setSelectionOverride(rendererIndex, trackGroupArray, overrides.get(i)); addTrackSelection(periodIndex, builder.build()); } } }
Example 8
Source File: DownloadHelper.java From Telegram-FOSS with GNU General Public License v2.0 | 6 votes |
/** * Creates download helper. * * @param downloadType A download type. This value will be used as {@link DownloadRequest#type}. * @param uri A {@link Uri}. * @param cacheKey An optional cache key. * @param mediaSource A {@link MediaSource} for which tracks are selected, or null if no track * selection needs to be made. * @param trackSelectorParameters {@link DefaultTrackSelector.Parameters} for selecting tracks for * downloading. * @param rendererCapabilities The {@link RendererCapabilities} of the renderers for which tracks * are selected. */ public DownloadHelper( String downloadType, Uri uri, @Nullable String cacheKey, @Nullable MediaSource mediaSource, DefaultTrackSelector.Parameters trackSelectorParameters, RendererCapabilities[] rendererCapabilities) { this.downloadType = downloadType; this.uri = uri; this.cacheKey = cacheKey; this.mediaSource = mediaSource; this.trackSelector = new DefaultTrackSelector(new DownloadTrackSelection.Factory()); this.rendererCapabilities = rendererCapabilities; this.scratchSet = new SparseIntArray(); trackSelector.setParameters(trackSelectorParameters); trackSelector.init(/* listener= */ () -> {}, new DummyBandwidthMeter()); callbackHandler = new Handler(Util.getLooper()); }
Example 9
Source File: DownloadHelper.java From Telegram with GNU General Public License v2.0 | 5 votes |
/** * Creates a {@link DownloadHelper} for SmoothStreaming streams. * * @param uri A manifest {@link Uri}. * @param dataSourceFactory A {@link DataSource.Factory} used to load the manifest. * @param renderersFactory A {@link RenderersFactory} creating the renderers for which tracks are * selected. * @param drmSessionManager An optional {@link DrmSessionManager} used by the renderers created by * {@code renderersFactory}. * @param trackSelectorParameters {@link DefaultTrackSelector.Parameters} for selecting tracks for * downloading. * @return A {@link DownloadHelper} for SmoothStreaming streams. * @throws IllegalStateException If the SmoothStreaming module is missing. */ public static DownloadHelper forSmoothStreaming( Uri uri, DataSource.Factory dataSourceFactory, RenderersFactory renderersFactory, @Nullable DrmSessionManager<FrameworkMediaCrypto> drmSessionManager, DefaultTrackSelector.Parameters trackSelectorParameters) { return new DownloadHelper( DownloadRequest.TYPE_SS, uri, /* cacheKey= */ null, SS_FACTORY.createMediaSource(uri, dataSourceFactory, /* streamKeys= */ null), trackSelectorParameters, Util.getRendererCapabilities(renderersFactory, drmSessionManager)); }
Example 10
Source File: DownloadHelper.java From MediaSDK with Apache License 2.0 | 5 votes |
/** Returns the default parameters used for track selection for downloading. */ public static DefaultTrackSelector.Parameters getDefaultTrackSelectorParameters(Context context) { return Parameters.getDefaults(context) .buildUpon() .setForceHighestSupportedBitrate(true) .build(); }
Example 11
Source File: DownloadHelper.java From Telegram with GNU General Public License v2.0 | 5 votes |
/** * Creates a {@link DownloadHelper} for HLS streams. * * @param uri A playlist {@link Uri}. * @param dataSourceFactory A {@link DataSource.Factory} used to load the playlist. * @param renderersFactory A {@link RenderersFactory} creating the renderers for which tracks are * selected. * @param drmSessionManager An optional {@link DrmSessionManager} used by the renderers created by * {@code renderersFactory}. * @param trackSelectorParameters {@link DefaultTrackSelector.Parameters} for selecting tracks for * downloading. * @return A {@link DownloadHelper} for HLS streams. * @throws IllegalStateException If the HLS module is missing. */ public static DownloadHelper forHls( Uri uri, DataSource.Factory dataSourceFactory, RenderersFactory renderersFactory, @Nullable DrmSessionManager<FrameworkMediaCrypto> drmSessionManager, DefaultTrackSelector.Parameters trackSelectorParameters) { return new DownloadHelper( DownloadRequest.TYPE_HLS, uri, /* cacheKey= */ null, HLS_FACTORY.createMediaSource(uri, dataSourceFactory, /* streamKeys= */ null), trackSelectorParameters, Util.getRendererCapabilities(renderersFactory, drmSessionManager)); }
Example 12
Source File: DownloadHelper.java From Telegram with GNU General Public License v2.0 | 5 votes |
/** * Creates a {@link DownloadHelper} for DASH streams. * * @param uri A manifest {@link Uri}. * @param dataSourceFactory A {@link DataSource.Factory} used to load the manifest. * @param renderersFactory A {@link RenderersFactory} creating the renderers for which tracks are * selected. * @param drmSessionManager An optional {@link DrmSessionManager} used by the renderers created by * {@code renderersFactory}. * @param trackSelectorParameters {@link DefaultTrackSelector.Parameters} for selecting tracks for * downloading. * @return A {@link DownloadHelper} for DASH streams. * @throws IllegalStateException If the DASH module is missing. */ public static DownloadHelper forDash( Uri uri, DataSource.Factory dataSourceFactory, RenderersFactory renderersFactory, @Nullable DrmSessionManager<FrameworkMediaCrypto> drmSessionManager, DefaultTrackSelector.Parameters trackSelectorParameters) { return new DownloadHelper( DownloadRequest.TYPE_DASH, uri, /* cacheKey= */ null, DASH_FACTORY.createMediaSource(uri, dataSourceFactory, /* streamKeys= */ null), trackSelectorParameters, Util.getRendererCapabilities(renderersFactory, drmSessionManager)); }
Example 13
Source File: DownloadHelper.java From Telegram-FOSS with GNU General Public License v2.0 | 5 votes |
/** * Creates a {@link DownloadHelper} for SmoothStreaming streams. * * @param uri A manifest {@link Uri}. * @param dataSourceFactory A {@link DataSource.Factory} used to load the manifest. * @param renderersFactory A {@link RenderersFactory} creating the renderers for which tracks are * selected. * @param drmSessionManager An optional {@link DrmSessionManager} used by the renderers created by * {@code renderersFactory}. * @param trackSelectorParameters {@link DefaultTrackSelector.Parameters} for selecting tracks for * downloading. * @return A {@link DownloadHelper} for SmoothStreaming streams. * @throws IllegalStateException If the SmoothStreaming module is missing. */ public static DownloadHelper forSmoothStreaming( Uri uri, DataSource.Factory dataSourceFactory, RenderersFactory renderersFactory, @Nullable DrmSessionManager<FrameworkMediaCrypto> drmSessionManager, DefaultTrackSelector.Parameters trackSelectorParameters) { return new DownloadHelper( DownloadRequest.TYPE_SS, uri, /* cacheKey= */ null, SS_FACTORY.createMediaSource(uri, dataSourceFactory, /* streamKeys= */ null), trackSelectorParameters, Util.getRendererCapabilities(renderersFactory, drmSessionManager)); }
Example 14
Source File: DownloadHelper.java From Telegram-FOSS with GNU General Public License v2.0 | 5 votes |
/** * Creates a {@link DownloadHelper} for HLS streams. * * @param uri A playlist {@link Uri}. * @param dataSourceFactory A {@link DataSource.Factory} used to load the playlist. * @param renderersFactory A {@link RenderersFactory} creating the renderers for which tracks are * selected. * @param drmSessionManager An optional {@link DrmSessionManager} used by the renderers created by * {@code renderersFactory}. * @param trackSelectorParameters {@link DefaultTrackSelector.Parameters} for selecting tracks for * downloading. * @return A {@link DownloadHelper} for HLS streams. * @throws IllegalStateException If the HLS module is missing. */ public static DownloadHelper forHls( Uri uri, DataSource.Factory dataSourceFactory, RenderersFactory renderersFactory, @Nullable DrmSessionManager<FrameworkMediaCrypto> drmSessionManager, DefaultTrackSelector.Parameters trackSelectorParameters) { return new DownloadHelper( DownloadRequest.TYPE_HLS, uri, /* cacheKey= */ null, HLS_FACTORY.createMediaSource(uri, dataSourceFactory, /* streamKeys= */ null), trackSelectorParameters, Util.getRendererCapabilities(renderersFactory, drmSessionManager)); }
Example 15
Source File: DownloadHelper.java From Telegram-FOSS with GNU General Public License v2.0 | 5 votes |
/** * Creates a {@link DownloadHelper} for DASH streams. * * @param uri A manifest {@link Uri}. * @param dataSourceFactory A {@link DataSource.Factory} used to load the manifest. * @param renderersFactory A {@link RenderersFactory} creating the renderers for which tracks are * selected. * @param drmSessionManager An optional {@link DrmSessionManager} used by the renderers created by * {@code renderersFactory}. * @param trackSelectorParameters {@link DefaultTrackSelector.Parameters} for selecting tracks for * downloading. * @return A {@link DownloadHelper} for DASH streams. * @throws IllegalStateException If the DASH module is missing. */ public static DownloadHelper forDash( Uri uri, DataSource.Factory dataSourceFactory, RenderersFactory renderersFactory, @Nullable DrmSessionManager<FrameworkMediaCrypto> drmSessionManager, DefaultTrackSelector.Parameters trackSelectorParameters) { return new DownloadHelper( DownloadRequest.TYPE_DASH, uri, /* cacheKey= */ null, DASH_FACTORY.createMediaSource(uri, dataSourceFactory, /* streamKeys= */ null), trackSelectorParameters, Util.getRendererCapabilities(renderersFactory, drmSessionManager)); }
Example 16
Source File: ExoMediaPlayer.java From ExoMedia with Apache License 2.0 | 5 votes |
/** * Return true if at least one renderer for the given type is enabled * @param type The renderer type * @return true if at least one renderer for the given type is enabled */ public boolean isRendererEnabled(@NonNull RendererType type) { MappingTrackSelector.MappedTrackInfo mappedTrackInfo = trackSelector.getCurrentMappedTrackInfo(); ExoPlayerRendererTracksInfo tracksInfo = getExoPlayerTracksInfo(type, 0, mappedTrackInfo); DefaultTrackSelector.Parameters parameters = trackSelector.getParameters(); for (Integer rendererTrackIndex : tracksInfo.rendererTrackIndexes) { if (!parameters.getRendererDisabled(rendererTrackIndex)) { return true; } } return false; }
Example 17
Source File: DownloadHelper.java From Telegram-FOSS with GNU General Public License v2.0 | 3 votes |
/** * Adds a selection of tracks to be downloaded. Must not be called until after preparation * completes. * * @param periodIndex The period index this track selection is added for. * @param trackSelectorParameters The {@link DefaultTrackSelector.Parameters} to obtain the new * selection of tracks. */ public void addTrackSelection( int periodIndex, DefaultTrackSelector.Parameters trackSelectorParameters) { assertPreparedWithMedia(); trackSelector.setParameters(trackSelectorParameters); runTrackSelection(periodIndex); }
Example 18
Source File: DownloadHelper.java From MediaSDK with Apache License 2.0 | 3 votes |
/** * Adds a selection of tracks to be downloaded. Must not be called until after preparation * completes. * * @param periodIndex The period index this track selection is added for. * @param trackSelectorParameters The {@link DefaultTrackSelector.Parameters} to obtain the new * selection of tracks. */ public void addTrackSelection( int periodIndex, DefaultTrackSelector.Parameters trackSelectorParameters) { assertPreparedWithMedia(); trackSelector.setParameters(trackSelectorParameters); runTrackSelection(periodIndex); }
Example 19
Source File: DownloadHelper.java From Telegram-FOSS with GNU General Public License v2.0 | 2 votes |
/** * Replaces a selection of tracks to be downloaded. Must not be called until after preparation * completes. * * @param periodIndex The period index for which the track selection is replaced. * @param trackSelectorParameters The {@link DefaultTrackSelector.Parameters} to obtain the new * selection of tracks. */ public void replaceTrackSelections( int periodIndex, DefaultTrackSelector.Parameters trackSelectorParameters) { clearTrackSelections(periodIndex); addTrackSelection(periodIndex, trackSelectorParameters); }
Example 20
Source File: DownloadHelper.java From Telegram with GNU General Public License v2.0 | 2 votes |
/** * Replaces a selection of tracks to be downloaded. Must not be called until after preparation * completes. * * @param periodIndex The period index for which the track selection is replaced. * @param trackSelectorParameters The {@link DefaultTrackSelector.Parameters} to obtain the new * selection of tracks. */ public void replaceTrackSelections( int periodIndex, DefaultTrackSelector.Parameters trackSelectorParameters) { clearTrackSelections(periodIndex); addTrackSelection(periodIndex, trackSelectorParameters); }