| 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/filter_host.h" | 7 #include "media/base/filter_host.h" |
| 8 #include "media/base/filters.h" | 8 #include "media/base/filters.h" |
| 9 #include "media/base/mock_filter_host.h" | 9 #include "media/base/mock_filter_host.h" |
| 10 #include "media/base/mock_media_filters.h" | 10 #include "media/base/mock_media_filters.h" |
| (...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 234 EXPECT_EQ(PIPELINE_OK, pipeline.GetError()); | 234 EXPECT_EQ(PIPELINE_OK, pipeline.GetError()); |
| 235 | 235 |
| 236 // Since we ignore data streams, the duration should be equal to the video | 236 // Since we ignore data streams, the duration should be equal to the video |
| 237 // stream's duration. | 237 // stream's duration. |
| 238 EXPECT_EQ(g_streams[1].duration, pipeline.GetDuration().InMicroseconds()); | 238 EXPECT_EQ(g_streams[1].duration, pipeline.GetDuration().InMicroseconds()); |
| 239 | 239 |
| 240 // Verify that 2 out of 3 streams were created. | 240 // Verify that 2 out of 3 streams were created. |
| 241 EXPECT_EQ(2, demuxer->GetNumberOfStreams()); | 241 EXPECT_EQ(2, demuxer->GetNumberOfStreams()); |
| 242 | 242 |
| 243 // First stream should be video. | 243 // First stream should be video. |
| 244 DemuxerStream* stream = demuxer->GetStream(0); | 244 scoped_refptr<DemuxerStream> stream = demuxer->GetStream(0); |
| 245 ASSERT_TRUE(stream); | 245 ASSERT_TRUE(stream); |
| 246 const MediaFormat* stream_format = stream->GetMediaFormat(); | 246 const MediaFormat* stream_format = stream->GetMediaFormat(); |
| 247 std::string mime_type; | 247 std::string mime_type; |
| 248 int result; | 248 int result; |
| 249 EXPECT_TRUE(stream_format->GetAsString(MediaFormat::kMimeType, &mime_type)); | 249 EXPECT_TRUE(stream_format->GetAsString(MediaFormat::kMimeType, &mime_type)); |
| 250 EXPECT_STREQ(mime_type::kFFmpegVideo, mime_type.c_str()); | 250 EXPECT_STREQ(mime_type::kFFmpegVideo, mime_type.c_str()); |
| 251 EXPECT_TRUE(stream_format->GetAsInteger(kFFmpegCodecID, &result)); | 251 EXPECT_TRUE(stream_format->GetAsInteger(kFFmpegCodecID, &result)); |
| 252 EXPECT_EQ(CODEC_ID_THEORA, static_cast<CodecID>(result)); | 252 EXPECT_EQ(CODEC_ID_THEORA, static_cast<CodecID>(result)); |
| 253 EXPECT_TRUE(stream_format->GetAsInteger(MediaFormat::kHeight, &result)); | 253 EXPECT_TRUE(stream_format->GetAsInteger(MediaFormat::kHeight, &result)); |
| 254 EXPECT_EQ(g_video_codec.height, result); | 254 EXPECT_EQ(g_video_codec.height, result); |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 304 EXPECT_TRUE(demuxer); | 304 EXPECT_TRUE(demuxer); |
| 305 MockFilterHost<Demuxer> filter_host_b(&pipeline, demuxer); | 305 MockFilterHost<Demuxer> filter_host_b(&pipeline, demuxer); |
| 306 EXPECT_TRUE(demuxer->Initialize(data_source)); | 306 EXPECT_TRUE(demuxer->Initialize(data_source)); |
| 307 EXPECT_TRUE(filter_host_b.IsInitialized()); | 307 EXPECT_TRUE(filter_host_b.IsInitialized()); |
| 308 EXPECT_EQ(PIPELINE_OK, pipeline.GetError()); | 308 EXPECT_EQ(PIPELINE_OK, pipeline.GetError()); |
| 309 | 309 |
| 310 // Verify both streams were created. | 310 // Verify both streams were created. |
| 311 EXPECT_EQ(2, demuxer->GetNumberOfStreams()); | 311 EXPECT_EQ(2, demuxer->GetNumberOfStreams()); |
| 312 | 312 |
| 313 // Get our streams. | 313 // Get our streams. |
| 314 DemuxerStream* audio_stream = demuxer->GetStream(kAudio); | 314 scoped_refptr<DemuxerStream> audio_stream = demuxer->GetStream(kAudio); |
| 315 DemuxerStream* video_stream = demuxer->GetStream(kVideo); | 315 scoped_refptr<DemuxerStream> video_stream = demuxer->GetStream(kVideo); |
| 316 ASSERT_TRUE(audio_stream); | 316 ASSERT_TRUE(audio_stream); |
| 317 ASSERT_TRUE(video_stream); | 317 ASSERT_TRUE(video_stream); |
| 318 | 318 |
| 319 // Both streams should support FFmpegDemuxerStream interface. |
| 320 scoped_refptr<FFmpegDemuxerStream> ffmpeg_demuxer_stream; |
| 321 EXPECT_TRUE(audio_stream->QueryInterface(&ffmpeg_demuxer_stream)); |
| 322 EXPECT_TRUE(ffmpeg_demuxer_stream); |
| 323 ffmpeg_demuxer_stream = NULL; |
| 324 EXPECT_TRUE(video_stream->QueryInterface(&ffmpeg_demuxer_stream)); |
| 325 EXPECT_TRUE(ffmpeg_demuxer_stream); |
| 326 |
| 319 // Prepare our test audio packet. | 327 // Prepare our test audio packet. |
| 320 g_packet.stream_index = kAudio; | 328 g_packet.stream_index = kAudio; |
| 321 g_packet.data = audio_data; | 329 g_packet.data = audio_data; |
| 322 g_packet.size = kDataSize; | 330 g_packet.size = kDataSize; |
| 323 | 331 |
| 324 // Attempt a read from the audio stream and run the message loop until done. | 332 // Attempt a read from the audio stream and run the message loop until done. |
| 325 scoped_refptr<TestBuffer> buffer(new TestBuffer()); | 333 scoped_refptr<TestBuffer> buffer(new TestBuffer()); |
| 326 audio_stream->Read(buffer); | 334 audio_stream->Read(buffer); |
| 327 pipeline.RunAllTasks(); | 335 pipeline.RunAllTasks(); |
| 328 EXPECT_TRUE(buffer->assigned()); | 336 EXPECT_TRUE(buffer->assigned()); |
| (...skipping 22 matching lines...) Expand all Loading... |
| 351 buffer = new TestBuffer(); | 359 buffer = new TestBuffer(); |
| 352 audio_stream->Read(buffer); | 360 audio_stream->Read(buffer); |
| 353 pipeline.RunAllTasks(); | 361 pipeline.RunAllTasks(); |
| 354 EXPECT_FALSE(buffer->assigned()); | 362 EXPECT_FALSE(buffer->assigned()); |
| 355 EXPECT_FALSE(buffer->buffer()); | 363 EXPECT_FALSE(buffer->buffer()); |
| 356 | 364 |
| 357 // Manually release buffer, which should release any remaining AVPackets. | 365 // Manually release buffer, which should release any remaining AVPackets. |
| 358 buffer = NULL; | 366 buffer = NULL; |
| 359 EXPECT_EQ(0, g_oustanding_packets); | 367 EXPECT_EQ(0, g_oustanding_packets); |
| 360 } | 368 } |
| OLD | NEW |