1 /* 2 * Copyright (C) 2021 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16 #include "dcamera_session_callback.h" 17 18 #include "distributed_camera_constants.h" 19 #include "distributed_hardware_log.h" 20 21 namespace OHOS { 22 namespace DistributedHardware { DCameraSessionCallback(const std::shared_ptr<StateCallback> & callback)23DCameraSessionCallback::DCameraSessionCallback(const std::shared_ptr<StateCallback>& callback) : callback_(callback) 24 { 25 } 26 OnError(int32_t errorCode)27void DCameraSessionCallback::OnError(int32_t errorCode) 28 { 29 DHLOGE("DCameraSessionCallback::OnError, errorCode: %d", errorCode); 30 if (callback_ == nullptr) { 31 DHLOGE("DCameraSessionCallback::OnError StateCallback is null"); 32 return; 33 } 34 35 std::shared_ptr<DCameraEvent> event = std::make_shared<DCameraEvent>(); 36 event->eventType_ = DCAMERA_MESSAGE; 37 event->eventResult_ = DCAMERA_EVENT_CAMERA_ERROR; 38 callback_->OnStateChanged(event); 39 } 40 } // namespace DistributedHardware 41 } // namespace OHOS