mirror of
https://github.com/tapframe/NuvioStreaming.git
synced 2026-04-21 00:32:04 +00:00
optimisations for exo
This commit is contained in:
parent
4fdda9a184
commit
59f77ac831
1 changed files with 4 additions and 7 deletions
|
|
@ -270,6 +270,7 @@ public class ReactExoplayerView extends FrameLayout implements
|
||||||
private final String instanceId = String.valueOf(UUID.randomUUID());
|
private final String instanceId = String.valueOf(UUID.randomUUID());
|
||||||
|
|
||||||
private CmcdConfiguration.Factory cmcdConfigurationFactory;
|
private CmcdConfiguration.Factory cmcdConfigurationFactory;
|
||||||
|
private static final ExecutorService SHARED_EXECUTOR = Executors.newSingleThreadExecutor();
|
||||||
|
|
||||||
public void setCmcdConfigurationFactory(CmcdConfiguration.Factory factory) {
|
public void setCmcdConfigurationFactory(CmcdConfiguration.Factory factory) {
|
||||||
this.cmcdConfigurationFactory = factory;
|
this.cmcdConfigurationFactory = factory;
|
||||||
|
|
@ -683,8 +684,7 @@ public class ReactExoplayerView extends FrameLayout implements
|
||||||
exoPlayerView.invalidateAspectRatio();
|
exoPlayerView.invalidateAspectRatio();
|
||||||
// DRM session manager creation must be done on a different thread to prevent
|
// DRM session manager creation must be done on a different thread to prevent
|
||||||
// crashes so we start a new thread
|
// crashes so we start a new thread
|
||||||
ExecutorService es = Executors.newSingleThreadExecutor();
|
SHARED_EXECUTOR.execute(() -> {
|
||||||
es.execute(() -> {
|
|
||||||
// DRM initialization must run on a different thread
|
// DRM initialization must run on a different thread
|
||||||
if (viewHasDropped && runningSource == source) {
|
if (viewHasDropped && runningSource == source) {
|
||||||
return;
|
return;
|
||||||
|
|
@ -1518,8 +1518,7 @@ public class ReactExoplayerView extends FrameLayout implements
|
||||||
ArrayList<Track> textTracks = getTextTrackInfo();
|
ArrayList<Track> textTracks = getTextTrackInfo();
|
||||||
|
|
||||||
if (source.getContentStartTime() != -1) {
|
if (source.getContentStartTime() != -1) {
|
||||||
ExecutorService es = Executors.newSingleThreadExecutor();
|
SHARED_EXECUTOR.execute(() -> {
|
||||||
es.execute(() -> {
|
|
||||||
// To prevent ANRs caused by getVideoTrackInfo we run this on a different thread
|
// To prevent ANRs caused by getVideoTrackInfo we run this on a different thread
|
||||||
// and notify the player only when we're done
|
// and notify the player only when we're done
|
||||||
ArrayList<VideoTrack> videoTracks = getVideoTrackInfoFromManifest();
|
ArrayList<VideoTrack> videoTracks = getVideoTrackInfoFromManifest();
|
||||||
|
|
@ -1632,12 +1631,11 @@ public class ReactExoplayerView extends FrameLayout implements
|
||||||
// conditions
|
// conditions
|
||||||
@WorkerThread
|
@WorkerThread
|
||||||
private ArrayList<VideoTrack> getVideoTrackInfoFromManifest(int retryCount) {
|
private ArrayList<VideoTrack> getVideoTrackInfoFromManifest(int retryCount) {
|
||||||
ExecutorService es = Executors.newSingleThreadExecutor();
|
|
||||||
final DataSource dataSource = this.mediaDataSourceFactory.createDataSource();
|
final DataSource dataSource = this.mediaDataSourceFactory.createDataSource();
|
||||||
final Uri sourceUri = source.getUri();
|
final Uri sourceUri = source.getUri();
|
||||||
final long startTime = source.getContentStartTime() * 1000 - 100; // s -> ms with 100ms offset
|
final long startTime = source.getContentStartTime() * 1000 - 100; // s -> ms with 100ms offset
|
||||||
|
|
||||||
Future<ArrayList<VideoTrack>> result = es.submit(new Callable() {
|
Future<ArrayList<VideoTrack>> result = SHARED_EXECUTOR.submit(new Callable<ArrayList<VideoTrack>>() {
|
||||||
final DataSource ds = dataSource;
|
final DataSource ds = dataSource;
|
||||||
final Uri uri = sourceUri;
|
final Uri uri = sourceUri;
|
||||||
final long startTimeUs = startTime * 1000; // ms -> us
|
final long startTimeUs = startTime * 1000; // ms -> us
|
||||||
|
|
@ -1687,7 +1685,6 @@ public class ReactExoplayerView extends FrameLayout implements
|
||||||
if (results == null && retryCount < 1) {
|
if (results == null && retryCount < 1) {
|
||||||
return this.getVideoTrackInfoFromManifest(++retryCount);
|
return this.getVideoTrackInfoFromManifest(++retryCount);
|
||||||
}
|
}
|
||||||
es.shutdown();
|
|
||||||
return results;
|
return results;
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
DebugLog.w(TAG, "error in getVideoTrackInfoFromManifest handling request:" + e.getMessage());
|
DebugLog.w(TAG, "error in getVideoTrackInfoFromManifest handling request:" + e.getMessage());
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue