9262 Commits

Author SHA1 Message Date
hschlueter
3d6bed1668 FrameProcessor: Replace SurfaceInfo.Provider with setter.
The FinalMatrixTransformationProcessorWrapper ensures that the
surface is only replaced when it is not being rendered to and vice
versa.

PiperOrigin-RevId: 458007639
(cherry picked from commit e5527a8addff1e35380d3383dea237c70198a63a)
2022-06-29 17:27:05 +00:00
rohks
583c12f843 Make MetadataRenderer configurable to output metadata early.
PiperOrigin-RevId: 457974611
(cherry picked from commit 14f75c162f85ac083c8b19b74790b4a6f921c68f)
2022-06-29 14:47:12 +00:00
hschlueter
47cc8aaf92 Fix outputHeight pass-through condition.
The outputHeight in the TransformationRequest is the height of
the frame as it would be displayed (i.e., after applying any
rotation specified in the format). So pass-through should only
be used if the requested outputHeight matches the input
format's height after applying the rotation.

PiperOrigin-RevId: 457934867
(cherry picked from commit c74cf1f1aaa917bad3479779dff80aeeac866493)
2022-06-29 10:28:54 +00:00
hschlueter
c812c80a2f Allow changing input pixelWidthHeightRatio for GlEffectsFrameProcessor.
pixelWidthHeightRatio is now passed to setInputFrameInfo instead of
the factory.

PiperOrigin-RevId: 457696703
(cherry picked from commit bfa663d2b13340297354ef32ea7679775cb2d4eb)
2022-06-28 11:22:45 +00:00
rohks
76310ad40c Add timestamp to Metadata
`MetadataRenderer` is updated to output `Metadata` with its presentation time, in microseconds.

PiperOrigin-RevId: 457444718
(cherry picked from commit 6e9275c13d7c6e0fc8b6568662929c186395a33a)
2022-06-27 11:31:10 +00:00
hschlueter
9ad2d7123e Rename setVideoFrameEffects to setVideoEffects.
PiperOrigin-RevId: 457023382
(cherry picked from commit 20d220193e4051811e307b67a7e631b290449e23)
2022-06-24 17:04:45 +01:00
hschlueter
ad7fef1641 Allow FrameProcessor input surface size changes.
This will be useful for downgrading to a lower resolution during
a slow preview and for processing slide-shows once sequential
multi-asset editing is supported.

PiperOrigin-RevId: 457017255
(cherry picked from commit a230d59f1b72e92f41196723eb1af1d23984a048)
2022-06-24 16:31:31 +01:00
hschlueter
bd3b450244 Extract FrameProcessor interface from GlEffectsFrameProcessor.
PiperOrigin-RevId: 456814150
(cherry picked from commit 1b5dd92dec4a9742cb957595857e695d5f8dfa83)
2022-06-23 19:00:01 +01:00
hschlueter
419ff0d264 Disable flaky transformer emulator test on API 31.
videoEncoderFormatUnsupported_completesWithError() has recently
been flaky on API 31 emulators on presubmit because a different
exception than the expected exception is thrown.
This disables it on those emulators to reduce testing noise
until the underlying problem is investigated and resolved.

PiperOrigin-RevId: 456765512
(cherry picked from commit d9c63c1e872cbb730417ec4624d2860c25cfddb4)
2022-06-23 15:44:02 +01:00
hschlueter
26d7037730 Rename FrameProcessorChain to GlEffectsFrameProcessor.
This change is just renaming. There is no functional change intended.
The FrameProcessor interface will be created in a follow-up.

PiperOrigin-RevId: 456741628
(cherry picked from commit 216fefd669ab2bfdb03c202094b35eb935272d96)
2022-06-23 13:13:56 +01:00
samrobinson
1ba723a89f Add a Builder for DefaultEncoderFactory.
PiperOrigin-RevId: 456728032
(cherry picked from commit 19bdff96ba9e053110bd701724c671ac10ae7cef)
2022-06-23 11:37:19 +01:00
rohks
1bc316dee1 Add timestamp to CueGroup
`TextRenderer` is updated to output `CueGroup`, which contains the presentation time of the cues, in microseconds.

