235 Commits

Author SHA1 Message Date
ibaker
d3894e6691 Add a default no-op implementation for SubtitleParser.reset
Most implementations were already no-ops.

PiperOrigin-RevId: 557503628
2023-08-16 21:59:19 +01:00
ibaker
d42c58f152 Fix DvbParser handling of pageComposition = null
This `DvbParser` was updated to implement the new `SubtitleParser`
interface in 2261756d3a.

This method used to return a `List<Cue>`, but now it returns a
`List<CuesWithTiming>`, which is closer to `List<List<Cue>>`. The
previous method returned an empty list, meaning a single 'event' with
no cues. After the change above the method still returns an empty list,
but that now means 'no events'. In order to maintain the old behaviour,
this change updates it to return a single-item list containing an empty
list of cues.

PiperOrigin-RevId: 557502261
2023-08-16 21:57:58 +01:00
ibaker
eb63ed5871 Add test for Mp3Extractor.FLAG_ENABLE_CONSTANT_BITRATE_SEEKING_ALWAYS
This test uses an existing CBR test asset, and shows that (as expected)
`isSeekable = true` even in the `unknown_length` dump file.

PiperOrigin-RevId: 557455364
2023-08-16 14:34:21 +01:00
tofunmi
d4b452d475 Use ProgressiveMediaSource and period for images
PiperOrigin-RevId: 555424664
2023-08-10 12:30:29 +00:00
tofunmi
7bc213d3ef Set tile count in Pngextractor
Tile count must be set to make sure the image decoder recognises and supports the format.

PiperOrigin-RevId: 555136616
2023-08-10 12:19:03 +00:00
samturci
821ec49049 Preserve the byte order when using read-only ByteBuffers.
`asReadOnlyBuffer` doesn't copy the original byte order but always sets it to big-endian. Replace calls to it with a utility method that manually sets the byte order after creating the read-only copy.

This fixes `TeeAudioProcessor` providing a `ByteBuffer` always in big-endian and hence causing `AudioBufferSink` to read wrong data.

PiperOrigin-RevId: 554861402
2023-08-10 12:08:19 +00:00
tofunmi
dfd668238a Create SingleSampleSeekMap and use in pngExtractor
PiperOrigin-RevId: 553191571
2023-08-07 11:27:27 +00:00
tofunmi
87a020a154 Add PngExtractor to DefaultExtractorsFactory
PiperOrigin-RevId: 552506545
2023-08-01 14:32:58 +01:00
jbibik
b8e6f27caf Update SubtitleExtractor to use SubtitleParser directly
`SubtitleExtractor` used to rely on a `SubtitleDecoder`. However, now all SubtitleDecoders that are used for side-loaded subtitles have been migrated to a `SubtitleParser` interface. We can therefore refactor the extractor.

The `SubtitleExtractor` is only used for side-loaded subtitles which means we do not require the migration of the CEA-608/708 `SubtitleDecoders`.

PiperOrigin-RevId: 552471710
2023-08-01 14:31:58 +01:00
tofunmi
bb699e41c9 Add png extractor
Implementing a basic extractor that reads the whole png file into the trackOutput as one sample.

PiperOrigin-RevId: 551897619
2023-08-01 14:24:47 +01:00
ibaker
449cf55523 Add comment about out-of-order timestamps in AtomParsers.parseStbl
PiperOrigin-RevId: 550596173
2023-08-01 13:57:36 +01:00
jbibik
f4ad26451f Deprecate MimeTypes.TEXT_EXOPLAYER_CUES for APPLICATION_MEDIA3_CUES
Instead of `text/x-exoplayer-cues`, we will use `application/x-media3-cues`.

The prefix should be `application` not `text` since the encoded form is arbitrary bytes, not necessarily text. The name should not reference `exoplayer`, since the Media3 Extractors (which are not part of `exoplayer`) produce this format.

PiperOrigin-RevId: 550181852
2023-08-01 13:50:50 +01:00
jbibik
25253698bc TtmlParser implementation - moved from TtmlDecoder
`TtmlDecoder` which used to be `SimpleSubtitleDecoder` will now be called `TtmlParser` and implement SubtitleParser interface. For backwards compatibility, we will have the same functionality provided by `DelegatingSubtitleDecoder` backed-up by a new `TtmlParser` instance.

PiperOrigin-RevId: 549700490
2023-08-01 13:43:12 +01:00
jbibik
1c1b78e635 Test for Decoder with Mp4WebvttParser corrected
PiperOrigin-RevId: 549629289
2023-08-01 13:42:06 +01:00
jbibik
e11e484bc3 Do not emit empty cues in SsaParser
It is not part of the `SubtitleParser` interface's promise to give events for all changes to do with `Cue` objects. So while in the past, we would have `endTimeUs` of one Cue event being the `startTimeUs` of the next one, now we have that encoded in `durationUs` and can skip event with empty `Cues`.

