blob: b7eaa311c376d4db12a028689867e2a0376e2c27 [file] [log] [blame]
Dharmaray Kundargi643290d2011-01-16 16:02:42 -08001/*
Dharmaray Kundargi643290d2011-01-16 16:02:42 -08002 * 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"
James Dongc9dedc42011-05-01 12:36:22 -070029#include "AudioPlayerBase.h"
30#include "PreviewPlayerBase.h"
Dharmaray Kundargi643290d2011-01-16 16:02:42 -080031
32namespace android {
33
34class MediaSource;
35class AudioTrack;
36class PreviewPlayer;
37
38
James Dongc9dedc42011-05-01 12:36:22 -070039class VideoEditorAudioPlayer : public AudioPlayerBase {
Dharmaray Kundargi643290d2011-01-16 16:02:42 -080040public:
41 enum {
42 REACHED_EOS,
43 SEEK_COMPLETE
44 };
45
46 VideoEditorAudioPlayer(const sp<MediaPlayerBase::AudioSink> &audioSink,
James Dongc9dedc42011-05-01 12:36:22 -070047 PreviewPlayerBase *audioObserver = NULL);
Dharmaray Kundargi643290d2011-01-16 16:02:42 -080048
49 virtual ~VideoEditorAudioPlayer();
50
51 status_t start(bool sourceAlreadyStarted = false);
Rajneesh Chowdury1c97d9a2011-02-21 15:43:33 -080052 void resume();
Dharmaray Kundargi643290d2011-01-16 16:02:42 -080053
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
James Dongc9dedc42011-05-01 12:36:22 -070061 void setObserver(PreviewPlayerBase *observer);
Rajneesh Chowdury1c97d9a2011-02-21 15:43:33 -080062 void setSource(const sp<MediaSource> &source);
63 sp<MediaSource> getSource();
64
65 bool isStarted();
Dharmaray Kundargi643290d2011-01-16 16:02:42 -080066private:
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_