diff options
author | Insun Kang <insun@google.com> | 2011-11-22 20:59:31 +0900 |
---|---|---|
committer | Insun Kang <insun@google.com> | 2011-11-22 21:11:49 +0900 |
commit | 0e0c3220ee1c4d57765e2cba3b07923921c55e08 (patch) | |
tree | 579d94e25dd5733d046a98bfe99781431dbd8676 | |
parent | 7c56bb3ac1fb758a222a0c23805704a2789657b6 (diff) | |
download | frameworks_av-0e0c3220ee1c4d57765e2cba3b07923921c55e08.zip frameworks_av-0e0c3220ee1c4d57765e2cba3b07923921c55e08.tar.gz frameworks_av-0e0c3220ee1c4d57765e2cba3b07923921c55e08.tar.bz2 |
Fix a subtitle bug: multiple blank lines in SubRip(srt) file.
TimedTextParser should handle multiple blank lines between subtitles
in SRT format.
Change-Id: Id81e0a14d9984141f68b9f0919942c85562301b3
-rw-r--r-- | media/libstagefright/timedtext/TimedTextParser.cpp | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/media/libstagefright/timedtext/TimedTextParser.cpp b/media/libstagefright/timedtext/TimedTextParser.cpp index 0bada16..caea0a4 100644 --- a/media/libstagefright/timedtext/TimedTextParser.cpp +++ b/media/libstagefright/timedtext/TimedTextParser.cpp @@ -128,7 +128,7 @@ status_t TimedTextParser::readNextLine(off64_t *offset, AString *data) { * Subtitle number * Start time --> End time * Text of subtitle (one or more lines) - * Blank line + * Blank lines * * .srt file example: * 1 @@ -143,15 +143,20 @@ status_t TimedTextParser::getNextInSrtFileFormat( off64_t *offset, int64_t *startTimeUs, TextInfo *info) { AString data; status_t err; - if ((err = readNextLine(offset, &data)) != OK) { - return err; - } - // to skip the first line + // To skip blank lines. + do { + if ((err = readNextLine(offset, &data)) != OK) { + return err; + } + data.trim(); + } while(data.empty()); + + // Just ignore the first non-blank line which is subtitle sequence number. + if ((err = readNextLine(offset, &data)) != OK) { return err; } - int hour1, hour2, min1, min2, sec1, sec2, msec1, msec2; // the start time format is: hours:minutes:seconds,milliseconds // 00:00:24,600 --> 00:00:27,800 |