PiperOrigin-RevId: 549629157
2023-08-01 13:41:11 +01:00
jbibik
27bda610aa Standardise the use of ParsableByteArray use among SubtitleParsers
PiperOrigin-RevId: 549609028
2023-08-01 13:38:38 +01:00
jbibik
f4c66d82dd TtmlDecoderTest refactor not to use TtmlNode or TtmlStyle
PiperOrigin-RevId: 549584918
2023-08-01 13:30:39 +01:00
jbibik
f0f24aa0d4 WebvttParser implementation - moved from WebvttDecoder
`WebvttDecoder` which used to be `SimpleSubtitleDecoder` will now be called `WebvttParser` and implement `SubtitleParser` interface.

For backwards compatibility, we will have the same functionality provided by `DelegatingSubtitleDecoder` backed-up by a new `WebvttParser` instance. `WebvttSubtitle` will still be used behind the scenes to handle overlapping `Cues`.

PiperOrigin-RevId: 549298733
2023-07-20 10:32:13 +01:00
ibaker
5d453fcf37 Add an Extractor to parse subtitles before SampleQueue
The end-to-end test output for the overlapping SRT and SSA subtitles
is currently incorrect. They will be fixed in a future change that
updates `TextRenderer` to support this overlap.

The 'extra' samples visible in the extractor test output files are
'empty cue list' samples produced by `SsaParser`. They will go away
when this implementation is updated to remove this behaviour and rely
on `CuesWithTiming.durationUs` instead (the 'empty list' behaviour is
not required by the `SubtitleParser` interface).

PiperOrigin-RevId: 549264593
2023-07-20 10:30:16 +01:00
jbibik
d9daa392d5 Util for Subtitle to CuesWithTiming conversion
PiperOrigin-RevId: 549027279
2023-07-20 10:27:47 +01:00
ibaker
0fa66534fe Use CuesWithTiming.durationUs in SubripParser instead of empty cues
This fixes two things in one go:
1. In order to indicate 'end of a cue' **without** relying on
   `CuesWithTiming.durationUs`, `SubripParser` should have been emitting
   an empty `List<Cue>` instead of the current behaviour of a
   single-item list with `cue.text=""`.
2. There's no need for the empty cue (or cue list), we can use
   `durationUs` to indicate the end of each list of cues.

There's no real need to ever have a `Cue` with `text=""`, so also
deprecate `Cue.EMPTY`.

PiperOrigin-RevId: 548938874
2023-07-20 10:18:09 +01:00
ibaker
34768c2399 Add MKV test assets with overlapping SSA and SRT subtitles
This is a step towards adding general support for overlapping
subtitles in these formats (and others), both muxed and sideloaded:
* Issue: google/ExoPlayer#10295
* Issue: google/ExoPlayer#4794

This change adds these files to the end-to-end playback tests too, but
the subtitle track is currently disabled because renderer-side subtitle
parsing causes flaky tests (due to an uncontrolled thread in
`SimpleSubtitleDecoder`). The subtitle track will be re-enabled in
a follow-up change when loading-side subtitle parsing is added (so the
tests will no longer be flaky). At this point the overlapping subtitles
**still** won't be supported end-to-end, but a second change will
resolve this will changes in `TextRenderer` - which will change the
end-to-end playback dumps to reflect the overlapping subtitles.

PiperOrigin-RevId: 548705032
2023-07-20 10:14:50 +01:00
jbibik
4ed01c42bd DefaultSubtitleParserFactory that creates supported SubtitleParsers
It will act similarly to `SubtitleDecoderFactory`, but return parsers instead of decoders. In turn `SubtitleDecoderFactory.createDecoder()` cab wrap those parsers with `DelegatingSubtitleDecoder`.

PiperOrigin-RevId: 548528054
2023-07-20 10:07:16 +01:00
jbibik
7d4848ece2 PgsParser implementation - moved from PgsDecoder
`PgsDecoder` which used to be `SimpleSubtitleDecoder` will now be called `PgsParser` and implement `SubtitleParser` interface. For backwards compatibility, we will have the same functionality provided by `DelegatingSubtitleDecoder` backed-up by a new `PgsParser` instance.

