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
66c461e6
authored
Jun 19, 2017
by
Karol Wrótniak
Committed by
Oliver Woodman
Jun 30, 2017
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
Comments from
https://github.com/google/ExoPlayer/pull/2963#discussion_r122669328
applied
parent
a0a50ac9
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
43 additions
and
20 deletions
library/core/src/androidTest/java/com/google/android/exoplayer2/upstream/AndroidDataSourceConstants.java
library/core/src/androidTest/java/com/google/android/exoplayer2/upstream/AndroidDataSourceTest.java → library/core/src/androidTest/java/com/google/android/exoplayer2/upstream/AssetDataSourceTest.java
library/core/src/androidTest/java/com/google/android/exoplayer2/upstream/ContentDataSourceTest.java
library/core/src/main/java/com/google/android/exoplayer2/upstream/ContentDataSource.java
library/core/src/androidTest/java/com/google/android/exoplayer2/upstream/AndroidDataSourceConstants.java
0 → 100644
View file @
66c461e6
package
com
.
google
.
android
.
exoplayer2
.
upstream
;
final
class
AndroidDataSourceConstants
{
static
final
long
SAMPLE_MP4_BYTES
=
101597
;
static
final
String
SAMPLE_MP4_PATH
=
"/mp4/sample.mp4"
;
private
AndroidDataSourceConstants
()
{}
}
library/core/src/androidTest/java/com/google/android/exoplayer2/upstream/A
ndroid
DataSourceTest.java
→
library/core/src/androidTest/java/com/google/android/exoplayer2/upstream/A
sset
DataSourceTest.java
View file @
66c461e6
...
@@ -4,10 +4,10 @@ import android.content.Context;
...
@@ -4,10 +4,10 @@ import android.content.Context;
import
android.net.Uri
;
import
android.net.Uri
;
import
android.test.InstrumentationTestCase
;
import
android.test.InstrumentationTestCase
;
public
class
AndroidDataSourceTest
extends
InstrumentationTestCase
{
import
static
com
.
google
.
android
.
exoplayer2
.
upstream
.
AndroidDataSourceConstants
.
SAMPLE_MP4_BYTES
;
import
static
com
.
google
.
android
.
exoplayer2
.
upstream
.
AndroidDataSourceConstants
.
SAMPLE_MP4_PATH
;
private
static
final
long
SAMPLE_MP4_BYTES
=
101597
;
public
class
AssetDataSourceTest
extends
InstrumentationTestCase
{
private
static
final
String
SAMPLE_MP4_PATH
=
"/mp4/sample.mp4"
;
public
void
testAssetDataSource
()
throws
Exception
{
public
void
testAssetDataSource
()
throws
Exception
{
final
Context
context
=
getInstrumentation
().
getContext
();
final
Context
context
=
getInstrumentation
().
getContext
();
...
@@ -18,14 +18,4 @@ public class AndroidDataSourceTest extends InstrumentationTestCase {
...
@@ -18,14 +18,4 @@ public class AndroidDataSourceTest extends InstrumentationTestCase {
assertEquals
(
SAMPLE_MP4_BYTES
,
sourceLengthBytes
);
assertEquals
(
SAMPLE_MP4_BYTES
,
sourceLengthBytes
);
}
}
public
void
testContentDataSource
()
throws
Exception
{
Context
context
=
getInstrumentation
().
getContext
();
ContentDataSource
dataSource
=
new
ContentDataSource
(
context
);
Uri
contentUri
=
Uri
.
parse
(
"content://exoplayer"
+
SAMPLE_MP4_PATH
);
DataSpec
dataSpec
=
new
DataSpec
(
contentUri
);
long
sourceLengthBytes
=
dataSource
.
open
(
dataSpec
);
assertEquals
(
SAMPLE_MP4_BYTES
,
sourceLengthBytes
);
}
}
}
library/core/src/androidTest/java/com/google/android/exoplayer2/upstream/ContentDataSourceTest.java
0 → 100644
View file @
66c461e6
package
com
.
google
.
android
.
exoplayer2
.
upstream
;
import
android.content.Context
;
import
android.net.Uri
;
import
android.test.InstrumentationTestCase
;
import
static
com
.
google
.
android
.
exoplayer2
.
upstream
.
AndroidDataSourceConstants
.
SAMPLE_MP4_BYTES
;
import
static
com
.
google
.
android
.
exoplayer2
.
upstream
.
AndroidDataSourceConstants
.
SAMPLE_MP4_PATH
;
public
class
ContentDataSourceTest
extends
InstrumentationTestCase
{
public
void
testContentDataSource
()
throws
Exception
{
Context
context
=
getInstrumentation
().
getContext
();
ContentDataSource
dataSource
=
new
ContentDataSource
(
context
);
Uri
contentUri
=
Uri
.
parse
(
"content://exoplayer"
+
SAMPLE_MP4_PATH
);
DataSpec
dataSpec
=
new
DataSpec
(
contentUri
);
long
sourceLengthBytes
=
dataSource
.
open
(
dataSpec
);
assertEquals
(
SAMPLE_MP4_BYTES
,
sourceLengthBytes
);
}
}
library/core/src/main/java/com/google/android/exoplayer2/upstream/ContentDataSource.java
View file @
66c461e6
...
@@ -71,7 +71,7 @@ public final class ContentDataSource implements DataSource {
...
@@ -71,7 +71,7 @@ public final class ContentDataSource implements DataSource {
try
{
try
{
uri
=
dataSpec
.
uri
;
uri
=
dataSpec
.
uri
;
assetFileDescriptor
=
resolver
.
openAssetFileDescriptor
(
uri
,
"r"
);
assetFileDescriptor
=
resolver
.
openAssetFileDescriptor
(
uri
,
"r"
);
inputStream
=
assetFileDescriptor
.
createInputStream
(
);
inputStream
=
new
FileInputStream
(
assetFileDescriptor
.
getFileDescriptor
()
);
long
skipped
=
inputStream
.
skip
(
dataSpec
.
position
);
long
skipped
=
inputStream
.
skip
(
dataSpec
.
position
);
if
(
skipped
<
dataSpec
.
position
)
{
if
(
skipped
<
dataSpec
.
position
)
{
// We expect the skip to be satisfied in full. If it isn't then we're probably trying to
// We expect the skip to be satisfied in full. If it isn't then we're probably trying to
...
@@ -81,12 +81,16 @@ public final class ContentDataSource implements DataSource {
...
@@ -81,12 +81,16 @@ public final class ContentDataSource implements DataSource {
if
(
dataSpec
.
length
!=
C
.
LENGTH_UNSET
)
{
if
(
dataSpec
.
length
!=
C
.
LENGTH_UNSET
)
{
bytesRemaining
=
dataSpec
.
length
;
bytesRemaining
=
dataSpec
.
length
;
}
else
{
}
else
{
bytesRemaining
=
inputStream
.
available
();
bytesRemaining
=
assetFileDescriptor
.
getLength
();
if
(
bytesRemaining
==
0
)
{
if
(
bytesRemaining
==
AssetFileDescriptor
.
UNKNOWN_LENGTH
)
{
// FileInputStream.available() returns 0 if the remaining length cannot be determined, or
// The asset must extend to the end of the file.
// if it's greater than Integer.MAX_VALUE. We don't know the true length in either case,
bytesRemaining
=
inputStream
.
available
();
// so treat as unbounded.
if
(
bytesRemaining
==
0
)
{
bytesRemaining
=
C
.
LENGTH_UNSET
;
// FileInputStream.available() returns 0 if the remaining length cannot be determined, or
// if it's greater than Integer.MAX_VALUE. We don't know the true length in either case,
// so treat as unbounded.
bytesRemaining
=
C
.
LENGTH_UNSET
;
}
}
}
}
}
}
catch
(
IOException
e
)
{
}
catch
(
IOException
e
)
{
...
...
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