android_LocAVPlayer.cpp revision 68d56b8ebaf60184a3aef988e3d2b09ed8b88c05
1/* 2 * Copyright (C) 2011 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17//#define USE_LOG SLAndroidLogLevel_Verbose 18 19#include "sles_allinclusive.h" 20#include <media/IMediaPlayerService.h> 21 22 23namespace android { 24 25//-------------------------------------------------------------------------------------------------- 26LocAVPlayer::LocAVPlayer(AudioPlayback_Parameters* params, bool hasVideo) : 27 GenericMediaPlayer(params, hasVideo) 28{ 29 SL_LOGI("LocAVPlayer::LocAVPlayer()"); 30 31} 32 33 34LocAVPlayer::~LocAVPlayer() { 35 SL_LOGI("LocAVPlayer::~LocAVPlayer()"); 36 37} 38 39 40//-------------------------------------------------- 41// Event handlers 42void LocAVPlayer::onPrepare() { 43 SL_LOGI("LocAVPlayer::onPrepare()"); 44 switch (mDataLocatorType) { 45 case kDataLocatorUri: 46 mPlayer = mMediaPlayerService->create(getpid(), mPlayerClient /*IMediaPlayerClient*/, 47 mDataLocator.uriRef /*url*/, NULL /*headers*/, mPlaybackParams.sessionId); 48 break; 49 case kDataLocatorFd: 50 mPlayer = mMediaPlayerService->create(getpid(), mPlayerClient /*IMediaPlayerClient*/, 51 mDataLocator.fdi.fd, mDataLocator.fdi.offset, mDataLocator.fdi.length, 52 mPlaybackParams.sessionId); 53 break; 54 case kDataLocatorNone: 55 SL_LOGE("no data locator for MediaPlayer object"); 56 break; 57 default: 58 SL_LOGE("unsupported data locator %d for MediaPlayer object", mDataLocatorType); 59 break; 60 } 61 // blocks until mPlayer is prepared 62 GenericMediaPlayer::onPrepare(); 63 SL_LOGI("LocAVPlayer::onPrepare() done"); 64} 65 66} // namespace android 67