PiperOrigin-RevId: 548520549
2023-07-20 10:05:52 +01:00
jbibik
2261756d3a DvbParser implementation to adhere to SubtitleParser interface
`DvbDecoder` which used to be `SimpleSubtitleDecoder` will now be called `DvbParser` and implement `SubtitleParser` interface. There was, however, already a `DvbParser`, used by `DvbDecoder` behind the scenes. Hence, the refactoring only requires the existing `DvbParser` to adhere to the new `SubtitleParser` interface.

For backwards compatibility, we will have the same functionality as `DvbDecoder` provided by `DelegatingSubtitleDecoder` backed-up by a new `DvbParser` instance, available from the `SubtitleDecoderFactory`.

PiperOrigin-RevId: 548155759
2023-07-20 10:02:34 +01:00
jbibik
7537e692c6 Tx3gParser implementation - moved from Tx3gDecoder
`Tx3gDecoder` which used to be `SimpleSubtitleDecoder` will now be called `Tx3gParser` and implement `SubtitleParser` interface. For backwards compatibility, we will have the same functionality provided by `DelegatingSubtitleDecoder` backed-up by a new `Tx3gParser` instance.

PiperOrigin-RevId: 548144492
2023-07-20 10:01:21 +01:00
michaelkatz
847f6f24d3 Prepend Ogg ID and Comment Header Pages to offloaded Opus stream
Add Ogg ID Header and Comment Header Pages to the Ogg encapsulated Opus for offload playback. This further matches the RFC 7845 spec and provides initialization data to decoders.

PiperOrigin-RevId: 548080222
2023-07-20 09:56:31 +01:00
ibaker
06132c6778 Update DelegatingSubtitleDecoder to handle startTimeUs = TIME_UNSET
Also add a test to enforce this when `Tx3gDecoder` is migrated to
`Tx3gParser`.

PiperOrigin-RevId: 547856968
2023-07-14 10:21:58 +01:00
andrewlewis
2bfc6c7740 Add support for extracting Vorbis audio in MP4
PiperOrigin-RevId: 547474958
2023-07-13 15:53:55 +01:00
jbibik
02b9d8d8b7 Mp4WebvttParser implementation - moved from Mp4WebvttDecoder
`Mp4WebvttDecoder` which used to be `SimpleSubtitleDecoder` will now be called `Mp4WebvttParser` and implement `SubtitleParser` interface. For backwards compatibility, we will have the same functionality provided by `DelegatingSubtitleDecoder` backed-up by a new `Mp4WebvttParser` instance.

PiperOrigin-RevId: 547248157
2023-07-13 15:46:44 +01:00
ibaker
9039621588 Update docs to allow CuesWithTiming.startTimeUs to be C.TIME_UNSET
This is needed for several subtitle formats where the `data` passed to
`SubtitleParser` doesn't contain any cue timing, such as PGS, CEA-608,
CEA-708, and DVB.

PiperOrigin-RevId: 547177127
2023-07-13 15:40:33 +01:00
andrewlewis
6f4ef51727 Add support for big endian 24/32-bit PCM
Also parse the PCM encoding for lpcm in MP4, and update `MatroskaExtractor`
similarly.

Tested manually in the demo app using an MP4 with 24-bit big endian audio.

PiperOrigin-RevId: 546878505
2023-07-13 15:31:14 +01:00
jbibik
ca483a3c2c SubripParser implementation - moved from SubripDecoder
`SubripDecoder` which used to be `SimpleSubtitleDecoder` will now be called `SubripParser` and implement `SubtitleParser` interface. For backwards compatibility, we will have the same functionality provided by `DelegatingSubtitleDecoder` backed-up by a new `SubripParser` instance.

PiperOrigin-RevId: 546538113
2023-07-13 15:21:55 +01:00
jbibik
377d8edf9c SsaParser implementation - moved from SsaDecoder
`SsaDecoder` which used to be `SimpleSubtitleDecoder` will now be called `SsaParser` and implement `SubtitleParser` interface. For backwards compatibility, we will have the same functionality provided by `DelegatingSubtitleDecoder` backed-up by a new `SsaParser` instance.

PiperOrigin-RevId: 546336035
2023-07-13 15:20:34 +01:00
ibaker
06a791620e Update TODO link for shrinking workaround in DefaultExtractorsFactory
PiperOrigin-RevId: 545930708
2023-07-13 15:02:33 +01:00
rohks
07d4e5986b Replace BitArray.skipBytes() with BitArray.skipBits()
Based on the spec, ETSI TS 102 366 V1.4.1 Annex F, 6 bits should have skipped instead of 6 bytes.

This correction was pointed out in Issue: androidx/media#474.

PiperOrigin-RevId: 545658365
2023-07-13 14:52:54 +01:00
ibaker
3456382ae7 Include timing info in some SCTE-35 toString implementations
This was helpful in investigating Issue: androidx/media#471

