1115 Commits

Author SHA1 Message Date
hschlueter
73b57d3c77 Implement chaining GlTextureProcessor.Listener.
In follow-ups the FrameProcessorChain will set an instance of this
listener for each GlTextureProcessor to chain it with its previous
and next GlTextureProcesssor.

PiperOrigin-RevId: 455628942
(cherry picked from commit 981baae7095ef34c548df600bfbea1f7765dbb9e)
2022-06-17 16:57:46 +01:00
hschlueter
c16e5ac47c Wrap processor chain executor service for better exception handling.
The wrapper
* catches exceptions for each task and notifies the
  listener (this will be used more in follow-ups when processFrame
  is split into lots of listeners and callbacks),
* removes finished tasks from the queue and signals any exceptions
  that occurred to the listener each time a new task is executed.

PiperOrigin-RevId: 455345184
(cherry picked from commit ee847d92c50c8d2929da287e1103110149d78170)
2022-06-16 10:41:23 +00:00
olly
8c748485d2 Don't export broadcast receivers that don't require it
Issue: google/ExoPlayer#10287
PiperOrigin-RevId: 455131138
(cherry picked from commit 691b392b246522fb664cdb1ce196e16c3449926c)
2022-06-15 15:00:47 +00:00
hschlueter
8c465a7860 Replace FrameProcessorChain#isEnded with listener method.
PiperOrigin-RevId: 455114693
(cherry picked from commit fdfca880195da2ca5e5d0ef002feb8144009384c)
2022-06-15 13:27:35 +00:00
hschlueter
b7118486dc Use FrameProcessorChain#SurfaceProvider for encoder compat transform.
This change adds a SurfaceProvider interface which is necessary to
allow for texture processors whose output size becomes available
asynchronously in follow-ups.
VTSP's implementation of this interface wraps the encoder and provides
its input surface together with the output frame width, height, and
orientation as used for encoder configuration.
The FrameProcessorChain converts the output frames to the provided
orientation and resolution using a ScaleToFitTransformation and
Presentation replacing EncoderCompatibilityTransformation.

PiperOrigin-RevId: 455112598
(cherry picked from commit ea7f1ca1e32f19131cec690c6934d82c81a2d6d0)
2022-06-15 13:14:56 +00:00
hmzh
f5f95a8f40 Implement seeking to the start of a MIDI file
- Fixed MidiExtractor state issues which caused seeking to behave unexpectedly. Ensures the extractor is now always in the file loading state after returning RESULT_END_OF_INPUT.
- Fixed an infinite loop in MidiExtractor caused by the file data array having an initial size of 0. The extractor attempted to increase the capacity of the array by using this size of 0 in it's calculations.

PiperOrigin-RevId: 455107511
(cherry picked from commit 84c43f855fd60f96b5f415dc316c1333cfdec704)
2022-06-15 12:42:05 +00:00
olly
84e772ada8 Suppress an ExtendsObjects violation
to support enabling this as a compile-time error.

More information: go/lsc-extends-object

PiperOrigin-RevId: 454582570
(cherry picked from commit ab56f865ea076ac3cc9eb1ad5aff6000136caf80)
2022-06-13 12:34:43 +00:00
ibaker
2396887234 Remove ExoPlayerTest.PlayerStateGrabber
It's no longer needed

PiperOrigin-RevId: 454161070
(cherry picked from commit 8c63ba6fdbfcf632538acbfb6737f227923e54bf)
2022-06-10 14:32:54 +00:00
hschlueter
0a42c702ca Combine all native GL errors in a GlException instead of logging.
The native GL errors are in an arbitrary order according to
https://www.khronos.org/registry/OpenGL-Refpages/es2.0/xhtml/glGetError.xml
This means any of them could contain the most useful message
so it's better to use all for the GlException's message rather than
picking the last message and logging all others.

PiperOrigin-RevId: 454130460
(cherry picked from commit d6a6b44715c15be8348b4a30664254e57d79036a)
2022-06-10 11:03:38 +00:00
hschlueter
56f234ea75 Check targetSdkVersion for frame dropping workaround.
Based on
https://developer.android.com/reference/android/media/MediaCodec#using-an-output-surface,
frame dropping behaviour depends on the target SDK version.
After this change transformer will only use
MediaFormat#KEY_ALLOW_FRAME_DROP if both the target and system SDK
version are at least 29 and default to its pre 29 behaviour where each
decoder output frame must be processed before a new one is rendered
to prevent frame dropping otherwise.

Also remove deprecated Transformer.Builder constructor without a
context and the context setter.

