OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 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 | 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 #ifndef MEDIA_VIDEO_CAPTURE_VIDEO_CAPTURE_BUFFER_TRACKER_H_ | 5 #ifndef MEDIA_VIDEO_CAPTURE_VIDEO_CAPTURE_BUFFER_TRACKER_H_ |
6 #define MEDIA_VIDEO_CAPTURE_VIDEO_CAPTURE_BUFFER_TRACKER_H_ | 6 #define MEDIA_VIDEO_CAPTURE_VIDEO_CAPTURE_BUFFER_TRACKER_H_ |
7 | 7 |
8 #include <memory> | 8 #include <memory> |
9 | 9 |
10 #include "base/synchronization/lock.h" | 10 #include "base/synchronization/lock.h" |
11 #include "media/base/video_capture_types.h" | 11 #include "media/base/video_capture_types.h" |
12 #include "media/capture/video/video_capture_buffer_handle.h" | 12 #include "media/capture/video/video_capture_buffer_handle.h" |
| 13 #include "mojo/public/cpp/system/buffer.h" |
13 | 14 |
14 namespace media { | 15 namespace media { |
15 | 16 |
16 // Keeps track of the state of a given mappable resource. Each | 17 // Keeps track of the state of a given mappable resource. Each |
17 // VideoCaptureBufferTracker carries indication of pixel format and storage | 18 // VideoCaptureBufferTracker carries indication of pixel format and storage |
18 // type. This is a base class for implementations using different kinds of | 19 // type. This is a base class for implementations using different kinds of |
19 // storage. | 20 // storage. |
20 class CAPTURE_EXPORT VideoCaptureBufferTracker { | 21 class CAPTURE_EXPORT VideoCaptureBufferTracker { |
21 public: | 22 public: |
22 VideoCaptureBufferTracker() | 23 VideoCaptureBufferTracker() |
(...skipping 16 matching lines...) Expand all Loading... |
39 } | 40 } |
40 media::VideoPixelStorage storage_type() const { return storage_type_; } | 41 media::VideoPixelStorage storage_type() const { return storage_type_; } |
41 void set_storage_type(media::VideoPixelStorage storage_type) { | 42 void set_storage_type(media::VideoPixelStorage storage_type) { |
42 storage_type_ = storage_type; | 43 storage_type_ = storage_type; |
43 } | 44 } |
44 bool held_by_producer() const { return held_by_producer_; } | 45 bool held_by_producer() const { return held_by_producer_; } |
45 void set_held_by_producer(bool value) { held_by_producer_ = value; } | 46 void set_held_by_producer(bool value) { held_by_producer_ = value; } |
46 int consumer_hold_count() const { return consumer_hold_count_; } | 47 int consumer_hold_count() const { return consumer_hold_count_; } |
47 void set_consumer_hold_count(int value) { consumer_hold_count_ = value; } | 48 void set_consumer_hold_count(int value) { consumer_hold_count_ = value; } |
48 | 49 |
49 // Returns a handle to the underlying storage, be that a block of Shared | 50 // Returns a scoped handle to the underlying storage. |
50 // Memory, or a GpuMemoryBuffer. | |
51 virtual std::unique_ptr<VideoCaptureBufferHandle> GetBufferHandle() = 0; | 51 virtual std::unique_ptr<VideoCaptureBufferHandle> GetBufferHandle() = 0; |
52 | 52 |
53 virtual bool ShareToProcess(base::ProcessHandle process_handle, | 53 virtual mojo::ScopedSharedBufferHandle GetHandleForTransit() = 0; |
54 base::SharedMemoryHandle* new_handle) = 0; | |
55 | 54 |
56 private: | 55 private: |
57 // |dimensions_| may change as a VideoCaptureBufferTracker is re-used, but | 56 // |dimensions_| may change as a VideoCaptureBufferTracker is re-used, but |
58 // |max_pixel_count_|, |pixel_format_|, and |storage_type_| are set once for | 57 // |max_pixel_count_|, |pixel_format_|, and |storage_type_| are set once for |
59 // the lifetime of a VideoCaptureBufferTracker. | 58 // the lifetime of a VideoCaptureBufferTracker. |
60 gfx::Size dimensions_; | 59 gfx::Size dimensions_; |
61 size_t max_pixel_count_; | 60 size_t max_pixel_count_; |
62 media::VideoPixelFormat pixel_format_; | 61 media::VideoPixelFormat pixel_format_; |
63 media::VideoPixelStorage storage_type_; | 62 media::VideoPixelStorage storage_type_; |
64 | 63 |
65 // Indicates whether this VideoCaptureBufferTracker is currently referenced by | 64 // Indicates whether this VideoCaptureBufferTracker is currently referenced by |
66 // the producer. | 65 // the producer. |
67 bool held_by_producer_; | 66 bool held_by_producer_; |
68 | 67 |
69 // Number of consumer processes which hold this VideoCaptureBufferTracker. | 68 // Number of consumer processes which hold this VideoCaptureBufferTracker. |
70 int consumer_hold_count_; | 69 int consumer_hold_count_; |
71 }; | 70 }; |
72 | 71 |
73 } // namespace content | 72 } // namespace content |
74 | 73 |
75 #endif // MEDIA_VIDEO_CAPTURE_VIDEO_CAPTURE_BUFFER_TRACKER_H_ | 74 #endif // MEDIA_VIDEO_CAPTURE_VIDEO_CAPTURE_BUFFER_TRACKER_H_ |
OLD | NEW |