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 "ICameraRecordingProxyListener"
19#include <camera/ICameraRecordingProxyListener.h>
20#include <binder/IMemory.h>
21#include <binder/Parcel.h>
22#include <utils/Log.h>
23
24namespace android {
25
26enum {
27    DATA_CALLBACK_TIMESTAMP = IBinder::FIRST_CALL_TRANSACTION,
28};
29
30class BpCameraRecordingProxyListener: public BpInterface<ICameraRecordingProxyListener>
31{
32public:
33    BpCameraRecordingProxyListener(const sp<IBinder>& impl)
34        : BpInterface<ICameraRecordingProxyListener>(impl)
35    {
36    }
37
38    void dataCallbackTimestamp(nsecs_t timestamp, int32_t msgType, const sp<IMemory>& imageData)
39    {
40        ALOGV("dataCallback");
41        Parcel data, reply;
42        data.writeInterfaceToken(ICameraRecordingProxyListener::getInterfaceDescriptor());
43        data.writeInt64(timestamp);
44        data.writeInt32(msgType);
45        data.writeStrongBinder(imageData->asBinder());
46        remote()->transact(DATA_CALLBACK_TIMESTAMP, data, &reply, IBinder::FLAG_ONEWAY);
47    }
48};
49
50IMPLEMENT_META_INTERFACE(CameraRecordingProxyListener, "android.hardware.ICameraRecordingProxyListener");
51
52// ----------------------------------------------------------------------
53
54status_t BnCameraRecordingProxyListener::onTransact(
55    uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags)
56{
57    switch(code) {
58        case DATA_CALLBACK_TIMESTAMP: {
59            ALOGV("DATA_CALLBACK_TIMESTAMP");
60            CHECK_INTERFACE(ICameraRecordingProxyListener, data, reply);
61            nsecs_t timestamp = data.readInt64();
62            int32_t msgType = data.readInt32();
63            sp<IMemory> imageData = interface_cast<IMemory>(data.readStrongBinder());
64            dataCallbackTimestamp(timestamp, msgType, imageData);
65            return NO_ERROR;
66        } break;
67        default:
68            return BBinder::onTransact(code, data, reply, flags);
69    }
70}
71
72// ----------------------------------------------------------------------------
73
74}; // namespace android
75
76