blob: 3dc0ffb9bb8e15e6408d8c775cc732ff6f5fd3f7 [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
34
35class BpCameraRecordingProxy: public BpInterface<ICameraRecordingProxy>
36{
37public:
38 BpCameraRecordingProxy(const sp<IBinder>& impl)
39 : BpInterface<ICameraRecordingProxy>(impl)
40 {
41 }
42
43 status_t startRecording(const sp<ICameraRecordingProxyListener>& listener)
44 {
Steve Block3856b092011-10-20 11:56:00 +010045 ALOGV("startRecording");
Wu-cheng Li4ca2c7c2011-06-01 17:22:24 +080046 Parcel data, reply;
47 data.writeInterfaceToken(ICameraRecordingProxy::getInterfaceDescriptor());
Marco Nelissen06b46062014-11-14 07:58:25 -080048 data.writeStrongBinder(IInterface::asBinder(listener));
Wu-cheng Li4ca2c7c2011-06-01 17:22:24 +080049 remote()->transact(START_RECORDING, data, &reply);
50 return reply.readInt32();
51 }
52
53 void stopRecording()
54 {
Steve Block3856b092011-10-20 11:56:00 +010055 ALOGV("stopRecording");
Wu-cheng Li4ca2c7c2011-06-01 17:22:24 +080056 Parcel data, reply;
57 data.writeInterfaceToken(ICameraRecordingProxy::getInterfaceDescriptor());
58 remote()->transact(STOP_RECORDING, data, &reply);
59 }
60
61 void releaseRecordingFrame(const sp<IMemory>& mem)
62 {
Steve Block3856b092011-10-20 11:56:00 +010063 ALOGV("releaseRecordingFrame");
Wu-cheng Li4ca2c7c2011-06-01 17:22:24 +080064 Parcel data, reply;
65 data.writeInterfaceToken(ICameraRecordingProxy::getInterfaceDescriptor());
Marco Nelissen06b46062014-11-14 07:58:25 -080066 data.writeStrongBinder(IInterface::asBinder(mem));
Wu-cheng Li4ca2c7c2011-06-01 17:22:24 +080067 remote()->transact(RELEASE_RECORDING_FRAME, data, &reply);
68 }
69};
70
71IMPLEMENT_META_INTERFACE(CameraRecordingProxy, "android.hardware.ICameraRecordingProxy");
72
73// ----------------------------------------------------------------------
74
75status_t BnCameraRecordingProxy::onTransact(
76 uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags)
77{
78 switch(code) {
79 case START_RECORDING: {
Steve Block3856b092011-10-20 11:56:00 +010080 ALOGV("START_RECORDING");
Wu-cheng Li4ca2c7c2011-06-01 17:22:24 +080081 CHECK_INTERFACE(ICameraRecordingProxy, data, reply);
82 sp<ICameraRecordingProxyListener> listener =
83 interface_cast<ICameraRecordingProxyListener>(data.readStrongBinder());
84 reply->writeInt32(startRecording(listener));
85 return NO_ERROR;
86 } break;
87 case STOP_RECORDING: {
Steve Block3856b092011-10-20 11:56:00 +010088 ALOGV("STOP_RECORDING");
Wu-cheng Li4ca2c7c2011-06-01 17:22:24 +080089 CHECK_INTERFACE(ICameraRecordingProxy, data, reply);
90 stopRecording();
91 return NO_ERROR;
92 } break;
93 case RELEASE_RECORDING_FRAME: {
Steve Block3856b092011-10-20 11:56:00 +010094 ALOGV("RELEASE_RECORDING_FRAME");
Wu-cheng Li4ca2c7c2011-06-01 17:22:24 +080095 CHECK_INTERFACE(ICameraRecordingProxy, data, reply);
96 sp<IMemory> mem = interface_cast<IMemory>(data.readStrongBinder());
97 releaseRecordingFrame(mem);
98 return NO_ERROR;
99 } break;
100
101 default:
102 return BBinder::onTransact(code, data, reply, flags);
103 }
104}
105
106// ----------------------------------------------------------------------------
107
108}; // namespace android
109