3 ** Copyright 2013, The Android Open Source Project
5 ** Licensed under the Apache License, Version 2.0 (the "License");
6 ** you may not use this file except in compliance with the License.
7 ** You may obtain a copy of the License at
9 ** http://www.apache.org/licenses/LICENSE-2.0
11 ** Unless required by applicable law or agreed to in writing, software
12 ** distributed under the License is distributed on an "AS IS" BASIS,
13 ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 ** See the License for the specific language governing permissions and
15 ** limitations under the License.
18 //#define LOG_NDEBUG 0
19 #define LOG_TAG "IProCameraCallbacks"
20 #include <utils/Log.h>
22 #include <sys/types.h>
24 #include <binder/Parcel.h>
25 #include <gui/IGraphicBufferProducer.h>
26 #include <gui/Surface.h>
27 #include <utils/Mutex.h>
29 #include <camera/IProCameraCallbacks.h>
31 #include "camera/CameraMetadata.h"
36 NOTIFY_CALLBACK = IBinder::FIRST_CALL_TRANSACTION,
41 class BpProCameraCallbacks: public BpInterface<IProCameraCallbacks>
44 BpProCameraCallbacks(const sp<IBinder>& impl)
45 : BpInterface<IProCameraCallbacks>(impl)
49 // generic callback from camera service to app
50 void notifyCallback(int32_t msgType, int32_t ext1, int32_t ext2)
52 ALOGV("notifyCallback");
54 data.writeInterfaceToken(IProCameraCallbacks::getInterfaceDescriptor());
55 data.writeInt32(msgType);
56 data.writeInt32(ext1);
57 data.writeInt32(ext2);
58 remote()->transact(NOTIFY_CALLBACK, data, &reply, IBinder::FLAG_ONEWAY);
61 void onLockStatusChanged(LockStatus newLockStatus) {
62 ALOGV("onLockStatusChanged");
64 data.writeInterfaceToken(IProCameraCallbacks::getInterfaceDescriptor());
65 data.writeInt32(newLockStatus);
66 remote()->transact(LOCK_STATUS_CHANGED, data, &reply,
67 IBinder::FLAG_ONEWAY);
70 void onResultReceived(int32_t requestId, camera_metadata* result) {
71 ALOGV("onResultReceived");
73 data.writeInterfaceToken(IProCameraCallbacks::getInterfaceDescriptor());
74 data.writeInt32(requestId);
75 CameraMetadata::writeToParcel(data, result);
76 remote()->transact(RESULT_RECEIVED, data, &reply, IBinder::FLAG_ONEWAY);
80 IMPLEMENT_META_INTERFACE(ProCameraCallbacks,
81 "android.hardware.IProCameraCallbacks");
83 // ----------------------------------------------------------------------
85 status_t BnProCameraCallbacks::onTransact(
86 uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags)
88 ALOGV("onTransact - code = %d", code);
90 case NOTIFY_CALLBACK: {
91 ALOGV("NOTIFY_CALLBACK");
92 CHECK_INTERFACE(IProCameraCallbacks, data, reply);
93 int32_t msgType = data.readInt32();
94 int32_t ext1 = data.readInt32();
95 int32_t ext2 = data.readInt32();
96 notifyCallback(msgType, ext1, ext2);
99 case LOCK_STATUS_CHANGED: {
100 ALOGV("LOCK_STATUS_CHANGED");
101 CHECK_INTERFACE(IProCameraCallbacks, data, reply);
102 LockStatus newLockStatus
103 = static_cast<LockStatus>(data.readInt32());
104 onLockStatusChanged(newLockStatus);
107 case RESULT_RECEIVED: {
108 ALOGV("RESULT_RECEIVED");
109 CHECK_INTERFACE(IProCameraCallbacks, data, reply);
110 int32_t requestId = data.readInt32();
111 camera_metadata_t *result = NULL;
112 CameraMetadata::readFromParcel(data, &result);
113 onResultReceived(requestId, result);
118 return BBinder::onTransact(code, data, reply, flags);
122 // ----------------------------------------------------------------------------
124 }; // namespace android