3294 Commits

Author SHA1 Message Date
andrewlewis
02bc2d7ce1 Add DefaultLoadControl test for starting playback
Also refactor the tests to make them behavioral (rather than testing the method)
and inline simple assertions.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=191867614
2018-04-08 16:39:57 +01:00
tonihei
66d2b76a6c Remove test max SDK version overrides.
These don't seem to be needed anymore. All tests run without them in gradle
and Blaze.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=191867518
2018-04-08 16:39:57 +01:00
danarapagna
8a74acbe6f Automated g4 rollback of changelist 191128111.
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=191834511
2018-04-08 16:40:58 +01:00
tek
26cb32ab6a Migrating to new "android" handler from deprecated "androidlocalizer".
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=191788495
2018-04-08 16:39:57 +01:00
andrewlewis
280cc545dd Search for TrueHD syncframes
In MatroskaExtractor TrueHD audio samples are joined into larger chunks. For
some streams the resulting chunked samples seem never to start with a syncframe.
This could result in playback of TrueHD streams getting stuck after seeking
because we could never read a syncframe at the start of a sample to determine
the sample size.

Instead of expecting to find a syncframe at the start of a sample, search for it
within the sample, to fix this issue.

Note: this means that we may search a few thousand bytes to find the sample
size, but the cost is only incurred for the first audio sample read.

Issue: #3845

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=191775779
2018-04-07 19:15:50 +01:00
andrewlewis
1b84544264 Improve TrueHD syncframe detection
Also increase the chunking size to sixteen samples.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=191768169
2018-04-07 19:14:03 +01:00
tonihei
6b82d1c2bd Add setters to MediaSource factories for custom window tag.
This field (formerly "id") is almost impossible to use so far. Having setters
in the factories allows to specify custom tags for all media sources.

Also added a ExoPlayer.getCurrentTag() method to retrieve the tag of the
currently playing media source in a convenient way.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=191738754
2018-04-07 19:12:21 +01:00
tonihei
f25c7a859a Add analytics listener interface and default data collector.
The data collector keeps track of active media periods to assign each event to
the correct media period and/or window. This information, together with other
information like playback position and buffered duration, is then forwarded
with the event to all registered listeners.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=191726408
2018-04-07 19:10:37 +01:00
olly
e26cad1a6d Blacklist Huawei P9 Lite from setOutputSurface
Issue: #4084

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=191716636
2018-04-07 19:07:00 +01:00
andrewlewis
6ea79c8a4e Fix usage of 'samples' vs 'frames' for gapless
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=191704629
2018-04-07 19:05:17 +01:00
andrewlewis
e3eddc4d20 Apply new playback parameters only once drained
Previously the SonicAudioProcessor and SilenceSkippingAudioProcessor would track
their pending playback parameters and only apply them in flush(). Having the
values only take effect once flushed made the processors a bit more difficult to
use, especially because the value returned by isActive wouldn't update
immediately.

Make DefaultAudioSink only set the new speed/pitch/skip silence setting after
the audio processors have drained. This means it's no longer necessary to keep
track of pending parameter values and also fixes a bug where initial playback
parameters weren't applied because the audio processors weren't flushed while
uninitialized before DefaultAudioSink called isActive() on them.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=191586727
2018-04-07 19:03:21 +01:00
tonihei
7c65b94578 Check for null listeners in deprecated paths in DefaultDrmSessionManager.
The previous API allowed to pass in null to the constructors although variants
without listeners exist. That's why we need to handle these null values.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=191577891
2018-04-07 19:01:30 +01:00
olly
631e1db7f9 Bump version to 2.7.3 and update release notes
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=191561921
2018-04-04 10:09:05 +01:00
sxp
aca4db1131 Keep old Exoplayer API.
Partial rollback of [] which caused b/77294898 by deleting a public Exoplayer API.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=191519591
2018-04-04 10:07:44 +01:00
andrewlewis
f2399c1c85 Make flush() update parameters, and make Sonic flushable
Previously it was necessary to create a new Sonic instance every time the
processor was flushed. Add a flush() method to Sonic so that it can be reused
when seeking. It still needs to be recreated when parameters change.

SonicAudioProcessor and SilenceSkippingAudioProcessor have methods for setting
parameters that are documented as taking effect after a call to flush(), but
actually the value returned by isActive() was updated immediately. Track the
pending values and apply them in flush() to fix this.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=191442336
2018-04-03 18:47:55 +01:00
olly
5f03c37599 Don't refresh DASH manifest if minUpdatePeriod is unset
We currently refresh repeatedly in this case. According to the
DASH spec omitting minUpdatePeriod indicates that the manifest
does not change, and therefore we should not refresh. I think
it might be valid to omit minUpdatePeriod in a dynamic manifest
if relying exclusively on EMSGs to trigger manifest refresh.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=191420247
2018-04-03 15:40:41 +01:00
eguven
f7e2cdbbbb Add missing synchronized keywords and assertions
applyContentMetadataMutations and getContentMetadata methods suppossed to be synchronized and assert the instance isn't released.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=191419637
2018-04-03 15:37:20 +01:00
andrewlewis
53eae50c0c Simplify buffer resizing in Sonic
This is in preparation for making it possible to flush a Sonic instance so that
it's not necessary to create new ones every time the processor is flushed.

