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

Unified Diff: media/capture/interfaces/video_capture.mojom

Issue 1699553002: Mojo Video Capture service in media/capture (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: added missing BUILD deps Created 4 years, 10 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 side-by-side diff with in-line comments
Download patch
Index: media/capture/interfaces/video_capture.mojom
diff --git a/media/capture/interfaces/video_capture.mojom b/media/capture/interfaces/video_capture.mojom
new file mode 100644
index 0000000000000000000000000000000000000000..ece2c0efbe1f5b6f805c4bb2ae3bc337cb3bd162
--- /dev/null
+++ b/media/capture/interfaces/video_capture.mojom
@@ -0,0 +1,119 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// This mojom defines the interface for enumerating Video Capture Devices and
+// selecting one for capturing. Such a VCD is manipulated via creation of a
+// Stream, which is then Start()ed to produce FrameInfos to a StreamCient. In
+// this sense, this API mimics a UserMediaClient.
+
+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.
+
+import "media/mojo/interfaces/media_types.mojom";
+import "ui/mojo/geometry/geometry.mojom";
+
+struct MediaDevicesInfoRequest {
+ 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.
+};
+
+// Copies of third_party/WebKit/public/platform/WebSourceInfo.h.
+enum SourceKind { None, Audio, Video };
+enum VideoFacingMode { None, User, Environment };
+struct WebSourceInfo {
+ string device_id;
+ string label;
+
+ SourceKind kind; // Should always be blink::WebSourceInfo::SourceKindVideo
+
+ VideoFacingMode facing_mode;
+};
+
+struct MediaDevicesInfoReply {
+ 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.
+ array<WebSourceInfo> sources;
+};
+
+struct StreamOptions {
+ 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!
+ string device_id;
+
+ // Replicate the used fields of VideoCaptureParams.
+ mojo.Size capture_size;
+ double frame_rate;
+ // TODO(mcasas): add and wire PowerLineFrequency and ResolutionChangePolicy.
+};
+
+// Information provided to a VideoStreamClient about an available video frame.
+struct FrameInfo {
+ // Shared memory handle to allocated storage for the frame. This handle may
+ // be mapped by the client for read-only access.
+ // TODO(mcasas): investigate if sharing this buffer per frame has ny impact in
+ // performance. If so, reinstaurate a sharing-buffer-preamble.
+ handle<shared_buffer> storage_handle;
+ // Size in bytes of the allocated storage.
+ int32 storage_size;
+
+ // Pixel format of the frame data in storage.
+ media.interfaces.VideoFormat pixel_format;
+
+ // Size of the frame in pixels. This includes pixel data for the whole image;
+ // i.e. for YUV formats with subsampled chroma planes where the visible
+ // portion does not line up on a sample boundary, |coded_size| will be rounded
+ // up appropriately and pixel data will be provided for the odd pixels.
+ mojo.Size coded_size;
+
+ // Visible rectangle of pixels in the frame. This must be a subrect of
+ // |coded_rect|. May be odd with respect to the sample boundaries, e.g. for
+ // formats with subsampled chroma. This is used e.g. for letterboxing.
+ mojo.Rect visible_rect;
+
+ // A coded version of base::TimeTicks::Now() at the time the frame data was
+ // generated by its source. For the sake of consistency this must always be
+ // interpreted using base::TimeTicks::FromInternalValue or some equivalent.
+ int64 timestamp;
+};
+
+// The client interface for a Stream.
+interface StreamClient {
+ // Informs the client that new frame data is available. |info| provides
+ // details about this individual frame.
+ FrameAvailable(FrameInfo info) => ();
+
+ // Some Error has happened; the capture will in all likelihood be interrupted.
+ Error(string error);
+};
+
+// The Stream interface abstracts a distinct local source of video frame data
+// such as a camera device, desktop capture, web view capture.
+interface Stream {
+ // Starts sending frames to |client|. Must only be called once and must be the
+ // first call on the Stream.
+ Start(StreamClient client);
+
+ // Temporarily stops sending frames to the client. The client will not begin
+ // receiving frame data again until Resume is called.
+ Pause();
+
+ // Resumes sending frames to the client.
+ Resume();
+
+ // Stops the capture, releasing all associated resources.
+ Stop();
+};
+
+// The primary top-level service interface exposed by the video_capture
+// component. This is used by a UserMediaClient implementation to get hold of a
+// Stream that can be Start()ed to produce video frames, so in a way, it is a
+// video-only flavour of WebUserMediaClient.
+// TODO(mcasas): Add a method to retrieve the capture capabilities of a given
+// |device_id|.
+interface VideoCaptureHandler {
+ // requestMediaDevices(const WebMediaDevicesRequest&)
+ 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.
+ => (MediaDevicesInfoReply reply);
+
+ // requestUserMedia(const WebUserMediaRequest&)
+ RequestStream(StreamOptions options, string security_origin)
+ => (Stream? stream);
+};
+

Powered by Google App Engine
This is Rietveld 408576698