3354 Commits

Author SHA1 Message Date
andrewlewis
41028fafba Workaround late event delivery from IMA
Remove assertions in pauseAd()/playAd(), which can fail if events are delivered
after detaching the player, and log warnings instead.

Use whether IMA has sent CONTENT_PAUSE_REQUESTED/CONTENT_RESUME_REQUESTED to
determine whether we pause/resume the AdsManager, matching the IMA
documentation.

Also clean up use of player.isPlayingAd vs playingAd.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=162364751
2017-07-19 14:14:26 +01:00
olly
078c57413b Correctly reset the upstream format from SampleQueues in HLS
When resetting a SampleQueue, by default the upstream format
is not cleared. This is necessary for progressive playbacks,
since (a) the formats never change, and (b) the extractors
only output them once. So when a seek occurs, it's necessary
to clear all sample data from the queue, but retain the current
upstream format.

Uniquely for HLS, the media in a SampleQueue that we may read
from can be in a format not supported by the consuming renderers.
We clear all the sample data from the queue in this case, but
not the upstream format. Since we have an optimization that
allows the upstream format to be read in advance of another
sample being written into the queue, this can result in an
unsupported format being read by a consuming renderer. This
change ensures the upstream format is correctly cleared in the
problematic case.

Issue: #3079

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=162360267
2017-07-19 14:13:09 +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
fb2dbf2c77 Use Clock in DefaultBandwidthMeter instead of SystemClock.
The default behaviour stays the same as Clock.DEFAULT == SystemClock. And it
enables bandwidth measurements in tests with simulated clocks.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=162350852
2017-07-19 14:10:29 +01:00
tonihei
3ff9695a73 Move getBufferedPositionUs into SequenceableLoader.
All implementations of SequenceableLoader already implement this method.
Moreover, all composite media periods contained an exact copy of an
implementation that now moved to CompositeSequencableLoader.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=162349083
2017-07-19 14:08:59 +01:00
olly
e26b8824dd Add Downloader for progressive content
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=162348129
2017-07-19 14:07:38 +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
olly
4fd516e35b Make MediaSessionConnector depend only on ExoPlayer
This is possible to do without passing the player instance to
custom action providers through their constructors, given we
no longer have a MuteActionProvider. Passing the player through
the constructors generalizes better to such cases, however, so
feels like the right thing to do.

It's also possible to use generics and keep passing the player
instance via the CustomActionProvider methods, but this adds
some unnecessary complexity.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=162333043
2017-07-19 14:03:38 +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
andrewlewis
c28a2a4100 Fix content position for postroll ads
The position returned by getContentPosition() could be C.TIME_END_OF_SOURCE.
Fix the content position stored in MediaPeriodInfos for postroll ads to be the
duration of the containing period.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=162322339
2017-07-19 13:59:38 +01:00
bachinger
5be79d4f42 Media session extension to connect ExoPlayer with the MediaSession of the
framework.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=162245883
2017-07-17 23:22:41 +01:00
olly
387720d182 Allow module registrations + log player release
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=162223981
2017-07-17 23:21:34 +01:00
olly
da79dec6c1 Make it a bit easier to sideload a subtitle
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=162221516
2017-07-17 23:20:20 +01:00
olly
daa214f82a Reinstate gradle instructions for IMA extension
Note: Wont work quite yet; we need to actually do a
release for the instructions to become effective.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=162220939
2017-07-17 23:19: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
olly
009369bf94 Reduce calls from TsExtractor to ExtractorInput.read
We currently read at most 5 packets at a time from the
extractor input. Whether this is inefficient depends on
how efficiently the underlying DataSource handles lots
of small reads. It seems likely, however, that DataSource
implementations will in general more efficiently handle
fewer larger reads, and in the case of this extractor
it's trivial to do this.

Notes:
- The change appears to make little difference in my
  testing with DefaultHttpDataSource, although analysis
  in #3040 suggests that it does help.
- This change shouldn't have any negative implications
  (i.e. at worst it should be neutral wrt performance). In
  particular it should not make buffering any more likely,
  because the underlying DataSource should return fewer
  bytes than are being requested in the case that it
  cannot fully satisfy the requested amount.

