426 Commits

Author SHA1 Message Date
tonihei
53e06e636d Clean up ExoHostedTest.
Some test specific things, like adding an extra listener or adding decoder
counters are currently handled by ExoHostedTest. They can be moved to the
classes actually using them to clean up ExoHostedTest.

This also adds more flexibility to further generic clean-up in onTestFinished.

Also, reorder player setup to what ExoPlayerTestRunner is doing.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=219446276
2018-10-31 13:57:37 +00:00
olly
dbf5b073a6 Network type cleanup
1. Remove option to pass null context to Util.getNetworkType. IMO it's
   clearer for the caller to just not call the method in this case.
2. Stop using deprecated DefaultBandwidthMeter.Builder constructor in
   all but one place.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=217147091
2018-10-18 23:17:16 +01:00
olly
842f622d29 Allow codec flushing without re-initialization
For decoder reuse, we want disable() to flush the decoder. However,
if the flush needs to release the decoder for some reason, it seems
non-ideal to immediately re-initialize it. Re-initialization can
also throw ExoPlaybackException, which we don't want for disabling.

This change allows a variant of flush that wont re-initialize the
decoder if it has to be released, which will be used from disable().

Issue: #2826

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=216834862
2018-10-15 09:33:37 +01:00
tonihei
711f9f8b6a Add test action to wait for an isLoading change.
This allows to wait until loading started or finished.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=215704424
2018-10-15 09:15:50 +01:00
tonihei
46731cdd1d Fix prepare position of DeferredMediaPeriods for windows with non-zero offset.
If we prepare a deferred media period before the actual timeline is available,
we either prepare with position zero (= the default) or with a non-zero
initial seek position.

So far, the zero (default) position got replaced by the actual default position
(including any potential non-zero window offset) when the timeline became known.

However, a non-zero initial seek position was not corrected by the non-zero
window offset. This is fixed by this change.

Related to that, we always assumed that the deferred media period will the
first period in the actual timeline. This is not true if we prepare with an
offset (either because of an initial seek position or because of a default
window position). So, we also determine the actual first period when the
timeline becomes known.

Issue:#4873

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=215213030
2018-10-01 19:34:29 +01:00
tonihei
e25b7d2148 Add wrapper for Log messages to allow settig the log level.
Currently there is no way to disable (or reduce) the logcat output generated
by ExoPlayer.

Issue:#4665

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=213421072
2018-09-20 12:12:21 +01:00
tonihei
1284f9ea4d Add Nullable to message payload.
Not having this annotation may cause Kotlin implementations to fail.

Issue:#4802

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=212980643
2018-09-17 17:47:11 +01:00
olly
46af49e282 Clean up easy cases of downstream format notification
- This makes it so that onDownstreamFormatChanged will occur before the corresponding
  renderer event. This was not previously the case, since the renderer would typically
  read the format (and report its event), then a sample (causing the
  onDownstreamFormatChanged event).
- The remaining ones to update are ChunkSampleStream (DASH + HLS), which will be done
  in a way that fixes #4533, and HLS.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=212434874
