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

Side by Side Diff: content/browser/renderer_host/media/video_capture_buffer_tracker.h

Issue 2343423003: Extract nested and private classes from VideoCaptureBufferPool (Closed)
Patch Set: Merge branch 'master' into BufferPoolRefactor Created 4 years, 3 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
OLDNEW
(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. This is a base class for implementations using different kinds of
19 // 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_|, |pixel_format_|, and |storage_type_| are set once for
62 // the lifetime of a VideoCaptureBufferTracker.
63 gfx::Size dimensions_;
64 size_t max_pixel_count_;
65 media::VideoPixelFormat pixel_format_;
66 media::VideoPixelStorage storage_type_;
67
68 // Indicates whether this VideoCaptureBufferTracker is currently referenced by
69 // the producer.
70 bool held_by_producer_;
71
72 // Number of consumer processes which hold this VideoCaptureBufferTracker.
73 int consumer_hold_count_;
74 };
75
76 } // namespace content
77
78 #endif // CONTENT_BROWSER_RENDERER_HOST_MEDIA_VIDEO_CAPTURE_BUFFER_TRACKER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698