208 Commits

Author SHA1 Message Date
tonihei
52de36c5eb Add abstract, default Player event listener.
This allows simplified listener implementations as most listeners
will not listen to all possible notifications.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=170177821
2017-10-03 08:44:33 +01:00
olly
55f696e11d Fix spurious failures due to late decoding.
By default, if a codec is instantiated during an ongoing
playback, ExoPlayer will render the first frame that it
receives (so that there's "something other than black"
drawn to the surface). This frame is the key-frame before
the current playback position, and may be as much as 5
seconds behind the current position. ExoPlayer then drops
subsequent frames that are late until it's caught up to
the current position again.

For GTS tests that are counting dropped frames, this is
not desirable behavior, since it will cause spurious test
failures in cases where DummySurface is not supported.
This change overrides the default behavior so that the
player instead skips (rather than drops) frames until it's
caught up to the current playback position, and only then
renders the first frame.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=170175944
2017-10-03 08:43:10 +01:00
olly
0ad39c642d Relax test termination for API level 23 and above
This allows test runs to continue when the activity
is paused (but not stopped), which is in line with
what we do in the demo app's PlayerActivity.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=168699521
2017-09-15 23:40:43 +01:00
tonihei
7d59383cc4 Add reason to onPositionDiscontinuity.
This allows listeners to easily determine the source of the discontinuity.
Reasons can be period transitions, seeks, and internal reasons.

Listeners still using the deprecated ExoPlayer.EventListener interface were
updated to Player.EventListener.

GitHub: #3252

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=168549612
2017-09-15 23:36:46 +01:00
hoangtc
5019da3e7b Update ABR logic in AdaptiveTrackSelection for live streaming case
In live streaming, if the playback position is very close to live edge,
the buffered duration will never reach minDurationForQualityIncreaseMs,
which prevents switching from ever happening. So we will provide the
durationToLiveEdgeUs to AdaptiveTrackSelection in live streaming case,
so it can handle this edge case.

GitHub: #3017

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=168535969
2017-09-15 23:33:10 +01:00
tonihei
f9661b5373 Use Handler callback instead of sleep() to catch InteruptedException.
The sleep used to simulate data load times is ignoring InterruptedExceptions.
(This is intended and in line with SystemClock.sleep()). However, when a
Loader cancels an ongoing load, it uses interrupts. To be able to catch these
and to immediately return from the reading data source, a handler callback
is used instead of the sleep() method which allows interuptable waiting.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=168212652
2017-09-15 23:28:13 +01:00
tonihei
c4bf83dd1a Support stop() in FakeExoPlayer and release media properly.
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=168209817
2017-09-15 23:26:56 +01:00
tonihei
c181057550 Fix bug in ActionSchedule.
When having a repeat() action and another subsequent action,
the next action should only be scheduled once (and not repeatedly).
Thus, the "next" pointer in the repeated action needs to be nulled
in the first iteration to prevent repeated scheduling of the next action.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=168202212
2017-09-15 23:25:45 +01:00
tonihei
9a91482a1b Release streams in fake adaptive media period.
Releasing the media period should also release the sample streams
to allow resources to be cleaned up.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=168201377
2017-09-15 23:24:28 +01:00
tonihei
8f43dcd424 Clear buffer in fake renderer in each iteration.
This simulates reading from the buffer (which is what actual
renderers would do). Otherwise the buffer always gets expanded
and might cause memory issues.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=167994899
2017-09-08 22:24:19 +01:00
tonihei
b2627d63fd Allow ExoPlayerTestRunner to end when Player.stop() is called.
In this case the playback state transitions to IDLE, which isn't
caught so far. (This code is equivalent to the one in ExoHostedTest.java)

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=167980981
2017-09-08 22:22:57 +01:00
andrewlewis
7c3fe19d3f Migrate remaining tests to Robolectric
Remaining instrumentation tests either use android.os.Handler or rely on assets.
In the latter case, the tests are difficult to migrate due to differences
between the internal and external build systems, and configuration needed in
Android Studio. In addition, SimpleCacheSpanTest remains as an instrumentation
test because it fails due to a problem with string encoding on the internal
build (and two other tests in its package are kept with it because they depend
on it).

This test removes a dependency from testutils on Mockito, as a different
version of Mockito needs to be used for instrumentation tests vs Robolectric
tests, yet both sets of tests need to rely on testutils. Mockito setup is now
done directly in the tests that need it.

Move OggTestData to testutils so it can be used from both instrumentation and
Robolectric tests.

It may be possible to simplify assertions further using Truth but this is left
for possible later changes.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=167831435
2017-09-08 22:21:33 +01:00
tonihei
8413dab9de Use clock in action schedule to handle delays.
This allows to use a fake clock and an action schedule with timed delays
together.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=167582860
2017-09-06 15:42:39 +01:00
tonihei
2f4a3fe1f3 Add postDelayed operation to Clock interface.
The default implementation is just calling through to handler.postDelayed,
while the fake clock uses its internal time value to trigger the handler
calls at the correct time.

