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

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

Issue 1090273006: Revert of VideoCapture: add support for GpuMemoryBuffer allocation and lifetime mgmt in VideoCaptureBufferPool (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 8 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 | « media/base/video_capture_types.cc ('k') | 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 "media/video/capture/video_capture_device.h" 18 #include "media/video/capture/video_capture_device.h"
19 19
20 namespace media { 20 namespace media {
21 21
22 class MEDIA_EXPORT FakeVideoCaptureDevice : public VideoCaptureDevice { 22 class MEDIA_EXPORT FakeVideoCaptureDevice : public VideoCaptureDevice {
23 public: 23 public:
24 enum FakeVideoCaptureDeviceType { 24 enum FakeVideoCaptureDeviceType {
25 USING_OWN_BUFFERS, 25 USING_OWN_BUFFERS,
26 USING_OWN_BUFFERS_TRIPLANAR, 26 USING_CLIENT_BUFFERS,
27 USING_CLIENT_BUFFERS_I420, 27 USING_GPU_MEMORY_BUFFERS,
28 USING_CLIENT_BUFFERS_GPU,
29 }; 28 };
30 29
31 static int FakeCapturePeriodMs() { return kFakeCapturePeriodMs; } 30 static int FakeCapturePeriodMs() { return kFakeCapturePeriodMs; }
32 31
33 explicit FakeVideoCaptureDevice(FakeVideoCaptureDeviceType device_type); 32 explicit FakeVideoCaptureDevice(FakeVideoCaptureDeviceType device_type);
34 ~FakeVideoCaptureDevice() override; 33 ~FakeVideoCaptureDevice() override;
35 34
36 // VideoCaptureDevice implementation. 35 // VideoCaptureDevice implementation.
37 void AllocateAndStart(const VideoCaptureParams& params, 36 void AllocateAndStart(const VideoCaptureParams& params,
38 scoped_ptr<Client> client) override; 37 scoped_ptr<Client> client) override;
39 void StopAndDeAllocate() override; 38 void StopAndDeAllocate() override;
40 39
41 private: 40 private:
42 static const int kFakeCapturePeriodMs = 50; 41 static const int kFakeCapturePeriodMs = 50;
43 42
44 void CaptureUsingOwnBuffers(); 43 void CaptureUsingOwnBuffers();
45 void CaptureUsingClientBuffers(VideoPixelFormat pixel_format); 44 void CaptureUsingClientBuffers();
45 void CaptureUsingGpuMemoryBuffers();
46 void BeepAndScheduleNextCapture(const base::Closure& next_capture); 46 void BeepAndScheduleNextCapture(const base::Closure& next_capture);
47 47
48 // |thread_checker_| is used to check that all methods are called in the 48 // |thread_checker_| is used to check that all methods are called in the
49 // correct thread that owns the object. 49 // correct thread that owns the object.
50 base::ThreadChecker thread_checker_; 50 base::ThreadChecker thread_checker_;
51 51
52 const FakeVideoCaptureDeviceType device_type_; 52 const FakeVideoCaptureDeviceType device_type_;
53 53
54 scoped_ptr<VideoCaptureDevice::Client> client_; 54 scoped_ptr<VideoCaptureDevice::Client> client_;
55 // |fake_frame_| is used for capturing on Own Buffers. 55 // |fake_frame_| is used for capturing on Own Buffers.
56 scoped_ptr<uint8[]> fake_frame_; 56 scoped_ptr<uint8[]> fake_frame_;
57 int frame_count_; 57 int frame_count_;
58 VideoCaptureFormat capture_format_; 58 VideoCaptureFormat capture_format_;
59 59
60 // FakeVideoCaptureDevice post tasks to itself for frame construction and 60 // FakeVideoCaptureDevice post tasks to itself for frame construction and
61 // needs to deal with asynchronous StopAndDeallocate(). 61 // needs to deal with asynchronous StopAndDeallocate().
62 base::WeakPtrFactory<FakeVideoCaptureDevice> weak_factory_; 62 base::WeakPtrFactory<FakeVideoCaptureDevice> weak_factory_;
63 63
64 DISALLOW_COPY_AND_ASSIGN(FakeVideoCaptureDevice); 64 DISALLOW_COPY_AND_ASSIGN(FakeVideoCaptureDevice);
65 }; 65 };
66 66
67 } // namespace media 67 } // namespace media
68 68
69 #endif // MEDIA_VIDEO_CAPTURE_FAKE_VIDEO_CAPTURE_DEVICE_H_ 69 #endif // MEDIA_VIDEO_CAPTURE_FAKE_VIDEO_CAPTURE_DEVICE_H_
OLDNEW
« no previous file with comments | « media/base/video_capture_types.cc ('k') | media/video/capture/fake_video_capture_device.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698