OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 <deque> | 5 #include <deque> |
6 | 6 |
7 #include "base/threading/thread.h" | 7 #include "base/threading/thread.h" |
8 #include "media/base/filters.h" | 8 #include "media/base/filters.h" |
9 #include "media/base/mock_callback.h" | 9 #include "media/base/mock_callback.h" |
10 #include "media/base/mock_ffmpeg.h" | 10 #include "media/base/mock_ffmpeg.h" |
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
140 void InitializeDemuxer() { | 140 void InitializeDemuxer() { |
141 InitializeDemuxerMocks(); | 141 InitializeDemuxerMocks(); |
142 | 142 |
143 // Since we ignore data streams, the duration should be equal to the longest | 143 // Since we ignore data streams, the duration should be equal to the longest |
144 // supported stream's duration (audio, in this case). | 144 // supported stream's duration (audio, in this case). |
145 base::TimeDelta expected_duration = | 145 base::TimeDelta expected_duration = |
146 base::TimeDelta::FromMicroseconds(kDurations[AV_STREAM_AUDIO]); | 146 base::TimeDelta::FromMicroseconds(kDurations[AV_STREAM_AUDIO]); |
147 EXPECT_CALL(host_, SetDuration(expected_duration)); | 147 EXPECT_CALL(host_, SetDuration(expected_duration)); |
148 | 148 |
149 demuxer_->Initialize(data_source_.get(), | 149 demuxer_->Initialize(data_source_.get(), |
150 NewExpectedStatusCallback(PIPELINE_OK)); | 150 NewExpectedStatusCB(PIPELINE_OK)); |
151 message_loop_.RunAllPending(); | 151 message_loop_.RunAllPending(); |
152 } | 152 } |
153 | 153 |
154 // Fixture members. | 154 // Fixture members. |
155 scoped_refptr<FFmpegDemuxer> demuxer_; | 155 scoped_refptr<FFmpegDemuxer> demuxer_; |
156 scoped_refptr<StrictMock<MockDataSource> > data_source_; | 156 scoped_refptr<StrictMock<MockDataSource> > data_source_; |
157 StrictMock<MockFilterHost> host_; | 157 StrictMock<MockFilterHost> host_; |
158 MessageLoop message_loop_; | 158 MessageLoop message_loop_; |
159 | 159 |
160 // FFmpeg fixtures. | 160 // FFmpeg fixtures. |
(...skipping 19 matching lines...) Expand all Loading... |
180 const uint8 FFmpegDemuxerTest::kAudioData[kDataSize] = {0, 1, 2, 3}; | 180 const uint8 FFmpegDemuxerTest::kAudioData[kDataSize] = {0, 1, 2, 3}; |
181 const uint8 FFmpegDemuxerTest::kVideoData[kDataSize] = {4, 5, 6, 7}; | 181 const uint8 FFmpegDemuxerTest::kVideoData[kDataSize] = {4, 5, 6, 7}; |
182 const uint8* FFmpegDemuxerTest::kNullData = NULL; | 182 const uint8* FFmpegDemuxerTest::kNullData = NULL; |
183 | 183 |
184 TEST_F(FFmpegDemuxerTest, Initialize_OpenFails) { | 184 TEST_F(FFmpegDemuxerTest, Initialize_OpenFails) { |
185 // Simulate av_open_input_file() failing. | 185 // Simulate av_open_input_file() failing. |
186 EXPECT_CALL(mock_ffmpeg_, AVOpenInputFile(_, _, NULL, 0, NULL)) | 186 EXPECT_CALL(mock_ffmpeg_, AVOpenInputFile(_, _, NULL, 0, NULL)) |
187 .WillOnce(Return(-1)); | 187 .WillOnce(Return(-1)); |
188 | 188 |
189 demuxer_->Initialize(data_source_.get(), | 189 demuxer_->Initialize(data_source_.get(), |
190 NewExpectedStatusCallback(DEMUXER_ERROR_COULD_NOT_OPEN)); | 190 NewExpectedStatusCB(DEMUXER_ERROR_COULD_NOT_OPEN)); |
191 message_loop_.RunAllPending(); | 191 message_loop_.RunAllPending(); |
192 } | 192 } |
193 | 193 |
194 TEST_F(FFmpegDemuxerTest, Initialize_ParseFails) { | 194 TEST_F(FFmpegDemuxerTest, Initialize_ParseFails) { |
195 // Simulate av_find_stream_info() failing. | 195 // Simulate av_find_stream_info() failing. |
196 EXPECT_CALL(mock_ffmpeg_, AVOpenInputFile(_, _, NULL, 0, NULL)) | 196 EXPECT_CALL(mock_ffmpeg_, AVOpenInputFile(_, _, NULL, 0, NULL)) |
197 .WillOnce(DoAll(SetArgumentPointee<0>(&format_context_), Return(0))); | 197 .WillOnce(DoAll(SetArgumentPointee<0>(&format_context_), Return(0))); |
198 EXPECT_CALL(mock_ffmpeg_, AVFindStreamInfo(&format_context_)) | 198 EXPECT_CALL(mock_ffmpeg_, AVFindStreamInfo(&format_context_)) |
199 .WillOnce(Return(AVERROR(EIO))); | 199 .WillOnce(Return(AVERROR(EIO))); |
200 EXPECT_CALL(mock_ffmpeg_, AVCloseInputFile(&format_context_)); | 200 EXPECT_CALL(mock_ffmpeg_, AVCloseInputFile(&format_context_)); |
201 | 201 |
202 demuxer_->Initialize( | 202 demuxer_->Initialize( |
203 data_source_.get(), | 203 data_source_.get(), |
204 NewExpectedStatusCallback(DEMUXER_ERROR_COULD_NOT_PARSE)); | 204 NewExpectedStatusCB(DEMUXER_ERROR_COULD_NOT_PARSE)); |
205 message_loop_.RunAllPending(); | 205 message_loop_.RunAllPending(); |
206 } | 206 } |
207 | 207 |
208 TEST_F(FFmpegDemuxerTest, Initialize_NoStreams) { | 208 TEST_F(FFmpegDemuxerTest, Initialize_NoStreams) { |
209 // Simulate media with no parseable streams. | 209 // Simulate media with no parseable streams. |
210 { | 210 { |
211 SCOPED_TRACE(""); | 211 SCOPED_TRACE(""); |
212 InitializeDemuxerMocks(); | 212 InitializeDemuxerMocks(); |
213 } | 213 } |
214 format_context_.nb_streams = 0; | 214 format_context_.nb_streams = 0; |
215 | 215 |
216 demuxer_->Initialize( | 216 demuxer_->Initialize( |
217 data_source_.get(), | 217 data_source_.get(), |
218 NewExpectedStatusCallback(DEMUXER_ERROR_NO_SUPPORTED_STREAMS)); | 218 NewExpectedStatusCB(DEMUXER_ERROR_NO_SUPPORTED_STREAMS)); |
219 message_loop_.RunAllPending(); | 219 message_loop_.RunAllPending(); |
220 } | 220 } |
221 | 221 |
222 TEST_F(FFmpegDemuxerTest, Initialize_DataStreamOnly) { | 222 TEST_F(FFmpegDemuxerTest, Initialize_DataStreamOnly) { |
223 // Simulate media with a data stream but no audio or video streams. | 223 // Simulate media with a data stream but no audio or video streams. |
224 { | 224 { |
225 SCOPED_TRACE(""); | 225 SCOPED_TRACE(""); |
226 InitializeDemuxerMocks(); | 226 InitializeDemuxerMocks(); |
227 } | 227 } |
228 EXPECT_EQ(format_context_.streams[0], &streams_[AV_STREAM_DATA]); | 228 EXPECT_EQ(format_context_.streams[0], &streams_[AV_STREAM_DATA]); |
229 format_context_.nb_streams = 1; | 229 format_context_.nb_streams = 1; |
230 | 230 |
231 demuxer_->Initialize( | 231 demuxer_->Initialize( |
232 data_source_.get(), | 232 data_source_.get(), |
233 NewExpectedStatusCallback(DEMUXER_ERROR_NO_SUPPORTED_STREAMS)); | 233 NewExpectedStatusCB(DEMUXER_ERROR_NO_SUPPORTED_STREAMS)); |
234 message_loop_.RunAllPending(); | 234 message_loop_.RunAllPending(); |
235 } | 235 } |
236 | 236 |
237 TEST_F(FFmpegDemuxerTest, Initialize_Successful) { | 237 TEST_F(FFmpegDemuxerTest, Initialize_Successful) { |
238 { | 238 { |
239 SCOPED_TRACE(""); | 239 SCOPED_TRACE(""); |
240 InitializeDemuxer(); | 240 InitializeDemuxer(); |
241 } | 241 } |
242 | 242 |
243 // First stream should be video and support the FFmpegDemuxerStream interface. | 243 // First stream should be video and support the FFmpegDemuxerStream interface. |
(...skipping 611 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
855 { | 855 { |
856 SCOPED_TRACE(""); | 856 SCOPED_TRACE(""); |
857 InitializeDemuxer(); | 857 InitializeDemuxer(); |
858 } | 858 } |
859 EXPECT_CALL(*data_source_, IsStreaming()) | 859 EXPECT_CALL(*data_source_, IsStreaming()) |
860 .WillOnce(Return(false)); | 860 .WillOnce(Return(false)); |
861 EXPECT_FALSE(demuxer_->IsStreaming()); | 861 EXPECT_FALSE(demuxer_->IsStreaming()); |
862 } | 862 } |
863 | 863 |
864 } // namespace media | 864 } // namespace media |
OLD | NEW |