Yin-Chia Yeh | b978c38 | 2019-10-30 00:22:37 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2019 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 | #ifndef ANDROID_SERVERS_CAMERA_PHOTOGRAPHY_CAMERAOFFLINESESSIONCLIENT_H |
| 18 | #define ANDROID_SERVERS_CAMERA_PHOTOGRAPHY_CAMERAOFFLINESESSIONCLIENT_H |
| 19 | |
| 20 | #include <android/hardware/camera2/BnCameraOfflineSession.h> |
| 21 | #include <android/hardware/camera2/ICameraDeviceCallbacks.h> |
| 22 | #include "CameraService.h" |
| 23 | |
| 24 | namespace android { |
| 25 | |
| 26 | using android::hardware::camera2::ICameraDeviceCallbacks; |
| 27 | |
Emilian Peev | b2bc5a4 | 2019-11-20 16:02:14 -0800 | [diff] [blame^] | 28 | // Client for offline session. Note that offline session client does not affect camera service's |
| 29 | // client arbitration logic. It is camera HAL's decision to decide whether a normal camera |
| 30 | // client is conflicting with existing offline client(s). |
| 31 | // The other distinctive difference between offline clients and normal clients is that normal |
| 32 | // clients are created through ICameraService binder calls, while the offline session client |
| 33 | // is created through ICameraDeviceUser::switchToOffline call. |
Yin-Chia Yeh | b978c38 | 2019-10-30 00:22:37 -0700 | [diff] [blame] | 34 | class CameraOfflineSessionClient : |
Emilian Peev | b2bc5a4 | 2019-11-20 16:02:14 -0800 | [diff] [blame^] | 35 | public CameraService::BasicClient, |
Yin-Chia Yeh | b978c38 | 2019-10-30 00:22:37 -0700 | [diff] [blame] | 36 | public hardware::camera2::BnCameraOfflineSession |
| 37 | // public camera2::FrameProcessorBase::FilteredListener? |
| 38 | { |
| 39 | public: |
| 40 | CameraOfflineSessionClient( |
| 41 | const sp<CameraService>& cameraService, |
| 42 | sp<CameraOfflineSessionBase> session, |
| 43 | const sp<ICameraDeviceCallbacks>& remoteCallback, |
| 44 | const String16& clientPackageName, |
Emilian Peev | b2bc5a4 | 2019-11-20 16:02:14 -0800 | [diff] [blame^] | 45 | const std::unique_ptr<String16>& clientFeatureId, |
| 46 | const String8& cameraIdStr, int cameraFacing, |
Yin-Chia Yeh | b978c38 | 2019-10-30 00:22:37 -0700 | [diff] [blame] | 47 | int clientPid, uid_t clientUid, int servicePid) : |
Emilian Peev | b2bc5a4 | 2019-11-20 16:02:14 -0800 | [diff] [blame^] | 48 | CameraService::BasicClient( |
| 49 | cameraService, |
| 50 | IInterface::asBinder(remoteCallback), |
| 51 | clientPackageName, clientFeatureId, |
| 52 | cameraIdStr, cameraFacing, clientPid, clientUid, servicePid), |
| 53 | mRemoteCallback(remoteCallback), mOfflineSession(session) {} |
Yin-Chia Yeh | b978c38 | 2019-10-30 00:22:37 -0700 | [diff] [blame] | 54 | |
Emilian Peev | b2bc5a4 | 2019-11-20 16:02:14 -0800 | [diff] [blame^] | 55 | virtual ~CameraOfflineSessionClient() {} |
Yin-Chia Yeh | b978c38 | 2019-10-30 00:22:37 -0700 | [diff] [blame] | 56 | |
Emilian Peev | b2bc5a4 | 2019-11-20 16:02:14 -0800 | [diff] [blame^] | 57 | virtual sp<IBinder> asBinderWrapper() override { |
| 58 | return IInterface::asBinder(this); |
Yin-Chia Yeh | b978c38 | 2019-10-30 00:22:37 -0700 | [diff] [blame] | 59 | } |
| 60 | |
Emilian Peev | b2bc5a4 | 2019-11-20 16:02:14 -0800 | [diff] [blame^] | 61 | virtual binder::Status disconnect() override; |
Yin-Chia Yeh | b978c38 | 2019-10-30 00:22:37 -0700 | [diff] [blame] | 62 | |
Emilian Peev | b2bc5a4 | 2019-11-20 16:02:14 -0800 | [diff] [blame^] | 63 | virtual status_t dump(int /*fd*/, const Vector<String16>& /*args*/) override; |
Yin-Chia Yeh | b978c38 | 2019-10-30 00:22:37 -0700 | [diff] [blame] | 64 | |
Emilian Peev | b2bc5a4 | 2019-11-20 16:02:14 -0800 | [diff] [blame^] | 65 | virtual status_t dumpClient(int /*fd*/, const Vector<String16>& /*args*/) override; |
| 66 | |
Yin-Chia Yeh | b978c38 | 2019-10-30 00:22:37 -0700 | [diff] [blame] | 67 | virtual void notifyError(int32_t /*errorCode*/, |
Emilian Peev | b2bc5a4 | 2019-11-20 16:02:14 -0800 | [diff] [blame^] | 68 | const CaptureResultExtras& /*resultExtras*/) override; |
Yin-Chia Yeh | b978c38 | 2019-10-30 00:22:37 -0700 | [diff] [blame] | 69 | |
Emilian Peev | b2bc5a4 | 2019-11-20 16:02:14 -0800 | [diff] [blame^] | 70 | virtual status_t initialize(sp<CameraProviderManager> /*manager*/, |
| 71 | const String8& /*monitorTags*/) override; |
Yin-Chia Yeh | b978c38 | 2019-10-30 00:22:37 -0700 | [diff] [blame] | 72 | |
Emilian Peev | b2bc5a4 | 2019-11-20 16:02:14 -0800 | [diff] [blame^] | 73 | // permissions management |
| 74 | virtual status_t startCameraOps() override; |
| 75 | virtual status_t finishCameraOps() override; |
Yin-Chia Yeh | b978c38 | 2019-10-30 00:22:37 -0700 | [diff] [blame] | 76 | |
Yin-Chia Yeh | b978c38 | 2019-10-30 00:22:37 -0700 | [diff] [blame] | 77 | private: |
Emilian Peev | b2bc5a4 | 2019-11-20 16:02:14 -0800 | [diff] [blame^] | 78 | |
| 79 | const sp<hardware::camera2::ICameraDeviceCallbacks>& getRemoteCallback() { |
| 80 | return mRemoteCallback; |
| 81 | } |
Yin-Chia Yeh | b978c38 | 2019-10-30 00:22:37 -0700 | [diff] [blame] | 82 | |
| 83 | sp<hardware::camera2::ICameraDeviceCallbacks> mRemoteCallback; |
Yin-Chia Yeh | b978c38 | 2019-10-30 00:22:37 -0700 | [diff] [blame] | 84 | |
| 85 | sp<CameraOfflineSessionBase> mOfflineSession; |
| 86 | }; |
| 87 | |
| 88 | } // namespace android |
| 89 | |
| 90 | #endif // ANDROID_SERVERS_CAMERA_PHOTOGRAPHY_CAMERAOFFLINESESSIONCLIENT_H |