Andreas Huber | e2b1028 | 2010-11-23 11:41:34 -0800 | [diff] [blame] | 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 | |
Andreas Huber | 14acc73 | 2010-12-06 10:36:06 -0800 | [diff] [blame] | 25 | struct AMessage; |
Andreas Huber | e2b1028 | 2010-11-23 11:41:34 -0800 | [diff] [blame] | 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; |
Andreas Huber | da7ff53 | 2012-08-31 13:40:12 -0700 | [diff] [blame] | 36 | |
| 37 | enum { |
| 38 | // Video PES packets contain exactly one (aligned) access unit. |
| 39 | kFlagAlignedVideoData = 1, |
| 40 | }; |
| 41 | virtual uint32_t flags() const { return 0; } |
Andreas Huber | e2b1028 | 2010-11-23 11:41:34 -0800 | [diff] [blame] | 42 | }; |
| 43 | |
| 44 | struct IStreamListener : public IInterface { |
| 45 | DECLARE_META_INTERFACE(StreamListener); |
| 46 | |
| 47 | enum Command { |
Andreas Huber | 14acc73 | 2010-12-06 10:36:06 -0800 | [diff] [blame] | 48 | EOS, |
Andreas Huber | e2b1028 | 2010-11-23 11:41:34 -0800 | [diff] [blame] | 49 | DISCONTINUITY, |
Andreas Huber | e2b1028 | 2010-11-23 11:41:34 -0800 | [diff] [blame] | 50 | }; |
| 51 | |
| 52 | virtual void queueBuffer(size_t index, size_t size) = 0; |
Andreas Huber | 14acc73 | 2010-12-06 10:36:06 -0800 | [diff] [blame] | 53 | |
Andreas Huber | 32f3cef | 2011-03-02 15:34:46 -0800 | [diff] [blame] | 54 | // When signalling a discontinuity you can optionally |
| 55 | // specify an int64_t PTS timestamp in "msg". |
| 56 | // If present, rendering of data following the discontinuity |
| 57 | // will be suppressed until media time reaches this timestamp. |
| 58 | static const char *const kKeyResumeAtPTS; |
| 59 | |
Andreas Huber | 42e549e | 2011-07-13 09:36:11 -0700 | [diff] [blame] | 60 | // When signalling a discontinuity you can optionally |
Andreas Huber | bfcc8d8 | 2011-11-29 11:57:35 -0800 | [diff] [blame] | 61 | // specify the type(s) of discontinuity, i.e. if the |
| 62 | // audio format has changed, the video format has changed, |
| 63 | // time has jumped or any combination thereof. |
| 64 | // To do so, include a non-zero int32_t value |
| 65 | // under the key "kKeyDiscontinuityMask" when issuing the DISCONTINUITY |
Andreas Huber | 42e549e | 2011-07-13 09:36:11 -0700 | [diff] [blame] | 66 | // command. |
Andreas Huber | bfcc8d8 | 2011-11-29 11:57:35 -0800 | [diff] [blame] | 67 | // If there is a change in audio/video format, The new logical stream |
| 68 | // must start with proper codec initialization |
Andreas Huber | 42e549e | 2011-07-13 09:36:11 -0700 | [diff] [blame] | 69 | // information for playback to continue, i.e. SPS and PPS in the case |
| 70 | // of AVC video etc. |
Andreas Huber | bfcc8d8 | 2011-11-29 11:57:35 -0800 | [diff] [blame] | 71 | // If this key is not present, only a time discontinuity is assumed. |
| 72 | // The value should be a bitmask of values from |
| 73 | // ATSParser::DiscontinuityType. |
| 74 | static const char *const kKeyDiscontinuityMask; |
Andreas Huber | 42e549e | 2011-07-13 09:36:11 -0700 | [diff] [blame] | 75 | |
Andreas Huber | b7c8e91 | 2012-11-27 15:02:53 -0800 | [diff] [blame^] | 76 | // Optionally signalled as part of a discontinuity that includes |
| 77 | // DISCONTINUITY_TIME. It indicates the media time (in us) to be associated |
| 78 | // with the next PTS occuring in the stream. The value is of type int64_t. |
| 79 | static const char *const kKeyMediaTimeUs; |
| 80 | |
Andreas Huber | 14acc73 | 2010-12-06 10:36:06 -0800 | [diff] [blame] | 81 | virtual void issueCommand( |
| 82 | Command cmd, bool synchronous, const sp<AMessage> &msg = NULL) = 0; |
Andreas Huber | e2b1028 | 2010-11-23 11:41:34 -0800 | [diff] [blame] | 83 | }; |
| 84 | |
| 85 | //////////////////////////////////////////////////////////////////////////////// |
| 86 | |
| 87 | struct BnStreamSource : public BnInterface<IStreamSource> { |
| 88 | virtual status_t onTransact( |
| 89 | uint32_t code, const Parcel &data, Parcel *reply, |
| 90 | uint32_t flags = 0); |
| 91 | }; |
| 92 | |
| 93 | struct BnStreamListener : public BnInterface<IStreamListener> { |
| 94 | virtual status_t onTransact( |
| 95 | uint32_t code, const Parcel &data, Parcel *reply, |
| 96 | uint32_t flags = 0); |
| 97 | }; |
| 98 | |
| 99 | } // namespace android |
| 100 | |
| 101 | #endif // ANDROID_ISTREAMSOURCE_H_ |