PiperOrigin-RevId: 545393217
2023-07-05 09:18:00 +00:00
ibaker
a783d704b2 Add duration to text/x-exoplayer-cues binary format
This plumbs a duration through `SampleQueue` which will make it easier
to handle transcoding muxed subtitles from e.g. SubRip to
`text/x-exoplayer-cues`.

This change is a no-op to the end-to-end behaviour of ExoPlayer because
currently we only support parsing sideloaded subtitles before
`SampleQueue`, and by adding the duration we don't affect the cues that
are ultimately output by `Player.Listener.onCues` (as shown by no change
to the golden files for `WebvttPlaybackTest` in this commit).

I considered making `CuesWithStartTimeAndDuration` implement
`Bundleable` (and deleting `CueEncoder/Decoder`) but decided against
it because we are deliberately not encoding `startTimeUs` (since that's
encoded as the sample time in `SampleQueue`). I also considered
introducing another type that only has `List<Cue>` and `durationUs`
fields, but it didn't seem necessary, since we want `startTimeUs`
everywhere else (except inside `SampleQueue`).

PiperOrigin-RevId: 545226847
2023-07-05 09:14:38 +00:00
ibaker
4ae36cc175 Fix Error Prone warning in SubtitleExtractorTest
Also make some casting that is needed a bit safer.

Error Prone was complaining about casting `long` to `int` before passing
it to `Extractor.seek(long, long)`:
> Converting a `long` or `Long` to an `int` to pass as a `long`
> parameter is usually not necessary. If this conversion is intentional,
> consider `Longs.constrainToRange()` instead.

PiperOrigin-RevId: 545226063
2023-07-05 09:13:29 +00:00
ibaker
412e9398f9 Add SubtitleParser.Factory
This is a corollary of `SubtitleDecoderFactory`. We may add a
`boolean supportsFormat(Format)` method later if it turns out to be
useful.

PiperOrigin-RevId: 545225489
2023-07-05 09:12:17 +00:00
ibaker
e67e28c4aa Introduce CuesWithTiming and use it in SubtitleParser
PiperOrigin-RevId: 545224876
2023-07-05 09:11:08 +00:00
ibaker
e8fdd83558 CEA-608: Only truncate to 32 visible characters
We introduced truncation to 32 chars in <unknown commit>
and included indent and offset in the calculation. I think this is
technically correct, but it causes problems with the content in
Issue: google/ExoPlayer#11019 and it doesn't seem a problem to only truncate actual
cue text (i.e. ignore offset and indent).

#minor-release

PiperOrigin-RevId: 544677965
2023-07-05 08:59:08 +00:00
tonihei
2322462404 Do not trim audio samples by changing their timestamp
MP4 edit lists sometimes ask to start playback between two samples.
If this happens, we currently change the timestamp of the first
sample to zero to trim it (e.g. to display the first frame for a
slightly shorter period of time). However, we can't do this to audio
samples are they have an inherent duration and trimming them this
way is not possible.

#minor-release

PiperOrigin-RevId: 543420218
2023-06-29 22:50:04 +00:00
ibaker
bc06039f7f Add Extractor.getUnderlyingImplementation
This change uses this new method everywhere we currently `instanceof`
check an `Extractor` directly. This allows us to introduce
wrapping/delegating `Extractor` instances - because the `instanceof`
checks will continue to operate on the underlying instance.

HLS is a slightly different case, because it directly re-instantiates
`Extractor` instances, which is not compatible with an arbitrary
wrapping structure. Luckily the only `Extractor` instances that HLS
re-instantiates do not support muxed subtitles, so won't be wrapped
in the first place (although future changes might use the
delegating-`Extractor` pattern for other purposes, which might affect
HLS).

PiperOrigin-RevId: 542550928
2023-06-22 15:49:52 +00:00
Tofunmi Adigun-Hameed
6e9df8df77 Merge pull request #461 from almiki:release
PiperOrigin-RevId: 542228372
2023-06-22 15:34:28 +00:00
Ian Baker
35e179f080 Add a release note, fix some nullness and comments 2023-06-21 10:00:47 +01:00
Alex Kinney
77c7c189a6 Fixed typo when determining 'rotationDegrees'
projectionPosePitch => projectionPoseRoll
2023-06-20 18:48:10 +01:00
Daniele Sparano
b553d2c3f9 Add end of TS input fix to HLS mode 2023-06-20 17:08:11 +01:00
Daniele Sparano
550bc5be20 Add end of input fix to H262 reader 2023-06-20 17:08:11 +01:00
Daniele Sparano
45372911b0 Add end of input fix to H263 reader 2023-06-20 17:08:11 +01:00