994 Commits

Author SHA1 Message Date
andrewlewis
51a3f214ed Fix handling of fetch errors for post-rolls
The ad break time in seconds from IMA was "-1" for postrolls, but this didn't
match C.TIME_END_OF_SOURCE in the ad group times array.

Handle an ad break time of -1 directly by mapping it onto the last ad group,
instead of trying to look it up in the array.

PiperOrigin-RevId: 312064886
2020-05-29 22:29:29 +01:00
andrewlewis
51b2a0f7a9 Add support for timing out ad preloading
Detect stuck buffering cases in ImaAdsLoader, and discard the ad group after
a timeout. This is intended to make the IMA extension more robust in the case
where an ad group unexpectedly doesn't load.

The timing out behavior is enabled by default but apps can choose to retain
the old behavior by setting an unset timeout on ImaAdsLoader.Builder.

PiperOrigin-RevId: 311729798
2020-05-29 22:29:14 +01:00
andrewlewis
e8c7405545 Upgrade IMA SDK to 3.19.0
PiperOrigin-RevId: 311106612
2020-05-29 22:20:00 +01:00
andrewlewis
e482aa2be8 Fix method ordering in ImaAdsLoader
Put static methods at the end.

Also add a couple of missing parameter name comments.

PiperOrigin-RevId: 311077684
2020-05-29 22:18:15 +01:00
andrewlewis
929b60e209 Improve DEBUG logging in ImaAdsLoader
Log content progress events, as these are helpful to debug triggering of events
based on the content progress.

Don't log AD_PROGRESS events as they occur several times per second while ads
are playing, and the verbosity makes logs difficult to read.

PiperOrigin-RevId: 311077302
2020-05-29 22:17:51 +01:00
andrewlewis
5529c124fe Remove deprecated symbols in ImaAdsLoader
PiperOrigin-RevId: 310901647
2020-05-29 22:17:24 +01:00
andrewlewis
8c108fb5fd Upgrade IMA SDK to 3.18.2
PiperOrigin-RevId: 310883076
2020-05-29 22:17:00 +01:00
andrewlewis
3b99a84dae Migrate to new IMA preloading APIs
issue:#6429
PiperOrigin-RevId: 309906760
2020-05-29 22:15:30 +01:00
andrewlewis
de03e389c0 Enable nullness checking for the IMA extension
adPlaybackState is now non-null, and the uninitialized case is covered by a new
boolean hasAdPlaybackState. Position progress updates are now non-null and
initialized with IMA's VIDEO_TIME_NOT_READY constant.

Also fix some misc code issues:
- Remove empty branch for SmoothStreaming (Android Studio warns about this).
- Tidy onTimelineChanged and onPositionDiscontinuity and the methods they call
  to improve naming.
- Remove logging for IMA events after release, as these methods are expected to
  be called in the current IMA SDK behavior.

PiperOrigin-RevId: 308977116
2020-05-29 21:58:59 +01:00
andrewlewis
6e66dc02fb Replace IMA ad tag fakes with mocks
The mocking setup is quite messy/unclear compared to the fakes, but it seems
worth switching over because IMA API changes have already required changes
to fakes in the past, and there are more API changes in the version we are
about to upgrade to. This change should generally remove the need to keep
the fakes up-to-date.

PiperOrigin-RevId: 308819176
2020-05-29 21:58:46 +01:00
tonihei
67d1b728d3 Clarify/fix position reference points for AdPlaybackState.
The positions were interchangeably used with window and period
positions. This change more clearly ensures that all positions in the
AdPlaybackState are based on periods and that we use the right adjustments
for all usages.

PiperOrigin-RevId: 297811633
2020-05-29 21:50:07 +01:00
tonihei
d1b900604a Add test to ensure AdsLoader is initialized.
This tests explicitly that initialization happens even if the Timeline
is a placeholder.

