Skip to content

Commit

Permalink
Prepare and release DrmSessionManager in Renderers
Browse files Browse the repository at this point in the history
Issue: #6951
PiperOrigin-RevId: 294187695
  • Loading branch information
AquilesCanta authored and kim-vde committed Feb 11, 2020
1 parent 7c85ca0 commit ac8a2e8
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 5 deletions.
6 changes: 4 additions & 2 deletions RELEASENOTES.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@
* Upgrade Truth dependency from 0.44 to 1.0.
* Upgrade to JUnit 4.13-rc-2.
* UI
* move logic of prev, next, fast forward and rewind to ControlDispatcher
[#6926](https://github.com/google/ExoPlayer/issues/6926)).
* Move logic of prev, next, fast forward and rewind to ControlDispatcher
([#6926](https://github.com/google/ExoPlayer/issues/6926)).
* Demo apps: Add
[GL demo app](https://github.com/google/ExoPlayer/tree/dev-v2/demos/gl) to
show how to render video to a `GLSurfaceView` while applying a GL shader.
Expand Down Expand Up @@ -101,6 +101,8 @@
on earlier releases, but only when embedded in a non-FLAC container such as
Matroska or MP4.
* Add support for ID3 genres added in Wimamp 5.6 (2010).
* DRM: Fix `NullPointerException` when playing DRM-protected content
([#6951](https://github.com/google/ExoPlayer/issues/6951)).

### 2.11.1 (2019-12-20) ###

Expand Down
5 changes: 2 additions & 3 deletions demos/main/src/main/assets/media.exolist.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,8 @@
"name": "YouTube DASH",
"samples": [
{
"name": "Google Glass (MP4,H264)",
"uri": "https://www.youtube.com/api/manifest/dash/id/bf5bb2419360daf1/source/youtube?as=fmp4_audio_clear,fmp4_sd_hd_clear&sparams=ip,ipbits,expire,source,id,as&ip=0.0.0.0&ipbits=0&expire=19000000000&signature=51AF5F39AB0CEC3E5497CD9C900EBFEAECCCB5C7.8506521BFC350652163895D4C26DEE124209AA9E&key=ik0",
"extension": "mpd"
"name": "6956",
"uri": "http://master255.org/res/%d0%9a%d0%bb%d0%b8%d0%bf%d1%8b/B/Billy%20Mack/Billy%20Mack%20-%20Christmas%20Is%20All%20Around.mpg"
},
{
"name": "Google Play (MP4,H264)",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ public abstract class SimpleDecoderAudioRenderer extends BaseRenderer implements
private final AudioSink audioSink;
private final DecoderInputBuffer flagsOnlyBuffer;

private boolean drmResourcesAcquired;
private DecoderCounters decoderCounters;
private Format inputFormat;
private int encoderDelay;
Expand Down Expand Up @@ -543,6 +544,10 @@ public PlaybackParameters getPlaybackParameters() {

@Override
protected void onEnabled(boolean joining) throws ExoPlaybackException {
if (drmSessionManager != null && !drmResourcesAcquired) {
drmResourcesAcquired = true;
drmSessionManager.prepare();
}
decoderCounters = new DecoderCounters();
eventDispatcher.enabled(decoderCounters);
int tunnelingAudioSessionId = getConfiguration().tunnelingAudioSessionId;
Expand Down Expand Up @@ -591,6 +596,14 @@ protected void onDisabled() {
}
}

@Override
protected void onReset() {
if (drmSessionManager != null && drmResourcesAcquired) {
drmResourcesAcquired = false;
drmSessionManager.release();
}
}

@Override
public void handleMessage(int messageType, @Nullable Object message) throws ExoPlaybackException {
switch (messageType) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -371,6 +371,7 @@ private static String getDiagnosticInfoV21(Throwable cause) {
private final ArrayList<Long> decodeOnlyPresentationTimestamps;
private final MediaCodec.BufferInfo outputBufferInfo;

private boolean drmResourcesAcquired;
@Nullable private Format inputFormat;
private Format outputFormat;
@Nullable private DrmSession<FrameworkMediaCrypto> codecDrmSession;
Expand Down Expand Up @@ -659,6 +660,10 @@ protected final MediaCodecInfo getCodecInfo() {

@Override
protected void onEnabled(boolean joining) throws ExoPlaybackException {
if (drmSessionManager != null && !drmResourcesAcquired) {
drmResourcesAcquired = true;
drmSessionManager.prepare();
}
decoderCounters = new DecoderCounters();
}

Expand Down Expand Up @@ -705,6 +710,10 @@ protected void onReset() {
} finally {
setSourceDrmSession(null);
}
if (drmSessionManager != null && drmResourcesAcquired) {
drmResourcesAcquired = false;
drmSessionManager.release();
}
}

protected void releaseCodec() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ public abstract class SimpleDecoderVideoRenderer extends BaseRenderer {
private final DecoderInputBuffer flagsOnlyBuffer;
private final DrmSessionManager<ExoMediaCrypto> drmSessionManager;

private boolean drmResourcesAcquired;
private Format inputFormat;
private Format outputFormat;
private SimpleDecoder<
Expand Down Expand Up @@ -237,6 +238,10 @@ public boolean isReady() {

@Override
protected void onEnabled(boolean joining) throws ExoPlaybackException {
if (drmSessionManager != null && !drmResourcesAcquired) {
drmResourcesAcquired = true;
drmSessionManager.prepare();
}
decoderCounters = new DecoderCounters();
eventDispatcher.enabled(decoderCounters);
}
Expand Down Expand Up @@ -286,6 +291,14 @@ protected void onDisabled() {
}
}

@Override
protected void onReset() {
if (drmSessionManager != null && drmResourcesAcquired) {
drmResourcesAcquired = false;
drmSessionManager.release();
}
}

@Override
protected void onStreamChanged(Format[] formats, long offsetUs) throws ExoPlaybackException {
outputStreamOffsetUs = offsetUs;
Expand Down

0 comments on commit ac8a2e8

Please sign in to comment.