ICameraService.cpp revision 3cf613507f1e2f7bd932d921a6e222e426fd3be4
13cf613507f1e2f7bd932d921a6e222e426fd3be4Mathias Agopian/* 23cf613507f1e2f7bd932d921a6e222e426fd3be4Mathias Agopian** 33cf613507f1e2f7bd932d921a6e222e426fd3be4Mathias Agopian** Copyright 2008, The Android Open Source Project 43cf613507f1e2f7bd932d921a6e222e426fd3be4Mathias Agopian** 53cf613507f1e2f7bd932d921a6e222e426fd3be4Mathias Agopian** Licensed under the Apache License, Version 2.0 (the "License"); 63cf613507f1e2f7bd932d921a6e222e426fd3be4Mathias Agopian** you may not use this file except in compliance with the License. 73cf613507f1e2f7bd932d921a6e222e426fd3be4Mathias Agopian** You may obtain a copy of the License at 83cf613507f1e2f7bd932d921a6e222e426fd3be4Mathias Agopian** 93cf613507f1e2f7bd932d921a6e222e426fd3be4Mathias Agopian** http://www.apache.org/licenses/LICENSE-2.0 103cf613507f1e2f7bd932d921a6e222e426fd3be4Mathias Agopian** 113cf613507f1e2f7bd932d921a6e222e426fd3be4Mathias Agopian** Unless required by applicable law or agreed to in writing, software 123cf613507f1e2f7bd932d921a6e222e426fd3be4Mathias Agopian** distributed under the License is distributed on an "AS IS" BASIS, 133cf613507f1e2f7bd932d921a6e222e426fd3be4Mathias Agopian** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 143cf613507f1e2f7bd932d921a6e222e426fd3be4Mathias Agopian** See the License for the specific language governing permissions and 153cf613507f1e2f7bd932d921a6e222e426fd3be4Mathias Agopian** limitations under the License. 163cf613507f1e2f7bd932d921a6e222e426fd3be4Mathias Agopian*/ 173cf613507f1e2f7bd932d921a6e222e426fd3be4Mathias Agopian 183cf613507f1e2f7bd932d921a6e222e426fd3be4Mathias Agopian#include <stdint.h> 193cf613507f1e2f7bd932d921a6e222e426fd3be4Mathias Agopian#include <sys/types.h> 203cf613507f1e2f7bd932d921a6e222e426fd3be4Mathias Agopian 213cf613507f1e2f7bd932d921a6e222e426fd3be4Mathias Agopian#include <binder/Parcel.h> 223cf613507f1e2f7bd932d921a6e222e426fd3be4Mathias Agopian#include <binder/IPCThreadState.h> 233cf613507f1e2f7bd932d921a6e222e426fd3be4Mathias Agopian#include <binder/IServiceManager.h> 243cf613507f1e2f7bd932d921a6e222e426fd3be4Mathias Agopian 253cf613507f1e2f7bd932d921a6e222e426fd3be4Mathias Agopian#include <camera/ICameraService.h> 263cf613507f1e2f7bd932d921a6e222e426fd3be4Mathias Agopian 273cf613507f1e2f7bd932d921a6e222e426fd3be4Mathias Agopiannamespace android { 283cf613507f1e2f7bd932d921a6e222e426fd3be4Mathias Agopian 293cf613507f1e2f7bd932d921a6e222e426fd3be4Mathias Agopianclass BpCameraService: public BpInterface<ICameraService> 303cf613507f1e2f7bd932d921a6e222e426fd3be4Mathias Agopian{ 313cf613507f1e2f7bd932d921a6e222e426fd3be4Mathias Agopianpublic: 323cf613507f1e2f7bd932d921a6e222e426fd3be4Mathias Agopian BpCameraService(const sp<IBinder>& impl) 333cf613507f1e2f7bd932d921a6e222e426fd3be4Mathias Agopian : BpInterface<ICameraService>(impl) 343cf613507f1e2f7bd932d921a6e222e426fd3be4Mathias Agopian { 353cf613507f1e2f7bd932d921a6e222e426fd3be4Mathias Agopian } 363cf613507f1e2f7bd932d921a6e222e426fd3be4Mathias Agopian 373cf613507f1e2f7bd932d921a6e222e426fd3be4Mathias Agopian // connect to camera service 383cf613507f1e2f7bd932d921a6e222e426fd3be4Mathias Agopian virtual sp<ICamera> connect(const sp<ICameraClient>& cameraClient) 393cf613507f1e2f7bd932d921a6e222e426fd3be4Mathias Agopian { 403cf613507f1e2f7bd932d921a6e222e426fd3be4Mathias Agopian Parcel data, reply; 413cf613507f1e2f7bd932d921a6e222e426fd3be4Mathias Agopian data.writeInterfaceToken(ICameraService::getInterfaceDescriptor()); 423cf613507f1e2f7bd932d921a6e222e426fd3be4Mathias Agopian data.writeStrongBinder(cameraClient->asBinder()); 433cf613507f1e2f7bd932d921a6e222e426fd3be4Mathias Agopian remote()->transact(BnCameraService::CONNECT, data, &reply); 443cf613507f1e2f7bd932d921a6e222e426fd3be4Mathias Agopian return interface_cast<ICamera>(reply.readStrongBinder()); 453cf613507f1e2f7bd932d921a6e222e426fd3be4Mathias Agopian } 463cf613507f1e2f7bd932d921a6e222e426fd3be4Mathias Agopian}; 473cf613507f1e2f7bd932d921a6e222e426fd3be4Mathias Agopian 483cf613507f1e2f7bd932d921a6e222e426fd3be4Mathias AgopianIMPLEMENT_META_INTERFACE(CameraService, "android.hardware.ICameraService"); 493cf613507f1e2f7bd932d921a6e222e426fd3be4Mathias Agopian 503cf613507f1e2f7bd932d921a6e222e426fd3be4Mathias Agopian// ---------------------------------------------------------------------- 513cf613507f1e2f7bd932d921a6e222e426fd3be4Mathias Agopian 523cf613507f1e2f7bd932d921a6e222e426fd3be4Mathias Agopianstatus_t BnCameraService::onTransact( 533cf613507f1e2f7bd932d921a6e222e426fd3be4Mathias Agopian uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags) 543cf613507f1e2f7bd932d921a6e222e426fd3be4Mathias Agopian{ 553cf613507f1e2f7bd932d921a6e222e426fd3be4Mathias Agopian switch(code) { 563cf613507f1e2f7bd932d921a6e222e426fd3be4Mathias Agopian case CONNECT: { 573cf613507f1e2f7bd932d921a6e222e426fd3be4Mathias Agopian CHECK_INTERFACE(ICameraService, data, reply); 583cf613507f1e2f7bd932d921a6e222e426fd3be4Mathias Agopian sp<ICameraClient> cameraClient = interface_cast<ICameraClient>(data.readStrongBinder()); 593cf613507f1e2f7bd932d921a6e222e426fd3be4Mathias Agopian sp<ICamera> camera = connect(cameraClient); 603cf613507f1e2f7bd932d921a6e222e426fd3be4Mathias Agopian reply->writeStrongBinder(camera->asBinder()); 613cf613507f1e2f7bd932d921a6e222e426fd3be4Mathias Agopian return NO_ERROR; 623cf613507f1e2f7bd932d921a6e222e426fd3be4Mathias Agopian } break; 633cf613507f1e2f7bd932d921a6e222e426fd3be4Mathias Agopian default: 643cf613507f1e2f7bd932d921a6e222e426fd3be4Mathias Agopian return BBinder::onTransact(code, data, reply, flags); 653cf613507f1e2f7bd932d921a6e222e426fd3be4Mathias Agopian } 663cf613507f1e2f7bd932d921a6e222e426fd3be4Mathias Agopian} 673cf613507f1e2f7bd932d921a6e222e426fd3be4Mathias Agopian 683cf613507f1e2f7bd932d921a6e222e426fd3be4Mathias Agopian// ---------------------------------------------------------------------------- 693cf613507f1e2f7bd932d921a6e222e426fd3be4Mathias Agopian 703cf613507f1e2f7bd932d921a6e222e426fd3be4Mathias Agopian}; // namespace android 713cf613507f1e2f7bd932d921a6e222e426fd3be4Mathias Agopian 72