624 Commits

Author SHA1 Message Date
tonihei
05fddff84f Modernize bandwidth profile simulator.
Main improvement is to switch away from ExoPlayerTestRunner and to
split out the waiting component so that the same class can be used
from Robolectric tests in the future.

The only functional difference is that that BufferLengthLogAction
is removed completely because the data isn't used downstream and the
method of collecting this data is a bit arbitrary.

PiperOrigin-RevId: 355117850
2021-02-02 13:06:43 +00:00
andrewlewis
afb41123c2 Switch transformer tests to use dump files
Add an interface to muxers to allow tests to pass a dumpable muxer.

#minor-release

PiperOrigin-RevId: 354543388
2021-02-01 18:10:55 +00:00
tonihei
ae51e2e1d1 Also fix thread blocking nullness assertion when called from non-Looper
PiperOrigin-RevId: 354268013
2021-02-01 18:10:24 +00:00
tonihei
a60938db96 Fix triggering messages sent from non-Looper threads.
This can happen for instrumented tests that are run on a non-Looper
thread. If these tests send a message to a Looper thread to start the
test procedure, they should just triger the message directly as before.

PiperOrigin-RevId: 354066836
2021-02-01 18:10:05 +00:00
tonihei
9b3014dd79 Remove randomness from adaptive bitrate tests.
- The order of sample stream (and thus the order in which loads are
  triggered) currently depends on a Set and thus on the hash codes
  of the objects that change with every run. Changing to a List solves
  this problem.
- The FakeAdaptiveDataSet directly created a static Random (with random
  seed) to compute the variation of chunk sizes. Changing this to an
  injected Random object that can always be initialized with the same
  seed also removed this randomness from the tests.

PiperOrigin-RevId: 353878661
2021-01-26 17:13:46 +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
a318e56d15 Fix FakeClock remove messages behaviour.
We currently only remove messages that have already been sent
to the actual Handler, not the pending ones that are only kept
in the FakeClock. Fix this by also removing matching messages
from the FakeClock list.

PiperOrigin-RevId: 353877049
2021-01-26 17:13:25 +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
olly
a1f06987eb Replace non-inclusively named constant
Issue: #7565
PiperOrigin-RevId: 353649187
2021-01-25 17:38:26 +00:00
krocard
ec43735054 Split mutations method out of TrackSelection
`TrackSelection` had mutation methods which were to be called only
internally by ExoPlayer components but were exposed in the
public `Player` interface.

The mutation methods have been moved out of `TrackSelection`
to a new class `ExoTrackSelection`.

Current track related read-only method have also been moved out,
because they are actually something quite unclear.
Even for a single item playlist, it's the track being buffered rather
than the track being played, which is unclear.
But when you have a playlist it starts to get really confusing,
because if the next item is being buffered, then it's actually
the last track to be buffered in the currently playing item.
As a final aside, the implementations don't do proper thread synchronization
to ensure visibility of updated state by the calling thread.

Exposing those mutable methods in the public `Player` interface
was problematic because they leaking internal concepts of `ExoPlayer`.
This is also required to minimize the `Player` interface for long term
stability.

`ExoTrackSelection` is a subclass of `TrackSelection`.
This is not ideal as an `TrackSelection` implementation could
break the current immutability.
This was done in order for this refactor to be simpler.
A future patch will fully split the two classes.

All `MediaPeriod` and `Sources` had to be updated to use the new
`TrackSelection` dynamic aspect class name.
An alternative would have been to break ExoPlayer's public API, keeping
`TrackSelection` as the dynamic aspect name, and calling the public static
aspect class `TrackSelectionState` or similar.
Nevertheless, while it would have impacted less files, it would have
many more small apps and casual users of ExoPlayer.

#player-to-common

