Fix some inconsistencies in the MediaItem
API
* Rename (via deprecation) `MediaItem.DrmConfiguration.Builder#forceSessionsForAudioAndVideoTracks` to `setForceSessionsForAudioAndVideoTracks`. This is more consistent with existing 'force' method names both in this class and in `TrackSelectionParameters.Builder`. * Add missing `@Nullable` annotation to the parameter for `MediaItem.SubtitleConfiguration.Builder#setMimeType`. This annotation is already present on the `MediaItem.SubtitleConfiguration#mimeType` field that this setter corresponds to. PiperOrigin-RevId: 450941336
This commit is contained in:
parent
de1dceedc1
commit
591eaef756
@ -188,7 +188,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)
|
||||||
.forceSessionsForAudioAndVideoTracks(
|
.setForceSessionsForAudioAndVideoTracks(
|
||||||
intent.getBooleanExtra(DRM_SESSION_FOR_CLEAR_CONTENT + extrasKeySuffix, false))
|
intent.getBooleanExtra(DRM_SESSION_FOR_CLEAR_CONTENT + extrasKeySuffix, false))
|
||||||
.build());
|
.build());
|
||||||
}
|
}
|
||||||
|
@ -458,7 +458,7 @@ public class SampleChooserActivity extends AppCompatActivity
|
|||||||
new MediaItem.DrmConfiguration.Builder(drmUuid)
|
new MediaItem.DrmConfiguration.Builder(drmUuid)
|
||||||
.setLicenseUri(drmLicenseUri)
|
.setLicenseUri(drmLicenseUri)
|
||||||
.setLicenseRequestHeaders(drmLicenseRequestHeaders)
|
.setLicenseRequestHeaders(drmLicenseRequestHeaders)
|
||||||
.forceSessionsForAudioAndVideoTracks(drmSessionForClearContent)
|
.setForceSessionsForAudioAndVideoTracks(drmSessionForClearContent)
|
||||||
.setMultiSession(drmMultiSession)
|
.setMultiSession(drmMultiSession)
|
||||||
.setForceDefaultLicenseUri(drmForceDefaultLicenseUri)
|
.setForceDefaultLicenseUri(drmForceDefaultLicenseUri)
|
||||||
.build());
|
.build());
|
||||||
|
@ -29,6 +29,7 @@ import androidx.media3.common.util.UnstableApi;
|
|||||||
import androidx.media3.common.util.Util;
|
import androidx.media3.common.util.Util;
|
||||||
import com.google.common.collect.ImmutableList;
|
import com.google.common.collect.ImmutableList;
|
||||||
import com.google.common.collect.ImmutableMap;
|
import com.google.common.collect.ImmutableMap;
|
||||||
|
import com.google.errorprone.annotations.InlineMe;
|
||||||
import java.lang.annotation.Documented;
|
import java.lang.annotation.Documented;
|
||||||
import java.lang.annotation.Retention;
|
import java.lang.annotation.Retention;
|
||||||
import java.lang.annotation.RetentionPolicy;
|
import java.lang.annotation.RetentionPolicy;
|
||||||
@ -315,12 +316,12 @@ public final class MediaItem implements Bundleable {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @deprecated Use {@link #setDrmConfiguration(DrmConfiguration)} and {@link
|
* @deprecated Use {@link #setDrmConfiguration(DrmConfiguration)} and {@link
|
||||||
* DrmConfiguration.Builder#forceSessionsForAudioAndVideoTracks(boolean)} instead.
|
* DrmConfiguration.Builder#setForceSessionsForAudioAndVideoTracks(boolean)} instead.
|
||||||
*/
|
*/
|
||||||
@UnstableApi
|
@UnstableApi
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public Builder setDrmSessionForClearPeriods(boolean sessionForClearPeriods) {
|
public Builder setDrmSessionForClearPeriods(boolean sessionForClearPeriods) {
|
||||||
drmConfiguration.forceSessionsForAudioAndVideoTracks(sessionForClearPeriods);
|
drmConfiguration.setForceSessionsForAudioAndVideoTracks(sessionForClearPeriods);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -659,6 +660,19 @@ public final class MediaItem implements Bundleable {
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @deprecated Use {@link #setForceSessionsForAudioAndVideoTracks(boolean)} instead.
|
||||||
|
*/
|
||||||
|
@UnstableApi
|
||||||
|
@Deprecated
|
||||||
|
@InlineMe(
|
||||||
|
replacement =
|
||||||
|
"this.setForceSessionsForAudioAndVideoTracks(forceSessionsForAudioAndVideoTracks)")
|
||||||
|
public Builder forceSessionsForAudioAndVideoTracks(
|
||||||
|
boolean forceSessionsForAudioAndVideoTracks) {
|
||||||
|
return setForceSessionsForAudioAndVideoTracks(forceSessionsForAudioAndVideoTracks);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets whether a DRM session should be used for clear tracks of type {@link
|
* Sets whether a DRM session should be used for clear tracks of type {@link
|
||||||
* C#TRACK_TYPE_VIDEO} and {@link C#TRACK_TYPE_AUDIO}.
|
* C#TRACK_TYPE_VIDEO} and {@link C#TRACK_TYPE_AUDIO}.
|
||||||
@ -666,10 +680,10 @@ public final class MediaItem implements Bundleable {
|
|||||||
* <p>This method overrides what has been set by previously calling {@link
|
* <p>This method overrides what has been set by previously calling {@link
|
||||||
* #setForcedSessionTrackTypes(List)}.
|
* #setForcedSessionTrackTypes(List)}.
|
||||||
*/
|
*/
|
||||||
public Builder forceSessionsForAudioAndVideoTracks(
|
public Builder setForceSessionsForAudioAndVideoTracks(
|
||||||
boolean useClearSessionsForAudioAndVideoTracks) {
|
boolean forceSessionsForAudioAndVideoTracks) {
|
||||||
this.setForcedSessionTrackTypes(
|
this.setForcedSessionTrackTypes(
|
||||||
useClearSessionsForAudioAndVideoTracks
|
forceSessionsForAudioAndVideoTracks
|
||||||
? 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;
|
||||||
@ -680,10 +694,10 @@ 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 #forceSessionsForAudioAndVideoTracks(boolean)} can be used.
|
* C#TRACK_TYPE_AUDIO}, {@link #setForceSessionsForAudioAndVideoTracks(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
|
||||||
* #forceSessionsForAudioAndVideoTracks(boolean)}.
|
* #setForceSessionsForAudioAndVideoTracks(boolean)}.
|
||||||
*/
|
*/
|
||||||
public Builder setForcedSessionTrackTypes(
|
public Builder setForcedSessionTrackTypes(
|
||||||
List<@C.TrackType Integer> forcedSessionTrackTypes) {
|
List<@C.TrackType Integer> forcedSessionTrackTypes) {
|
||||||
@ -1311,7 +1325,7 @@ public final class MediaItem implements Bundleable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** Sets the MIME type. */
|
/** Sets the MIME type. */
|
||||||
public Builder setMimeType(String mimeType) {
|
public Builder setMimeType(@Nullable String mimeType) {
|
||||||
this.mimeType = mimeType;
|
this.mimeType = mimeType;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
@ -223,7 +223,7 @@ public class MediaItemTest {
|
|||||||
new MediaItem.DrmConfiguration.Builder(C.WIDEVINE_UUID)
|
new MediaItem.DrmConfiguration.Builder(C.WIDEVINE_UUID)
|
||||||
.setLicenseUri(licenseUri)
|
.setLicenseUri(licenseUri)
|
||||||
.setForcedSessionTrackTypes(ImmutableList.of(C.TRACK_TYPE_AUDIO))
|
.setForcedSessionTrackTypes(ImmutableList.of(C.TRACK_TYPE_AUDIO))
|
||||||
.forceSessionsForAudioAndVideoTracks(true)
|
.setForceSessionsForAudioAndVideoTracks(true)
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
assertThat(drmConfiguration.sessionForClearTypes)
|
assertThat(drmConfiguration.sessionForClearTypes)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user