Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 /* Copyright 2014 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 | |
| 6 #ifndef PPAPI_CPP_PRIVATE_IMAGE_CAPTURE_PRIVATE_H_ | |
| 7 #define PPAPI_CPP_PRIVATE_IMAGE_CAPTURE_PRIVATE_H_ | |
| 8 | |
| 9 #include "ppapi/c/private/ppb_image_capture_private.h" | |
| 10 #include "ppapi/cpp/completion_callback.h" | |
| 11 #include "ppapi/cpp/private/image_capture_config_private.h" | |
|
Justin Chuang
2014/08/14 16:33:45
need *capabilities_private.h?
wuchengli
2014/08/15 08:18:01
Done.
| |
| 12 #include "ppapi/cpp/resource.h" | |
| 13 #include "ppapi/cpp/var.h" | |
| 14 | |
| 15 /// @file | |
| 16 /// Defines the <code>ImageCapture_Private</code> interface. Used for | |
| 17 /// acquiring a single still image from a camera source. | |
| 18 namespace pp { | |
| 19 | |
| 20 /// To capture a still image with this class, use the following steps. | |
| 21 /// 1. Get a ImageCapture_Private object by Create(). | |
|
Justin Chuang
2014/08/14 16:33:46
No Create() in C++.
wuchengli
2014/08/15 08:18:01
Done.
| |
| 22 /// 2. Call GetCameraCapabilities to get the supported preview sizes. | |
| 23 /// 3. For optimal performance, set one of the supported preview size as the | |
| 24 /// constraints of getUserMedia. Use the created MediaStreamVideoTrack for | |
| 25 /// camera previews. | |
| 26 /// 4. Set the same preview size and other settings by SetConfig. | |
| 27 /// 5. Call CaptureStillImage to capture a still image. Play the shutter sound | |
| 28 /// in the shutter callback. The image from the preview callback can be used | |
| 29 /// for display. JPEG image will be returned to the JPEG callback. | |
| 30 class ImageCapture_Private { | |
| 31 public: | |
| 32 /// Default constructor for creating an is_null() | |
| 33 /// <code>ImageCapture_Private</code> object. | |
| 34 ImageCapture_Private(); | |
| 35 | |
| 36 /// Creates a ImageCapture_Private resource. | |
|
Justin Chuang
2014/08/14 16:33:45
s/a/an/
wuchengli
2014/08/15 08:18:01
Done.
| |
| 37 /// | |
| 38 /// @param[in] instance A <code>PP_Instance</code> identifying one instance | |
| 39 /// of a module. | |
| 40 /// @param[in] camera_source_id A <code>Var</code> identifying a camera | |
| 41 /// source. The type is string. The ID can be obtained from | |
| 42 /// MediaStreamTrack.getSources() or MediaStreamVideoTrack.id. If a | |
| 43 /// MediaStreamVideoTrack is associated with the same source and the track | |
| 44 /// is closed, this ImageCapture_Private object can still do image capture. | |
| 45 /// @param[in] error_callback A <code>ImageCapture_Private_ErrorCallback | |
| 46 /// </code> callback to indicate the image capture has failed. | |
| 47 /// @param[inout] user_data An opaque pointer that will be passed to the | |
| 48 /// callbacks of ImageCapture_Private. | |
| 49 /// | |
| 50 /// @return A <code>Resource</code> corresponding to a | |
| 51 /// ImageCapture_Private resource if successful, 0 if failed. | |
| 52 ImageCapture_Private(const InstanceHandle& instance, | |
| 53 const Var& camera_source_id, | |
| 54 PPB_ImageCapture_Private_ErrorCallback error_callback, | |
| 55 void* user_data); | |
| 56 | |
| 57 /// The copy constructor for <code>ImageCapture_Private</code>. | |
| 58 /// | |
| 59 /// @param[in] other A reference to a <code>ImageCapture_Private | |
| 60 /// </code>. | |
| 61 ImageCapture_Private(const ImageCapture_Private& other); | |
|
Justin Chuang
2014/08/14 16:33:45
nit: Supporting copy constructor for this class ma
wuchengli
2014/08/15 08:18:01
Removed. I checked and many ppapi cpp classes do n
| |
| 62 | |
| 63 /// Constructs a <code>ImageCapture_Private</code> from a <code> | |
| 64 /// Resource</code>. | |
| 65 /// | |
| 66 /// @param[in] resource A <code>ImageCapture_Private</code> | |
| 67 /// resource. | |
| 68 explicit ImageCapture_Private(const Resource& resource); | |
| 69 | |
| 70 /// A constructor used when you have received a <code>PP_Resource</code> as a | |
| 71 /// return value that has had 1 ref added for you. | |
| 72 /// | |
| 73 /// @param[in] resource A <code>ImageCapture_Private</code> | |
| 74 /// resource. | |
| 75 ImageCapture_Private(PassRef, PP_Resource resource); | |
| 76 | |
| 77 // Destructor. | |
| 78 ~ImageCapture_Private(); | |
| 79 | |
| 80 /// Disconnects from the camera and cancels all pending capture requests. | |
| 81 /// After this returns, no callbacks will be called. If <code> | |
| 82 /// ImageCapture_Private</code> is destroyed and is not closed yet, this | |
| 83 /// function will be automatically called. Calling this more than once has no | |
| 84 /// effect. | |
| 85 /// | |
| 86 /// @param[in] image_capture A <code>Resource</code> corresponding to an | |
| 87 /// image capture resource. | |
|
Justin Chuang
2014/08/14 16:33:45
redundant @param
wuchengli
2014/08/15 08:18:01
Done.
| |
| 88 /// @param[in] callback <code>CompletionCallback</code> to be called upon | |
| 89 /// completion of <code>Close()</code>. | |
| 90 /// | |
| 91 /// @return An int32_t containing a result code from <code>pp_errors.h</code>. | |
| 92 int32_t Close(const CompletionCallback& callback); | |
| 93 | |
| 94 /// Sets the configuration of the image capture. | |
| 95 /// If <code>SetConfig()</code> is not called, default settings will be used. | |
| 96 /// | |
| 97 /// @param[in] image_capture A <code>Resource</code> corresponding to an | |
| 98 /// image capture resource. | |
|
Justin Chuang
2014/08/14 16:33:45
redundant @param
wuchengli
2014/08/15 08:18:01
Done.
| |
| 99 /// @param[in] config A <code>PP_ImageCaptureConfig_Private</code> object. | |
| 100 /// @param[in] callback <code>CompletionCallback</code> to be called upon | |
| 101 /// completion of <code>SetConfig()</code>. | |
| 102 /// | |
| 103 /// @return An int32_t containing a result code from <code>pp_errors.h</code>. | |
| 104 /// Returns <code>PP_ERROR_INPROGRESS</code> if there is a pending call of | |
| 105 /// <code>SetConfig()</code> or <code>CaptureStillImage()</code>. | |
| 106 /// If an error is returned, the configuration will not be changed. | |
| 107 int32_t SetConfig(const ImageCaptureConfig_Private& config, | |
| 108 const CompletionCallback& callback); | |
| 109 | |
| 110 /// Gets the configuration of the image capture. | |
| 111 /// | |
| 112 /// @param[out] config A <code>PP_ImageCaptureConfig_Private</code> for | |
| 113 /// storing the current image capture config on success. Otherwise, the values | |
| 114 /// will not be changed. | |
| 115 /// @param[in] callback <code>CompletionCallback</code> to be called upon | |
| 116 /// completion of <code>GetConfig()</code>. | |
| 117 /// | |
| 118 /// @return An int32_t containing a result code from <code>pp_errors.h</code>. | |
| 119 int32_t GetConfig(ImageCaptureConfig_Private* config, | |
| 120 const CompletionCallback& callback); | |
|
Justin Chuang
2014/08/14 16:33:46
Can replace both arguments with
const Completion
wuchengli
2014/08/15 08:18:01
Done.
| |
| 121 | |
| 122 /// Gets the camera capabilities. | |
| 123 /// | |
| 124 /// The camera capabilities do not change for a given camera source. | |
| 125 /// | |
| 126 /// @param[out] capabilities A <code>CameraCapabilities_Private</code> for | |
| 127 /// storing the image capture capabilities on success. Otherwise, the value | |
| 128 /// will not be changed. | |
| 129 /// @param[in] callback <code>CompletionCallback</code> to be called upon | |
| 130 /// completion of <code>GetCameraCapabilities()</code>. | |
| 131 /// | |
| 132 /// @return An int32_t containing a result code from <code>pp_errors.h</code>. | |
| 133 int32_t GetCameraCapabilities(CameraCapabilities_Private* capabilities, | |
| 134 const CompletionCallback& callback); | |
|
Justin Chuang
2014/08/14 16:33:45
Can replace both arguments with
const Completion
wuchengli
2014/08/15 08:18:01
Done.
| |
| 135 | |
| 136 /// Captures a still JPEG image from the camera. | |
| 137 /// | |
| 138 /// Triggers an asynchronous image capture. The camera will initiate a series | |
| 139 /// of callbacks to the application as the image capture progresses. The | |
| 140 /// callbacks will be invoked in the order of shutter callback, preview | |
| 141 /// callback, and JPEG callback. The shutter callback occurs after the image | |
| 142 /// is captured. This can be used to trigger a sound to let the user know that | |
| 143 /// image has been captured. The preview callback occurs when a scaled, fully | |
| 144 /// processed preview image is available. The JPEG callback occurs when the | |
| 145 /// compressed image is available. If there is an error after the capture is | |
| 146 /// in progress, the error callback passed to <code> | |
| 147 /// ImageCapture_Private.Create()</code> will be invoked. All the callbacks | |
| 148 /// are invoked by the thread that calls this function. | |
| 149 /// | |
| 150 /// The size of the preview image in preview callback is determined by | |
| 151 /// <code>ImageCaptureConfig_Private.SetPreviewSize</code>. The format is | |
| 152 /// decided by the camera and can be got from <code>VideoFrame.GetFormat | |
| 153 /// </code>. The size of the JPEG image is determined by <code> | |
| 154 /// ImageCaptureConfig_Private.SetJpegSize</code>. | |
| 155 /// | |
| 156 /// The camera may need to stop and re-start streaming during image capture. | |
| 157 /// If some MediaStreamVideoTrack are associated with the camera source, they | |
| 158 /// will receive mute and unmute events. The mute event will be received | |
| 159 /// before all the callbacks. The unmute event will be received after all the | |
| 160 /// callbacks. The preview image will not be sent to the video tracks | |
| 161 /// associated with the camera. | |
| 162 /// | |
| 163 /// @param[in] shutter_callback A <code> | |
| 164 /// ImageCapture_Private_ShutterCallback</code> callback to indicate the | |
| 165 /// image has been taken. | |
| 166 /// @param[in] preview_callback A <code> | |
| 167 /// ImageCapture_Private_PreviewCallback</code> callback to return a | |
| 168 /// preview of the captured image. | |
| 169 /// @param[in] jpeg_callback A <code> | |
| 170 /// ImageCapture_Private_JpegCallback</code> callback to return captured | |
| 171 /// JPEG image. | |
| 172 /// @param[out] sequence_id The sequence ID is a unique monotonically | |
| 173 /// increasing value starting from 0, incremented every time a new request | |
| 174 /// like image capture is submitted. | |
| 175 /// | |
| 176 /// @return An int32_t containing a result code from <code>pp_errors.h</code>. | |
| 177 /// PP_OK means the callbacks will be triggered. Other values mean the | |
| 178 /// callbacks will not be triggered. | |
| 179 int32_t CaptureStillImage( | |
| 180 const PPB_ImageCapture_Private_ShutterCallback& shutter_callback, | |
|
Justin Chuang
2014/08/14 16:33:45
No need to use 'const &'
I think this C++ API can
wuchengli
2014/08/15 08:18:01
Done.
| |
| 181 const PPB_ImageCapture_Private_PreviewCallback& preview_callback, | |
| 182 const PPB_ImageCapture_Private_JpegCallback& jpeg_callback, | |
| 183 int64_t* sequence_id); | |
| 184 | |
| 185 /// Determines if a resource is an image capture resource. | |
| 186 /// | |
| 187 /// @param[in] resource The <code>Resource</code> to test. | |
| 188 /// | |
| 189 /// @return True if the given resource is an image capture resource or false | |
| 190 /// otherwise. | |
|
Justin Chuang
2014/08/14 16:33:46
s/True/true/
wuchengli
2014/08/15 08:18:01
Done.
| |
| 191 static bool IsImageCapture(const Resource& resource); | |
| 192 }; | |
| 193 | |
| 194 } // namespace pp | |
| 195 | |
| 196 #endif /* PPAPI_CPP_PRIVATE_IMAGE_CAPTURE_PRIVATE_H_ */ | |
| 197 | |
| OLD | NEW |