Rename DrmConfiguration.sessionForClearTypes to forcedSessionTrackTypes
The previous name is quite easy to misread because it sounds like it splits up like "(session) for (clear types)" when it's meant to be "(session for clear) (types)". The old field is left deprecated for backwards compatibility. The DrmConfiguration.Builder methods are directly renamed without deprecation because they're not yet present in a released version of the library. PiperOrigin-RevId: 403338799
This commit is contained in:
parent
5ef00f0e96
commit
61c8f8c27e
@ -177,7 +177,7 @@ public class IntentUtil {
|
|||||||
intent.getBooleanExtra(
|
intent.getBooleanExtra(
|
||||||
DRM_FORCE_DEFAULT_LICENSE_URI_EXTRA + extrasKeySuffix, false))
|
DRM_FORCE_DEFAULT_LICENSE_URI_EXTRA + extrasKeySuffix, false))
|
||||||
.setLicenseRequestHeaders(headers)
|
.setLicenseRequestHeaders(headers)
|
||||||
.setSessionForClearPeriods(
|
.forceSessionsForAudioAndVideoTracks(
|
||||||
intent.getBooleanExtra(DRM_SESSION_FOR_CLEAR_CONTENT + extrasKeySuffix, false))
|
intent.getBooleanExtra(DRM_SESSION_FOR_CLEAR_CONTENT + extrasKeySuffix, false))
|
||||||
.build());
|
.build());
|
||||||
}
|
}
|
||||||
|
@ -445,7 +445,7 @@ public class SampleChooserActivity extends AppCompatActivity
|
|||||||
new MediaItem.DrmConfiguration.Builder(drmUuid)
|
new MediaItem.DrmConfiguration.Builder(drmUuid)
|
||||||
.setLicenseUri(drmLicenseUri)
|
.setLicenseUri(drmLicenseUri)
|
||||||
.setLicenseRequestHeaders(drmLicenseRequestHeaders)
|
.setLicenseRequestHeaders(drmLicenseRequestHeaders)
|
||||||
.setSessionForClearPeriods(drmSessionForClearContent)
|
.forceSessionsForAudioAndVideoTracks(drmSessionForClearContent)
|
||||||
.setMultiSession(drmMultiSession)
|
.setMultiSession(drmMultiSession)
|
||||||
.setForceDefaultLicenseUri(drmForceDefaultLicenseUri)
|
.setForceDefaultLicenseUri(drmForceDefaultLicenseUri)
|
||||||
.build());
|
.build());
|
||||||
|
@ -298,22 +298,22 @@ public final class MediaItem implements Bundleable {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @deprecated Use {@link #setDrmConfiguration(DrmConfiguration)} and {@link
|
* @deprecated Use {@link #setDrmConfiguration(DrmConfiguration)} and {@link
|
||||||
* DrmConfiguration.Builder#setSessionForClearPeriods(boolean)} instead.
|
* DrmConfiguration.Builder#forceSessionsForAudioAndVideoTracks(boolean)} instead.
|
||||||
*/
|
*/
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public Builder setDrmSessionForClearPeriods(boolean sessionForClearPeriods) {
|
public Builder setDrmSessionForClearPeriods(boolean sessionForClearPeriods) {
|
||||||
drmConfiguration.setSessionForClearPeriods(sessionForClearPeriods);
|
drmConfiguration.forceSessionsForAudioAndVideoTracks(sessionForClearPeriods);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @deprecated Use {@link #setDrmConfiguration(DrmConfiguration)} and {@link
|
* @deprecated Use {@link #setDrmConfiguration(DrmConfiguration)} and {@link
|
||||||
* DrmConfiguration.Builder#setSessionForClearTypes(List)} instead.
|
* DrmConfiguration.Builder#setForcedSessionTrackTypes(List)} instead.
|
||||||
*/
|
*/
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public Builder setDrmSessionForClearTypes(
|
public Builder setDrmSessionForClearTypes(
|
||||||
@Nullable List<@C.TrackType Integer> sessionForClearTypes) {
|
@Nullable List<@C.TrackType Integer> sessionForClearTypes) {
|
||||||
drmConfiguration.setSessionForClearTypes(sessionForClearTypes);
|
drmConfiguration.setForcedSessionTrackTypes(sessionForClearTypes);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -532,7 +532,7 @@ public final class MediaItem implements Bundleable {
|
|||||||
private boolean multiSession;
|
private boolean multiSession;
|
||||||
private boolean playClearContentWithoutKey;
|
private boolean playClearContentWithoutKey;
|
||||||
private boolean forceDefaultLicenseUri;
|
private boolean forceDefaultLicenseUri;
|
||||||
private ImmutableList<@C.TrackType Integer> sessionForClearTypes;
|
private ImmutableList<@C.TrackType Integer> forcedSessionTrackTypes;
|
||||||
@Nullable private byte[] keySetId;
|
@Nullable private byte[] keySetId;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -543,7 +543,7 @@ public final class MediaItem implements Bundleable {
|
|||||||
public Builder(UUID scheme) {
|
public Builder(UUID scheme) {
|
||||||
this.scheme = scheme;
|
this.scheme = scheme;
|
||||||
this.licenseRequestHeaders = ImmutableMap.of();
|
this.licenseRequestHeaders = ImmutableMap.of();
|
||||||
this.sessionForClearTypes = ImmutableList.of();
|
this.forcedSessionTrackTypes = ImmutableList.of();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -553,7 +553,7 @@ public final class MediaItem implements Bundleable {
|
|||||||
@Deprecated
|
@Deprecated
|
||||||
private Builder() {
|
private Builder() {
|
||||||
this.licenseRequestHeaders = ImmutableMap.of();
|
this.licenseRequestHeaders = ImmutableMap.of();
|
||||||
this.sessionForClearTypes = ImmutableList.of();
|
this.forcedSessionTrackTypes = ImmutableList.of();
|
||||||
}
|
}
|
||||||
|
|
||||||
private Builder(DrmConfiguration drmConfiguration) {
|
private Builder(DrmConfiguration drmConfiguration) {
|
||||||
@ -563,7 +563,7 @@ public final class MediaItem implements Bundleable {
|
|||||||
this.multiSession = drmConfiguration.multiSession;
|
this.multiSession = drmConfiguration.multiSession;
|
||||||
this.playClearContentWithoutKey = drmConfiguration.playClearContentWithoutKey;
|
this.playClearContentWithoutKey = drmConfiguration.playClearContentWithoutKey;
|
||||||
this.forceDefaultLicenseUri = drmConfiguration.forceDefaultLicenseUri;
|
this.forceDefaultLicenseUri = drmConfiguration.forceDefaultLicenseUri;
|
||||||
this.sessionForClearTypes = drmConfiguration.sessionForClearTypes;
|
this.forcedSessionTrackTypes = drmConfiguration.forcedSessionTrackTypes;
|
||||||
this.keySetId = drmConfiguration.keySetId;
|
this.keySetId = drmConfiguration.keySetId;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -633,11 +633,12 @@ public final class MediaItem implements Bundleable {
|
|||||||
* C#TRACK_TYPE_VIDEO} and {@link C#TRACK_TYPE_AUDIO}.
|
* C#TRACK_TYPE_VIDEO} and {@link C#TRACK_TYPE_AUDIO}.
|
||||||
*
|
*
|
||||||
* <p>This method overrides what has been set by previously calling {@link
|
* <p>This method overrides what has been set by previously calling {@link
|
||||||
* #setSessionForClearTypes(List)}.
|
* #setForcedSessionTrackTypes(List)}.
|
||||||
*/
|
*/
|
||||||
public Builder setSessionForClearPeriods(boolean sessionForClearPeriods) {
|
public Builder forceSessionsForAudioAndVideoTracks(
|
||||||
this.setSessionForClearTypes(
|
boolean useClearSessionsForAudioAndVideoTracks) {
|
||||||
sessionForClearPeriods
|
this.setForcedSessionTrackTypes(
|
||||||
|
useClearSessionsForAudioAndVideoTracks
|
||||||
? ImmutableList.of(C.TRACK_TYPE_VIDEO, C.TRACK_TYPE_AUDIO)
|
? ImmutableList.of(C.TRACK_TYPE_VIDEO, C.TRACK_TYPE_AUDIO)
|
||||||
: ImmutableList.of());
|
: ImmutableList.of());
|
||||||
return this;
|
return this;
|
||||||
@ -648,18 +649,18 @@ public final class MediaItem implements Bundleable {
|
|||||||
* when the tracks are in the clear.
|
* when the tracks are in the clear.
|
||||||
*
|
*
|
||||||
* <p>For the common case of using a DRM session for {@link C#TRACK_TYPE_VIDEO} and {@link
|
* <p>For the common case of using a DRM session for {@link C#TRACK_TYPE_VIDEO} and {@link
|
||||||
* C#TRACK_TYPE_AUDIO}, {@link #setSessionForClearPeriods(boolean)} can be used.
|
* C#TRACK_TYPE_AUDIO}, {@link #forceSessionsForAudioAndVideoTracks(boolean)} can be used.
|
||||||
*
|
*
|
||||||
* <p>This method overrides what has been set by previously calling {@link
|
* <p>This method overrides what has been set by previously calling {@link
|
||||||
* #setSessionForClearPeriods(boolean)}.
|
* #forceSessionsForAudioAndVideoTracks(boolean)}.
|
||||||
*
|
*
|
||||||
* <p>{@code null} or an empty {@link List} can be used for a reset.
|
* <p>{@code null} or an empty {@link List} can be used for a reset.
|
||||||
*/
|
*/
|
||||||
public Builder setSessionForClearTypes(
|
public Builder setForcedSessionTrackTypes(
|
||||||
@Nullable List<@C.TrackType Integer> sessionForClearTypes) {
|
@Nullable List<@C.TrackType Integer> forcedSessionTrackTypes) {
|
||||||
this.sessionForClearTypes =
|
this.forcedSessionTrackTypes =
|
||||||
sessionForClearTypes != null
|
forcedSessionTrackTypes != null
|
||||||
? ImmutableList.copyOf(sessionForClearTypes)
|
? ImmutableList.copyOf(forcedSessionTrackTypes)
|
||||||
: ImmutableList.of();
|
: ImmutableList.of();
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
@ -715,8 +716,12 @@ public final class MediaItem implements Bundleable {
|
|||||||
*/
|
*/
|
||||||
public final boolean forceDefaultLicenseUri;
|
public final boolean forceDefaultLicenseUri;
|
||||||
|
|
||||||
/** The types of clear tracks for which to use a DRM session. */
|
/** @deprecated Use {@link #forcedSessionTrackTypes}. */
|
||||||
public final ImmutableList<@C.TrackType Integer> sessionForClearTypes;
|
@Deprecated public final ImmutableList<@C.TrackType Integer> sessionForClearTypes;
|
||||||
|
/**
|
||||||
|
* The types of tracks for which to always use a DRM session even if the content is unencrypted.
|
||||||
|
*/
|
||||||
|
public final ImmutableList<@C.TrackType Integer> forcedSessionTrackTypes;
|
||||||
|
|
||||||
@Nullable private final byte[] keySetId;
|
@Nullable private final byte[] keySetId;
|
||||||
|
|
||||||
@ -731,7 +736,8 @@ public final class MediaItem implements Bundleable {
|
|||||||
this.multiSession = builder.multiSession;
|
this.multiSession = builder.multiSession;
|
||||||
this.forceDefaultLicenseUri = builder.forceDefaultLicenseUri;
|
this.forceDefaultLicenseUri = builder.forceDefaultLicenseUri;
|
||||||
this.playClearContentWithoutKey = builder.playClearContentWithoutKey;
|
this.playClearContentWithoutKey = builder.playClearContentWithoutKey;
|
||||||
this.sessionForClearTypes = builder.sessionForClearTypes;
|
this.sessionForClearTypes = builder.forcedSessionTrackTypes;
|
||||||
|
this.forcedSessionTrackTypes = builder.forcedSessionTrackTypes;
|
||||||
this.keySetId =
|
this.keySetId =
|
||||||
builder.keySetId != null
|
builder.keySetId != null
|
||||||
? Arrays.copyOf(builder.keySetId, builder.keySetId.length)
|
? Arrays.copyOf(builder.keySetId, builder.keySetId.length)
|
||||||
@ -765,7 +771,7 @@ public final class MediaItem implements Bundleable {
|
|||||||
&& multiSession == other.multiSession
|
&& multiSession == other.multiSession
|
||||||
&& forceDefaultLicenseUri == other.forceDefaultLicenseUri
|
&& forceDefaultLicenseUri == other.forceDefaultLicenseUri
|
||||||
&& playClearContentWithoutKey == other.playClearContentWithoutKey
|
&& playClearContentWithoutKey == other.playClearContentWithoutKey
|
||||||
&& sessionForClearTypes.equals(other.sessionForClearTypes)
|
&& forcedSessionTrackTypes.equals(other.forcedSessionTrackTypes)
|
||||||
&& Arrays.equals(keySetId, other.keySetId);
|
&& Arrays.equals(keySetId, other.keySetId);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -777,7 +783,7 @@ public final class MediaItem implements Bundleable {
|
|||||||
result = 31 * result + (multiSession ? 1 : 0);
|
result = 31 * result + (multiSession ? 1 : 0);
|
||||||
result = 31 * result + (forceDefaultLicenseUri ? 1 : 0);
|
result = 31 * result + (forceDefaultLicenseUri ? 1 : 0);
|
||||||
result = 31 * result + (playClearContentWithoutKey ? 1 : 0);
|
result = 31 * result + (playClearContentWithoutKey ? 1 : 0);
|
||||||
result = 31 * result + sessionForClearTypes.hashCode();
|
result = 31 * result + forcedSessionTrackTypes.hashCode();
|
||||||
result = 31 * result + Arrays.hashCode(keySetId);
|
result = 31 * result + Arrays.hashCode(keySetId);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
@ -118,6 +118,8 @@ public class MediaItemTest {
|
|||||||
assertThat(mediaItem.localConfiguration.drmConfiguration.playClearContentWithoutKey).isTrue();
|
assertThat(mediaItem.localConfiguration.drmConfiguration.playClearContentWithoutKey).isTrue();
|
||||||
assertThat(mediaItem.localConfiguration.drmConfiguration.sessionForClearTypes)
|
assertThat(mediaItem.localConfiguration.drmConfiguration.sessionForClearTypes)
|
||||||
.containsExactly(C.TRACK_TYPE_AUDIO);
|
.containsExactly(C.TRACK_TYPE_AUDIO);
|
||||||
|
assertThat(mediaItem.localConfiguration.drmConfiguration.forcedSessionTrackTypes)
|
||||||
|
.containsExactly(C.TRACK_TYPE_AUDIO);
|
||||||
assertThat(mediaItem.localConfiguration.drmConfiguration.getKeySetId()).isEqualTo(keySetId);
|
assertThat(mediaItem.localConfiguration.drmConfiguration.getKeySetId()).isEqualTo(keySetId);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -152,6 +154,7 @@ public class MediaItemTest {
|
|||||||
assertThat(mediaItem.localConfiguration.drmConfiguration.forceDefaultLicenseUri).isFalse();
|
assertThat(mediaItem.localConfiguration.drmConfiguration.forceDefaultLicenseUri).isFalse();
|
||||||
assertThat(mediaItem.localConfiguration.drmConfiguration.playClearContentWithoutKey).isFalse();
|
assertThat(mediaItem.localConfiguration.drmConfiguration.playClearContentWithoutKey).isFalse();
|
||||||
assertThat(mediaItem.localConfiguration.drmConfiguration.sessionForClearTypes).isEmpty();
|
assertThat(mediaItem.localConfiguration.drmConfiguration.sessionForClearTypes).isEmpty();
|
||||||
|
assertThat(mediaItem.localConfiguration.drmConfiguration.forcedSessionTrackTypes).isEmpty();
|
||||||
assertThat(mediaItem.localConfiguration.drmConfiguration.getKeySetId()).isNull();
|
assertThat(mediaItem.localConfiguration.drmConfiguration.getKeySetId()).isNull();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -172,7 +175,7 @@ public class MediaItemTest {
|
|||||||
.setMultiSession(true)
|
.setMultiSession(true)
|
||||||
.setForceDefaultLicenseUri(true)
|
.setForceDefaultLicenseUri(true)
|
||||||
.setPlayClearContentWithoutKey(true)
|
.setPlayClearContentWithoutKey(true)
|
||||||
.setSessionForClearTypes(ImmutableList.of(C.TRACK_TYPE_AUDIO))
|
.setForcedSessionTrackTypes(ImmutableList.of(C.TRACK_TYPE_AUDIO))
|
||||||
.setKeySetId(keySetId)
|
.setKeySetId(keySetId)
|
||||||
.build())
|
.build())
|
||||||
.build();
|
.build();
|
||||||
@ -190,11 +193,13 @@ public class MediaItemTest {
|
|||||||
assertThat(mediaItem.localConfiguration.drmConfiguration.playClearContentWithoutKey).isTrue();
|
assertThat(mediaItem.localConfiguration.drmConfiguration.playClearContentWithoutKey).isTrue();
|
||||||
assertThat(mediaItem.localConfiguration.drmConfiguration.sessionForClearTypes)
|
assertThat(mediaItem.localConfiguration.drmConfiguration.sessionForClearTypes)
|
||||||
.containsExactly(C.TRACK_TYPE_AUDIO);
|
.containsExactly(C.TRACK_TYPE_AUDIO);
|
||||||
|
assertThat(mediaItem.localConfiguration.drmConfiguration.forcedSessionTrackTypes)
|
||||||
|
.containsExactly(C.TRACK_TYPE_AUDIO);
|
||||||
assertThat(mediaItem.localConfiguration.drmConfiguration.getKeySetId()).isEqualTo(keySetId);
|
assertThat(mediaItem.localConfiguration.drmConfiguration.getKeySetId()).isEqualTo(keySetId);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@SuppressWarnings("deprecation") // Testing deprecated methods
|
@SuppressWarnings("deprecation") // Testing deprecated methods and field
|
||||||
public void builderSetDrmSessionForClearPeriods_setsAudioAndVideoTracks() {
|
public void builderSetDrmSessionForClearPeriods_setsAudioAndVideoTracks() {
|
||||||
Uri licenseUri = Uri.parse(URI_STRING);
|
Uri licenseUri = Uri.parse(URI_STRING);
|
||||||
MediaItem mediaItem =
|
MediaItem mediaItem =
|
||||||
@ -208,20 +213,25 @@ public class MediaItemTest {
|
|||||||
|
|
||||||
assertThat(mediaItem.localConfiguration.drmConfiguration.sessionForClearTypes)
|
assertThat(mediaItem.localConfiguration.drmConfiguration.sessionForClearTypes)
|
||||||
.containsExactly(C.TRACK_TYPE_AUDIO, C.TRACK_TYPE_VIDEO);
|
.containsExactly(C.TRACK_TYPE_AUDIO, C.TRACK_TYPE_VIDEO);
|
||||||
|
assertThat(mediaItem.localConfiguration.drmConfiguration.forcedSessionTrackTypes)
|
||||||
|
.containsExactly(C.TRACK_TYPE_AUDIO, C.TRACK_TYPE_VIDEO);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@SuppressWarnings("deprecation") // Testing deprecated field
|
||||||
public void drmConfigurationBuilderSetSessionForClearPeriods_overridesSetSessionForClearTypes() {
|
public void drmConfigurationBuilderSetSessionForClearPeriods_overridesSetSessionForClearTypes() {
|
||||||
Uri licenseUri = Uri.parse(URI_STRING);
|
Uri licenseUri = Uri.parse(URI_STRING);
|
||||||
MediaItem.DrmConfiguration drmConfiguration =
|
MediaItem.DrmConfiguration drmConfiguration =
|
||||||
new MediaItem.DrmConfiguration.Builder(C.WIDEVINE_UUID)
|
new MediaItem.DrmConfiguration.Builder(C.WIDEVINE_UUID)
|
||||||
.setLicenseUri(licenseUri)
|
.setLicenseUri(licenseUri)
|
||||||
.setSessionForClearTypes(ImmutableList.of(C.TRACK_TYPE_AUDIO))
|
.setForcedSessionTrackTypes(ImmutableList.of(C.TRACK_TYPE_AUDIO))
|
||||||
.setSessionForClearPeriods(true)
|
.forceSessionsForAudioAndVideoTracks(true)
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
assertThat(drmConfiguration.sessionForClearTypes)
|
assertThat(drmConfiguration.sessionForClearTypes)
|
||||||
.containsExactly(C.TRACK_TYPE_AUDIO, C.TRACK_TYPE_VIDEO);
|
.containsExactly(C.TRACK_TYPE_AUDIO, C.TRACK_TYPE_VIDEO);
|
||||||
|
assertThat(drmConfiguration.forcedSessionTrackTypes)
|
||||||
|
.containsExactly(C.TRACK_TYPE_AUDIO, C.TRACK_TYPE_VIDEO);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@ -628,7 +638,7 @@ public class MediaItemTest {
|
|||||||
.setMultiSession(true)
|
.setMultiSession(true)
|
||||||
.setForceDefaultLicenseUri(true)
|
.setForceDefaultLicenseUri(true)
|
||||||
.setPlayClearContentWithoutKey(true)
|
.setPlayClearContentWithoutKey(true)
|
||||||
.setSessionForClearTypes(ImmutableList.of(C.TRACK_TYPE_AUDIO))
|
.setForcedSessionTrackTypes(ImmutableList.of(C.TRACK_TYPE_AUDIO))
|
||||||
.setKeySetId(new byte[] {1, 2, 3})
|
.setKeySetId(new byte[] {1, 2, 3})
|
||||||
.build())
|
.build())
|
||||||
.setMediaId("mediaId")
|
.setMediaId("mediaId")
|
||||||
|
Loading…
x
Reference in New Issue
Block a user