Chih-Chung Chang | 9969866 | 2011-06-30 14:21:38 +0800 | [diff] [blame^] | 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 | #ifndef VE_AUDIO_PLAYER_H_ |
| 18 | |
| 19 | #define VE_AUDIO_PLAYER_H_ |
| 20 | |
| 21 | #include <media/MediaPlayerInterface.h> |
| 22 | #include <media/stagefright/MediaBuffer.h> |
| 23 | #include <media/stagefright/TimeSource.h> |
| 24 | #include <utils/threads.h> |
| 25 | #include "M4xVSS_API.h" |
| 26 | #include "VideoEditorMain.h" |
| 27 | #include "M4OSA_FileReader.h" |
| 28 | #include "VideoEditorBGAudioProcessing.h" |
| 29 | #include "AudioPlayerBase.h" |
| 30 | #include "PreviewPlayerBase.h" |
| 31 | |
| 32 | namespace android { |
| 33 | |
| 34 | class MediaSource; |
| 35 | class AudioTrack; |
| 36 | class PreviewPlayer; |
| 37 | |
| 38 | |
| 39 | class VideoEditorAudioPlayer : public AudioPlayerBase { |
| 40 | public: |
| 41 | enum { |
| 42 | REACHED_EOS, |
| 43 | SEEK_COMPLETE |
| 44 | }; |
| 45 | |
| 46 | VideoEditorAudioPlayer(const sp<MediaPlayerBase::AudioSink> &audioSink, |
| 47 | PreviewPlayerBase *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(PreviewPlayerBase *observer); |
| 62 | void setSource(const sp<MediaSource> &source); |
| 63 | sp<MediaSource> getSource(); |
| 64 | |
| 65 | bool isStarted(); |
| 66 | private: |
| 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_ |