Skip to content

Commit 2bdf235

Browse files
icbakercopybara-github
authored andcommitted
Enforce peek limit in (f)MP4 extractor tests
This CL also introduces a new `ExtractorAsserts.PEEK_LIMIT_FAIL_WITH_MAX` value to make finding the right peek limit for each test easier. PiperOrigin-RevId: 791171112
1 parent a3bef49 commit 2bdf235

File tree

4 files changed

+132
-77
lines changed

4 files changed

+132
-77
lines changed

libraries/extractor/src/test/java/androidx/media3/extractor/mp4/FragmentedMp4ExtractorParameterizedTest.java

Lines changed: 52 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -79,13 +79,17 @@ public static List<Object[]> params() {
7979
@Test
8080
public void sample() throws Exception {
8181
assertExtractorBehavior(
82-
/* closedCaptionFormats= */ ImmutableList.of(), "media/mp4/sample_fragmented.mp4");
82+
/* closedCaptionFormats= */ ImmutableList.of(),
83+
"media/mp4/sample_fragmented.mp4",
84+
/* peekLimit= */ 1100);
8385
}
8486

8587
@Test
8688
public void sampleSeekable() throws Exception {
8789
assertExtractorBehavior(
88-
/* closedCaptionFormats= */ ImmutableList.of(), "media/mp4/sample_fragmented_seekable.mp4");
90+
/* closedCaptionFormats= */ ImmutableList.of(),
91+
"media/mp4/sample_fragmented_seekable.mp4",
92+
/* peekLimit= */ 260);
8993
}
9094

9195
@Test
@@ -101,6 +105,7 @@ public void sampleSeekable_multipleSidx_noMerging() throws Exception {
101105
/* closedCaptionFormats= */ ImmutableList.of(),
102106
/* additionalEmsgTrackOutput= */ null),
103107
file,
108+
/* peekLimit= */ 700,
104109
new ExtractorAsserts.AssertionConfig.Builder()
105110
.setDumpFilesPrefix(
106111
file.replaceFirst("media", "extractordumps") + ".no-merge-fragmented-sidx")
@@ -121,6 +126,7 @@ public void sampleSeekable_multipleSidx_mergingEnabled() throws Exception {
121126
/* closedCaptionFormats= */ ImmutableList.of(),
122127
/* additionalEmsgTrackOutput= */ null),
123128
file,
129+
/* peekLimit= */ 700,
124130
new ExtractorAsserts.AssertionConfig.Builder()
125131
.setDumpFilesPrefix(
126132
file.replaceFirst("media", "extractordumps") + ".merge-fragmented-sidx")
@@ -135,7 +141,8 @@ public void sampleWithSeiPayloadInputHasNoCaptions() throws Exception {
135141
Collections.singletonList(
136142
new Format.Builder().setSampleMimeType(MimeTypes.APPLICATION_CEA608).build());
137143

138-
assertExtractorBehavior(closedCaptions, "media/mp4/sample_fragmented_sei.mp4");
144+
assertExtractorBehavior(
145+
closedCaptions, "media/mp4/sample_fragmented_sei.mp4", /* peekLimit= */ 1100);
139146
}
140147

141148
@Test
@@ -145,99 +152,121 @@ public void sampleWithSeiPayloadInputHasCaptions() throws Exception {
145152
Collections.singletonList(
146153
new Format.Builder().setSampleMimeType(MimeTypes.APPLICATION_CEA608).build());
147154

148-
assertExtractorBehavior(closedCaptions, "media/mp4/fragmented_captions.mp4");
155+
assertExtractorBehavior(
156+
closedCaptions, "media/mp4/fragmented_captions.mp4", /* peekLimit= */ 660);
149157
}
150158

151159
@Test
152160
public void sampleWithAc3Track() throws Exception {
153161
assertExtractorBehavior(
154-
/* closedCaptionFormats= */ ImmutableList.of(), "media/mp4/sample_ac3_fragmented.mp4");
162+
/* closedCaptionFormats= */ ImmutableList.of(),
163+
"media/mp4/sample_ac3_fragmented.mp4",
164+
/* peekLimit= */ 550);
155165
}
156166

157167
@Test
158168
public void sampleWithAc4Track() throws Exception {
159169
assertExtractorBehavior(
160-
/* closedCaptionFormats= */ ImmutableList.of(), "media/mp4/sample_ac4_fragmented.mp4");
170+
/* closedCaptionFormats= */ ImmutableList.of(),
171+
"media/mp4/sample_ac4_fragmented.mp4",
172+
/* peekLimit= */ 600);
161173
}
162174

163175
@Test
164176
public void sampleWithAc4Level4Track() throws Exception {
165177
assertExtractorBehavior(
166178
/* closedCaptionFormats= */ ImmutableList.of(),
167-
"media/mp4/sample_ac4_level4_fragmented.mp4");
179+
"media/mp4/sample_ac4_level4_fragmented.mp4",
180+
/* peekLimit= */ 580);
168181
}
169182

170183
@Test
171184
public void sampleWithProtectedAc4Track() throws Exception {
172185
assertExtractorBehavior(
173-
/* closedCaptionFormats= */ ImmutableList.of(), "media/mp4/sample_ac4_protected.mp4");
186+
/* closedCaptionFormats= */ ImmutableList.of(),
187+
"media/mp4/sample_ac4_protected.mp4",
188+
/* peekLimit= */ 810);
174189
}
175190

176191
@Test
177192
public void sampleWithEac3Track() throws Exception {
178193
assertExtractorBehavior(
179-
/* closedCaptionFormats= */ ImmutableList.of(), "media/mp4/sample_eac3_fragmented.mp4");
194+
/* closedCaptionFormats= */ ImmutableList.of(),
195+
"media/mp4/sample_eac3_fragmented.mp4",
196+
/* peekLimit= */ 550);
180197
}
181198

