com.google.android.exoplayer2.trackselection.DefaultTrackSelector.Parameters Java Examples
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 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 #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 Telegram 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 #4
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 #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: 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 #7
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 #8
Source File: DownloadHelper.java From MediaSDK with Apache License 2.0 | 6 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, createMediaSourceInternal( HLS_FACTORY_CONSTRUCTOR, uri, dataSourceFactory, /* streamKeys= */ null), trackSelectorParameters, Util.getRendererCapabilities(renderersFactory, drmSessionManager)); }
Example #9
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 #10
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 #11
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 #12
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 #13
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 #14
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 #15
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 #16
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 #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 Telegram 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 #19
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 #20
Source File: DownloadHelper.java From MediaSDK with Apache License 2.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 #21
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); }
Example #22
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); }