There should be no behavior changes here.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=191410326
2018-04-03 15:32:20 +01:00
olly
8b5a34769f Remove unnecessary line from test manifests
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=191409777
2018-04-03 15:30:40 +01:00
danarapagna
6380f26a7f Temp fix for b/77315136: Don't lock or check cache directories in SimpleCache
To be immediately rolled back after submission

Submitting on behalf of cblay.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=191128111
2018-04-03 15:27:26 +01:00
olly
3a98f7aa99 Make toUpperCase conversions locale invariant
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=190942033
2018-03-29 18:00:05 +01:00
olly
1648e4e9f9 Don't call getLayoutDirection before API level 17
Weirdly, the Android Javadoc indicates that it returns something
before the API level on which the same Javadoc states it was added.
In any case, we can simply not call the method to avoid the
warning, since we only use the value if the API level is at least
23 anyway.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=190941776
2018-03-29 17:58:38 +01:00
olly
d2fe3cf9c9 Bump version to 2.7.2 + update release notes
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=190941619
2018-03-29 17:56:48 +01:00
andrewlewis
8d47209a46 Make video playback smoother at the beginning
Video renderers assume that the player position is advancing linearly while in
the started state. MediaCodecVideoRenderer schedules frames for rendering in the
future in the expectation that the player position is advancing.

This assumption is not currently true when using a position from the AudioTrack:
the player position can be fixed for (in the worst case) up to about 100 ms
before it starts increasing. This leads to an effect where the first frame is
rendered then a few other frames are rendered, then there's a pause before
frames start being rendered smoothly.

Work around this issue by checking whether the position has started advancing
before scheduling frames to be rendered in the future.

It might be preferable to make the audio renderer only become ready when its
timestamp can start advancing, but this is likely to be complicated.

Issue: #3841

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=190937429
2018-03-29 17:55:01 +01:00
andrewlewis
7820497006 Add speed-only constructor for PlaybackParameters
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=190927811
2018-03-29 17:53:18 +01:00
eguven
1d2d777f66 Fix DashDownloader failure for some multi segment representations
Issue: #3729

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=190922866
2018-03-29 17:51:24 +01:00
andrewlewis
ba8bbd8941 Add skip silence option to PlaybackParameters
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=190917894
2018-03-29 17:49:32 +01:00
andrewlewis
017c95ffdd Use audio frames vs samples consistently in Sonic
In audio processors an audio frame consists of a sample (which is 2 bytes for
16-bit PCM) for each channel. Sonic used "sample" to refer to this.

We've already diverged from the original source for Sonic quite a bit (deleting
code and making stylistic changes) and there haven't been upstream changes so
far, so it seems fine to start making more substantial changes here.

There should be no behavior changes here.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=190916793
2018-03-29 17:47:16 +01:00
olly
2b9b2510dc Fix Javadoc generation + Javadoc
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=190916130
2018-03-29 13:57:09 +01:00
andrewlewis
f634b1d4d8 Resolve locale warnings in EventLogger
Use string concatenation for Metadata.Entry instances, and add
Util.formatInvariant for numerical formatting.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=190915643
2018-03-29 13:55:46 +01:00
tonihei
39e4112e8f Add proper live stream clipping.
This adds two options to the ClippingMediaSource which allow proper clipping
of live streams:
 1. The clipping stays fixed relative to already created media periods. That
    means that playback actually progresses through the clipped media and
    eventually reaches the end of the clipping. The window is also marked
    as non-dynamic to let playback end in this case.
 2. Allow to specify a clipping duration relative to the default position to
    be able to specify the duration of live stream which is to be played.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=190911049
2018-03-29 13:54:06 +01:00
tonihei
09cf927713 Make constructor in EventDispatcher public.
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=190907004
2018-03-29 13:52:26 +01:00
tonihei
4db6d6fbaa Automated g4 rollback of changelist 190628272.
*** Reason for rollback ***

b/76391022 was caused by a timestamp correction in StabilizableSimpleExoPlayer which will be fixed with this CL.

*** Original change description ***

Automated g4 rollback of changelist 189570277.

*** Reason for rollback ***

causes b/76391022, motion still playback in Photos is broken

*** Original change description ***

Used fixed time frame in clipping media period.

Currently, whenever the clipping is updated, we move the time frame of the
clipped period to start at 0. This causes problems when we are already playing
this period and the renderer position does no longer match the stream
positions.

This change keeps the time frame of the...

***

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=190906020
2018-03-29 13:50:44 +01:00
andrewlewis
78ff4af6a7 Clean up AudioProcessor implementations
- Ensure that no memory is used by audio processors that are always inactive, by
  only allocating in flush() if active. If data was already allocated but a
  processor becomes inactive we assume that the allocation may be needed in
  future so do not remove it (e.g., in the case of ResamplingAudioProcessor).
