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
d9529479
authored
Sep 04, 2019
by
wingyippp
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
get 2 SeekPoints from the getSeekPosition() in flac_parser
parent
a02237de
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
36 additions
and
12 deletions
extensions/flac/src/main/java/com/google/android/exoplayer2/ext/flac/FlacDecoderJni.java
extensions/flac/src/main/java/com/google/android/exoplayer2/ext/flac/FlacExtractor.java
extensions/flac/src/main/jni/flac_jni.cc
extensions/flac/src/main/jni/flac_parser.cc
extensions/flac/src/main/jni/include/flac_parser.h
extensions/flac/src/main/java/com/google/android/exoplayer2/ext/flac/FlacDecoderJni.java
View file @
d9529479
...
@@ -223,7 +223,7 @@ import java.nio.ByteBuffer;
...
@@ -223,7 +223,7 @@ import java.nio.ByteBuffer;
* @return The corresponding position (byte offset) in the flac stream or -1 if the stream doesn't
* @return The corresponding position (byte offset) in the flac stream or -1 if the stream doesn't
* have a seek table.
* have a seek table.
*/
*/
public
long
getSeekPosition
(
long
timeUs
)
{
public
long
[]
getSeekPosition
(
long
timeUs
)
{
return
flacGetSeekPosition
(
nativeDecoderContext
,
timeUs
);
return
flacGetSeekPosition
(
nativeDecoderContext
,
timeUs
);
}
}
...
@@ -283,7 +283,7 @@ import java.nio.ByteBuffer;
...
@@ -283,7 +283,7 @@ import java.nio.ByteBuffer;
private
native
long
flacGetNextFrameFirstSampleIndex
(
long
context
);
private
native
long
flacGetNextFrameFirstSampleIndex
(
long
context
);
private
native
long
flacGetSeekPosition
(
long
context
,
long
timeUs
);
private
native
long
[]
flacGetSeekPosition
(
long
context
,
long
timeUs
);
private
native
String
flacGetStateString
(
long
context
);
private
native
String
flacGetStateString
(
long
context
);
...
...
extensions/flac/src/main/java/com/google/android/exoplayer2/ext/flac/FlacExtractor.java
View file @
d9529479
...
@@ -276,7 +276,8 @@ public final class FlacExtractor implements Extractor {
...
@@ -276,7 +276,8 @@ public final class FlacExtractor implements Extractor {
FlacStreamMetadata
streamMetadata
,
FlacStreamMetadata
streamMetadata
,
long
streamLength
,
long
streamLength
,
ExtractorOutput
output
)
{
ExtractorOutput
output
)
{
boolean
hasSeekTable
=
decoderJni
.
getSeekPosition
(
/* timeUs= */
0
)
!=
-
1
;
long
[]
result
=
decoderJni
.
getSeekPosition
(
/* timeUs= */
0
);
boolean
hasSeekTable
=
result
.
length
==
4
&&
result
[
1
]
!=
-
1
&&
result
[
3
]
!=
-
1
;
FlacBinarySearchSeeker
binarySearchSeeker
=
null
;
FlacBinarySearchSeeker
binarySearchSeeker
=
null
;
SeekMap
seekMap
;
SeekMap
seekMap
;
if
(
hasSeekTable
)
{
if
(
hasSeekTable
)
{
...
@@ -341,8 +342,12 @@ public final class FlacExtractor implements Extractor {
...
@@ -341,8 +342,12 @@ public final class FlacExtractor implements Extractor {
@Override
@Override
public
SeekPoints
getSeekPoints
(
long
timeUs
)
{
public
SeekPoints
getSeekPoints
(
long
timeUs
)
{
// TODO: Access the seek table via JNI to return two seek points when appropriate.
long
[]
result
=
decoderJni
.
getSeekPosition
(
timeUs
);
return
new
SeekPoints
(
new
SeekPoint
(
timeUs
,
decoderJni
.
getSeekPosition
(
timeUs
)));
if
(
result
.
length
==
4
)
{
return
new
SeekPoints
(
new
SeekPoint
(
result
[
0
],
result
[
1
]),
new
SeekPoint
(
result
[
2
],
result
[
3
]));
}
else
{
return
new
SeekPoints
(
new
SeekPoint
(
timeUs
,
decoderJni
.
getDecodePosition
()));
}
}
}
@Override
@Override
...
...
extensions/flac/src/main/jni/flac_jni.cc
View file @
d9529479
...
@@ -200,9 +200,13 @@ DECODER_FUNC(jlong, flacGetNextFrameFirstSampleIndex, jlong jContext) {
...
@@ -200,9 +200,13 @@ DECODER_FUNC(jlong, flacGetNextFrameFirstSampleIndex, jlong jContext) {
return
context
->
parser
->
getNextFrameFirstSampleIndex
();
return
context
->
parser
->
getNextFrameFirstSampleIndex
();
}
}
DECODER_FUNC
(
jlong
,
flacGetSeekPosition
,
jlong
jContext
,
jlong
timeUs
)
{
DECODER_FUNC
(
jlong
Array
,
flacGetSeekPosition
,
jlong
jContext
,
jlong
timeUs
)
{
Context
*
context
=
reinterpret_cast
<
Context
*>
(
jContext
);
Context
*
context
=
reinterpret_cast
<
Context
*>
(
jContext
);
return
context
->
parser
->
getSeekPosition
(
timeUs
);
int64_t
*
result
=
context
->
parser
->
getSeekPosition
(
timeUs
);
const
jlong
resultJLong
[
4
]
=
{
result
[
0
],
result
[
1
],
result
[
2
],
result
[
3
]};
jlongArray
resultArray
=
env
->
NewLongArray
(
4
);
env
->
SetLongArrayRegion
(
resultArray
,
0
,
4
,
resultJLong
);
return
resultArray
;
}
}
DECODER_FUNC
(
jstring
,
flacGetStateString
,
jlong
jContext
)
{
DECODER_FUNC
(
jstring
,
flacGetStateString
,
jlong
jContext
)
{
...
...
extensions/flac/src/main/jni/flac_parser.cc
View file @
d9529479
...
@@ -438,9 +438,11 @@ size_t FLACParser::readBuffer(void *output, size_t output_size) {
...
@@ -438,9 +438,11 @@ size_t FLACParser::readBuffer(void *output, size_t output_size) {
return
bufferSize
;
return
bufferSize
;
}
}
int64_t
FLACParser
::
getSeekPosition
(
int64_t
timeUs
)
{
int64_t
*
FLACParser
::
getSeekPosition
(
int64_t
timeUs
)
{
int64_t
*
result
=
new
int64_t
[
4
];
memset
(
result
,
-
1
,
sizeof
(
result
));
if
(
!
mSeekTable
)
{
if
(
!
mSeekTable
)
{
return
-
1
;
return
result
;
}
}
int64_t
sample
=
(
timeUs
*
getSampleRate
())
/
1000000LL
;
int64_t
sample
=
(
timeUs
*
getSampleRate
())
/
1000000LL
;
...
@@ -452,8 +454,21 @@ int64_t FLACParser::getSeekPosition(int64_t timeUs) {
...
@@ -452,8 +454,21 @@ int64_t FLACParser::getSeekPosition(int64_t timeUs) {
for
(
unsigned
i
=
mSeekTable
->
num_points
;
i
>
0
;
)
{
for
(
unsigned
i
=
mSeekTable
->
num_points
;
i
>
0
;
)
{
i
--
;
i
--
;
if
(
points
[
i
].
sample_number
<=
sample
)
{
if
(
points
[
i
].
sample_number
<=
sample
)
{
return
firstFrameOffset
+
points
[
i
].
stream_offset
;
result
[
0
]
=
points
[
i
].
sample_number
/
getSampleRate
()
*
1000000LL
;
result
[
1
]
=
firstFrameOffset
+
points
[
i
].
stream_offset
;
if
(
i
+
1
<=
mSeekTable
->
num_points
)
{
result
[
2
]
=
points
[
i
+
1
].
sample_number
/
getSampleRate
()
*
1000000LL
;
result
[
3
]
=
firstFrameOffset
+
points
[
i
+
1
].
stream_offset
;
}
else
{
result
[
2
]
=
result
[
0
];
result
[
3
]
=
result
[
1
];
}
return
result
;
}
}
}
}
return
firstFrameOffset
;
result
[
0
]
=
timeUs
;
result
[
1
]
=
firstFrameOffset
;
result
[
2
]
=
timeUs
;
result
[
3
]
=
firstFrameOffset
;
return
result
;
}
}
extensions/flac/src/main/jni/include/flac_parser.h
View file @
d9529479
...
@@ -84,7 +84,7 @@ class FLACParser {
...
@@ -84,7 +84,7 @@ class FLACParser {
bool
decodeMetadata
();
bool
decodeMetadata
();
size_t
readBuffer
(
void
*
output
,
size_t
output_size
);
size_t
readBuffer
(
void
*
output
,
size_t
output_size
);
int64_t
getSeekPosition
(
int64_t
timeUs
);
int64_t
*
getSeekPosition
(
int64_t
timeUs
);
void
flush
()
{
void
flush
()
{
reset
(
mCurrentPos
);
reset
(
mCurrentPos
);
...
...
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