299 Commits

Author SHA1 Message Date
bachinger
6d014cbfd2 Move SubtitleExtractor to text package
PiperOrigin-RevId: 399661676
2021-09-30 11:20:44 +01:00
bachinger
3e7b2d06c1 Move SubtitleExtractor to text package
PiperOrigin-RevId: 399400909
2021-09-28 16:41:08 +01:00
Oliver Woodman
9108dc5b0e Merge pull request #9421 from MarcusWichelmann:hevc-sps-parsing
PiperOrigin-RevId: 398749045
2021-09-24 18:13:01 +01:00
bachinger
4fec4b8f6a Move format specific metadata packages to lib-extractor
PiperOrigin-RevId: 398262695
2021-09-23 15:13:10 +01:00
bachinger
f2a027e068 Move text classes from lib-exoplayer to lib-extractor and lib-common
PiperOrigin-RevId: 398247348
2021-09-23 15:09:07 +01:00
ibaker
ad99a44083 Add empty sdk-version node to all AndroidManifest.xml files
PiperOrigin-RevId: 397772916
2021-09-21 14:17:33 +01:00
kimvde
46d97bdd39 Fix DTS_X audio mime type
Issue: #9429

#minor-release

PiperOrigin-RevId: 397717740
2021-09-20 13:02:53 +01:00
ibaker
73aece6356 Improve AdtsExtractor#sniff when trying different sync word offsets
The previous implementation did the following (after skipping any ID3
headers at the start of the stream):
1. Skip forward byte-by-byte looking for a sync word (0xFFF)
2. Assume this indicates the start of an ADTS frame and read the size
  a) If frameSize <= 6 immediately return false
3. Skip forward by frameSize and expect to find another ADTS sync word
   (with no further scanning).
   b) If we find one, great! Loop from step 2.
   a) If we don't find one then assume the **last** sync word we found
      wasn't actually one, so loop from step 1 starting one extra byte
      into the stream. This means we're looking for a sync word we would
      have skipped over in step 3.

The asymmetry here comes from the different handling of frameSize <= 6
(immediately return false) and frameSize being 'wrong because it doesn't
lead to another sync word' (scan the file again from the beginning for
alternative sync words).

With this change both these cases are handled symmetrically (always scan
for alternative sync words). Step 2a) becomes the same as 3b): Loop back
to the beginning of the stream with an incremented offset and scan for
another sync word.

#minor-release

PiperOrigin-RevId: 397285756
2021-09-17 13:10:58 +01:00
bachinger
f7abce6aea Move FlacConstant to lib-extractor
PiperOrigin-RevId: 397156268
2021-09-16 22:39:14 +01:00
krocard
92bf5d80c7 Add nullness annotations to TsExtractors
#exofixit

PiperOrigin-RevId: 396658717
2021-09-14 21:35:08 +01:00
olly
f8d60e2bbb Add flag for constant bitrate seeking even if input length is unknown
PiperOrigin-RevId: 396363113
2021-09-14 12:11:48 +01:00
andrewlewis
469c0e756a Use @C.TrackType more widely
Also add `TYPE_USE` target on the @IntDef (and fix @Targets for other
@IntDefs).

#exofixit

PiperOrigin-RevId: 396333212
2021-09-14 12:04:11 +01:00
Marcus Wichelmann
65001cc0e5
Added javadoc comments to HevcConfig 2021-09-13 16:48:08 +02:00
Marcus Wichelmann
dbc7088716
Keep the existing parseSpsNalUnit (and similar) methods to avoid breaking changes 2021-09-13 12:30:21 +02:00
Marcus Wichelmann
296074fbea
Extend SPS parsing when building the initial MP4 HevcConfig and include the PAR for propagating it into the Format 2021-09-13 10:27:55 +02:00
apodob
837667dea1 Add seeking support to the SubtitleExtractor
SubtitleExtractor is using IndexSeekMap with only one position to
indicate that its output is seekable. SubtitleExtractor is keeping Cues
in memory anyway so more seek points are not needed. SubtitleExtractor
gets notified about seek occurrence through seek() method. Inside that
method extractor saves seekTimeUs, and on the next call to read()
extractor outputs all cues that should be displayed at this time and
later.

PiperOrigin-RevId: 395477127
2021-09-08 17:16:31 +01:00
apodob
66335ab6f5 Redesign states of the SubtitleExtractor.
Simplifies the SubtitleExtractor implementation. Makes the extractor
more aligned with the Extractor interface documentation by removing
STATE_DECODING in which extractor was doing nothing in term of input
and output while returning RESULT_CONTINUE at the same time.

PiperOrigin-RevId: 395267468
2021-09-07 20:24:16 +01:00
olly
97b717b8dc Duration readers: Return TIME_UNSET rather than a negative value
This typically happens if there's a discontinuity in the stream.
It's better to say we don't know, than it is to return a negative
position.

