279 Commits

Author SHA1 Message Date
tonihei
1a12018dae Add ConcatenatingMediaSource version that fully combines windows.
The published Timeline contains one window only with all periods of
the child sources.

Issue: #4868
PiperOrigin-RevId: 358150276
2021-02-19 10:58:05 +00:00
gyumin
dea6a67ce9 Remove nullable utility methods in Bundleable
PiperOrigin-RevId: 357845774
2021-02-19 10:57:32 +00:00
gyumin
2326b56132 Implement Bundleable for MediaItem and MediaMetadata
PiperOrigin-RevId: 357656504
2021-02-19 10:56:52 +00:00
olly
7f5b5c9b6d Add static TrackSelection type
This type is different to the selection reason, which is
dynamic (i.e., corresponds to the individual selected track,
which can change during playback). The static type is
exposed via TrackSelection, where-as the selection reason
will be internal to the core (i.e., player) module.

PiperOrigin-RevId: 357578201
2021-02-19 10:56:27 +00:00
olly
1b6dd40aa5 Move Spherical UI components to the UI module
PiperOrigin-RevId: 357549002
2021-02-19 10:55:46 +00:00
gyumin
6a642ec58b Generalize exception thrown by fromBundle
It allows Bundleable classes throw a RuntimeException which is broader
than IAE. Now, Bundleable implementation may utilize checkNotNull for
brevity.

PiperOrigin-RevId: 357546375
2021-02-19 10:55:37 +00:00
kimvde
842ca9c09f Add method to query whether a command is available
- Other commands will be added later.
- The returned value is a boolean until we decide what it should be.

PiperOrigin-RevId: 357535877
2021-02-19 10:55:20 +00:00
gyumin
c7751344d4 Use compact String keys for Bundleable
To save bytes in serialized format, it uses shorter keys in Bundles.

PiperOrigin-RevId: 357492840
2021-02-19 10:55:11 +00:00
olly
18722bfb0b Bump version to 2.13.1
PiperOrigin-RevId: 357219132
2021-02-12 19:55:57 +00:00
aquilescanta
f8505204cc Move MediaFormatUtil into common
Also move out of the mediacodec package into the util package.

PiperOrigin-RevId: 356949401
2021-02-12 16:39:28 +00:00
olly
493d996c6f Move RepeatModeUtil to common
It's used by the UI and mediasession modules. We may be able to move
it into the UI module if/when the mediasession module goes away.

PiperOrigin-RevId: 356734939
2021-02-11 12:06:02 +00:00
gyumin
753bccec1f Implement Bundleable for media2 MediaItem and related classes
PiperOrigin-RevId: 356622155
2021-02-11 12:05:18 +00:00
andrewlewis
e28332ff82 Add common prefix to loader thread names
All threads created by ExoPlayer should now have the prefix "ExoPlayer:".

PiperOrigin-RevId: 356518037
2021-02-11 12:05:06 +00:00
olly
50db2ee172 Remove deprecated Player.DefaultEventListener
PiperOrigin-RevId: 356479682
2021-02-09 14:00:06 +00:00
olly
94a4b905c9 Make additional modules depend only on common
ControlDispatcher and DefaultControlDispatcher also need
to move to common for the UI module. As does PlaybackPreparer,
although that will be removed entirely in a future release.

PiperOrigin-RevId: 356467394
2021-02-09 13:59:41 +00:00
andrewlewis
846bb94ec4 Handle loading the same ad more than once
Also allow the player's prepared ad media period durations array to exceed the
length of the loaded ad URIs array, as it's possible for the player to buffer
an ad media period fully at the point where it's known that an ad is coming up
but its URI is still unknown.

#minor-release

PiperOrigin-RevId: 356249284
2021-02-09 13:59:24 +00:00
tonihei
91c2f891a0 Ensure BandwidthProfileDataSource loading is fully deterministic
We currently block the loading thread until the calculated load
time has past and then unblock again by a message sent from the
playback thread. However, because the loading thread itself is not
using a Looper and runs freely, we don't control when the short
calculations on the loader thread that determine how long we have
to wait are happening, and we also don't control how long it takes
to start and stop this thread.

To solve these problems and to make the playback deterministic we
can
 1. Send a message on the playback thread to block until the loader
    thread has started.
 2. Block the playback thread whenever a loading thread is doing its
    short calculation of wait times. The playback thread knows when it
    can continue because loading either enter a new waiting state for
    a simulated load time or loading is finished completely.
 3. Also wait on the playback thread until the loader has shut down.
    As this is waiting for a message on the playback thread, we can
    achieve this by sending messages to ourselves at the current time
    until the loader is shut down.
