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 module content.mojom; | 5 module content.mojom; |
6 | 6 |
7 import "gpu/ipc/common/sync_token.mojom"; | 7 import "gpu/ipc/common/sync_token.mojom"; |
8 import "media/mojo/interfaces/media_types.mojom"; | 8 import "media/mojo/interfaces/media_types.mojom"; |
9 import "mojo/common/common_custom_types.mojom"; | 9 import "mojo/common/common_custom_types.mojom"; |
10 import "services/video_capture/public/interfaces/video_capture_device_proxy.mojo
m"; | 10 import "services/video_capture/public/interfaces/video_capture_device_proxy.mojo
m"; |
11 import "services/video_capture/public/interfaces/video_capture_format.mojom"; | 11 import "services/video_capture/public/interfaces/video_capture_format.mojom"; |
12 import "ui/gfx/geometry/mojo/geometry.mojom"; | 12 import "ui/gfx/geometry/mojo/geometry.mojom"; |
13 | 13 |
| 14 // This file decribes the communication between a given Renderer Host interface |
| 15 // implementation (VideoCaptureHost) and a remote VideoCaptureObserver. |
| 16 // VideoCaptureHost offers a stateless part (GetDeviceSupportedFormats() and |
| 17 // GetDeviceFormatsInUse()) that can be invoked at any time, and a stateful part |
| 18 // sandwiched between Start() and Stop(). A Client's OnStateChanged() can be |
| 19 // notified any time during the stateful part. The stateful part is composed of |
| 20 // a preamble where a Renderer client sends a command to Start() the capture, |
| 21 // registering itself as the associated remote VideoCaptureObserver. The Host |
| 22 // will then create and pre- share a number of buffers: |
| 23 // |
| 24 // Observer VideoCaptureHost |
| 25 // | ---> StartCapture | |
| 26 // | OnStateChanged(STARTED) <--- | |
| 27 // | OnBufferCreated(1) <--- | |
| 28 // | OnBufferCreated(2) <--- | |
| 29 // = = |
| 30 // and capture will then refer to those preallocated buffers: |
| 31 // | OnBufferReady(1) <--- | |
| 32 // | OnBufferReady(2) <--- | |
| 33 // | ---> ReleaseBuffer(1) | |
| 34 // | OnBufferReady(1) <--- | |
| 35 // | ---> ReleaseBuffer(2) | |
| 36 // | OnBufferReady(2) <--- | |
| 37 // | ---> ReleaseBuffer(1) | |
| 38 // | ... | |
| 39 // = = |
| 40 // Buffers can be reallocated with a larger size, if e.g. resolution changes. |
| 41 // | (resolution change) | |
| 42 // | OnBufferDestroyed(1) <--- | |
| 43 // | OnBufferCreated(3) <--- | |
| 44 // | OnBufferReady(3) <--- | |
| 45 // | ---> ReleaseBuffer(2) | |
| 46 // | OnBufferDestroyed(2) <--- | |
| 47 // | OnBufferCreated(5) <--- | |
| 48 // | OnBufferReady(5) <--- | |
| 49 // = = |
| 50 // In the communication epilogue, the client Stop()s capture, receiving a last |
| 51 // status update: |
| 52 // | ---> StopCapture | |
| 53 // | OnStateChanged(STOPPED) <--- | |
| 54 |
14 struct VideoCaptureParams { | 55 struct VideoCaptureParams { |
15 video_capture.mojom.VideoCaptureFormat requested_format; | 56 video_capture.mojom.VideoCaptureFormat requested_format; |
16 video_capture.mojom.ResolutionChangePolicy resolution_change_policy; | 57 video_capture.mojom.ResolutionChangePolicy resolution_change_policy; |
17 video_capture.mojom.PowerLineFrequency power_line_frequency; | 58 video_capture.mojom.PowerLineFrequency power_line_frequency; |
18 }; | 59 }; |
19 | 60 |
20 struct VideoFrameInfo{ | 61 struct VideoFrameInfo{ |
21 mojo.common.mojom.TimeDelta timestamp; | 62 mojo.common.mojom.TimeDelta timestamp; |
22 mojo.common.mojom.DictionaryValue metadata; | 63 mojo.common.mojom.DictionaryValue metadata; |
23 media.mojom.VideoPixelFormat pixel_format; | 64 media.mojom.VideoPixelFormat pixel_format; |
(...skipping 10 matching lines...) Expand all Loading... |
34 FAILED, | 75 FAILED, |
35 ENDED, | 76 ENDED, |
36 }; | 77 }; |
37 | 78 |
38 // Interface for notifications from Browser/Host back to Renderer/Client. This | 79 // Interface for notifications from Browser/Host back to Renderer/Client. This |
39 // interface is used between VideoCaptureHost.Start() and Stop(). | 80 // interface is used between VideoCaptureHost.Start() and Stop(). |
40 interface VideoCaptureObserver { | 81 interface VideoCaptureObserver { |
41 // Gets notified about a VideoCaptureState update. | 82 // Gets notified about a VideoCaptureState update. |
42 OnStateChanged(VideoCaptureState state); | 83 OnStateChanged(VideoCaptureState state); |
43 | 84 |
| 85 // A new buffer identified by |buffer_id| has been created for video capture. |
| 86 OnBufferCreated(int32 buffer_id, handle<shared_buffer> handle_fd); |
| 87 |
44 // |buffer_id| has video capture data with |info| containing the associated | 88 // |buffer_id| has video capture data with |info| containing the associated |
45 // VideoFrame constituent parts. | 89 // VideoFrame constituent parts. |
46 OnBufferReady(int32 buffer_id, VideoFrameInfo info); | 90 OnBufferReady(int32 buffer_id, VideoFrameInfo info); |
47 | 91 |
48 // |buffer_id| has been released by VideoCaptureHost and must not be used. | 92 // |buffer_id| has been released by VideoCaptureHost and must not be used. |
49 OnBufferDestroyed(int32 buffer_id); | 93 OnBufferDestroyed(int32 buffer_id); |
50 | |
51 // TODO(mcasas): Migrate the rest of the messages, https://crbug.com/651897. | |
52 }; | 94 }; |
53 | 95 |
54 interface VideoCaptureHost { | 96 interface VideoCaptureHost { |
55 // Start the |session_id| session with |params|. The video capture will be | 97 // Start the |session_id| session with |params|. The video capture will be |
56 // identified as |device_id|, a new id picked by the renderer process. | 98 // identified as |device_id|, a new id picked by the renderer process. |
57 // |observer| will be used for notifications. | 99 // |observer| will be used for notifications. |
58 Start(int32 device_id, int32 session_id, VideoCaptureParams params, | 100 Start(int32 device_id, int32 session_id, VideoCaptureParams params, |
59 VideoCaptureObserver observer); | 101 VideoCaptureObserver observer); |
60 | 102 |
61 // Closes the video capture specified by |device_id|. | 103 // Closes the video capture specified by |device_id|. |
(...skipping 15 matching lines...) Expand all Loading... |
77 double consumer_resource_utilization); | 119 double consumer_resource_utilization); |
78 | 120 |
79 // Get the formats supported by a device referenced by |session_id|. | 121 // Get the formats supported by a device referenced by |session_id|. |
80 GetDeviceSupportedFormats(int32 device_id, int32 session_id) | 122 GetDeviceSupportedFormats(int32 device_id, int32 session_id) |
81 => (array<video_capture.mojom.VideoCaptureFormat> formats_supported); | 123 => (array<video_capture.mojom.VideoCaptureFormat> formats_supported); |
82 | 124 |
83 // Get the format(s) in use by a device referenced by |session_id|. | 125 // Get the format(s) in use by a device referenced by |session_id|. |
84 GetDeviceFormatsInUse(int32 device_id, int32 session_id) | 126 GetDeviceFormatsInUse(int32 device_id, int32 session_id) |
85 => (array<video_capture.mojom.VideoCaptureFormat> formats_in_use); | 127 => (array<video_capture.mojom.VideoCaptureFormat> formats_in_use); |
86 }; | 128 }; |
OLD | NEW |