1 /* 2 ** 3 ** Copyright 2015, The Android Open Source Project 4 ** 5 ** Licensed under the Apache License, Version 2.0 (the "License"); 6 ** you may not use this file except in compliance with the License. 7 ** You may obtain a copy of the License at 8 ** 9 ** http://www.apache.org/licenses/LICENSE-2.0 10 ** 11 ** Unless required by applicable law or agreed to in writing, software 12 ** distributed under the License is distributed on an "AS IS" BASIS, 13 ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 ** See the License for the specific language governing permissions and 15 ** limitations under the License. 16 */ 17 18 #define LOG_TAG "IMediaCodecService" 19 //#define LOG_NDEBUG 0 20 21 #include <utils/Log.h> 22 #include <stdint.h> 23 #include <sys/types.h> 24 #include <binder/Parcel.h> 25 #include <media/IMediaCodecService.h> 26 27 namespace android { 28 29 enum { 30 GET_OMX = IBinder::FIRST_CALL_TRANSACTION 31 }; 32 33 class BpMediaCodecService : public BpInterface<IMediaCodecService> 34 { 35 public: 36 BpMediaCodecService(const sp<IBinder>& impl) 37 : BpInterface<IMediaCodecService>(impl) 38 { 39 } 40 41 virtual sp<IOMX> getOMX() { 42 Parcel data, reply; 43 data.writeInterfaceToken(IMediaCodecService::getInterfaceDescriptor()); 44 remote()->transact(GET_OMX, data, &reply); 45 return interface_cast<IOMX>(reply.readStrongBinder()); 46 } 47 48 }; 49 50 IMPLEMENT_META_INTERFACE(MediaCodecService, "android.media.IMediaCodecService"); 51 52 // ---------------------------------------------------------------------- 53 54 status_t BnMediaCodecService::onTransact( 55 uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags) 56 { 57 switch (code) { 58 59 case GET_OMX: { 60 CHECK_INTERFACE(IMediaCodecService, data, reply); 61 sp<IOMX> omx = getOMX(); 62 reply->writeStrongBinder(IInterface::asBinder(omx)); 63 return NO_ERROR; 64 } 65 default: 66 return BBinder::onTransact(code, data, reply, flags); 67 } 68 } 69 70 // ---------------------------------------------------------------------------- 71 72 } // namespace android 73