| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 "media/base/filters.h" | 7 #include "media/base/filters.h" |
| 8 #include "media/base/mock_ffmpeg.h" | 8 #include "media/base/mock_ffmpeg.h" |
| 9 #include "media/base/mock_filter_host.h" | 9 #include "media/base/mock_filter_host.h" |
| 10 #include "media/base/mock_filters.h" | 10 #include "media/base/mock_filters.h" |
| (...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 190 media_format.SetAsString(MediaFormat::kMimeType, | 190 media_format.SetAsString(MediaFormat::kMimeType, |
| 191 mime_type::kApplicationOctetStream); | 191 mime_type::kApplicationOctetStream); |
| 192 demuxer = factory->Create<Demuxer>(media_format); | 192 demuxer = factory->Create<Demuxer>(media_format); |
| 193 ASSERT_TRUE(demuxer); | 193 ASSERT_TRUE(demuxer); |
| 194 } | 194 } |
| 195 | 195 |
| 196 TEST_F(FFmpegDemuxerTest, Initialize_OpenFails) { | 196 TEST_F(FFmpegDemuxerTest, Initialize_OpenFails) { |
| 197 // Simulate av_open_input_file() failing. | 197 // Simulate av_open_input_file() failing. |
| 198 EXPECT_CALL(*MockFFmpeg::get(), AVOpenInputFile(_, _, NULL, 0, NULL)) | 198 EXPECT_CALL(*MockFFmpeg::get(), AVOpenInputFile(_, _, NULL, 0, NULL)) |
| 199 .WillOnce(Return(-1)); | 199 .WillOnce(Return(-1)); |
| 200 EXPECT_CALL(host_, Error(DEMUXER_ERROR_COULD_NOT_OPEN)); | 200 EXPECT_CALL(host_, SetError(DEMUXER_ERROR_COULD_NOT_OPEN)); |
| 201 EXPECT_CALL(callback_, OnFilterCallback()); | 201 EXPECT_CALL(callback_, OnFilterCallback()); |
| 202 EXPECT_CALL(callback_, OnCallbackDestroyed()); | 202 EXPECT_CALL(callback_, OnCallbackDestroyed()); |
| 203 | 203 |
| 204 demuxer_->Initialize(data_source_.get(), callback_.NewCallback()); | 204 demuxer_->Initialize(data_source_.get(), callback_.NewCallback()); |
| 205 message_loop_.RunAllPending(); | 205 message_loop_.RunAllPending(); |
| 206 } | 206 } |
| 207 | 207 |
| 208 TEST_F(FFmpegDemuxerTest, Initialize_ParseFails) { | 208 TEST_F(FFmpegDemuxerTest, Initialize_ParseFails) { |
| 209 // Simulate av_find_stream_info() failing. | 209 // Simulate av_find_stream_info() failing. |
| 210 EXPECT_CALL(*MockFFmpeg::get(), AVOpenInputFile(_, _, NULL, 0, NULL)) | 210 EXPECT_CALL(*MockFFmpeg::get(), AVOpenInputFile(_, _, NULL, 0, NULL)) |
| 211 .WillOnce(DoAll(SetArgumentPointee<0>(&format_context_), Return(0))); | 211 .WillOnce(DoAll(SetArgumentPointee<0>(&format_context_), Return(0))); |
| 212 EXPECT_CALL(*MockFFmpeg::get(), AVFindStreamInfo(&format_context_)) | 212 EXPECT_CALL(*MockFFmpeg::get(), AVFindStreamInfo(&format_context_)) |
| 213 .WillOnce(Return(AVERROR_IO)); | 213 .WillOnce(Return(AVERROR_IO)); |
| 214 EXPECT_CALL(*MockFFmpeg::get(), AVCloseInputFile(&format_context_)); | 214 EXPECT_CALL(*MockFFmpeg::get(), AVCloseInputFile(&format_context_)); |
| 215 EXPECT_CALL(host_, Error(DEMUXER_ERROR_COULD_NOT_PARSE)); | 215 EXPECT_CALL(host_, SetError(DEMUXER_ERROR_COULD_NOT_PARSE)); |
| 216 EXPECT_CALL(callback_, OnFilterCallback()); | 216 EXPECT_CALL(callback_, OnFilterCallback()); |
| 217 EXPECT_CALL(callback_, OnCallbackDestroyed()); | 217 EXPECT_CALL(callback_, OnCallbackDestroyed()); |
| 218 | 218 |
| 219 demuxer_->Initialize(data_source_.get(), callback_.NewCallback()); | 219 demuxer_->Initialize(data_source_.get(), callback_.NewCallback()); |
| 220 message_loop_.RunAllPending(); | 220 message_loop_.RunAllPending(); |
| 221 } | 221 } |
| 222 | 222 |
| 223 TEST_F(FFmpegDemuxerTest, Initialize_NoStreams) { | 223 TEST_F(FFmpegDemuxerTest, Initialize_NoStreams) { |
| 224 // Simulate media with no parseable streams. | 224 // Simulate media with no parseable streams. |
| 225 { | 225 { |
| 226 SCOPED_TRACE(""); | 226 SCOPED_TRACE(""); |
| 227 InitializeDemuxerMocks(); | 227 InitializeDemuxerMocks(); |
| 228 } | 228 } |
| 229 EXPECT_CALL(host_, Error(DEMUXER_ERROR_NO_SUPPORTED_STREAMS)); | 229 EXPECT_CALL(host_, SetError(DEMUXER_ERROR_NO_SUPPORTED_STREAMS)); |
| 230 EXPECT_CALL(callback_, OnFilterCallback()); | 230 EXPECT_CALL(callback_, OnFilterCallback()); |
| 231 EXPECT_CALL(callback_, OnCallbackDestroyed()); | 231 EXPECT_CALL(callback_, OnCallbackDestroyed()); |
| 232 format_context_.nb_streams = 0; | 232 format_context_.nb_streams = 0; |
| 233 | 233 |
| 234 demuxer_->Initialize(data_source_.get(), callback_.NewCallback()); | 234 demuxer_->Initialize(data_source_.get(), callback_.NewCallback()); |
| 235 message_loop_.RunAllPending(); | 235 message_loop_.RunAllPending(); |
| 236 } | 236 } |
| 237 | 237 |
| 238 TEST_F(FFmpegDemuxerTest, Initialize_DataStreamOnly) { | 238 TEST_F(FFmpegDemuxerTest, Initialize_DataStreamOnly) { |
| 239 // Simulate media with a data stream but no audio or video streams. | 239 // Simulate media with a data stream but no audio or video streams. |
| 240 { | 240 { |
| 241 SCOPED_TRACE(""); | 241 SCOPED_TRACE(""); |
| 242 InitializeDemuxerMocks(); | 242 InitializeDemuxerMocks(); |
| 243 } | 243 } |
| 244 EXPECT_CALL(host_, Error(DEMUXER_ERROR_NO_SUPPORTED_STREAMS)); | 244 EXPECT_CALL(host_, SetError(DEMUXER_ERROR_NO_SUPPORTED_STREAMS)); |
| 245 EXPECT_CALL(callback_, OnFilterCallback()); | 245 EXPECT_CALL(callback_, OnFilterCallback()); |
| 246 EXPECT_CALL(callback_, OnCallbackDestroyed()); | 246 EXPECT_CALL(callback_, OnCallbackDestroyed()); |
| 247 EXPECT_EQ(format_context_.streams[0], &streams_[AV_STREAM_DATA]); | 247 EXPECT_EQ(format_context_.streams[0], &streams_[AV_STREAM_DATA]); |
| 248 format_context_.nb_streams = 1; | 248 format_context_.nb_streams = 1; |
| 249 | 249 |
| 250 demuxer_->Initialize(data_source_.get(), callback_.NewCallback()); | 250 demuxer_->Initialize(data_source_.get(), callback_.NewCallback()); |
| 251 message_loop_.RunAllPending(); | 251 message_loop_.RunAllPending(); |
| 252 } | 252 } |
| 253 | 253 |
| 254 TEST_F(FFmpegDemuxerTest, Initialize_Successful) { | 254 TEST_F(FFmpegDemuxerTest, Initialize_Successful) { |
| (...skipping 401 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 656 | 656 |
| 657 // Attempt the read... | 657 // Attempt the read... |
| 658 audio->Read(callback.release()); | 658 audio->Read(callback.release()); |
| 659 message_loop_.RunAllPending(); | 659 message_loop_.RunAllPending(); |
| 660 | 660 |
| 661 // ...and verify that |callback| was deleted. | 661 // ...and verify that |callback| was deleted. |
| 662 MockFFmpeg::get()->CheckPoint(1); | 662 MockFFmpeg::get()->CheckPoint(1); |
| 663 } | 663 } |
| 664 | 664 |
| 665 } // namespace media | 665 } // namespace media |
| OLD | NEW |