Skip to content

Commit d580062

Browse files
Format with google-java-format
1 parent 521a91e commit d580062

File tree

3 files changed

+83
-52
lines changed

3 files changed

+83
-52
lines changed

libraries/exoplayer_hls/src/main/java/androidx/media3/exoplayer/hls/playlist/HlsMediaPlaylist.java

Lines changed: 62 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -613,12 +613,11 @@ public int hashCode() {
613613
clientDefinedAttributes);
614614
}
615615

616-
617616
/**
618617
* Builder for {@link Interstitial}.
619618
*
620-
* <p>See RFC 8216bis, section 4.4.5.1 for how to consolidate multiple interstitials with
621-
* the same {@linkplain HlsMediaPlaylist.Interstitial#id ID}.
619+
* <p>See RFC 8216bis, section 4.4.5.1 for how to consolidate multiple interstitials with the
620+
* same {@linkplain HlsMediaPlaylist.Interstitial#id ID}.
622621
*/
623622
public static final class Builder {
624623

@@ -662,7 +661,8 @@ public Builder setAssetUri(@Nullable Uri assetUri) {
662661
return this;
663662
}
664663
if (this.assetUri != null) {
665-
checkArgument(this.assetUri.equals(assetUri),
664+
checkArgument(
665+
this.assetUri.equals(assetUri),
666666
"Can't change assetUri from " + this.assetUri + " to " + assetUri);
667667
}
668668
this.assetUri = assetUri;
@@ -675,7 +675,8 @@ public Builder setAssetListUri(@Nullable Uri assetListUri) {
675675
return this;
676676
}
677677
if (this.assetListUri != null) {
678-
checkArgument(this.assetListUri.equals(assetListUri),
678+
checkArgument(
679+
this.assetListUri.equals(assetListUri),
679680
"Can't change assetListUri from " + this.assetListUri + " to " + assetListUri);
680681
}
681682
this.assetListUri = assetListUri;
@@ -688,8 +689,12 @@ public Builder setStartDateUnixUs(long startDateUnixUs) {
688689
return this;
689690
}
690691
if (this.startDateUnixUs != C.TIME_UNSET) {
691-
checkArgument(this.startDateUnixUs == startDateUnixUs,
692-
"Can't change startDateUnixUs from " + this.startDateUnixUs + " to " + startDateUnixUs);
692+
checkArgument(
693+
this.startDateUnixUs == startDateUnixUs,
694+
"Can't change startDateUnixUs from "
695+
+ this.startDateUnixUs
696+
+ " to "
697+
+ startDateUnixUs);
693698
}
694699
this.startDateUnixUs = startDateUnixUs;
695700
return this;
@@ -701,7 +706,8 @@ public Builder setEndDateUnixUs(long endDateUnixUs) {
701706
return this;
702707
}
703708
if (this.endDateUnixUs != C.TIME_UNSET) {
704-
checkArgument(this.endDateUnixUs == endDateUnixUs,
709+
checkArgument(
710+
this.endDateUnixUs == endDateUnixUs,
705711
"Can't change endDateUnixUs from " + this.endDateUnixUs + " to " + endDateUnixUs);
706712
}
707713
this.endDateUnixUs = endDateUnixUs;
@@ -714,7 +720,8 @@ public Builder setDurationUs(long durationUs) {
714720
return this;
715721
}
716722
if (this.durationUs != C.TIME_UNSET) {
717-
checkArgument(this.durationUs == durationUs,
723+
checkArgument(
724+
this.durationUs == durationUs,
718725
"Can't change durationUs from " + this.durationUs + " to " + durationUs);
719726
}
720727
this.durationUs = durationUs;
@@ -727,8 +734,12 @@ public Builder setPlannedDurationUs(long plannedDurationUs) {
727734
return this;
728735
}
729736
if (this.plannedDurationUs != C.TIME_UNSET) {
730-
checkArgument(this.plannedDurationUs == plannedDurationUs,
731-
"Can't change plannedDurationUs from " + this.plannedDurationUs + " to " + plannedDurationUs);
737+
checkArgument(
738+
this.plannedDurationUs == plannedDurationUs,
739+
"Can't change plannedDurationUs from "
740+
+ this.plannedDurationUs
741+
+ " to "
742+
+ plannedDurationUs);
732743
}
733744
this.plannedDurationUs = plannedDurationUs;
734745
return this;
@@ -740,8 +751,12 @@ public Builder setCue(List<@Interstitial.CueTriggerType String> cue) {
740751
return this;
741752
}
742753
if (!this.cue.isEmpty()) {
743-
checkArgument(this.cue.equals(cue),
744-
"Can't change cue from " + String.join(", ", this.cue) + " to " + String.join(", ", cue));
754+
checkArgument(
755+
this.cue.equals(cue),
756+
"Can't change cue from "
757+
+ String.join(", ", this.cue)
758+
+ " to "
759+
+ String.join(", ", cue));
745760
}
746761
this.cue = cue;
747762
return this;
@@ -762,7 +777,8 @@ public Builder setResumeOffsetUs(long resumeOffsetUs) {
762777
return this;
763778
}
764779
if (this.resumeOffsetUs != C.TIME_UNSET) {
765-
checkArgument(this.resumeOffsetUs == resumeOffsetUs,
780+
checkArgument(
781+
this.resumeOffsetUs == resumeOffsetUs,
766782
"Can't change resumeOffsetUs from " + this.resumeOffsetUs + " to " + resumeOffsetUs);
767783
}
768784
this.resumeOffsetUs = resumeOffsetUs;
@@ -775,7 +791,8 @@ public Builder setPlayoutLimitUs(long playoutLimitUs) {
775791
return this;
776792
}
777793
if (this.playoutLimitUs != C.TIME_UNSET) {
778-
checkArgument(this.playoutLimitUs == playoutLimitUs,
794+
checkArgument(
795+
this.playoutLimitUs == playoutLimitUs,
779796
"Can't change playoutLimitUs from " + this.playoutLimitUs + " to " + playoutLimitUs);
780797
}
781798
this.playoutLimitUs = playoutLimitUs;
@@ -788,21 +805,30 @@ public Builder setSnapTypes(List<@Interstitial.SnapType String> snapTypes) {
788805
return this;
789806
}
790807
if (!this.snapTypes.isEmpty()) {
791-
checkArgument(this.snapTypes.equals(snapTypes),
792-
"Can't change snapTypes from " + String.join(", ", this.snapTypes) + " to " + String.join(", ", snapTypes));
808+
checkArgument(
809+
this.snapTypes.equals(snapTypes),
810+
"Can't change snapTypes from "
811+
+ String.join(", ", this.snapTypes)
812+
+ " to "
813+
+ String.join(", ", snapTypes));
793814
}
794815
this.snapTypes = snapTypes;
795816
return this;
796817
}
797818

798819
/** Sets the {@code NavigationRestriction}. */
799-
public Builder setRestrictions(List<@Interstitial.NavigationRestriction String> restrictions) {
820+
public Builder setRestrictions(
821+
List<@Interstitial.NavigationRestriction String> restrictions) {
800822
if (restrictions.isEmpty()) {
801823
return this;
802824
}
803825
if (!this.restrictions.isEmpty()) {
804-
checkArgument(this.restrictions.equals(restrictions),
805-
"Can't change restrictions from " + String.join(", ", this.restrictions) + " to " + String.join(", ", restrictions));
826+
checkArgument(
827+
this.restrictions.equals(restrictions),
828+
"Can't change restrictions from "
829+
+ String.join(", ", this.restrictions)
830+
+ " to "
831+
+ String.join(", ", restrictions));
806832
}
807833
this.restrictions = restrictions;
808834
return this;
@@ -814,17 +840,26 @@ public Builder setClientDefinedAttributes(
814840
if (clientDefinedAttributes.isEmpty()) {
815841
return this;
816842
}
817-
for (Map.Entry<String, HlsMediaPlaylist.ClientDefinedAttribute> newEntry : clientDefinedAttributes.entrySet()) {
843+
for (Map.Entry<String, HlsMediaPlaylist.ClientDefinedAttribute> newEntry :
844+
clientDefinedAttributes.entrySet()) {
818845
String newKey = newEntry.getKey();
819846
HlsMediaPlaylist.ClientDefinedAttribute newValue = newEntry.getValue();
820847
if (this.clientDefinedAttributes.containsKey(newKey)) {
821-
HlsMediaPlaylist.ClientDefinedAttribute existingValue = this.clientDefinedAttributes.get(newKey);
848+
HlsMediaPlaylist.ClientDefinedAttribute existingValue =
849+
this.clientDefinedAttributes.get(newKey);
822850
if (existingValue != null) {
823851
checkArgument(
824852
existingValue.equals(newValue),
825-
"Can't change " + newKey + " from "
826-
+ existingValue.textValue + " " + existingValue.doubleValue + " to "
827-
+ newValue.textValue + " " + newValue.doubleValue);
853+
"Can't change "
854+
+ newKey
855+
+ " from "
856+
+ existingValue.textValue
857+
+ " "
858+
+ existingValue.doubleValue
859+
+ " to "
860+
+ newValue.textValue
861+
+ " "
862+
+ newValue.doubleValue);
828863
}
829864
}
830865
this.clientDefinedAttributes.put(newKey, newValue);
@@ -834,8 +869,7 @@ public Builder setClientDefinedAttributes(
834869

835870
public @Nullable Interstitial build() {
836871
if ((assetListUri == null && assetUri != null)
837-
|| (assetListUri != null && assetUri == null)
838-
&& startDateUnixUs != C.TIME_UNSET) {
872+
|| (assetListUri != null && assetUri == null) && startDateUnixUs != C.TIME_UNSET) {
839873
return new Interstitial(
840874
this.id,
841875
this.assetUri,
@@ -850,8 +884,7 @@ public Builder setClientDefinedAttributes(
850884
this.playoutLimitUs,
851885
this.snapTypes,
852886
this.restrictions,
853-
new ArrayList<>(this.clientDefinedAttributes.values())
854-
);
887+
new ArrayList<>(this.clientDefinedAttributes.values()));
855888
}
856889
return null;
857890
}

libraries/exoplayer_hls/src/main/java/androidx/media3/exoplayer/hls/playlist/HlsPlaylistParser.java

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,6 @@
5050
import androidx.media3.exoplayer.hls.playlist.HlsMultivariantPlaylist.Variant;
5151
import androidx.media3.exoplayer.upstream.ParsingLoadable;
5252
import androidx.media3.extractor.mp4.PsshAtomUtil;
53-
import com.google.common.collect.ImmutableList;
5453
import com.google.common.collect.Iterables;
5554
import java.io.BufferedReader;
5655
import java.io.IOException;
@@ -1193,22 +1192,24 @@ && parseOptionalStringAttr(line, REGEX_CLASS, /* defaultValue= */ "", variableDe
11931192
}
11941193
}
11951194

1196-
Interstitial.Builder interstitialBuilder = (interstitialBuilderMap.containsKey(id) ?
1197-
interstitialBuilderMap.get(id) : new Interstitial.Builder(id))
1198-
.setAssetUri(assetUri)
1199-
.setAssetListUri(assetListUri)
1200-
.setStartDateUnixUs(startDateUnixUs)
1201-
.setEndDateUnixUs(endDateUnixUs)
1202-
.setDurationUs(durationUs)
1203-
.setPlannedDurationUs(plannedDurationUs)
1204-
.setCue(cue)
1205-
.setEndOnNext(endOnNext)
1206-
.setResumeOffsetUs(resumeOffsetUs)
1207-
.setPlayoutLimitUs(playoutLimitUs)
1208-
.setSnapTypes(snapTypes)
1209-
.setRestrictions(restrictions)
1210-
.setClientDefinedAttributes(clientDefinedAttributes);
1211-
interstitialBuilderMap.put(id, interstitialBuilder);
1195+
Interstitial.Builder interstitialBuilder =
1196+
(interstitialBuilderMap.containsKey(id)
1197+
? interstitialBuilderMap.get(id)
1198+
: new Interstitial.Builder(id))
1199+
.setAssetUri(assetUri)
1200+
.setAssetListUri(assetListUri)
1201+
.setStartDateUnixUs(startDateUnixUs)
1202+
.setEndDateUnixUs(endDateUnixUs)
1203+
.setDurationUs(durationUs)
1204+
.setPlannedDurationUs(plannedDurationUs)
1205+
.setCue(cue)
1206+
.setEndOnNext(endOnNext)
1207+
.setResumeOffsetUs(resumeOffsetUs)
1208+
.setPlayoutLimitUs(playoutLimitUs)
1209+
.setSnapTypes(snapTypes)
1210+
.setRestrictions(restrictions)
1211+
.setClientDefinedAttributes(clientDefinedAttributes);
1212+
interstitialBuilderMap.put(id, interstitialBuilder);
12121213
} else if (!line.startsWith("#")) {
12131214
@Nullable
12141215
String segmentEncryptionIV =

libraries/exoplayer_hls/src/test/java/androidx/media3/exoplayer/hls/playlist/HlsMediaPlaylistParserTest.java

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1445,8 +1445,7 @@ public void parseMediaPlaylist_withDateRangeWithMissingClass_dateRangeIgnored()
14451445
}
14461446

14471447
@Test
1448-
public void parseMediaPlaylist_interstitialWithoutStartDate_ignored()
1449-
throws IOException {
1448+
public void parseMediaPlaylist_interstitialWithoutStartDate_ignored() throws IOException {
14501449
Uri playlistUri = Uri.parse("https://example.com/test.m3u8");
14511450
String playlistString =
14521451
"#EXTM3U\n"
@@ -1612,9 +1611,7 @@ public void parseMediaPlaylist_withInterstitialWithAssetUriAndList_interstitialI
16121611
}
16131612

16141613
@Test
1615-
public void
1616-
parseMediaPlaylist_withInterstitialWithUpdatingDateRange()
1617-
throws IOException {
1614+
public void parseMediaPlaylist_withInterstitialWithUpdatingDateRange() throws IOException {
16181615
Uri playlistUri = Uri.parse("https://example.com/test.m3u8");
16191616
String playlistString =
16201617
"#EXTM3U\n"
@@ -1649,7 +1646,7 @@ public void parseMediaPlaylist_withInterstitialWithAssetUriAndList_interstitialI
16491646

16501647
@Test
16511648
public void
1652-
parseMediaPlaylist_withInterstitiaStartDateInvalidUpdate_throwsIllegalArgumentException() {
1649+
parseMediaPlaylist_withInterstitiaStartDateInvalidUpdate_throwsIllegalArgumentException() {
16531650
Uri playlistUri = Uri.parse("https://example.com/test.m3u8");
16541651
String playlistString =
16551652
"#EXTM3U\n"

0 commit comments

Comments
 (0)