PiperOrigin-RevId: 453971097
(cherry picked from commit a105d033a7d44b8c3afb0e8134ad65f624caf256)
2022-06-09 18:22:39 +00:00
hschlueter
0b08396255 Make GlUtil.GlException checked and remove flag to disable it.
Transformer always enabled glAssertionsEnabled, so there should
be no functional change.

ExoPlayer previously disabled glAssertionsEnabled, so GlUtil logged
GlExceptions instead of throwing them. The GlExceptions are now
caught and logged by the callers so that there should also be no
functional change overall.

This change also replaces EGLSurfaceTexture#GlException with
GlUtil#GlException.

PiperOrigin-RevId: 453963741
(cherry picked from commit cc1f32d094cc4371d92b3ddab144d8965e1bc1c3)
2022-06-09 17:53:39 +00:00
claincly
780631c14b Ensure re-encode on performance tests
PiperOrigin-RevId: 453933854
(cherry picked from commit 12d775f055faac1b9de2c53fd296c5b1d0f89a32)
2022-06-09 15:41:09 +00:00
huangdarwin
5349312f50 Transformer GL: Split Presentation and Crop.
This removes the prior restriction of needing to remember not to crop and set aspect ratio in the same Presentation.Builder, and makes each class a bit more targeted.

This is partially made feasible by the past work to merge consecutive
MatrixTransformations into a single MatrixTransformationFrameProcessor, which
ensures that there's no loss in quality between successive MatrixTransformations.

PiperOrigin-RevId: 453660582
(cherry picked from commit c5b881e0899e713a7c632da48f1cd64b1394a221)
2022-06-08 12:51:28 +00:00
hschlueter
8973efd199 Mention alpha for matrix transformation background color.
PiperOrigin-RevId: 453633920
(cherry picked from commit cdb80387828c0087d9c9b96c55f303b978847910)
2022-06-08 09:50:18 +00:00
hschlueter
dac3878273 Implement default GlTextureProcessor in SingleFrameGlTextureProcessor.
SingleFrameGlTextureProcessor is now an abstract class containing a
default implementation of the more flexible GlTextureProcessor interface
while still exposing the same simple abstract methods for single frame
processing it previously did.

FrameProcessorChain and GlEffect will be changed to use
GlTextureProcessor in follow-ups.

PiperOrigin-RevId: 453633000
(cherry picked from commit 457f446114823831b940bf46fb256daa0ea00815)
2022-06-08 09:44:25 +00:00
christosts
a6fc6fac31 Ignore flaky test
PiperOrigin-RevId: 453168843
(cherry picked from commit 8d326312fba9ec36264815746c531ea9b28e2c28)
2022-06-06 11:35:12 +00:00
christosts
94e97fe5db De-flake test in MediaSessionPermissionTest
This change makes MediaSessionPermissionTest.removeMediaItems()
non-flaky. This is a quick fix though it'd be good to refactor this
test file.

PiperOrigin-RevId: 453162764
(cherry picked from commit 34ca3bc3c3b52b8dcfc531de76bc0b34f7a89c8c)
2022-06-06 10:42:08 +00:00
hschlueter
f4dfbdbc37 Add interface for async texture processors.
Implementations of this interface will be able to drop or add frames,
change timestamps, accept multiple input frames before producing
output, and process frames on their own background thread.

A default implementation of this interface will be added to SingleFrameGlTextureProcessor in a follow-up.

PiperOrigin-RevId: 453159835
(cherry picked from commit 63436390de55741620ab3faccbbc504af24c2686)
2022-06-06 10:18:26 +00:00
hschlueter
27f23041cf Add async error listener to transformer to avoid exception wrapping.
This internal listener avoids wrapping the TransformationExceptions
in PlaybackExceptions that are handled via the Player.Listener and
is also used for FrameProcessingExceptions which already avoided
the PlaybackException layer previously.

This listener will also be useful in follow-ups for encoder-related
TransformationExceptions that are thrown in the SurfaceProvider that
will be called on the GL thread.

PiperOrigin-RevId: 452074575
(cherry picked from commit 35b5147eb1404698132d9b063c905202c22e31d8)
2022-05-31 17:01:02 +00:00
hschlueter
22ee071b53 Move program initialization to texture processor constructor.
Once the more advanced GlTextureProcessor interface exists,
it will be possible to change the output size of a GlTextureProcessor
between frames. To keep the re-configuration based on the frame sizes
minimal, things indepedent of the frame size, such as the GlProgram,
can be initialized in the constructor.