Issue: #8346
#exofixit
#minor-release
PiperOrigin-RevId: 395224088
2021-09-07 17:46:47 +01:00
andrewlewis
d05c15dee0 Add open @IntDef for track types
Also add handling of `C.TRACK_TYPE_IMAGE` in a couple of places where it was
missing.

#exofixit

PiperOrigin-RevId: 395078312
2021-09-06 15:04:47 +01:00
apodob
095c63933b Fix the preparation of Extractor inside the init() method
Extractor was not calling endTracks() and seekMap() on the
extractorOutput which are required to finish the preparation.
At that point extractor does not support seeking.

PiperOrigin-RevId: 393994848
2021-09-02 09:38:30 +01:00
kimvde
97466ab779 TsExtractor: handle packets without PTS
#minor-release
Issue: #9294
PiperOrigin-RevId: 392844983
2021-08-25 10:59:58 +01:00
andrewlewis
654a320792 Remove stray symlinks
These are unneeded for the external project

#minor-release

PiperOrigin-RevId: 392835942
2021-08-25 10:58:20 +01:00
apodob
cbd6527926 Set format.sampleMimeType to TEXT_EXOPLAYER_CUES in SubtitleExtractor.
Samples are serialized using our custom CueEncoder. Information in
which format samples are encoded is needed by Renderer to decide which
decoder to use. Extractor receives Format object in the constructor and
prepares new Format object with sampleMimeType moved to codecs field
and new sampleMimeType set to "custom serialized exoplayer Cue".

PiperOrigin-RevId: 391739866
2021-08-20 11:44:06 +01:00
apodob
afc549fba4 Release subtitle outputBuffer after decoding.
PiperOrigin-RevId: 391509443
2021-08-19 10:51:34 +01:00
apodob
80d9d47d1c Add Extractor#release() implementation.
SubtitleExtractor.release() releases the underlying SubtitleDecoder.
This change introduces the STATE_RELEASED state. The extractor
handles the new state in the read() and seek() methods.

PiperOrigin-RevId: 391046478
2021-08-17 15:41:03 +01:00
olly
88a637bc45 Move format util classes to extractor package
PiperOrigin-RevId: 390577072
2021-08-13 11:45:37 +01:00
apodob
c5b01b2f7b Add SubtitleExtractor which wraps a SubtitleDecoder.
SubtitleExtractor is a component that extracts subtitle data taken from
ExtractorInput into samples. Samples are pushed into an ExtractorOutput
(usually SampleQueue). As a temporary solution SubtitleExtractor uses
SubtitleDecoder to extract Cues from input data.

PiperOrigin-RevId: 390319875
2021-08-12 16:33:14 +01:00
olly
7e8ba03147 Deprecate final non-nested Factory classes in upstream
PiperOrigin-RevId: 389661768
2021-08-09 20:07:24 +01:00
ibaker
db1fe8041b Remove @DoNotInstrument from test classes
This isn't needed now we've updated to Robolectric 4.6

Follow-up to 0df0df9aee

PiperOrigin-RevId: 389616471
2021-08-09 20:02:05 +01:00
olly
a34809bb9d Tweak use of TimestampAdjuster for seeking
- Fix use of getTimestampOffsetUs in TsExtractor where
  getFirstSampleTimestampUs should have been used.
- Don't reset TimestampAdjuster if it's in no-offset mode.
- Improve comment clarity

#minor-release

PiperOrigin-RevId: 388682711
2021-08-04 18:40:45 +01:00
olly
f726212180 Simplify TimestampAdjuster logic
- Use timestampOffsetUs == C.TIME_UNSET directly as the way of
  determining whether the adjuster has determined the offset,
  rather than relying on lastSampleTimestampUs checks for this.
- Remove comment referring to lastSampleTimestampUs as holding
  the "adjusted PTS". Its value may not have originated from a PTS
  timestamp. It's also confusing to refer to it as "adjusted"
  given timestampOffsetUs has not been applied to it.
- Fix PassthroughSectionPayloadReader to make sure it'll never
  output a sample with an unset timestamp.

#minor-release

PiperOrigin-RevId: 388226180
2021-08-02 19:19:28 +01:00
andrewlewis
9c27cfcda7 Fix parameter names on overridden methods
The dokka javadoc generation tool complains when parameter names don't match between a method and its override. This change updates occurrences where there is currently a mismatch.

Notable renamings that might be controversial:
- `onPlaybackStateChanged(int state)` to `onPlaybackStateChanged(int playbackState)` affected a lot of lines but seems more consistent with other '-Changed' methods.
- `handleMessage(int messageType, Object payload)` to `handleMessage(int messageType, Object message)`
- `ExtractorInput` and `DataSource` inherit `DataReader` which had `read(byte[] target, ...`, while data sources normally called the first parameter `buffer`. I have standardized these all to use `buffer` even though it looks out of place in the `ExtractorInput` interface (which has more `read` methods with `target`).