PiperOrigin-RevId: 456531399
(cherry picked from commit bf11a8a83148f0d68c82cf22a5f978b1e6a5e299)
2022-06-22 17:19:55 +01:00
hschlueter
6edd1d2a2f Use GlTextureProcessor to avoid redundant copy in MediaPipeProcessor.
After this change GlEffects can use any GlTextureProcessor not just
SingleFrameGlTextureProcessor.
MediaPipeProcessor now implements GlTextureProcessor directly which
allows it to reuse MediaPipe's output texture for its output texture
and avoids an extra copy shader step.

PiperOrigin-RevId: 456530718
(cherry picked from commit e25bf811959baf1066ba18adc37e8bbdaad4791a)
2022-06-22 17:16:54 +01:00
hschlueter
f96a6c71b8 Support chaining async GlTextureProcessors in FrameProcessorChain.
After this change, FrameProcessorChain chains any GlTextureProcessors
instead of only SingleFrameGlTextureProcessors.

The GlTextureProcessors are chained in a bidirectional manner using
ChainingGlTextureProcessorListener to feed input and output related
events forward and release events backwards.

PiperOrigin-RevId: 456478414
(cherry picked from commit 3a966916545f92c5ce08a640c912054ede215152)
2022-06-22 12:03:41 +01:00
huangdarwin
4102cdbc8a FrameProcessor: Use factories instead of a builder for Presentation.
PiperOrigin-RevId: 456064021
(cherry picked from commit d1357e8b59d019fcc7200c5ff13787c5ab3e211a)
2022-06-20 14:26:12 +01:00
hschlueter
23110cd6cc 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 c92e18ec583eccde1bc80c11842ec81c9a6fedef)
2022-06-17 16:57:46 +01:00
hschlueter
3bca195c9f 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 bf9fa124115abe26764e163e755ed6046c4a0114)
2022-06-16 10:41:23 +00:00
olly
54f72e733f Don't export broadcast receivers that don't require it
Issue: google/ExoPlayer#10287
PiperOrigin-RevId: 455131138
(cherry picked from commit 9267ba3f9e14da4436bfbfe76045f7d09af80feb)
2022-06-15 15:00:47 +00:00
hschlueter
da7ad3716b Replace FrameProcessorChain#isEnded with listener method.
PiperOrigin-RevId: 455114693
(cherry picked from commit 10050a1e8ccca217ba7facd21ecabab2b9811f8b)
2022-06-15 13:27:35 +00:00
hschlueter
5f142c4bbe 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 d20f68498666ddf1f1946799cf002a9edb573a40)
2022-06-15 13:14:56 +00:00
olly
dc22f62ffb 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 d2f5f212b909fcbd81a48d84d805005724e5303e)
2022-06-13 12:34:43 +00:00
ibaker
beb0422e22 Remove ExoPlayerTest.PlayerStateGrabber
It's no longer needed

PiperOrigin-RevId: 454161070
(cherry picked from commit 86a2f297a5f8eb94fc04820ea943512c078205c4)
2022-06-10 14:32:54 +00:00
hschlueter
ddd8f4174f 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 92c2a304e10d0da968cf341080de47566ce551ed)
2022-06-10 11:03:38 +00:00
hschlueter
e4605583bc 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 3f718b0d10e1d577620cca9ec76d0af38efc542c)
2022-06-09 18:22:39 +00:00
hschlueter
9ecf722824 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 dc668f2b59bb0df12cdbb77cb88072babe0218eb)
2022-06-09 17:53:39 +00:00
claincly
092fbd6c83 Ensure re-encode on performance tests
PiperOrigin-RevId: 453933854
(cherry picked from commit fa22efb7058816444a20cd11a2a423e99e8e4837)
2022-06-09 15:41:09 +00:00
huangdarwin
a4ed533eb5 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 b33dc5e57b96d81f9c246a369a09fb7a23a119e2)
2022-06-08 12:51:28 +00:00
hschlueter
1086e3bfbf Mention alpha for matrix transformation background color.
PiperOrigin-RevId: 453633920
(cherry picked from commit d5e4faa9ef8da6ec0810dee14ac7d23da85c7b56)
2022-06-08 09:50:18 +00:00
hschlueter
df6c8f1d8a 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 0b37d860d13df1ac638f5a75c7af32c840e02956)
2022-06-08 09:44:25 +00:00
hschlueter
84b46c10de 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 023d19c8c5aa54841aeec12657846ac6a889dddb)
2022-06-06 10:18:26 +00:00
hschlueter
a04cc94afd 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 960422e36f22a4c76e0617672aac9b9bcef50f43)
2022-05-31 17:01:02 +00:00
hschlueter
23b0610a37 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 54d44d38b6bb4a7a5dc69ed8cfd878aebe46f4b4)
2022-05-31 09:36:18 +00:00
rohks
064bbbff41 Version bump to exoplayer:2.18.1 and media3:1.0.0-beta02
#minor-release

PiperOrigin-RevId: 461162552
(cherry picked from commit 6d27ff862b0e8bc99b43dcc59c1d99760f1b0946)
2022-07-15 10:37:41 +00:00
tonihei
b82be0472a 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

#minor-release

PiperOrigin-RevId: 460721541
(cherry picked from commit 6be0d6ea25a850b816b23105aa900683d30dfe8d)
2022-07-13 15:27:55 +00:00
Rohit Singh
77a3b16d6b Merge pull request #10185 from TiVo:p-custom-logger
PiperOrigin-RevId: 460689252
(cherry picked from commit 60437397f4984b5a5c64490fe88aa210d6547ce6)
2022-07-13 18:11:52 +00:00
Rohit Singh
344ac7bde0 Merge pull request #110 from ittiam-systems:rtp_vp8_test
PiperOrigin-RevId: 460513413
(cherry picked from commit c75b6a3a88e7e6ff2f5f25e334cfaae5567783ea)
2022-07-13 17:54:35 +00:00
ibaker
4b684b59d3 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 1b1e0f890da4de6055491730595f72afdde0811a)
2022-07-12 14:06:27 +00:00
rohks
43eb3d0fc8 Add tests for extracting MP4 with large bitrates
Also added the test to `MP4PlaybackTest`.

PiperOrigin-RevId: 459492188
(cherry picked from commit a1665841fc90e979af427f9da0b8398d56cc6632)
2022-07-07 13:04:29 +00:00
christosts
f9f6cb3458 Add missing Nullable annotation
PiperOrigin-RevId: 459485334
(cherry picked from commit 752e82df2e0b54a1935e329b5d7da6c23309a388)
2022-07-07 12:17:36 +00:00
tonihei
d39075a216 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 a80dd60449a029ad5246a98717bbe3bf0fc38be7)
2022-07-07 10:22:56 +00:00
Rohit Singh
ef96641558 Merge pull request #10260 from sr1990:clearkey_parse_licenseurl
PiperOrigin-RevId: 459215225
(cherry picked from commit 9521807681840f530ed4af17c4ab5c68dedaa13e)
2022-07-07 18:12:15 +00:00
tonihei
036a48dcf9 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 bf88f28539de7740dd542345ff8b70626f58ed45)
2022-07-06 09:46:27 +00:00
tonihei
84280c8530 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 577e19168d981a92c18eff7f7a045c925d80ca8d)
2022-07-01 15:28:39 +00:00
rohks
3d79536f80 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.

#minor-release

PiperOrigin-RevId: 458423162
(cherry picked from commit 9e10286b5ea624b8a7533e5fc452b19476589764)
2022-07-01 09:52:45 +00:00
rohks
3709e90e34 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 5095ff160bec2fdad21a51351373a03073236ffd)
2022-07-01 09:39:11 +00:00
ibaker
315bf6b898 Ensure TalkBack announces the selected playback speed in the UI menu
Issue: google/ExoPlayer#10298
#minor-release
PiperOrigin-RevId: 457991028
(cherry picked from commit bf86b603a30211ec2b48a78223683f758e6d5f83)
2022-06-29 16:10:11 +00:00
ibaker
d3b5f71f25 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 5c7ec13e85d32bdb464082069d462c740bc7cd55)
2022-06-28 12:15:54 +00:00
ibaker
f3a350d651 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 292f6de6305fa7fbbd2b80223e7860aa1f69118a)
2022-06-28 12:15:03 +00:00
tonihei
0d83c44699 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 aedde2de396995e4354f3110cc37e86b48525892)
2022-06-27 10:34:56 +01:00
tonihei
0b75c254ae Rename shouldUseDummySurface to shouldUsePlaceholderSurface
This was likely missed in 33373d0d0a.

PiperOrigin-RevId: 457422574
(cherry picked from commit aaa01529052bb299be41d5c56b2ea58abf738ce7)
2022-06-27 10:04:19 +01:00