Issue: #3040

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=162206761
2017-07-17 23:13:48 +01:00
andrewlewis
6041b0fe9c Handle VAST loading errors by playing content
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=162204327
2017-07-17 23:12:34 +01:00
andrewlewis
706d4e51fe Don't offset the first period holder by the start position
If seek is called for a non-seekable period, when the period is prepared the
start position will be updated from the seek position to zero. Because the
start position is part of the renderer offset for the first loaded period
holder, after the update the renderer offset start position and the new start
position would no longer cancel out, leading to the player position being
negative.

The first period holder's renderer offset is the fixed base offset (60 seconds)
plus its start position, but the start position is always subtracted. Avoid
subtracting the start position for the first period holder so that when it
changes there is no need to update the renderer offset.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=162188133
2017-07-17 23:10:06 +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
aquilescanta
055abc7592 Detect playlist stuck and playlist reset conditions in HLS
This CL aims that the player fails upon:

- Playlist that don't change in a suspiciously long time,
  which might mean there are server side issues.
- Playlist with a media sequence lower that its last snapshot
  and no overlapping segments.

This two error conditions are propagated through the renderer,
but not through MediaSource#maybeThrowSourceInfoRefreshError.

Issue:#2872

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=160899995
2017-07-15 22:43:15 +01:00
olly
1855423734 Simplify + optimize VorbisBitArray
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=161796758
2017-07-15 22:27:50 +01:00
olly
977fb225e3 Minor tweak to demo app
"Default (none)" is sometimes just wrong, since the track
selector may attempt to select a track even if it exceeds
the renderer's capabilities. Just "Default", as it used to
be, was more accurate.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=161695241
2017-07-15 22:27:44 +01:00
olly
a39ab8161e Fix FlacStreamInfo to not call readBits with a >32 value
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=161677399
2017-07-15 22:27:37 +01:00
olly
17e73bdc78 Optimize ParsableNalUnitBitArray
Apply the same learnings as in ParsableBitArray.

Issue: #3040

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=161674119
2017-07-15 22:27:31 +01:00
olly
fba0546774 Optimize ParsableBitArray
ParsableBitArray.readBit in particular was doing an excessive
amount of work. The new implementation is ~20% faster on desktop.

Issue: #3040

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=161666420
2017-07-15 22:27:26 +01:00
olly
4cb5b34977 Don't use ParsableBitArray to parse TS packet headers
Really low hanging fruit optimization for TS extraction.

ParsableBitArray is quite expensive. In particular readBits
contains at least 2 if blocks and a for loop, and was being
called 5 times per 188 byte packet (4 times via readBit). A
separate change will follow that optimizes readBit, but for
this particular case there's no real value to using a
ParsableBitArray anyway; use of ParsableBitArray IMO only
really becomes useful when you need to parse a bitstream more
than 4 bytes long, or where parsing the bitstream requires
some control flow (if/for) to parse.

There are probably other places where we're using
ParsableBitArray over-zealously. I'll roll that into a
tracking bug for looking in more detail at all extractors.

Issue: #3040

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=161650940
2017-07-15 22:27:20 +01:00
olly
2665e42f85 Correctly propagate format identifier for CEA-608 in HLS
Issue: #3033

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=161512537
2017-07-15 22:27:13 +01:00
olly
4233f81ed7 Misc tweaks to UI components
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=161454491
2017-07-15 22:27:06 +01:00
olly
f94db63366 Fix reporting of width/height
1. maybeRenotifyVideoSizeChanged should report reported* variables
2. Add check into maybeNotifyVideoSizeChanged to suppress reporting
   in the case that the width and height are still unknown.

Issue: #3007

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=160879625
2017-07-15 22:26:39 +01:00
olly
bf5495f2f5 Optimize in-buffer seeking for HLS
Also move to using an array to hold the SampleQueues,
as we've moved to doing in ExtractorMediaPeriod.

