3914 Commits

Author SHA1 Message Date
christosts
d9e0b91be7 Remove deprecated Player.setAudioAttributes()
PiperOrigin-RevId: 351800287
2021-01-15 10:57:17 +00:00
christosts
a1bb89d90d Remove DefaultAnalyticsListener
PiperOrigin-RevId: 351782634
2021-01-15 10:57:07 +00:00
christosts
eb71d730cb Remove SingleSampleMediaSource.EventListener and constructors
They have been deprecated since r2.7.0

PiperOrigin-RevId: 351777769
2021-01-15 10:56:57 +00:00
olly
8045c62d09 Fully document ExoMediaDrm
PiperOrigin-RevId: 351771497
2021-01-15 10:56:37 +00:00
tonihei
3c4a976a41 Clean up subclassing behaviour of AnalyticsCollector.
AnalyticsCollector is allowed to be subclassed to simplify adding
new events that make use of the EventTime generation.

Clean up the subclassing interface to simplify this:
 - Make generateCurrentPlayerMediaPeriodEventTime protected. This is
   arguably the most useful method for extended clients. Other
   generateXXXEventTime methods are left private as they can't be
   useful for extensions because they require some integration into
   the ExoPlayer playback thread to make sense. So keeping them
   private to cause less confusion.
 - Some existing callback handling should be final as all the others.
 - Adding @CallSuper to all lifecycle management methods that might
   be helpful to subclasses but require to call the super method.
 - Make sendEvent protected to let subclasses use the simple
   event sending method.

PiperOrigin-RevId: 351766369
2021-01-15 10:56:27 +00:00
krocard
789a211d53 Remove VideoDecoderOutputBufferRenderer from Player interface
The VideoDecoderOutputBufferRenderer will be set
automatically when setVideoSurfaceView is called on a
VideoDecoderGLSurfaceView.

#player-to-common

PiperOrigin-RevId: 351742601
2021-01-15 10:55:56 +00:00
olly
6084a552a9 Rename AnalyticsListener.onAudioSessionId for consistency
PiperOrigin-RevId: 351687086
2021-01-15 10:55:46 +00:00
olly
adb9dcb43f Add KeyRequest.getRequestType
Issue: #7847
PiperOrigin-RevId: 351661084
2021-01-15 10:55:36 +00:00
christosts
b5a319dc4e Remove deprecated methods from SimpleExoPlayer
Remove SimpleExoPlayer methods:
- setTextOutput
- clearTextOutput
- setMetadataOutput
- clearMetadataOutput

The methods were deprecated in r2.6.0.

PiperOrigin-RevId: 351611289
2021-01-15 10:55:26 +00:00
olly
9198dd6f5a Update AudioListener to reflect new audio session ID logic
PiperOrigin-RevId: 351597144
2021-01-15 10:55:16 +00:00
andrewlewis
d5124e8cdc Add presentation time to motion photo metadata
PiperOrigin-RevId: 351581997
2021-01-15 10:54:56 +00:00
claincly
421aa9df40 Added a test-only method to clear the clearDecoderInfosCache.
The cache, being static, is updated every time a new MimeType is encountered.
The static cache needs to be cleared between tests that register codecs through
ShadowMediaCodec, or the subsequent tests could possibly pick up a wrong codec.

PiperOrigin-RevId: 351576018
2021-01-15 10:54:45 +00:00
christosts
bdc2a4e3af Remove deprecated methods from SimpleExoPlayer
Remove methods:
- SimpleExoPlayer.setPlaybackParams, deprecated since r2.4.0.
- SimpleExoPlayer.setAudioStreamType, deprecated since r2.5.0.
- SimpleExoPlayer.getAudioStreamType, deprecated since r2.5.0.

