11606 Commits

Author SHA1 Message Date
bachinger
095e2feb20 Enable source code formatting
PiperOrigin-RevId: 375979170
2021-05-27 10:42:22 +01:00
olly
ee2af43a54 Fix file formatting
PiperOrigin-RevId: 375919564
2021-05-27 10:40:54 +01:00
olly
4b0c987675 Fix StyledPlayerView detachment
Issue: #8985
#minor-release
PiperOrigin-RevId: 375913914
2021-05-27 10:40:14 +01:00
claincly
614f9d8d55 Rename RtspMessageChannel.openSocket() to open().
The method openSocket in RtspMessageChannel does not actually open a socket.
The 'open' term refers more to opening the message channel.

#minor-release

PiperOrigin-RevId: 375908999
2021-05-27 10:38:56 +01:00
claincly
cfb90e4b70 Remove the default RTSP message handling off playback thread.
The callbacks received RTSP messages and RTSP sending errors are now invoked
directly from RtspMessageChannel's internal threads. It's up to the handler
implementation to decide which thread to handle the messages.

#minor-release

PiperOrigin-RevId: 375908282
2021-05-27 10:38:17 +01:00
claincly
68b2875a42 Move RTP packet forwarding off playback thread.
Previously, RTSP interleaved binary data is posted onto the playback thread
for handling, the playback thread then adds the received data to a queue.
A loader thread will later dequeue the data and process it.

In this CL, the binary data is sent through a separate listener, on
RtspMessageChannel's RTSP receiving thread.

#minor-release

PiperOrigin-RevId: 375907609
2021-05-27 10:37:39 +01:00
claincly
4a780fb90a Allow RtspHeaders to take multiple header values under the same name.
Some RTSP servers will offer multiple WWW-Authenticate options. We wanted to
be able to pick them up.

#minor-release

PiperOrigin-RevId: 375907276
2021-05-27 10:37:00 +01:00
ibaker
e7516fe4e0 Throw from (pre)acquireSession if the DrmSessionManager isn't prepared
Currently acquireSession() fails with an NPE from
checkNotNull(exoMediaDrm). A follow-up change will result in exoMediaDrm
sometimes being non-null while prepareCount==0 (and in this case we
still want acquireSession() to fail).

preacquireSession() doesn't currently fail in a way the caller can
observe - the same NPE is thrown, but asynchronously and it doesn't
propagate out of the background thread. Throwing directly seems
preferable since it's a clear bug to be trying to preacquire sessions
from an unprepared/released manager.

PiperOrigin-RevId: 375906450
2021-05-27 10:36:20 +01:00
gyumin
beb13f62a7 Add FOLDER_TYPE_NONE to MediaMetadata
PiperOrigin-RevId: 375883879
2021-05-26 11:33:41 +01:00
klhyun
2e5c95e80a Remove obsolte TODO
PiperOrigin-RevId: 375830765
2021-05-26 11:33:04 +01:00
aquilescanta
ddc047c235 Add ColorInfo parsing support in MP4 files
PiperOrigin-RevId: 375719035
2021-05-26 11:32:29 +01:00
aquilescanta
2e8d4c9110 Extract function for mapping ColorInfo-related constants
PiperOrigin-RevId: 375705247
2021-05-26 11:31:52 +01:00
aquilescanta
4e5e654eff Add convenience method for getting the name of an error code
PiperOrigin-RevId: 375686596
2021-05-26 11:31:12 +01:00
samrobinson
6b7a0d8c11 Add year to MediaMetadata.
#minor-release

PiperOrigin-RevId: 375674759
2021-05-26 11:30:36 +01:00
aquilescanta
a1ecf3193a Assign ERROR_CODE_PARSING_* to ParsingException
PiperOrigin-RevId: 375515685
2021-05-26 11:29:53 +01:00
aquilescanta
6a8b9557cc Use ERROR_CODE_BEHIND_LIVE_WINDOW instead of instanceof checks
PiperOrigin-RevId: 375514509
2021-05-26 11:29:16 +01:00
Oliver Woodman
afe4217c1c Merge pull request #8943 from dlafayet:embeddedstyle2
PiperOrigin-RevId: 375484765
2021-05-26 11:28:37 +01:00
ibaker
926df59081 Defensively copy potentially mutable text in Cue constructor
Without this the Cue isn't deeply immutable, which can be a bit
surprising.

PiperOrigin-RevId: 375477571
2021-05-26 11:27:59 +01:00
ibaker
2081f4b466 Annotate Cue.Builder getters with @Pure
This reduces the null-checking required in a follow-up change.

PiperOrigin-RevId: 375468504
2021-05-26 11:27:22 +01:00
ibaker
5afc915e51 Don't restore DRM keys before releasing them
#minor-release

PiperOrigin-RevId: 375436117
2021-05-26 11:26:09 +01:00
samrobinson
8d550bf05b Add an extras bundle to MediaMetadata.
#minor-release