This is useful to apply a fake clock in situations where a handler is used to
post delayed messages.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=167567914
2017-09-05 16:34:44 +01:00
tonihei
264f1c903d Fix bug in FakeChunkSource.
In order to retrieve the data set, the track selection index was used, but
the data set is actually indexed by track group indices.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=167566049
2017-09-05 16:33:17 +01:00
andrewlewis
0b78837f35 Fix ContentDataSource bytesRemaining calculation
The bytesRemaining didn't always take into account any skipped bytes, which
meant that reaching the end of the file was not correctly detected in read().

Issue: #3216

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=167016672
2017-08-31 16:32:28 +01:00
tonihei
30b31b5679 Support empty concatenations and empty timelines in concatenations.
Both cases were not supported so far. Added tests which all failed in the
previous code version and adapted the concatenated media sources to cope with
empty timelines and empty concatenations.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=166480344
2017-08-29 23:01:41 +01:00
olly
6907ffb285 Remove unnecessary view casts
findViewById is now defined using generics, which allows
the types to be inferred.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=166355555
2017-08-29 22:57:17 +01:00
tonihei
aa712114c6 Force stop hosted test after timeout.
When hosted tests run into a timeout, the outer test method stops.
However, the hosted test itself may continue running and needs to be
forced-stopped to ensure it does not block any resources needed by
subsequent test methods.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=166208204
2017-08-29 22:52:10 +01:00
tonihei
eeebb3968b Implement shuffle mode logic in ExoPlayerImplInternal.
This is mostly connecting the already stored shuffleMode with the timeline queries
for the playback order.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=166199330
2017-08-29 22:50:49 +01:00
tonihei
b27c25e880 Add fake shuffle order.
This just implements a reverse order which is different from the original order but
still deterministic for simplified testing.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=166194311
2017-08-29 22:44:13 +01:00
tonihei
bd81181892 Add shortcut methods to query next or previous window index.
This functionality is most likely needed by UI modules which currently need
to obtain the timeline, the current repeat and shuffle modes and are only then
able to query the next/previous window index using this information.

Adding these methods simplifies these cumbersome requests.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=166181202
2017-08-29 22:40:13 +01:00
tonihei
2c8d5f846e Pass shuffle mode to timeline assertion helper methods.
This allows to test the expected behaviour of timeline with different shuffle modes.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=166181091
2017-08-29 22:38:50 +01:00
tonihei
10f1bd7396 Add shuffle mode parameter to Timeline interface methods.
This parameter is used by methods such as getNextWindowIndex
and getPreviousWindowIndex to determine the playback order.
Additionally, there are method to query the first and last
window index given the shuffle mode.

None of the timeline implementations nor the ExoPlayer
implementation supports shuffling so far.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=166170229
2017-08-29 22:37:27 +01:00
tonihei
b9a6a40539 Add listener callback for shuffle mode changes.
The listener implementations do not do anything yet.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=166056933
2017-08-22 16:23:27 +01:00
tonihei
c1d7e5bf9d Add set/getShuffleModeEnabled to Player interface.
And implement a basic version of the methods in all implementations.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=166041342
2017-08-22 16:19:25 +01:00
olly
2470b39d95 Split metadata and text outputs from their renderer classes
There will be non-ExoPlayer players that can output text
and metadata, so the outputs should be standalone. There
may also be ExoPlayer instances that use non-standard
text and metadata renderers, for which this change also
makes sense.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=165628420
2017-08-17 23:05:44 +01:00
olly
cf6534ea5b SegmentDownloader loadManifest cleanup.
- HlsDownloader.loadManifest (previously called getHlsPlaylist)
  suppressed errors for the offline case, where-as the DashUtil
  equivalent method did not. This change makes them consistent
  and moves both other to use ParsingLoadable.
- Enable GZIP for manifest loads in both cases.
- Use Uri rather than String to represent Uris. Previously the
  strings were parsed into Uris quite deep in the code, which
  isn't ideal if the parsing fails; you'd probably prefer the
  error to occur early at the top level.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=165181398