No other change is needed. While the Timeline is still a placeholder
ImaAdsLoader.getCurrentPeriodPosition will return 0 and trigger
pre-rolls (intended behaviour) and it doesn't matter whether the
actual initial period position may be somewhere else.

PiperOrigin-RevId: 298833867
2020-05-29 21:42:22 +01:00
Andrew Lewis
03be1551a7 Clean up player event handling
This change is similar to e8293b92d877bd6e5a00606358db610d6fb7a4d6
but without relying on new player events that haven't been released
yet, to make it easier to merge changes related to ImaAdsLoader on
top.
2020-05-29 21:15:17 +01:00
andrewlewis
b3de2b08d4 Inline ENABLE_PRELOADING
ImaAdsLoader relies on preloading being enabled (it doesn't
work without it) so we may as well remove the constant to
avoid potential confusion.

PiperOrigin-RevId: 284951356
2020-05-29 21:15:17 +01:00
bachinger
68059070f4 Add missing nullable annotations
The MediaSessionConnector gets a Bundle passed to the MediaSession.Callback
from the framework which can be null. This needs to be properly annotated
with @Nullable.

Issue: #7234
PiperOrigin-RevId: 307822764
2020-05-29 21:15:17 +01:00
Oliver Woodman
bc96d3a93c Merge pull request #7367 from inv3rse:keep-paused-state-during-buffering
PiperOrigin-RevId: 311623784
2020-05-29 21:15:17 +01:00
Oliver Woodman
5f6a489bd1 Merge pull request #7324 from tpiDev:cronet/migrate-to-play-services-17-0-0
PiperOrigin-RevId: 310115628
2020-05-29 21:15:17 +01:00
olly
4862c7e6a8 Upgrade OkHttp to 3.12.11.
PiperOrigin-RevId: 310114401
2020-05-29 21:15:17 +01:00
olly
d1ff984670 CronetDataSource: Use standard InterruptedIOException
PiperOrigin-RevId: 309710359
2020-05-29 21:15:17 +01:00
vigneshv
8760424d76 av1_extension: Add a heuristic to determine default thread count
Android scheduler has performance issues when a device has a
combiation of big/medium/little cores. Add a heuristic to set the
default number of threads used for deocding to the number of
"performance" (i.e. big) cores.

PiperOrigin-RevId: 308683989
2020-05-27 20:28:37 +01:00
andrewlewis
f052e89a8f Pass app context to the IMA SDK
Notes: this doesn't fix the current issue where the component containing the
ad overlay view leaks, but is good practice anyway.
PiperOrigin-RevId: 308582036
2020-05-27 20:23:57 +01:00
olly
f95a0caec3 Update misc dependencies
PiperOrigin-RevId: 305503804
2020-04-08 21:53:45 +01:00
olly
1f4d37431e Upgrade cast dependency
Issue: #7191
PiperOrigin-RevId: 305502293
2020-04-08 21:52:38 +01:00
olly
69ca534935 Parse opus gain correctly as a signed value
Issue: #7046
PiperOrigin-RevId: 303354941
2020-03-30 18:31:24 +01:00
olly
3fd7d214cd Consistency fixes for FFmpeg extension instructions
PiperOrigin-RevId: 303316976
2020-03-30 18:31:24 +01:00
olly
a39715d323 Improve logging
- Make sure logging of UnknownHostException indicates the failure reason
- Indent stack traces inside event blocks in EventLogger
- Don't log media URLs

PiperOrigin-RevId: 302007601
2020-03-30 18:27:14 +01:00
krocard
40d5db0460 Add support for x86_64 for the ffmpeg extension
Requested by https://github.com/google/ExoPlayer/issues/7058.
Additionally move one of the common option in COMMON_OPTIONS.

