264 Commits

Author SHA1 Message Date
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
Daniele Sparano
f0666c605c Fix lib-extractor tests 2023-06-20 17:08:11 +01:00
Daniele Sparano
c6c048f542 Send empty pusi flagged data, on end of input, from TS extractor to readers; add end of input flag to readers to flush accumulated data from last PES 2023-06-20 17:08:11 +01:00
sheenachhabra
911a6430f3 Remove UdtaInfo class
The class seems unnecessary and the code can be simplified by
removing this.

PiperOrigin-RevId: 541675378
2023-06-20 14:00:50 +01:00
tonihei
51fb72b00d Replace deprecated NullableType from checkerframework with our own one
The existing NullableType has been deprecated 5 years ago and causes
crashes in Kotlin apps because Kotlin doesn't recognize this annotation
as a nullable type annotation.

While we can't align on a single @Nullable annotation yet, we can at
least replace this one by JSR305's @Nonnull(MAYBE) as it fulfils all
requirements, including full Kotlin compatiblity. To avoid the
cumbersome name, we can redefine it as our own @NullableType
annotation. (We can't use @Nullable to avoid name clashes with the main
@Nullable annotation from AndroidX)

Issue: google/ExoPlayer#6792
PiperOrigin-RevId: 540497469
2023-06-19 16:08:20 +01:00
sheenachhabra
d0eda433ea Replace CreationTime class with Mp4TimestampData class
PiperOrigin-RevId: 540257484
2023-06-14 20:42:36 +01:00
ibaker
3cf21bd5d5 Require the list returned by SubtitleParser to be sorted by timestamp
This makes it more efficient to consume (e.g. we can binary search
through it).

PiperOrigin-RevId: 539095673
2023-06-10 20:21:29 +00:00
sheenachhabra
53c174f047 Add support for passing custom metadata via transformer
Changes included:
1. Enable MP4 extractor to read all types of metadata.
2. Allow passing String and Float metadata via Transformer.

Reference to QuickTime spec: https://developer.apple.com/library/archive/documentation/QuickTime/QTFF/Metadata/Metadata.html#//apple_ref/doc/uid/TP40000939-CH1-SW21

PiperOrigin-RevId: 538783982
2023-06-09 13:51:15 +00:00
sheenachhabra
7e14811e25 Add support for passing creation time via InAppMuxer
PiperOrigin-RevId: 538175466
2023-06-06 18:12:51 +00:00
tianyifeng
f4bf376e89 Defer outputting the metadata sample when TimestampAdjuster isn't initialized
The sample timestamp carried by the emsg box can have a significant delta when comparing to the earliest presentation timestamp of the segment. Using this timestamp to intialize the timestamp offset in TimestampAdjuster will cause the media sample to have a wrong adjusted timestamp. So we should defer adjusting the metadata sample timestamp until the TimestampAdjuster is initialized with a real media sample.

PiperOrigin-RevId: 538172841
2023-06-06 18:10:41 +00:00
Googler
83e9080b71 Override ParserException#getMessage
PiperOrigin-RevId: 537908595
2023-06-06 18:05:33 +00:00
ibaker
79b721e411 Define the SubtitleParser interface
We will migrate concrete implementations of `SubtitleDecoder` to implement
this instead.

PiperOrigin-RevId: 537298600
2023-06-05 09:49:26 +00:00
ibaker
7e6dae7b31 Remove exoplayer2-only javadoc machinery from media3
This introduces whitespace-only changes in exoplayer2 due to the way
copybara stripping works.

PiperOrigin-RevId: 537296933
2023-06-05 09:47:58 +00:00
christosts
757247e2ae Release MIDI decoder module in open-source
PiperOrigin-RevId: 537034577
2023-06-02 09:18:09 +00:00
Tianyi Feng
9d147f2227 Adjust the comment lines 2023-05-25 09:58:07 +00:00
Tianyi Feng
f69718e5ad Fix the lint issues 2023-05-25 09:58:07 +00:00
Tianyi Feng
47b0726ea9 Format with google-java-format 2023-05-25 09:55:10 +00:00
Cedric T
c984387248 Re-word comments for new DTS Sync words in DtsUtil.java. 2023-05-25 09:55:10 +00:00
Cedric T
3b9d680914 Add comments for DTSUtil.java 2023-05-25 09:55:09 +00:00
Cedric T
b73d2cc736 Add direct passthrough support for DTS audio. 2023-05-25 09:55:09 +00:00
christosts
b9a4e614f7 Fix seeking bug in opus
Fix a bug when seeking in an opus container. The calculations inside
DefaultOggSeeker may overflow a long primitive.

Issue: androidx/media#391

#minor-release

PiperOrigin-RevId: 534128513
2023-05-24 15:44:49 +01:00
sheenachhabra
b382a7c2da Move MdtaMetadataEntry class into container module
This class is to be shared between extractor, transformer
and muxer module.

PiperOrigin-RevId: 533490888
2023-05-24 15:29:23 +01:00