blob: 16a3d0221b6134df121b78b38abd8cce62a68cca [file] [log] [blame]
Wu-cheng Li4ca2c7c2011-06-01 17:22:24 +08001/*
2 * Copyright (C) 2011 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//#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>
23#include <stdint.h>
24#include <utils/Log.h>
25
26namespace android {
27
28enum {
29 START_RECORDING = IBinder::FIRST_CALL_TRANSACTION,
30 STOP_RECORDING,
31 RELEASE_RECORDING_FRAME,
32};
33
Eino-Ville Talvala7a3de842016-06-20 17:00:14 -070034uint8_t ICameraRecordingProxy::baseObject = 0;
35
36size_t ICameraRecordingProxy::getCommonBaseAddress() {
37 return (size_t)&baseObject;
38}
Wu-cheng Li4ca2c7c2011-06-01 17:22:24 +080039
40class BpCameraRecordingProxy: public BpInterface<ICameraRecordingProxy>
41{
42public:
43 BpCameraRecordingProxy(const sp<IBinder>& impl)
44 : BpInterface<ICameraRecordingProxy>(impl)
45 {
46 }
47
48 status_t startRecording(const sp<ICameraRecordingProxyListener>& listener)
49 {
Steve Block3856b092011-10-20 11:56:00 +010050 ALOGV("startRecording");
Wu-cheng Li4ca2c7c2011-06-01 17:22:24 +080051 Parcel data, reply;
52 data.writeInterfaceToken(ICameraRecordingProxy::getInterfaceDescriptor());
53 data.writeStrongBinder(listener->asBinder());
54 remote()->transact(START_RECORDING, data, &reply);
55 return reply.readInt32();
56 }
57
58 void stopRecording()
59 {
Steve Block3856b092011-10-20 11:56:00 +010060 ALOGV("stopRecording");
Wu-cheng Li4ca2c7c2011-06-01 17:22:24 +080061 Parcel data, reply;
62 data.writeInterfaceToken(ICameraRecordingProxy::getInterfaceDescriptor());
63 remote()->transact(STOP_RECORDING, data, &reply);
64 }
65
66 void releaseRecordingFrame(const sp<IMemory>& mem)
67 {
Steve Block3856b092011-10-20 11:56:00 +010068 ALOGV("releaseRecordingFrame");
Wu-cheng Li4ca2c7c2011-06-01 17:22:24 +080069 Parcel data, reply;
70 data.writeInterfaceToken(ICameraRecordingProxy::getInterfaceDescriptor());
71 data.writeStrongBinder(mem->asBinder());
72 remote()->transact(RELEASE_RECORDING_FRAME, data, &reply);
73 }
74};
75
76IMPLEMENT_META_INTERFACE(CameraRecordingProxy, "android.hardware.ICameraRecordingProxy");
77
78// ----------------------------------------------------------------------
79
80status_t BnCameraRecordingProxy::onTransact(
81 uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags)
82{
83 switch(code) {
84 case START_RECORDING: {
Steve Block3856b092011-10-20 11:56:00 +010085 ALOGV("START_RECORDING");
Wu-cheng Li4ca2c7c2011-06-01 17:22:24 +080086 CHECK_INTERFACE(ICameraRecordingProxy, data, reply);
87 sp<ICameraRecordingProxyListener> listener =
88 interface_cast<ICameraRecordingProxyListener>(data.readStrongBinder());
89 reply->writeInt32(startRecording(listener));
90 return NO_ERROR;
91 } break;
92 case STOP_RECORDING: {
Steve Block3856b092011-10-20 11:56:00 +010093 ALOGV("STOP_RECORDING");
Wu-cheng Li4ca2c7c2011-06-01 17:22:24 +080094 CHECK_INTERFACE(ICameraRecordingProxy, data, reply);
95 stopRecording();
96 return NO_ERROR;
97 } break;
98 case RELEASE_RECORDING_FRAME: {
Steve Block3856b092011-10-20 11:56:00 +010099 ALOGV("RELEASE_RECORDING_FRAME");
Wu-cheng Li4ca2c7c2011-06-01 17:22:24 +0800100 CHECK_INTERFACE(ICameraRecordingProxy, data, reply);
101 sp<IMemory> mem = interface_cast<IMemory>(data.readStrongBinder());
102 releaseRecordingFrame(mem);
103 return NO_ERROR;
104 } break;
105
106 default:
107 return BBinder::onTransact(code, data, reply, flags);
108 }
109}
110
111// ----------------------------------------------------------------------------
112
113}; // namespace android