PiperOrigin-RevId: 299862479
2020-03-30 14:26:33 +01:00
Oliver Woodman
e2a6775ea4 Merge pull request #6999 from xufuji456:dev-v2
PiperOrigin-RevId: 298544278
2020-03-30 14:25:03 +01:00
vigneshv
265670cf93 Add ReleaseInputBuffer callback
The release_input_buffer callback will be called when the library
is done consuming an "input buffer". The buffer passed into
EnqueueFrame must be kept valid until this callback is called. If
frame parallel is false, then this callback can be nullptr (in
this case the buffer has to be kept valid until the next call to
DequeueFrame). If frame parallel is true, this callback cannot be
nullptr.

PiperOrigin-RevId: 296276083
2020-03-30 13:46:50 +01:00
olly
908a76e851 Change libgav1's frame buffer callback API.
1. Have frame buffer callbacks return Libgav1StatusCode instead of int.
The 0 (success), -1 (failure) return value convention is less obvious.
Note: The callers of frame buffer callbacks,
BufferPool::OnFrameBufferSizeChanged() and YuvBuffer::Realloc(),
currently return bool, so more work is needed to propagate the frame
buffer callbacks' Libgav1StatusCode return value to the Decoder API.

2. Allow the FrameBufferSizeChangedCallback to be omitted if the frame
buffer size information is not useful to the application.

3. Remove the old (version 1) frame buffer callback API. Remove the
frame buffer callback adaptor.

frame_buffer2.h is renamed frame_buffer.h.
Libgav1FrameBuffer2 is renamed Libgav1FrameBuffer.
GetFrameBufferCallback2 and ReleaseFrameBufferCallback2 are renamed
GetFrameBufferCallback and ReleaseFrameBufferCallback.

PiperOrigin-RevId: 295971183
2020-03-30 13:44:13 +01:00
olly
75bd4ebc18 Use &id_ as buffer_private_data for libgav1.
This avoids the issue of whether it is defined behaviour to cast an
arbitrary int (or even intptr_t) value to a void* pointer. This is the
original approach used before commit 0915998add5918214fa0282a69b50a159168a6d5.

PiperOrigin-RevId: 295552115
2020-03-30 13:44:05 +01:00
olly
766b383d27 Use libgav1 frame buffer callback helper functions
Libgav1 recently added the ComputeFrameBufferInfo() and SetFrameBuffer()
helper functions for writing frame buffer callbacks. Using them
simplifies the Libgav1GetFrameBuffer() function.

Also resurrect the AlignTo16() function.

PiperOrigin-RevId: 295548330
2020-03-30 13:43:58 +01:00
olly
b73f6b6ef0 gav1_jni: fix pointer->int conversion warnings
fixes:
gav1_jni.cc:446:25: error: cast from pointer to smaller type 'int' loses information
  const int buffer_id = reinterpret_cast<int>(buffer_private_data);
                        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
gav1_jni.cc:730:9: error: cast from pointer to smaller type 'int' loses information
        reinterpret_cast<int>(decoder_buffer->buffer_private_data);
        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

after 0915998add

PiperOrigin-RevId: 295211245
2020-03-30 13:43:47 +01:00
olly
0acc95cfbb Cast void* to JniContext* using static_cast.
static_cast is more appropriate than reinrerpret_cast for casting from
void* to JniContext*. See Section 7.2.1 (page 173) in The C++
Programming Language, 4th Edition and
https://stackoverflow.com/questions/310451/should-i-use-static-cast-or-reinterpret-cast-when-casting-a-void-to-whatever

PiperOrigin-RevId: 293812940
2020-03-30 13:43:39 +01:00
olly
11635191a6 Switch to new libgav1 frame buffer callback API.
The new code in Libgav1GetFrameBuffer is copied from
libgav1/src/frame_buffer_callback_adaptor.cc. It may become libgav1
utility functions available to libgav1 clients in the future.

The Libgav1FrameBuffer struct in the old frame buffer callback API is
defined as follows:

  typedef struct Libgav1FrameBuffer {
    uint8_t* data[3];
    size_t size[3];
    void* private_data;
  } Libgav1FrameBuffer;

