5756 Commits

Author SHA1 Message Date
Oliver Woodman
750396c90f Merge pull request #7153 from friederbluemle:fix-gradle-ext
PiperOrigin-RevId: 303319078
2020-03-27 23:32:48 +00:00
tonihei
c4a93b6420 Simplify/avoid usages of onSeekProcessed in ExoPlayer code.
This callback will be deprecated, so moving all usages to better callbacks.
Some usages are still remaining that are less straight-forward to update.

PiperOrigin-RevId: 303298834
2020-03-27 23:32:20 +00:00
tonihei
af05ceac61 Call onSeekProcessed immediately after seek command.
OnSeekProcessed is documented to be called as soon as all neccessary state changes
as a result of the seek have been made. As we now mask the state changes directly
when calling seekTo, we can also call this callback immediately without changing
the semantics of the method.

Our tests often use this callback as a way to wait for the internal player
to receive all pending commands and then report back. This is a special test
requirement for cases where we want to make sure no further updates happen as
a result of the player handling commands. To facilitate that, a new action is
added with a more descriptive name that achieves the same goal.

PiperOrigin-RevId: 303296210
2020-03-27 23:32:03 +00:00
bachinger
25d9f76a07 deprecate createMediaSource with uri argument
PiperOrigin-RevId: 303217607
2020-03-27 23:31:37 +00:00
ibaker
2842eb3eb4 Make milliseconds optional in SubRip (SRT) subtitles
issue:#7122
PiperOrigin-RevId: 303154493
2020-03-27 23:31:21 +00:00
ibaker
47d5dd911c Document ExoMediaDrm listener methods as optional
Also document FrameworkMediaDrm overrides as dependent on API level.

These two methods call through to equivalent methods on MediaDrm that
were added in 23:
https://developer.android.com/reference/android/media/MediaDrm#setOnExpirationUpdateListener(java.util.concurrent.Executor,%20android.media.MediaDrm.OnExpirationUpdateListener)

PiperOrigin-RevId: 303102370
2020-03-27 23:31:12 +00:00
bachinger
d0fc83ed8a Playlist API: move media item based API to Player
This moves the playlist API methods to the Player interface. Implementation is moved from ExoPlayerImpl to BasePlayer where possible.

Further the CastPlayer is changed to implement the Player interface. Proper migration of the Playermanager to not use the ConcatenatingMediaSource anymore follows in a separate, future CL.

PiperOrigin-RevId: 302937779
2020-03-27 23:30:46 +00:00
ibaker
4ff04696c4 Remove unneeded unchecked warning suppressions
Most of these are no longer needed since aa9eb5abc9

Cleanup change automatically generated by error-prone refactoring
//java/com/google/devtools/staticanalysis/errorprone:UnnecessaryJavacSuppressWarnings_refactoring on targets third_party/java_src/android_libs/exoplayer/v2/... java/com/google/android/libraries/exoplayer/v2/...

PiperOrigin-RevId: 302916092
2020-03-27 23:30:37 +00:00
ibaker
92494ce44b Document that overlapping spans aren't rendered to HTML correctly
Add some mitigation about why this is probably on OK limitation.

PiperOrigin-RevId: 302907940
2020-03-27 23:30:28 +00:00
Frieder Bluemle
d24f37cdd7
Check if exoplayerModulePrefix is set 2020-03-27 00:53:01 -07:00
olly
2555fb36b4 Resample float audio to 16-bit by default to enable audio processing
This is less confusing than having audio processing functionality (e.g., playback
speed adjustment) just "not work" for some pieces of media.

If this change is merged, I will update #6749 to also track making DefaultAudioSink
intelligently enable/disable float output depending on how the audio processors are
configured.

