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

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

Issue 8341033: Remove DemuxerStream::GetAVStream() once and for all. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: now with cmath Created 9 years, 1 month 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 | Annotate | Revision Log
« no previous file with comments | « media/filters/ffmpeg_demuxer.cc ('k') | media/filters/ffmpeg_video_decoder.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) 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/file_path.h" 7 #include "base/file_path.h"
8 #include "base/path_service.h" 8 #include "base/path_service.h"
9 #include "base/threading/thread.h" 9 #include "base/threading/thread.h"
10 #include "media/base/filters.h" 10 #include "media/base/filters.h"
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after
175 //} 175 //}
176 176
177 TEST_F(FFmpegDemuxerTest, Initialize_Successful) { 177 TEST_F(FFmpegDemuxerTest, Initialize_Successful) {
178 InitializeDemuxer(CreateDataSource("bear-320x240.webm")); 178 InitializeDemuxer(CreateDataSource("bear-320x240.webm"));
179 179
180 // Video stream should be present. 180 // Video stream should be present.
181 scoped_refptr<DemuxerStream> stream = 181 scoped_refptr<DemuxerStream> stream =
182 demuxer_->GetStream(DemuxerStream::VIDEO); 182 demuxer_->GetStream(DemuxerStream::VIDEO);
183 ASSERT_TRUE(stream); 183 ASSERT_TRUE(stream);
184 EXPECT_EQ(DemuxerStream::VIDEO, stream->type()); 184 EXPECT_EQ(DemuxerStream::VIDEO, stream->type());
185 ASSERT_TRUE(stream->GetAVStream()); 185
186 const VideoDecoderConfig& video_config = stream->video_decoder_config();
187 EXPECT_EQ(kCodecVP8, video_config.codec());
188 EXPECT_EQ(VideoFrame::YV12, video_config.format());
189 EXPECT_EQ(320, video_config.coded_size().width());
190 EXPECT_EQ(240, video_config.coded_size().height());
191 EXPECT_EQ(0, video_config.visible_rect().x());
192 EXPECT_EQ(0, video_config.visible_rect().y());
193 EXPECT_EQ(320, video_config.visible_rect().width());
194 EXPECT_EQ(240, video_config.visible_rect().height());
195 EXPECT_EQ(30000, video_config.frame_rate_numerator());
196 EXPECT_EQ(1001, video_config.frame_rate_denominator());
197 EXPECT_EQ(1, video_config.aspect_ratio_numerator());
198 EXPECT_EQ(1, video_config.aspect_ratio_denominator());
199 EXPECT_FALSE(video_config.extra_data());
200 EXPECT_EQ(0u, video_config.extra_data_size());
186 201
187 // Audio stream should be present. 202 // Audio stream should be present.
188 stream = demuxer_->GetStream(DemuxerStream::AUDIO); 203 stream = demuxer_->GetStream(DemuxerStream::AUDIO);
189 ASSERT_TRUE(stream); 204 ASSERT_TRUE(stream);
190 EXPECT_EQ(DemuxerStream::AUDIO, stream->type()); 205 EXPECT_EQ(DemuxerStream::AUDIO, stream->type());
191 ASSERT_TRUE(stream->GetAVStream());
192 206
193 // FFmpegDemuxer's audio streams support AudioDecoderConfig structs. 207 const AudioDecoderConfig& audio_config = stream->audio_decoder_config();
194 const AudioDecoderConfig& config = stream->audio_decoder_config(); 208 EXPECT_EQ(kCodecVorbis, audio_config.codec());
195 EXPECT_EQ(kCodecVorbis, config.codec()); 209 EXPECT_EQ(16, audio_config.bits_per_channel());
196 EXPECT_EQ(16, config.bits_per_channel()); 210 EXPECT_EQ(CHANNEL_LAYOUT_STEREO, audio_config.channel_layout());
197 EXPECT_EQ(CHANNEL_LAYOUT_STEREO, config.channel_layout()); 211 EXPECT_EQ(44100, audio_config.samples_per_second());
198 EXPECT_EQ(44100, config.samples_per_second()); 212 EXPECT_TRUE(audio_config.extra_data());
199 EXPECT_TRUE(config.extra_data()); 213 EXPECT_GT(audio_config.extra_data_size(), 0u);
200 EXPECT_GT(config.extra_data_size(), 0u);
201 } 214 }
202 215
203 TEST_F(FFmpegDemuxerTest, Read_Audio) { 216 TEST_F(FFmpegDemuxerTest, Read_Audio) {
204 // We test that on a successful audio packet read. 217 // We test that on a successful audio packet read.
205 InitializeDemuxer(CreateDataSource("bear-320x240.webm")); 218 InitializeDemuxer(CreateDataSource("bear-320x240.webm"));
206 219
207 // Attempt a read from the audio stream and run the message loop until done. 220 // Attempt a read from the audio stream and run the message loop until done.
208 scoped_refptr<DemuxerStream> audio = 221 scoped_refptr<DemuxerStream> audio =
209 demuxer_->GetStream(DemuxerStream::AUDIO); 222 demuxer_->GetStream(DemuxerStream::AUDIO);
210 scoped_refptr<DemuxerStreamReader> reader(new DemuxerStreamReader()); 223 scoped_refptr<DemuxerStreamReader> reader(new DemuxerStreamReader());
(...skipping 472 matching lines...) Expand 10 before | Expand all | Expand 10 after
683 message_loop_.RunAllPending(); 696 message_loop_.RunAllPending();
684 EXPECT_TRUE(reader->called()); 697 EXPECT_TRUE(reader->called());
685 ValidateBuffer(FROM_HERE, reader->buffer(), 1740, 2436000); 698 ValidateBuffer(FROM_HERE, reader->buffer(), 1740, 2436000);
686 699
687 // Manually release the last reference to the buffer and verify it was freed. 700 // Manually release the last reference to the buffer and verify it was freed.
688 reader->Reset(); 701 reader->Reset();
689 message_loop_.RunAllPending(); 702 message_loop_.RunAllPending();
690 } 703 }
691 704
692 } // namespace media 705 } // namespace media
OLDNEW
« no previous file with comments | « media/filters/ffmpeg_demuxer.cc ('k') | media/filters/ffmpeg_video_decoder.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698