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

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

Issue 126170: Make the generated stubs weak. Enable the unittests that had conflicting symbols. (Closed)
Patch Set: Fix indent.w Created 11 years, 6 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
« no previous file with comments | « media/base/video_frame_impl_unittest.cc ('k') | media/filters/ffmpeg_glue_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "base/singleton.h" 7 #include "base/singleton.h"
8 #include "base/tuple.h" 8 #include "base/tuple.h"
9 #include "media/base/filter_host.h" 9 #include "media/base/filter_host.h"
10 #include "media/base/filters.h" 10 #include "media/base/filters.h"
(...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after
261 factory_ = FFmpegDemuxer::CreateFilterFactory(); 261 factory_ = FFmpegDemuxer::CreateFilterFactory();
262 MediaFormat media_format; 262 MediaFormat media_format;
263 media_format.SetAsString(MediaFormat::kMimeType, 263 media_format.SetAsString(MediaFormat::kMimeType,
264 mime_type::kApplicationOctetStream); 264 mime_type::kApplicationOctetStream);
265 demuxer_ = factory_->Create<Demuxer>(media_format); 265 demuxer_ = factory_->Create<Demuxer>(media_format);
266 DCHECK(demuxer_); 266 DCHECK(demuxer_);
267 267
268 // Prepare a filter host and data source for the demuxer. 268 // Prepare a filter host and data source for the demuxer.
269 pipeline_.reset(new MockPipeline()); 269 pipeline_.reset(new MockPipeline());
270 filter_host_.reset(new MockFilterHost<Demuxer>(pipeline_.get(), demuxer_)); 270 filter_host_.reset(new MockFilterHost<Demuxer>(pipeline_.get(), demuxer_));
271 MockFilterConfig config; 271 old_mocks::MockFilterConfig config;
272 data_source_ = new MockDataSource(&config); 272 data_source_ = new old_mocks::MockDataSource(&config);
273 } 273 }
274 274
275 virtual void TearDown() { 275 virtual void TearDown() {
276 // Call Stop() to shut down internal threads. 276 // Call Stop() to shut down internal threads.
277 demuxer_->Stop(); 277 demuxer_->Stop();
278 } 278 }
279 279
280 // Fixture members. 280 // Fixture members.
281 scoped_refptr<FilterFactory> factory_; 281 scoped_refptr<FilterFactory> factory_;
282 scoped_refptr<Demuxer> demuxer_; 282 scoped_refptr<Demuxer> demuxer_;
283 scoped_ptr<MockPipeline> pipeline_; 283 scoped_ptr<MockPipeline> pipeline_;
284 scoped_ptr< MockFilterHost<Demuxer> > filter_host_; 284 scoped_ptr<MockFilterHost<Demuxer> > filter_host_;
285 scoped_refptr<MockDataSource> data_source_; 285 scoped_refptr<old_mocks::MockDataSource> data_source_;
286 286
287 private: 287 private:
288 static void InitializeFFmpegMocks() { 288 static void InitializeFFmpegMocks() {
289 // Initialize function return codes. 289 // Initialize function return codes.
290 g_av_open_input_file = 0; 290 g_av_open_input_file = 0;
291 g_av_find_stream_info = 0; 291 g_av_find_stream_info = 0;
292 g_av_read_frame = 0; 292 g_av_read_frame = 0;
293 293
294 // Initialize AVFormatContext structure. 294 // Initialize AVFormatContext structure.
295 memset(&g_format, 0, sizeof(g_format)); 295 memset(&g_format, 0, sizeof(g_format));
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
393 EXPECT_TRUE(demuxer_->Initialize(data_source_.get())); 393 EXPECT_TRUE(demuxer_->Initialize(data_source_.get()));
394 EXPECT_TRUE(filter_host_->WaitForInitialized()); 394 EXPECT_TRUE(filter_host_->WaitForInitialized());
395 EXPECT_TRUE(filter_host_->IsInitialized()); 395 EXPECT_TRUE(filter_host_->IsInitialized());
396 EXPECT_EQ(PIPELINE_OK, pipeline_->GetError()); 396 EXPECT_EQ(PIPELINE_OK, pipeline_->GetError());
397 397
398 // Since we ignore data streams, the duration should be equal to the video 398 // Since we ignore data streams, the duration should be equal to the video
399 // stream's duration. 399 // stream's duration.
400 EXPECT_EQ(g_streams[1].duration, pipeline_->GetDuration().InMicroseconds()); 400 EXPECT_EQ(g_streams[1].duration, pipeline_->GetDuration().InMicroseconds());
401 401
402 // Verify that 2 out of 3 streams were created. 402 // Verify that 2 out of 3 streams were created.
403 EXPECT_EQ(2, demuxer_->GetNumberOfStreams()); 403 EXPECT_EQ(2u, demuxer_->GetNumberOfStreams());
404 404
405 // First stream should be video and support FFmpegDemuxerStream interface. 405 // First stream should be video and support FFmpegDemuxerStream interface.
406 scoped_refptr<DemuxerStream> stream = demuxer_->GetStream(0); 406 scoped_refptr<DemuxerStream> stream = demuxer_->GetStream(0);
407 AVStreamProvider* av_stream_provider = NULL; 407 AVStreamProvider* av_stream_provider = NULL;
408 ASSERT_TRUE(stream); 408 ASSERT_TRUE(stream);
409 std::string mime_type; 409 std::string mime_type;
410 EXPECT_TRUE( 410 EXPECT_TRUE(
411 stream->media_format().GetAsString(MediaFormat::kMimeType, &mime_type)); 411 stream->media_format().GetAsString(MediaFormat::kMimeType, &mime_type));
412 EXPECT_STREQ(mime_type::kFFmpegVideo, mime_type.c_str()); 412 EXPECT_STREQ(mime_type::kFFmpegVideo, mime_type.c_str());
413 EXPECT_TRUE(stream->QueryInterface(&av_stream_provider)); 413 EXPECT_TRUE(stream->QueryInterface(&av_stream_provider));
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
452 g_streams[2].duration = 10; 452 g_streams[2].duration = 10;
453 g_streams[2].codec = &g_video_codec; 453 g_streams[2].codec = &g_video_codec;
454 454
455 // Initialize the demuxer. 455 // Initialize the demuxer.
456 EXPECT_TRUE(demuxer_->Initialize(data_source_.get())); 456 EXPECT_TRUE(demuxer_->Initialize(data_source_.get()));
457 EXPECT_TRUE(filter_host_->WaitForInitialized()); 457 EXPECT_TRUE(filter_host_->WaitForInitialized());
458 EXPECT_TRUE(filter_host_->IsInitialized()); 458 EXPECT_TRUE(filter_host_->IsInitialized());
459 EXPECT_EQ(PIPELINE_OK, pipeline_->GetError()); 459 EXPECT_EQ(PIPELINE_OK, pipeline_->GetError());
460 460
461 // Verify both streams were created. 461 // Verify both streams were created.
462 EXPECT_EQ(2, demuxer_->GetNumberOfStreams()); 462 EXPECT_EQ(2u, demuxer_->GetNumberOfStreams());
463 463
464 // Get our streams. 464 // Get our streams.
465 scoped_refptr<DemuxerStream> audio_stream = demuxer_->GetStream(kAudio); 465 scoped_refptr<DemuxerStream> audio_stream = demuxer_->GetStream(kAudio);
466 scoped_refptr<DemuxerStream> video_stream = demuxer_->GetStream(kVideo); 466 scoped_refptr<DemuxerStream> video_stream = demuxer_->GetStream(kVideo);
467 ASSERT_TRUE(audio_stream); 467 ASSERT_TRUE(audio_stream);
468 ASSERT_TRUE(video_stream); 468 ASSERT_TRUE(video_stream);
469 469
470 // Prepare data packets, which should all get immediately released. 470 // Prepare data packets, which should all get immediately released.
471 PacketQueue::get()->Enqueue(kPacketData, kDataSize, audio_data); 471 PacketQueue::get()->Enqueue(kPacketData, kDataSize, audio_data);
472 PacketQueue::get()->Enqueue(kPacketData, kDataSize, audio_data); 472 PacketQueue::get()->Enqueue(kPacketData, kDataSize, audio_data);
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after
648 g_streams[0].codec = &g_audio_codec; 648 g_streams[0].codec = &g_audio_codec;
649 g_audio_codec.codec_id = CODEC_ID_MP3; 649 g_audio_codec.codec_id = CODEC_ID_MP3;
650 650
651 // Initialize the demuxer. 651 // Initialize the demuxer.
652 EXPECT_TRUE(demuxer_->Initialize(data_source_.get())); 652 EXPECT_TRUE(demuxer_->Initialize(data_source_.get()));
653 EXPECT_TRUE(filter_host_->WaitForInitialized()); 653 EXPECT_TRUE(filter_host_->WaitForInitialized());
654 EXPECT_TRUE(filter_host_->IsInitialized()); 654 EXPECT_TRUE(filter_host_->IsInitialized());
655 EXPECT_EQ(PIPELINE_OK, pipeline_->GetError()); 655 EXPECT_EQ(PIPELINE_OK, pipeline_->GetError());
656 656
657 // Verify the stream was created. 657 // Verify the stream was created.
658 EXPECT_EQ(1, demuxer_->GetNumberOfStreams()); 658 EXPECT_EQ(1u, demuxer_->GetNumberOfStreams());
659 scoped_refptr<DemuxerStream> audio_stream = demuxer_->GetStream(kAudio); 659 scoped_refptr<DemuxerStream> audio_stream = demuxer_->GetStream(kAudio);
660 ASSERT_TRUE(audio_stream); 660 ASSERT_TRUE(audio_stream);
661 661
662 // Prepare our test audio packet. 662 // Prepare our test audio packet.
663 PacketQueue::get()->Enqueue(kPacketAudio, kDataSize, audio_data); 663 PacketQueue::get()->Enqueue(kPacketAudio, kDataSize, audio_data);
664 664
665 // Audio read should perform a deep copy on the packet and instantly release 665 // Audio read should perform a deep copy on the packet and instantly release
666 // the original packet. The data pointers should not be the same, but the 666 // the original packet. The data pointers should not be the same, but the
667 // contents should match. 667 // contents should match.
668 scoped_refptr<TestReader> reader = new TestReader(); 668 scoped_refptr<TestReader> reader = new TestReader();
(...skipping 11 matching lines...) Expand all
680 EXPECT_TRUE(PacketQueue::get()->WaitForOutstandingPackets(0)); 680 EXPECT_TRUE(PacketQueue::get()->WaitForOutstandingPackets(0));
681 EXPECT_EQ(1, g_outstanding_packets_av_new_frame); 681 EXPECT_EQ(1, g_outstanding_packets_av_new_frame);
682 682
683 // Now release our reference, which should destruct the packet allocated by 683 // Now release our reference, which should destruct the packet allocated by
684 // av_new_packet(). 684 // av_new_packet().
685 reader = NULL; 685 reader = NULL;
686 EXPECT_EQ(0, g_outstanding_packets_av_new_frame); 686 EXPECT_EQ(0, g_outstanding_packets_av_new_frame);
687 } 687 }
688 688
689 } // namespace 689 } // namespace
OLDNEW
« no previous file with comments | « media/base/video_frame_impl_unittest.cc ('k') | media/filters/ffmpeg_glue_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698