All 3 steps together ensure that the loading thread interaction is
compeltely deterministic when simulating bandwidth profiles with the
BandwidthProfileDataSource. As we need to notify the source before and
after the load started/finished, we also need a small wrapper for the
chunk source when running the playback.

PiperOrigin-RevId: 355810408
2021-02-09 13:58:42 +00:00
olly
5107fea576 More clearly define the semantics of error recovery
- When throwing a recoverable error from a renderer, it's important to understand
  exactly how the player will attempt recovery. Clarify the documentation to
  make this explicit.
- Rename some methods/constants to make it clear that error recovery is specific
  to renderer errors. The current recovery mechanism only makes sense for
  renderer errors. Making the naming renderer specific avoids reader doubt that
  the implementation doesn't appear to be generic enough for other types of
  errors.

PiperOrigin-RevId: 355650945
2021-02-04 18:14:26 +00:00
gyumin
d72d25470d Add Bundleable interface
It's for classes to clearly denote they support bundling and it gives
us a good place to document the best practice to implement fromBundle.

PiperOrigin-RevId: 355609942
2021-02-04 16:17:24 +00:00
kimvde
35d34af2e9 Fall back to AVC/HEVC for Dolby Vision levels 10-13
Before, the level was set to null in this case.
MediaCodecUtil.getCodecProfileAndLevel() was therefore returning null
and the fallback to AVC/HEVC was not enabled in MediaCodecVideoRenderer.

Issue:#8530
#minor-release
PiperOrigin-RevId: 355574499
2021-02-04 09:57:46 +00:00
olly
1bf53bfabc Refine ProGuard config workaround for Function
This is a more targeted workaround, which still allows for the
containing package name to be obfuscated.

#minor-release

PiperOrigin-RevId: 355381201
2021-02-03 15:03:07 +00:00
olly
b1920f3a78 Fix ProGuard configuration for 2.13
Note: We only support pro-guard on a best effort basis,
and developers should use R8 whenever possible.

#minor-release

PiperOrigin-RevId: 355129695
2021-02-02 13:06:52 +00:00
olly
35b99d634f Make Cronet extension depend only on common
This also moves DefaultHttpDataSource to common, which seems
sensible, else non-player components that need a DataSource
don't have any useful concrete implementations. We should
think about moving some of the other concrete implementations
to common as well.

PiperOrigin-RevId: 354738925
2021-02-01 18:11:23 +00:00
tonihei
2e52c0b8d8 Make FakeClock fully deterministic.
This is achieved by only triggering one message at a time. After
triggering a message we send another to ourselves to know when the
following message can be triggered.

Other required changes:
 - The messages need to be sorted correctly (by time and creation order)
 - To prevent deadlocks when one thread is waiting for another,
   we need to add new method to Clock to indicate that the current
   thread is about to wait. This then allows us to trigger messages
   from other threads in FakeClock.
 - AnalyticsCollectorTest needed some adjustments:
   - onTimelineChanged now deterministically arrives after the initial
     timline is already known, so some of the period information changes
     from window only to full period info.
   - The playlistOperations test suffers from a bug that the first frame
     is rendered too early and that's why we now get additional events.

PiperOrigin-RevId: 353877832
2021-01-26 17:13:35 +00:00
tonihei
89ea38d155 Handle all messages in FakeClock.
Currently only delayed messages are handled. Change this to handling
all messages so that we have more control over their execution order.

This requires adding a new wrapper type for the Message to support
the obtainMessage + sendToTarget use case.

PiperOrigin-RevId: 353876557
2021-01-26 17:13:15 +00:00
tonihei
06fe0900a9 Remove FakeClock.sleep.
This functionality isn't used and there is no point in supporting
it.

PiperOrigin-RevId: 353876038
2021-01-26 17:13:03 +00:00
gyumin
3e8e3737d6 Add toBundle/fromBundle to AudioAttributes and DeviceInfo
PiperOrigin-RevId: 353864181
2021-01-26 15:59:32 +00:00
ibaker
724ded167c Bump version to 2.13.0
PiperOrigin-RevId: 353655249
2021-01-25 17:38:56 +00:00
olly
3fcc14b3c2 OkHttp/Rtmp extensions: Remove dependency on core
They only require common. This allows their use for non-playback networking
without requiring the user to depend on the whole of core. I will also make
the same change for Cronet, although this needs a little more work.

