1 /* 2 * Copyright (C) 2013 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 #include <stdint.h> 18 #include <sys/types.h> 19 20 #include <binder/IInterface.h> 21 #include <binder/Parcel.h> 22 23 #include <gui/IConsumerListener.h> 24 25 // --------------------------------------------------------------------------- 26 namespace android { 27 // --------------------------------------------------------------------------- 28 29 enum { 30 ON_FRAME_AVAILABLE = IBinder::FIRST_CALL_TRANSACTION, 31 ON_BUFFER_RELEASED, 32 ON_SIDEBAND_STREAM_CHANGED, 33 }; 34 35 class BpConsumerListener : public BpInterface<IConsumerListener> 36 { 37 public: 38 BpConsumerListener(const sp<IBinder>& impl) 39 : BpInterface<IConsumerListener>(impl) { 40 } 41 42 virtual void onFrameAvailable() { 43 Parcel data, reply; 44 data.writeInterfaceToken(IConsumerListener::getInterfaceDescriptor()); 45 remote()->transact(ON_FRAME_AVAILABLE, data, &reply, IBinder::FLAG_ONEWAY); 46 } 47 48 virtual void onBuffersReleased() { 49 Parcel data, reply; 50 data.writeInterfaceToken(IConsumerListener::getInterfaceDescriptor()); 51 remote()->transact(ON_BUFFER_RELEASED, data, &reply, IBinder::FLAG_ONEWAY); 52 } 53 54 virtual void onSidebandStreamChanged() { 55 Parcel data, reply; 56 data.writeInterfaceToken(IConsumerListener::getInterfaceDescriptor()); 57 remote()->transact(ON_SIDEBAND_STREAM_CHANGED, data, &reply, IBinder::FLAG_ONEWAY); 58 } 59 }; 60 61 IMPLEMENT_META_INTERFACE(ConsumerListener, "android.gui.IConsumerListener"); 62 63 // ---------------------------------------------------------------------- 64 65 status_t BnConsumerListener::onTransact( 66 uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags) 67 { 68 switch(code) { 69 case ON_FRAME_AVAILABLE: 70 CHECK_INTERFACE(IConsumerListener, data, reply); 71 onFrameAvailable(); 72 return NO_ERROR; 73 case ON_BUFFER_RELEASED: 74 CHECK_INTERFACE(IConsumerListener, data, reply); 75 onBuffersReleased(); 76 return NO_ERROR; 77 case ON_SIDEBAND_STREAM_CHANGED: 78 CHECK_INTERFACE(IConsumerListener, data, reply); 79 onSidebandStreamChanged(); 80 return NO_ERROR; 81 } 82 return BBinder::onTransact(code, data, reply, flags); 83 } 84 85 86 // --------------------------------------------------------------------------- 87 }; // namespace android 88 // --------------------------------------------------------------------------- 89