Commit c683a22
[HLS] Properly handle getNextChunk for a playlist with no segments
When calculating the `segmentIndexInPlaylist` with the binary search (`stayInBound=true`), a corner case of `mediaPlaylist.segments` being empty also lead to the adjusted result of `segmentIndexInPlaylist = 0`. Then in the logic of picking up a `Part`, fetching a `Segment` may end up in `IndexOutOfBoundsException`. Thus we fix the `Part` picking logic into:
* When the playlist is VOD, there is no need to pick up a `Part`, then we bypass the `Part` picking logic;
* When the playlist is LIVE, and we are inside the live window:
* When the `mediaPlaylist.segments` is not empty, use the old part picking logic: Depending on the `targetPositionInPlaylistUs`, either picking among the `Part`s of an existing `Segment`, or picking among the trailing parts. If we pick among the trailing parts, we should increase the media sequence by one as if we will be loading a "new segment";
* When the `mediaPlaylist.segments` is empty, we can still try to pick from the trailing parts. If we pick a part, we don't need to increase the media sequence as we have hiddenly increased it by the `stayInBound` adjustment.
As a result, for VOD playlist, an empty `mediaPlaylist.segments` will lead to end of stream, and for LIVE playlist, it will lead to either loading a trailing part or refreshing the playlist.
Issue: #2821
PiperOrigin-RevId: 8308876861 parent 6384e63 commit c683a22
File tree
6 files changed
+134
-7
lines changed- libraries
- exoplayer_hls/src
- main/java/androidx/media3/exoplayer/hls
- test/java/androidx/media3/exoplayer/hls
- test_data/src/test/assets/media/m3u8
6 files changed
+134
-7
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
32 | 32 | | |
33 | 33 | | |
34 | 34 | | |
| 35 | + | |
| 36 | + | |
35 | 37 | | |
36 | 38 | | |
37 | 39 | | |
| |||
Lines changed: 23 additions & 7 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
905 | 905 | | |
906 | 906 | | |
907 | 907 | | |
| 908 | + | |
| 909 | + | |
| 910 | + | |
| 911 | + | |
| 912 | + | |
908 | 913 | | |
909 | 914 | | |
910 | | - | |
911 | | - | |
912 | | - | |
913 | | - | |
914 | | - | |
| 915 | + | |
| 916 | + | |
| 917 | + | |
| 918 | + | |
| 919 | + | |
| 920 | + | |
| 921 | + | |
| 922 | + | |
| 923 | + | |
| 924 | + | |
| 925 | + | |
915 | 926 | | |
916 | 927 | | |
917 | 928 | | |
918 | 929 | | |
919 | 930 | | |
920 | | - | |
921 | | - | |
| 931 | + | |
| 932 | + | |
| 933 | + | |
| 934 | + | |
| 935 | + | |
| 936 | + | |
| 937 | + | |
922 | 938 | | |
923 | 939 | | |
924 | 940 | | |
| |||
Lines changed: 93 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
78 | 78 | | |
79 | 79 | | |
80 | 80 | | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
81 | 85 | | |
82 | 86 | | |
83 | 87 | | |
| |||
337 | 341 | | |
338 | 342 | | |
339 | 343 | | |
| 344 | + | |
| 345 | + | |
| 346 | + | |
| 347 | + | |
| 348 | + | |
| 349 | + | |
| 350 | + | |
| 351 | + | |
| 352 | + | |
| 353 | + | |
| 354 | + | |
| 355 | + | |
| 356 | + | |
| 357 | + | |
| 358 | + | |
| 359 | + | |
| 360 | + | |
| 361 | + | |
| 362 | + | |
| 363 | + | |
| 364 | + | |
| 365 | + | |
| 366 | + | |
| 367 | + | |
| 368 | + | |
| 369 | + | |
| 370 | + | |
| 371 | + | |
| 372 | + | |
| 373 | + | |
| 374 | + | |
| 375 | + | |
| 376 | + | |
| 377 | + | |
| 378 | + | |
| 379 | + | |
| 380 | + | |
| 381 | + | |
| 382 | + | |
| 383 | + | |
| 384 | + | |
| 385 | + | |
| 386 | + | |
| 387 | + | |
| 388 | + | |
| 389 | + | |
| 390 | + | |
| 391 | + | |
| 392 | + | |
| 393 | + | |
| 394 | + | |
| 395 | + | |
| 396 | + | |
| 397 | + | |
| 398 | + | |
| 399 | + | |
| 400 | + | |
| 401 | + | |
| 402 | + | |
| 403 | + | |
| 404 | + | |
| 405 | + | |
| 406 | + | |
| 407 | + | |
| 408 | + | |
| 409 | + | |
| 410 | + | |
| 411 | + | |
| 412 | + | |
| 413 | + | |
| 414 | + | |
| 415 | + | |
| 416 | + | |
| 417 | + | |
| 418 | + | |
| 419 | + | |
| 420 | + | |
| 421 | + | |
| 422 | + | |
| 423 | + | |
| 424 | + | |
| 425 | + | |
| 426 | + | |
| 427 | + | |
| 428 | + | |
| 429 | + | |
| 430 | + | |
| 431 | + | |
340 | 432 | | |
341 | 433 | | |
342 | 434 | | |
| |||
949 | 1041 | | |
950 | 1042 | | |
951 | 1043 | | |
| 1044 | + | |
952 | 1045 | | |
953 | 1046 | | |
954 | 1047 | | |
| |||
Lines changed: 9 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
Lines changed: 3 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
Lines changed: 4 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
0 commit comments