Issue: #551

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=161972990
2017-07-15 17:33:33 +01:00
olly
a2ffcec200 Fix NPE setting drm scheme type
drmInitData can be null in DASH if all of the init data is
specified at the manifest level instead. I took a look at
injecting the manifest format into the extractors, so that
we can actually copy the scheme type into it, but that's
at least non-trivial enough to delay for a subsequent CL.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=161956246
2017-07-15 17:32:28 +01:00
olly
0869802173 Show last seek position when playing an ad
We'd normally expect playback controls to be hidden during
ad playback, although if they are visible for whatever reason,
it makes sense to set the position to the current content
position now that we have it.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=161950098
2017-07-15 17:31:01 +01:00
matttt
7b20e130ce Allow a direct executor for Cronet's response handling thread.
We want to experiment with a direct executor to avoid thread hops between the
network thread and the response handling thread. This change is needed to do
so.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=161812382
2017-07-15 17:29:41 +01:00
andrewlewis
68e5e91735 Store the resume position even if the window is not seekable
Note: this temporarily exposes a bug where seeking a non-seekable source leads
to the player position being negative before playback starts.

Issue: #2655

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=161801111
2017-07-15 17:28:20 +01:00
olly
8378c3dc1f Simplify + optimize VorbisBitArray
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=161796758
2017-07-15 17:26:55 +01:00
eguven
90398c5811 Check if thread is interrupted before opening connection
On an old version of okhttp, opening connection clears the thread interrupt flag silently. This is a workaround
to reduce the effect of the bug.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=161784435
2017-07-15 17:24:09 +01:00
andrewlewis
70c5bf7052 Support resuming ads
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=161778560
2017-07-15 17:22:52 +01:00
andrewlewis
6c74a31556 Support resuming content after ads
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=161775394
2017-07-15 17:21:32 +01:00
olly
4f2fae4fba Minor tweak to demo app
"Default (none)" is sometimes just wrong, since the track
selector may attempt to select a track even if it exceeds
the renderer's capabilities. Just "Default", as it used to
be, was more accurate.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=161695241
2017-07-15 17:20:08 +01:00
olly
0da2299c49 Fix FlacStreamInfo to not call readBits with a >32 value
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=161677399
2017-07-12 18:29:31 +01:00
olly
5885f34d12 Optimize ParsableNalUnitBitArray
Apply the same learnings as in ParsableBitArray.

Issue: #3040

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=161674119
2017-07-12 18:28:20 +01:00
olly
01c0ccbdbd Optimize ParsableBitArray
ParsableBitArray.readBit in particular was doing an excessive
amount of work. The new implementation is ~20% faster on desktop.

Issue: #3040

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=161666420
2017-07-12 18:27:08 +01:00
olly
2b1614cc7b Don't use ParsableBitArray to parse TS packet headers
Really low hanging fruit optimization for TS extraction.

ParsableBitArray is quite expensive. In particular readBits
contains at least 2 if blocks and a for loop, and was being
called 5 times per 188 byte packet (4 times via readBit). A
separate change will follow that optimizes readBit, but for
this particular case there's no real value to using a
ParsableBitArray anyway; use of ParsableBitArray IMO only
really becomes useful when you need to parse a bitstream more
than 4 bytes long, or where parsing the bitstream requires
some control flow (if/for) to parse.

There are probably other places where we're using
ParsableBitArray over-zealously. I'll roll that into a
tracking bug for looking in more detail at all extractors.

Issue: #3040

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=161650940
2017-07-12 18:24:23 +01:00
olly
ecc8f6c4fa Upgrade dependencies
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=161648060
2017-07-12 18:23:11 +01:00
aquilescanta
f72833476e Add DRM support to RendererCapabilities
This CL also makes DefaultTrackSelector take it into account when RendererCapabilities
sets it to unsupported.

A following CL could add a DefaultTrackSelector parameter to force DRM "known support" for specific track types.

Issue:#1661
Issue:#1989
Issue:#2089

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=161556467
2017-07-12 18:22:04 +01:00
olly
3c5688de73 Optimize in-queue seeking when non-AV tracks are present
Let's do it this way for now. Note there's an implicit
assumption in here that non-AV tracks consist of only
key-frames, but I think we'll not encounter any issues
in the real world as a result, we already make this
assumption in ChunkSampleStream, and actually tagging
every queue with this information explicitly is a very
painful amount of plumbing.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=161545383
2017-07-12 18:20:54 +01:00