OLD | NEW |
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 "base/logging.h" | 5 #include "base/logging.h" |
6 #include "base/memory/scoped_ptr.h" | 6 #include "base/memory/scoped_ptr.h" |
7 #include "media/base/mock_filters.h" | 7 #include "media/base/mock_filters.h" |
8 #include "media/base/test_data_util.h" | 8 #include "media/base/test_data_util.h" |
9 #include "media/ffmpeg/ffmpeg_common.h" | 9 #include "media/ffmpeg/ffmpeg_common.h" |
10 #include "media/filters/ffmpeg_glue.h" | 10 #include "media/filters/ffmpeg_glue.h" |
(...skipping 27 matching lines...) Expand all Loading... |
38 public: | 38 public: |
39 FFmpegGlueTest() | 39 FFmpegGlueTest() |
40 : protocol_(new StrictMock<MockProtocol>()) { | 40 : protocol_(new StrictMock<MockProtocol>()) { |
41 // IsStreaming() is called when opening. | 41 // IsStreaming() is called when opening. |
42 EXPECT_CALL(*protocol_.get(), IsStreaming()).WillOnce(Return(true)); | 42 EXPECT_CALL(*protocol_.get(), IsStreaming()).WillOnce(Return(true)); |
43 glue_.reset(new FFmpegGlue(protocol_.get())); | 43 glue_.reset(new FFmpegGlue(protocol_.get())); |
44 CHECK(glue_->format_context()); | 44 CHECK(glue_->format_context()); |
45 CHECK(glue_->format_context()->pb); | 45 CHECK(glue_->format_context()->pb); |
46 } | 46 } |
47 | 47 |
48 virtual ~FFmpegGlueTest() { | 48 ~FFmpegGlueTest() override { |
49 // Ensure |glue_| and |protocol_| are still alive. | 49 // Ensure |glue_| and |protocol_| are still alive. |
50 CHECK(glue_.get()); | 50 CHECK(glue_.get()); |
51 CHECK(protocol_.get()); | 51 CHECK(protocol_.get()); |
52 | 52 |
53 // |protocol_| should outlive |glue_|, so ensure it's destructed first. | 53 // |protocol_| should outlive |glue_|, so ensure it's destructed first. |
54 glue_.reset(); | 54 glue_.reset(); |
55 } | 55 } |
56 | 56 |
57 int ReadPacket(int size, uint8* data) { | 57 int ReadPacket(int size, uint8* data) { |
58 return glue_->format_context()->pb->read_packet( | 58 return glue_->format_context()->pb->read_packet( |
(...skipping 18 matching lines...) Expand all Loading... |
77 | 77 |
78 void Initialize(const char* filename) { | 78 void Initialize(const char* filename) { |
79 data_ = ReadTestDataFile(filename); | 79 data_ = ReadTestDataFile(filename); |
80 protocol_.reset(new InMemoryUrlProtocol( | 80 protocol_.reset(new InMemoryUrlProtocol( |
81 data_->data(), data_->data_size(), false)); | 81 data_->data(), data_->data_size(), false)); |
82 glue_.reset(new FFmpegGlue(protocol_.get())); | 82 glue_.reset(new FFmpegGlue(protocol_.get())); |
83 CHECK(glue_->format_context()); | 83 CHECK(glue_->format_context()); |
84 CHECK(glue_->format_context()->pb); | 84 CHECK(glue_->format_context()->pb); |
85 } | 85 } |
86 | 86 |
87 virtual ~FFmpegGlueDestructionTest() { | 87 ~FFmpegGlueDestructionTest() override { |
88 // Ensure Initialize() was called. | 88 // Ensure Initialize() was called. |
89 CHECK(glue_.get()); | 89 CHECK(glue_.get()); |
90 CHECK(protocol_.get()); | 90 CHECK(protocol_.get()); |
91 | 91 |
92 // |glue_| should be destroyed before |protocol_|. | 92 // |glue_| should be destroyed before |protocol_|. |
93 glue_.reset(); | 93 glue_.reset(); |
94 | 94 |
95 // |protocol_| should be destroyed before |data_|. | 95 // |protocol_| should be destroyed before |data_|. |
96 protocol_.reset(); | 96 protocol_.reset(); |
97 data_ = NULL; | 97 data_ = NULL; |
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
234 Initialize("bear-320x240.webm"); | 234 Initialize("bear-320x240.webm"); |
235 ASSERT_TRUE(glue_->OpenContext()); | 235 ASSERT_TRUE(glue_->OpenContext()); |
236 ASSERT_GT(glue_->format_context()->nb_streams, 0u); | 236 ASSERT_GT(glue_->format_context()->nb_streams, 0u); |
237 | 237 |
238 AVCodecContext* context = glue_->format_context()->streams[0]->codec; | 238 AVCodecContext* context = glue_->format_context()->streams[0]->codec; |
239 ASSERT_EQ(avcodec_open2( | 239 ASSERT_EQ(avcodec_open2( |
240 context, avcodec_find_decoder(context->codec_id), NULL), 0); | 240 context, avcodec_find_decoder(context->codec_id), NULL), 0); |
241 } | 241 } |
242 | 242 |
243 } // namespace media | 243 } // namespace media |
OLD | NEW |