PiperOrigin-RevId: 375435339
2021-05-26 11:25:27 +01:00
aquilescanta
1fa61feb7e Migrate AtomParsers to using new ParserException fields
PiperOrigin-RevId: 375133184
2021-05-26 11:24:46 +01:00
samrobinson
e793a9031b Add a mediaType field to MediaMetadata.
#minor-release

PiperOrigin-RevId: 375097412
2021-05-21 18:25:49 +01:00
aquilescanta
3f33f10a32 Add ExtractorUtil method for checking input conditions
Unlike Assertions, the introduced method cannot be disabled and throws
a ParserException instead. This method is meant to replace regular
assertions (which throw RuntimeExceptions) which check input in the
parsing code.

PiperOrigin-RevId: 375085160
2021-05-21 18:24:37 +01:00
krocard
e8ca443389 Add to realease note DefaultDrmSessionEventListener's rename.
Its absence seems to have caused
https://github.com/google/ExoPlayer/issues/8969.

#minor-release

PiperOrigin-RevId: 375058222
2021-05-21 18:24:01 +01:00
olly
e9f66fc5d1 Replace internal dependencies on monolithic module
PiperOrigin-RevId: 375054051
2021-05-21 12:05:56 +01:00
tonihei
8ded11753e Fix issue where getFirstSampleIndex was called on spliced in chunks.
We need to avoid reading and skipping into preload chunks as they
may need to be discarded. The current code iterates over all chunks,
but this can be simplified by just checking the last chunk knowing
that the preload chunk must always be the last one.

As a result, we avoid calling getFirstSampleIndex on all chunks. This
is a bug since the method is not allowed to be called for chunks
that have been spliced in. This still leaves the smaller issue of
potentially calling this method for spliced-in preload chunks, which
will be solved separately.

Issue: #8937

#minor-release

PiperOrigin-RevId: 375053638
2021-05-21 12:05:23 +01:00
olly
8c9c0f8d3f Gradle cleanup #3
Tweak the way directories are passed

PiperOrigin-RevId: 374912886
2021-05-21 12:04:15 +01:00
aquilescanta
2c2197d12c Assign ERROR_CODE_IO_BAD_HTTP_STATUS to InvalidResponseCodeException
PiperOrigin-RevId: 374885599
2021-05-21 12:03:39 +01:00
aquilescanta
23d4efad7b Make TYPE_* constant declarations in lexicographic order
PiperOrigin-RevId: 374880929
2021-05-21 12:03:04 +01:00
aquilescanta
1c4294175f Add contentIsMalformed and dataType to ParserException
PiperOrigin-RevId: 374874272
2021-05-21 12:02:29 +01:00
tonihei
08259f8987 Don't allow spliced-in preload chunks.
Preload chunks may still need to be discarded. However, we don't
currently support discarding spliced-in chunks. Thus, we need to
avoid loadng a preload chunk that needs to be spliced-in.

Issue: #8937

#minor-release

PiperOrigin-RevId: 374851661
2021-05-20 15:45:30 +01:00
olly
20fcb42872 Gradle cleanup #2
PiperOrigin-RevId: 374847609
2021-05-20 15:44:28 +01:00
olly
45fde20b0e Gradle cleanup #1
Colocate lines that refer to the same module, to reduce probability of
accidentally removing one line and not the other (which has happened
more than once :)).

PiperOrigin-RevId: 374847082
2021-05-20 15:43:59 +01:00
tonihei
d08303d05d Add ServerSideInsertedAdsMediaSource.
This media source wraps another source and publishes a Timeline with
ads. The created MediaPeriods for ad and content are mapped back to
the original stream to allow seamless playback.

PiperOrigin-RevId: 374836091
2021-05-20 15:43:00 +01:00
tonihei
1a6f36d4a4 Fix reading position at stream transition.
PiperOrigin-RevId: 374836046
2021-05-20 15:42:31 +01:00
tonihei
8eb990e47a Make SSAI player logic more targeted.
There is a newly added condition to help advancing between SSAI ads
and content in case the ad group position or ad duration changed. The
condition currently doesn't check directly whether it's a SSAI
transition but relies on indrect signals. Making this more direct
helps to understand the purpose and avoid unintentional bugs where
this condition would apply in other cases too.

In addition, we need to exclude TextRenderer from the check because
its read position doesn't correspond to the actual decode position
since the decoding happens in the renderer itself (b/181312195).

PiperOrigin-RevId: 374835985
2021-05-20 15:42:02 +01:00
tonihei
5ff4211c5e Avoid recalculation of whether a MediaPeriod is part of a SSAI stream
We can instead just save this information in MediaPeriodInfo, similar
to how we store whether the MediaPeriod is last in the timeline etc.

PiperOrigin-RevId: 374835918
2021-05-20 15:41:34 +01:00
olly
0de6bc861a Format *_jni.cc files
PiperOrigin-RevId: 374830877
2021-05-20 15:40:34 +01:00
klhyun
9e4315f48d Implement MediaController#getCurrentCues
It only covers MediaSession - MediaController
(Does not consider cases that either a legacy session or a legacy controller is involved)