PiperOrigin-RevId: 387290360
2021-07-28 09:15:29 +01:00
olly
c6e860b8bb Fix 1 ErrorProneStyle finding:
* @Flags is not a TYPE_USE annotation, so should appear before any modifiers and after Javadocs.
  (see go/java-style#s4.8.5-annotations)

This CL looks good? Just LGTM and Approve it!
This CL doesn’t look good? This is what you can do:
* Suggest a fix on the CL (go/how-to-suggest-fix).
* Revert this CL, by replying "REVERT: <provide reason>"
* File a bug under go/error-prone-bug for category ErrorProneStyle if the change looks generally problematic.
* Revert this CL and not get a CL that cleans up these paths in the future by
replying "BLOCKLIST: <provide reason>". This is not reversible! We recommend to
opt out the respective paths in your CL Robot configuration instead:
go/clrobot-opt-out.

This CL was generated by CL Robot - a tool that cleans up code findings
(go/clrobot). The affected code paths have been enabled for CL Robot in //depot/google3/java/com/google/android/libraries/media/METADATA which is reachable following include_presubmits from //depot/google3/third_party/java_src/android_libs/media/METADATA.
Anything wrong with the signup? File a bug at go/clrobot-bug.

#codehealth

PiperOrigin-RevId: 386849198
2021-07-27 12:22:08 +01:00
kim-vde
8e29e76b51 Merge pull request #9163 from ProtoScott:feature/dtsx_codec_updates
PiperOrigin-RevId: 386428758
2021-07-23 14:12:29 +01:00
aquilescanta
99abb4e1e9 Check for TS synchronization before parsing packet from random position
#minor-release
Issue: #9100
PiperOrigin-RevId: 384962258
2021-07-16 11:22:55 +01:00
bachinger
f60c080500 Minor change to extractor module to avoid formatting changes
PiperOrigin-RevId: 384730845
2021-07-14 21:18:23 +01:00
kimvde
1309b26ebe Add support for MP4 H263 atom type
#minor-release
Issue:#9158
PiperOrigin-RevId: 383660258
2021-07-09 09:24:13 +01:00
Scott
716cbceaa4 Updates to mp4 atom extractor/parser for dtsx support. 2021-07-08 11:07:56 +01:00
kimvde
6e4508daec Improve support for Ogg truncated content
#minor-release

Issue:#7608
PiperOrigin-RevId: 382081687
2021-06-30 13:49:15 +01:00
aquilescanta
fc26d4eeb1 Remove the last deprecated ParserException constructor
PiperOrigin-RevId: 381221669
2021-06-30 13:27:45 +01:00
andrewlewis
7d05f20493 Signal container MIME type for JPEGs
Before this change the `Format` on the image track output by the
`JpegExtractor` doesn't have a MIME type.

PiperOrigin-RevId: 381015819
2021-06-30 13:19:00 +01:00
aquilescanta
81c542b6a7 Remove deprecated ParserException constructor
And replace it with factory method which includes more
context for error code assignment.

PiperOrigin-RevId: 380624625
2021-06-21 22:29:27 +01:00
olly
a3dbd61239 Remove obsolete Checker Framework suppression strings
More information: go/checker-3130-lsc

Tested:
    Some test failures are present, but the CL author has decided to mail the change anyway
PiperOrigin-RevId: 379622938
2021-06-21 21:56:37 +01:00
olly
4e8895d5cb Fix issue where a trun atom could be associated with the wrong track
Note that this removes a workaround for malformed content, in which the
track_ID is set incorrectly. It's unclear there was sufficient reason to
implement that workaround, and so it's preferable to remove it, rather
than implementing the concept of unrecognized tracks, which would be
needed to keep it and to also fix this issue.

Issue: #9056
#minor-release
PiperOrigin-RevId: 379506261
2021-06-15 18:45:21 +01:00
olly
3e819d082a Make javadoc valid html5
As of [JDK-8247957](https://bugs.openjdk.java.net/browse/JDK-8247957), doclint
no longer supports html4.

Tested:
    Some test failures are present, but the CL author has decided to mail the change anyway
PiperOrigin-RevId: 378819179
2021-06-11 12:23:35 +01:00
aquilescanta
b5dbadee0c Remove ParserException(cause) constructor
PiperOrigin-RevId: 378635295
2021-06-10 17:36:29 +01:00
olly
4b30cca914 Update @SuppressWarnings annotations for go/nullness diagnostics
in preparation for upgrading the version of the Checker Framework in google3.

More information: go/checker-3110-lsc

PiperOrigin-RevId: 377925828
2021-06-08 13:02:47 +01:00
bachinger
5700401ec1 Reformat README of extractors module
PiperOrigin-RevId: 377031562
2021-06-02 18:17:13 +01:00
bachinger
f40a92281b Add @DoNotInstrument annotations for extractors module
PiperOrigin-RevId: 377007386
2021-06-02 18:14:35 +01:00
aquilescanta
85e4137b81 Add test for ColorInfo in MP4
PiperOrigin-RevId: 375992816
2021-05-27 10:44:50 +01:00