VideoEditorAudioPlayer.h revision 1c97d9ab52a288d24ea54499de435277cc1a3d68
1/* 2 * Copyright (C) 2011 NXP Software 3 * Copyright (C) 2011 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#ifndef VE_AUDIO_PLAYER_H_ 19 20#define VE_AUDIO_PLAYER_H_ 21 22#include <media/MediaPlayerInterface.h> 23#include <media/stagefright/MediaBuffer.h> 24#include <media/stagefright/TimeSource.h> 25#include <utils/threads.h> 26#include "M4xVSS_API.h" 27#include "VideoEditorMain.h" 28#include "M4OSA_FileReader.h" 29#include "VideoEditorBGAudioProcessing.h" 30#include <media/stagefright/AudioPlayer.h> 31 32namespace android { 33 34class MediaSource; 35class AudioTrack; 36class PreviewPlayer; 37 38 39class VideoEditorAudioPlayer : public AudioPlayer { 40public: 41 enum { 42 REACHED_EOS, 43 SEEK_COMPLETE 44 }; 45 46 VideoEditorAudioPlayer(const sp<MediaPlayerBase::AudioSink> &audioSink, 47 AwesomePlayer *audioObserver = NULL); 48 49 virtual ~VideoEditorAudioPlayer(); 50 51 status_t start(bool sourceAlreadyStarted = false); 52 void resume(); 53 54 void setAudioMixSettings(M4xVSS_AudioMixingSettings* pAudioMixSettings); 55 void setAudioMixPCMFileHandle(M4OSA_Context pBGAudioPCMFileHandle); 56 void setAudioMixStoryBoardSkimTimeStamp( 57 M4OSA_UInt32 pBGAudioStoryBoardSkimTimeStamp, 58 M4OSA_UInt32 pBGAudioCurrentMediaBeginCutTS, 59 M4OSA_UInt32 pBGAudioCurrentMediaVolumeVal); 60 61 void setObserver(AwesomePlayer *observer); 62 void setSource(const sp<MediaSource> &source); 63 sp<MediaSource> getSource(); 64 65 bool isStarted(); 66private: 67 68 M4xVSS_AudioMixingSettings *mAudioMixSettings; 69 VideoEditorBGAudioProcessing *mAudioProcess; 70 71 M4OSA_Context mBGAudioPCMFileHandle; 72 int64_t mBGAudioPCMFileLength; 73 int64_t mBGAudioPCMFileTrimmedLength; 74 int64_t mBGAudioPCMFileDuration; 75 int64_t mBGAudioPCMFileSeekPoint; 76 int64_t mBGAudioPCMFileOriginalSeekPoint; 77 int64_t mBGAudioStoryBoardSkimTimeStamp; 78 int64_t mBGAudioStoryBoardCurrentMediaBeginCutTS; 79 int64_t mBGAudioStoryBoardCurrentMediaVolumeVal; 80 81 size_t fillBuffer(void *data, size_t size); 82 83 void reset(); 84 void setPrimaryTrackVolume(M4OSA_Int16 *data, M4OSA_UInt32 size, M4OSA_Float volLevel); 85 86 static size_t AudioSinkCallback( 87 MediaPlayerBase::AudioSink *audioSink, 88 void *data, size_t size, void *me); 89 90 VideoEditorAudioPlayer(const VideoEditorAudioPlayer &); 91 VideoEditorAudioPlayer &operator=(const VideoEditorAudioPlayer &); 92}; 93 94} // namespace android 95 96#endif // VE_AUDIO_PLAYER_H_ 97