182199
@Test
183200
public void sampleWithEac3jocTrack() throws Exception {
184201
assertExtractorBehavior(
185-
/* closedCaptionFormats= */ ImmutableList.of(), "media/mp4/sample_eac3joc_fragmented.mp4");
202+
/* closedCaptionFormats= */ ImmutableList.of(),
203+
"media/mp4/sample_eac3joc_fragmented.mp4",
204+
/* peekLimit= */ 550);
186205
}
187206

188207
@Test
189208
public void sampleWithOpusTrack() throws Exception {
190209
assertExtractorBehavior(
191-
/* closedCaptionFormats= */ ImmutableList.of(), "media/mp4/sample_opus_fragmented.mp4");
210+
/* closedCaptionFormats= */ ImmutableList.of(),
211+
"media/mp4/sample_opus_fragmented.mp4",
212+
/* peekLimit= */ 540);
192213
}
193214

194215
@Test
195216
public void samplePartiallyFragmented() throws Exception {
196217
assertExtractorBehavior(
197218
/* closedCaptionFormats= */ ImmutableList.of(),
198-
"media/mp4/sample_partially_fragmented.mp4");
219+
"media/mp4/sample_partially_fragmented.mp4",
220+
/* peekLimit= */ 1300);
199221
}
200222

201223
/** https://github.com/google/ExoPlayer/issues/10381 */
202224
@Test
203225
public void sampleWithLargeBitrates() throws Exception {
204226
assertExtractorBehavior(
205227
/* closedCaptionFormats= */ ImmutableList.of(),
206-
"media/mp4/sample_fragmented_large_bitrates.mp4");
228+
"media/mp4/sample_fragmented_large_bitrates.mp4",
229+
/* peekLimit= */ 260);
207230
}
208231

209232
@Test
210233
public void sampleWithMhm1BlCicp1Track() throws Exception {
211234
assertExtractorBehavior(
212235
/* closedCaptionFormats= */ ImmutableList.of(),
213-
"media/mp4/sample_mhm1_bl_cicp1_fragmented.mp4");
236+
"media/mp4/sample_mhm1_bl_cicp1_fragmented.mp4",
237+
/* peekLimit= */ 610);
214238
}
215239

216240
@Test
217241
public void sampleWithMhm1LcblCicp1Track() throws Exception {
218242
assertExtractorBehavior(
219243
/* closedCaptionFormats= */ ImmutableList.of(),
220-
"media/mp4/sample_mhm1_lcbl_cicp1_fragmented.mp4");
244+
"media/mp4/sample_mhm1_lcbl_cicp1_fragmented.mp4",
245+
/* peekLimit= */ 620);
221246
}
222247

223248
@Test
224249
public void sampleWithMhm1BlConfigChangeTrack() throws Exception {
225250
assertExtractorBehavior(
226251
/* closedCaptionFormats= */ ImmutableList.of(),
227-
"media/mp4/sample_mhm1_bl_configchange_fragmented.mp4");
252+
"media/mp4/sample_mhm1_bl_configchange_fragmented.mp4",
253+
/* peekLimit= */ 610);
228254
}
229255

230256
@Test
231257
public void sampleWithMhm1LcblConfigChangeTrack() throws Exception {
232258
assertExtractorBehavior(
233259
/* closedCaptionFormats= */ ImmutableList.of(),
234-
"media/mp4/sample_mhm1_lcbl_configchange_fragmented.mp4");
260+
"media/mp4/sample_mhm1_lcbl_configchange_fragmented.mp4",
261+
/* peekLimit= */ 620);
235262
}
236263

237264
@Test
238265
public void sampleWithIamfTrack() throws Exception {
239266
assertExtractorBehavior(
240-
/* closedCaptionFormats= */ ImmutableList.of(), "media/mp4/sample_fragmented_iamf.mp4");
267+
/* closedCaptionFormats= */ ImmutableList.of(),
268+
"media/mp4/sample_fragmented_iamf.mp4",
269+
/* peekLimit= */ 150);
241270
}
242271

243272
@Test
@@ -247,11 +276,12 @@ public void sampleWithNonReferenceH265FramesAndCaptions() throws Exception {
247276
Collections.singletonList(
248277
new Format.Builder().setSampleMimeType(MimeTypes.APPLICATION_CEA608).build());
249278

250-
assertExtractorBehavior(closedCaptions, "media/mp4/fragmented_captions_h265.mp4");
279+
assertExtractorBehavior(
280+
closedCaptions, "media/mp4/fragmented_captions_h265.mp4", /* peekLimit= */ 3100);
251281
}
252282

253-
private void assertExtractorBehavior(List<Format> closedCaptionFormats, String file)
254-
throws IOException {
283+
private void assertExtractorBehavior(
284+
List<Format> closedCaptionFormats, String file, int peekLimit) throws IOException {
255285
ExtractorAsserts.AssertionConfig.Builder assertionConfigBuilder =
256286
new ExtractorAsserts.AssertionConfig.Builder();
257287
if (readWithinGopSampleDependencies) {
@@ -263,6 +293,7 @@ private void assertExtractorBehavior(List<Format> closedCaptionFormats, String f
263293
getExtractorFactory(
264294
closedCaptionFormats, subtitlesParsedDuringExtraction, readWithinGopSampleDependencies),
265295
file,
296+
peekLimit,
266297
assertionConfigBuilder.build(),
267298
simulationConfig);
268299
}

0 commit comments

Comments
 (0)