Colin Cross | 85e88d9 | 2017-10-26 16:16:55 -0700 | [diff] [blame^] | 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 | GET_OMX_STORE |
| 32 | }; |
| 33 | |
| 34 | class BpMediaCodecService : public BpInterface<IMediaCodecService> |
| 35 | { |
| 36 | public: |
| 37 | explicit BpMediaCodecService(const sp<IBinder>& impl) |
| 38 | : BpInterface<IMediaCodecService>(impl) |
| 39 | { |
| 40 | } |
| 41 | |
| 42 | virtual sp<IOMX> getOMX() { |
| 43 | Parcel data, reply; |
| 44 | data.writeInterfaceToken(IMediaCodecService::getInterfaceDescriptor()); |
| 45 | remote()->transact(GET_OMX, data, &reply); |
| 46 | return interface_cast<IOMX>(reply.readStrongBinder()); |
| 47 | } |
| 48 | |
| 49 | virtual sp<IOMXStore> getOMXStore() { |
| 50 | Parcel data, reply; |
| 51 | data.writeInterfaceToken(IMediaCodecService::getInterfaceDescriptor()); |
| 52 | remote()->transact(GET_OMX_STORE, data, &reply); |
| 53 | return interface_cast<IOMXStore>(reply.readStrongBinder()); |
| 54 | } |
| 55 | |
| 56 | }; |
| 57 | |
| 58 | IMPLEMENT_META_INTERFACE(MediaCodecService, "android.media.IMediaCodecService"); |
| 59 | |
| 60 | // ---------------------------------------------------------------------- |
| 61 | |
| 62 | status_t BnMediaCodecService::onTransact( |
| 63 | uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags) |
| 64 | { |
| 65 | switch (code) { |
| 66 | |
| 67 | case GET_OMX: { |
| 68 | CHECK_INTERFACE(IMediaCodecService, data, reply); |
| 69 | sp<IOMX> omx = getOMX(); |
| 70 | reply->writeStrongBinder(IInterface::asBinder(omx)); |
| 71 | return NO_ERROR; |
| 72 | } |
| 73 | case GET_OMX_STORE: { |
| 74 | CHECK_INTERFACE(IMediaCodecService, data, reply); |
| 75 | sp<IOMXStore> omxStore = getOMXStore(); |
| 76 | reply->writeStrongBinder(IInterface::asBinder(omxStore)); |
| 77 | return NO_ERROR; |
| 78 | } |
| 79 | default: |
| 80 | return BBinder::onTransact(code, data, reply, flags); |
| 81 | } |
| 82 | } |
| 83 | |
| 84 | // ---------------------------------------------------------------------------- |
| 85 | |
| 86 | } // namespace android |