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