blob: e92a05cedf3bfe8b7dc5c8c00b281b747512ab19 [file] [log] [blame]
Yin-Chia Yehb978c382019-10-30 00:22:37 -07001/*
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 Peev4697b642019-11-19 17:11:14 -080023#include "CompositeStream.h"
Yin-Chia Yehb978c382019-10-30 00:22:37 -070024
25namespace android {
26
27using android::hardware::camera2::ICameraDeviceCallbacks;
Emilian Peev4697b642019-11-19 17:11:14 -080028using camera3::CompositeStream;
Yin-Chia Yehb978c382019-10-30 00:22:37 -070029
Emilian Peevb2bc5a42019-11-20 16:02:14 -080030// 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 Yehb978c382019-10-30 00:22:37 -070036class CameraOfflineSessionClient :
Emilian Peevb2bc5a42019-11-20 16:02:14 -080037 public CameraService::BasicClient,
Yin-Chia Yehb978c382019-10-30 00:22:37 -070038 public hardware::camera2::BnCameraOfflineSession
39 // public camera2::FrameProcessorBase::FilteredListener?
40{
41public:
42 CameraOfflineSessionClient(
43 const sp<CameraService>& cameraService,
44 sp<CameraOfflineSessionBase> session,
Emilian Peev4697b642019-11-19 17:11:14 -080045 const KeyedVector<sp<IBinder>, sp<CompositeStream>>& offlineCompositeStreamMap,
Yin-Chia Yehb978c382019-10-30 00:22:37 -070046 const sp<ICameraDeviceCallbacks>& remoteCallback,
47 const String16& clientPackageName,
Emilian Peevb2bc5a42019-11-20 16:02:14 -080048 const std::unique_ptr<String16>& clientFeatureId,
49 const String8& cameraIdStr, int cameraFacing,
Yin-Chia Yehb978c382019-10-30 00:22:37 -070050 int clientPid, uid_t clientUid, int servicePid) :
Emilian Peevb2bc5a42019-11-20 16:02:14 -080051 CameraService::BasicClient(
52 cameraService,
53 IInterface::asBinder(remoteCallback),
54 clientPackageName, clientFeatureId,
55 cameraIdStr, cameraFacing, clientPid, clientUid, servicePid),
Emilian Peev4697b642019-11-19 17:11:14 -080056 mRemoteCallback(remoteCallback), mOfflineSession(session),
57 mCompositeStreamMap(offlineCompositeStreamMap) {}
Yin-Chia Yehb978c382019-10-30 00:22:37 -070058
Emilian Peevb2bc5a42019-11-20 16:02:14 -080059 virtual ~CameraOfflineSessionClient() {}
Yin-Chia Yehb978c382019-10-30 00:22:37 -070060
Emilian Peevb2bc5a42019-11-20 16:02:14 -080061 virtual sp<IBinder> asBinderWrapper() override {
62 return IInterface::asBinder(this);
Yin-Chia Yehb978c382019-10-30 00:22:37 -070063 }
64
Emilian Peevb2bc5a42019-11-20 16:02:14 -080065 virtual binder::Status disconnect() override;
Yin-Chia Yehb978c382019-10-30 00:22:37 -070066
Emilian Peevb2bc5a42019-11-20 16:02:14 -080067 virtual status_t dump(int /*fd*/, const Vector<String16>& /*args*/) override;
Yin-Chia Yehb978c382019-10-30 00:22:37 -070068
Emilian Peevb2bc5a42019-11-20 16:02:14 -080069 virtual status_t dumpClient(int /*fd*/, const Vector<String16>& /*args*/) override;
70
Yin-Chia Yehb978c382019-10-30 00:22:37 -070071 virtual void notifyError(int32_t /*errorCode*/,
Emilian Peevb2bc5a42019-11-20 16:02:14 -080072 const CaptureResultExtras& /*resultExtras*/) override;
Yin-Chia Yehb978c382019-10-30 00:22:37 -070073
Emilian Peevb2bc5a42019-11-20 16:02:14 -080074 virtual status_t initialize(sp<CameraProviderManager> /*manager*/,
75 const String8& /*monitorTags*/) override;
Yin-Chia Yehb978c382019-10-30 00:22:37 -070076
Emilian Peevb2bc5a42019-11-20 16:02:14 -080077 // permissions management
78 virtual status_t startCameraOps() override;
79 virtual status_t finishCameraOps() override;
Yin-Chia Yehb978c382019-10-30 00:22:37 -070080
Emilian Peev4697b642019-11-19 17:11:14 -080081 // 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 Yehb978c382019-10-30 00:22:37 -070086private:
Emilian Peevb2bc5a42019-11-20 16:02:14 -080087
88 const sp<hardware::camera2::ICameraDeviceCallbacks>& getRemoteCallback() {
89 return mRemoteCallback;
90 }
Yin-Chia Yehb978c382019-10-30 00:22:37 -070091
92 sp<hardware::camera2::ICameraDeviceCallbacks> mRemoteCallback;
Yin-Chia Yehb978c382019-10-30 00:22:37 -070093
94 sp<CameraOfflineSessionBase> mOfflineSession;
Emilian Peev4697b642019-11-19 17:11:14 -080095
96 // Offline composite streams
97 KeyedVector<sp<IBinder>, sp<CompositeStream>> mCompositeStreamMap;
Yin-Chia Yehb978c382019-10-30 00:22:37 -070098};
99
100} // namespace android
101
102#endif // ANDROID_SERVERS_CAMERA_PHOTOGRAPHY_CAMERAOFFLINESESSIONCLIENT_H