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

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

Issue 2352253002: Added MediaSourceState unit test. (Closed)
Patch Set: buildfix Created 4 years, 3 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
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 "media/filters/chunk_demuxer.h" 5 #include "media/filters/chunk_demuxer.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 #include <algorithm> 9 #include <algorithm>
10 #include <utility> 10 #include <utility>
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
111 static void WriteInt64(uint8_t* buffer, int64_t number) { 111 static void WriteInt64(uint8_t* buffer, int64_t number) {
112 DCHECK(number >= 0 && number < 0x00FFFFFFFFFFFFFFLL); 112 DCHECK(number >= 0 && number < 0x00FFFFFFFFFFFFFFLL);
113 buffer[0] = 0x01; 113 buffer[0] = 0x01;
114 int64_t tmp = number; 114 int64_t tmp = number;
115 for (int i = 7; i > 0; i--) { 115 for (int i = 7; i > 0; i--) {
116 buffer[i] = tmp & 0xff; 116 buffer[i] = tmp & 0xff;
117 tmp >>= 8; 117 tmp >>= 8;
118 } 118 }
119 } 119 }
120 120
121 MATCHER_P(HasTimestamp, timestamp_in_ms, "") {
servolk 2016/09/21 15:36:49 Moved to test_helpers.h
122 return arg.get() && !arg->end_of_stream() &&
123 arg->timestamp().InMilliseconds() == timestamp_in_ms;
124 }
125
126 MATCHER(IsEndOfStream, "") { return arg.get() && arg->end_of_stream(); }
127
128 MATCHER_P(SegmentMissingFrames, track_id, "") {
129 return CONTAINS_STRING(
130 arg, "Media segment did not contain any coded frames for track " +
131 std::string(track_id));
132 }
133
134 MATCHER(StreamParsingFailed, "") {
135 return CONTAINS_STRING(arg, "Append: stream parsing failed.");
136 }
137
138 MATCHER_P(FoundStream, stream_type_string, "") {
139 return CONTAINS_STRING(
140 arg, "found_" + std::string(stream_type_string) + "_stream") &&
141 CONTAINS_STRING(arg, "true");
142 }
143
144 MATCHER_P2(CodecName, stream_type_string, codec_string, "") {
145 return CONTAINS_STRING(arg,
146 std::string(stream_type_string) + "_codec_name") &&
147 CONTAINS_STRING(arg, std::string(codec_string));
148 }
149
150 MATCHER_P2(InitSegmentMismatchesMimeType, stream_type, codec_name, "") {
151 return CONTAINS_STRING(arg, std::string(stream_type) + " stream codec " +
152 std::string(codec_name) +
153 " doesn't match SourceBuffer codecs.");
154 }
155
156 MATCHER_P(InitSegmentMissesExpectedTrack, missing_codec, "") {
157 return CONTAINS_STRING(arg, "Initialization segment misses expected " +
158 std::string(missing_codec) + " track.");
159 }
160
161 MATCHER_P2(GeneratedSplice, duration_microseconds, time_microseconds, "") {
162 return CONTAINS_STRING(arg, "Generated splice of overlap duration " +
163 base::IntToString(duration_microseconds) +
164 "us into new buffer at " +
165 base::IntToString(time_microseconds) + "us.");
166 }
167
168 MATCHER_P2(SkippingSpliceAtOrBefore,
169 new_microseconds,
170 existing_microseconds,
171 "") {
172 return CONTAINS_STRING(
173 arg, "Skipping splice frame generation: first new buffer at " +
174 base::IntToString(new_microseconds) +
175 "us begins at or before existing buffer at " +
176 base::IntToString(existing_microseconds) + "us.");
177 }
178
179 MATCHER_P(SkippingSpliceAlreadySpliced, time_microseconds, "") {
180 return CONTAINS_STRING(
181 arg, "Skipping splice frame generation: overlapped buffers at " +
182 base::IntToString(time_microseconds) +
183 "us are in a previously buffered splice.");
184 }
185
186 MATCHER_P(WebMSimpleBlockDurationEstimated, estimated_duration_ms, "") {
187 return CONTAINS_STRING(arg, "Estimating WebM block duration to be " +
188 base::IntToString(estimated_duration_ms) +
189 "ms for the last (Simple)Block in the "
190 "Cluster for this Track. Use BlockGroups "
191 "with BlockDurations at the end of each "
192 "Track in a Cluster to avoid estimation.");
193 }
194
195 MATCHER_P(WebMNegativeTimecodeOffset, timecode_string, "") {
196 return CONTAINS_STRING(arg, "Got a block with negative timecode offset " +
197 std::string(timecode_string));
198 }
199
200 MATCHER(WebMOutOfOrderTimecode, "") {
201 return CONTAINS_STRING(
202 arg, "Got a block with a timecode before the previous block.");
203 }
204
205 MATCHER(WebMClusterBeforeFirstInfo, "") {
206 return CONTAINS_STRING(arg, "Found Cluster element before Info.");
207 }
208
209 static void OnReadDone(const base::TimeDelta& expected_time, 121 static void OnReadDone(const base::TimeDelta& expected_time,
210 bool* called, 122 bool* called,
211 DemuxerStream::Status status, 123 DemuxerStream::Status status,
212 const scoped_refptr<DecoderBuffer>& buffer) { 124 const scoped_refptr<DecoderBuffer>& buffer) {
213 EXPECT_EQ(status, DemuxerStream::kOk); 125 EXPECT_EQ(status, DemuxerStream::kOk);
214 EXPECT_EQ(expected_time, buffer->timestamp()); 126 EXPECT_EQ(expected_time, buffer->timestamp());
215 *called = true; 127 *called = true;
216 } 128 }
217 129
218 static void OnReadDone_AbortExpected( 130 static void OnReadDone_AbortExpected(
(...skipping 4582 matching lines...) Expand 10 before | Expand all | Expand 10 after
4801 demuxer_->RemoveId(kId1); 4713 demuxer_->RemoveId(kId1);
4802 EXPECT_EQ(nullptr, demuxer_->GetStream(DemuxerStream::AUDIO)); 4714 EXPECT_EQ(nullptr, demuxer_->GetStream(DemuxerStream::AUDIO));
4803 EXPECT_EQ(nullptr, demuxer_->GetStream(DemuxerStream::VIDEO)); 4715 EXPECT_EQ(nullptr, demuxer_->GetStream(DemuxerStream::VIDEO));
4804 } 4716 }
4805 4717
4806 // TODO(servolk): Add a unit test with multiple audio/video tracks using the 4718 // TODO(servolk): Add a unit test with multiple audio/video tracks using the
4807 // same codec type in a single SourceBuffer/MediaSourceState, when WebM parser 4719 // same codec type in a single SourceBuffer/MediaSourceState, when WebM parser
4808 // supports multiple tracks. crbug.com/646900 4720 // supports multiple tracks. crbug.com/646900
4809 4721
4810 } // namespace media 4722 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698