PiperOrigin-RevId: 451997584
(cherry picked from commit 87ab96d352c0ffbf83d514d93193638895b61e5e)
2022-05-31 09:36:18 +00:00
rohks
37f11161ce Version bump to exoplayer:2.18.1 and media3:1.0.0-beta02
#minor-release

PiperOrigin-RevId: 461162552
(cherry picked from commit be27daebc4e598a4c0d532779649a77f82650911)
2022-07-15 10:39:34 +00:00
tonihei
dfe8bee0cf Fix setDataSourceFactory handling in DefaultMediaSourceFactory
The call doesn't currently reset the already loaded suppliers and
factories. Also fix the supplier loading code to use a local copy
of the current dataSourceFactory to avoid leaking an updated
instance to a later invocation.

Issue: androidx/media#116

PiperOrigin-RevId: 460721541
(cherry picked from commit adc50515e93e6fdcf303d168e8388050503c46ef)
2022-07-13 15:27:55 +00:00
Rohit Singh
3abffb7583 Merge pull request #10185 from TiVo:p-custom-logger
PiperOrigin-RevId: 460689252
(cherry picked from commit bd8723e35a195e0e67816a64e74266bac9fe5058)
2022-07-13 17:45:54 +00:00
bachinger
05a1bbf66e Don't set the tag in CastTimeline
Leaving the media item that has been passed in unchanged, ensures that the
media item in the timeline is equal to the media item that the user has
passed into the player. The value of the tag is the uid of the window,
meaning this is redundant information.

#minor-release

PiperOrigin-RevId: 460542246
(cherry picked from commit b61a06ba2f1aa4cc75dc1702ad94e483101adc51)
2022-07-12 20:41:57 +00:00
Rohit Singh
da52b9489a Merge pull request #110 from ittiam-systems:rtp_vp8_test
PiperOrigin-RevId: 460513413
(cherry picked from commit 9d9bbe3d33721b1301ae16df7f87f9aa51d06b89)
2022-07-13 17:40:18 +00:00
bachinger
97716cd0a1 Enable onMediaMetadataChanged in CastPlayer
Issue: androidx/media#25
PiperOrigin-RevId: 460476841
(cherry picked from commit 6922bd58ee844cc8293ef885918d01e2d0fbc02b)
2022-07-12 16:04:45 +00:00
ibaker
fff99fe93f Group COMMAND_SET_MEDIA_ITEM and COMMAND_CHANGE_MEDIA_ITEMS together
I don't think it's useful to keep these in numerical order, it makes
more sense to keep them grouped into a 'logical' ordering.

#minor-release

PiperOrigin-RevId: 460453464
(cherry picked from commit ad46cb1c81addfc20b7333a451741a717e85da18)
2022-07-12 14:06:27 +00:00
bachinger
fe6baee775 Use the public MediaItem in the timeline of CastPlayer
The media item needs to be assigned to `Window.mediaItem` in `CastTimeline.setWindow`. For this the `MediaItem` needs to be available in the timeline.

When a `MediaItem` is passed to the `set/addMediaItems` method, we can't yet know the Cast `MediaQueueItem.itemId` that is generated on the device and arrives with an async update of the `RemoteMediaClient` state. Hence in the `CastTimelineTracker`, we need to store the `MediaItem` by Casts's `MediaItem.contentId`. When we then receive the updated queue, we look the media item up by the content ID to augment the `ItemData` that is available in the `CastTimeline`.

Issue: androidx/media#25
Issue: google/ExoPlayer#8212

#minor-release

PiperOrigin-RevId: 460325235
(cherry picked from commit 30fbc3a27d1c2b673c3f0a6f1c8956e183b11952)
2022-07-11 23:22:27 +00:00
christosts
329aa5864c Listen to playWhenReady changes in LeanbackPlayerAdapter
#minor-release

Issue: google/ExoPlayer#10420
PiperOrigin-RevId: 460223064
(cherry picked from commit 4eb34e4c58e9cdfc804a5e3347ef30e9991c0186)
2022-07-11 15:49:33 +00:00
rohks
c40d669c51 Add tests for extracting MP4 with large bitrates
Also added the test to `MP4PlaybackTest`.

PiperOrigin-RevId: 459492188
(cherry picked from commit 05e728a31eb85b82610a5eb83622ee2670582a26)
2022-07-07 13:04:29 +00:00
christosts
f9e082743d Add missing Nullable annotation
PiperOrigin-RevId: 459485334
(cherry picked from commit cb87b7432f4c08a597d048114b5006d09de29da9)
2022-07-07 12:17:36 +00:00
tonihei
9af65a909d Don't block AudioTrack when waiting for previous release
We wait until a previous AudioTrack has been released before
creating a new one. This is currently done with a thread
block operation, which may cause ANRs in the extreme case
when someone attempts to release the player while this is
still blocked.

