Ari Hausman-Cohen | cb11a4d | 2016-09-19 17:57:37 -0700 | [diff] [blame^] | 1 | /* |
| 2 | * Copyright 2016 The Android Open Source Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
| 17 | #include "capture_request.h" |
| 18 | |
| 19 | #include <set> |
| 20 | |
| 21 | namespace default_camera_hal { |
| 22 | |
| 23 | CaptureRequest::CaptureRequest() : CaptureRequest(nullptr) {} |
| 24 | |
| 25 | CaptureRequest::CaptureRequest(const camera3_capture_request_t* request) { |
| 26 | if (!request) { |
| 27 | return; |
| 28 | } |
| 29 | |
| 30 | frame_number = request->frame_number; |
| 31 | |
| 32 | // CameraMetadata makes copies of camera_metadata_t through the |
| 33 | // assignment operator (the constructor taking a camera_metadata_t* |
| 34 | // takes ownership instead). |
| 35 | settings = request->settings; |
| 36 | |
| 37 | // camera3_stream_buffer_t can be default copy constructed, |
| 38 | // as its pointer values are handles, not ownerships. |
| 39 | |
| 40 | // Copy the input buffer. |
| 41 | if (request->input_buffer) { |
| 42 | input_buffer = |
| 43 | std::make_unique<camera3_stream_buffer_t>(*request->input_buffer); |
| 44 | } |
| 45 | |
| 46 | // Safely copy all the output buffers. |
| 47 | uint32_t num_output_buffers = request->num_output_buffers; |
| 48 | if (num_output_buffers < 0 || !request->output_buffers) { |
| 49 | num_output_buffers = 0; |
| 50 | } |
| 51 | output_buffers.insert(output_buffers.end(), |
| 52 | request->output_buffers, |
| 53 | request->output_buffers + num_output_buffers); |
| 54 | } |
| 55 | |
| 56 | } // namespace default_camera_hal |