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 media.video_capture; | |
Ken Rockot(use gerrit already)
2016/03/02 02:52:08
We shouldn't nest namespaces more than necessary,
mcasas
2016/03/02 19:53:50
Done.
| |
11 | |
12 import "media/mojo/interfaces/media_types.mojom"; | |
13 import "ui/mojo/geometry/geometry.mojom"; | |
14 | |
15 struct MediaDevicesInfoRequest { | |
16 int32 request_id; | |
Ken Rockot(use gerrit already)
2016/03/02 02:52:08
Shouldn't be necessary, in fact this struct should
mcasas
2016/03/02 19:53:51
Done.
| |
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; | |
Ken Rockot(use gerrit already)
2016/03/02 02:52:07
Shouldn't be necessary, in fact this struct should
mcasas
2016/03/02 19:53:50
Done.
| |
33 array<WebSourceInfo> sources; | |
34 }; | |
35 | |
36 struct StreamOptions { | |
37 int32 request_id; | |
Ken Rockot(use gerrit already)
2016/03/02 02:52:08
I don't think this is used?
mcasas
2016/03/02 19:53:51
Gone!
| |
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 // Shared memory handle to allocated storage for the frame. This handle may | |
49 // be mapped by the client for read-only access. | |
50 // TODO(mcasas): investigate if sharing this buffer per frame has ny impact in | |
51 // performance. If so, reinstaurate a sharing-buffer-preamble. | |
52 handle<shared_buffer> storage_handle; | |
53 // Size in bytes of the allocated storage. | |
54 int32 storage_size; | |
55 | |
56 // Pixel format of the frame data in storage. | |
57 media.interfaces.VideoFormat pixel_format; | |
58 | |
59 // Size of the frame in pixels. This includes pixel data for the whole image; | |
60 // i.e. for YUV formats with subsampled chroma planes where the visible | |
61 // portion does not line up on a sample boundary, |coded_size| will be rounded | |
62 // up appropriately and pixel data will be provided for the odd pixels. | |
63 mojo.Size coded_size; | |
64 | |
65 // Visible rectangle of pixels in the frame. This must be a subrect of | |
66 // |coded_rect|. May be odd with respect to the sample boundaries, e.g. for | |
67 // formats with subsampled chroma. This is used e.g. for letterboxing. | |
68 mojo.Rect visible_rect; | |
69 | |
70 // A coded version of base::TimeTicks::Now() at the time the frame data was | |
71 // generated by its source. For the sake of consistency this must always be | |
72 // interpreted using base::TimeTicks::FromInternalValue or some equivalent. | |
73 int64 timestamp; | |
74 }; | |
75 | |
76 // The client interface for a Stream. | |
77 interface StreamClient { | |
78 // Informs the client that new frame data is available. |info| provides | |
79 // details about this individual frame. | |
80 FrameAvailable(FrameInfo info) => (); | |
81 | |
82 // Some Error has happened; the capture will in all likelihood be interrupted. | |
83 Error(string error); | |
84 }; | |
85 | |
86 // The Stream interface abstracts a distinct local source of video frame data | |
87 // such as a camera device, desktop capture, web view capture. | |
88 interface Stream { | |
89 // Starts sending frames to |client|. Must only be called once and must be the | |
90 // first call on the Stream. | |
91 Start(StreamClient client); | |
92 | |
93 // Temporarily stops sending frames to the client. The client will not begin | |
94 // receiving frame data again until Resume is called. | |
95 Pause(); | |
96 | |
97 // Resumes sending frames to the client. | |
98 Resume(); | |
99 | |
100 // Stops the capture, releasing all associated resources. | |
101 Stop(); | |
102 }; | |
103 | |
104 // The primary top-level service interface exposed by the video_capture | |
105 // component. This is used by a UserMediaClient implementation to get hold of a | |
106 // Stream that can be Start()ed to produce video frames, so in a way, it is a | |
107 // video-only flavour of WebUserMediaClient. | |
108 // TODO(mcasas): Add a method to retrieve the capture capabilities of a given | |
109 // |device_id|. | |
110 interface VideoCaptureHandler { | |
111 // requestMediaDevices(const WebMediaDevicesRequest&) | |
112 RequestMediaDevices(MediaDevicesInfoRequest request) | |
Ken Rockot(use gerrit already)
2016/03/02 02:52:08
This should just be:
RequestMediaDevices() => (
mcasas
2016/03/02 19:53:50
Done.
| |
113 => (MediaDevicesInfoReply reply); | |
114 | |
115 // requestUserMedia(const WebUserMediaRequest&) | |
116 RequestStream(StreamOptions options, string security_origin) | |
117 => (Stream? stream); | |
118 }; | |
119 | |
OLD | NEW |