PiperOrigin-RevId: 353637924
2021-01-25 15:37:38 +00:00
olly
dc7fde1ff7 Some more language fixes
Issue: #7565
PiperOrigin-RevId: 353613493
2021-01-25 15:36:59 +00:00
christosts
0a3542e50e Add contract test for CronetDataSource
PiperOrigin-RevId: 353290124
2021-01-25 15:35:59 +00:00
tonihei
4cbd4e2e2a Use Clock to create Handler for delivering messages.
This ensures the message devilery is governed by the clock.

Also replace setting a Handler with a Looper to facilititate this
change.

PiperOrigin-RevId: 353019729
2021-01-22 16:21:44 +00:00
tonihei
d1faf713af Use Clock to create Handler in ListenerSet.
This ensures the Handler is governed by this clock.

PiperOrigin-RevId: 353011555
2021-01-22 16:21:27 +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
christosts
21f3fa9f7c Add contract test for DataSchemeDataSource
PiperOrigin-RevId: 352558063
2021-01-19 19:23:40 +00:00
christosts
c808751009 Add contract tests for OkHttpDataSource
PiperOrigin-RevId: 352554949
2021-01-19 19:23:31 +00:00
olly
adb9dcb43f Add KeyRequest.getRequestType
Issue: #7847
PiperOrigin-RevId: 351661084
2021-01-15 10:55:36 +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
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
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
ibaker
e154cb1787 Fix calls to readExactly in DataSourceContractTest
The length needs to change depending on the positition/length parameters
passed to DataSpec, so it doesn't really make sense to keep this private
method - it's clearer to in-line the calls in each test.

PiperOrigin-RevId: 348749254
2020-12-23 22:52:57 +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
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
7027e75ce8 DataSourceContractTest: Check an unbounded subrange is read correctly
PiperOrigin-RevId: 347994829
2020-12-23 22:48:29 +00:00
ibaker
1a00da4c19 Add CapturingRenderersFactory and use it in Mp4PlaybackTest
I decided not to migrate all the tests in one CL to keep the diff
manageable. I'll make follow-up CLs to migrate the tests, and eventually
delete TeeCodec and all associated logic.

I couldn't completely remove the dump diff because
ShadowMediaCodec.getCodecInfo() (which would give me access to the MIME
type) doesn't seem to work properly - it returned video/avc when
name=exotest.audio.aac, and looking into the code it looks like there's
some native methods that are missing shadow implementations.
PiperOrigin-RevId: 347991956
2020-12-23 22:48:20 +00:00
tonihei
43886491f6 Make FakeMediaPeriod and FakeAdaptiveMediaPeriod independent.
The adaptive period currently extends the base (non-adaptive) period
to share common MediaPeriod boilerplate code.

However, once we start using the real SampleQueue in FakeMediaPeriod
the common code becomes even less and the overhead to support
multiple stream implementation from the base class is no longer
worth it. Thus, this change removes the class hierarchy and copies
the common parts to FakeAdaptiveMediaPeriod.

PiperOrigin-RevId: 347990468
2020-12-23 22:48:10 +00:00
christosts
e18892cd03 Make setters of TestResource.Builder accept a value.
PiperOrigin-RevId: 347388172
2020-12-17 11:25:52 +00:00
christosts
401634a9fb Create UdpDataSource contract test
PiperOrigin-RevId: 347386108
2020-12-17 11:25:52 +00:00
ibaker
73b9cee83a Add a ContentDataSource contract test
PiperOrigin-RevId: 346954787
2020-12-14 10:17:33 +00:00
bachinger
05c928f96d Add live configuration to Timeline.Window
Issue: #5011
PiperOrigin-RevId: 346828103
2020-12-14 10:17:23 +00:00
ibaker
2a93eff25a Attach resource info to exceptions thrown in DataSourceContractTest
Before this we added the resource info to Truth assertions, but the
same info is missing if an exception bubbles out of the SUT.

PiperOrigin-RevId: 346757960
2020-12-14 10:16:53 +00:00
christosts
1ff0965a10 Do not advance SystemClock manually in tests
Changes MetadataRetriever and Transformer so that their
respective tests don't need to manually control the SystemClock
in order to execute taks posted with delay from Loader.

