1 /*
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/CameraUtils.h>
20 #include <camera/ICameraRecordingProxy.h>
21 #include <binder/IMemory.h>
22 #include <binder/Parcel.h>
23 #include <media/hardware/HardwareAPI.h>
24 #include <stdint.h>
25 #include <utils/Log.h>
26
27 namespace android {
28
29 enum {
30 START_RECORDING = IBinder::FIRST_CALL_TRANSACTION,
31 STOP_RECORDING
32 };
33
34
35 class BpCameraRecordingProxy: public BpInterface<ICameraRecordingProxy>
36 {
37 public:
BpCameraRecordingProxy(const sp<IBinder> & impl)38 explicit BpCameraRecordingProxy(const sp<IBinder>& impl)
39 : BpInterface<ICameraRecordingProxy>(impl)
40 {
41 }
42
startRecording()43 status_t startRecording()
44 {
45 ALOGV("startRecording");
46 Parcel data, reply;
47 data.writeInterfaceToken(ICameraRecordingProxy::getInterfaceDescriptor());
48 remote()->transact(START_RECORDING, data, &reply);
49 return reply.readInt32();
50 }
51
stopRecording()52 void stopRecording()
53 {
54 ALOGV("stopRecording");
55 Parcel data, reply;
56 data.writeInterfaceToken(ICameraRecordingProxy::getInterfaceDescriptor());
57 remote()->transact(STOP_RECORDING, data, &reply);
58 }
59 };
60
61 IMPLEMENT_META_INTERFACE(CameraRecordingProxy, "android.hardware.ICameraRecordingProxy");
62
63 // ----------------------------------------------------------------------
64
onTransact(uint32_t code,const Parcel & data,Parcel * reply,uint32_t flags)65 status_t BnCameraRecordingProxy::onTransact(
66 uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags)
67 {
68 switch(code) {
69 case START_RECORDING: {
70 ALOGV("START_RECORDING");
71 CHECK_INTERFACE(ICameraRecordingProxy, data, reply);
72 reply->writeInt32(startRecording());
73 return NO_ERROR;
74 } break;
75 case STOP_RECORDING: {
76 ALOGV("STOP_RECORDING");
77 CHECK_INTERFACE(ICameraRecordingProxy, data, reply);
78 stopRecording();
79 return NO_ERROR;
80 } break;
81 default:
82 return BBinder::onTransact(code, data, reply, flags);
83 }
84 }
85
86 // ----------------------------------------------------------------------------
87
88 }; // namespace android
89