Add PlayerInfo#Builder to clean it up.

PiperOrigin-RevId: 374785779
2021-05-20 15:39:34 +01:00
christosts
65d8ff80db ForwardingPlayer only forwards Player operations
PiperOrigin-RevId: 374621615
2021-05-19 20:24:53 +01:00
krocard
41afb6ac4e Add guarantied invalid command to allow niche optimisations
This allows users to use `int` to store an optional command.

PiperOrigin-RevId: 374600127
2021-05-19 20:24:29 +01:00
claincly
e383b0031d Define the default RTSP character set.
#minor-release

PiperOrigin-RevId: 374433331
2021-05-19 20:24:04 +01:00
aquilescanta
66c1aedeb3 Assign ERROR_CODE_BEHIND_LIVE_WINDOW to BehindLiveWindowExceptions
PiperOrigin-RevId: 374425179
2021-05-19 20:23:38 +01:00
ibaker
73f28d4829 Fix core_settings.gradle to not assume exoplayerRoot is absolute
Gradle warns against passing a relative path to `new File(String)`:
https://docs.gradle.org/current/userguide/working_with_files.html#sec:single_file_paths

This change fixes all usages of `exoplayerRoot` to pass it to Gradle's
`Project.file()` first, which returns an absolute `File`.

To reproduce the problem in Issue: #8927:
1. Checkout ExoPlayer git project, to e.g. `~/ExoPlayer/exoplayer-git`
2. Create a new Android Studio project in e.g. `~/AndroidStudioProjects/exoplayer-test`
3. Edit the new project's `settings.gradle` file as described in
   https://github.com/google/ExoPlayer/blob/release-v2/README.md
   using a relative path for `exoplayerRoot`:
   ```
   gradle.ext.exoplayerRoot = '../../ExoPlayer/exoplayer-git'
   ```
4. In a shell:
   ```bash
   $ cd ~/AndroidStudioProjects/exoplayer-test/app
   $ ../gradlew build
   ```

(Step 4 is important, it seems running `./gradlew` from the project root
doesn't trigger the relative path problem)

This change fixes the problem, and also works with `exoplayerRoot` as a
`File` or `Path` object. `String`, `File` and `Path` all work with relative or
absolute paths:
```
gradle.ext.exoplayerRoot = '/home/ibaker/ExoPlayer/exoplayer-git'
gradle.ext.exoplayerRoot = '../../ExoPlayer/exoplayer-git'
gradle.ext.exoplayerRoot = new File('/home/ibaker/ExoPlayer/exoplayer-git')
gradle.ext.exoplayerRoot = new File('../../ExoPlayer/exoplayer-git')
gradle.ext.exoplayerRoot = Paths.get('/home/ibaker/ExoPlayer/exoplayer-git')
gradle.ext.exoplayerRoot = Paths.get('../../ExoPlayer/exoplayer-git')
```

Note: The Path versions above require importing `java.nio.file.Paths`
and changing the `apply from:` line in the project's settings.gradle
file to something like:
```
apply from: file(gradle.ext.exoplayerRoot.resolve('core_settings.gradle'))
```
It's assumed that a project wanting to pass a `Path` will make these
changes.

Issue: #8927
PiperOrigin-RevId: 374421627
2021-05-19 20:23:13 +01:00
aquilescanta
227795964b Add an IntDef for DATA_TYPE_* constants
PiperOrigin-RevId: 374418502
2021-05-19 20:22:48 +01:00
aquilescanta
6c06b4efd1 Re-order error codes for symmetry
PiperOrigin-RevId: 374416794
2021-05-19 20:22:23 +01:00
aquilescanta
61c92007b7 Bubble up the errorCode argument in preparation for new factory methods
Notes:
- The only functional change is that createForRemote now assings ERROR_CODE_REMOTE_ERROR.
- createForSource still uses ERROR_CODE_UNSPECIFIED, even though it expects an
  IOException. The reason for not using ERROR_CODE_IO_UNSPECIFIED is that the reason for
  the error might not be IO. For example, malformed media, or BehindLiveWindowException,
  which have non-IO error codes. So using UNSPECIFIED saves a later change in category.
PiperOrigin-RevId: 374390407
2021-05-19 20:21:57 +01:00
tonihei
378b3f6eb5 Add Util class for server-side inserted ads.
When working with SSAI ads, we need to easily convert positions between
the underlying stream and the media model that exposes ad groups. To
simplify this, we can add util methods (that are testable on their own).

In addition, we need an easy way to build AdPlaybackStates for SSAI
inserted ads. The metadata is obtained out-of-band and usually has the
ad group start and end times in the underlying stream only. Hence, we
also add a util method to add a new ad group based on this information.

PiperOrigin-RevId: 374369360
2021-05-19 20:21:32 +01:00
aquilescanta
c7db9fb390 Deduplicate calls to maybeNotifyPlaybackInfoChanged
PiperOrigin-RevId: 374253036
2021-05-19 20:21:08 +01:00