PiperOrigin-RevId: 351570070
2021-01-15 10:54:34 +00:00
Zen Xu
3854a97062 Fix VP9 on Android L and M by advertising profile level 2021-01-14 23:56:52 -08:00
christosts
dde0b9b614 Remove setVideoDebugListener and setAudioDebugListener
PiperOrigin-RevId: 351565147
2021-01-13 13:52:20 +00:00
aquilescanta
03ebc5b52f Move readPosition modification out of readSampleMetadata
Preparation CL for SampleQueue.peek.

PiperOrigin-RevId: 351439887
2021-01-13 00:04:23 +00:00
olly
69423bc2b4 Remove deprecated MappingTrackSelector methods
PiperOrigin-RevId: 351400274
2021-01-13 00:04:15 +00:00
christosts
a9cdb4ca06 Remove deprecated methods from SimpleExoPlayer
PiperOrigin-RevId: 351375479
2021-01-13 00:03:58 +00:00
christosts
969b6468d9 Remove deprecated method from DefaultEventListener
PiperOrigin-RevId: 351367833
2021-01-13 00:03:49 +00:00
olly
89b33ac9c0 Remove deprecated DefaultLoadControl constructors
PiperOrigin-RevId: 351361628
2021-01-13 00:03:33 +00:00
olly
500b4f89a8 Remove deprecated ExtractorMediaSource.createMediaSource method
A previous release note has already noted to use ProgressiveMediaSource
instead of this whole class, so adding a specific release note seems
unnecessary for this one.

PiperOrigin-RevId: 351353979
2021-01-13 00:03:24 +00:00
olly
a95b2ebb1d Fix audio session ID generation
- SimpleExoPlayer now always generates a session ID at
  construction time. This ID is used indefinitely, including
  for tunneling, unless a call to setAudioSessionId is made
  to change it.
- DefaultTrackSelector support for enabling tunneling has
  been changed to a boolean, since tunneling now uses the
  same session ID as non-tunneled mode.
- Since the session ID is now always set at the top level,
  internal propagation of generated session IDs is no longer
  necessary, and so is removed.

PiperOrigin-RevId: 351349687
2021-01-13 00:03:16 +00:00
christosts
85641a38b1 Remove AdaptiveMediaSourceEventListener
AdaptiveMediaSourceEventListener was deprecated in r2.6.1.

PiperOrigin-RevId: 351344147
2021-01-13 00:03:06 +00:00
tonihei
a0460c3bd7 Remove ExoPlaybackException.TYPE_TIMEOUT.
The ExoPlaybackException types are locations from where the exception
is coming from and not the type of exception itself, which should be
denoted by different exception classes.

To avoid a mixture of error types and class checks, the timeout
exceptions should use their own class and be of type RENDERER as this
is where the timeout actually happens.

PiperOrigin-RevId: 351337699
2021-01-13 00:02:58 +00:00
tonihei
d640cedab8 Forward live playback speed changes to track selections and renderers.
This allows the respective components to adapt to the speed changes
if desired.

To avoid frequent updates to the media codec operating rate, we also
forward the target speed to the renderers so that this value can be set
based on the target speed and not the current speed.

PiperOrigin-RevId: 351336401
2021-01-13 00:02:49 +00:00
tonihei
c63f3d92ba Remove ExoPlaybackException.TYPE_OUT_OF_MEMORY
Catching OOM errors is bad practise unless there is a specific known
cause that tried to allocate a large amount of memory. Without this
known cause with a large allocation, the source of the error is
likely somewhere else in the app and every random small further
allocation may lead to additional OOM errors (for example b/145134199).

We have three known causes in ExoPlayer:
 1. Source allocations based on unexpected values in streams. This is
    caught on the loader thread and reported as an
    UnexpectedLoaderException.
 2. Output buffer allocations by non-MediaCodec decoders. These are
    caught in SimpleDecoder on the decoder thread and reported as
    UnexpectedDecodeException.
 3. Input buffer allocations by non-MediaCodc decoders in their
    constructors. These are currently caught on a higher-level and
    reported as ExoPlaybackException.TYPE_OUT_OF_MEMORY.

