OLD | NEW |
---|---|
(Empty) | |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 #ifndef CONTENT_BROWSER_RENDERER_HOST_MEDIA_VIDEO_CAPTURE_BUFFER_TRACKER_H_ | |
6 #define CONTENT_BROWSER_RENDERER_HOST_MEDIA_VIDEO_CAPTURE_BUFFER_TRACKER_H_ | |
7 | |
8 #include <memory> | |
9 | |
10 #include "base/synchronization/lock.h" | |
11 #include "content/browser/renderer_host/media/video_capture_buffer_handle.h" | |
12 #include "media/base/video_capture_types.h" | |
13 | |
14 namespace content { | |
15 | |
16 // Keeps track of the state of a given mappable resource. Each | |
17 // VideoCaptureBufferTracker carries indication of pixel format and storage | |
18 // type. | |
19 // This is a base class for implementations using different kinds of storage. | |
20 class VideoCaptureBufferTracker { | |
21 public: | |
22 VideoCaptureBufferTracker() | |
23 : max_pixel_count_(0), | |
24 held_by_producer_(false), | |
25 consumer_hold_count_(0) {} | |
26 virtual bool Init(const gfx::Size& dimensions, | |
27 media::VideoPixelFormat format, | |
28 media::VideoPixelStorage storage_type, | |
29 base::Lock* lock) = 0; | |
30 virtual ~VideoCaptureBufferTracker(){}; | |
31 | |
32 const gfx::Size& dimensions() const { return dimensions_; } | |
33 void set_dimensions(const gfx::Size& dim) { dimensions_ = dim; } | |
34 size_t max_pixel_count() const { return max_pixel_count_; } | |
35 void set_max_pixel_count(size_t count) { max_pixel_count_ = count; } | |
36 media::VideoPixelFormat pixel_format() const { return pixel_format_; } | |
37 void set_pixel_format(media::VideoPixelFormat format) { | |
38 pixel_format_ = format; | |
39 } | |
40 media::VideoPixelStorage storage_type() const { return storage_type_; } | |
41 void set_storage_type(media::VideoPixelStorage storage_type) { | |
42 storage_type_ = storage_type; | |
43 } | |
44 bool held_by_producer() const { return held_by_producer_; } | |
45 void set_held_by_producer(bool value) { held_by_producer_ = value; } | |
46 int consumer_hold_count() const { return consumer_hold_count_; } | |
47 void set_consumer_hold_count(int value) { consumer_hold_count_ = value; } | |
48 | |
49 // Returns a handle to the underlying storage, be that a block of Shared | |
50 // Memory, or a GpuMemoryBuffer. | |
51 virtual std::unique_ptr<VideoCaptureBufferHandle> GetBufferHandle() = 0; | |
52 | |
53 virtual bool ShareToProcess(base::ProcessHandle process_handle, | |
54 base::SharedMemoryHandle* new_handle) = 0; | |
55 virtual bool ShareToProcess2(int plane, | |
56 base::ProcessHandle process_handle, | |
57 gfx::GpuMemoryBufferHandle* new_handle) = 0; | |
58 | |
59 private: | |
60 // |dimensions_| may change as a VideoCaptureBufferTracker is re-used, but | |
61 // |max_pixel_count_|, | |
62 // |pixel_format_|, and |storage_type_| are set once for the lifetime of a | |
mcasas
2016/09/20 00:51:08
nit: Reflow these comments.
chfremer
2016/09/20 18:43:10
Done.
| |
63 // VideoCaptureBufferTracker. | |
64 gfx::Size dimensions_; | |
65 size_t max_pixel_count_; | |
66 media::VideoPixelFormat pixel_format_; | |
67 media::VideoPixelStorage storage_type_; | |
68 | |
69 // Indicates whether this VideoCaptureBufferTracker is currently referenced by | |
70 // the producer. | |
71 bool held_by_producer_; | |
72 | |
73 // Number of consumer processes which hold this VideoCaptureBufferTracker. | |
74 int consumer_hold_count_; | |
75 }; | |
76 | |
77 } // namespace content | |
78 | |
79 #endif // CONTENT_BROWSER_RENDERER_HOST_MEDIA_VIDEO_CAPTURE_BUFFER_TRACKER_H_ | |
OLD | NEW |