Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(31)

Side by Side Diff: media/filters/chunk_demuxer_unittest.cc

Issue 346613003: Fix WebMStreamParser to handle Cues between Clusters correctly. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | media/formats/webm/webm_stream_parser.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include <algorithm> 5 #include <algorithm>
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/message_loop/message_loop.h" 8 #include "base/message_loop/message_loop.h"
9 #include "base/strings/string_number_conversions.h" 9 #include "base/strings/string_number_conversions.h"
10 #include "base/strings/string_split.h" 10 #include "base/strings/string_split.h"
(...skipping 28 matching lines...) Expand all
39 }; 39 };
40 40
41 // WebM Block bytes that represent a VP8 keyframe. 41 // WebM Block bytes that represent a VP8 keyframe.
42 const uint8 kVP8Keyframe[] = { 42 const uint8 kVP8Keyframe[] = {
43 0x010, 0x00, 0x00, 0x9d, 0x01, 0x2a, 0x00, 0x10, 0x00, 0x10, 0x00 43 0x010, 0x00, 0x00, 0x9d, 0x01, 0x2a, 0x00, 0x10, 0x00, 0x10, 0x00
44 }; 44 };
45 45
46 // WebM Block bytes that represent a VP8 interframe. 46 // WebM Block bytes that represent a VP8 interframe.
47 const uint8 kVP8Interframe[] = { 0x11, 0x00, 0x00 }; 47 const uint8 kVP8Interframe[] = { 0x11, 0x00, 0x00 };
48 48
49 static const uint8 kCuesHeader[] = {
50 0x1C, 0x53, 0xBB, 0x6B, // Cues ID
51 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // cues(size = 0)
52 };
53
49 const int kTracksHeaderSize = sizeof(kTracksHeader); 54 const int kTracksHeaderSize = sizeof(kTracksHeader);
50 const int kTracksSizeOffset = 4; 55 const int kTracksSizeOffset = 4;
51 56
52 // The size of TrackEntry element in test file "webm_vorbis_track_entry" starts 57 // The size of TrackEntry element in test file "webm_vorbis_track_entry" starts
53 // at index 1 and spans 8 bytes. 58 // at index 1 and spans 8 bytes.
54 const int kAudioTrackSizeOffset = 1; 59 const int kAudioTrackSizeOffset = 1;
55 const int kAudioTrackSizeWidth = 8; 60 const int kAudioTrackSizeWidth = 8;
56 const int kAudioTrackEntryHeaderSize = 61 const int kAudioTrackEntryHeaderSize =
57 kAudioTrackSizeOffset + kAudioTrackSizeWidth; 62 kAudioTrackSizeOffset + kAudioTrackSizeWidth;
58 63
(...skipping 3414 matching lines...) Expand 10 before | Expand all | Expand 10 after
3473 ASSERT_TRUE(InitDemuxer(HAS_AUDIO | HAS_VIDEO)); 3478 ASSERT_TRUE(InitDemuxer(HAS_AUDIO | HAS_VIDEO));
3474 3479
3475 AppendCluster(GenerateCluster(0, 0, 4, true)); 3480 AppendCluster(GenerateCluster(0, 0, 4, true));
3476 CheckExpectedRanges(kSourceId, "{ [0,46) }"); 3481 CheckExpectedRanges(kSourceId, "{ [0,46) }");
3477 3482
3478 // A new cluster indicates end of the previous cluster with unknown size. 3483 // A new cluster indicates end of the previous cluster with unknown size.
3479 AppendCluster(GenerateCluster(46, 66, 5, true)); 3484 AppendCluster(GenerateCluster(46, 66, 5, true));
3480 CheckExpectedRanges(kSourceId, "{ [0,115) }"); 3485 CheckExpectedRanges(kSourceId, "{ [0,115) }");
3481 } 3486 }
3482 3487
3488 TEST_P(ChunkDemuxerTest, CuesBetweenClustersWithUnknownSize) {
3489 ASSERT_TRUE(InitDemuxer(HAS_AUDIO | HAS_VIDEO));
3490
3491 // Add two cluster separated by Cues in a single Append() call.
wolenetz 2014/06/18 23:54:29 nit:s/cluster/clusters
Sergey Ulanov 2014/06/19 00:18:09 Done.
3492 scoped_ptr<Cluster> cluster = GenerateCluster(0, 0, 4, true);
3493 std::vector<uint8> data(cluster->data(), cluster->data() + cluster->size());
3494 data.insert(data.end(), kCuesHeader, kCuesHeader + sizeof(kCuesHeader));
3495 cluster = GenerateCluster(46, 66, 5, true);
3496 data.insert(data.end(), cluster->data(), cluster->data() + cluster->size());
3497 AppendData(&*data.begin(), data.size());
3498
3499 CheckExpectedRanges(kSourceId, "{ [0,115) }");
3500 }
3501
3502 TEST_P(ChunkDemuxerTest, CuesBetweenClusters) {
3503 ASSERT_TRUE(InitDemuxer(HAS_AUDIO | HAS_VIDEO));
3504
3505 AppendCluster(GenerateCluster(0, 0, 4));
3506 AppendData(kCuesHeader, sizeof(kCuesHeader));
3507 AppendCluster(GenerateCluster(46, 66, 5));
3508 CheckExpectedRanges(kSourceId, "{ [0,115) }");
3509 }
3510
3483 // Generate two sets of tests: one using FrameProcessor, and one using 3511 // Generate two sets of tests: one using FrameProcessor, and one using
3484 // LegacyFrameProcessor. 3512 // LegacyFrameProcessor.
3485 INSTANTIATE_TEST_CASE_P(NewFrameProcessor, ChunkDemuxerTest, Values(false)); 3513 INSTANTIATE_TEST_CASE_P(NewFrameProcessor, ChunkDemuxerTest, Values(false));
3486 INSTANTIATE_TEST_CASE_P(LegacyFrameProcessor, ChunkDemuxerTest, Values(true)); 3514 INSTANTIATE_TEST_CASE_P(LegacyFrameProcessor, ChunkDemuxerTest, Values(true));
3487 3515
3488 } // namespace media 3516 } // namespace media
OLDNEW
« no previous file with comments | « no previous file | media/formats/webm/webm_stream_parser.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698