Skip to content

Commit

Permalink
Add util method to extract renderer capabilities.
Browse files Browse the repository at this point in the history
This instantiates the renderers and extract the capabilities. None of the known
renderes incurs any overhead during instantiation.

PiperOrigin-RevId: 224118511
  • Loading branch information
tonihei authored and ojw28 committed Dec 5, 2018
1 parent 0d79208 commit b993367
Showing 1 changed file with 33 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,15 @@
import com.google.android.exoplayer2.ExoPlayerLibraryInfo;
import com.google.android.exoplayer2.Format;
import com.google.android.exoplayer2.ParserException;
import com.google.android.exoplayer2.Renderer;
import com.google.android.exoplayer2.RendererCapabilities;
import com.google.android.exoplayer2.RenderersFactory;
import com.google.android.exoplayer2.SeekParameters;
import com.google.android.exoplayer2.audio.AudioRendererEventListener;
import com.google.android.exoplayer2.drm.DrmSessionManager;
import com.google.android.exoplayer2.drm.FrameworkMediaCrypto;
import com.google.android.exoplayer2.upstream.DataSource;
import com.google.android.exoplayer2.video.VideoRendererEventListener;
import java.io.ByteArrayOutputStream;
import java.io.Closeable;
import java.io.File;
Expand Down Expand Up @@ -1842,6 +1849,32 @@ public static Point getPhysicalDisplaySize(Context context, Display display) {
return displaySize;
}

/**
* Extract renderer capabilities for the renderers created by the provided renderers factory.
*
* @param renderersFactory A {@link RenderersFactory}.
* @param drmSessionManager An optional {@link DrmSessionManager} used by the renderers.
* @return The {@link RendererCapabilities} for each renderer created by the {@code
* renderersFactory}.
*/
public static RendererCapabilities[] getRendererCapabilities(
RenderersFactory renderersFactory,
@Nullable DrmSessionManager<FrameworkMediaCrypto> drmSessionManager) {
Renderer[] renderers =
renderersFactory.createRenderers(
new Handler(),
new VideoRendererEventListener() {},
new AudioRendererEventListener() {},
(cues) -> {},
(metadata) -> {},
drmSessionManager);
RendererCapabilities[] capabilities = new RendererCapabilities[renderers.length];
for (int i = 0; i < renderers.length; i++) {
capabilities[i] = renderers[i].getCapabilities();
}
return capabilities;
}

@Nullable
private static String getSystemProperty(String name) {
try {
Expand Down

0 comments on commit b993367

Please sign in to comment.