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 struct 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 38 struct IStreamListener : public IInterface { 39 DECLARE_META_INTERFACE(StreamListener); 40 41 enum Command { 42 EOS, 43 DISCONTINUITY, 44 }; 45 46 virtual void queueBuffer(size_t index, size_t size) = 0; 47 48 // 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 54 // When signalling a discontinuity you can optionally 55 // signal that this is a "hard" discontinuity, i.e. the format 56 // or configuration of subsequent stream data differs from that 57 // currently active. To do so, include a non-zero int32_t value 58 // under the key "kKeyFormatChange" when issuing the DISCONTINUITY 59 // command. 60 // The new logical stream must start with proper codec initialization 61 // information for playback to continue, i.e. SPS and PPS in the case 62 // of AVC video etc. 63 static const char *const kKeyFormatChange; 64 65 virtual void issueCommand( 66 Command cmd, bool synchronous, const sp<AMessage> &msg = NULL) = 0; 67 }; 68 69 //////////////////////////////////////////////////////////////////////////////// 70 71 struct BnStreamSource : public BnInterface<IStreamSource> { 72 virtual status_t onTransact( 73 uint32_t code, const Parcel &data, Parcel *reply, 74 uint32_t flags = 0); 75 }; 76 77 struct BnStreamListener : public BnInterface<IStreamListener> { 78 virtual status_t onTransact( 79 uint32_t code, const Parcel &data, Parcel *reply, 80 uint32_t flags = 0); 81 }; 82 83 } // namespace android 84 85 #endif // ANDROID_ISTREAMSOURCE_H_ 86