| 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 23 matching lines...) Expand all Loading... |
| 34 // of the desired pipeline. The test using this must ensure that the lifetime | 34 // of the desired pipeline. The test using this must ensure that the lifetime |
| 35 // of the object is at least as long as the lifetime of the filters, as this | 35 // of the object is at least as long as the lifetime of the filters, as this |
| 36 // is typically allocated on the stack. | 36 // is typically allocated on the stack. |
| 37 struct MockFilterConfig { | 37 struct MockFilterConfig { |
| 38 MockFilterConfig() | 38 MockFilterConfig() |
| 39 : data_source_behavior(MOCK_DATA_SOURCE_NORMAL_INIT), | 39 : data_source_behavior(MOCK_DATA_SOURCE_NORMAL_INIT), |
| 40 has_video(true), | 40 has_video(true), |
| 41 video_width(1280u), | 41 video_width(1280u), |
| 42 video_height(720u), | 42 video_height(720u), |
| 43 video_surface_format(VideoSurface::YV12), | 43 video_surface_format(VideoSurface::YV12), |
| 44 has_audio(true), |
| 44 compressed_audio_mime_type(mime_type::kAACAudio), | 45 compressed_audio_mime_type(mime_type::kAACAudio), |
| 45 uncompressed_audio_mime_type(mime_type::kUncompressedAudio), | 46 uncompressed_audio_mime_type(mime_type::kUncompressedAudio), |
| 46 compressed_video_mime_type(mime_type::kH264AnnexB), | 47 compressed_video_mime_type(mime_type::kH264AnnexB), |
| 47 uncompressed_video_mime_type(mime_type::kUncompressedVideo), | 48 uncompressed_video_mime_type(mime_type::kUncompressedVideo), |
| 48 frame_duration(base::TimeDelta::FromMicroseconds(33333)), | 49 frame_duration(base::TimeDelta::FromMicroseconds(33333)), |
| 49 media_duration(base::TimeDelta::FromSeconds(5)) { | 50 media_duration(base::TimeDelta::FromSeconds(5)), |
| 51 media_total_bytes(media_duration.InMilliseconds() * 250) { |
| 50 } | 52 } |
| 51 | 53 |
| 52 MockDataSourceBehavior data_source_behavior; | 54 MockDataSourceBehavior data_source_behavior; |
| 53 bool has_video; | 55 bool has_video; |
| 54 size_t video_width; | 56 size_t video_width; |
| 55 size_t video_height; | 57 size_t video_height; |
| 56 VideoSurface::Format video_surface_format; | 58 VideoSurface::Format video_surface_format; |
| 59 bool has_audio; |
| 57 std::string compressed_audio_mime_type; | 60 std::string compressed_audio_mime_type; |
| 58 std::string uncompressed_audio_mime_type; | 61 std::string uncompressed_audio_mime_type; |
| 59 std::string compressed_video_mime_type; | 62 std::string compressed_video_mime_type; |
| 60 std::string uncompressed_video_mime_type; | 63 std::string uncompressed_video_mime_type; |
| 61 base::TimeDelta frame_duration; | 64 base::TimeDelta frame_duration; |
| 62 base::TimeDelta media_duration; | 65 base::TimeDelta media_duration; |
| 66 int64 media_total_bytes; |
| 63 }; | 67 }; |
| 64 | 68 |
| 65 | 69 |
| 66 class MockDataSource : public DataSource { | 70 class MockDataSource : public DataSource { |
| 67 public: | 71 public: |
| 68 static FilterFactory* CreateFactory(const MockFilterConfig* config) { | 72 static FilterFactory* CreateFactory(const MockFilterConfig* config) { |
| 69 return new FilterFactoryImpl1<MockDataSource, | 73 return new FilterFactoryImpl1<MockDataSource, |
| 70 const MockFilterConfig*>(config); | 74 const MockFilterConfig*>(config); |
| 71 } | 75 } |
| 72 | 76 |
| 73 // Implementation of MediaFilter. | 77 // Implementation of MediaFilter. |
| 74 virtual void Stop() {} | 78 virtual void Stop() {} |
| 75 | 79 |
| 76 // Implementation of DataSource. | 80 // Implementation of DataSource. |
| 77 virtual bool Initialize(const std::string& url) { | 81 virtual bool Initialize(const std::string& url) { |
| 78 media_format_.SetAsString(MediaFormat::kMimeType, | 82 media_format_.SetAsString(MediaFormat::kMimeType, |
| 79 mime_type::kApplicationOctetStream); | 83 mime_type::kApplicationOctetStream); |
| 80 media_format_.SetAsString(MediaFormat::kURL, url); | 84 media_format_.SetAsString(MediaFormat::kURL, url); |
| 81 switch (behavior_) { | 85 host_->SetTotalBytes(config_->media_total_bytes); |
| 86 switch (config_->data_source_behavior) { |
| 82 case MOCK_DATA_SOURCE_NORMAL_INIT: | 87 case MOCK_DATA_SOURCE_NORMAL_INIT: |
| 83 host_->InitializationComplete(); | 88 host_->InitializationComplete(); |
| 84 return true; | 89 return true; |
| 85 case MOCK_DATA_SOURCE_NEVER_INIT: | 90 case MOCK_DATA_SOURCE_NEVER_INIT: |
| 86 return true; | 91 return true; |
| 87 case MOCK_DATA_SOURCE_TASK_ERROR_POST_INIT: | 92 case MOCK_DATA_SOURCE_TASK_ERROR_POST_INIT: |
| 88 host_->InitializationComplete(); | 93 host_->InitializationComplete(); |
| 89 // Yes, we want to fall through to schedule the task... | 94 // Yes, we want to fall through to schedule the task... |
| 90 case MOCK_DATA_SOURCE_TASK_ERROR_PRE_INIT: | 95 case MOCK_DATA_SOURCE_TASK_ERROR_PRE_INIT: |
| 91 case MOCK_DATA_SOURCE_TASK_INIT: | 96 case MOCK_DATA_SOURCE_TASK_INIT: |
| 92 host_->PostTask(NewRunnableMethod(this, &MockDataSource::TaskBehavior)); | 97 host_->PostTask(NewRunnableMethod(this, &MockDataSource::TaskBehavior)); |
| 93 return true; | 98 return true; |
| 94 case MOCK_DATA_SOURCE_ERROR_IN_INIT: | 99 case MOCK_DATA_SOURCE_ERROR_IN_INIT: |
| 95 host_->Error(PIPELINE_ERROR_NETWORK); | 100 host_->Error(PIPELINE_ERROR_NETWORK); |
| 96 return false; | 101 return false; |
| 97 case MOCK_DATA_SOURCE_INIT_RETURN_FALSE: | 102 case MOCK_DATA_SOURCE_INIT_RETURN_FALSE: |
| 98 return false; | 103 return false; |
| 99 default: | 104 default: |
| 100 NOTREACHED(); | 105 NOTREACHED(); |
| 101 return false; | 106 return false; |
| 102 } | 107 } |
| 103 } | 108 } |
| 104 | 109 |
| 105 virtual const MediaFormat* GetMediaFormat() { | 110 virtual const MediaFormat* GetMediaFormat() { |
| 106 return &media_format_; | 111 return &media_format_; |
| 107 } | 112 } |
| 108 | 113 |
| 109 virtual size_t Read(char* data, size_t size) { | 114 virtual size_t Read(uint8* data, size_t size) { |
| 110 return 0; | 115 size_t read = static_cast<size_t>(config_->media_total_bytes - position_); |
| 116 if (size < read) { |
| 117 read = size; |
| 118 } |
| 119 memset(data, 0, read); |
| 120 return read; |
| 111 } | 121 } |
| 112 | 122 |
| 113 virtual bool GetPosition(int64* position_out) { | 123 virtual bool GetPosition(int64* position_out) { |
| 114 *position_out = 0; | 124 *position_out = position_; |
| 115 return false; | 125 return true; |
| 116 } | 126 } |
| 117 | 127 |
| 118 virtual bool SetPosition(int64 position) { | 128 virtual bool SetPosition(int64 position) { |
| 129 EXPECT_GE(position, 0u); |
| 130 EXPECT_LE(position, config_->media_total_bytes); |
| 131 if (position < 0u || position > config_->media_total_bytes) { |
| 132 return false; |
| 133 } |
| 134 position_ = position; |
| 119 return true; | 135 return true; |
| 120 } | 136 } |
| 121 | 137 |
| 122 virtual bool GetSize(int64* size_out) { | 138 virtual bool GetSize(int64* size_out) { |
| 123 *size_out = 0; | 139 *size_out = config_->media_total_bytes; |
| 124 return false; | 140 return false; |
| 125 } | 141 } |
| 126 | 142 |
| 127 private: | 143 private: |
| 128 friend class FilterFactoryImpl1<MockDataSource, | 144 friend class FilterFactoryImpl1<MockDataSource, |
| 129 const MockFilterConfig*>; | 145 const MockFilterConfig*>; |
| 130 | 146 |
| 131 explicit MockDataSource(const MockFilterConfig* config) | 147 explicit MockDataSource(const MockFilterConfig* config) |
| 132 : behavior_(config->data_source_behavior) { | 148 : config_(config), |
| 149 position_(0) { |
| 133 } | 150 } |
| 134 | 151 |
| 135 virtual ~MockDataSource() {} | 152 virtual ~MockDataSource() {} |
| 136 | 153 |
| 137 void TaskBehavior() { | 154 void TaskBehavior() { |
| 138 switch (behavior_) { | 155 switch (config_->data_source_behavior) { |
| 139 case MOCK_DATA_SOURCE_TASK_ERROR_POST_INIT: | 156 case MOCK_DATA_SOURCE_TASK_ERROR_POST_INIT: |
| 140 case MOCK_DATA_SOURCE_TASK_ERROR_PRE_INIT: | 157 case MOCK_DATA_SOURCE_TASK_ERROR_PRE_INIT: |
| 141 host_->Error(PIPELINE_ERROR_NETWORK); | 158 host_->Error(PIPELINE_ERROR_NETWORK); |
| 142 break; | 159 break; |
| 143 case MOCK_DATA_SOURCE_TASK_INIT: | 160 case MOCK_DATA_SOURCE_TASK_INIT: |
| 144 host_->InitializationComplete(); | 161 host_->InitializationComplete(); |
| 145 break; | 162 break; |
| 146 default: | 163 default: |
| 147 NOTREACHED(); | 164 NOTREACHED(); |
| 148 } | 165 } |
| 149 } | 166 } |
| 150 | 167 |
| 151 MockDataSourceBehavior behavior_; | 168 const MockFilterConfig* config_; |
| 169 int64 position_; |
| 152 MediaFormat media_format_; | 170 MediaFormat media_format_; |
| 153 | 171 |
| 154 DISALLOW_COPY_AND_ASSIGN(MockDataSource); | 172 DISALLOW_COPY_AND_ASSIGN(MockDataSource); |
| 155 }; | 173 }; |
| 156 | 174 |
| 157 //------------------------------------------------------------------------------ | 175 //------------------------------------------------------------------------------ |
| 158 | 176 |
| 159 class MockDemuxer : public Demuxer { | 177 class MockDemuxer : public Demuxer { |
| 160 public: | 178 public: |
| 161 static FilterFactory* CreateFactory(const MockFilterConfig* config) { | 179 static FilterFactory* CreateFactory(const MockFilterConfig* config) { |
| 162 return new FilterFactoryImpl1<MockDemuxer, | 180 return new FilterFactoryImpl1<MockDemuxer, |
| 163 const MockFilterConfig*>(config); | 181 const MockFilterConfig*>(config); |
| 164 } | 182 } |
| 165 | 183 |
| 166 // Implementation of MediaFilter. | 184 // Implementation of MediaFilter. |
| 167 virtual void Stop() {} | 185 virtual void Stop() {} |
| 168 | 186 |
| 169 // Implementation of Demuxer. | 187 // Implementation of Demuxer. |
| 170 virtual bool Initialize(DataSource* data_source) { | 188 virtual bool Initialize(DataSource* data_source) { |
| 171 host_->InitializationComplete(); | 189 host_->InitializationComplete(); |
| 172 return true; | 190 return true; |
| 173 } | 191 } |
| 174 | 192 |
| 175 virtual size_t GetNumberOfStreams() { | 193 virtual size_t GetNumberOfStreams() { |
| 194 size_t num_streams = 0; |
| 195 if (config_->has_audio) { |
| 196 ++num_streams; |
| 197 } |
| 176 if (config_->has_video) { | 198 if (config_->has_video) { |
| 177 return 2; | 199 ++num_streams; |
| 178 } | 200 } |
| 179 return 1; | 201 return num_streams; |
| 180 } | 202 } |
| 181 | 203 |
| 182 virtual DemuxerStream* GetStream(int stream_id) { | 204 virtual DemuxerStream* GetStream(int stream_id) { |
| 183 switch (stream_id) { | 205 switch (stream_id) { |
| 184 case 0: | 206 case 0: |
| 185 return &mock_audio_stream_; | 207 if (config_->has_audio) { |
| 186 case 1: | 208 return &mock_audio_stream_; |
| 187 if (config_->has_video) { | 209 } else if (config_->has_video) { |
| 188 return &mock_video_stream_; | 210 return &mock_video_stream_; |
| 189 } | 211 } |
| 190 // Fall-through is correct if no video. | 212 break; |
| 191 default: | 213 case 1: |
| 192 ADD_FAILURE(); | 214 if (config_->has_audio && config_->has_video) { |
| 193 return NULL; | 215 return &mock_video_stream_; |
| 216 } |
| 217 break; |
| 194 } | 218 } |
| 219 ADD_FAILURE(); |
| 220 return NULL; |
| 195 } | 221 } |
| 196 | 222 |
| 197 private: | 223 private: |
| 198 friend class FilterFactoryImpl1<MockDemuxer, const MockFilterConfig*>; | 224 friend class FilterFactoryImpl1<MockDemuxer, const MockFilterConfig*>; |
| 199 | 225 |
| 200 explicit MockDemuxer(const MockFilterConfig* config) | 226 explicit MockDemuxer(const MockFilterConfig* config) |
| 201 : config_(config), | 227 : config_(config), |
| 202 mock_audio_stream_(config->compressed_audio_mime_type), | 228 mock_audio_stream_(config, true), |
| 203 mock_video_stream_(config->compressed_video_mime_type) { | 229 mock_video_stream_(config, false) { |
| 204 } | 230 } |
| 205 | 231 |
| 206 virtual ~MockDemuxer() {} | 232 virtual ~MockDemuxer() {} |
| 207 | 233 |
| 208 // Internal class implements DemuxerStream interface. | 234 // Internal class implements DemuxerStream interface. |
| 209 class MockDemuxerStream : public DemuxerStream { | 235 class MockDemuxerStream : public DemuxerStream { |
| 210 public: | 236 public: |
| 211 explicit MockDemuxerStream(const std::string& mime_type) { | 237 MockDemuxerStream(const MockFilterConfig* config, bool is_audio) { |
| 212 media_format_.SetAsString(MediaFormat::kMimeType, mime_type); | 238 if (is_audio) { |
| 239 media_format_.SetAsString(MediaFormat::kMimeType, |
| 240 config->compressed_audio_mime_type); |
| 241 } else { |
| 242 media_format_.SetAsString(MediaFormat::kMimeType, |
| 243 config->compressed_video_mime_type); |
| 244 media_format_.SetAsInteger(MediaFormat::kWidth, config->video_width); |
| 245 media_format_.SetAsInteger(MediaFormat::kHeight, config->video_height); |
| 246 } |
| 213 } | 247 } |
| 214 | 248 |
| 215 virtual ~MockDemuxerStream() {} | 249 virtual ~MockDemuxerStream() {} |
| 216 | 250 |
| 217 // Implementation of DemuxerStream. | 251 // Implementation of DemuxerStream. |
| 218 virtual const MediaFormat* GetMediaFormat() { | 252 virtual const MediaFormat* GetMediaFormat() { |
| 219 return &media_format_; | 253 return &media_format_; |
| 220 } | 254 } |
| 221 | 255 |
| 222 virtual void Read(Assignable<Buffer>* buffer) { | 256 virtual void Read(Assignable<Buffer>* buffer) { |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 313 | 347 |
| 314 virtual ~MockAudioRenderer() {} | 348 virtual ~MockAudioRenderer() {} |
| 315 | 349 |
| 316 DISALLOW_COPY_AND_ASSIGN(MockAudioRenderer); | 350 DISALLOW_COPY_AND_ASSIGN(MockAudioRenderer); |
| 317 }; | 351 }; |
| 318 | 352 |
| 319 //------------------------------------------------------------------------------ | 353 //------------------------------------------------------------------------------ |
| 320 | 354 |
| 321 class MockVideoFrame : public VideoFrame { | 355 class MockVideoFrame : public VideoFrame { |
| 322 public: | 356 public: |
| 323 explicit MockVideoFrame(const MockFilterConfig* config, | 357 MockVideoFrame(size_t video_width, |
| 324 base::TimeDelta timestamp) | 358 size_t video_height, |
| 325 : config_(config), | 359 VideoSurface::Format video_surface_format, |
| 326 surface_locked_(false) { | 360 base::TimeDelta timestamp, |
| 361 base::TimeDelta duration, |
| 362 double ratio_white_to_black) { |
| 363 surface_locked_ = false; |
| 327 SetTimestamp(timestamp); | 364 SetTimestamp(timestamp); |
| 328 SetDuration(config->frame_duration); | 365 SetDuration(duration); |
| 329 size_t y_byte_count = config_->video_width * config_->video_height; | 366 size_t y_byte_count = video_width * video_height; |
| 330 size_t uv_byte_count = y_byte_count / 4; | 367 size_t uv_byte_count = y_byte_count / 4; |
| 331 surface_.format = config_->video_surface_format; | 368 surface_.format = video_surface_format; |
| 332 surface_.width = config_->video_width; | 369 surface_.width = video_width; |
| 333 surface_.height = config_->video_height; | 370 surface_.height = video_height; |
| 334 surface_.planes = 3; | 371 surface_.planes = 3; |
| 335 surface_.data[0] = new char[y_byte_count]; | 372 surface_.data[0] = new uint8[y_byte_count]; |
| 336 surface_.data[1] = new char[uv_byte_count]; | 373 surface_.data[1] = new uint8[uv_byte_count]; |
| 337 surface_.data[2] = new char[uv_byte_count]; | 374 surface_.data[2] = new uint8[uv_byte_count]; |
| 338 surface_.strides[0] = config_->video_width; | 375 surface_.strides[0] = video_width; |
| 339 surface_.strides[1] = config_->video_width / 2; | 376 surface_.strides[1] = video_width / 2; |
| 340 surface_.strides[2] = config_->video_width / 2; | 377 surface_.strides[2] = video_width / 2; |
| 341 memset(surface_.data[0], 0, y_byte_count); | 378 memset(surface_.data[0], 0, y_byte_count); |
| 342 memset(surface_.data[1], 0x80, uv_byte_count); | 379 memset(surface_.data[1], 0x80, uv_byte_count); |
| 343 memset(surface_.data[2], 0x80, uv_byte_count); | 380 memset(surface_.data[2], 0x80, uv_byte_count); |
| 344 int64 num_white_pixels = y_byte_count * | 381 int64 num_white_pixels = static_cast<int64>(y_byte_count * |
| 345 timestamp.InMicroseconds() / | 382 ratio_white_to_black); |
| 346 config_->media_duration.InMicroseconds(); | |
| 347 if (num_white_pixels > y_byte_count) { | 383 if (num_white_pixels > y_byte_count) { |
| 348 ADD_FAILURE(); | 384 ADD_FAILURE(); |
| 349 num_white_pixels = y_byte_count; | 385 num_white_pixels = y_byte_count; |
| 350 } | 386 } |
| 351 if (num_white_pixels < 0) { | 387 if (num_white_pixels < 0) { |
| 352 ADD_FAILURE(); | 388 ADD_FAILURE(); |
| 353 num_white_pixels = 0; | 389 num_white_pixels = 0; |
| 354 } | 390 } |
| 355 memset(surface_.data[0], 0xFF, static_cast<size_t>(num_white_pixels)); | 391 memset(surface_.data[0], 0xFF, static_cast<size_t>(num_white_pixels)); |
| 356 } | 392 } |
| 357 | 393 |
| 358 virtual ~MockVideoFrame() { | 394 virtual ~MockVideoFrame() { |
| 359 delete[] surface_.data[0]; | 395 delete[] surface_.data[0]; |
| 360 delete[] surface_.data[1]; | 396 delete[] surface_.data[1]; |
| 361 delete[] surface_.data[2]; | 397 delete[] surface_.data[2]; |
| 362 } | 398 } |
| 363 | 399 |
| 364 virtual bool Lock(VideoSurface* surface) { | 400 virtual bool Lock(VideoSurface* surface) { |
| 365 EXPECT_FALSE(surface_locked_); | 401 EXPECT_FALSE(surface_locked_); |
| 366 if (surface_locked_) { | 402 if (surface_locked_) { |
| 367 memset(surface, 0, sizeof(*surface)); | 403 memset(surface, 0, sizeof(*surface)); |
| 368 return false; | 404 return false; |
| 369 } | 405 } |
| 370 surface_locked_ = true; | 406 surface_locked_ = true; |
| 371 DCHECK(sizeof(*surface) == sizeof(surface_)); | 407 COMPILE_ASSERT(sizeof(*surface) == sizeof(surface_), surface_size_mismatch); |
| 372 memcpy(surface, &surface_, sizeof(*surface)); | 408 memcpy(surface, &surface_, sizeof(*surface)); |
| 373 return true; | 409 return true; |
| 374 } | 410 } |
| 375 | 411 |
| 376 virtual void Unlock() { | 412 virtual void Unlock() { |
| 377 EXPECT_TRUE(surface_locked_); | 413 EXPECT_TRUE(surface_locked_); |
| 378 surface_locked_ = false; | 414 surface_locked_ = false; |
| 379 } | 415 } |
| 380 | 416 |
| 381 private: | 417 private: |
| 382 const MockFilterConfig* config_; | |
| 383 bool surface_locked_; | 418 bool surface_locked_; |
| 384 VideoSurface surface_; | 419 VideoSurface surface_; |
| 385 | 420 |
| 386 DISALLOW_COPY_AND_ASSIGN(MockVideoFrame); | 421 DISALLOW_COPY_AND_ASSIGN(MockVideoFrame); |
| 387 }; | 422 }; |
| 388 | 423 |
| 389 class MockVideoDecoder : public VideoDecoder { | 424 class MockVideoDecoder : public VideoDecoder { |
| 390 public: | 425 public: |
| 391 static FilterFactory* CreateFactory(const MockFilterConfig* config) { | 426 static FilterFactory* CreateFactory(const MockFilterConfig* config) { |
| 392 return new FilterFactoryImpl1<MockVideoDecoder, | 427 return new FilterFactoryImpl1<MockVideoDecoder, |
| (...skipping 28 matching lines...) Expand all Loading... |
| 421 explicit MockVideoDecoder(const MockFilterConfig* config) | 456 explicit MockVideoDecoder(const MockFilterConfig* config) |
| 422 : config_(config) { | 457 : config_(config) { |
| 423 media_format_.SetAsString(MediaFormat::kMimeType, | 458 media_format_.SetAsString(MediaFormat::kMimeType, |
| 424 config->uncompressed_video_mime_type); | 459 config->uncompressed_video_mime_type); |
| 425 media_format_.SetAsInteger(MediaFormat::kWidth, config->video_width); | 460 media_format_.SetAsInteger(MediaFormat::kWidth, config->video_width); |
| 426 media_format_.SetAsInteger(MediaFormat::kHeight, config->video_height); | 461 media_format_.SetAsInteger(MediaFormat::kHeight, config->video_height); |
| 427 } | 462 } |
| 428 | 463 |
| 429 void DoRead(Assignable<VideoFrame>* buffer) { | 464 void DoRead(Assignable<VideoFrame>* buffer) { |
| 430 if (mock_frame_time_ < config_->media_duration) { | 465 if (mock_frame_time_ < config_->media_duration) { |
| 431 VideoFrame* frame = new MockVideoFrame(config_, mock_frame_time_); | 466 VideoFrame* frame = new MockVideoFrame( |
| 467 config_->video_width, |
| 468 config_->video_height, |
| 469 config_->video_surface_format, |
| 470 mock_frame_time_, |
| 471 config_->frame_duration, |
| 472 (mock_frame_time_.InSecondsF() / |
| 473 config_->media_duration.InSecondsF())); |
| 432 mock_frame_time_ += config_->frame_duration; | 474 mock_frame_time_ += config_->frame_duration; |
| 433 if (mock_frame_time_ >= config_->media_duration) { | 475 if (mock_frame_time_ >= config_->media_duration) { |
| 434 frame->SetEndOfStream(true); | 476 frame->SetEndOfStream(true); |
| 435 } | 477 } |
| 436 buffer->SetBuffer(frame); | 478 buffer->SetBuffer(frame); |
| 437 buffer->OnAssignment(); | 479 buffer->OnAssignment(); |
| 438 } | 480 } |
| 439 buffer->Release(); | 481 buffer->Release(); |
| 440 } | 482 } |
| 441 | 483 |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 546 | 588 |
| 547 bool callback_success_status_; | 589 bool callback_success_status_; |
| 548 bool waiting_for_callback_; | 590 bool waiting_for_callback_; |
| 549 | 591 |
| 550 DISALLOW_COPY_AND_ASSIGN(InitializationHelper); | 592 DISALLOW_COPY_AND_ASSIGN(InitializationHelper); |
| 551 }; | 593 }; |
| 552 | 594 |
| 553 } // namespace media | 595 } // namespace media |
| 554 | 596 |
| 555 #endif // MEDIA_BASE_MOCK_MEDIA_FILTERS_H_ | 597 #endif // MEDIA_BASE_MOCK_MEDIA_FILTERS_H_ |
| OLD | NEW |