Copy these three fields to the JniFrameBuffer class as private data
members and add the RawBuffer() and Id() getter methods.

The existing AlignTo16 function is replaced by the copied Align template
function.

PiperOrigin-RevId: 293709205
2020-03-30 13:43:27 +01:00
kimvde
67a748f47d FLAC extension: remove sample rate check
This check is not needed because the FLAC specification does not
restrict the sample rate value and because the extension reads files
with other sample rates properly.

PiperOrigin-RevId: 292909391
2020-02-13 15:50:20 +00:00
bachinger
ee2ad943d7 annotate nullabilty of CommandReceiver
Issue: #6938
PiperOrigin-RevId: 292415853
2020-02-01 19:39:43 +00:00
olly
fbe840e880 Upgrade OkHttp dependency to 3.12.8
OkHttp 3.12.7 introduced a regression, which was fixed in 3.12.8.

PiperOrigin-RevId: 291695577
2020-01-27 19:08:45 +00:00
olly
7aefaa7d68 extensions/av1: use -O2 for release builds
+ force arm (over thumb) mode for 32-bit builds

-O2 improves performance ~30-40% over the default -Oz depending on the
resolution; this is similar to what is done for vp9 which uses -O3.

PiperOrigin-RevId: 290318121
2020-01-27 19:06:17 +00:00
olly
dfa4d55f50 Fix DownloadService resumption
- DownloadManagerHelper now passes all downloads to the
  DownloadService when the service is attached (and once
  the downloads are known). The service then starts the
  foreground notification updater if necessary. This fixes
  the ref'd issue.
- Don't call getScheduler() if the service is background
  only. This was already documented to be the case on the
  DownloadService constructor.
- If the service is started in the foreground on SDK level
  26 and higher, satisfy the condition to move the service
  to the foreground in onStartCommand rather than in stop().
  It's much more obviously correct, and should produce the
  same end result.

Issue: #6798
PiperOrigin-RevId: 290050024
2020-01-17 14:01:38 +00:00
olly
ca11e56fe6 Add tests to validate FLAC decoder output
PiperOrigin-RevId: 289091494
2020-01-17 13:57:41 +00:00
olly
4e767faa1c Fix extension FLAC decoder to correctly handle non-16-bit depths
PiperOrigin-RevId: 288860159
2020-01-17 13:56:35 +00:00
kimvde
7fe55cd468 Use FlacLibrary.isAvailable in FlacExtractor selection
PiperOrigin-RevId: 288667790
2020-01-17 13:55:40 +00:00
olly
bf9a61d62f Upgrade OkHttp library to fix HTTP2 issue
Issue: #4078
PiperOrigin-RevId: 288651166
2020-01-17 13:55:24 +00:00
kimvde
d1839f141a Add comment explaining FlacBinarySearchSeeker output
PiperOrigin-RevId: 288464154
2020-01-17 13:54:58 +00:00
olly
97be06529c Use MIME types rather than PCM encodings for ALAW and MLAW
PiperOrigin-RevId: 287999703
2020-01-17 13:52:47 +00:00
andrewlewis
3cf88bb48b Fix typos
PiperOrigin-RevId: 287810018
2020-01-17 13:52:06 +00:00
kimvde
910bd8bdc5 Implement binary search seeking for FLAC extractor
PiperOrigin-RevId: 284814594
2020-01-17 13:42:07 +00:00
kimvde
54413c26d4 Make metadata field nullable in FlacStreamMetadata
This makes the format metadata null (instead of an empty Metadata
object) when it is not provided, and is therefore consistent with the
other extractors behavior.

PiperOrigin-RevId: 284171148
2020-01-17 13:37:58 +00:00
andrewlewis
023e141be8 Verify metadata in extractor tests
PiperOrigin-RevId: 283960017
2020-01-17 13:36:40 +00:00