For consistency and to prevent catching OOM errors without known cause
we can remove the generic TYPE_OUT_OF_MEMORY and catch the specific
exception where it occurs to report it as an
ExoPlaybackException.TYPE_RENDERER. This also has the added advantage
that the format metadata is added to the exception.

PiperOrigin-RevId: 351326688
2021-01-13 00:02:39 +00:00
olly
01b9ae6325 DownloadManagerTest: Address remaining flakiness
#minor-release

PiperOrigin-RevId: 351158541
2021-01-11 18:05:54 +00:00
aquilescanta
09c49f3ca8 Simplify comment
#minor-release

PiperOrigin-RevId: 351144857
2021-01-11 18:05:44 +00:00
ibaker
01ae2b047f Remove expectedResolvedLength from DataSourceContractTest
Whether a resource resolves to a known length or not is more than just
a property of the resource & data source - for example if
`DataSpec.flags` contains `ALLOW_GZIP` then the length might be
unresolved. More generally, a `DataSource` could randomly return
`C.UNKNOWN_LENGTH` from `open()` 50% of the time and still fulfil the
`DataSource` interface. This makes it ~impossible to write a meaningful
assertion aroun this.

So this change relaxes the assertion slightly to more closely match the
definition of the `DataSource` interface.

We leave the `resolveToUnknownLength` toggle in
`WebServerDispatcher.Resource` because this is still useful for
simulating the case of a server that is serving a file it doesn't
know the length of.

PiperOrigin-RevId: 351124246
2021-01-11 18:05:24 +00:00
ibaker
361e80f40c Fix usage of ParsableByteArray in PgsDecoder
This is a partial revert of
46598a46fd

The change from reset(int) to setPosition/Limit() in this file was
incorrect, the reset(int) call is important because it ensures
`bitmapData` is large enough for the `buffer.readBytes` call on L188.

Issue: #8417
PiperOrigin-RevId: 351110038
2021-01-11 18:05:04 +00:00
olly
2a5f6d8f62 Improve user-agent configuration
- Support setting the user-agent in CronetDataSource
- Support setting the default user-agent in CronetEngineWrapper
- Use the underlying network stack's default user-agent by
  default. Many applications will configure the underlying
  CronetEngine or OkHttpClient with a user-agent that they
  expect to be used throughout their app, so always overriding
  this with our own default, on reflection, is not the best
  thing to do!

Issue: #8395
PiperOrigin-RevId: 350921963
2021-01-11 18:04:43 +00:00
olly
7e295cbfc9 Simplify bypass buffer batching
BatchBuffer has three different clear methods (clear, flush,
batchWasConsumed), and it's not hugely clear what each of them
does. In general, BatchBuffer owning the sample buffer seems
more complicated than having the caller own it, particularly
when it can be "pending" inside of the batch buffer.

This change moves ownership of the sample buffer to the
caller. BatchBuffer is simplified as a result. There are also
two behaviour changes:

1. The buffer's timeUs field is now set to the first sample's
   timestamp, rather than the last sample's.
2. A key-frame in the middle of the batch no longer causes the
   batch buffer to be considered a key-frame. Which seems like
   the right thing to do, because the batched data cannot be
   decoded independently of whatever came before it.

PiperOrigin-RevId: 350921306
2021-01-11 18:04:33 +00:00
Oliver Woodman
953e4e89e2 Merge pull request #8414 from tidoemanuele:tidoemanuele-improve-non-2xx-message
PiperOrigin-RevId: 350797551
2021-01-08 19:09:15 +00:00
olly
c1529c46d8 Fix flaky DownloadManager test
#minor-release

PiperOrigin-RevId: 350782940
2021-01-08 17:55:34 +00:00
ibaker
06942116bd Propagate LoadErrorHandlingPolicy to SingleSampleMediaSource.Factory
I think this was missed when integrating DefaultMediaSourceFactory with
SingleSampleMediaSource.Factory in
315ba6f324

Issue: #8430
#minor-release
PiperOrigin-RevId: 350759580
2021-01-08 15:33:43 +00:00
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