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
93cc9164
authored
Mar 11, 2021
by
olly
Committed by
Ian Baker
Mar 12, 2021
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
Make DataSchemeDataSource consistent with other DataSource impls
PiperOrigin-RevId: 362388683
parent
1a68f3d3
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
9 deletions
library/core/src/main/java/com/google/android/exoplayer2/upstream/DataSchemeDataSource.java
library/core/src/main/java/com/google/android/exoplayer2/upstream/DataSchemeDataSource.java
View file @
93cc9164
...
...
@@ -35,8 +35,8 @@ public final class DataSchemeDataSource extends BaseDataSource {
@Nullable
private
DataSpec
dataSpec
;
@Nullable
private
byte
[]
data
;
private
int
endPosition
;
private
int
readPosition
;
private
int
bytesRemaining
;
public
DataSchemeDataSource
()
{
super
(
/* isNetwork= */
false
);
...
...
@@ -46,7 +46,6 @@ public final class DataSchemeDataSource extends BaseDataSource {
public
long
open
(
DataSpec
dataSpec
)
throws
IOException
{
transferInitializing
(
dataSpec
);
this
.
dataSpec
=
dataSpec
;
readPosition
=
(
int
)
dataSpec
.
position
;
Uri
uri
=
dataSpec
.
uri
;
String
scheme
=
uri
.
getScheme
();
if
(!
SCHEME_DATA
.
equals
(
scheme
))
{
...
...
@@ -67,14 +66,17 @@ public final class DataSchemeDataSource extends BaseDataSource {
// TODO: Add support for other charsets.
data
=
Util
.
getUtf8Bytes
(
URLDecoder
.
decode
(
dataString
,
Charsets
.
US_ASCII
.
name
()));
}
endPosition
=
dataSpec
.
length
!=
C
.
LENGTH_UNSET
?
(
int
)
dataSpec
.
length
+
readPosition
:
data
.
length
;
if
(
readPosition
>=
endPosition
)
{
if
(
dataSpec
.
position
>
data
.
length
)
{
data
=
null
;
throw
new
DataSourceException
(
DataSourceException
.
POSITION_OUT_OF_RANGE
);
}
readPosition
=
(
int
)
dataSpec
.
position
;
bytesRemaining
=
data
.
length
-
readPosition
;
if
(
dataSpec
.
length
!=
C
.
LENGTH_UNSET
)
{
bytesRemaining
=
(
int
)
min
(
bytesRemaining
,
dataSpec
.
length
);
}
transferStarted
(
dataSpec
);
return
(
long
)
endPosition
-
readPosition
;
return
dataSpec
.
length
!=
C
.
LENGTH_UNSET
?
dataSpec
.
length
:
bytesRemaining
;
}
@Override
...
...
@@ -82,13 +84,13 @@ public final class DataSchemeDataSource extends BaseDataSource {
if
(
readLength
==
0
)
{
return
0
;
}
int
remainingBytes
=
endPosition
-
readPosition
;
if
(
remainingBytes
==
0
)
{
if
(
bytesRemaining
==
0
)
{
return
C
.
RESULT_END_OF_INPUT
;
}
readLength
=
min
(
readLength
,
remainingBytes
);
readLength
=
min
(
readLength
,
bytesRemaining
);
System
.
arraycopy
(
castNonNull
(
data
),
readPosition
,
buffer
,
offset
,
readLength
);
readPosition
+=
readLength
;
bytesRemaining
-=
readLength
;
bytesTransferred
(
readLength
);
return
readLength
;
}
...
...
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