2018-09-12 15:17:19 +01:00
olly
38386c480a Be explicit about character set.
The default character set is always UTF-8 anyway on Android, but
we don't want our code to behave any differently where it's not
(e.g. robolectric test runs could potentially run in an environment
where UTF-8 isn't the default?).

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=211953885
2018-09-12 14:58:33 +01:00
tonihei
77a529f0ed Add static Util.EMPTY_BYTE_ARRAY
This prevents repeated instantiation of empty arrays.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=211941723
2018-09-12 14:57:01 +01:00
tonihei
6b9e1824ad Extend updateSelectedTrack method with additional information.
This provides the list of currently buffered media chunks and iterators over
the potential next chunks to the track selection. Having these two parameters
enables more advanced decision logic based on this data.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=210551812
2018-09-03 14:04:45 +01:00
olly
924a76d532 Clean up use of deprecated APIs
- Add @Deprecated on overrides of deprecated method.
- Suppress deprecation warnings where appropriate.
- Use non-deprecated alternatives where appropriate.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=210092434
2018-08-24 16:12:44 +01:00
olly
0da7f6ca08 Use EventLogger in ExoHostedTest
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=210082909
2018-08-24 16:11:07 +01:00
olly
38f2f352f9 Move playback tests off deprecated APIs
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=210077548
2018-08-24 16:05:40 +01:00
olly
4d8a5c44b3 Fix some more lint issues
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=209947034
2018-08-24 15:59:32 +01:00
tonihei
74e2384fb6 Add response headers to LoadEventInfo.
The response headers of the last load are available from the loading source
when creating media source events and can be easily forwarded.

Issue:#4361
Issue:#4615

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=209900693
2018-08-24 15:55:01 +01:00
tonihei
bf43cca302 Fix flaky ExoPlayerTest tests.
Some tests were flaky because of the PlayUntilPosition action which called
player.setPlayWhenReady from the wrong thread. Also fixed some other misc
flakiness.

ExoPlayerTest seems to be non-flaky now (tested with 10000 runs).

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=209743076
2018-08-24 15:39:49 +01:00
tonihei
d51b98dd1f Replace period index with uid in MediaPeriodId.
The MediaPeriodId with index is only properly defined together with a
timeline containing the index. Changing it to the period uid allows to use
the MediaPeriodId independent of the corresponding timeline.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=209430257
2018-08-24 15:32:11 +01:00
eguven
b58f6940eb Add VideoFrameMetadataListener
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=209193233
2018-08-24 15:21:03 +01:00
olly
bd8a956d53 Use lamdas everywhere
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=209162373
2018-08-24 15:19:30 +01:00
aquilescanta
d5c7bff643 Use LoadErrorHandlingPolicy in SsMediaSource and DashMediaSource
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=208020030
2018-08-13 13:49:45 +01:00
olly
af507efb2a Deprecate/remove DataSource constructors that accept listeners
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=207713478
2018-08-07 16:28:02 +01:00
hoangtc
077f2c3036 Supports seeking for TS Streams.
This CL adds support for seeking witin TS streams by using binary search. For
any seek timestamp, it tries to find the location in the stream where PCR
timestamp is close to the target timestamp, and return this position as the
seek position.

Github: #966.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=207529906
2018-08-06 14:35:12 +01:00
hoangtc
c3d8ad2488 Add supports for Seeking in ADTS format using a constant bitrate seekmap.
- Use ConstantBitrateSeeker to implement seeking for ADTS format. Since most
ADTS streams are VBR, we use the average bitrate of the first 1000 frames as
the average bit rate.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=207509651
2018-08-06 11:33:06 +01:00
eguven
45c1e9eef3 Add missing Nullable annotation Player.EventListener.onTimelineChanged
Issue: #4593

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=206911927
2018-08-01 13:49:21 +01:00
andrewlewis
5715960304 Add Context to SimpleExoPlayer factory methods
This is needed for implementing (optional) support for audio focus handling in a
later change.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=206899837
2018-08-01 13:49:21 +01:00
tonihei
ffdc17d0e0 Remove generic type parameter from TransferListener.
All known instances use DataSource as generic type and thus code can be simplified
by removing the generic type altogether.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=205798542
2018-07-24 14:56:45 +01:00
tonihei
a67c73650e Add helper method to get uid of timeline period.
This removes the need to populate the entire period for the common usage of
getting the uid from the period.

Also add default implementation to get period by uid.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=205638265
2018-07-23 12:22:57 +01:00
Oliver Woodman
badd9356f8 Refine use of KEY_OPERATING_RATE 2018-07-20 16:15:30 +01:00
ojw28
f4219b55e6
Merge pull request #3634 from jinminghe/bugfix/format
Set KEY_OPERATING_RATE for MediaCodecVideoRenderer.
2018-07-20 16:12:04 +01:00
tonihei
6aab2bdc55 Set bandwidth meter at player level.
This bandwidth meter is then forwarded to the track selection and as a transfer
listener to media and data sources.

When no bandwidth meter is specified in the ExoPlayerFactory methods, a static
singleton instance will be used.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=204881497
2018-07-17 20:32:59 +01:00
Jinming he
5cdb886db1 Address comments. 2018-07-16 21:36:00 +08:00
tonihei
2b1434dfcb Change DataSource.Type to a boolean.
There are only two types at the moment and we can therefore use a boolean.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=203937357
2018-07-11 14:53:14 +01:00
tonihei
acbe52d0d7 Forward TransferListener from MediaSources to DataSources.
This wires up recent changes of passing a transfer listener to the MediaSource and
allowing DataSources to accept new listeners.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=203280818
2018-07-06 14:35:17 +01:00
tonihei
abb4d6ff70 Use correct generics type bounds for TransferListener in MediaSources.
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=203260699
2018-07-06 14:32:46 +01:00
tonihei
97120bc6cb Add MediaChunkIterator for FakeAdaptiveDataSet.
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=203102464
2018-07-06 14:25:38 +01:00
tonihei
55ce085a0d Add transferInitializing to BaseDataSource.
This allows implementations to notify when the transfer is about to be started.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=203102117
2018-07-06 14:24:21 +01:00
tonihei
985160a47d Use BaseDataSource for all internal leaf data sources.
This allows all leaf data sources (i.e. ones which do not forward the requests
to other data sources) to accept multiple listeners.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=203097587
2018-07-06 14:23:02 +01:00
olly
e48b712a32 Fail tests quickly if they don't start within the host activity
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=202965785
2018-07-03 11:58:20 +01:00
tonihei
c8af6d176f Forward queue of media chunks to getNextChunk.
This allows to use this queue in the track selection in the future.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=202954871
2018-07-03 11:57:26 +01:00
tonihei
98afaa60d0 Forward TransferListener to media sources.
In the future, this allows to register the BandwidthMeter (managed by the player)
as a listener to all media transfers related to this media source.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=202643946
2018-07-03 11:47:15 +01:00
hoangtc
a916ad6a50 Refactor, move MetadataRetrieverTestRunner to testutil package.
- Make it looks more natural to have MetadataRetrieverTestRunner in the same
package as ExoPlayerTestRunner.
- Change moe_config script to remove the file MetadataRetrieverTestRunner,
instead of the folder.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=202626238
2018-06-29 12:10:54 +01:00
tonihei
dd14500eba Add url (after redirection) to LoadEventInfo.
This url is readily available when creating media source events (from the
data source) but so far not published to external listeners. This change
adds a new field to LoadEventInfo which corresponds to DataSource.getUri().

Issue:#2054

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=202459049
2018-06-28 16:18:50 +01:00
hoangtc
eb8c686243 Fix a bug with MetadataRetriever getMedatadata query.
When getMedatadata from an ExtractorMediaPeriod, due to the MediaPeriod refreshing its Timeline twice, the MetadataRetriever may wrongly reset periodIndex of the current trackGroup to C.TIME_UNSET, which makes it unable to handle subsequent metadata queries.

This CL changes the MetadataRetriever to keep track of periodUid of the current trackGroup instead of period index. PeriodUid is not changed on timeline refreshing, so is not prone the existing problem.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=201969350
2018-06-25 22:37:15 +01:00
tonihei
156e2317cc Deprecate Player.DefaultEventListener in favor of default no-ops in interface.
The DefaultEventListener was added for selective overrides. Now that Java 8
support is enabled, these selective listener overrides can be implemented
more easily and more flexible using default methods.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=201695490
2018-06-22 17:49:25 +01:00
hoangtc
8dbec616c4 Use isAtLeast() instead of (>=) to make the tests clearer.
Replace assertThat(a >= b).isTrue() with assertThat(a).isAtLeast(b) because it
reads more natural, and in case the assertion fails, it will print out the
actual values to help debugging.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=201371993
2018-06-20 18:34:22 +01:00
tonihei
4f2b596062 Allow to specify player looper at the time of ExoPlayer creation.
Currently, the looper of the thread the player is created on is used (or the
main looper if this thread doesn't have a looper). To allow more control over
the threading, this change lets users specificy the looper which must be used
to call player methods and which is used for event callbacks.

Issue:#4278

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=201331564
2018-06-20 18:05:52 +01:00
hoangtc
3d3ab1f72e Add VideoRendererOutputCapturer
Added a capturer that can capture output from video renderer into bitmaps. This
class uses SurfaceCapturer to setup a surface, then configures this surface as the
output for a video renderer. Once the output is set, it will capture the
output frames from the video renderer and return them as bitmaps.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=201148184
2018-06-20 18:00:03 +01:00
hoangtc
a0b4e58312 Update PixelCopySurfaceCapturerV24, uses only 1 copy step.
Currently, we are using 2 copy steps for PixelCopySurfaceCapturerV24:
- Copy from the source surface to a similarly sized bitmap (using PixelCopy API).
- Copy from the bitmap to a scaled bitmap, based on the given output size, using scaledBitmap API.
This CL merges the 2 steps and uses PixelCopy API to perform copy directly from
the source surface to the bitmap of the given output size.
However, since our test uses scaledBitmap API to create reference bitmap from original image, due to various Bitmap copy optimizations (filtering, antialiasing etc...) that are different between PixelCopy API and scaledBitmap API implementations, the result images cannot be the same. We can perform the our tests by asserting that their PSNR value is very high, which means they are very similar.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=199472005
2018-06-06 19:00:37 +01:00
tonihei
b6113763b4 Allow lazy preparation of child source in a concatenation.
This adds an optional parameter to ConcatenatingMediaSource to prepare
child sources only lazily when are needed. This is helpful for long playlists
of media sources with manifests to prevent a lot of simultaneous manifest
loads.

Issue:#3972

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=198855676
2018-06-05 12:33:31 +01:00