| OLD | NEW |
| (Empty) |
| 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 | |
| 3 // LICENSE file. | |
| 4 // | |
| 5 // Simple test class used by unit tests. Tests create the filter on the test's | |
| 6 // thread and then use InstanceFilterFactory to force the test's instance to | |
| 7 // be returned to the pipeline. | |
| 8 | |
| 9 #ifndef MEDIA_FILTERS_TEST_VIDEO_RENDERER_H_ | |
| 10 #define MEDIA_FILTERS_TEST_VIDEO_RENDERER_H_ | |
| 11 | |
| 12 #include "media/base/buffers.h" | |
| 13 #include "media/base/factory.h" | |
| 14 #include "media/base/filters.h" | |
| 15 #include "media/filters/video_renderer_base.h" | |
| 16 | |
| 17 namespace media { | |
| 18 | |
| 19 class TestVideoRenderer : public VideoRendererBase { | |
| 20 public: | |
| 21 TestVideoRenderer() | |
| 22 : last_frame_(NULL), | |
| 23 paint_called_(0), | |
| 24 unique_frames_(0) { | |
| 25 } | |
| 26 | |
| 27 virtual bool OnInitialize(size_t width, size_t height) { return true; } | |
| 28 | |
| 29 virtual void OnPaintNeeded() { | |
| 30 ++paint_called_; | |
| 31 scoped_refptr<VideoFrame> frame; | |
| 32 GetCurrentFrame(&frame); | |
| 33 if (frame.get()) { | |
| 34 VideoSurface video_surface; | |
| 35 EXPECT_TRUE(frame->Lock(&video_surface)); | |
| 36 frame->Unlock(); | |
| 37 if (frame != last_frame_) { | |
| 38 ++unique_frames_; | |
| 39 last_frame_ = frame; | |
| 40 last_timestamp_ = frame->GetTimestamp(); | |
| 41 } | |
| 42 } | |
| 43 } | |
| 44 | |
| 45 size_t unique_frames() { return unique_frames_; } | |
| 46 size_t paint_called() { return paint_called_; } | |
| 47 base::TimeDelta last_timestamp() { return last_timestamp_; } | |
| 48 | |
| 49 static bool IsMediaFormatSupported(const MediaFormat& format) { | |
| 50 return VideoRendererBase::IsMediaFormatSupported(format); | |
| 51 } | |
| 52 | |
| 53 private: | |
| 54 friend class scoped_refptr<TestVideoRenderer>; | |
| 55 virtual ~TestVideoRenderer() {} | |
| 56 | |
| 57 VideoFrame* last_frame_; | |
| 58 size_t paint_called_; | |
| 59 size_t unique_frames_; | |
| 60 base::TimeDelta last_timestamp_; | |
| 61 | |
| 62 DISALLOW_COPY_AND_ASSIGN(TestVideoRenderer); | |
| 63 }; | |
| 64 | |
| 65 } // namespace | |
| 66 | |
| 67 #endif // MEDIA_FILTERS_TEST_VIDEO_RENDERER_H_ | |
| OLD | NEW |