The problem can be avoided by just returning false from
DefaultAudioSink.handleBuffer to try again until the previous
AudioTrack is released.

Reproduction steps to force the issue:
1. Add Thread.sleep(10000); to the AudioTrack release thread.
2. Add this to the demo app:
    private int positionMs = 0;

    Handler handler = new Handler();
    handler.post(new Runnable() {
      @Override
      public void run() {
        player.seekTo(positionMs++);
        if (positionMs == 10) {
          player.release();
        } else {
          handler.postDelayed(this, 1000);
        }
      }
3. Observe Player release timeout exception.

These steps can't be easily captured in a unit test as we can't
artifically delay the AudioTrack release from the test.

Issue: google/ExoPlayer#10057
PiperOrigin-RevId: 459468912
(cherry picked from commit a83ab05aeceb6c99f3b7b19d6fedd20f317e0aa6)
2022-07-07 10:22:56 +00:00
bachinger
87b817b0f9 Fix incorrect link tags
PiperOrigin-RevId: 459215618
(cherry picked from commit 87adb88f57afb050a96a9c67dd9eb55fb3a6706c)
2022-07-06 11:02:12 +00:00
Rohit Singh
bc47036993 Merge pull request #10260 from sr1990:clearkey_parse_licenseurl
PiperOrigin-RevId: 459215225
(cherry picked from commit f00f93a96e0c7fa4f37e32e280b073d1cef2649e)
2022-07-07 16:43:14 +00:00
tonihei
d2027a8338 Exclude HEVC 10bit profile on Pixel 1.
This profile is declared as supported although it isn't.

Issue: google/ExoPlayer#10345
Issue: google/ExoPlayer#3537

#minor-release

PiperOrigin-RevId: 459205512
(cherry picked from commit 656eaf74d13d5c35b67ef16b21c6ddbdd1266fc8)
2022-07-06 09:46:27 +00:00
bachinger
1f1460a152 Use mediaId as contentId if available
This is to be consistent with what cast `QueueMediaItem` is doing. If a contentId is
not available the contentUrl is used as the ID.

#minor-release

PiperOrigin-RevId: 459133323
(cherry picked from commit 0a9f9007c66ca725959b3fe70311dd72dc086346)
2022-07-05 23:21:59 +00:00
Marc Baechinger
1bbaec9c1b Merge pull request #96 from fengdai:release
PiperOrigin-RevId: 458883441
(cherry picked from commit 8e5af4a3aa43a3f2e0fd96415adf800a0abf8507)
2022-07-04 19:56:41 +00:00
tonihei
1def7b5a36 Only consider enabled tracks in ProgressiveMediaPeriod.bufferedPosition
ProgressiveMediaPeriod loads all available tracks into SampleStreams
(because it needs to read the data anyway and it allows easy activation
of tracks without reloading). However, the SampleStreams for disabled
tracks are not read and no one if waiting for them.

The buffered position is used for user-visible state (e.g. in the UI)
and to check how much data is already buffered to decide when to stop
buffering (using LoadControl). Both values benefit from only
using the actually enabled tracks to better reflect what is available
for playback at the moment.

Issue:Issue: google/ExoPlayer#10361
PiperOrigin-RevId: 458475038
(cherry picked from commit ceb23e69bbdc075df96943e5c29d52cf1d492db9)
2022-07-01 15:28:39 +00:00
bachinger
3de3f41757 Document custom commands in the DefaultMediaNotificationProvider
Issue: androidx/media#103
#minor-release
PiperOrigin-RevId: 458465479
(cherry picked from commit 2c0806814bd28612834b51b8489a138e5eb10ecf)
2022-07-01 14:27:24 +00:00
rohks
1ec7148c96 Fix MP4 parser issue in reading bitrates from esds boxes.
As per MP4 spec, bitrates in esds boxes can be a 32 bit number which doesn't fits in Java int type, so now reading it as a long value. Our class for holding media format, only allows bitrates value to be an int as we don't expect the bitrates to be greater than or equal to 2^31. So we're limiting the values for bitrates to Integer.MAX_VALUE.

PiperOrigin-RevId: 458423162
(cherry picked from commit 21638fa3784078170af3be545316e062313a30b5)
2022-07-01 09:52:45 +00:00
rohks
4d6781be2c Fix MP4 parser issue in reading length of URL array from esds boxes.
As per MP4 spec, the length of URL array is a 8 bit number.

#minor-release

PiperOrigin-RevId: 458421436
(cherry picked from commit 42f13c331f8c7e28505edcd1e033c5525e5c22f2)
2022-07-01 09:39:11 +00:00
ibaker
258d9361c4 Ensure TalkBack announces the selected playback speed in the UI menu
Issue: google/ExoPlayer#10298
PiperOrigin-RevId: 457991028
(cherry picked from commit 3fc6a66527c6af940b45dd0d2ce1f3fb19491fa0)
2022-06-29 16:10:11 +00:00
ibaker
8b2b7868f3 Consider shuffle order in Timeline.equals()
Previously two timelines that differed only in shuffle order were
considered equal, which resulted in no call to
Player.Listener.onTimelineChanged when calling
ExoPlayer.setShuffleOrder. This in turn resulted in no call to
MediaControllerCompat.Callback.onQueueChanged.

Also make a small fix inside ExoPlayerImpl.setShuffleOrder, to ensure
that the new shuffle order is used when constructing the masked
timeline.

Issue: google/ExoPlayer#9889
#minor-release
PiperOrigin-RevId: 457703727
(cherry picked from commit 6f9ce4056cc427076ba48189ab192e65234da4d8)
2022-06-28 12:15:54 +00:00
ibaker
968169c784 Use a helper function and Truth Correspondence instead of NoUidTimeline
NoUidTimeline still exists as a private detail of TestUtil, but it no
longer extends ForwardingTimeline because the interactions are quite
hard to reason about.

#minor-release

PiperOrigin-RevId: 457703593
(cherry picked from commit 2a2d9e360baa6e1a44be53c39fbcd69079f34dcc)
2022-06-28 12:15:03 +00:00
tonihei
9274f08b89 Clean up offload state tracking
1. The offloadSchedulingEnabled value doesn't need to be in
   PlaybackInfo because it's never updated in EPII.
2. The sleepingForOffload value in EPII wasn't updated explicitly
   (just via the return value of a method). It was also only
   meant to be enabled while the player is actively playing, but
   confusingly triggered from a path where the player may
   theoretically be buffering as well.
3. The offload sleeping (=not scheduling doSomeWork) was interwoven
   into the actual scheduling code making it slightly hard to follow.
   This can be improved slightly by keeping the offload sleeping
   decision and the scheduling separate.

PiperOrigin-RevId: 457427293
(cherry picked from commit 5c2752b4a92a076babc0bc1ff5651a306c20e693)
2022-06-27 09:34:56 +00:00
tonihei
7683c8bf6c Rename shouldUseDummySurface to shouldUsePlaceholderSurface
This was likely missed in 33373d0d0a.

PiperOrigin-RevId: 457422574
(cherry picked from commit 8e716d6804e4c5b3417a19e1ef3c07cf2810aefd)
2022-06-27 10:04:19 +01:00
olly
2f1260e346 Inform ProgressiveMediaPeriod of known length earlier
PiperOrigin-RevId: 456753343
(cherry picked from commit 1d2ad39a4d4778124a6b87c3d3a7a4415eeb8865)
2022-06-23 14:31:27 +01:00
tonihei
59fbb45506 Clear pending doSomeWork messages when sleeping for offload
The offload sleeping stops as soon as a new DO_SOME_WORK message
is handled (because this indicates an expected change in rendering
and we want to stop sleeping until we know it's safe to do so).

Every exit path from doSomeWork needs to clear other pending
DO_SOME_WORK messages as these requests have already been handled by
the current method invocation. This currently doesn't happen from the
offload sleeping return path and a previously queued DO_SOME_WORK
message can immediately wake up the rendering loop again.

Fix this by moving the message removal to the beginning of the
doSomeWork method (as it prevents forgetting it in one of the
exit paths later).

PiperOrigin-RevId: 456259715
(cherry picked from commit a7649b639cef242f70cf832f5dbf56514b7e8c4b)
2022-06-21 15:58:04 +01:00
olly
4e51ef5a2c Fix parsing H265 short term reference picture sets
Issue: google/ExoPlayer#10316
PiperOrigin-RevId: 456084302
(cherry picked from commit 6dc85dc241dca8f0783d3ffbb3448840b0e75b60)
2022-06-20 16:46:15 +01:00
christosts
265b865b26 Misc improvement in Util
#minor-release

PiperOrigin-RevId: 455380010
(cherry picked from commit 7563bd2792d85c61223c12dd0c4c5a77d1b75b13)
2022-06-16 14:39:46 +00:00