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
47e3b4dc
authored
Aug 17, 2017
by
Oliver Woodman
Committed by
Oliver Woodman
Sep 09, 2017
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
Minor style tweaks
parent
51dac583
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
70 additions
and
28 deletions
library/core/src/androidTest/assets/subrip/typical_unexpected_end
library/core/src/androidTest/java/com/google/android/exoplayer2/text/subrip/SubripDecoderTest.java
library/core/src/main/java/com/google/android/exoplayer2/drm/OfflineLicenseHelper.java
library/core/src/main/java/com/google/android/exoplayer2/extractor/mp4/AtomParsers.java
library/core/src/main/java/com/google/android/exoplayer2/text/subrip/SubripDecoder.java
library/core/src/androidTest/assets/subrip/typical_unexpected_end
0 → 100644
View file @
47e3b4dc
1
00:00:00,000 --> 00:00:01,234
This is the first subtitle.
2
00:00:02,345 --> 00:00:03,456
This is the second subtitle.
Second subtitle with second line.
3
\ No newline at end of file
library/core/src/androidTest/java/com/google/android/exoplayer2/text/subrip/SubripDecoderTest.java
View file @
47e3b4dc
...
@@ -31,6 +31,7 @@ public final class SubripDecoderTest extends InstrumentationTestCase {
...
@@ -31,6 +31,7 @@ public final class SubripDecoderTest extends InstrumentationTestCase {
private
static
final
String
TYPICAL_MISSING_TIMECODE
=
"subrip/typical_missing_timecode"
;
private
static
final
String
TYPICAL_MISSING_TIMECODE
=
"subrip/typical_missing_timecode"
;
private
static
final
String
TYPICAL_MISSING_SEQUENCE
=
"subrip/typical_missing_sequence"
;
private
static
final
String
TYPICAL_MISSING_SEQUENCE
=
"subrip/typical_missing_sequence"
;
private
static
final
String
TYPICAL_NEGATIVE_TIMESTAMPS
=
"subrip/typical_negative_timestamps"
;
private
static
final
String
TYPICAL_NEGATIVE_TIMESTAMPS
=
"subrip/typical_negative_timestamps"
;
private
static
final
String
TYPICAL_UNEXPECTED_END
=
"subrip/typical_unexpected_end"
;
private
static
final
String
NO_END_TIMECODES_FILE
=
"subrip/no_end_timecodes"
;
private
static
final
String
NO_END_TIMECODES_FILE
=
"subrip/no_end_timecodes"
;
public
void
testDecodeEmpty
()
throws
IOException
{
public
void
testDecodeEmpty
()
throws
IOException
{
...
@@ -107,6 +108,17 @@ public final class SubripDecoderTest extends InstrumentationTestCase {
...
@@ -107,6 +108,17 @@ public final class SubripDecoderTest extends InstrumentationTestCase {
assertTypicalCue3
(
subtitle
,
0
);
assertTypicalCue3
(
subtitle
,
0
);
}
}
public
void
testDecodeTypicalUnexpectedEnd
()
throws
IOException
{
// Parsing should succeed, parsing the first and second cues only.
SubripDecoder
decoder
=
new
SubripDecoder
();
byte
[]
bytes
=
TestUtil
.
getByteArray
(
getInstrumentation
(),
TYPICAL_UNEXPECTED_END
);
SubripSubtitle
subtitle
=
decoder
.
decode
(
bytes
,
bytes
.
length
,
false
);
assertEquals
(
4
,
subtitle
.
getEventTimeCount
());
assertTypicalCue1
(
subtitle
,
0
);
assertTypicalCue2
(
subtitle
,
2
);
}
public
void
testDecodeNoEndTimecodes
()
throws
IOException
{
public
void
testDecodeNoEndTimecodes
()
throws
IOException
{
SubripDecoder
decoder
=
new
SubripDecoder
();
SubripDecoder
decoder
=
new
SubripDecoder
();
byte
[]
bytes
=
TestUtil
.
getByteArray
(
getInstrumentation
(),
NO_END_TIMECODES_FILE
);
byte
[]
bytes
=
TestUtil
.
getByteArray
(
getInstrumentation
(),
NO_END_TIMECODES_FILE
);
...
...
library/core/src/main/java/com/google/android/exoplayer2/drm/OfflineLicenseHelper.java
View file @
47e3b4dc
...
@@ -116,9 +116,32 @@ public final class OfflineLicenseHelper<T extends ExoMediaCrypto> {
...
@@ -116,9 +116,32 @@ public final class OfflineLicenseHelper<T extends ExoMediaCrypto> {
optionalKeyRequestParameters
,
new
Handler
(
handlerThread
.
getLooper
()),
eventListener
);
optionalKeyRequestParameters
,
new
Handler
(
handlerThread
.
getLooper
()),
eventListener
);
}
}
/** Releases the helper. Should be called when the helper is no longer required. */
/**
public
void
release
()
{
* @see DefaultDrmSessionManager#getPropertyByteArray
handlerThread
.
quit
();
*/
public
synchronized
byte
[]
getPropertyByteArray
(
String
key
)
{
return
drmSessionManager
.
getPropertyByteArray
(
key
);
}
/**
* @see DefaultDrmSessionManager#setPropertyByteArray
*/
public
synchronized
void
setPropertyByteArray
(
String
key
,
byte
[]
value
)
{
drmSessionManager
.
setPropertyByteArray
(
key
,
value
);
}
/**
* @see DefaultDrmSessionManager#getPropertyString
*/
public
synchronized
String
getPropertyString
(
String
key
)
{
return
drmSessionManager
.
getPropertyString
(
key
);
}
/**
* @see DefaultDrmSessionManager#setPropertyString
*/
public
synchronized
void
setPropertyString
(
String
key
,
String
value
)
{
drmSessionManager
.
setPropertyString
(
key
,
value
);
}
}
/**
/**
...
@@ -185,21 +208,12 @@ public final class OfflineLicenseHelper<T extends ExoMediaCrypto> {
...
@@ -185,21 +208,12 @@ public final class OfflineLicenseHelper<T extends ExoMediaCrypto> {
}
}
return
licenseDurationRemainingSec
;
return
licenseDurationRemainingSec
;
}
}
public
byte
[]
getPropertyByteArray
(
String
key
)
{
return
drmSessionManager
.
getPropertyByteArray
(
key
);
}
public
void
setPropertyByteArray
(
String
key
,
byte
[]
value
)
{
drmSessionManager
.
setPropertyByteArray
(
key
,
value
);
}
public
String
getPropertyString
(
String
key
)
{
/**
return
drmSessionManager
.
getPropertyString
(
key
);
* Releases the helper. Should be called when the helper is no longer required.
}
*/
public
void
release
()
{
public
void
setPropertyString
(
String
key
,
String
value
)
{
handlerThread
.
quit
();
drmSessionManager
.
setPropertyString
(
key
,
value
);
}
}
private
byte
[]
blockingKeyRequest
(
@Mode
int
licenseMode
,
byte
[]
offlineLicenseKeySetId
,
private
byte
[]
blockingKeyRequest
(
@Mode
int
licenseMode
,
byte
[]
offlineLicenseKeySetId
,
...
...
library/core/src/main/java/com/google/android/exoplayer2/extractor/mp4/AtomParsers.java
View file @
47e3b4dc
...
@@ -995,9 +995,10 @@ import java.util.List;
...
@@ -995,9 +995,10 @@ import java.util.List;
int
objectTypeIndication
=
parent
.
readUnsignedByte
();
int
objectTypeIndication
=
parent
.
readUnsignedByte
();
String
mimeType
;
String
mimeType
;
switch
(
objectTypeIndication
)
{
switch
(
objectTypeIndication
)
{
case
0x6B
:
case
0x60
:
mimeType
=
MimeTypes
.
AUDIO_MPEG
;
case
0x61
:
return
Pair
.
create
(
mimeType
,
null
);
mimeType
=
MimeTypes
.
VIDEO_MPEG2
;
break
;
case
0x20
:
case
0x20
:
mimeType
=
MimeTypes
.
VIDEO_MP4V
;
mimeType
=
MimeTypes
.
VIDEO_MP4V
;
break
;
break
;
...
@@ -1007,6 +1008,9 @@ import java.util.List;
...
@@ -1007,6 +1008,9 @@ import java.util.List;
case
0x23
:
case
0x23
:
mimeType
=
MimeTypes
.
VIDEO_H265
;
mimeType
=
MimeTypes
.
VIDEO_H265
;
break
;
break
;
case
0x6B
:
mimeType
=
MimeTypes
.
AUDIO_MPEG
;
return
Pair
.
create
(
mimeType
,
null
);
case
0x40
:
case
0x40
:
case
0x66
:
case
0x66
:
case
0x67
:
case
0x67
:
...
@@ -1027,10 +1031,6 @@ import java.util.List;
...
@@ -1027,10 +1031,6 @@ import java.util.List;
case
0xAB
:
case
0xAB
:
mimeType
=
MimeTypes
.
AUDIO_DTS_HD
;
mimeType
=
MimeTypes
.
AUDIO_DTS_HD
;
return
Pair
.
create
(
mimeType
,
null
);
return
Pair
.
create
(
mimeType
,
null
);
case
0x60
:
/* Visual 13818-2 Simple Profile */
case
0x61
:
/* Visual 13818-2 Main Profile */
mimeType
=
MimeTypes
.
VIDEO_MPEG2
;
break
;
default
:
default
:
mimeType
=
null
;
mimeType
=
null
;
break
;
break
;
...
@@ -1038,8 +1038,8 @@ import java.util.List;
...
@@ -1038,8 +1038,8 @@ import java.util.List;
parent
.
skipBytes
(
12
);
parent
.
skipBytes
(
12
);
// Start of the
AudioSpecificConfig
.
// Start of the
DecoderSpecificInfo
.
parent
.
skipBytes
(
1
);
//
AudioSpecificConfig
tag
parent
.
skipBytes
(
1
);
//
DecoderSpecificInfo
tag
int
initializationDataSize
=
parseExpandableClassSize
(
parent
);
int
initializationDataSize
=
parseExpandableClassSize
(
parent
);
byte
[]
initializationData
=
new
byte
[
initializationDataSize
];
byte
[]
initializationData
=
new
byte
[
initializationDataSize
];
parent
.
readBytes
(
initializationData
,
0
,
initializationDataSize
);
parent
.
readBytes
(
initializationData
,
0
,
initializationDataSize
);
...
...
library/core/src/main/java/com/google/android/exoplayer2/text/subrip/SubripDecoder.java
View file @
47e3b4dc
...
@@ -69,8 +69,13 @@ public final class SubripDecoder extends SimpleSubtitleDecoder {
...
@@ -69,8 +69,13 @@ public final class SubripDecoder extends SimpleSubtitleDecoder {
// Read and parse the timing line.
// Read and parse the timing line.
boolean
haveEndTimecode
=
false
;
boolean
haveEndTimecode
=
false
;
currentLine
=
subripData
.
readLine
();
currentLine
=
subripData
.
readLine
();
Matcher
matcher
=
currentLine
==
null
?
null
:
SUBRIP_TIMING_LINE
.
matcher
(
currentLine
);
if
(
currentLine
==
null
)
{
if
(
matcher
!=
null
&&
matcher
.
matches
())
{
Log
.
w
(
TAG
,
"Unexpected end"
);
break
;
}
Matcher
matcher
=
SUBRIP_TIMING_LINE
.
matcher
(
currentLine
);
if
(
matcher
.
matches
())
{
cueTimesUs
.
add
(
parseTimecode
(
matcher
,
1
));
cueTimesUs
.
add
(
parseTimecode
(
matcher
,
1
));
if
(!
TextUtils
.
isEmpty
(
matcher
.
group
(
6
)))
{
if
(!
TextUtils
.
isEmpty
(
matcher
.
group
(
6
)))
{
haveEndTimecode
=
true
;
haveEndTimecode
=
true
;
...
...
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