Skip to content

Commit

Permalink
segmentの生成の部分を修正。(生成中のファイルが再生候補にはいっていました。)
Browse files Browse the repository at this point in the history
  • Loading branch information
taktod committed Jun 8, 2012
1 parent 69df175 commit 58c30b4
Showing 1 changed file with 4 additions and 38 deletions.
42 changes: 4 additions & 38 deletions src/com/ttProject/streaming/TsSegmentCreator.java
Expand Up @@ -90,53 +90,21 @@ public void writeSegment(byte[] buf, int size, long timestamp, boolean isKey) {
});
// タイムスタンプが次の開始位置以降の場合
outputStream.close();
counter ++;
outputStream = new FileOutputStream(tmpTarget + counter + ".ts");
PrintWriter pw = new PrintWriter(new BufferedWriter(new FileWriter(tmpTarget + "hoge.m3u8")));
pw.println("#EXTM3U");
pw.println("#EXT-X-ALLOW-CACHE:NO");
pw.println("#EXT-X-TARGETDURATION:" + (int)(duration / 1000 + 1));
if(counter - 5 >= 0) {
pw.println("#EXT-X-MEDIA-SEQUENCE:" + (counter - 5));
pw.println("#EXTINF:" + (int)(duration / 1000 + 1));
pw.println((counter - 5) + ".ts");
pw.println("#EXTINF:" + (int)(duration / 1000 + 1));
pw.println((counter - 4) + ".ts");
pw.println("#EXTINF:" + (int)(duration / 1000 + 1));
pw.println((counter - 3) + ".ts");
pw.println("#EXTINF:" + (int)(duration / 1000 + 1));
pw.println((counter - 2) + ".ts");
pw.println("#EXTINF:" + (int)(duration / 1000 + 1));
pw.println((counter - 1) + ".ts");
}
else if(counter - 4 >= 0) {
pw.println("#EXT-X-MEDIA-SEQUENCE:" + (counter - 4));
pw.println("#EXTINF:" + (int)(duration / 1000 + 1));
pw.println((counter - 4) + ".ts");
pw.println("#EXTINF:" + (int)(duration / 1000 + 1));
pw.println((counter - 3) + ".ts");
pw.println("#EXTINF:" + (int)(duration / 1000 + 1));
pw.println((counter - 2) + ".ts");
pw.println("#EXTINF:" + (int)(duration / 1000 + 1));
pw.println((counter - 1) + ".ts");
}
else if(counter - 3 >= 0) {
pw.println("#EXT-X-MEDIA-SEQUENCE:" + (counter - 3));
pw.println("#EXTINF:" + (int)(duration / 1000 + 1));
pw.println((counter - 3) + ".ts");
pw.println("#EXTINF:" + (int)(duration / 1000 + 1));
pw.println((counter - 2) + ".ts");
pw.println("#EXTINF:" + (int)(duration / 1000 + 1));
pw.println((counter - 1) + ".ts");
}
else if(counter - 2 >= 0) {
if(counter - 2 >= 0) {
pw.println("#EXT-X-MEDIA-SEQUENCE:" + (counter - 2));
pw.println("#EXTINF:" + (int)(duration / 1000 + 1));
pw.println((counter - 2) + ".ts");
pw.println("#EXTINF:" + (int)(duration / 1000 + 1));
pw.println((counter - 1) + ".ts");
}
else if(counter - 1 >= 0) {
pw.println("#EXT-X-MEDIA-SEQUENCE:0");
else if(counter - 1 >= 0) {
pw.println("#EXT-X-MEDIA-SEQUENCE:" + (counter - 1));
pw.println("#EXTINF:" + (int)(duration / 1000 + 1));
pw.println((counter - 1) + ".ts");
}
Expand All @@ -145,11 +113,9 @@ else if(counter - 1 >= 0) {
}
pw.println("#EXTINF:" + (int)(duration / 1000 + 1));
pw.println(counter + ".ts");
pw.println();
pw.close();
pw = null;
nextStartPos = timestamp + duration;
counter ++;
}
outputStream.write(buf);
}
Expand Down

0 comments on commit 58c30b4

Please sign in to comment.