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 namespace default_camera_hal { 20 CaptureRequest()21CaptureRequest::CaptureRequest() : CaptureRequest(nullptr) {} 22 CaptureRequest(const camera3_capture_request_t * request)23CaptureRequest::CaptureRequest(const camera3_capture_request_t* request) { 24 if (!request) { 25 return; 26 } 27 28 frame_number = request->frame_number; 29 30 // CameraMetadata makes copies of camera_metadata_t through the 31 // assignment operator (the constructor taking a camera_metadata_t* 32 // takes ownership instead). 33 settings = request->settings; 34 35 // camera3_stream_buffer_t can be default copy constructed, 36 // as its pointer values are handles, not ownerships. 37 38 // Copy the input buffer. 39 if (request->input_buffer) { 40 input_buffer = 41 std::make_unique<camera3_stream_buffer_t>(*request->input_buffer); 42 } 43 44 // Safely copy all the output buffers. 45 uint32_t num_output_buffers = request->num_output_buffers; 46 if (num_output_buffers < 0 || !request->output_buffers) { 47 num_output_buffers = 0; 48 } 49 output_buffers.insert(output_buffers.end(), 50 request->output_buffers, 51 request->output_buffers + num_output_buffers); 52 } 53 54 } // namespace default_camera_hal 55