You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
You need to overwrite CronetDataSource and read the protocol after opening the source:
public class MyCronetSource extends CronetDataSource {
public MyCronetSource(CronetEngine cronetEngine) {
super(cronetEngine, Executors.newSingleThreadExecutor(), null);
}
@Override
public long open(DataSpec dataSpec) throws IOException {
long result = super.open(dataSpec);
// Use getCurrentUrlResponseInfo() here and in any other method of the data source.
// This method is call ed on the background loading thread.
return result;
}
}
And to set up the player just create your data source in a factory:
DataSource.Factory factory = () -> new MyCronetDataSource(cronetEngine);
I have tried that approach by implementing:
class MyCronetSource extends CronetDataSource {
public MyCronetSource(CronetEngine cronetEngine) {
super(cronetEngine,
Executors.newSingleThreadExecutor(),
REQUEST_PRIORITY_MEDIUM,
DEFAULT_CONNECT_TIMEOUT_MILLIS,
DEFAULT_READ_TIMEOUT_MILLIS,
false,
false,
"User agent foo",
null,
null,
true
);
Log.i("App", "MyCronetSource constructed");
}
@Override
public long open(DataSpec dataSpec) throws HttpDataSourceException {
Log.i("App", "open called");
long result = super.open(dataSpec);
Log.i("App", getCurrentUrlResponseInfo().getNegotiatedProtocol());
// Use getCurrentUrlResponseInfo() here and in any other method of the data source.
// This method is call ed on the background loading thread.
return result;
}
And then setting it via httpDataSourceFactory = () -> new MyCronetSource(cronetEngine);
But the open method is never called. Which makes me think that something has changed over the past 4 years and this approach is maybe no longer relevant. Any guidance on that?
I am working on top of commit 03569f9e6536e6c60cb585115d6d7352a4deab71 (HEAD -> release-v2, tag: r2.18.0, origin/release-v2, origin/HEAD)
This is possibly a duplicate of androidx/media#116 which is a bug in the DefaultMediaSourceFactory.
The demo app does
new DefaultMediaSourceFactory(/* context= */ this)
.setDataSourceFactory(dataSourceFactory);
which internally creates a DefaultHttpDataSource in the constructor and the dataSourceFactory passed to the setter is ignored. This would in a very trivial way explain why you are seeing HTTP.
The quick fix would be to do
new DefaultMediaSourceFactory(dataSourceFactory)
We have fixed this already and this will be shipped with the next release that is soon, like tomorrow or start of next week.
Can you confirm that this is removing this behaviour for you? I that's the case, sorry for the confusion and inconvenience and thanks for the excellent bug report.
marcbaechinger
changed the title
Issues with ExoPlayer and QUIC that dont appear with just Cronet
DefaultMediaSourceFactory ignores custom Cronet data source
Jul 14, 2022
Hey folks,
Core Problem
I am trying to enabled QUIC for ExoPlayer and I am running into issues that I believe are specific (in a way that is not clear to me) to ExoPlayer.
For start I have following piece of code:
That connection is going over the wire with HTTP3 (validated both via
MyUrlRequestCallback
and a packetdump)Now when I use the same
cronetEngine
on ExoPlayer it never goes through HTTP3.In the demo APP I change the following (full diff bellow):
But the connection goes over TCP when I try it with wireshark.
Debugging Attempts
I have attempted to debug this by following #5134
In the comments @tonihei mentions
I have tried that approach by implementing:
And then setting it via
httpDataSourceFactory = () -> new MyCronetSource(cronetEngine);
But the
open
method is never called. Which makes me think that something has changed over the past 4 years and this approach is maybe no longer relevant. Any guidance on that?I am working on top of commit
03569f9e6536e6c60cb585115d6d7352a4deab71 (HEAD -> release-v2, tag: r2.18.0, origin/release-v2, origin/HEAD)
cc @jamesonwilliams
Git Diff Patch
The text was updated successfully, but these errors were encountered: