Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
SDK
/
exoplayer
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
44cf5735
authored
Mar 13, 2023
by
tofunmi
Committed by
tonihei
Mar 14, 2023
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
Update GlObjectsProvider to cover creating surface.
PiperOrigin-RevId: 516300480
parent
8a9c51a8
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
54 additions
and
10 deletions
library/common/src/main/java/com/google/android/exoplayer2/util/GlObjectsProvider.java
library/effect/src/main/java/com/google/android/exoplayer2/effect/DefaultVideoFrameProcessor.java
library/effect/src/main/java/com/google/android/exoplayer2/effect/FinalShaderProgramWrapper.java
library/common/src/main/java/com/google/android/exoplayer2/util/GlObjectsProvider.java
View file @
44cf5735
...
@@ -18,6 +18,7 @@ package com.google.android.exoplayer2.util;
...
@@ -18,6 +18,7 @@ package com.google.android.exoplayer2.util;
import
android.opengl.EGLContext
;
import
android.opengl.EGLContext
;
import
android.opengl.EGLDisplay
;
import
android.opengl.EGLDisplay
;
import
android.opengl.EGLSurface
;
import
androidx.annotation.IntRange
;
import
androidx.annotation.IntRange
;
import
androidx.annotation.RequiresApi
;
import
androidx.annotation.RequiresApi
;
import
com.google.android.exoplayer2.C
;
import
com.google.android.exoplayer2.C
;
...
@@ -40,6 +41,26 @@ public interface GlObjectsProvider {
...
@@ -40,6 +41,26 @@ public interface GlObjectsProvider {
}
}
@Override
@Override
@RequiresApi
(
17
)
public
EGLSurface
createEglSurface
(
EGLDisplay
eglDisplay
,
Object
surface
,
@C
.
ColorTransfer
int
colorTransfer
,
boolean
isEncoderInputSurface
)
throws
GlException
{
return
GlUtil
.
createEglSurface
(
eglDisplay
,
surface
,
colorTransfer
,
isEncoderInputSurface
);
}
@Override
@RequiresApi
(
17
)
public
EGLSurface
createFocusedPlaceholderEglSurface
(
EGLContext
eglContext
,
EGLDisplay
eglDisplay
,
int
[]
configAttributes
)
throws
GlException
{
return
GlUtil
.
createFocusedPlaceholderEglSurface
(
eglContext
,
eglDisplay
,
configAttributes
);
}
@Override
public
GlTextureInfo
createBuffersForTexture
(
int
texId
,
int
width
,
int
height
)
public
GlTextureInfo
createBuffersForTexture
(
int
texId
,
int
width
,
int
height
)
throws
GlException
{
throws
GlException
{
int
fboId
=
GlUtil
.
createFboForTexture
(
texId
);
int
fboId
=
GlUtil
.
createFboForTexture
(
texId
);
...
@@ -66,6 +87,23 @@ public interface GlObjectsProvider {
...
@@ -66,6 +87,23 @@ public interface GlObjectsProvider {
EGLDisplay
eglDisplay
,
@IntRange
(
from
=
2
,
to
=
3
)
int
openGlVersion
,
int
[]
configAttributes
)
EGLDisplay
eglDisplay
,
@IntRange
(
from
=
2
,
to
=
3
)
int
openGlVersion
,
int
[]
configAttributes
)
throws
GlException
;
throws
GlException
;
// TODO(b/271433904): Remove default implementations once photos have implemented these methods.
@RequiresApi
(
17
)
default
EGLSurface
createEglSurface
(
EGLDisplay
eglDisplay
,
Object
surface
,
@C
.
ColorTransfer
int
colorTransfer
,
boolean
isEncoderInputSurface
)
throws
GlException
{
return
GlUtil
.
createEglSurface
(
eglDisplay
,
surface
,
colorTransfer
,
isEncoderInputSurface
);
}
@RequiresApi
(
17
)
default
EGLSurface
createFocusedPlaceholderEglSurface
(
EGLContext
eglContext
,
EGLDisplay
eglDisplay
,
int
[]
configAttributes
)
throws
GlException
{
return
GlUtil
.
createFocusedPlaceholderEglSurface
(
eglContext
,
eglDisplay
,
configAttributes
);
}
/**
/**
* Returns a {@link GlTextureInfo} containing the identifiers of the newly created buffers.
* Returns a {@link GlTextureInfo} containing the identifiers of the newly created buffers.
*
*
...
...
library/effect/src/main/java/com/google/android/exoplayer2/effect/DefaultVideoFrameProcessor.java
View file @
44cf5735
...
@@ -395,7 +395,7 @@ public final class DefaultVideoFrameProcessor implements VideoFrameProcessor {
...
@@ -395,7 +395,7 @@ public final class DefaultVideoFrameProcessor implements VideoFrameProcessor {
ColorInfo
.
isTransferHdr
(
inputColorInfo
)
||
ColorInfo
.
isTransferHdr
(
outputColorInfo
)
?
3
:
2
;
ColorInfo
.
isTransferHdr
(
inputColorInfo
)
||
ColorInfo
.
isTransferHdr
(
outputColorInfo
)
?
3
:
2
;
EGLContext
eglContext
=
EGLContext
eglContext
=
glObjectsProvider
.
createEglContext
(
eglDisplay
,
openGlVersion
,
configAttributes
);
glObjectsProvider
.
createEglContext
(
eglDisplay
,
openGlVersion
,
configAttributes
);
GlUtil
.
createFocusedPlaceholderEglSurface
(
eglContext
,
eglDisplay
,
configAttributes
);
glObjectsProvider
.
createFocusedPlaceholderEglSurface
(
eglContext
,
eglDisplay
,
configAttributes
);
// Not releaseFramesAutomatically means outputting to a display surface. HDR display surfaces
// Not releaseFramesAutomatically means outputting to a display surface. HDR display surfaces
// require the BT2020 PQ GL extension.
// require the BT2020 PQ GL extension.
...
@@ -422,7 +422,8 @@ public final class DefaultVideoFrameProcessor implements VideoFrameProcessor {
...
@@ -422,7 +422,8 @@ public final class DefaultVideoFrameProcessor implements VideoFrameProcessor {
isInputTextureExternal
,
isInputTextureExternal
,
releaseFramesAutomatically
,
releaseFramesAutomatically
,
executor
,
executor
,
listener
);
listener
,
glObjectsProvider
);
setGlObjectProviderOnShaderPrograms
(
shaderPrograms
,
glObjectsProvider
);
setGlObjectProviderOnShaderPrograms
(
shaderPrograms
,
glObjectsProvider
);
VideoFrameProcessingTaskExecutor
videoFrameProcessingTaskExecutor
=
VideoFrameProcessingTaskExecutor
videoFrameProcessingTaskExecutor
=
new
VideoFrameProcessingTaskExecutor
(
singleThreadExecutorService
,
listener
);
new
VideoFrameProcessingTaskExecutor
(
singleThreadExecutorService
,
listener
);
...
@@ -460,7 +461,8 @@ public final class DefaultVideoFrameProcessor implements VideoFrameProcessor {
...
@@ -460,7 +461,8 @@ public final class DefaultVideoFrameProcessor implements VideoFrameProcessor {
boolean
isInputTextureExternal
,
boolean
isInputTextureExternal
,
boolean
releaseFramesAutomatically
,
boolean
releaseFramesAutomatically
,
Executor
executor
,
Executor
executor
,
Listener
listener
)
Listener
listener
,
GlObjectsProvider
glObjectsProvider
)
throws
VideoFrameProcessingException
{
throws
VideoFrameProcessingException
{
ImmutableList
.
Builder
<
GlShaderProgram
>
shaderProgramListBuilder
=
new
ImmutableList
.
Builder
<>();
ImmutableList
.
Builder
<
GlShaderProgram
>
shaderProgramListBuilder
=
new
ImmutableList
.
Builder
<>();
ImmutableList
.
Builder
<
GlMatrixTransformation
>
matrixTransformationListBuilder
=
ImmutableList
.
Builder
<
GlMatrixTransformation
>
matrixTransformationListBuilder
=
...
@@ -533,7 +535,8 @@ public final class DefaultVideoFrameProcessor implements VideoFrameProcessor {
...
@@ -533,7 +535,8 @@ public final class DefaultVideoFrameProcessor implements VideoFrameProcessor {
isInputTextureExternal
,
isInputTextureExternal
,
releaseFramesAutomatically
,
releaseFramesAutomatically
,
executor
,
executor
,
listener
));
listener
,
glObjectsProvider
));
return
shaderProgramListBuilder
.
build
();
return
shaderProgramListBuilder
.
build
();
}
}
...
...
library/effect/src/main/java/com/google/android/exoplayer2/effect/FinalShaderProgramWrapper.java
View file @
44cf5735
...
@@ -116,7 +116,8 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
...
@@ -116,7 +116,8 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
boolean
isInputTextureExternal
,
boolean
isInputTextureExternal
,
boolean
releaseFramesAutomatically
,
boolean
releaseFramesAutomatically
,
Executor
videoFrameProcessorListenerExecutor
,
Executor
videoFrameProcessorListenerExecutor
,
VideoFrameProcessor
.
Listener
videoFrameProcessorListener
)
{
VideoFrameProcessor
.
Listener
videoFrameProcessorListener
,
GlObjectsProvider
glObjectsProvider
)
{
this
.
context
=
context
;
this
.
context
=
context
;
this
.
matrixTransformations
=
matrixTransformations
;
this
.
matrixTransformations
=
matrixTransformations
;
this
.
rgbMatrices
=
rgbMatrices
;
this
.
rgbMatrices
=
rgbMatrices
;
...
@@ -130,10 +131,10 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
...
@@ -130,10 +131,10 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
this
.
releaseFramesAutomatically
=
releaseFramesAutomatically
;
this
.
releaseFramesAutomatically
=
releaseFramesAutomatically
;
this
.
videoFrameProcessorListenerExecutor
=
videoFrameProcessorListenerExecutor
;
this
.
videoFrameProcessorListenerExecutor
=
videoFrameProcessorListenerExecutor
;
this
.
videoFrameProcessorListener
=
videoFrameProcessorListener
;
this
.
videoFrameProcessorListener
=
videoFrameProcessorListener
;
this
.
glObjectsProvider
=
glObjectsProvider
;
textureTransformMatrix
=
GlUtil
.
create4x4IdentityMatrix
();
textureTransformMatrix
=
GlUtil
.
create4x4IdentityMatrix
();
streamOffsetUsQueue
=
new
ConcurrentLinkedQueue
<>();
streamOffsetUsQueue
=
new
ConcurrentLinkedQueue
<>();
glObjectsProvider
=
GlObjectsProvider
.
DEFAULT
;
inputListener
=
new
InputListener
()
{};
inputListener
=
new
InputListener
()
{};
availableFrames
=
new
ConcurrentLinkedQueue
<>();
availableFrames
=
new
ConcurrentLinkedQueue
<>();
}
}
...
@@ -375,7 +376,7 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
...
@@ -375,7 +376,7 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
@Nullable
EGLSurface
outputEglSurface
=
this
.
outputEglSurface
;
@Nullable
EGLSurface
outputEglSurface
=
this
.
outputEglSurface
;
if
(
outputEglSurface
==
null
)
{
if
(
outputEglSurface
==
null
)
{
outputEglSurface
=
outputEglSurface
=
GlUtil
.
createEglSurface
(
glObjectsProvider
.
createEglSurface
(
eglDisplay
,
eglDisplay
,
outputSurfaceInfo
.
surface
,
outputSurfaceInfo
.
surface
,
outputColorInfo
.
colorTransfer
,
outputColorInfo
.
colorTransfer
,
...
@@ -472,7 +473,8 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
...
@@ -472,7 +473,8 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
checkNotNull
(
debugSurfaceViewWrapper
).
outputColorTransfer
);
checkNotNull
(
debugSurfaceViewWrapper
).
outputColorTransfer
);
defaultShaderProgram
.
drawFrame
(
inputTexture
.
texId
,
presentationTimeUs
);
defaultShaderProgram
.
drawFrame
(
inputTexture
.
texId
,
presentationTimeUs
);
defaultShaderProgram
.
setOutputColorTransfer
(
configuredColorTransfer
);
defaultShaderProgram
.
setOutputColorTransfer
(
configuredColorTransfer
);
});
},
glObjectsProvider
);
}
catch
(
VideoFrameProcessingException
|
GlUtil
.
GlException
e
)
{
}
catch
(
VideoFrameProcessingException
|
GlUtil
.
GlException
e
)
{
Log
.
d
(
TAG
,
"Error rendering to debug preview"
,
e
);
Log
.
d
(
TAG
,
"Error rendering to debug preview"
,
e
);
}
}
...
@@ -546,7 +548,8 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
...
@@ -546,7 +548,8 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
*
*
* <p>Must be called on the GL thread.
* <p>Must be called on the GL thread.
*/
*/
public
synchronized
void
maybeRenderToSurfaceView
(
VideoFrameProcessingTask
renderingTask
)
public
synchronized
void
maybeRenderToSurfaceView
(
VideoFrameProcessingTask
renderingTask
,
GlObjectsProvider
glObjectsProvider
)
throws
GlUtil
.
GlException
,
VideoFrameProcessingException
{
throws
GlUtil
.
GlException
,
VideoFrameProcessingException
{
if
(
surface
==
null
)
{
if
(
surface
==
null
)
{
return
;
return
;
...
@@ -554,7 +557,7 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
...
@@ -554,7 +557,7 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
if
(
eglSurface
==
null
)
{
if
(
eglSurface
==
null
)
{
eglSurface
=
eglSurface
=
GlUtil
.
createEglSurface
(
glObjectsProvider
.
createEglSurface
(
eglDisplay
,
surface
,
outputColorTransfer
,
/* isEncoderInputSurface= */
false
);
eglDisplay
,
surface
,
outputColorTransfer
,
/* isEncoderInputSurface= */
false
);
}
}
EGLSurface
eglSurface
=
this
.
eglSurface
;
EGLSurface
eglSurface
=
this
.
eglSurface
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment