2 * Copyright (C) 2011 The Android Open Source Project
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
17 //#define LOG_NDEBUG 0
18 #define LOG_TAG "ICameraRecordingProxy"
19 #include <camera/ICameraRecordingProxy.h>
20 #include <camera/ICameraRecordingProxyListener.h>
21 #include <binder/IMemory.h>
22 #include <binder/Parcel.h>
24 #include <utils/Log.h>
29 START_RECORDING = IBinder::FIRST_CALL_TRANSACTION,
31 RELEASE_RECORDING_FRAME,
34 uint8_t ICameraRecordingProxy::baseObject = 0;
36 size_t ICameraRecordingProxy::getCommonBaseAddress() {
37 return (size_t)&baseObject;
40 class BpCameraRecordingProxy: public BpInterface<ICameraRecordingProxy>
43 BpCameraRecordingProxy(const sp<IBinder>& impl)
44 : BpInterface<ICameraRecordingProxy>(impl)
48 status_t startRecording(const sp<ICameraRecordingProxyListener>& listener)
50 ALOGV("startRecording");
52 data.writeInterfaceToken(ICameraRecordingProxy::getInterfaceDescriptor());
53 data.writeStrongBinder(listener->asBinder());
54 remote()->transact(START_RECORDING, data, &reply);
55 return reply.readInt32();
60 ALOGV("stopRecording");
62 data.writeInterfaceToken(ICameraRecordingProxy::getInterfaceDescriptor());
63 remote()->transact(STOP_RECORDING, data, &reply);
66 void releaseRecordingFrame(const sp<IMemory>& mem)
68 ALOGV("releaseRecordingFrame");
70 data.writeInterfaceToken(ICameraRecordingProxy::getInterfaceDescriptor());
71 data.writeStrongBinder(mem->asBinder());
72 remote()->transact(RELEASE_RECORDING_FRAME, data, &reply);
76 IMPLEMENT_META_INTERFACE(CameraRecordingProxy, "android.hardware.ICameraRecordingProxy");
78 // ----------------------------------------------------------------------
80 status_t BnCameraRecordingProxy::onTransact(
81 uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags)
84 case START_RECORDING: {
85 ALOGV("START_RECORDING");
86 CHECK_INTERFACE(ICameraRecordingProxy, data, reply);
87 sp<ICameraRecordingProxyListener> listener =
88 interface_cast<ICameraRecordingProxyListener>(data.readStrongBinder());
89 reply->writeInt32(startRecording(listener));
92 case STOP_RECORDING: {
93 ALOGV("STOP_RECORDING");
94 CHECK_INTERFACE(ICameraRecordingProxy, data, reply);
98 case RELEASE_RECORDING_FRAME: {
99 ALOGV("RELEASE_RECORDING_FRAME");
100 CHECK_INTERFACE(ICameraRecordingProxy, data, reply);
101 sp<IMemory> mem = interface_cast<IMemory>(data.readStrongBinder());
102 releaseRecordingFrame(mem);
107 return BBinder::onTransact(code, data, reply, flags);
111 // ----------------------------------------------------------------------------
113 }; // namespace android