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
90c17fbe
authored
Jul 08, 2020
by
olly
Committed by
kim-vde
Jul 08, 2020
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
CameraMotionRenderer: Cleanup + respect decode-only flag
PiperOrigin-RevId: 320149613
parent
8748646c
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
11 deletions
library/core/src/main/java/com/google/android/exoplayer2/video/spherical/CameraMotionRenderer.java
library/core/src/main/java/com/google/android/exoplayer2/video/spherical/CameraMotionRenderer.java
View file @
90c17fbe
...
@@ -31,7 +31,7 @@ import com.google.android.exoplayer2.util.Util;
...
@@ -31,7 +31,7 @@ import com.google.android.exoplayer2.util.Util;
import
java.nio.ByteBuffer
;
import
java.nio.ByteBuffer
;
/** A {@link Renderer} that parses the camera motion track. */
/** A {@link Renderer} that parses the camera motion track. */
public
class
CameraMotionRenderer
extends
BaseRenderer
{
public
final
class
CameraMotionRenderer
extends
BaseRenderer
{
private
static
final
String
TAG
=
"CameraMotionRenderer"
;
private
static
final
String
TAG
=
"CameraMotionRenderer"
;
// The amount of time to read samples ahead of the current time.
// The amount of time to read samples ahead of the current time.
...
@@ -73,12 +73,13 @@ public class CameraMotionRenderer extends BaseRenderer {
...
@@ -73,12 +73,13 @@ public class CameraMotionRenderer extends BaseRenderer {
}
}
@Override
@Override
protected
void
onStreamChanged
(
Format
[]
formats
,
long
offsetUs
)
throws
ExoPlaybackException
{
protected
void
onStreamChanged
(
Format
[]
formats
,
long
offsetUs
)
{
this
.
offsetUs
=
offsetUs
;
this
.
offsetUs
=
offsetUs
;
}
}
@Override
@Override
protected
void
onPositionReset
(
long
positionUs
,
boolean
joining
)
throws
ExoPlaybackException
{
protected
void
onPositionReset
(
long
positionUs
,
boolean
joining
)
{
lastTimestampUs
=
Long
.
MIN_VALUE
;
resetListener
();
resetListener
();
}
}
...
@@ -88,7 +89,7 @@ public class CameraMotionRenderer extends BaseRenderer {
...
@@ -88,7 +89,7 @@ public class CameraMotionRenderer extends BaseRenderer {
}
}
@Override
@Override
public
void
render
(
long
positionUs
,
long
elapsedRealtimeUs
)
throws
ExoPlaybackException
{
public
void
render
(
long
positionUs
,
long
elapsedRealtimeUs
)
{
// Keep reading available samples as long as the sample time is not too far into the future.
// Keep reading available samples as long as the sample time is not too far into the future.
while
(!
hasReadStreamToEnd
()
&&
lastTimestampUs
<
positionUs
+
SAMPLE_WINDOW_DURATION_US
)
{
while
(!
hasReadStreamToEnd
()
&&
lastTimestampUs
<
positionUs
+
SAMPLE_WINDOW_DURATION_US
)
{
buffer
.
clear
();
buffer
.
clear
();
...
@@ -99,14 +100,18 @@ public class CameraMotionRenderer extends BaseRenderer {
...
@@ -99,14 +100,18 @@ public class CameraMotionRenderer extends BaseRenderer {
return
;
return
;
}
}
buffer
.
flip
();
lastTimestampUs
=
buffer
.
timeUs
;
lastTimestampUs
=
buffer
.
timeUs
;
if
(
listener
!=
null
)
{
if
(
listener
==
null
||
buffer
.
isDecodeOnly
())
{
float
[]
rotation
=
parseMetadata
(
Util
.
castNonNull
(
buffer
.
data
));
continue
;
if
(
rotation
!=
null
)
{
Util
.
castNonNull
(
listener
).
onCameraMotion
(
lastTimestampUs
-
offsetUs
,
rotation
);
}
}
}
buffer
.
flip
();
@Nullable
float
[]
rotation
=
parseMetadata
(
Util
.
castNonNull
(
buffer
.
data
));
if
(
rotation
==
null
)
{
continue
;
}
Util
.
castNonNull
(
listener
).
onCameraMotion
(
lastTimestampUs
-
offsetUs
,
rotation
);
}
}
}
}
...
@@ -135,7 +140,6 @@ public class CameraMotionRenderer extends BaseRenderer {
...
@@ -135,7 +140,6 @@ public class CameraMotionRenderer extends BaseRenderer {
}
}
private
void
resetListener
()
{
private
void
resetListener
()
{
lastTimestampUs
=
0
;
if
(
listener
!=
null
)
{
if
(
listener
!=
null
)
{
listener
.
onCameraMotionReset
();
listener
.
onCameraMotionReset
();
}
}
...
...
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