blob: 040eb36a7c7d3e60c9fe34cb220ccacd4313e973 [file] [log] [blame]
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -08001/*
2**
3** Copyright 2008, 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 ANDROID_VORBISPLAYER_H
19#define ANDROID_VORBISPLAYER_H
20
21#include <utils/threads.h>
22
23#include <media/MediaPlayerInterface.h>
24#include <media/AudioTrack.h>
25
26#include "ivorbiscodec.h"
27#include "ivorbisfile.h"
28
29#define ANDROID_LOOP_TAG "ANDROID_LOOP"
30
31namespace android {
32
33class VorbisPlayer : public MediaPlayerInterface {
34public:
35 VorbisPlayer();
36 ~VorbisPlayer();
37
38 virtual void onFirstRef();
39 virtual status_t initCheck();
40 virtual status_t setDataSource(const char* path);
41 virtual status_t setDataSource(int fd, int64_t offset, int64_t length);
42 virtual status_t setVideoSurface(const sp<ISurface>& surface) { return UNKNOWN_ERROR; }
43 virtual status_t prepare();
44 virtual status_t prepareAsync();
45 virtual status_t start();
46 virtual status_t stop();
47 virtual status_t seekTo(int msec);
48 virtual status_t pause();
49 virtual bool isPlaying();
50 virtual status_t getCurrentPosition(int* msec);
51 virtual status_t getDuration(int* msec);
52 virtual status_t release();
53 virtual status_t reset();
54 virtual status_t setLooping(int loop);
55 virtual player_type playerType() { return VORBIS_PLAYER; }
Nicolas Catania1d187f12009-05-12 23:25:55 -070056 virtual status_t invoke(const Parcel& request, Parcel *reply) {return INVALID_OPERATION;}
nikod608a812009-07-16 16:39:53 -070057 virtual status_t getMetadata(const SortedVector<MetadataType>& ids,
58 Parcel *records) {
59 return INVALID_OPERATION;
60 }
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -080061
62private:
63 status_t setdatasource(const char *path, int fd, int64_t offset, int64_t length);
64 status_t reset_nosync();
65 status_t createOutputTrack();
66 static int renderThread(void*);
67 int render();
68
69 static size_t vp_fread(void *, size_t, size_t, void *);
70 static int vp_fseek(void *, ogg_int64_t, int);
71 static int vp_fclose(void *);
72 static long vp_ftell(void *);
73
74 Mutex mMutex;
75 Condition mCondition;
76 FILE* mFile;
77 int64_t mOffset;
78 int64_t mLength;
79 OggVorbis_File mVorbisFile;
80 char* mAudioBuffer;
81 int mPlayTime;
82 int mDuration;
83 status_t mState;
84 int mStreamType;
85 bool mLoop;
86 bool mAndroidLoop;
87 volatile bool mExit;
88 bool mPaused;
89 volatile bool mRender;
90 pid_t mRenderTid;
91};
92
93}; // namespace android
94
95#endif // ANDROID_VORBISPLAYER_H