| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. Use of this | 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. Use of this |
| 2 // source code is governed by a BSD-style license that can be found in the | 2 // source code is governed by a BSD-style license that can be found in the |
| 3 // LICENSE file. | 3 // LICENSE file. |
| 4 | 4 |
| 5 #ifndef MEDIA_BASE_MOCK_MEDIA_FILTERS_H_ | 5 #ifndef MEDIA_BASE_MOCK_MEDIA_FILTERS_H_ |
| 6 #define MEDIA_BASE_MOCK_MEDIA_FILTERS_H_ | 6 #define MEDIA_BASE_MOCK_MEDIA_FILTERS_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/waitable_event.h" | 10 #include "base/waitable_event.h" |
| (...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 188 | 188 |
| 189 // Set to true inside the destructor. Used in FFmpegGlue unit tests for | 189 // Set to true inside the destructor. Used in FFmpegGlue unit tests for |
| 190 // testing proper reference counting. | 190 // testing proper reference counting. |
| 191 bool* deleted_; | 191 bool* deleted_; |
| 192 | 192 |
| 193 DISALLOW_COPY_AND_ASSIGN(MockDataSource); | 193 DISALLOW_COPY_AND_ASSIGN(MockDataSource); |
| 194 }; | 194 }; |
| 195 | 195 |
| 196 //------------------------------------------------------------------------------ | 196 //------------------------------------------------------------------------------ |
| 197 | 197 |
| 198 class MockDemuxerStream : public DemuxerStream { |
| 199 public: |
| 200 MockDemuxerStream(const MockFilterConfig* config, bool is_audio) { |
| 201 if (is_audio) { |
| 202 media_format_.SetAsString(MediaFormat::kMimeType, |
| 203 config->compressed_audio_mime_type); |
| 204 } else { |
| 205 media_format_.SetAsString(MediaFormat::kMimeType, |
| 206 config->compressed_video_mime_type); |
| 207 media_format_.SetAsInteger(MediaFormat::kWidth, config->video_width); |
| 208 media_format_.SetAsInteger(MediaFormat::kHeight, config->video_height); |
| 209 } |
| 210 } |
| 211 |
| 212 // Implementation of DemuxerStream. |
| 213 virtual const MediaFormat* GetMediaFormat() { |
| 214 return &media_format_; |
| 215 } |
| 216 |
| 217 virtual void Read(Assignable<Buffer>* buffer) { |
| 218 NOTREACHED(); // TODO(ralphl): fix me!! |
| 219 } |
| 220 |
| 221 private: |
| 222 virtual ~MockDemuxerStream() {} |
| 223 |
| 224 MediaFormat media_format_; |
| 225 |
| 226 DISALLOW_COPY_AND_ASSIGN(MockDemuxerStream); |
| 227 }; |
| 228 |
| 229 //------------------------------------------------------------------------------ |
| 230 |
| 198 class MockDemuxer : public Demuxer { | 231 class MockDemuxer : public Demuxer { |
| 199 public: | 232 public: |
| 200 static FilterFactory* CreateFactory(const MockFilterConfig* config) { | 233 static FilterFactory* CreateFactory(const MockFilterConfig* config) { |
| 201 return new FilterFactoryImpl1<MockDemuxer, | 234 return new FilterFactoryImpl1<MockDemuxer, |
| 202 const MockFilterConfig*>(config); | 235 const MockFilterConfig*>(config); |
| 203 } | 236 } |
| 204 | 237 |
| 205 explicit MockDemuxer(const MockFilterConfig* config) | 238 explicit MockDemuxer(const MockFilterConfig* config) |
| 206 : config_(config), | 239 : config_(config), |
| 207 mock_audio_stream_(config, true), | 240 mock_audio_stream_(new MockDemuxerStream(config, true)), |
| 208 mock_video_stream_(config, false) { | 241 mock_video_stream_(new MockDemuxerStream(config, false)) { |
| 209 } | 242 } |
| 210 | 243 |
| 211 // Implementation of MediaFilter. | 244 // Implementation of MediaFilter. |
| 212 virtual void Stop() {} | 245 virtual void Stop() {} |
| 213 | 246 |
| 214 // Implementation of Demuxer. | 247 // Implementation of Demuxer. |
| 215 virtual bool Initialize(DataSource* data_source) { | 248 virtual bool Initialize(DataSource* data_source) { |
| 216 host_->InitializationComplete(); | 249 host_->InitializationComplete(); |
| 217 return true; | 250 return true; |
| 218 } | 251 } |
| 219 | 252 |
| 220 virtual size_t GetNumberOfStreams() { | 253 virtual size_t GetNumberOfStreams() { |
| 221 size_t num_streams = 0; | 254 size_t num_streams = 0; |
| 222 if (config_->has_audio) { | 255 if (config_->has_audio) { |
| 223 ++num_streams; | 256 ++num_streams; |
| 224 } | 257 } |
| 225 if (config_->has_video) { | 258 if (config_->has_video) { |
| 226 ++num_streams; | 259 ++num_streams; |
| 227 } | 260 } |
| 228 return num_streams; | 261 return num_streams; |
| 229 } | 262 } |
| 230 | 263 |
| 231 virtual DemuxerStream* GetStream(int stream_id) { | 264 virtual scoped_refptr<DemuxerStream> GetStream(int stream_id) { |
| 232 switch (stream_id) { | 265 switch (stream_id) { |
| 233 case 0: | 266 case 0: |
| 234 if (config_->has_audio) { | 267 if (config_->has_audio) { |
| 235 return &mock_audio_stream_; | 268 return mock_audio_stream_; |
| 236 } else if (config_->has_video) { | 269 } else if (config_->has_video) { |
| 237 return &mock_video_stream_; | 270 return mock_video_stream_; |
| 238 } | 271 } |
| 239 break; | 272 break; |
| 240 case 1: | 273 case 1: |
| 241 if (config_->has_audio && config_->has_video) { | 274 if (config_->has_audio && config_->has_video) { |
| 242 return &mock_video_stream_; | 275 return mock_video_stream_; |
| 243 } | 276 } |
| 244 break; | 277 break; |
| 245 } | 278 } |
| 246 ADD_FAILURE(); | 279 ADD_FAILURE(); |
| 247 return NULL; | 280 return NULL; |
| 248 } | 281 } |
| 249 | 282 |
| 250 private: | 283 private: |
| 251 virtual ~MockDemuxer() {} | 284 virtual ~MockDemuxer() {} |
| 252 | 285 |
| 253 // Internal class implements DemuxerStream interface. | |
| 254 class MockDemuxerStream : public DemuxerStream { | |
| 255 public: | |
| 256 MockDemuxerStream(const MockFilterConfig* config, bool is_audio) { | |
| 257 if (is_audio) { | |
| 258 media_format_.SetAsString(MediaFormat::kMimeType, | |
| 259 config->compressed_audio_mime_type); | |
| 260 } else { | |
| 261 media_format_.SetAsString(MediaFormat::kMimeType, | |
| 262 config->compressed_video_mime_type); | |
| 263 media_format_.SetAsInteger(MediaFormat::kWidth, config->video_width); | |
| 264 media_format_.SetAsInteger(MediaFormat::kHeight, config->video_height); | |
| 265 } | |
| 266 } | |
| 267 | |
| 268 virtual ~MockDemuxerStream() {} | |
| 269 | |
| 270 // Implementation of DemuxerStream. | |
| 271 virtual const MediaFormat* GetMediaFormat() { | |
| 272 return &media_format_; | |
| 273 } | |
| 274 | |
| 275 virtual void Read(Assignable<Buffer>* buffer) { | |
| 276 NOTREACHED(); // TODO(ralphl): fix me!! | |
| 277 } | |
| 278 | |
| 279 private: | |
| 280 MediaFormat media_format_; | |
| 281 | |
| 282 DISALLOW_COPY_AND_ASSIGN(MockDemuxerStream); | |
| 283 }; | |
| 284 | |
| 285 const MockFilterConfig* config_; | 286 const MockFilterConfig* config_; |
| 286 MockDemuxerStream mock_audio_stream_; | 287 scoped_refptr<DemuxerStream> mock_audio_stream_; |
| 287 MockDemuxerStream mock_video_stream_; | 288 scoped_refptr<DemuxerStream> mock_video_stream_; |
| 288 | 289 |
| 289 DISALLOW_COPY_AND_ASSIGN(MockDemuxer); | 290 DISALLOW_COPY_AND_ASSIGN(MockDemuxer); |
| 290 }; | 291 }; |
| 291 | 292 |
| 292 //------------------------------------------------------------------------------ | 293 //------------------------------------------------------------------------------ |
| 293 | 294 |
| 294 class MockAudioDecoder : public AudioDecoder { | 295 class MockAudioDecoder : public AudioDecoder { |
| 295 public: | 296 public: |
| 296 static FilterFactory* CreateFactory(const MockFilterConfig* config) { | 297 static FilterFactory* CreateFactory(const MockFilterConfig* config) { |
| 297 return new FilterFactoryImpl1<MockAudioDecoder, | 298 return new FilterFactoryImpl1<MockAudioDecoder, |
| (...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 587 base::WaitableEvent event_; | 588 base::WaitableEvent event_; |
| 588 bool callback_success_status_; | 589 bool callback_success_status_; |
| 589 bool waiting_for_callback_; | 590 bool waiting_for_callback_; |
| 590 | 591 |
| 591 DISALLOW_COPY_AND_ASSIGN(InitializationHelper); | 592 DISALLOW_COPY_AND_ASSIGN(InitializationHelper); |
| 592 }; | 593 }; |
| 593 | 594 |
| 594 } // namespace media | 595 } // namespace media |
| 595 | 596 |
| 596 #endif // MEDIA_BASE_MOCK_MEDIA_FILTERS_H_ | 597 #endif // MEDIA_BASE_MOCK_MEDIA_FILTERS_H_ |
| OLD | NEW |