OSDN Git Service

OpenSL ES: support decode to PCM buffer queue
[android-x86/system-media.git] / wilhelm / src / android / android_StreamPlayer.h
1 /*
2  * Copyright (C) 2010 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 #include <binder/IServiceManager.h>
18
19
20 //--------------------------------------------------------------------------------------------------
21 namespace android {
22
23
24 class StreamSourceAppProxy : public BnStreamSource {
25 public:
26     StreamSourceAppProxy(slAndroidBufferQueueCallback callback, void *appContext,
27             const void *caller);
28     virtual ~StreamSourceAppProxy();
29
30     // IStreamSource implementation
31     virtual void setListener(const sp<IStreamListener> &listener);
32     virtual void setBuffers(const Vector<sp<IMemory> > &buffers);
33     virtual void onBufferAvailable(size_t index);
34
35     void receivedFromAppCommand(IStreamListener::Command cmd);
36     void receivedFromAppBuffer(size_t buffIndex, size_t buffLength);
37
38 private:
39     Mutex mListenerLock;
40     sp<IStreamListener> mListener;
41     Vector<sp<IMemory> > mBuffers;
42
43     slAndroidBufferQueueCallback mCallback;
44     void *mAppContext;
45     const void *mCaller;
46
47     DISALLOW_EVIL_CONSTRUCTORS(StreamSourceAppProxy);
48 };
49
50
51 //--------------------------------------------------------------------------------------------------
52 class StreamPlayer : public AVPlayer
53 {
54 public:
55     StreamPlayer(AudioPlayback_Parameters* params);
56     virtual ~StreamPlayer();
57
58     void registerQueueCallback(slAndroidBufferQueueCallback callback, void *context,
59             const void *caller);
60     void appEnqueue(SLuint32 bufferId, SLuint32 length, SLAbufferQueueEvent event, void *pData);
61     void appClear();
62
63 protected:
64     sp<StreamSourceAppProxy> mAppProxy; // application proxy for the android buffer queue source
65
66     // overridden from AVPlayer
67     virtual void onPrepare();
68
69 private:
70     DISALLOW_EVIL_CONSTRUCTORS(StreamPlayer);
71 };
72
73 } // namespace android
74
75
76 //--------------------------------------------------------------------------------------------------
77 /*
78  * xxx_l functions are called with a lock on the CAudioPlayer mObject
79  */
80 extern void android_StreamPlayer_realize_l(CAudioPlayer *ap, const notif_cbf_t cbf,
81         void* notifUser);
82 extern void android_StreamPlayer_destroy(CAudioPlayer *ap);
83 extern void android_StreamPlayer_androidBufferQueue_registerCallback(
84         android::StreamPlayer *splr,
85         slAndroidBufferQueueCallback callback, void* context, const void* callerItf);
86 extern void android_StreamPlayer_enqueue_l(CAudioPlayer *ap,
87         SLuint32 bufferId, SLuint32 length, SLAbufferQueueEvent event, void *pData);
88 extern void android_StreamPlayer_clear_l(CAudioPlayer *ap);