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

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 27 matching lines...) Expand all
38 }; 38 };
39 39
40 // WebM Block bytes that represent a VP8 keyframe. 40 // WebM Block bytes that represent a VP8 keyframe.
41 const uint8 kVP8Keyframe[] = { 41 const uint8 kVP8Keyframe[] = {
42 0x010, 0x00, 0x00, 0x9d, 0x01, 0x2a, 0x00, 0x10, 0x00, 0x10, 0x00 42 0x010, 0x00, 0x00, 0x9d, 0x01, 0x2a, 0x00, 0x10, 0x00, 0x10, 0x00
43 }; 43 };
44 44
45 // WebM Block bytes that represent a VP8 interframe. 45 // WebM Block bytes that represent a VP8 interframe.
46 const uint8 kVP8Interframe[] = { 0x11, 0x00, 0x00 }; 46 const uint8 kVP8Interframe[] = { 0x11, 0x00, 0x00 };
47 47
48 static const uint8 kCuesHeader[] = {
49 0x1C, 0x53, 0xBB, 0x6B, // Cues ID
50 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // cues(size = 0)
51 };
52
48 const int kTracksHeaderSize = sizeof(kTracksHeader); 53 const int kTracksHeaderSize = sizeof(kTracksHeader);
49 const int kTracksSizeOffset = 4; 54 const int kTracksSizeOffset = 4;
50 55
51 // The size of TrackEntry element in test file "webm_vorbis_track_entry" starts 56 // The size of TrackEntry element in test file "webm_vorbis_track_entry" starts
52 // at index 1 and spans 8 bytes. 57 // at index 1 and spans 8 bytes.
53 const int kAudioTrackSizeOffset = 1; 58 const int kAudioTrackSizeOffset = 1;
54 const int kAudioTrackSizeWidth = 8; 59 const int kAudioTrackSizeWidth = 8;
55 const int kAudioTrackEntryHeaderSize = 60 const int kAudioTrackEntryHeaderSize =
56 kAudioTrackSizeOffset + kAudioTrackSizeWidth; 61 kAudioTrackSizeOffset + kAudioTrackSizeWidth;
57 62
(...skipping 3388 matching lines...) Expand 10 before | Expand all | Expand 10 after
3446 ASSERT_TRUE(InitDemuxer(HAS_AUDIO | HAS_VIDEO)); 3451 ASSERT_TRUE(InitDemuxer(HAS_AUDIO | HAS_VIDEO));
3447 3452
3448 AppendCluster(GenerateCluster(0, 0, 4, true)); 3453 AppendCluster(GenerateCluster(0, 0, 4, true));
3449 CheckExpectedRanges(kSourceId, "{ [0,46) }"); 3454 CheckExpectedRanges(kSourceId, "{ [0,46) }");
3450 3455
3451 // A new cluster indicates end of the previous cluster with unknown size. 3456 // A new cluster indicates end of the previous cluster with unknown size.
3452 AppendCluster(GenerateCluster(46, 66, 5, true)); 3457 AppendCluster(GenerateCluster(46, 66, 5, true));
3453 CheckExpectedRanges(kSourceId, "{ [0,115) }"); 3458 CheckExpectedRanges(kSourceId, "{ [0,115) }");
3454 } 3459 }
3455 3460
3461 TEST_F(ChunkDemuxerTest, CuesBetweenClustersWithUnknownSize) {
3462 ASSERT_TRUE(InitDemuxer(HAS_AUDIO | HAS_VIDEO));
3463
3464 // Add two clusters separated by Cues in a single Append() call.
3465 scoped_ptr<Cluster> cluster = GenerateCluster(0, 0, 4, true);
3466 std::vector<uint8> data(cluster->data(), cluster->data() + cluster->size());
3467 data.insert(data.end(), kCuesHeader, kCuesHeader + sizeof(kCuesHeader));
3468 cluster = GenerateCluster(46, 66, 5, true);
3469 data.insert(data.end(), cluster->data(), cluster->data() + cluster->size());
3470 AppendData(&*data.begin(), data.size());
3471
3472 CheckExpectedRanges(kSourceId, "{ [0,115) }");
3473 }
3474
3475 TEST_F(ChunkDemuxerTest, CuesBetweenClusters) {
3476 ASSERT_TRUE(InitDemuxer(HAS_AUDIO | HAS_VIDEO));
3477
3478 AppendCluster(GenerateCluster(0, 0, 4));
3479 AppendData(kCuesHeader, sizeof(kCuesHeader));
3480 AppendCluster(GenerateCluster(46, 66, 5));
3481 CheckExpectedRanges(kSourceId, "{ [0,115) }");
3482 }
3483
3456 } // namespace media 3484 } // 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