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_input_callback.h"
17
18 #include "distributed_camera_constants.h"
19 #include "distributed_hardware_log.h"
20
21 namespace OHOS {
22 namespace DistributedHardware {
DCameraInputCallback(const std::shared_ptr<StateCallback> & callback)23 DCameraInputCallback::DCameraInputCallback(const std::shared_ptr<StateCallback>& callback) : callback_(callback)
24 {
25 }
26
OnError(const int32_t errorType,const int32_t errorMsg) const27 void DCameraInputCallback::OnError(const int32_t errorType, const int32_t errorMsg) const
28 {
29 DHLOGE("DCameraInputCallback::OnError, errorType: %d, errorMsg: %d", errorType, errorMsg);
30 if (callback_ == nullptr) {
31 DHLOGE("DCameraInputCallback::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