Wed, 31 Dec 2014 13:27:57 +0100
Ignore runtime configuration files generated during quality assurance.
michael@0 | 1 | /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ |
michael@0 | 2 | /* vim:set ts=2 sw=2 sts=2 et cindent: */ |
michael@0 | 3 | /* This Source Code Form is subject to the terms of the Mozilla Public |
michael@0 | 4 | * License, v. 2.0. If a copy of the MPL was not distributed with this file, |
michael@0 | 5 | * You can obtain one at http://mozilla.org/MPL/2.0/. */ |
michael@0 | 6 | |
michael@0 | 7 | //#define LOG_NDEBUG 0 |
michael@0 | 8 | #define LOG_TAG "IMediaResourceManagerService" |
michael@0 | 9 | |
michael@0 | 10 | #include <stdint.h> |
michael@0 | 11 | #include <sys/types.h> |
michael@0 | 12 | |
michael@0 | 13 | #include <binder/Parcel.h> |
michael@0 | 14 | #include <utils/Log.h> |
michael@0 | 15 | |
michael@0 | 16 | #include "IMediaResourceManagerService.h" |
michael@0 | 17 | |
michael@0 | 18 | namespace android { |
michael@0 | 19 | |
michael@0 | 20 | /** |
michael@0 | 21 | * Function ID used between BpMediaResourceManagerService and |
michael@0 | 22 | * BnMediaResourceManagerService by using Binder ipc. |
michael@0 | 23 | */ |
michael@0 | 24 | enum { |
michael@0 | 25 | REQUEST_MEDIA_RESOURCE = IBinder::FIRST_CALL_TRANSACTION, |
michael@0 | 26 | DEREGISTER_CLIENT |
michael@0 | 27 | }; |
michael@0 | 28 | |
michael@0 | 29 | class BpMediaResourceManagerService : public BpInterface<IMediaResourceManagerService> |
michael@0 | 30 | { |
michael@0 | 31 | public: |
michael@0 | 32 | BpMediaResourceManagerService(const sp<IBinder>& impl) |
michael@0 | 33 | : BpInterface<IMediaResourceManagerService>(impl) |
michael@0 | 34 | { |
michael@0 | 35 | } |
michael@0 | 36 | |
michael@0 | 37 | virtual void requestMediaResource(const sp<IMediaResourceManagerClient>& client, int resourceType) |
michael@0 | 38 | { |
michael@0 | 39 | Parcel data, reply; |
michael@0 | 40 | data.writeInterfaceToken(IMediaResourceManagerService::getInterfaceDescriptor()); |
michael@0 | 41 | data.writeStrongBinder(client->asBinder()); |
michael@0 | 42 | data.writeInt32(resourceType); |
michael@0 | 43 | remote()->transact(REQUEST_MEDIA_RESOURCE, data, &reply); |
michael@0 | 44 | } |
michael@0 | 45 | |
michael@0 | 46 | virtual status_t cancelClient(const sp<IMediaResourceManagerClient>& client) |
michael@0 | 47 | { |
michael@0 | 48 | Parcel data, reply; |
michael@0 | 49 | data.writeInterfaceToken(IMediaResourceManagerService::getInterfaceDescriptor()); |
michael@0 | 50 | data.writeStrongBinder(client->asBinder()); |
michael@0 | 51 | remote()->transact(DEREGISTER_CLIENT, data, &reply); |
michael@0 | 52 | return reply.readInt32(); |
michael@0 | 53 | } |
michael@0 | 54 | }; |
michael@0 | 55 | |
michael@0 | 56 | IMPLEMENT_META_INTERFACE(MediaResourceManagerService, "android.media.IMediaResourceManagerService"); |
michael@0 | 57 | |
michael@0 | 58 | // ---------------------------------------------------------------------- |
michael@0 | 59 | |
michael@0 | 60 | status_t BnMediaResourceManagerService::onTransact( |
michael@0 | 61 | uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags) |
michael@0 | 62 | { |
michael@0 | 63 | switch(code) { |
michael@0 | 64 | |
michael@0 | 65 | case REQUEST_MEDIA_RESOURCE: { |
michael@0 | 66 | CHECK_INTERFACE(IMediaResourceManagerService, data, reply); |
michael@0 | 67 | sp<IMediaResourceManagerClient> client = interface_cast<IMediaResourceManagerClient>(data.readStrongBinder()); |
michael@0 | 68 | int resourceType = data.readInt32(); |
michael@0 | 69 | requestMediaResource(client, resourceType); |
michael@0 | 70 | return NO_ERROR; |
michael@0 | 71 | } break; |
michael@0 | 72 | case DEREGISTER_CLIENT: { |
michael@0 | 73 | CHECK_INTERFACE(IMediaResourceManagerService, data, reply); |
michael@0 | 74 | sp<IMediaResourceManagerClient> client = interface_cast<IMediaResourceManagerClient>(data.readStrongBinder()); |
michael@0 | 75 | cancelClient(client); |
michael@0 | 76 | reply->writeInt32(NO_ERROR); |
michael@0 | 77 | return NO_ERROR; |
michael@0 | 78 | } break; |
michael@0 | 79 | default: |
michael@0 | 80 | return BBinder::onTransact(code, data, reply, flags); |
michael@0 | 81 | } |
michael@0 | 82 | } |
michael@0 | 83 | |
michael@0 | 84 | // ---------------------------------------------------------------------------- |
michael@0 | 85 | |
michael@0 | 86 | }; // namespace android |