Wu-cheng Li | 4ca2c7c | 2011-06-01 17:22:24 +0800 | [diff] [blame] | 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" |
Praveen Chavan | 6773d47 | 2016-01-13 01:24:30 -0800 | [diff] [blame] | 19 | #include <camera/CameraUtils.h> |
Wu-cheng Li | 4ca2c7c | 2011-06-01 17:22:24 +0800 | [diff] [blame] | 20 | #include <camera/ICameraRecordingProxy.h> |
Wu-cheng Li | 4ca2c7c | 2011-06-01 17:22:24 +0800 | [diff] [blame] | 21 | #include <binder/IMemory.h> |
| 22 | #include <binder/Parcel.h> |
Praveen Chavan | 6773d47 | 2016-01-13 01:24:30 -0800 | [diff] [blame] | 23 | #include <media/hardware/HardwareAPI.h> |
Wu-cheng Li | 4ca2c7c | 2011-06-01 17:22:24 +0800 | [diff] [blame] | 24 | #include <stdint.h> |
| 25 | #include <utils/Log.h> |
| 26 | |
| 27 | namespace android { |
| 28 | |
| 29 | enum { |
| 30 | START_RECORDING = IBinder::FIRST_CALL_TRANSACTION, |
Eino-Ville Talvala | b8ed8ef | 2020-06-22 16:59:48 -0700 | [diff] [blame] | 31 | STOP_RECORDING |
Wu-cheng Li | 4ca2c7c | 2011-06-01 17:22:24 +0800 | [diff] [blame] | 32 | }; |
| 33 | |
| 34 | |
| 35 | class BpCameraRecordingProxy: public BpInterface<ICameraRecordingProxy> |
| 36 | { |
| 37 | public: |
Chih-Hung Hsieh | 090ef60 | 2016-04-27 10:39:54 -0700 | [diff] [blame] | 38 | explicit BpCameraRecordingProxy(const sp<IBinder>& impl) |
Wu-cheng Li | 4ca2c7c | 2011-06-01 17:22:24 +0800 | [diff] [blame] | 39 | : BpInterface<ICameraRecordingProxy>(impl) |
| 40 | { |
| 41 | } |
| 42 | |
Eino-Ville Talvala | b8ed8ef | 2020-06-22 16:59:48 -0700 | [diff] [blame] | 43 | status_t startRecording() |
Wu-cheng Li | 4ca2c7c | 2011-06-01 17:22:24 +0800 | [diff] [blame] | 44 | { |
Steve Block | 3856b09 | 2011-10-20 11:56:00 +0100 | [diff] [blame] | 45 | ALOGV("startRecording"); |
Wu-cheng Li | 4ca2c7c | 2011-06-01 17:22:24 +0800 | [diff] [blame] | 46 | Parcel data, reply; |
| 47 | data.writeInterfaceToken(ICameraRecordingProxy::getInterfaceDescriptor()); |
Wu-cheng Li | 4ca2c7c | 2011-06-01 17:22:24 +0800 | [diff] [blame] | 48 | remote()->transact(START_RECORDING, data, &reply); |
| 49 | return reply.readInt32(); |
| 50 | } |
| 51 | |
| 52 | void stopRecording() |
| 53 | { |
Steve Block | 3856b09 | 2011-10-20 11:56:00 +0100 | [diff] [blame] | 54 | ALOGV("stopRecording"); |
Wu-cheng Li | 4ca2c7c | 2011-06-01 17:22:24 +0800 | [diff] [blame] | 55 | Parcel data, reply; |
| 56 | data.writeInterfaceToken(ICameraRecordingProxy::getInterfaceDescriptor()); |
| 57 | remote()->transact(STOP_RECORDING, data, &reply); |
| 58 | } |
Wu-cheng Li | 4ca2c7c | 2011-06-01 17:22:24 +0800 | [diff] [blame] | 59 | }; |
| 60 | |
| 61 | IMPLEMENT_META_INTERFACE(CameraRecordingProxy, "android.hardware.ICameraRecordingProxy"); |
| 62 | |
| 63 | // ---------------------------------------------------------------------- |
| 64 | |
| 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: { |
Steve Block | 3856b09 | 2011-10-20 11:56:00 +0100 | [diff] [blame] | 70 | ALOGV("START_RECORDING"); |
Wu-cheng Li | 4ca2c7c | 2011-06-01 17:22:24 +0800 | [diff] [blame] | 71 | CHECK_INTERFACE(ICameraRecordingProxy, data, reply); |
Eino-Ville Talvala | b8ed8ef | 2020-06-22 16:59:48 -0700 | [diff] [blame] | 72 | reply->writeInt32(startRecording()); |
Wu-cheng Li | 4ca2c7c | 2011-06-01 17:22:24 +0800 | [diff] [blame] | 73 | return NO_ERROR; |
| 74 | } break; |
| 75 | case STOP_RECORDING: { |
Steve Block | 3856b09 | 2011-10-20 11:56:00 +0100 | [diff] [blame] | 76 | ALOGV("STOP_RECORDING"); |
Wu-cheng Li | 4ca2c7c | 2011-06-01 17:22:24 +0800 | [diff] [blame] | 77 | CHECK_INTERFACE(ICameraRecordingProxy, data, reply); |
| 78 | stopRecording(); |
| 79 | return NO_ERROR; |
| 80 | } break; |
Wu-cheng Li | 4ca2c7c | 2011-06-01 17:22:24 +0800 | [diff] [blame] | 81 | default: |
| 82 | return BBinder::onTransact(code, data, reply, flags); |
| 83 | } |
| 84 | } |
| 85 | |
| 86 | // ---------------------------------------------------------------------------- |
| 87 | |
| 88 | }; // namespace android |