| 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 // This mojom defines the interface for enumerating Video Capture Devices and |
| 6 // selecting one for capturing. Such a VCD is manipulated via creation of a |
| 7 // Stream, which is then Start()ed to produce FrameInfos to a StreamCient. In |
| 8 // this sense, this API mimics a UserMediaClient. |
| 9 |
| 10 module video_capture.mojom; |
| 11 |
| 12 import "media/mojo/interfaces/media_types.mojom"; |
| 13 import "ui/mojo/geometry/geometry.mojom"; |
| 14 |
| 15 struct MediaDevicesInfoRequest { |
| 16 int32 request_id; |
| 17 }; |
| 18 |
| 19 // Copies of third_party/WebKit/public/platform/WebSourceInfo.h. |
| 20 enum SourceKind { None, Audio, Video }; |
| 21 enum VideoFacingMode { None, User, Environment }; |
| 22 struct WebSourceInfo { |
| 23 string device_id; |
| 24 string label; |
| 25 |
| 26 SourceKind kind; // Should always be blink::WebSourceInfo::SourceKindVideo |
| 27 |
| 28 VideoFacingMode facing_mode; |
| 29 }; |
| 30 |
| 31 struct MediaDevicesInfoReply { |
| 32 int32 request_id; |
| 33 array<WebSourceInfo> sources; |
| 34 }; |
| 35 |
| 36 struct StreamOptions { |
| 37 int32 request_id; |
| 38 string device_id; |
| 39 |
| 40 // Replicate the used fields of VideoCaptureParams. |
| 41 mojo.Size capture_size; |
| 42 double frame_rate; |
| 43 // TODO(mcasas): add and wire PowerLineFrequency and ResolutionChangePolicy. |
| 44 }; |
| 45 |
| 46 // Information provided to a VideoStreamClient about an available video frame. |
| 47 struct FrameInfo { |
| 48 // The frame buffer in which this frame's pixel data can be found. |
| 49 int32 buffer_id; |
| 50 |
| 51 // Shared memory handle to allocated storage for the frame. This handle may |
| 52 // be mapped by the client for read-only access. |
| 53 // TODO(mcasas): investigate if sharing this buffer per frame has ny impact in |
| 54 // performance. If so, reinstaurate a sharing-buffer-preamble. |
| 55 handle<shared_buffer> storage_handle; |
| 56 // Size in bytes of the allocated storage. |
| 57 int32 storage_size; |
| 58 |
| 59 // Pixel format of the frame data in storage. |
| 60 media.interfaces.VideoFormat pixel_format; |
| 61 |
| 62 // Size of the frame in pixels. This includes pixel data for the whole image; |
| 63 // i.e. for YUV formats with subsampled chroma planes where the visible |
| 64 // portion does not line up on a sample boundary, |coded_size| will be rounded |
| 65 // up appropriately and pixel data will be provided for the odd pixels. |
| 66 mojo.Size coded_size; |
| 67 |
| 68 // Visible rectangle of pixels in the frame. This must be a subrect of |
| 69 // |coded_rect|. May be odd with respect to the sample boundaries, e.g. for |
| 70 // formats with subsampled chroma. This is used e.g. for letterboxing. |
| 71 mojo.Rect visible_rect; |
| 72 |
| 73 // A coded version of base::TimeTicks::Now() at the time the frame data was |
| 74 // generated by its source. For the sake of consistency this must always be |
| 75 // interpreted using base::TimeTicks::FromInternalValue or some equivalent. |
| 76 int64 timestamp; |
| 77 }; |
| 78 |
| 79 // The client interface for a Stream. |
| 80 interface StreamClient { |
| 81 // Informs the client that new frame data is available. |info| provides |
| 82 // details about this individual frame. |
| 83 FrameAvailable(FrameInfo info) => (); |
| 84 |
| 85 // Some Error has happened; the capture will in all likelihood be interrupted. |
| 86 Error(string error); |
| 87 }; |
| 88 |
| 89 // The Stream interface abstracts a distinct local source of video frame data |
| 90 // such as a camera device, desktop capture, web view capture. |
| 91 interface Stream { |
| 92 // Starts sending frames to |client|. Must only be called once and must be the |
| 93 // first call on the Stream. |
| 94 Start(StreamClient client); |
| 95 |
| 96 // Temporarily stops sending frames to the client. The client will not begin |
| 97 // receiving frame data again until Resume is called. |
| 98 Pause(); |
| 99 |
| 100 // Resumes sending frames to the client. |
| 101 Resume(); |
| 102 |
| 103 // Stops the capture, releasing all associated resources. |
| 104 Stop(); |
| 105 }; |
| 106 |
| 107 // The primary top-level service interface exposed by the video_capture |
| 108 // component. This is used by a UserMediaClient implementation to get hold of a |
| 109 // Stream that can be Start()ed to produce video frames, so in a way, it is a |
| 110 // video-only flavour of WebUserMediaClient. |
| 111 interface VideoCaptureHandler { |
| 112 // requestMediaDevices(const WebMediaDevicesRequest&) |
| 113 RequestMediaDevices(MediaDevicesInfoRequest request) |
| 114 => (MediaDevicesInfoReply reply); |
| 115 |
| 116 // requestUserMedia(const WebUserMediaRequest&) |
| 117 RequestStream(StreamOptions options, string security_origin) |
| 118 => (Stream? stream); |
| 119 }; |
| 120 |
| OLD | NEW |