com.google.android.exoplayer2.trackselection.TrackSelection.Definition Java Examples
The following examples show how to use
com.google.android.exoplayer2.trackselection.TrackSelection.Definition.
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: TrackSelectionUtil.java From MediaSDK with Apache License 2.0 | 6 votes |
/** * Creates track selections for an array of track selection definitions, with at most one * multi-track adaptive selection. * * @param definitions The list of track selection {@link Definition definitions}. May include null * values. * @param adaptiveTrackSelectionFactory A factory for the multi-track adaptive track selection. * @return The array of created track selection. For null entries in {@code definitions} returns * null values. */ public static @NullableType TrackSelection[] createTrackSelectionsForDefinitions( @NullableType Definition[] definitions, AdaptiveTrackSelectionFactory adaptiveTrackSelectionFactory) { TrackSelection[] selections = new TrackSelection[definitions.length]; boolean createdAdaptiveTrackSelection = false; for (int i = 0; i < definitions.length; i++) { Definition definition = definitions[i]; if (definition == null) { continue; } if (definition.tracks.length > 1 && !createdAdaptiveTrackSelection) { createdAdaptiveTrackSelection = true; selections[i] = adaptiveTrackSelectionFactory.createAdaptiveTrackSelection(definition); } else { selections[i] = new FixedTrackSelection( definition.group, definition.tracks[0], definition.reason, definition.data); } } return selections; }
Example #2
Source File: TrackSelectionUtil.java From Telegram-FOSS with GNU General Public License v2.0 | 6 votes |
/** * Creates track selections for an array of track selection definitions, with at most one * multi-track adaptive selection. * * @param definitions The list of track selection {@link Definition definitions}. May include null * values. * @param adaptiveTrackSelectionFactory A factory for the multi-track adaptive track selection. * @return The array of created track selection. For null entries in {@code definitions} returns * null values. */ public static @NullableType TrackSelection[] createTrackSelectionsForDefinitions( @NullableType Definition[] definitions, AdaptiveTrackSelectionFactory adaptiveTrackSelectionFactory) { TrackSelection[] selections = new TrackSelection[definitions.length]; boolean createdAdaptiveTrackSelection = false; for (int i = 0; i < definitions.length; i++) { Definition definition = definitions[i]; if (definition == null) { continue; } if (definition.tracks.length > 1 && !createdAdaptiveTrackSelection) { createdAdaptiveTrackSelection = true; selections[i] = adaptiveTrackSelectionFactory.createAdaptiveTrackSelection(definition); } else { selections[i] = new FixedTrackSelection( definition.group, definition.tracks[0], definition.reason, definition.data); } } return selections; }
Example #3
Source File: TrackSelectionUtil.java From Telegram with GNU General Public License v2.0 | 6 votes |
/** * Creates track selections for an array of track selection definitions, with at most one * multi-track adaptive selection. * * @param definitions The list of track selection {@link Definition definitions}. May include null * values. * @param adaptiveTrackSelectionFactory A factory for the multi-track adaptive track selection. * @return The array of created track selection. For null entries in {@code definitions} returns * null values. */ public static @NullableType TrackSelection[] createTrackSelectionsForDefinitions( @NullableType Definition[] definitions, AdaptiveTrackSelectionFactory adaptiveTrackSelectionFactory) { TrackSelection[] selections = new TrackSelection[definitions.length]; boolean createdAdaptiveTrackSelection = false; for (int i = 0; i < definitions.length; i++) { Definition definition = definitions[i]; if (definition == null) { continue; } if (definition.tracks.length > 1 && !createdAdaptiveTrackSelection) { createdAdaptiveTrackSelection = true; selections[i] = adaptiveTrackSelectionFactory.createAdaptiveTrackSelection(definition); } else { selections[i] = new FixedTrackSelection( definition.group, definition.tracks[0], definition.reason, definition.data); } } return selections; }
Example #4
Source File: BufferSizeAdaptationBuilder.java From MediaSDK with Apache License 2.0 | 4 votes |
/** * Builds player components for buffer size based track adaptation. * * @return A pair of a {@link TrackSelection.Factory} and a {@link LoadControl}, which should be * used to construct the player. */ public Pair<TrackSelection.Factory, LoadControl> buildPlayerComponents() { Assertions.checkArgument(hysteresisBufferMs < maxBufferMs - minBufferMs); Assertions.checkState(!buildCalled); buildCalled = true; DefaultLoadControl.Builder loadControlBuilder = new DefaultLoadControl.Builder() .setTargetBufferBytes(/* targetBufferBytes = */ Integer.MAX_VALUE) .setBufferDurationsMs( /* minBufferMs= */ maxBufferMs, maxBufferMs, bufferForPlaybackMs, bufferForPlaybackAfterRebufferMs); if (allocator != null) { loadControlBuilder.setAllocator(allocator); } TrackSelection.Factory trackSelectionFactory = new TrackSelection.Factory() { @Override public @NullableType TrackSelection[] createTrackSelections( @NullableType Definition[] definitions, BandwidthMeter bandwidthMeter) { return TrackSelectionUtil.createTrackSelectionsForDefinitions( definitions, definition -> new BufferSizeAdaptiveTrackSelection( definition.group, definition.tracks, bandwidthMeter, minBufferMs, maxBufferMs, hysteresisBufferMs, startUpBandwidthFraction, startUpMinBufferForQualityIncreaseMs, dynamicFormatFilter, clock)); } }; return Pair.create(trackSelectionFactory, loadControlBuilder.createDefaultLoadControl()); }
Example #5
Source File: BufferSizeAdaptationBuilder.java From Telegram-FOSS with GNU General Public License v2.0 | 4 votes |
/** * Builds player components for buffer size based track adaptation. * * @return A pair of a {@link TrackSelection.Factory} and a {@link LoadControl}, which should be * used to construct the player. */ public Pair<TrackSelection.Factory, LoadControl> buildPlayerComponents() { Assertions.checkArgument(hysteresisBufferMs < maxBufferMs - minBufferMs); Assertions.checkState(!buildCalled); buildCalled = true; DefaultLoadControl.Builder loadControlBuilder = new DefaultLoadControl.Builder() .setTargetBufferBytes(/* targetBufferBytes = */ Integer.MAX_VALUE) .setBufferDurationsMs( /* minBufferMs= */ maxBufferMs, maxBufferMs, bufferForPlaybackMs, bufferForPlaybackAfterRebufferMs); if (allocator != null) { loadControlBuilder.setAllocator(allocator); } TrackSelection.Factory trackSelectionFactory = new TrackSelection.Factory() { @Override public @NullableType TrackSelection[] createTrackSelections( @NullableType Definition[] definitions, BandwidthMeter bandwidthMeter) { return TrackSelectionUtil.createTrackSelectionsForDefinitions( definitions, definition -> new BufferSizeAdaptiveTrackSelection( definition.group, definition.tracks, bandwidthMeter, minBufferMs, maxBufferMs, hysteresisBufferMs, startUpBandwidthFraction, startUpMinBufferForQualityIncreaseMs, dynamicFormatFilter, clock)); } }; return Pair.create(trackSelectionFactory, loadControlBuilder.createDefaultLoadControl()); }
Example #6
Source File: BufferSizeAdaptationBuilder.java From Telegram with GNU General Public License v2.0 | 4 votes |
/** * Builds player components for buffer size based track adaptation. * * @return A pair of a {@link TrackSelection.Factory} and a {@link LoadControl}, which should be * used to construct the player. */ public Pair<TrackSelection.Factory, LoadControl> buildPlayerComponents() { Assertions.checkArgument(hysteresisBufferMs < maxBufferMs - minBufferMs); Assertions.checkState(!buildCalled); buildCalled = true; DefaultLoadControl.Builder loadControlBuilder = new DefaultLoadControl.Builder() .setTargetBufferBytes(/* targetBufferBytes = */ Integer.MAX_VALUE) .setBufferDurationsMs( /* minBufferMs= */ maxBufferMs, maxBufferMs, bufferForPlaybackMs, bufferForPlaybackAfterRebufferMs); if (allocator != null) { loadControlBuilder.setAllocator(allocator); } TrackSelection.Factory trackSelectionFactory = new TrackSelection.Factory() { @Override public @NullableType TrackSelection[] createTrackSelections( @NullableType Definition[] definitions, BandwidthMeter bandwidthMeter) { return TrackSelectionUtil.createTrackSelectionsForDefinitions( definitions, definition -> new BufferSizeAdaptiveTrackSelection( definition.group, definition.tracks, bandwidthMeter, minBufferMs, maxBufferMs, hysteresisBufferMs, startUpBandwidthFraction, startUpMinBufferForQualityIncreaseMs, dynamicFormatFilter, clock)); } }; return Pair.create(trackSelectionFactory, loadControlBuilder.createDefaultLoadControl()); }
Example #7
Source File: TrackSelectionUtil.java From MediaSDK with Apache License 2.0 | 2 votes |
/** * Creates an adaptive track selection for the provided track selection definition. * * @param trackSelectionDefinition A {@link Definition} for the track selection. * @return The created track selection. */ TrackSelection createAdaptiveTrackSelection(Definition trackSelectionDefinition);
Example #8
Source File: TrackSelectionUtil.java From Telegram-FOSS with GNU General Public License v2.0 | 2 votes |
/** * Creates an adaptive track selection for the provided track selection definition. * * @param trackSelectionDefinition A {@link Definition} for the track selection. * @return The created track selection. */ TrackSelection createAdaptiveTrackSelection(Definition trackSelectionDefinition);
Example #9
Source File: TrackSelectionUtil.java From Telegram with GNU General Public License v2.0 | 2 votes |
/** * Creates an adaptive track selection for the provided track selection definition. * * @param trackSelectionDefinition A {@link Definition} for the track selection. * @return The created track selection. */ TrackSelection createAdaptiveTrackSelection(Definition trackSelectionDefinition);