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 #ifndef ANDROID_ISTREAMSOURCE_H_
18 
19 #define ANDROID_ISTREAMSOURCE_H_
20 
21 #include <binder/IInterface.h>
22 
23 namespace android {
24 
25 struct AMessage;
26 class IMemory;
27 struct IStreamListener;
28 
29 struct IStreamSource : public IInterface {
30     DECLARE_META_INTERFACE(StreamSource);
31 
32     virtual void setListener(const sp<IStreamListener> &listener) = 0;
33     virtual void setBuffers(const Vector<sp<IMemory> > &buffers) = 0;
34 
35     virtual void onBufferAvailable(size_t index) = 0;
36 
37     enum {
38         // Video PES packets contain exactly one (aligned) access unit.
39         kFlagAlignedVideoData = 1,
40 
41         // Timestamps are in ALooper::GetNowUs() units.
42         kFlagIsRealTimeData   = 2,
43     };
flagsIStreamSource44     virtual uint32_t flags() const { return 0; }
45 };
46 
47 struct IStreamListener : public IInterface {
48     DECLARE_META_INTERFACE(StreamListener);
49 
50     enum Command {
51         EOS,
52         DISCONTINUITY,
53     };
54 
55     virtual void queueBuffer(size_t index, size_t size) = 0;
56 
57     virtual void issueCommand(
58             Command cmd, bool synchronous, const sp<AMessage> &msg = NULL) = 0;
59 };
60 
61 ////////////////////////////////////////////////////////////////////////////////
62 
63 struct BnStreamSource : public BnInterface<IStreamSource> {
64     virtual status_t onTransact(
65             uint32_t code, const Parcel &data, Parcel *reply,
66             uint32_t flags = 0);
67 };
68 
69 struct BnStreamListener : public BnInterface<IStreamListener> {
70     virtual status_t onTransact(
71             uint32_t code, const Parcel &data, Parcel *reply,
72             uint32_t flags = 0);
73 };
74 
75 }  // namespace android
76 
77 #endif  // ANDROID_ISTREAMSOURCE_H_
78