3879 Commits

Author SHA1 Message Date
ibaker
b1cf04f22c Tweak comment in PgsDecoder to match the structure of the data
The Palette Definition Segment is documented here, you can is it goes:
luminance (y), red (cr), blue (cb), alpha

http://blog.thescorpius.com/index.php/2017/07/15/presentation-graphic-stream-sup-files-bluray-subtitle-format/

(I think it's important to be really precise here, because YCbCr is a
very common format, so this ordering is slightly unusual:
https://en.wikipedia.org/wiki/YCbCr)

PiperOrigin-RevId: 350747808
2021-01-08 15:33:31 +00:00
christosts
04250031bc Synchronize initialization of DefaultDownloadIndex
There is a race condition when initializing the downloads database. The
constructor of the DownloadManager kicks-off the database initialization
in its internal thread, but at the same time an app can try to access
the database directly through the manager's download index, e.g. doing

DonwloadManager manager = new ...
manager.getDownloadIndex().getDownload("id");

might enter DefaultDownloadIndex.ensureInitialized() from two threads.
When upgrading the downloads table from version 2 to version 3, the
first thread that enters the database transaction in ensureInitialized()
will drop and recreate the table using the v3 schema. Then, the second
thread will attempt to read from the newly created table using the v2
schema, which will fail.

This race condition was not introduced in 2.12 but was there already.
However, prior to 2.12, the code only dropped and re-created and the
table and did not attempt to read any data. Hence, if the race condition
happened, the code would drop and create the table twice, but no error
would occur.

Issue: #8420
#minor-release
PiperOrigin-RevId: 350745463
2021-01-08 15:33:21 +00:00
tonihei
2480e0a477 Add option to align durations of MergingMediaSource.
Without this feature it's impossible to nicely merge multiple sources
with different durations if these durations are not known exactly
before the start of playback.

Issue: #8422
PiperOrigin-RevId: 350567625
2021-01-08 15:32:37 +00:00
tonihei
c2d7fae535 Add preferred MIME type(s) to DefaultTrackSelector parameters.
This allows to set preferences based on MIME type for video and audio.
The MIME type preference is applied after other explicit preferences
and restrictions (e.g. language or max resolution), but before implicit
preferences like bitrate.

Issue: #8320
PiperOrigin-RevId: 350550543
2021-01-08 15:32:05 +00:00
krocard
6dec83238b Enable setOutputSurface workaround for Xiaomi Mi Box S
Reported by https://github.com/google/ExoPlayer/issues/8329.

PiperOrigin-RevId: 350547523
2021-01-08 15:31:43 +00:00
olly
a7cb6a02e4 Rollback of 1347d572ef
*** Original commit ***

Restore old SampleQueue exoMediaCryptoType behavior

***

PiperOrigin-RevId: 350545215
2021-01-08 15:31:32 +00:00
christosts
fc3b91c96c Add assertion in MediaCodec adapter
Add assertion to check an output format has been propagated before
returning an output buffer when operating MediaCodec in asynchronous
mode.

PiperOrigin-RevId: 350534918
2021-01-08 15:31:10 +00:00
andrewlewis
456622a275 Deprecate stop(boolean)
`stop(true)` is almost the same as `clearMediaItems(); stop();`, except that
any player error isn't cleared. Clearing media items more clearly expresses the
intent.

PiperOrigin-RevId: 350516748
2021-01-07 10:45:02 +00:00
olly
855db95fb3 Update surface frame-rate based on fixed frame-rate estimate
PiperOrigin-RevId: 350442843
2021-01-07 10:44:44 +00:00
tonihei
25ed6b127d Clarify parameter Javadoc for playback speed values.
In many cases we just used "playback speed" as a detailed Javadoc
parameter or return type definition. This doesn't define which scale
the speed is using.

PlaybackParameters as the main point to set the speed already uses a
more precise wording to describe the value as a factor by which playback
will be sped up.

This change replaces other usages of "playback speed" with this wording
whereever we would usually add a unit, keeping "playback speed" for
summary statements etc to reference the general concept that doesn't
usually require a unit.

PiperOrigin-RevId: 350379139
2021-01-07 10:44:34 +00:00
olly
d1d28a418d Propagate audio session ID to MediaCodecVideoRenderer
Issue: #8190
PiperOrigin-RevId: 350357825
2021-01-07 10:44:25 +00:00
tonihei
aa2beb080c Turn on parallel video and audio adaptation by default.
The experimental setting shows positive results and can be turned
on by default. To avoid adaptation between HLS audio formats without
bitrates, we need to ensure that only formats with bitrates are
considered for adaptation.

Also added tests for these features.

Issue: #5111
PiperOrigin-RevId: 350315296
2021-01-07 10:44:15 +00:00
christosts
51d90a40ba Keep pending output format after multiple flushes
The AsynchronousMediaCodecCallback has logic to retain a pending
output format in case flush() is called. This commit fixes a case where
calling flush() again while an output format is pending would nullify
the pending output format.

A unit test is added in AsynchronousMediaCodecCallback but not the
AsynchronousMediaCodecAdapter. That is because the adapter operates
directly on top of MediaCodec, but Robolectric's ShadowMediaCodec
produces an output format on every MediaCodec.start(). This is
unrealistic when operating MediaCodec in asynchronous mode where we
need to call MediaCodec.start() after every MediaCodec.flush().

PiperOrigin-RevId: 350176659
2021-01-07 10:44:05 +00:00
tonihei
a4fbc2c98d Clean up parallel adaptation code.
- The AdaptiveTrackSelection doesn't need to use the experimental
terminolgy because the code is always triggered if there are multiple
adaptive selections.

- It's also confusing to pass the state on the outside after the object
creation, so moving everything into a simple control flow again where
the adaptation checkpoints are passed in via the constructor.

- Instead of triple arrays, we can use more readable named structures.

- The calculation of the checkpoints can be cleaned up to be more
readable by moving things to helper methods.

- The reserved bandwidth from all fixed track selections is really just
a special case of multiple parallel adaptataions. So this logic doesn't
need to be separate.

- The whole logic also didn't have test coverage so far. Added tests
for the actual adaptation using these checkpoints and the builder
calculating the checkpoints.

Overall this should be a no-op change.

PiperOrigin-RevId: 350162834
2021-01-07 10:43:56 +00:00
olly
0901fe6e38 Remove internal renderer audio session ID propagation
Overriding this method will never be necessary or advisable once we
improve routing of audio session IDs

Issue: #8190
PiperOrigin-RevId: 350146302
2021-01-07 10:43:46 +00:00
Emanuele Tidó
75b222d8d4
Update DefaultHttpDataSource.java 2021-01-06 00:17:13 +00:00
Emanuele Tidó
654890846a
Update DefaultHttpDataSource.java
set responseBody to Util.EMPTY_BYTE_ARRAY when an IOException occurs trying to get his value from inputStream
2021-01-06 00:10:56 +00:00
olly
6d2d2e31ef Fix DownloadManager assertion failure
Issue: #8419
#minor-release
PiperOrigin-RevId: 350134719
2021-01-05 16:04:46 +00:00
andrewlewis
97d3e52340 Move XML parsing utils to common module
This is in preparation for using them from the extractor module.

PiperOrigin-RevId: 349571390
2021-01-05 11:59:58 +00:00
sneelavara
b534097d1c This pull request is for issue#1807. Refactoring the PR #8356
In this change -

Handling the sequence number discontinuity in caption channel packet header.

The processCurrentPacket returns if the packet length does not match with the currentIndex. That assumption is wrong. As per spec the the packet can end on reception of next cc_type = 0x3.
2020-12-30 17:35:44 -08:00
Emanuele Tidó
ee0d4a5b3e
Update DefaultHttpDataSource.java 2020-12-30 17:01:36 +00:00
Emanuele Tidó
625c46e963
throw InvalidResponseCodeException instead of HttpDataSourceException
if responseCode and responseMessage ara available always throws an InvalidResponseCodeException instead of HttpDataSourceException, so in onPlayerError method the http status code and message can be used to decide what will be the next step.
2020-12-30 16:50:04 +00:00
olly
1347d572ef Restore old SampleQueue exoMediaCryptoType behavior
PiperOrigin-RevId: 348818482
2020-12-23 22:54:07 +00:00
olly
3abdec17ca Some no-op cleanup to bypass mode
PiperOrigin-RevId: 348795995
2020-12-23 22:53:59 +00:00
olly
5f3d1c1bc8 Fix bypass mode when the stream is empty
#minor-release
Issue: #8374
PiperOrigin-RevId: 348792965
2020-12-23 22:53:50 +00:00
olly
e71ce06722 Add e2e test for playing SilenceMediaSource
PiperOrigin-RevId: 348789555
2020-12-23 22:53:41 +00:00
olly
d01093d711 Rollback of dd7b379dc0
*** Original commit ***

DataSource.open() throws if already opened.

Update DataSource implementations to throw an error if open() is called
when the DataSource is already open.

***

PiperOrigin-RevId: 348783425
2020-12-23 22:53:24 +00:00
ibaker
653d180d4c Add 302 redirect test to DefaultHttpDataSourceContractTest
PiperOrigin-RevId: 348760170
2020-12-23 22:53:15 +00:00
ibaker
f44e5bd292 Add a DefaultHttpDataSource contract test
Also add a MockWebServer Dispatcher that can be customised with
different resources and behaviours for different paths.

PiperOrigin-RevId: 348759662
2020-12-23 22:53:06 +00:00
bachinger
525f151f21 Check whether drm session manager of sample queue is null
PiperOrigin-RevId: 348688419
2020-12-23 22:52:48 +00:00
tonihei
c7af1e12de Fix nullness warnings.
These two things were reported by the nullness checker as warnings.

PiperOrigin-RevId: 348650535
2020-12-23 22:52:30 +00:00
christosts
dd7b379dc0 DataSource.open() throws if already opened.
Update DataSource implementations to throw an error if open() is called
when the DataSource is already open.

PiperOrigin-RevId: 348609860
2020-12-23 22:52:21 +00:00
tonihei
0226543090 Remove experimental method to disable stuck buffering detection.
PiperOrigin-RevId: 348462189
2020-12-23 22:52:12 +00:00
olly
85d094a2b6 Move surface frame-rate adjustment into the helper
Estimating the playback frame-rate, querying the display refresh rate, and
setting the surface frame-rate, are all closely related to one another. In
particular because setting the surface frame-rate can directly cause the
display refresh rate to change. It therefore makes sense to move surface
frame-rate adjustment into the helper.

This also makes it easier to re-use the logic in other video renderers.

PiperOrigin-RevId: 348455864
2020-12-23 22:52:04 +00:00
ibaker
df0b74e4c4 DataSourceContractTest: Add tests for reading subranges
PiperOrigin-RevId: 348443305
2020-12-23 22:51:29 +00:00
bachinger
04824dfd25 Make DefaultHttpDataSourceFactory an inner class of the built class
#exofixit

PiperOrigin-RevId: 348441436
2020-12-23 22:51:20 +00:00
Oliver Woodman
5e47c3c5e5 Merge pull request #8357 from TiVo:p-fix-cea708anchor
PiperOrigin-RevId: 348440799
2020-12-23 22:51:10 +00:00
tonihei
30ee29df1a Use real SampleQueue in FakeSampleStream.
This replaces all the duplicated logic previously implemented in
FakeSampleStream and more closely follows the pattern of how
SampleStreams are used from real MediaPeriods.

Some tests needed adjustments because using real the SampleQueue
improved behaviour:
 - Waiting for isLoading is only needed once even across period
   boundaries because the real SampleQueue doesn't have the on/off
   pattern.
 - AnalyticsCollectorTest.playlistOperations() was wrongly asserting
   that some pre-buffering events. The new version is more intuitively
   correct we pre-buffer the second item during the initial loading
   phase (thus period1seq1) and keep the buffer in the queue after
   the removal operation.

PiperOrigin-RevId: 348440255
2020-12-23 22:51:00 +00:00
ibaker
1327ecad24 Use CapturingRenderersFactory in Vp9PlaybackTest
PiperOrigin-RevId: 348017841
2020-12-23 22:50:25 +00:00
ibaker
27e290e701 Use CapturingRenderersFactory in TsPlaybackTest
PiperOrigin-RevId: 348017268
2020-12-23 22:50:16 +00:00
krocard
8fb15f97ca Explicitly fail playback if new format has no sampleMimeType
This avoids a NullPointerException later when the format is used.

Fixes https://github.com/google/ExoPlayer/issues/8283.

PiperOrigin-RevId: 348017149
2020-12-23 22:50:07 +00:00
ibaker
fe5176c009 Use CapturingRenderersFactory in OggPlaybackTest
PiperOrigin-RevId: 348016819
2020-12-23 22:49:58 +00:00
ibaker
6a89027f56 Use CapturingRenderersFactory in Mp3PlaybackTest
PiperOrigin-RevId: 348016339
2020-12-23 22:49:49 +00:00
ibaker
56d30205ba Use CapturingRenderersFactory in MkvPlaybackTest
PiperOrigin-RevId: 348015859
2020-12-23 22:49:40 +00:00
ibaker
237766548c Use CapturingRenderersFactory in MkaPlaybackTest
PiperOrigin-RevId: 348015304
2020-12-23 22:49:32 +00:00
ibaker
5bfa818533 Use CapturingRenderersFactory in FlvPlaybackTest
PiperOrigin-RevId: 348014814
2020-12-23 22:49:23 +00:00
ibaker
3bf5e6b0e4 Use CapturingRenderersFactory in FlacPlaybackTest
PiperOrigin-RevId: 348014322
2020-12-23 22:49:14 +00:00
christosts
6b43f1566f Reduce length of test data in UdpDataSourceContractTest
PiperOrigin-RevId: 348011243
2020-12-23 22:49:05 +00:00
ibaker
9d2855c31f Add @Test to overridden test in UdpDataSourceContractTest
With @Ignore but not @Test the method is still executed by JUnit:
https://github.com/junit-team/junit4/issues/695

PiperOrigin-RevId: 348009981
2020-12-23 22:48:56 +00:00
ibaker
7027e75ce8 DataSourceContractTest: Check an unbounded subrange is read correctly
PiperOrigin-RevId: 347994829
2020-12-23 22:48:29 +00:00