blob: 97523a52319c0aea3fa448012d7c7603073ba5dd [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"
Praveen Chavan6773d472016-01-13 01:24:30 -080019#include <camera/CameraUtils.h>
Wu-cheng Li4ca2c7c2011-06-01 17:22:24 +080020#include <camera/ICameraRecordingProxy.h>
Wu-cheng Li4ca2c7c2011-06-01 17:22:24 +080021#include <binder/IMemory.h>
22#include <binder/Parcel.h>
Praveen Chavan6773d472016-01-13 01:24:30 -080023#include <media/hardware/HardwareAPI.h>
Wu-cheng Li4ca2c7c2011-06-01 17:22:24 +080024#include <stdint.h>
25#include <utils/Log.h>
26
27namespace android {
28
29enum {
30 START_RECORDING = IBinder::FIRST_CALL_TRANSACTION,
Eino-Ville Talvalab8ed8ef2020-06-22 16:59:48 -070031 STOP_RECORDING
Wu-cheng Li4ca2c7c2011-06-01 17:22:24 +080032};
33
34
35class BpCameraRecordingProxy: public BpInterface<ICameraRecordingProxy>
36{
37public:
Chih-Hung Hsieh090ef602016-04-27 10:39:54 -070038 explicit BpCameraRecordingProxy(const sp<IBinder>& impl)
Wu-cheng Li4ca2c7c2011-06-01 17:22:24 +080039 : BpInterface<ICameraRecordingProxy>(impl)
40 {
41 }
42
Eino-Ville Talvalab8ed8ef2020-06-22 16:59:48 -070043 status_t startRecording()
Wu-cheng Li4ca2c7c2011-06-01 17:22:24 +080044 {
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());
Wu-cheng Li4ca2c7c2011-06-01 17:22:24 +080048 remote()->transact(START_RECORDING, data, &reply);
49 return reply.readInt32();
50 }
51
52 void stopRecording()
53 {
Steve Block3856b092011-10-20 11:56:00 +010054 ALOGV("stopRecording");
Wu-cheng Li4ca2c7c2011-06-01 17:22:24 +080055 Parcel data, reply;
56 data.writeInterfaceToken(ICameraRecordingProxy::getInterfaceDescriptor());
57 remote()->transact(STOP_RECORDING, data, &reply);
58 }
Wu-cheng Li4ca2c7c2011-06-01 17:22:24 +080059};
60
61IMPLEMENT_META_INTERFACE(CameraRecordingProxy, "android.hardware.ICameraRecordingProxy");
62
63// ----------------------------------------------------------------------
64
65status_t BnCameraRecordingProxy::onTransact(
66 uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags)
67{
68 switch(code) {
69 case START_RECORDING: {
Steve Block3856b092011-10-20 11:56:00 +010070 ALOGV("START_RECORDING");
Wu-cheng Li4ca2c7c2011-06-01 17:22:24 +080071 CHECK_INTERFACE(ICameraRecordingProxy, data, reply);
Eino-Ville Talvalab8ed8ef2020-06-22 16:59:48 -070072 reply->writeInt32(startRecording());
Wu-cheng Li4ca2c7c2011-06-01 17:22:24 +080073 return NO_ERROR;
74 } break;
75 case STOP_RECORDING: {
Steve Block3856b092011-10-20 11:56:00 +010076 ALOGV("STOP_RECORDING");
Wu-cheng Li4ca2c7c2011-06-01 17:22:24 +080077 CHECK_INTERFACE(ICameraRecordingProxy, data, reply);
78 stopRecording();
79 return NO_ERROR;
80 } break;
Wu-cheng Li4ca2c7c2011-06-01 17:22:24 +080081 default:
82 return BBinder::onTransact(code, data, reply, flags);
83 }
84}
85
86// ----------------------------------------------------------------------------
87
88}; // namespace android