com.google.android.exoplayer2.upstream.DataSource.Factory Java Examples
The following examples show how to use
com.google.android.exoplayer2.upstream.DataSource.Factory.
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 | 7 votes |
/** * Utility method to create a MediaSource which only contains the tracks defined in {@code * downloadRequest}. * * @param downloadRequest A {@link DownloadRequest}. * @param dataSourceFactory A factory for {@link DataSource}s to read the media. * @return A MediaSource which only contains the tracks defined in {@code downloadRequest}. */ public static MediaSource createMediaSource( DownloadRequest downloadRequest, DataSource.Factory dataSourceFactory) { MediaSourceFactory factory; switch (downloadRequest.type) { case DownloadRequest.TYPE_DASH: factory = DASH_FACTORY; break; case DownloadRequest.TYPE_SS: factory = SS_FACTORY; break; case DownloadRequest.TYPE_HLS: factory = HLS_FACTORY; break; case DownloadRequest.TYPE_PROGRESSIVE: return new ProgressiveMediaSource.Factory(dataSourceFactory) .createMediaSource(downloadRequest.uri); default: throw new IllegalStateException("Unsupported type: " + downloadRequest.type); } return factory.createMediaSource( downloadRequest.uri, dataSourceFactory, downloadRequest.streamKeys); }
Example #2
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 #3
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 #4
Source File: DownloadHelper.java From MediaSDK with Apache License 2.0 | 6 votes |
private static MediaSource createMediaSourceInternal( @Nullable Constructor<? extends MediaSourceFactory> constructor, Uri uri, Factory dataSourceFactory, @Nullable List<StreamKey> streamKeys) { if (constructor == null) { throw new IllegalStateException("Module missing to create media source."); } try { MediaSourceFactory factory = constructor.newInstance(dataSourceFactory); if (streamKeys != null) { factory.setStreamKeys(streamKeys); } return Assertions.checkNotNull(factory.createMediaSource(uri)); } catch (Exception e) { throw new IllegalStateException("Failed to instantiate media source.", e); } }
Example #5
Source File: DownloadHelper.java From MediaSDK with Apache License 2.0 | 6 votes |
/** * Utility method to create a MediaSource which only contains the tracks defined in {@code * downloadRequest}. * * @param downloadRequest A {@link DownloadRequest}. * @param dataSourceFactory A factory for {@link DataSource}s to read the media. * @return A MediaSource which only contains the tracks defined in {@code downloadRequest}. */ public static MediaSource createMediaSource( DownloadRequest downloadRequest, DataSource.Factory dataSourceFactory) { @Nullable Constructor<? extends MediaSourceFactory> constructor; switch (downloadRequest.type) { case DownloadRequest.TYPE_DASH: constructor = DASH_FACTORY_CONSTRUCTOR; break; case DownloadRequest.TYPE_SS: constructor = SS_FACTORY_CONSTRUCTOR; break; case DownloadRequest.TYPE_HLS: constructor = HLS_FACTORY_CONSTRUCTOR; break; case DownloadRequest.TYPE_PROGRESSIVE: return new ProgressiveMediaSource.Factory(dataSourceFactory) .createMediaSource(downloadRequest.uri); default: throw new IllegalStateException("Unsupported type: " + downloadRequest.type); } return createMediaSourceInternal( constructor, downloadRequest.uri, dataSourceFactory, downloadRequest.streamKeys); }
Example #6
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 #7
Source File: DownloadHelper.java From Telegram with GNU General Public License v2.0 | 6 votes |
/** * Utility method to create a MediaSource which only contains the tracks defined in {@code * downloadRequest}. * * @param downloadRequest A {@link DownloadRequest}. * @param dataSourceFactory A factory for {@link DataSource}s to read the media. * @return A MediaSource which only contains the tracks defined in {@code downloadRequest}. */ public static MediaSource createMediaSource( DownloadRequest downloadRequest, DataSource.Factory dataSourceFactory) { MediaSourceFactory factory; switch (downloadRequest.type) { case DownloadRequest.TYPE_DASH: factory = DASH_FACTORY; break; case DownloadRequest.TYPE_SS: factory = SS_FACTORY; break; case DownloadRequest.TYPE_HLS: factory = HLS_FACTORY; break; case DownloadRequest.TYPE_PROGRESSIVE: return new ProgressiveMediaSource.Factory(dataSourceFactory) .createMediaSource(downloadRequest.uri); default: throw new IllegalStateException("Unsupported type: " + downloadRequest.type); } return factory.createMediaSource( downloadRequest.uri, dataSourceFactory, downloadRequest.streamKeys); }
Example #8
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 #9
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 #10
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 #11
Source File: DefaultDataSourceFactory.java From TelePlus-Android with GNU General Public License v2.0 | 5 votes |
/** * @param context A context. * @param listener An optional listener. * @param baseDataSourceFactory A {@link Factory} to be used to create a base {@link DataSource} * for {@link DefaultDataSource}. * @see DefaultDataSource#DefaultDataSource(Context, TransferListener, DataSource) */ public DefaultDataSourceFactory( Context context, @Nullable TransferListener listener, DataSource.Factory baseDataSourceFactory) { this.context = context.getApplicationContext(); this.listener = listener; this.baseDataSourceFactory = baseDataSourceFactory; }
Example #12
Source File: PriorityDataSourceFactory.java From Telegram-FOSS with GNU General Public License v2.0 | 5 votes |
/** * @param upstreamFactory A {@link DataSource.Factory} to be used to create an upstream {@link * DataSource} for {@link PriorityDataSource}. * @param priorityTaskManager The priority manager to which PriorityDataSource task is registered. * @param priority The priority of PriorityDataSource task. */ public PriorityDataSourceFactory(Factory upstreamFactory, PriorityTaskManager priorityTaskManager, int priority) { this.upstreamFactory = upstreamFactory; this.priorityTaskManager = priorityTaskManager; this.priority = priority; }
Example #13
Source File: DownloaderConstructorHelper.java From TelePlus-Android with GNU General Public License v2.0 | 5 votes |
/** * @param cache Cache instance to be used to store downloaded data. * @param upstreamDataSourceFactory A {@link Factory} for downloading data. * @param cacheReadDataSourceFactory A {@link Factory} for reading data from the cache. If null * then standard {@link FileDataSource} instances will be used. * @param cacheWriteDataSinkFactory A {@link DataSink.Factory} for writing data to the cache. If * null then standard {@link CacheDataSink} instances will be used. * @param priorityTaskManager A {@link PriorityTaskManager} to use when downloading. If non-null, * downloaders will register as tasks with priority {@link C#PRIORITY_DOWNLOAD} whilst * downloading. */ public DownloaderConstructorHelper( Cache cache, Factory upstreamDataSourceFactory, @Nullable Factory cacheReadDataSourceFactory, @Nullable DataSink.Factory cacheWriteDataSinkFactory, @Nullable PriorityTaskManager priorityTaskManager) { Assertions.checkNotNull(upstreamDataSourceFactory); this.cache = cache; this.upstreamDataSourceFactory = upstreamDataSourceFactory; this.cacheReadDataSourceFactory = cacheReadDataSourceFactory; this.cacheWriteDataSinkFactory = cacheWriteDataSinkFactory; this.priorityTaskManager = priorityTaskManager; }
Example #14
Source File: PriorityDataSourceFactory.java From TelePlus-Android with GNU General Public License v2.0 | 5 votes |
/** * @param upstreamFactory A {@link DataSource.Factory} to be used to create an upstream {@link * DataSource} for {@link PriorityDataSource}. * @param priorityTaskManager The priority manager to which PriorityDataSource task is registered. * @param priority The priority of PriorityDataSource task. */ public PriorityDataSourceFactory(Factory upstreamFactory, PriorityTaskManager priorityTaskManager, int priority) { this.upstreamFactory = upstreamFactory; this.priorityTaskManager = priorityTaskManager; this.priority = priority; }
Example #15
Source File: CacheDataSourceFactory.java From TelePlus-Android with GNU General Public License v2.0 | 5 votes |
/** * @see CacheDataSource#CacheDataSource(Cache, DataSource, DataSource, DataSink, int, * EventListener) */ public CacheDataSourceFactory(Cache cache, Factory upstreamFactory, Factory cacheReadDataSourceFactory, DataSink.Factory cacheWriteDataSinkFactory, @CacheDataSource.Flags int flags, EventListener eventListener) { this.cache = cache; this.upstreamFactory = upstreamFactory; this.cacheReadDataSourceFactory = cacheReadDataSourceFactory; this.cacheWriteDataSinkFactory = cacheWriteDataSinkFactory; this.flags = flags; this.eventListener = eventListener; }
Example #16
Source File: PriorityDataSourceFactory.java From K-Sonic with MIT License | 5 votes |
/** * @param upstreamFactory A {@link DataSource.Factory} to be used to create an upstream {@link * DataSource} for {@link PriorityDataSource}. * @param priorityTaskManager The priority manager to which PriorityDataSource task is registered. * @param priority The priority of PriorityDataSource task. */ public PriorityDataSourceFactory(Factory upstreamFactory, PriorityTaskManager priorityTaskManager, int priority) { this.upstreamFactory = upstreamFactory; this.priorityTaskManager = priorityTaskManager; this.priority = priority; }
Example #17
Source File: CacheDataSourceFactory.java From K-Sonic with MIT License | 5 votes |
/** * @see CacheDataSource#CacheDataSource(Cache, DataSource, DataSource, DataSink, int, * EventListener) */ public CacheDataSourceFactory(Cache cache, Factory upstreamFactory, Factory cacheReadDataSourceFactory, DataSink.Factory cacheWriteDataSinkFactory, int flags, EventListener eventListener) { this.cache = cache; this.upstreamFactory = upstreamFactory; this.cacheReadDataSourceFactory = cacheReadDataSourceFactory; this.cacheWriteDataSinkFactory = cacheWriteDataSinkFactory; this.flags = flags; this.eventListener = eventListener; }
Example #18
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 #19
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 #20
Source File: DefaultDataSourceFactory.java From MediaSDK with Apache License 2.0 | 5 votes |
/** * @param context A context. * @param listener An optional listener. * @param baseDataSourceFactory A {@link Factory} to be used to create a base {@link DataSource} * for {@link DefaultDataSource}. * @see DefaultDataSource#DefaultDataSource(Context, DataSource) */ public DefaultDataSourceFactory( Context context, @Nullable TransferListener listener, Factory baseDataSourceFactory) { this.context = context.getApplicationContext(); this.listener = listener; this.baseDataSourceFactory = baseDataSourceFactory; }
Example #21
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 #22
Source File: DownloadHelper.java From Telegram-FOSS with GNU General Public License v2.0 | 5 votes |
private MediaSource createMediaSource( Uri uri, Factory dataSourceFactory, @Nullable List<StreamKey> streamKeys) { if (constructor == null || setStreamKeysMethod == null || createMethod == null) { throw new IllegalStateException("Module missing to create media source."); } try { Object factory = constructor.newInstance(dataSourceFactory); if (streamKeys != null) { setStreamKeysMethod.invoke(factory, streamKeys); } return (MediaSource) Assertions.checkNotNull(createMethod.invoke(factory, uri)); } catch (Exception e) { throw new IllegalStateException("Failed to instantiate media source.", e); } }
Example #23
Source File: DefaultDataSourceFactory.java From Telegram-FOSS with GNU General Public License v2.0 | 5 votes |
/** * @param context A context. * @param listener An optional listener. * @param baseDataSourceFactory A {@link Factory} to be used to create a base {@link DataSource} * for {@link DefaultDataSource}. * @see DefaultDataSource#DefaultDataSource(Context, TransferListener, DataSource) */ public DefaultDataSourceFactory( Context context, @Nullable TransferListener listener, DataSource.Factory baseDataSourceFactory) { this.context = context.getApplicationContext(); this.listener = listener; this.baseDataSourceFactory = baseDataSourceFactory; }
Example #24
Source File: DownloadHelper.java From MediaSDK with Apache License 2.0 | 5 votes |
/** * Creates a {@link DownloadHelper} for DASH streams. * * @param context Any {@link Context}. * @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. * @return A {@link DownloadHelper} for DASH streams. * @throws IllegalStateException If the DASH module is missing. */ public static DownloadHelper forDash( Context context, Uri uri, DataSource.Factory dataSourceFactory, RenderersFactory renderersFactory) { return forDash( uri, dataSourceFactory, renderersFactory, /* drmSessionManager= */ null, getDefaultTrackSelectorParameters(context)); }
Example #25
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 #26
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 #27
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 #28
Source File: DownloadHelper.java From Telegram with GNU General Public License v2.0 | 5 votes |
private MediaSource createMediaSource( Uri uri, Factory dataSourceFactory, @Nullable List<StreamKey> streamKeys) { if (constructor == null || setStreamKeysMethod == null || createMethod == null) { throw new IllegalStateException("Module missing to create media source."); } try { Object factory = constructor.newInstance(dataSourceFactory); if (streamKeys != null) { setStreamKeysMethod.invoke(factory, streamKeys); } return (MediaSource) Assertions.checkNotNull(createMethod.invoke(factory, uri)); } catch (Exception e) { throw new IllegalStateException("Failed to instantiate media source.", e); } }
Example #29
Source File: DefaultDataSourceFactory.java From Telegram with GNU General Public License v2.0 | 5 votes |
/** * @param context A context. * @param listener An optional listener. * @param baseDataSourceFactory A {@link Factory} to be used to create a base {@link DataSource} * for {@link DefaultDataSource}. * @see DefaultDataSource#DefaultDataSource(Context, TransferListener, DataSource) */ public DefaultDataSourceFactory( Context context, @Nullable TransferListener listener, DataSource.Factory baseDataSourceFactory) { this.context = context.getApplicationContext(); this.listener = listener; this.baseDataSourceFactory = baseDataSourceFactory; }
Example #30
Source File: PriorityDataSourceFactory.java From Telegram with GNU General Public License v2.0 | 5 votes |
/** * @param upstreamFactory A {@link DataSource.Factory} to be used to create an upstream {@link * DataSource} for {@link PriorityDataSource}. * @param priorityTaskManager The priority manager to which PriorityDataSource task is registered. * @param priority The priority of PriorityDataSource task. */ public PriorityDataSourceFactory(Factory upstreamFactory, PriorityTaskManager priorityTaskManager, int priority) { this.upstreamFactory = upstreamFactory; this.priorityTaskManager = priorityTaskManager; this.priority = priority; }