PiperOrigin-RevId: 345024140
2020-12-03 17:10:19 +00:00
krocard
538445572d Move FormatSupport in common
#player-to-common

PiperOrigin-RevId: 344558028
2020-11-30 09:33:11 +00:00
tonihei
e66f0032aa Remove stopTest workaround in ExoHostedTest
The workaround to post a message was needed to ensure we
receive any final onIsPlayingChanged event before the test
is finished (to record the correct playing time).

Using onEvents allows us to do this synchronously as the
callback guarantees that there is no other pending event.

#exofixit

PiperOrigin-RevId: 344436180
2020-11-27 11:08:49 +00:00
ibaker
3aa17bfb9b Switch extractor tests to single-parameter parameterized syntax
This is simpler than instantiating a single-element string array for
every parameter.

#exofixit

PiperOrigin-RevId: 344237475
2020-11-27 11:06:51 +00:00
tonihei
87e141d376 Remove boilerplate setting up FakeTimeline and FakeMediaSource.
In many cases it doesn't matter for the test itself how many windows
a timeline has, or even how the timeline of a MediaSource looks like.

And since we introduced the MediaItem-based APIs, single-window
Timelines are the only fully supported Timelines. Thus there is no
point in specifiying this explicitly.

Using these assumptions, we can remove some boilerplate when setting
up standard FakeTimelines or FakeMediaSources with a standard
FakeTimeline.

#exofixit

PiperOrigin-RevId: 344210395
2020-11-27 11:06:27 +00:00
kimvde
7a7d3d1b07 Add FMP4 extractor test with sideloaded track
#exofixit

PiperOrigin-RevId: 344052500
2020-11-24 16:03:46 +00:00
ibaker
6d7997e747 Move DataSourceContractTest to the testutil package
PiperOrigin-RevId: 343096974
2020-11-18 18:40:36 +00:00
tonihei
44009ea686 Rollback of fa6e01312b
*** Original commit ***

Suppress warnings in preparation for Checker Framework 3.7.1 upgrade.

***

PiperOrigin-RevId: 343085407
2020-11-18 18:40:22 +00:00
olly
755f5b7d76 Suppress warnings in preparation for Checker Framework 3.7.1 upgrade.
PiperOrigin-RevId: 342999709
2020-11-18 18:40:10 +00:00
ibaker
4936c730c3 Add a contract testing abstract class for DataSource implementations
This only has a couple of simple tests for now. We'll add more tests
after we've written some concrete sub-class tests for various
DataSource implementations.

I've included a concrete FileDataSourceContractTest as a demonstration.

PiperOrigin-RevId: 342851187
2020-11-18 18:30:58 +00:00
ibaker
41d0c0f882 Add @deprecated javadoc to StubExoPlayer#getPlaybackError
This should be inherited from Player#getPlaybackError, but lint still
complains and this seems like the easiest fix.

PiperOrigin-RevId: 342598368
2020-11-16 16:50:23 +00:00
olly
c47e62209d Report reasons for not being able to reuse decoders
PiperOrigin-RevId: 342344090
2020-11-16 16:49:48 +00:00
ibaker
1e776a864b Fix some typos
PiperOrigin-RevId: 341573964
2020-11-11 09:50:30 +00:00
andrewlewis
764e5e8141 Expose the ads identifier in the Timeline period
Issue: #3750
PiperOrigin-RevId: 341021084
2020-11-06 16:35:06 +00:00
tonihei
ae17e6d6f8 Forward Timeline and period id to TrackSelection.Factory
This information is already available in the MappingTrackSelector,
but not currently forwarded to the TrackSelection.Factory.

This makes it more complicated (or impossible) to depend on period
or manifest information in the track selection (for example to only
select tracks which are cached for the current format).

PiperOrigin-RevId: 340605886
2020-11-06 16:32:57 +00:00