blob: 19646b0c9d06d8b755160c16839c57356bc8cb78 [file] [log] [blame]
Andreas Hubere2b10282010-11-23 11:41:34 -08001/*
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
23namespace android {
24
Andreas Huber14acc732010-12-06 10:36:06 -080025struct AMessage;
Andreas Hubere2b10282010-11-23 11:41:34 -080026struct IMemory;
27struct IStreamListener;
28
29struct 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
38struct IStreamListener : public IInterface {
39 DECLARE_META_INTERFACE(StreamListener);
40
41 enum Command {
Andreas Huber14acc732010-12-06 10:36:06 -080042 EOS,
Andreas Hubere2b10282010-11-23 11:41:34 -080043 DISCONTINUITY,
Andreas Hubere2b10282010-11-23 11:41:34 -080044 };
45
46 virtual void queueBuffer(size_t index, size_t size) = 0;
Andreas Huber14acc732010-12-06 10:36:06 -080047
Andreas Huber32f3cef2011-03-02 15:34:46 -080048 // When signalling a discontinuity you can optionally
49 // specify an int64_t PTS timestamp in "msg".
50 // If present, rendering of data following the discontinuity
51 // will be suppressed until media time reaches this timestamp.
52 static const char *const kKeyResumeAtPTS;
53
Andreas Huber42e549e2011-07-13 09:36:11 -070054 // When signalling a discontinuity you can optionally
Andreas Huberbfcc8d82011-11-29 11:57:35 -080055 // specify the type(s) of discontinuity, i.e. if the
56 // audio format has changed, the video format has changed,
57 // time has jumped or any combination thereof.
58 // To do so, include a non-zero int32_t value
59 // under the key "kKeyDiscontinuityMask" when issuing the DISCONTINUITY
Andreas Huber42e549e2011-07-13 09:36:11 -070060 // command.
Andreas Huberbfcc8d82011-11-29 11:57:35 -080061 // If there is a change in audio/video format, The new logical stream
62 // must start with proper codec initialization
Andreas Huber42e549e2011-07-13 09:36:11 -070063 // information for playback to continue, i.e. SPS and PPS in the case
64 // of AVC video etc.
Andreas Huberbfcc8d82011-11-29 11:57:35 -080065 // If this key is not present, only a time discontinuity is assumed.
66 // The value should be a bitmask of values from
67 // ATSParser::DiscontinuityType.
68 static const char *const kKeyDiscontinuityMask;
Andreas Huber42e549e2011-07-13 09:36:11 -070069
Andreas Huber14acc732010-12-06 10:36:06 -080070 virtual void issueCommand(
71 Command cmd, bool synchronous, const sp<AMessage> &msg = NULL) = 0;
Andreas Hubere2b10282010-11-23 11:41:34 -080072};
73
74////////////////////////////////////////////////////////////////////////////////
75
76struct BnStreamSource : public BnInterface<IStreamSource> {
77 virtual status_t onTransact(
78 uint32_t code, const Parcel &data, Parcel *reply,
79 uint32_t flags = 0);
80};
81
82struct BnStreamListener : public BnInterface<IStreamListener> {
83 virtual status_t onTransact(
84 uint32_t code, const Parcel &data, Parcel *reply,
85 uint32_t flags = 0);
86};
87
88} // namespace android
89
90#endif // ANDROID_ISTREAMSOURCE_H_