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

Side by Side Diff: media/video/capture/fake_video_capture_device.h

Issue 1153713006: FakeVideoCaptureDevice: Regulate framerate without drifting (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: mcasas@ comments #2 Created 5 years, 6 months 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
« no previous file with comments | « no previous file | media/video/capture/fake_video_capture_device.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) 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 // Implementation of a fake VideoCaptureDevice class. Used for testing other 5 // Implementation of a fake VideoCaptureDevice class. Used for testing other
6 // video capture classes when no real hardware is available. 6 // video capture classes when no real hardware is available.
7 7
8 #ifndef MEDIA_VIDEO_CAPTURE_FAKE_VIDEO_CAPTURE_DEVICE_H_ 8 #ifndef MEDIA_VIDEO_CAPTURE_FAKE_VIDEO_CAPTURE_DEVICE_H_
9 #define MEDIA_VIDEO_CAPTURE_FAKE_VIDEO_CAPTURE_DEVICE_H_ 9 #define MEDIA_VIDEO_CAPTURE_FAKE_VIDEO_CAPTURE_DEVICE_H_
10 10
11 #include <string> 11 #include <string>
12 12
13 #include "base/atomicops.h" 13 #include "base/atomicops.h"
14 #include "base/memory/scoped_ptr.h" 14 #include "base/memory/scoped_ptr.h"
15 #include "base/memory/weak_ptr.h" 15 #include "base/memory/weak_ptr.h"
16 #include "base/threading/thread.h" 16 #include "base/threading/thread.h"
17 #include "base/threading/thread_checker.h" 17 #include "base/threading/thread_checker.h"
18 #include "base/time/time.h"
18 #include "media/video/capture/video_capture_device.h" 19 #include "media/video/capture/video_capture_device.h"
19 20
20 namespace media { 21 namespace media {
21 22
22 class MEDIA_EXPORT FakeVideoCaptureDevice : public VideoCaptureDevice { 23 class MEDIA_EXPORT FakeVideoCaptureDevice : public VideoCaptureDevice {
23 public: 24 public:
24 enum FakeVideoCaptureDeviceType { 25 enum FakeVideoCaptureDeviceType {
25 USING_OWN_BUFFERS, 26 USING_OWN_BUFFERS,
26 USING_OWN_BUFFERS_TRIPLANAR, 27 USING_OWN_BUFFERS_TRIPLANAR,
27 USING_CLIENT_BUFFERS_I420, 28 USING_CLIENT_BUFFERS_I420,
28 USING_CLIENT_BUFFERS_GPU, 29 USING_CLIENT_BUFFERS_GPU,
29 }; 30 };
30 31
31 static int FakeCapturePeriodMs() { return kFakeCapturePeriodMs; } 32 static int FakeCapturePeriodMs() { return kFakeCapturePeriodMs; }
32 33
33 explicit FakeVideoCaptureDevice(FakeVideoCaptureDeviceType device_type); 34 explicit FakeVideoCaptureDevice(FakeVideoCaptureDeviceType device_type);
34 ~FakeVideoCaptureDevice() override; 35 ~FakeVideoCaptureDevice() override;
35 36
36 // VideoCaptureDevice implementation. 37 // VideoCaptureDevice implementation.
37 void AllocateAndStart(const VideoCaptureParams& params, 38 void AllocateAndStart(const VideoCaptureParams& params,
38 scoped_ptr<Client> client) override; 39 scoped_ptr<Client> client) override;
39 void StopAndDeAllocate() override; 40 void StopAndDeAllocate() override;
40 41
41 private: 42 private:
42 static const int kFakeCapturePeriodMs = 50; 43 static const int kFakeCapturePeriodMs = 50;
43 44
44 void CaptureUsingOwnBuffers(); 45 void CaptureUsingOwnBuffers(base::TimeTicks expected_execution_time);
45 void CaptureUsingClientBuffers(VideoPixelFormat pixel_format); 46 void CaptureUsingClientBuffers(VideoPixelFormat pixel_format,
46 void BeepAndScheduleNextCapture(const base::Closure& next_capture); 47 base::TimeTicks expected_execution_time);
48 void BeepAndScheduleNextCapture(
49 base::TimeTicks expected_execution_time,
50 const base::Callback<void(base::TimeTicks)>& next_capture);
47 51
48 // |thread_checker_| is used to check that all methods are called in the 52 // |thread_checker_| is used to check that all methods are called in the
49 // correct thread that owns the object. 53 // correct thread that owns the object.
50 base::ThreadChecker thread_checker_; 54 base::ThreadChecker thread_checker_;
51 55
52 const FakeVideoCaptureDeviceType device_type_; 56 const FakeVideoCaptureDeviceType device_type_;
53 57
54 scoped_ptr<VideoCaptureDevice::Client> client_; 58 scoped_ptr<VideoCaptureDevice::Client> client_;
55 // |fake_frame_| is used for capturing on Own Buffers. 59 // |fake_frame_| is used for capturing on Own Buffers.
56 scoped_ptr<uint8[]> fake_frame_; 60 scoped_ptr<uint8[]> fake_frame_;
57 int frame_count_; 61 int frame_count_;
58 VideoCaptureFormat capture_format_; 62 VideoCaptureFormat capture_format_;
59 63
60 // FakeVideoCaptureDevice post tasks to itself for frame construction and 64 // FakeVideoCaptureDevice post tasks to itself for frame construction and
61 // needs to deal with asynchronous StopAndDeallocate(). 65 // needs to deal with asynchronous StopAndDeallocate().
62 base::WeakPtrFactory<FakeVideoCaptureDevice> weak_factory_; 66 base::WeakPtrFactory<FakeVideoCaptureDevice> weak_factory_;
63 67
64 DISALLOW_COPY_AND_ASSIGN(FakeVideoCaptureDevice); 68 DISALLOW_COPY_AND_ASSIGN(FakeVideoCaptureDevice);
65 }; 69 };
66 70
67 } // namespace media 71 } // namespace media
68 72
69 #endif // MEDIA_VIDEO_CAPTURE_FAKE_VIDEO_CAPTURE_DEVICE_H_ 73 #endif // MEDIA_VIDEO_CAPTURE_FAKE_VIDEO_CAPTURE_DEVICE_H_
OLDNEW
« no previous file with comments | « no previous file | media/video/capture/fake_video_capture_device.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698