diff --git a/packager/app/test/testdata/bear-320x240-vorbis-golden.webm b/packager/app/test/testdata/bear-320x240-vorbis-golden.webm index 66a902379a..8d7a28c92e 100644 Binary files a/packager/app/test/testdata/bear-320x240-vorbis-golden.webm and b/packager/app/test/testdata/bear-320x240-vorbis-golden.webm differ diff --git a/packager/app/test/testdata/bear-320x240-vp9-golden.webm b/packager/app/test/testdata/bear-320x240-vp9-golden.webm index 0ec03cd26d..67eb5c87c6 100644 Binary files a/packager/app/test/testdata/bear-320x240-vp9-golden.webm and b/packager/app/test/testdata/bear-320x240-vp9-golden.webm differ diff --git a/packager/app/test/testdata/bear-640x360-vp8-cenc-golden.webm b/packager/app/test/testdata/bear-640x360-vp8-cenc-golden.webm index 76ce0e1c93..ea363b8a3b 100644 Binary files a/packager/app/test/testdata/bear-640x360-vp8-cenc-golden.webm and b/packager/app/test/testdata/bear-640x360-vp8-cenc-golden.webm differ diff --git a/packager/app/test/testdata/bear-640x360-vp8-golden.webm b/packager/app/test/testdata/bear-640x360-vp8-golden.webm index 59fdcdac00..b176d09ab2 100644 Binary files a/packager/app/test/testdata/bear-640x360-vp8-golden.webm and b/packager/app/test/testdata/bear-640x360-vp8-golden.webm differ diff --git a/packager/media/formats/webm/encrypted_segmenter_unittest.cc b/packager/media/formats/webm/encrypted_segmenter_unittest.cc index cb9c2f3933..15eb8f86c1 100644 --- a/packager/media/formats/webm/encrypted_segmenter_unittest.cc +++ b/packager/media/formats/webm/encrypted_segmenter_unittest.cc @@ -40,26 +40,36 @@ const uint8_t kBasicSupportData[] = { 0x42, 0x85, 0x81, 0x02, // ID: Segment, Payload Size: 411 0x18, 0x53, 0x80, 0x67, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x9b, - // ID: SeekHead, Payload Size: 30 - 0x11, 0x4d, 0x9b, 0x74, 0x9e, + // ID: SeekHead, Payload Size: 58 + 0x11, 0x4d, 0x9b, 0x74, 0xba, + // ID: Seek, Payload Size: 11 + 0x4d, 0xbb, 0x8b, + // SeekID: binary(4) (Info) + 0x53, 0xab, 0x84, 0x15, 0x49, 0xa9, 0x66, + // SeekPosition: 89 + 0x53, 0xac, 0x81, 0x59, + // ID: Seek, Payload Size: 11 + 0x4d, 0xbb, 0x8b, + // SeekID: binary(4) (Tracks) + 0x53, 0xab, 0x84, 0x16, 0x54, 0xae, 0x6b, + // SeekPosition: 182 + 0x53, 0xac, 0x81, 0xb6, // ID: Seek, Payload Size: 12 0x4d, 0xbb, 0x8c, // SeekID: binary(4) (Cluster) 0x53, 0xab, 0x84, 0x1f, 0x43, 0xb6, 0x75, - // SeekPosition: 322 - 0x53, 0xac, 0x82, 0x01, 0x47, + // SeekPosition: 279 + 0x53, 0xac, 0x82, 0x01, 0x17, // ID: Seek, Payload Size: 12 0x4d, 0xbb, 0x8c, // SeekID: binary(4) (Cues) 0x53, 0xab, 0x84, 0x1c, 0x53, 0xbb, 0x6b, - // SeekPosition: 429 - 0x53, 0xac, 0x82, 0x01, 0xb8, - // ID: Void, Payload Size: 52 - 0xec, 0xb4, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + // SeekPosition: 392 + 0x53, 0xac, 0x82, 0x01, 0x88, + // ID: Void, Payload Size: 24 + 0xec, 0x98, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, // ID: Info, Payload Size: 88 0x15, 0x49, 0xa9, 0x66, 0xd8, // TimecodeScale: 1000000 diff --git a/packager/media/formats/webm/seek_head.cc b/packager/media/formats/webm/seek_head.cc index 60a3ca6792..5935a2eeb7 100644 --- a/packager/media/formats/webm/seek_head.cc +++ b/packager/media/formats/webm/seek_head.cc @@ -14,9 +14,10 @@ namespace edash_packager { namespace media { namespace { -const mkvmuxer::uint64 kElementIds[] = {mkvmuxer::kMkvCluster, - mkvmuxer::kMkvCues, mkvmuxer::kMkvInfo, - mkvmuxer::kMkvTracks}; +const mkvmuxer::uint64 kElementIds[] = { + mkvmuxer::kMkvInfo, mkvmuxer::kMkvTracks, mkvmuxer::kMkvCluster, + mkvmuxer::kMkvCues, +}; const int kElementIdCount = arraysize(kElementIds); uint64_t MaxSeekEntrySize() { @@ -55,7 +56,7 @@ bool SeekHead::Write(mkvmuxer::IMkvWriter* writer) { if (!WriteEbmlMasterElement(writer, mkvmuxer::kMkvSeekHead, payload_size)) return false; - const int64_t positions[] = {cluster_pos_, cues_pos_, info_pos_, tracks_pos_}; + const int64_t positions[] = {info_pos_, tracks_pos_, cluster_pos_, cues_pos_}; for (int i = 0; i < kElementIdCount; ++i) { if (element_sizes[i] == 0) continue; @@ -99,7 +100,7 @@ bool SeekHead::WriteVoid(mkvmuxer::IMkvWriter* writer) { } uint64_t SeekHead::GetPayloadSize(std::vector* data) { - const int64_t positions[] = {cluster_pos_, cues_pos_, info_pos_, tracks_pos_}; + const int64_t positions[] = {info_pos_, tracks_pos_, cluster_pos_, cues_pos_}; uint64_t total_payload_size = 0; data->resize(kElementIdCount); for (int i = 0; i < kElementIdCount; ++i) { diff --git a/packager/media/formats/webm/segmenter.cc b/packager/media/formats/webm/segmenter.cc index 5db1d3f96b..72c219de3a 100644 --- a/packager/media/formats/webm/segmenter.cc +++ b/packager/media/formats/webm/segmenter.cc @@ -224,9 +224,11 @@ Status Segmenter::WriteSegmentHeader(uint64_t file_size, MkvWriter* writer) { return error_status; } + seek_head_.set_info_pos(writer->Position() - segment_payload_pos_); if (!segment_info_.Write(writer)) return error_status; + seek_head_.set_tracks_pos(writer->Position() - segment_payload_pos_); if (!tracks_.Write(writer)) return error_status; diff --git a/packager/media/formats/webm/single_segment_segmenter.cc b/packager/media/formats/webm/single_segment_segmenter.cc index 5a8d64603f..71eab2e3d0 100644 --- a/packager/media/formats/webm/single_segment_segmenter.cc +++ b/packager/media/formats/webm/single_segment_segmenter.cc @@ -22,7 +22,7 @@ Status SingleSegmentSegmenter::DoInitialize(scoped_ptr writer) { writer_ = writer.Pass(); Status ret = WriteSegmentHeader(0, writer_.get()); init_end_ = writer_->Position() - 1; - seek_head()->set_cluster_pos(init_end_ + 1); + seek_head()->set_cluster_pos(init_end_ + 1 - segment_payload_pos()); return ret; } @@ -32,7 +32,7 @@ Status SingleSegmentSegmenter::DoFinalize() { // Write the Cues to the end of the file. index_start_ = writer_->Position(); - seek_head()->set_cues_pos(index_start_); + seek_head()->set_cues_pos(index_start_ - segment_payload_pos()); if (!cues()->Write(writer_.get())) return Status(error::FILE_FAILURE, "Error writing Cues data."); diff --git a/packager/media/formats/webm/single_segment_segmenter_unittest.cc b/packager/media/formats/webm/single_segment_segmenter_unittest.cc index 3bcda22cde..1f216ea189 100644 --- a/packager/media/formats/webm/single_segment_segmenter_unittest.cc +++ b/packager/media/formats/webm/single_segment_segmenter_unittest.cc @@ -35,26 +35,36 @@ const uint8_t kBasicSupportData[] = { 0x42, 0x85, 0x81, 0x02, // ID: Segment, Payload Size: 343 0x18, 0x53, 0x80, 0x67, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x57, - // ID: SeekHead, Payload Size: 30 - 0x11, 0x4d, 0x9b, 0x74, 0x9e, - // ID: Seek, Payload Size: 12 - 0x4d, 0xbb, 0x8c, + // ID: SeekHead, Payload Size: 57 + 0x11, 0x4d, 0x9b, 0x74, 0xb9, + // ID: Seek, Payload Size: 11 + 0x4d, 0xbb, 0x8b, + // SeekID: binary(4) (Info) + 0x53, 0xab, 0x84, 0x15, 0x49, 0xa9, 0x66, + // SeekPosition: 89 + 0x53, 0xac, 0x81, 0x59, + // ID: Seek, Payload Size: 11 + 0x4d, 0xbb, 0x8b, + // SeekID: binary(4) (Tracks) + 0x53, 0xab, 0x84, 0x16, 0x54, 0xae, 0x6b, + // SeekPosition: 182 + 0x53, 0xac, 0x81, 0xb6, + // ID: Seek, Payload Size: 11 + 0x4d, 0xbb, 0x8b, // SeekID: binary(4) (Cluster) 0x53, 0xab, 0x84, 0x1f, 0x43, 0xb6, 0x75, - // SeekPosition: 276 - 0x53, 0xac, 0x82, 0x01, 0x14, + // SeekPosition: 228 + 0x53, 0xac, 0x81, 0xe4, // ID: Seek, Payload Size: 12 0x4d, 0xbb, 0x8c, // SeekID: binary(4) (Cues) 0x53, 0xab, 0x84, 0x1c, 0x53, 0xbb, 0x6b, - // SeekPosition: 367 - 0x53, 0xac, 0x82, 0x01, 0x75, - // ID: Void, Payload Size: 52 - 0xec, 0xb4, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + // SeekPosition: 325 + 0x53, 0xac, 0x82, 0x01, 0x45, + // ID: Void, Payload Size: 25 + 0xec, 0x99, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, // ID: Info, Payload Size: 88 0x15, 0x49, 0xa9, 0x66, 0xd8, // TimecodeScale: 1000000 diff --git a/packager/media/formats/webm/two_pass_single_segment_segmenter.cc b/packager/media/formats/webm/two_pass_single_segment_segmenter.cc index 5eb4311d15..4f2541d4c7 100644 --- a/packager/media/formats/webm/two_pass_single_segment_segmenter.cc +++ b/packager/media/formats/webm/two_pass_single_segment_segmenter.cc @@ -95,7 +95,7 @@ Status TwoPassSingleSegmentSegmenter::DoFinalize() { // Write the Cues to the end of the temp file. uint64_t cues_pos = writer()->Position(); set_index_start(cues_pos); - seek_head()->set_cues_pos(cues_pos); + seek_head()->set_cues_pos(cues_pos - segment_payload_pos()); if (!cues()->Write(writer())) return Status(error::FILE_FAILURE, "Error writing Cues data.");