OLD | NEW |
---|---|
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 Loading... | |
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 Loading... | |
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 AppendCluster(GenerateCluster(0, 0, 4, true)); | |
3492 CheckExpectedRanges(kSourceId, "{ [0,46) }"); | |
wolenetz
2014/06/18 22:47:53
nit: ClusterWithUnknownSize already does this. Can
Sergey Ulanov
2014/06/18 23:26:49
Done.
| |
3493 | |
3494 // Add Cues followed by a new cluster in a single Append() call. | |
3495 std::vector<uint8> data(kCuesHeader, kCuesHeader + sizeof(kCuesHeader)); | |
3496 scoped_ptr<Cluster> cluster = GenerateCluster(46, 66, 5, true); | |
3497 data.insert(data.end(), cluster->data(), cluster->data() + cluster->size()); | |
3498 AppendData(&*data.begin(), data.size()); | |
wolenetz
2014/06/18 22:47:53
nit: s/&*data.begin()/data.data()/ ?
Sergey Ulanov
2014/06/18 23:26:49
This doesn't compile on android, I already tried:
wolenetz
2014/06/18 23:54:29
I see. Thanks. (std::vector::data() is C++11)
| |
3499 | |
3500 CheckExpectedRanges(kSourceId, "{ [0,115) }"); | |
3501 } | |
3502 | |
3503 TEST_P(ChunkDemuxerTest, CuesBetweenClusters) { | |
3504 ASSERT_TRUE(InitDemuxer(HAS_AUDIO | HAS_VIDEO)); | |
3505 | |
3506 AppendCluster(GenerateCluster(0, 0, 4)); | |
3507 AppendData(kCuesHeader, sizeof(kCuesHeader)); | |
3508 AppendCluster(GenerateCluster(46, 66, 5)); | |
3509 CheckExpectedRanges(kSourceId, "{ [0,115) }"); | |
3510 } | |
3511 | |
3483 // Generate two sets of tests: one using FrameProcessor, and one using | 3512 // Generate two sets of tests: one using FrameProcessor, and one using |
3484 // LegacyFrameProcessor. | 3513 // LegacyFrameProcessor. |
3485 INSTANTIATE_TEST_CASE_P(NewFrameProcessor, ChunkDemuxerTest, Values(false)); | 3514 INSTANTIATE_TEST_CASE_P(NewFrameProcessor, ChunkDemuxerTest, Values(false)); |
3486 INSTANTIATE_TEST_CASE_P(LegacyFrameProcessor, ChunkDemuxerTest, Values(true)); | 3515 INSTANTIATE_TEST_CASE_P(LegacyFrameProcessor, ChunkDemuxerTest, Values(true)); |
3487 | 3516 |
3488 } // namespace media | 3517 } // namespace media |
OLD | NEW |