blob: 73aea6595de30020fb652374738ff9876595e152 [file] [log] [blame]
Dharmaray Kundargi643290d2011-01-16 16:02:42 -08001/*
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"
James Dongc9dedc42011-05-01 12:36:22 -070030#include "AudioPlayerBase.h"
31#include "PreviewPlayerBase.h"
Dharmaray Kundargi643290d2011-01-16 16:02:42 -080032
33namespace android {
34
35class MediaSource;
36class AudioTrack;
37class PreviewPlayer;
38
39
James Dongc9dedc42011-05-01 12:36:22 -070040class VideoEditorAudioPlayer : public AudioPlayerBase {
Dharmaray Kundargi643290d2011-01-16 16:02:42 -080041public:
42 enum {
43 REACHED_EOS,
44 SEEK_COMPLETE
45 };
46
47 VideoEditorAudioPlayer(const sp<MediaPlayerBase::AudioSink> &audioSink,
James Dongc9dedc42011-05-01 12:36:22 -070048 PreviewPlayerBase *audioObserver = NULL);
Dharmaray Kundargi643290d2011-01-16 16:02:42 -080049
50 virtual ~VideoEditorAudioPlayer();
51
52 status_t start(bool sourceAlreadyStarted = false);
Rajneesh Chowdury1c97d9a2011-02-21 15:43:33 -080053 void resume();
Dharmaray Kundargi643290d2011-01-16 16:02:42 -080054
55 void setAudioMixSettings(M4xVSS_AudioMixingSettings* pAudioMixSettings);
56 void setAudioMixPCMFileHandle(M4OSA_Context pBGAudioPCMFileHandle);
57 void setAudioMixStoryBoardSkimTimeStamp(
58 M4OSA_UInt32 pBGAudioStoryBoardSkimTimeStamp,
59 M4OSA_UInt32 pBGAudioCurrentMediaBeginCutTS,
60 M4OSA_UInt32 pBGAudioCurrentMediaVolumeVal);
61
James Dongc9dedc42011-05-01 12:36:22 -070062 void setObserver(PreviewPlayerBase *observer);
Rajneesh Chowdury1c97d9a2011-02-21 15:43:33 -080063 void setSource(const sp<MediaSource> &source);
64 sp<MediaSource> getSource();
65
66 bool isStarted();
Dharmaray Kundargi643290d2011-01-16 16:02:42 -080067private:
68
69 M4xVSS_AudioMixingSettings *mAudioMixSettings;
70 VideoEditorBGAudioProcessing *mAudioProcess;
71
72 M4OSA_Context mBGAudioPCMFileHandle;
73 int64_t mBGAudioPCMFileLength;
74 int64_t mBGAudioPCMFileTrimmedLength;
75 int64_t mBGAudioPCMFileDuration;
76 int64_t mBGAudioPCMFileSeekPoint;
77 int64_t mBGAudioPCMFileOriginalSeekPoint;
78 int64_t mBGAudioStoryBoardSkimTimeStamp;
79 int64_t mBGAudioStoryBoardCurrentMediaBeginCutTS;
80 int64_t mBGAudioStoryBoardCurrentMediaVolumeVal;
81
82 size_t fillBuffer(void *data, size_t size);
83
84 void reset();
85 void setPrimaryTrackVolume(M4OSA_Int16 *data, M4OSA_UInt32 size, M4OSA_Float volLevel);
86
87 static size_t AudioSinkCallback(
88 MediaPlayerBase::AudioSink *audioSink,
89 void *data, size_t size, void *me);
90
91 VideoEditorAudioPlayer(const VideoEditorAudioPlayer &);
92 VideoEditorAudioPlayer &operator=(const VideoEditorAudioPlayer &);
93};
94
95} // namespace android
96
97#endif // VE_AUDIO_PLAYER_H_