IMediaPlayer.cpp revision d681bbb1767bed09415e050ba78975df214bcd68
189fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project/* 289fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project** 389fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project** Copyright 2008, The Android Open Source Project 489fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project** 589fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project** Licensed under the Apache License, Version 2.0 (the "License"); 689fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project** you may not use this file except in compliance with the License. 789fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project** You may obtain a copy of the License at 889fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project** 989fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project** http://www.apache.org/licenses/LICENSE-2.0 1089fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project** 1189fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project** Unless required by applicable law or agreed to in writing, software 1289fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project** distributed under the License is distributed on an "AS IS" BASIS, 1389fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1489fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project** See the License for the specific language governing permissions and 1589fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project** limitations under the License. 1689fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project*/ 1789fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project 1889fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project#include <stdint.h> 1989fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project#include <sys/types.h> 2089fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project 217562408b2261d38415453378b6188f74fda99d88Mathias Agopian#include <binder/Parcel.h> 2289fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project 2389fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project#include <media/IMediaPlayer.h> 24d681bbb1767bed09415e050ba78975df214bcd68Dave Burke#include <media/IStreamSource.h> 25d681bbb1767bed09415e050ba78975df214bcd68Dave Burke 263cf613507f1e2f7bd932d921a6e222e426fd3be4Mathias Agopian#include <surfaceflinger/ISurface.h> 275daeb129a2c2ba3d14ccd94af283b5f561c783eaAndreas Huber#include <surfaceflinger/Surface.h> 281173118eace0e9e347cb007f0da817cee87579edGlenn Kasten#include <gui/ISurfaceTexture.h> 29d681bbb1767bed09415e050ba78975df214bcd68Dave Burke#include <utils/String8.h> 3089fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project 3189fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Projectnamespace android { 3289fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project 3389fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Projectenum { 3489fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project DISCONNECT = IBinder::FIRST_CALL_TRANSACTION, 35d681bbb1767bed09415e050ba78975df214bcd68Dave Burke SET_DATA_SOURCE_URL, 36d681bbb1767bed09415e050ba78975df214bcd68Dave Burke SET_DATA_SOURCE_FD, 37d681bbb1767bed09415e050ba78975df214bcd68Dave Burke SET_DATA_SOURCE_STREAM, 3889fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project SET_VIDEO_SURFACE, 3989fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project PREPARE_ASYNC, 4089fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project START, 4189fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project STOP, 4289fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project IS_PLAYING, 4389fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project PAUSE, 4489fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project SEEK_TO, 4589fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project GET_CURRENT_POSITION, 4689fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project GET_DURATION, 4789fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project RESET, 4889fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project SET_AUDIO_STREAM_TYPE, 4989fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project SET_LOOPING, 501d187f1a86855f5f0694d7ec30efc9833bf7c589Nicolas Catania SET_VOLUME, 511d187f1a86855f5f0694d7ec30efc9833bf7c589Nicolas Catania INVOKE, 52a7e0e8b4c429fc68eb1bd5b5a30f5b91352288f9Nicolas Catania SET_METADATA_FILTER, 538e1b6cce24574b9ecd5b0300155776bd0b4ef756Nicolas Catania GET_METADATA, 542beeb50b1bba9e92f6cacfeca37fe9fa9d36ead1Eric Laurent SET_AUX_EFFECT_SEND_LEVEL, 551173118eace0e9e347cb007f0da817cee87579edGlenn Kasten ATTACH_AUX_EFFECT, 561173118eace0e9e347cb007f0da817cee87579edGlenn Kasten SET_VIDEO_SURFACETEXTURE, 574f9e47f2c03ce36261c4717cd7e131d7940bb068Gloria Wang SET_PARAMETER, 584f9e47f2c03ce36261c4717cd7e131d7940bb068Gloria Wang GET_PARAMETER, 5989fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project}; 6089fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project 6189fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Projectclass BpMediaPlayer: public BpInterface<IMediaPlayer> 6289fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project{ 6389fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Projectpublic: 6489fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project BpMediaPlayer(const sp<IBinder>& impl) 6589fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project : BpInterface<IMediaPlayer>(impl) 6689fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project { 6789fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project } 6889fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project 6989fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project // disconnect from media player service 7089fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project void disconnect() 7189fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project { 7289fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project Parcel data, reply; 7389fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project data.writeInterfaceToken(IMediaPlayer::getInterfaceDescriptor()); 7489fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project remote()->transact(DISCONNECT, data, &reply); 7589fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project } 7689fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project 77d681bbb1767bed09415e050ba78975df214bcd68Dave Burke status_t setDataSource(const char* url, 78d681bbb1767bed09415e050ba78975df214bcd68Dave Burke const KeyedVector<String8, String8>* headers) 79d681bbb1767bed09415e050ba78975df214bcd68Dave Burke { 80d681bbb1767bed09415e050ba78975df214bcd68Dave Burke Parcel data, reply; 81d681bbb1767bed09415e050ba78975df214bcd68Dave Burke data.writeInterfaceToken(IMediaPlayer::getInterfaceDescriptor()); 82d681bbb1767bed09415e050ba78975df214bcd68Dave Burke data.writeCString(url); 83d681bbb1767bed09415e050ba78975df214bcd68Dave Burke if (headers == NULL) { 84d681bbb1767bed09415e050ba78975df214bcd68Dave Burke data.writeInt32(0); 85d681bbb1767bed09415e050ba78975df214bcd68Dave Burke } else { 86d681bbb1767bed09415e050ba78975df214bcd68Dave Burke // serialize the headers 87d681bbb1767bed09415e050ba78975df214bcd68Dave Burke data.writeInt32(headers->size()); 88d681bbb1767bed09415e050ba78975df214bcd68Dave Burke for (size_t i = 0; i < headers->size(); ++i) { 89d681bbb1767bed09415e050ba78975df214bcd68Dave Burke data.writeString8(headers->keyAt(i)); 90d681bbb1767bed09415e050ba78975df214bcd68Dave Burke data.writeString8(headers->valueAt(i)); 91d681bbb1767bed09415e050ba78975df214bcd68Dave Burke } 92d681bbb1767bed09415e050ba78975df214bcd68Dave Burke } 93d681bbb1767bed09415e050ba78975df214bcd68Dave Burke remote()->transact(SET_DATA_SOURCE_URL, data, &reply); 94d681bbb1767bed09415e050ba78975df214bcd68Dave Burke return reply.readInt32(); 95d681bbb1767bed09415e050ba78975df214bcd68Dave Burke } 96d681bbb1767bed09415e050ba78975df214bcd68Dave Burke 97d681bbb1767bed09415e050ba78975df214bcd68Dave Burke status_t setDataSource(int fd, int64_t offset, int64_t length) { 98d681bbb1767bed09415e050ba78975df214bcd68Dave Burke Parcel data, reply; 99d681bbb1767bed09415e050ba78975df214bcd68Dave Burke data.writeInterfaceToken(IMediaPlayer::getInterfaceDescriptor()); 100d681bbb1767bed09415e050ba78975df214bcd68Dave Burke data.writeFileDescriptor(fd); 101d681bbb1767bed09415e050ba78975df214bcd68Dave Burke data.writeInt64(offset); 102d681bbb1767bed09415e050ba78975df214bcd68Dave Burke data.writeInt64(length); 103d681bbb1767bed09415e050ba78975df214bcd68Dave Burke remote()->transact(SET_DATA_SOURCE_FD, data, &reply); 104d681bbb1767bed09415e050ba78975df214bcd68Dave Burke return reply.readInt32(); 105d681bbb1767bed09415e050ba78975df214bcd68Dave Burke } 106d681bbb1767bed09415e050ba78975df214bcd68Dave Burke 107d681bbb1767bed09415e050ba78975df214bcd68Dave Burke status_t setDataSource(const sp<IStreamSource> &source) { 108d681bbb1767bed09415e050ba78975df214bcd68Dave Burke Parcel data, reply; 109d681bbb1767bed09415e050ba78975df214bcd68Dave Burke data.writeInterfaceToken(IMediaPlayer::getInterfaceDescriptor()); 110d681bbb1767bed09415e050ba78975df214bcd68Dave Burke data.writeStrongBinder(source->asBinder()); 111d681bbb1767bed09415e050ba78975df214bcd68Dave Burke return reply.readInt32(); 112d681bbb1767bed09415e050ba78975df214bcd68Dave Burke } 113d681bbb1767bed09415e050ba78975df214bcd68Dave Burke 1141173118eace0e9e347cb007f0da817cee87579edGlenn Kasten // pass the buffered Surface to the media player service 1155daeb129a2c2ba3d14ccd94af283b5f561c783eaAndreas Huber status_t setVideoSurface(const sp<Surface>& surface) 1165daeb129a2c2ba3d14ccd94af283b5f561c783eaAndreas Huber { 1175daeb129a2c2ba3d14ccd94af283b5f561c783eaAndreas Huber Parcel data, reply; 1185daeb129a2c2ba3d14ccd94af283b5f561c783eaAndreas Huber data.writeInterfaceToken(IMediaPlayer::getInterfaceDescriptor()); 1195daeb129a2c2ba3d14ccd94af283b5f561c783eaAndreas Huber Surface::writeToParcel(surface, &data); 12089fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project remote()->transact(SET_VIDEO_SURFACE, data, &reply); 12189fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project return reply.readInt32(); 12289fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project } 12389fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project 1241173118eace0e9e347cb007f0da817cee87579edGlenn Kasten // pass the buffered ISurfaceTexture to the media player service 1251173118eace0e9e347cb007f0da817cee87579edGlenn Kasten status_t setVideoSurfaceTexture(const sp<ISurfaceTexture>& surfaceTexture) 1261173118eace0e9e347cb007f0da817cee87579edGlenn Kasten { 1271173118eace0e9e347cb007f0da817cee87579edGlenn Kasten Parcel data, reply; 1281173118eace0e9e347cb007f0da817cee87579edGlenn Kasten data.writeInterfaceToken(IMediaPlayer::getInterfaceDescriptor()); 1291173118eace0e9e347cb007f0da817cee87579edGlenn Kasten sp<IBinder> b(surfaceTexture->asBinder()); 1301173118eace0e9e347cb007f0da817cee87579edGlenn Kasten data.writeStrongBinder(b); 1311173118eace0e9e347cb007f0da817cee87579edGlenn Kasten remote()->transact(SET_VIDEO_SURFACETEXTURE, data, &reply); 1321173118eace0e9e347cb007f0da817cee87579edGlenn Kasten return reply.readInt32(); 1331173118eace0e9e347cb007f0da817cee87579edGlenn Kasten } 1341173118eace0e9e347cb007f0da817cee87579edGlenn Kasten 13589fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project status_t prepareAsync() 13689fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project { 13789fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project Parcel data, reply; 13889fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project data.writeInterfaceToken(IMediaPlayer::getInterfaceDescriptor()); 13989fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project remote()->transact(PREPARE_ASYNC, data, &reply); 14089fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project return reply.readInt32(); 14189fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project } 14289fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project 14389fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project status_t start() 14489fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project { 14589fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project Parcel data, reply; 14689fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project data.writeInterfaceToken(IMediaPlayer::getInterfaceDescriptor()); 14789fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project remote()->transact(START, data, &reply); 14889fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project return reply.readInt32(); 14989fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project } 15089fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project 15189fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project status_t stop() 15289fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project { 15389fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project Parcel data, reply; 15489fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project data.writeInterfaceToken(IMediaPlayer::getInterfaceDescriptor()); 15589fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project remote()->transact(STOP, data, &reply); 15689fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project return reply.readInt32(); 15789fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project } 15889fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project 15989fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project status_t isPlaying(bool* state) 16089fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project { 16189fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project Parcel data, reply; 16289fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project data.writeInterfaceToken(IMediaPlayer::getInterfaceDescriptor()); 16389fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project remote()->transact(IS_PLAYING, data, &reply); 16489fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project *state = reply.readInt32(); 16589fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project return reply.readInt32(); 16689fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project } 16789fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project 16889fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project status_t pause() 16989fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project { 17089fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project Parcel data, reply; 17189fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project data.writeInterfaceToken(IMediaPlayer::getInterfaceDescriptor()); 17289fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project remote()->transact(PAUSE, data, &reply); 17389fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project return reply.readInt32(); 17489fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project } 17589fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project 17689fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project status_t seekTo(int msec) 17789fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project { 17889fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project Parcel data, reply; 17989fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project data.writeInterfaceToken(IMediaPlayer::getInterfaceDescriptor()); 18089fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project data.writeInt32(msec); 18189fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project remote()->transact(SEEK_TO, data, &reply); 18289fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project return reply.readInt32(); 18389fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project } 18489fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project 18589fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project status_t getCurrentPosition(int* msec) 18689fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project { 18789fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project Parcel data, reply; 18889fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project data.writeInterfaceToken(IMediaPlayer::getInterfaceDescriptor()); 18989fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project remote()->transact(GET_CURRENT_POSITION, data, &reply); 19089fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project *msec = reply.readInt32(); 19189fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project return reply.readInt32(); 19289fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project } 19389fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project 19489fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project status_t getDuration(int* msec) 19589fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project { 19689fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project Parcel data, reply; 19789fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project data.writeInterfaceToken(IMediaPlayer::getInterfaceDescriptor()); 19889fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project remote()->transact(GET_DURATION, data, &reply); 19989fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project *msec = reply.readInt32(); 20089fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project return reply.readInt32(); 20189fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project } 20289fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project 20389fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project status_t reset() 20489fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project { 20589fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project Parcel data, reply; 20689fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project data.writeInterfaceToken(IMediaPlayer::getInterfaceDescriptor()); 20789fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project remote()->transact(RESET, data, &reply); 20889fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project return reply.readInt32(); 20989fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project } 21089fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project 21189fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project status_t setAudioStreamType(int type) 21289fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project { 21389fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project Parcel data, reply; 21489fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project data.writeInterfaceToken(IMediaPlayer::getInterfaceDescriptor()); 21589fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project data.writeInt32(type); 21689fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project remote()->transact(SET_AUDIO_STREAM_TYPE, data, &reply); 21789fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project return reply.readInt32(); 21889fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project } 21989fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project 22089fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project status_t setLooping(int loop) 22189fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project { 22289fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project Parcel data, reply; 22389fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project data.writeInterfaceToken(IMediaPlayer::getInterfaceDescriptor()); 22489fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project data.writeInt32(loop); 22589fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project remote()->transact(SET_LOOPING, data, &reply); 22689fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project return reply.readInt32(); 22789fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project } 22889fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project 22989fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project status_t setVolume(float leftVolume, float rightVolume) 23089fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project { 23189fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project Parcel data, reply; 232172fb9ab347e146642234f0bd6f223d351e9fd0bDave Sparks data.writeInterfaceToken(IMediaPlayer::getInterfaceDescriptor()); 23389fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project data.writeFloat(leftVolume); 23489fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project data.writeFloat(rightVolume); 23589fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project remote()->transact(SET_VOLUME, data, &reply); 23689fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project return reply.readInt32(); 23789fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project } 2381d187f1a86855f5f0694d7ec30efc9833bf7c589Nicolas Catania 2391d187f1a86855f5f0694d7ec30efc9833bf7c589Nicolas Catania status_t invoke(const Parcel& request, Parcel *reply) 240040e4a14ef9cafd5d08d9a180e6237fb79687995James Dong { 241040e4a14ef9cafd5d08d9a180e6237fb79687995James Dong // Avoid doing any extra copy. The interface descriptor should 242040e4a14ef9cafd5d08d9a180e6237fb79687995James Dong // have been set by MediaPlayer.java. 2438e1b6cce24574b9ecd5b0300155776bd0b4ef756Nicolas Catania return remote()->transact(INVOKE, request, reply); 2441d187f1a86855f5f0694d7ec30efc9833bf7c589Nicolas Catania } 245a7e0e8b4c429fc68eb1bd5b5a30f5b91352288f9Nicolas Catania 246a7e0e8b4c429fc68eb1bd5b5a30f5b91352288f9Nicolas Catania status_t setMetadataFilter(const Parcel& request) 247a7e0e8b4c429fc68eb1bd5b5a30f5b91352288f9Nicolas Catania { 248a7e0e8b4c429fc68eb1bd5b5a30f5b91352288f9Nicolas Catania Parcel reply; 249a7e0e8b4c429fc68eb1bd5b5a30f5b91352288f9Nicolas Catania // Avoid doing any extra copy of the request. The interface 250a7e0e8b4c429fc68eb1bd5b5a30f5b91352288f9Nicolas Catania // descriptor should have been set by MediaPlayer.java. 251a7e0e8b4c429fc68eb1bd5b5a30f5b91352288f9Nicolas Catania remote()->transact(SET_METADATA_FILTER, request, &reply); 252a7e0e8b4c429fc68eb1bd5b5a30f5b91352288f9Nicolas Catania return reply.readInt32(); 253a7e0e8b4c429fc68eb1bd5b5a30f5b91352288f9Nicolas Catania } 2548e1b6cce24574b9ecd5b0300155776bd0b4ef756Nicolas Catania 2558e1b6cce24574b9ecd5b0300155776bd0b4ef756Nicolas Catania status_t getMetadata(bool update_only, bool apply_filter, Parcel *reply) 2568e1b6cce24574b9ecd5b0300155776bd0b4ef756Nicolas Catania { 2578e1b6cce24574b9ecd5b0300155776bd0b4ef756Nicolas Catania Parcel request; 2588e1b6cce24574b9ecd5b0300155776bd0b4ef756Nicolas Catania request.writeInterfaceToken(IMediaPlayer::getInterfaceDescriptor()); 2598e1b6cce24574b9ecd5b0300155776bd0b4ef756Nicolas Catania // TODO: Burning 2 ints for 2 boolean. Should probably use flags in an int here. 2608e1b6cce24574b9ecd5b0300155776bd0b4ef756Nicolas Catania request.writeInt32(update_only); 2618e1b6cce24574b9ecd5b0300155776bd0b4ef756Nicolas Catania request.writeInt32(apply_filter); 2628e1b6cce24574b9ecd5b0300155776bd0b4ef756Nicolas Catania remote()->transact(GET_METADATA, request, reply); 2638e1b6cce24574b9ecd5b0300155776bd0b4ef756Nicolas Catania return reply->readInt32(); 2648e1b6cce24574b9ecd5b0300155776bd0b4ef756Nicolas Catania } 2654e92c7efc68b5d7635a32dbd283ab8558ad9bdd6Andreas Huber 2662beeb50b1bba9e92f6cacfeca37fe9fa9d36ead1Eric Laurent status_t setAuxEffectSendLevel(float level) 2672beeb50b1bba9e92f6cacfeca37fe9fa9d36ead1Eric Laurent { 2682beeb50b1bba9e92f6cacfeca37fe9fa9d36ead1Eric Laurent Parcel data, reply; 2692beeb50b1bba9e92f6cacfeca37fe9fa9d36ead1Eric Laurent data.writeInterfaceToken(IMediaPlayer::getInterfaceDescriptor()); 2702beeb50b1bba9e92f6cacfeca37fe9fa9d36ead1Eric Laurent data.writeFloat(level); 2712beeb50b1bba9e92f6cacfeca37fe9fa9d36ead1Eric Laurent remote()->transact(SET_AUX_EFFECT_SEND_LEVEL, data, &reply); 2722beeb50b1bba9e92f6cacfeca37fe9fa9d36ead1Eric Laurent return reply.readInt32(); 2732beeb50b1bba9e92f6cacfeca37fe9fa9d36ead1Eric Laurent } 2742beeb50b1bba9e92f6cacfeca37fe9fa9d36ead1Eric Laurent 2752beeb50b1bba9e92f6cacfeca37fe9fa9d36ead1Eric Laurent status_t attachAuxEffect(int effectId) 2762beeb50b1bba9e92f6cacfeca37fe9fa9d36ead1Eric Laurent { 2772beeb50b1bba9e92f6cacfeca37fe9fa9d36ead1Eric Laurent Parcel data, reply; 2782beeb50b1bba9e92f6cacfeca37fe9fa9d36ead1Eric Laurent data.writeInterfaceToken(IMediaPlayer::getInterfaceDescriptor()); 2792beeb50b1bba9e92f6cacfeca37fe9fa9d36ead1Eric Laurent data.writeInt32(effectId); 2802beeb50b1bba9e92f6cacfeca37fe9fa9d36ead1Eric Laurent remote()->transact(ATTACH_AUX_EFFECT, data, &reply); 2812beeb50b1bba9e92f6cacfeca37fe9fa9d36ead1Eric Laurent return reply.readInt32(); 2822beeb50b1bba9e92f6cacfeca37fe9fa9d36ead1Eric Laurent } 2831173118eace0e9e347cb007f0da817cee87579edGlenn Kasten 2844f9e47f2c03ce36261c4717cd7e131d7940bb068Gloria Wang status_t setParameter(int key, const Parcel& request) 2854f9e47f2c03ce36261c4717cd7e131d7940bb068Gloria Wang { 2864f9e47f2c03ce36261c4717cd7e131d7940bb068Gloria Wang Parcel data, reply; 2874f9e47f2c03ce36261c4717cd7e131d7940bb068Gloria Wang data.writeInterfaceToken(IMediaPlayer::getInterfaceDescriptor()); 2884f9e47f2c03ce36261c4717cd7e131d7940bb068Gloria Wang data.writeInt32(key); 2894f9e47f2c03ce36261c4717cd7e131d7940bb068Gloria Wang if (request.dataSize() > 0) { 2904f9e47f2c03ce36261c4717cd7e131d7940bb068Gloria Wang data.appendFrom(const_cast<Parcel *>(&request), 0, request.dataSize()); 2914f9e47f2c03ce36261c4717cd7e131d7940bb068Gloria Wang } 2924f9e47f2c03ce36261c4717cd7e131d7940bb068Gloria Wang remote()->transact(SET_PARAMETER, data, &reply); 2934f9e47f2c03ce36261c4717cd7e131d7940bb068Gloria Wang return reply.readInt32(); 2944f9e47f2c03ce36261c4717cd7e131d7940bb068Gloria Wang } 2954f9e47f2c03ce36261c4717cd7e131d7940bb068Gloria Wang 2964f9e47f2c03ce36261c4717cd7e131d7940bb068Gloria Wang status_t getParameter(int key, Parcel *reply) 2974f9e47f2c03ce36261c4717cd7e131d7940bb068Gloria Wang { 2984f9e47f2c03ce36261c4717cd7e131d7940bb068Gloria Wang Parcel data; 2994f9e47f2c03ce36261c4717cd7e131d7940bb068Gloria Wang data.writeInterfaceToken(IMediaPlayer::getInterfaceDescriptor()); 3004f9e47f2c03ce36261c4717cd7e131d7940bb068Gloria Wang data.writeInt32(key); 3014f9e47f2c03ce36261c4717cd7e131d7940bb068Gloria Wang return remote()->transact(GET_PARAMETER, data, reply); 3024f9e47f2c03ce36261c4717cd7e131d7940bb068Gloria Wang } 3034f9e47f2c03ce36261c4717cd7e131d7940bb068Gloria Wang 30489fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project}; 30589fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project 30656f0cc533a38bdb84bc03adcb43515614ab21baenikoIMPLEMENT_META_INTERFACE(MediaPlayer, "android.media.IMediaPlayer"); 30789fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project 30889fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project// ---------------------------------------------------------------------- 30989fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project 31089fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Projectstatus_t BnMediaPlayer::onTransact( 31189fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags) 31289fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project{ 31389fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project switch(code) { 31489fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project case DISCONNECT: { 31589fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project CHECK_INTERFACE(IMediaPlayer, data, reply); 31689fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project disconnect(); 31789fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project return NO_ERROR; 31889fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project } break; 319d681bbb1767bed09415e050ba78975df214bcd68Dave Burke case SET_DATA_SOURCE_URL: { 320d681bbb1767bed09415e050ba78975df214bcd68Dave Burke CHECK_INTERFACE(IMediaPlayer, data, reply); 321d681bbb1767bed09415e050ba78975df214bcd68Dave Burke const char* url = data.readCString(); 322d681bbb1767bed09415e050ba78975df214bcd68Dave Burke KeyedVector<String8, String8> headers; 323d681bbb1767bed09415e050ba78975df214bcd68Dave Burke int32_t numHeaders = data.readInt32(); 324d681bbb1767bed09415e050ba78975df214bcd68Dave Burke for (int i = 0; i < numHeaders; ++i) { 325d681bbb1767bed09415e050ba78975df214bcd68Dave Burke String8 key = data.readString8(); 326d681bbb1767bed09415e050ba78975df214bcd68Dave Burke String8 value = data.readString8(); 327d681bbb1767bed09415e050ba78975df214bcd68Dave Burke headers.add(key, value); 328d681bbb1767bed09415e050ba78975df214bcd68Dave Burke } 329d681bbb1767bed09415e050ba78975df214bcd68Dave Burke reply->writeInt32(setDataSource(url, numHeaders > 0 ? &headers : NULL)); 330d681bbb1767bed09415e050ba78975df214bcd68Dave Burke return NO_ERROR; 331d681bbb1767bed09415e050ba78975df214bcd68Dave Burke } break; 332d681bbb1767bed09415e050ba78975df214bcd68Dave Burke case SET_DATA_SOURCE_FD: { 333d681bbb1767bed09415e050ba78975df214bcd68Dave Burke CHECK_INTERFACE(IMediaPlayer, data, reply); 334d681bbb1767bed09415e050ba78975df214bcd68Dave Burke int fd = data.readFileDescriptor(); 335d681bbb1767bed09415e050ba78975df214bcd68Dave Burke int64_t offset = data.readInt64(); 336d681bbb1767bed09415e050ba78975df214bcd68Dave Burke int64_t length = data.readInt64(); 337d681bbb1767bed09415e050ba78975df214bcd68Dave Burke reply->writeInt32(setDataSource(fd, offset, length)); 338d681bbb1767bed09415e050ba78975df214bcd68Dave Burke return NO_ERROR; 339d681bbb1767bed09415e050ba78975df214bcd68Dave Burke } 340d681bbb1767bed09415e050ba78975df214bcd68Dave Burke case SET_DATA_SOURCE_STREAM: { 341d681bbb1767bed09415e050ba78975df214bcd68Dave Burke CHECK_INTERFACE(IMediaPlayer, data, reply); 342d681bbb1767bed09415e050ba78975df214bcd68Dave Burke sp<IStreamSource> source = 343d681bbb1767bed09415e050ba78975df214bcd68Dave Burke interface_cast<IStreamSource>(data.readStrongBinder()); 344d681bbb1767bed09415e050ba78975df214bcd68Dave Burke reply->writeInt32(setDataSource(source)); 345d681bbb1767bed09415e050ba78975df214bcd68Dave Burke return NO_ERROR; 346d681bbb1767bed09415e050ba78975df214bcd68Dave Burke } 3475daeb129a2c2ba3d14ccd94af283b5f561c783eaAndreas Huber case SET_VIDEO_SURFACE: { 3485daeb129a2c2ba3d14ccd94af283b5f561c783eaAndreas Huber CHECK_INTERFACE(IMediaPlayer, data, reply); 3495daeb129a2c2ba3d14ccd94af283b5f561c783eaAndreas Huber sp<Surface> surface = Surface::readFromParcel(data); 35089fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project reply->writeInt32(setVideoSurface(surface)); 35189fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project return NO_ERROR; 35289fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project } break; 3531173118eace0e9e347cb007f0da817cee87579edGlenn Kasten case SET_VIDEO_SURFACETEXTURE: { 3541173118eace0e9e347cb007f0da817cee87579edGlenn Kasten CHECK_INTERFACE(IMediaPlayer, data, reply); 3551173118eace0e9e347cb007f0da817cee87579edGlenn Kasten sp<ISurfaceTexture> surfaceTexture = 3561173118eace0e9e347cb007f0da817cee87579edGlenn Kasten interface_cast<ISurfaceTexture>(data.readStrongBinder()); 3571173118eace0e9e347cb007f0da817cee87579edGlenn Kasten reply->writeInt32(setVideoSurfaceTexture(surfaceTexture)); 3581173118eace0e9e347cb007f0da817cee87579edGlenn Kasten return NO_ERROR; 3591173118eace0e9e347cb007f0da817cee87579edGlenn Kasten } break; 36089fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project case PREPARE_ASYNC: { 36189fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project CHECK_INTERFACE(IMediaPlayer, data, reply); 36289fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project reply->writeInt32(prepareAsync()); 36389fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project return NO_ERROR; 36489fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project } break; 36589fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project case START: { 36689fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project CHECK_INTERFACE(IMediaPlayer, data, reply); 36789fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project reply->writeInt32(start()); 36889fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project return NO_ERROR; 36989fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project } break; 37089fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project case STOP: { 37189fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project CHECK_INTERFACE(IMediaPlayer, data, reply); 37289fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project reply->writeInt32(stop()); 37389fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project return NO_ERROR; 37489fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project } break; 37589fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project case IS_PLAYING: { 37689fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project CHECK_INTERFACE(IMediaPlayer, data, reply); 37789fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project bool state; 37889fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project status_t ret = isPlaying(&state); 37989fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project reply->writeInt32(state); 38089fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project reply->writeInt32(ret); 38189fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project return NO_ERROR; 38289fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project } break; 38389fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project case PAUSE: { 38489fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project CHECK_INTERFACE(IMediaPlayer, data, reply); 38589fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project reply->writeInt32(pause()); 38689fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project return NO_ERROR; 38789fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project } break; 38889fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project case SEEK_TO: { 38989fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project CHECK_INTERFACE(IMediaPlayer, data, reply); 39089fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project reply->writeInt32(seekTo(data.readInt32())); 39189fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project return NO_ERROR; 39289fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project } break; 39389fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project case GET_CURRENT_POSITION: { 39489fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project CHECK_INTERFACE(IMediaPlayer, data, reply); 39589fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project int msec; 39689fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project status_t ret = getCurrentPosition(&msec); 39789fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project reply->writeInt32(msec); 39889fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project reply->writeInt32(ret); 39989fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project return NO_ERROR; 40089fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project } break; 40189fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project case GET_DURATION: { 40289fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project CHECK_INTERFACE(IMediaPlayer, data, reply); 40389fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project int msec; 40489fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project status_t ret = getDuration(&msec); 40589fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project reply->writeInt32(msec); 40689fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project reply->writeInt32(ret); 40789fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project return NO_ERROR; 40889fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project } break; 40989fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project case RESET: { 41089fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project CHECK_INTERFACE(IMediaPlayer, data, reply); 41189fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project reply->writeInt32(reset()); 41289fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project return NO_ERROR; 41389fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project } break; 41489fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project case SET_AUDIO_STREAM_TYPE: { 41589fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project CHECK_INTERFACE(IMediaPlayer, data, reply); 41689fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project reply->writeInt32(setAudioStreamType(data.readInt32())); 41789fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project return NO_ERROR; 41889fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project } break; 41989fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project case SET_LOOPING: { 42089fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project CHECK_INTERFACE(IMediaPlayer, data, reply); 42189fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project reply->writeInt32(setLooping(data.readInt32())); 42289fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project return NO_ERROR; 42389fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project } break; 42489fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project case SET_VOLUME: { 425172fb9ab347e146642234f0bd6f223d351e9fd0bDave Sparks CHECK_INTERFACE(IMediaPlayer, data, reply); 426de162ff337723798381890151247b129c4fbe314Gloria Wang float leftVolume = data.readFloat(); 427de162ff337723798381890151247b129c4fbe314Gloria Wang float rightVolume = data.readFloat(); 428de162ff337723798381890151247b129c4fbe314Gloria Wang reply->writeInt32(setVolume(leftVolume, rightVolume)); 42989fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project return NO_ERROR; 43089fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project } break; 4311d187f1a86855f5f0694d7ec30efc9833bf7c589Nicolas Catania case INVOKE: { 4321d187f1a86855f5f0694d7ec30efc9833bf7c589Nicolas Catania CHECK_INTERFACE(IMediaPlayer, data, reply); 433040e4a14ef9cafd5d08d9a180e6237fb79687995James Dong status_t result = invoke(data, reply); 434040e4a14ef9cafd5d08d9a180e6237fb79687995James Dong return result; 4351d187f1a86855f5f0694d7ec30efc9833bf7c589Nicolas Catania } break; 436a7e0e8b4c429fc68eb1bd5b5a30f5b91352288f9Nicolas Catania case SET_METADATA_FILTER: { 437a7e0e8b4c429fc68eb1bd5b5a30f5b91352288f9Nicolas Catania CHECK_INTERFACE(IMediaPlayer, data, reply); 438a7e0e8b4c429fc68eb1bd5b5a30f5b91352288f9Nicolas Catania reply->writeInt32(setMetadataFilter(data)); 439a7e0e8b4c429fc68eb1bd5b5a30f5b91352288f9Nicolas Catania return NO_ERROR; 440a7e0e8b4c429fc68eb1bd5b5a30f5b91352288f9Nicolas Catania } break; 4418e1b6cce24574b9ecd5b0300155776bd0b4ef756Nicolas Catania case GET_METADATA: { 4428e1b6cce24574b9ecd5b0300155776bd0b4ef756Nicolas Catania CHECK_INTERFACE(IMediaPlayer, data, reply); 443de162ff337723798381890151247b129c4fbe314Gloria Wang bool update_only = static_cast<bool>(data.readInt32()); 444de162ff337723798381890151247b129c4fbe314Gloria Wang bool apply_filter = static_cast<bool>(data.readInt32()); 445de162ff337723798381890151247b129c4fbe314Gloria Wang const status_t retcode = getMetadata(update_only, apply_filter, reply); 4468e1b6cce24574b9ecd5b0300155776bd0b4ef756Nicolas Catania reply->setDataPosition(0); 4478e1b6cce24574b9ecd5b0300155776bd0b4ef756Nicolas Catania reply->writeInt32(retcode); 4488e1b6cce24574b9ecd5b0300155776bd0b4ef756Nicolas Catania reply->setDataPosition(0); 4498e1b6cce24574b9ecd5b0300155776bd0b4ef756Nicolas Catania return NO_ERROR; 4508e1b6cce24574b9ecd5b0300155776bd0b4ef756Nicolas Catania } break; 4512beeb50b1bba9e92f6cacfeca37fe9fa9d36ead1Eric Laurent case SET_AUX_EFFECT_SEND_LEVEL: { 4522beeb50b1bba9e92f6cacfeca37fe9fa9d36ead1Eric Laurent CHECK_INTERFACE(IMediaPlayer, data, reply); 4532beeb50b1bba9e92f6cacfeca37fe9fa9d36ead1Eric Laurent reply->writeInt32(setAuxEffectSendLevel(data.readFloat())); 4542beeb50b1bba9e92f6cacfeca37fe9fa9d36ead1Eric Laurent return NO_ERROR; 4552beeb50b1bba9e92f6cacfeca37fe9fa9d36ead1Eric Laurent } break; 4562beeb50b1bba9e92f6cacfeca37fe9fa9d36ead1Eric Laurent case ATTACH_AUX_EFFECT: { 4572beeb50b1bba9e92f6cacfeca37fe9fa9d36ead1Eric Laurent CHECK_INTERFACE(IMediaPlayer, data, reply); 4582beeb50b1bba9e92f6cacfeca37fe9fa9d36ead1Eric Laurent reply->writeInt32(attachAuxEffect(data.readInt32())); 4592beeb50b1bba9e92f6cacfeca37fe9fa9d36ead1Eric Laurent return NO_ERROR; 4602beeb50b1bba9e92f6cacfeca37fe9fa9d36ead1Eric Laurent } break; 4614f9e47f2c03ce36261c4717cd7e131d7940bb068Gloria Wang case SET_PARAMETER: { 4624f9e47f2c03ce36261c4717cd7e131d7940bb068Gloria Wang CHECK_INTERFACE(IMediaPlayer, data, reply); 4634f9e47f2c03ce36261c4717cd7e131d7940bb068Gloria Wang int key = data.readInt32(); 4644f9e47f2c03ce36261c4717cd7e131d7940bb068Gloria Wang 4654f9e47f2c03ce36261c4717cd7e131d7940bb068Gloria Wang Parcel request; 4664f9e47f2c03ce36261c4717cd7e131d7940bb068Gloria Wang if (data.dataAvail() > 0) { 4674f9e47f2c03ce36261c4717cd7e131d7940bb068Gloria Wang request.appendFrom( 4684f9e47f2c03ce36261c4717cd7e131d7940bb068Gloria Wang const_cast<Parcel *>(&data), data.dataPosition(), data.dataAvail()); 4694f9e47f2c03ce36261c4717cd7e131d7940bb068Gloria Wang } 4704f9e47f2c03ce36261c4717cd7e131d7940bb068Gloria Wang request.setDataPosition(0); 4714f9e47f2c03ce36261c4717cd7e131d7940bb068Gloria Wang reply->writeInt32(setParameter(key, request)); 4724f9e47f2c03ce36261c4717cd7e131d7940bb068Gloria Wang return NO_ERROR; 4734f9e47f2c03ce36261c4717cd7e131d7940bb068Gloria Wang } break; 4744f9e47f2c03ce36261c4717cd7e131d7940bb068Gloria Wang case GET_PARAMETER: { 4754f9e47f2c03ce36261c4717cd7e131d7940bb068Gloria Wang CHECK_INTERFACE(IMediaPlayer, data, reply); 4764f9e47f2c03ce36261c4717cd7e131d7940bb068Gloria Wang return getParameter(data.readInt32(), reply); 4774f9e47f2c03ce36261c4717cd7e131d7940bb068Gloria Wang } break; 47889fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project default: 47989fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project return BBinder::onTransact(code, data, reply, flags); 48089fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project } 48189fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project} 48289fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project 48389fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project// ---------------------------------------------------------------------------- 48489fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project 48589fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project}; // namespace android 486