| // Copyright 2018 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. |
| |
| module cros.mojom; |
| |
| // Encode errors (see |
| // https://cs.chromium.org/chromium/src/media/video/jpeg_encode_accelerator.h) |
| enum EncodeStatus { |
| ENCODE_OK, |
| HW_JPEG_ENCODE_NOT_SUPPORTED, |
| THREAD_CREATION_FAILED, |
| INVALID_ARGUMENT, |
| INACCESSIBLE_OUTPUT_BUFFER, |
| PARSE_IMAGE_FAILED, |
| PLATFORM_FAILURE, |
| }; |
| |
| // GPU process interface exposed to the browser for encoding JPEG images. |
| interface JpegEncodeAccelerator { |
| // Initializes the JPEG encoder. Should be called once per encoder |
| // construction and before using EncodeWithFD(). This call returns true if |
| // initialization is successful. |
| Initialize() => (bool success); |
| |
| // Encodes the given buffer that contains one I420 image. |
| // |input_fd| and |output_fd| are file descriptors of shared memory. |
| // The image is encoded from memory of |input_fd| |
| // with size |input_buffer_size|. The output buffer is associated with |
| // |buffer_id| and the dimension of I420 image is |coded_size_width| and |
| // |coded_size_height|. |
| // |exif_fd| is the shared memory buffer, with |exif_buffer_size| as size, |
| // containing Exif data which will be put onto APP1 segment in the output |
| // JPEG image. |
| // Encoded JPEG image will be put onto memory associated with |output_fd| |
| // with allocated size |output_buffer_size|. |
| // Returns |buffer_id| and |error| in a callback to notify the |
| // encode status. |buffer_id| is the id of |output_buffer| and |status| is the |
| // status code. |encoded_buffer_size| is the actual size of the encoded JPEG. |
| EncodeWithFD(int32 buffer_id, handle input_fd, uint32 input_buffer_size, |
| int32 coded_size_width, int32 coded_size_height, |
| handle exif_fd, uint32 exif_buffer_size, |
| handle output_fd, uint32 output_buffer_size) |
| => (int32 buffer_id, uint32 encoded_buffer_size, EncodeStatus status); |
| }; |