- Make SilenceSkippingAudioProcessor set up its buffers in flush(), and clarify
  that it is always necessary to call flush() if configure() returns true.
- Make reset() reset all state for all processors.
- Use @Nullable state or empty arrays for inactive audio processor buffers.
- Miscellaneous style/consistency cleanup.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=190895783
2018-03-29 13:47:19 +01:00
eguven
acca4f238b Add missing @Nullable annotations
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=190817805
2018-03-29 13:45:38 +01:00
aquilescanta
fbd7c0bd1f Fix typo in DownloadAction
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=190787979
2018-03-29 13:43:53 +01:00
eguven
f40add5244 Add a DownloadManager constructor with default parameter values
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=190782395
2018-03-29 13:38:54 +01:00
andrewlewis
6dcfe57fd3 Add SilenceSkippingAudioProcessor
This uses a simple threshold-based algorithm for classifying audio frames as
silent, and removes silences from input audio that last longer than a given
duration.

The plan is to expose this functionality via PlaybackParameters in a later
change.

Issue: #2635

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=190737027
2018-03-29 13:28:42 +01:00
olly
18df028ce2 Remove TrackGroups from TrackSelectorResult
They don't really belong there; it was basically a convenience
thing where one of the arguments to the track selector was being
packaged up in the result to avoid having to hold a separate
reference to it.

This change is being made as a precursor to a subsequent change
where creating the TrackSelectorResult will move from
MappingTrackSelector to DefaultTrackSelector. DefaultTrackSelector
doesn't currently have access to the un-mapped tracks, and so is
unable to create a TrackSelectorResult. It's IMO preferable to
keep it that way rather than passing them down just so they can
be included in the result.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=190640594
2018-03-28 01:04:56 +01:00
olly
0a4ea1cd3e Make DefaultTrackSelector.Parameters parcelable
Issue: #3915

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=190635670
2018-03-28 01:01:55 +01:00
byungh
82b72c9358 Automated g4 rollback of changelist 189570277.
*** Reason for rollback ***

causes b/76391022, motion still playback in Photos is broken

*** Original change description ***

Used fixed time frame in clipping media period.

Currently, whenever the clipping is updated, we move the time frame of the
clipped period to start at 0. This causes problems when we are already playing
this period and the renderer position does no longer match the stream
positions.

This change keeps the time frame of the clipped media period as it is and
instead specifies the offset of the window in the period.

***

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=190628272
2018-03-28 00:58:38 +01:00
aquilescanta
74b7b90555 Propagate non-MediaSource-preparation playlist load errors through HlsChunkSource
Erroneous condition:
===================
If the track selection contains a subset of the available variants in the
master playlist, but only the selected variants return 404, the playlist
tracker will never propagate the error.

Fix:
====
The Chunk source will propagate the playlist load error if no more
alternative playlists are available (because all are already blacklisted).

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=190624484
2018-03-28 00:57:01 +01:00
aquilescanta
71e5b2c073 Assume TS when the HLS segment URI has no path
Issue:#4033

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=190603518
2018-03-28 00:55:19 +01:00
eguven
5925f92482 Persist content redirected URI in CacheDataSource
Issue: #2360

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=190597773
2018-03-28 00:53:40 +01:00
aquilescanta
f0bb6bb263 Make MediaPeriod implementations compliant with its specification
Currently, MediaPeriod states that continueLoading may be called
during preparation. Some implementations would throw an error if
this happened.

Also make MediaPeriod documentation clearer.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=190596870
2018-03-28 00:52:04 +01:00
andrewlewis
6cb07adcee Fix handling of timestamps before play()
If the AudioTimestamp was sampled before play() was called, it was incorrectly
returned to the caller for sanity-checking. Fix this behavior by dropping the
timestamp internally in the AudioTimestampPoller.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=190584412
2018-03-28 00:48:35 +01:00
olly
eb34a2a102 Improve DASH/SS seek performance
This change enables feeding decoders from the closest sync frame
before a specified seek position, where-as previously we'd
always feed decoders from the start of the chunk. This avoids
decoding and discarding many audio samples during each seek. The
same benefit also applies to video chunks containing more than
one key-frame.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=190539547
2018-03-28 00:46:49 +01:00
olly
f7cd9f7d1d Seek to sync frame within moof in FragmentedMp4Extractor
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=190498206
2018-03-28 00:44:54 +01:00
tonihei
3cbe91a3b0 Pass DrmSessionManager through SimpleExoPlayer.
This will allow SimpleExoPlayer to auto-register its own listener before the
drm session manager is used to set-up the renderers.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=190478174
2018-03-28 00:43:07 +01:00
tonihei
6c0d676050 Add callbacks for media period life cycle.
This adds callbacks for creating, releasing, and starting to read from media
periods.

Such events allow listeners to keep a list of active media periods. This is
useful to determine when no further events for a certain media period are
expected. It also allows listeners to associate renderer events unambigiously
with a reading media period.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=190462717
2018-03-28 00:41:29 +01:00