PiperOrigin-RevId: 353649388
2021-01-25 17:38:36 +00:00
krocard
b0258e7192 Move Player in common
This is the last CL to move Player in common.

#player-to-common

PiperOrigin-RevId: 353642347
2021-01-25 15:37:48 +00:00
olly
dc7fde1ff7 Some more language fixes
Issue: #7565
PiperOrigin-RevId: 353613493
2021-01-25 15:36:59 +00:00
olly
9825e5f9d7 Move some utility classes to common
These are used by the cast extension, so will need moving eventually!

PiperOrigin-RevId: 353219703
2021-01-22 16:22:18 +00:00
olly
4791900848 Move Player.getTrackSelector to ExoPlayer
PiperOrigin-RevId: 353212567
2021-01-22 16:22:09 +00:00
krocard
a10e9de484 Check that cache dir exist
Not checking it would force ExoPlayer to use the
global tmp dir which would expose it to
external file replacement attacks.

This is a theoretical vulnerability as this code is
only use in tests and cache dir always exist in the
AOSP android implementation.

PiperOrigin-RevId: 353013929
2021-01-22 16:21:35 +00:00
krocard
efcaee563a Move TrackGroup and TrackGroupArray in common
This is a dependency of TrackSelection and Player.

#player-to-common

PiperOrigin-RevId: 353004379
2021-01-22 16:21:10 +00:00
ibaker
3069251bd0 Add gzip support to WebServerDispatcher
Add a test to DataSourceContractTest that asserts the gzip flag is
either ignored or handled correctly.

Add a test resource to DefaultHttpDataSourceContracTest that enables
gzip compression on the 'server' and checks it's handled correctly by
the client.

PiperOrigin-RevId: 352574359
2021-01-19 19:23:57 +00:00
andrewlewis
60f000c8b1 Remove incorrect TODOs
PiperOrigin-RevId: 352552961
2021-01-19 19:23:23 +00:00
ibaker
fc952bfba2 Annotate log methods with @Pure
PiperOrigin-RevId: 352519583
2021-01-19 19:22:47 +00:00
samrobinson
1be4960464 Implement a segment based speed provider and interface.
PiperOrigin-RevId: 352401836
2021-01-18 22:00:19 +00:00
samrobinson
dedf60713d Enforce stricter SlowMotionData and Segment initialisation checks.
PiperOrigin-RevId: 352389366
2021-01-18 22:00:11 +00:00
olly
464f53373a Remove deprecated debug listener methods from SimpleExoPlayer
- Once the ability to add debug listeners is removed, analyticsCollector
  is the only component that needs to receive the events. Hence it is
  called directly.
- It seemed less confusing to do the same thing for (non-debug) video and
  audio events, and to have AnalyticsCollector no longer implement
  VideoListener and AudioListener directly. This clears up confusion that
  arises as a result of the debug and non-debug interfaces defining the
  same methods in some cases, and having to be careful not to end up
  calling the corresponding AnalyticsCollector method twice.

PiperOrigin-RevId: 351835491
2021-01-15 10:57:47 +00:00
kimvde
4c3f580b0c Rollback of 7d847a9552
*** Original commit ***

Handle sample size mismatch in MP4 extractors

#minor-release

***

PiperOrigin-RevId: 351774860
2021-01-15 10:56:47 +00:00
olly
8045c62d09 Fully document ExoMediaDrm
PiperOrigin-RevId: 351771497
2021-01-15 10:56:37 +00:00
kimvde
7d847a9552 Handle sample size mismatch in MP4 extractors
#minor-release

PiperOrigin-RevId: 351756333
2021-01-15 10:56:17 +00:00
andrewlewis
9b062053fa Add support for JPEG motion photo extraction
PiperOrigin-RevId: 351752989
2021-01-15 10:56:07 +00:00
olly
9198dd6f5a Update AudioListener to reflect new audio session ID logic
PiperOrigin-RevId: 351597144
2021-01-15 10:55:16 +00:00
christosts
73114e3987 Remove deprecated method DrmInitData.get(UUID)
PiperOrigin-RevId: 351589689
2021-01-15 10:55:06 +00:00
andrewlewis
d5124e8cdc Add presentation time to motion photo metadata
PiperOrigin-RevId: 351581997
2021-01-15 10:54:56 +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
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