Issue: #7134
PiperOrigin-RevId: 302871568
2020-03-25 13:06:17 +00:00
tonihei
46a10ec01a Fix some EventListener logic in ExoPlayerImpl
We currently have multiple places in ExoPlayerImpl that assign PlaybackInfo
instances and then inform listeners of all current changes. This is not ideal
because it causes multiple issues:
 1. Some changes may easily be forgotten, e.g. there are clearly some checks
    missing to see if isPlaying changed (e.g. in seekTo or setMediaSources)
 2. Some callbacks didn't check if the value actually changed before sending
    the callback (e.g. for the timeline change in setMediaSources - if the
    timeline is still the same, we shouldn't send a onTimelineChanged event).
 3. Having multiple callbacks in a single Runnable changes the order of
    listener invocations slightly: Currently all events for one listener will
    be send first before moving to the next listener. It should however send
    a single event to all listeners first before moving to the next event.

All these issues can be solved by always using updatePlaybackInfo and never
assigning playbackInfo directly in another place.

Some tests needed to be updated as well because of issues (2) and (3). Also
added a new test to cover issue (1).

PiperOrigin-RevId: 302844981
2020-03-25 13:05:59 +00:00
olly
3a6a037520 DefaultAudioSink: Fix issue if last processor is not active
It's incorrect to use an AudioFormat returned from AudioProcessor.configure
unless the AudioProcessor is active.

Issue: #7134
PiperOrigin-RevId: 302674132
2020-03-25 13:05:32 +00:00
olly
9ed471651e Support 32-bit FP to 16-bit Int audio resampling
This is a no-op for DefaultAudioSink for now, because DefaultAudioSink
currently disables processing anyway if the input uses ENCODING_PCM_FLOAT.

Issue: #7134
PiperOrigin-RevId: 302670534
2020-03-25 13:05:23 +00:00
olly
05fb211121 WAV: Don't read past data end position
Issue: #7129
PiperOrigin-RevId: 302660343
2020-03-25 13:05:14 +00:00
olly
134df9fb71 Add common prefix to thread names
PiperOrigin-RevId: 302659142
2020-03-25 13:05:05 +00:00
tonihei
d47ceae165 Add some missing TAG values to ExoPlayerTest
PiperOrigin-RevId: 302646400
2020-03-25 13:04:55 +00:00
tonihei
aa987fdb79 Add state masking for seeking.
The playback state will be immediately set to the most likely final state.

PiperOrigin-RevId: 302645852
2020-03-25 13:04:45 +00:00
olly
4e5b2c692f Exclude transitive dependency on core for androidTest
androidTest of core already has the dependency on its main. Without this
exclude, gradle complains about type duplication when merging dex saying
"Type X is defined multiple times".

PiperOrigin-RevId: 302641585
2020-03-25 13:04:35 +00:00
olly
eebe990d20 MP4 edit lists: Use floor rather than ceil to find first sample
If the start time of the edit falls within a sample, start from that
sample rather than the next one. This ensures playback can start from
the correct point if the sample is a keyframe, rather than having to
start from the next one.

Issue: #7133
PiperOrigin-RevId: 302639115
2020-03-25 13:04:23 +00:00
ibaker
2cbf98bb68 Suppress 'unused' warning on largeBuffer local in ExoPlayerTest
PiperOrigin-RevId: 302474924
2020-03-25 13:04:03 +00:00
ibaker
0c20462b48 Allow missing hours in SubRip (.srt) subtitle timecodes
Add a test for this case, and extend the existing tests to ensure the
hour is parsed when it's present.

issue:#7122
PiperOrigin-RevId: 302472213
2020-03-25 13:03:52 +00:00
olly
dc33c0bdfb Improve logging II
- Show renderers with no tracks in EventLogger track logging
- Log renderer names in EventLogger track logging
- Add useful message to ExoPlaybackException instances (including
  renderer name for renderer errors)

PiperOrigin-RevId: 302421616
2020-03-25 13:03:12 +00:00
ibaker
adae53c787 Use MediaSourceEventDispatcher in DefaultDrmSession(Manager)
Remove add/removeEventListener methods & associated listener plumbing.

Part of issue:#6765

PiperOrigin-RevId: 302411347
2020-03-25 13:03:03 +00:00
krocard
1fa9dbc31e Conserve ByteOrder when growingDecoderInputBuffer
#exo-offload

PiperOrigin-RevId: 302403507
2020-03-25 13:02:53 +00:00
tonihei
d38c6c84a6 Fix bug in MaskingMediaSource caused by removed periods.
If MaskingMediaSource masks a multi-window media source, it may be that a period
is removed while we are using an initial unprepared masking MediaPeriod. That
means it's not guaranteed that a timeline update still contains our
unpreparedMaskingMediaPeriod and we should ignore timeline updates where the
period is no longer present because the it will be removed anyway.

PiperOrigin-RevId: 302383787
2020-03-25 13:02:44 +00:00
tonihei
6927192a9d Add missing indirect build dependency.
Gradle produces build warnings without this dependency.

PiperOrigin-RevId: 302045675
2020-03-25 13:02:26 +00:00
olly
429bdfb974 Improve logging
- Make sure logging of UnknownHostException indicates the failure reason
- Indent stack traces inside event blocks in EventLogger
- Don't log media URLs

PiperOrigin-RevId: 302007601
2020-03-20 12:49:20 +00:00
ibaker
c0d632936a Add @Nullable to ExoMediaDrm's setListener methods
These methods document themselves only by referencing the Android's
MediaDrm, which explicitly accepts null [1]. The implementation in
FrameworkMediaDrm also handles nulls.

[1] https://developer.android.com/reference/android/media/MediaDrm#setOnEventListener(android.media.MediaDrm.OnEventListener)

PiperOrigin-RevId: 302007441
2020-03-20 12:49:11 +00:00
Oliver Woodman
c251eac545 Merge pull request #7098 from matamegger:feature/webvtt_negative_media_timestamp
PiperOrigin-RevId: 301996778
2020-03-20 12:49:00 +00:00
aquilescanta
aa9eb5abc9 Remove generics from DRM components
PiperOrigin-RevId: 301798563
2020-03-20 12:48:50 +00:00
ibaker
077e7932bf Add some more DRM event plumbing to Playlist
This was missed in f08eed4145

Part of issue:#6765

PiperOrigin-RevId: 301796232
2020-03-20 12:48:41 +00:00
ibaker
181177a245 Clarify docs around listener hierarchies in MediaSourceEventDispatcher
Also add a couple of tests to enforce the documentation.

PiperOrigin-RevId: 301796102
2020-03-20 12:48:32 +00:00
olly
818925d4a7 Add shell for FfmpegVideoRenderer
Issue: #2159
PiperOrigin-RevId: 301705371
2020-03-19 00:50:55 +00:00
olly
0a274946ac Simplify extension video renderers
- This change also adds support for VideoFrameMetadataListener in the
  AV1 renderer
- This is a preliminary step prior to adding FfmpegVideoDecoder

Issue: #2159
PiperOrigin-RevId: 301702460
2020-03-19 00:50:47 +00:00
olly
ee6afe5eb9 Merge AudioDecoderException and VideoDecoderException
This is a necessary step for Decoder implementations to support
audio and video. MediaCodecRenderer.DecoderException is renamed
MediaCodecDecoderException and extends the new DecoderException

Issue: #2159
PiperOrigin-RevId: 301698238
2020-03-19 00:50:39 +00:00
tonihei
395a7031ac Add tests to cover two OOM scenarios.
We have two known scenarios where the app could create an OOM error and
we want to handle it gracefully:
 1. The app continues to allocate memory but doesn't make any progress
    in the buffered position. OOM should be prevented by the default
    load control and it should eventually throw an exception.
 2. An extractor tries to allocate a large amount of memory on the
    Loader thread based on information it read in faulty media files.
    In this case we should attempt to play remaining media and then
    throw an exception.

Both cases are already handled correctly, but we don't have any tests
ensuring that we don't introduce regressions.

PiperOrigin-RevId: 301585700
2020-03-19 00:50:31 +00:00
tonihei
99667a6dc1 Detect stuck-buffering cases in the player.
This removes a workaround that always continues buffering and instead
detects if the LoadControl returns false even though we don't have
any buffer. If enabled by a flag, this condition throws an exception.

PiperOrigin-RevId: 301584239
2020-03-19 00:50:23 +00:00
tonihei
2e5444b49b Add option to use a custom DrmSessionManager into OfflineLicenseHelper
This allows to customize the DrmSessionManager, e.g. with a
LoadErrorHandlingPolicy.

Issue:issue:#7078
PiperOrigin-RevId: 301571783
2020-03-19 00:50:14 +00:00
bachinger
14aa56d62b correct the javadoc of onRenderedFirstFrame in VideoListener
Issue: #7097
PiperOrigin-RevId: 301456951
2020-03-19 00:50:06 +00:00
olly
cbe99ec475 Make SimpleDecoderXRenderers work with any Decoder implementation
The restriction that these classes only work with SimpleDecoders
is unnecessary. An FfmpegVideoRenderer will not be able to use a
SimpleDecoder, because the SimpleDecoder assumption that each input
buffer can be decoded immediately into a corresponding output is
not true for all video codecs that Ffmpeg supports (e.g., H264 does
not have this property). Generalizing SimpleDecoderVideoRenderer to
DecoderVideoRenderer will allow FfmpegVideoRenderer to still use
the base class, without having to use a SimpleDecoder.

This is a preliminary change toward being able to merge a version
of https://github.com/google/ExoPlayer/pull/7079.

Issue: #2159
PiperOrigin-RevId: 301412344
2020-03-19 00:49:58 +00:00
tonihei
a3a3b5be0b Add comment to clarify usage of constant.
PiperOrigin-RevId: 301406108
2020-03-19 00:49:50 +00:00
olly
5c4d4762d1 Remove unused dependency
PiperOrigin-RevId: 301397420
2020-03-19 00:49:42 +00:00
tonihei
9d5319d6ac Fix flaky test by slightly changing its setup.
The test is flkay (2/1000 runs) because the decoder initialization
before and after the seek are not perfectly deterministic. I couldn't
find a way to make them deterministic, so slightly chaning the test
setup instead. The test setup change doesn't affect the scenario being
tested.

PiperOrigin-RevId: 301390491
2020-03-19 00:49:34 +00:00
tonihei
363b4224b9 Fix stuck buffering problem caused by target buffer size of 0.
When no tracks are selected (or only tracks of unknown type), the
target buffer size is calculated to be 0. This means the player
won't request to buffer more data, nor can it start playback and
will be stuck forever.

PiperOrigin-RevId: 301374229
2020-03-19 00:49:26 +00:00
ibaker
cb414e8743 Change FakeRenderer to take a track type instead of a list of formats
The assertion about the expected formats doesn't really belong in a
fake, the assertions should be closer to the test method.

This gets in the way when I try and write a new test in
AnalyticsCollectorTest that doesn't use the expected, constant Format
(because i want to specify drmInitData) - but changing the expected
Format is tricky because it's hard-coded into the FakeVideoRenderer
inner class.

I replaced the assertion in FakeRenderer with assertions in test
methods that used to assert on the format count.

PiperOrigin-RevId: 301353072
2020-03-19 00:49:10 +00:00
kimvde
e962a478b9 Document missing messages in audio renderers
PiperOrigin-RevId: 301352482
2020-03-19 00:48:54 +00:00
bachinger
510f5edd1d Remove cast media item
PiperOrigin-RevId: 301224632
2020-03-19 00:48:22 +00:00
ibaker
5f8cc71d1b Use reference-counting for listeners from MediaSourceEventDispatcher
Previously calling removeListener would remove all instances of that
listener. Now it only removes a single instance.

This probably should have been part of introducing the Multiset:
2bd4d61b9b

PiperOrigin-RevId: 301191940
2020-03-19 00:48:14 +00:00
kimvde
aec6fe7e65 Notify listeners when audio session ID is set
PiperOrigin-RevId: 301187369
2020-03-19 00:48:05 +00:00