Chromium Code Reviews| 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 // VideoCaptureStream, which is then Start()ed to produce FrameInfos to a | |
| 8 // VideoCaptureStreamClient. In this sense, this API mimics a UserMediaClient. | |
| 9 | |
| 10 module media.mojom; | |
| 11 | |
| 12 import "media/mojo/interfaces/media_types.mojom"; | |
| 13 import "ui/mojo/geometry/geometry.mojom"; | |
| 14 | |
| 15 struct VideoCaptureDeviceInfo { | |
| 16 string device_id; | |
| 17 string name; | |
| 18 // TODO(mcasas): add VideoFacingMode facing_mode; | |
| 19 }; | |
| 20 | |
| 21 struct VideoCaptureOptions { | |
| 22 string device_id; | |
| 23 | |
| 24 // Replicate the used fields of VideoCaptureParams. | |
| 25 mojo.Size capture_size; | |
| 26 double frame_rate; | |
| 27 // TODO(mcasas): add and wire PowerLineFrequency and ResolutionChangePolicy. | |
| 28 }; | |
| 29 | |
| 30 // Information provided to a VideoStreamClient about an available video frame. | |
| 31 struct FrameInfo { | |
| 32 // Shared memory handle to allocated storage for the frame. This handle may | |
| 33 // be mapped by the client for read-only access. | |
| 34 // TODO(mcasas): investigate if sharing this buffer per frame has any impact | |
| 35 // in performance. If so, reinstaurate a sharing-buffer-preamble. | |
| 36 handle<shared_buffer> storage_handle; | |
| 37 // Size in bytes of the allocated storage. | |
| 38 int32 storage_size; | |
| 39 | |
| 40 // Pixel format of the frame data in storage. | |
| 41 media.interfaces.VideoFormat pixel_format; | |
| 42 | |
| 43 // Size of the frame in pixels. This includes pixel data for the whole image; | |
| 44 // i.e. for YUV formats with subsampled chroma planes where the visible | |
| 45 // portion does not line up on a sample boundary, |coded_size| will be rounded | |
| 46 // up appropriately and pixel data will be provided for the odd pixels. | |
| 47 mojo.Size coded_size; | |
| 48 | |
| 49 // Visible rectangle of pixels in the frame. This must be a subrect of | |
| 50 // |coded_rect|. May be odd with respect to the sample boundaries, e.g. for | |
| 51 // formats with subsampled chroma. This is used e.g. for letterboxing. | |
| 52 mojo.Rect visible_rect; | |
| 53 | |
| 54 // A coded version of base::TimeTicks::Now() at the time the frame data was | |
| 55 // generated by its source. For the sake of consistency this must always be | |
| 56 // interpreted using base::TimeTicks::FromInternalValue or some equivalent. | |
| 57 int64 timestamp; | |
| 58 }; | |
| 59 | |
| 60 // The client interface for a VideoCaptureStream. | |
| 61 interface VideoCaptureStreamClient { | |
| 62 // Informs the client that new frame data is available. |info| provides | |
| 63 // details about this individual frame. | |
| 64 OnFrameAvailable(FrameInfo info) => (); | |
| 65 | |
| 66 // An error has ocurred; the capture will in all likelihood be interrupted. | |
|
perkj_chrome
2016/03/07 23:58:27
So to continu the discussion. What is the client s
mcasas
2016/03/08 23:57:28
Yes, you're right. Corrected.
| |
| 67 OnError(string error); | |
| 68 }; | |
| 69 | |
| 70 // The VideoCaptureStream interface abstracts a distinct local source of video | |
| 71 // frame data such as a WebCam. | |
| 72 // TODO(mcasas): Consider extending to desktop capture and web view capture. | |
| 73 interface VideoCaptureStream { | |
| 74 // Starts sending frames to |client|. Must only be called once and must be the | |
| 75 // first call on the Stream. | |
| 76 Start(VideoCaptureStreamClient client); | |
| 77 | |
| 78 // Stops the capture, releasing all associated resources. | |
| 79 Stop(); | |
| 80 }; | |
| 81 | |
| 82 // Primary top-level service interface exposed by the video_capture component. | |
| 83 interface VideoCaptureHandler { | |
| 84 EnumerateDevices() | |
| 85 => (array<VideoCaptureDeviceInfo> devices); | |
| 86 | |
| 87 // TODO(mcasas): Add a method to retrieve the capture capabilities of a given | |
| 88 // |device_id|. | |
| 89 | |
| 90 RequestVideoCaptureStream(VideoCaptureOptions options) | |
| 91 => (VideoCaptureStream? stream); | |
| 92 }; | |
| 93 | |
| OLD | NEW |