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_CAPTURE_VIDEO_VIDEO_CAPTURE_BUFFER_TRACKER_H_ | 5 #ifndef MEDIA_CAPTURE_VIDEO_VIDEO_CAPTURE_BUFFER_TRACKER_H_ |
6 #define MEDIA_CAPTURE_VIDEO_VIDEO_CAPTURE_BUFFER_TRACKER_H_ | 6 #define MEDIA_CAPTURE_VIDEO_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/capture/video/video_capture_buffer_handle.h" | 11 #include "media/capture/video/video_capture_buffer_handle.h" |
12 #include "media/capture/video_capture_types.h" | 12 #include "media/capture/video_capture_types.h" |
13 #include "mojo/public/cpp/system/buffer.h" | 13 #include "mojo/public/cpp/system/buffer.h" |
14 | 14 |
15 namespace media { | 15 namespace media { |
16 | 16 |
17 // Keeps track of the state of a given mappable resource. Each | 17 // Keeps track of the state of a given mappable resource. Each |
18 // VideoCaptureBufferTracker carries indication of pixel format and storage | 18 // VideoCaptureBufferTracker carries indication of pixel format and storage |
19 // 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 |
20 // storage. | 20 // storage. |
21 class CAPTURE_EXPORT VideoCaptureBufferTracker { | 21 class CAPTURE_EXPORT VideoCaptureBufferTracker { |
22 public: | 22 public: |
23 VideoCaptureBufferTracker() | 23 VideoCaptureBufferTracker() |
24 : max_pixel_count_(0), | 24 : max_pixel_count_(0), |
25 held_by_producer_(false), | 25 held_by_producer_(false), |
26 consumer_hold_count_(0) {} | 26 consumer_hold_count_(0), |
| 27 frame_feedback_id_(0) {} |
27 virtual bool Init(const gfx::Size& dimensions, | 28 virtual bool Init(const gfx::Size& dimensions, |
28 media::VideoPixelFormat format, | 29 media::VideoPixelFormat format, |
29 media::VideoPixelStorage storage_type, | 30 media::VideoPixelStorage storage_type, |
30 base::Lock* lock) = 0; | 31 base::Lock* lock) = 0; |
31 virtual ~VideoCaptureBufferTracker(){}; | 32 virtual ~VideoCaptureBufferTracker(){}; |
32 | 33 |
33 const gfx::Size& dimensions() const { return dimensions_; } | 34 const gfx::Size& dimensions() const { return dimensions_; } |
34 void set_dimensions(const gfx::Size& dim) { dimensions_ = dim; } | 35 void set_dimensions(const gfx::Size& dim) { dimensions_ = dim; } |
35 size_t max_pixel_count() const { return max_pixel_count_; } | 36 size_t max_pixel_count() const { return max_pixel_count_; } |
36 void set_max_pixel_count(size_t count) { max_pixel_count_ = count; } | 37 void set_max_pixel_count(size_t count) { max_pixel_count_ = count; } |
37 media::VideoPixelFormat pixel_format() const { return pixel_format_; } | 38 media::VideoPixelFormat pixel_format() const { return pixel_format_; } |
38 void set_pixel_format(media::VideoPixelFormat format) { | 39 void set_pixel_format(media::VideoPixelFormat format) { |
39 pixel_format_ = format; | 40 pixel_format_ = format; |
40 } | 41 } |
41 media::VideoPixelStorage storage_type() const { return storage_type_; } | 42 media::VideoPixelStorage storage_type() const { return storage_type_; } |
42 void set_storage_type(media::VideoPixelStorage storage_type) { | 43 void set_storage_type(media::VideoPixelStorage storage_type) { |
43 storage_type_ = storage_type; | 44 storage_type_ = storage_type; |
44 } | 45 } |
45 bool held_by_producer() const { return held_by_producer_; } | 46 bool held_by_producer() const { return held_by_producer_; } |
46 void set_held_by_producer(bool value) { held_by_producer_ = value; } | 47 void set_held_by_producer(bool value) { held_by_producer_ = value; } |
47 int consumer_hold_count() const { return consumer_hold_count_; } | 48 int consumer_hold_count() const { return consumer_hold_count_; } |
48 void set_consumer_hold_count(int value) { consumer_hold_count_ = value; } | 49 void set_consumer_hold_count(int value) { consumer_hold_count_ = value; } |
| 50 void set_frame_feedback_id(int value) { frame_feedback_id_ = value; } |
| 51 int frame_feedback_id() { return frame_feedback_id_; } |
49 | 52 |
50 // Returns a scoped handle to the underlying storage. | 53 // Returns a scoped handle to the underlying storage. |
51 virtual std::unique_ptr<VideoCaptureBufferHandle> GetBufferHandle() = 0; | 54 virtual std::unique_ptr<VideoCaptureBufferHandle> GetBufferHandle() = 0; |
52 | 55 |
53 virtual mojo::ScopedSharedBufferHandle GetHandleForTransit() = 0; | 56 virtual mojo::ScopedSharedBufferHandle GetHandleForTransit() = 0; |
54 | 57 |
55 private: | 58 private: |
56 // |dimensions_| may change as a VideoCaptureBufferTracker is re-used, but | 59 // |dimensions_| may change as a VideoCaptureBufferTracker is re-used, but |
57 // |max_pixel_count_|, |pixel_format_|, and |storage_type_| are set once for | 60 // |max_pixel_count_|, |pixel_format_|, and |storage_type_| are set once for |
58 // the lifetime of a VideoCaptureBufferTracker. | 61 // the lifetime of a VideoCaptureBufferTracker. |
59 gfx::Size dimensions_; | 62 gfx::Size dimensions_; |
60 size_t max_pixel_count_; | 63 size_t max_pixel_count_; |
61 media::VideoPixelFormat pixel_format_; | 64 media::VideoPixelFormat pixel_format_; |
62 media::VideoPixelStorage storage_type_; | 65 media::VideoPixelStorage storage_type_; |
63 | 66 |
64 // Indicates whether this VideoCaptureBufferTracker is currently referenced by | 67 // Indicates whether this VideoCaptureBufferTracker is currently referenced by |
65 // the producer. | 68 // the producer. |
66 bool held_by_producer_; | 69 bool held_by_producer_; |
67 | 70 |
68 // Number of consumer processes which hold this VideoCaptureBufferTracker. | 71 // Number of consumer processes which hold this VideoCaptureBufferTracker. |
69 int consumer_hold_count_; | 72 int consumer_hold_count_; |
| 73 |
| 74 int frame_feedback_id_; |
70 }; | 75 }; |
71 | 76 |
72 } // namespace content | 77 } // namespace content |
73 | 78 |
74 #endif // MEDIA_CAPTURE_VIDEO_VIDEO_CAPTURE_BUFFER_TRACKER_H_ | 79 #endif // MEDIA_CAPTURE_VIDEO_VIDEO_CAPTURE_BUFFER_TRACKER_H_ |
OLD | NEW |