2017-08-17 22:32:57 +01:00
olly
40f34956a8 Bump minimum and target API levels + support lib version
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=164863447
2017-08-11 15:01:43 +01:00
tonihei
ccd05cbd04 Add fake simple exo player.
This implementation runs as fast as possible by triggering a simplified
playback loop continuously without waiting. The class only supports a basic
use case with a single-period timeline, no timeline update, no seeks or other
user-initiated actions.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=164120420
2017-08-04 12:29:40 +01:00
olly
412138b2ea Some extractor fixes
- Fix Ogg extractor to work without sniffing.
- Fix extractors to handle seek() before init().
- Add tests for both issues.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=163992343
2017-08-02 17:44:41 +01:00
tonihei
22ea9ed687 Clean-up ExoHostedTest/HostActivity.
This change clearly seperates the hosting of a test (HostActivity) from
the internals of hosting an ExoPlayer lifecycle (ExoHostedTest).

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=163967960
2017-08-02 17:42:11 +01:00
tonihei
1151104e2f Use TrackGroup instead of TrackSelection in FakeAdaptiveDataSet.
This was a bug as the data set should contain sample data for all available
tracks. Also added a unit test.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=163806579
2017-08-01 16:23:39 +01:00
olly
c2d7e05429 Propagate skipped input buffers through to CodecCounters
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=163683081
2017-07-31 21:14:23 +01:00
tonihei
5bd5af8c60 Replace canStop with blockUntilEnded in HostedActiviy.
The canStop method gets called every second in a seperate thread until the
test can be stopped. Replacing it with blockUntilEnded forwards the
responsibility to stop to the test itself which has better control over the
stop condition.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=163343824
2017-07-31 21:06:11 +01:00
tonihei
ad5ca0812d Add unit test for FakeDataSource.
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=163341994
2017-07-31 21:03:36 +01:00
tonihei
b631755b63 Clean up test runner for ExoPlayer tests.
Currently the ExoPlayerWrapper is used to run tests using an ExoPlayer
implementation. Some properties of the test are set in the constructor, some
are set by overloading the class, others are hard-coded in the
ExoPlayerWrapper class, and a mechanism similar to the existing ActionSchedule
is missing.

This change does the following:
 1. Renames ExoPlayerWrapper to ExoPlayerTestRunner as it better reflects
    its purpose.
 2. Adds an internal Builder to easily set-up the test in a coherent way. This
    allows to only set necessary test components while using defaults for the rest.
 3. Integrate ActionSchedule.
 4. Apply the new structure to the existing tests currently using ExoPlayerWrapper.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=163186578
2017-07-31 20:54:18 +01:00
tonihei
3991a6198b Extend ActionSchedule with new actions.
The new actions are: prepare source, set repeat mode, wait for timeline
change, wait for position discontinuity, execute Runnable.

Moreover, this change removes the restriction of using a SimpleExoPlayer to
allow ActionSchedule to be used in other scenarios.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=162918554
2017-07-31 20:46:35 +01:00
tonihei
0411add91e Add fake adaptive media source.
This class extends the existing FakeMediaSource by creating a
FakeAdaptiveMediaPeriod instead of a FakeMediaPeriod.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=162918487
2017-07-31 20:45:08 +01:00
tonihei
1bc01c09ee Add fake adaptive media period.
This class extends the existing FakeMediaPeriod by using a ChunkSampleStream
with chunks from a FakeChunkSource instead of a FakeSampleStream.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=162916656
2017-07-31 20:43:51 +01:00
andrewlewis
554a399407 Switch to non-deprecated player constants
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=162605429
2017-07-21 11:20:07 +01:00
tonihei
b950a5e874 Add fake chunk source.
This chunk source retuns SimpleSampleMediaChunks based on the data definition
of a FakeAdaptiveDataSet.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=162351688
2017-07-19 14:11:51 +01:00
tonihei
0717c3502f Extend Clock interface with sleep method and add FakeClock.
The FakeClock allows to simulate timing behaviour including sleep time
for test cases.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=162345258
2017-07-19 14:06:18 +01:00
tonihei
958f12e2cc Make isReady of FakeRenderer more realistic.
Currently the renderer is only ready when the input stream has more data to
read. Actual renderers, however, are also ready as long as their output buffer
contains some audio/video samples to play, roughly corresponding to the fact
that the playback time hasn't reached the timestamp of the last buffered
sample. Added a isready flag to FakeRenderer to simulate this behaviour.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=162343074
2017-07-19 14:04:58 +01:00
tonihei
1d046d5da8 Fix chunk count bug in FakeAdaptiveDataSet.
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=162331762
2017-07-19 14:02:24 +01:00
tonihei
f77e96bca8 Allow to extend FakeDataSource.
Extensions can perform additional actions whenever data is read (e.g. sleeping
to simulate bandwidth restrictions).

Additionally, the factory class can also be overwritten and allows to set the
FakeDataSet later in case it is not available right away.

Moreover, this class now also uses a transfer listener similar to all real data sources.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=162326000
2017-07-19 14:01:03 +01:00
tonihei
81048ee7af Add byte offset variable to fake data segments.
The value is automatically set at creation and allows simpler access to the
faked data position within the source.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=162218095
2017-07-17 23:17:43 +01:00
tonihei
91341df7b0 Add fake adaptive data set.
This class defines the data of an adaptive media source. It currently has
chunks of equal length and size corresponding to the declared average bitrate
of the Formats.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=162208008
2017-07-17 23:16:32 +01:00
tonihei
508db5fd0a Allow multiple Formats per TrackGroup in testutil fake classes.
This enables adaptive media test cases using TrackGroups with multiple
Formats.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=162182005
2017-07-17 23:08:52 +01:00
tonihei
8399de4706 Move FakeDataSet to seperate class.
This allows to create extensions of FakeDataSet and also simplifies the
FakeDataSource class.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=162180952
2017-07-17 23:07:38 +01:00