blob: 4a6aafd3ee9529e8239b9fbe121dd654cd209f4d [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;
Lajos Molnaree4e1b12015-04-17 13:46:19 -070026class IMemory;
Andreas Hubere2b10282010-11-23 11:41:34 -080027struct 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;
Andreas Huberda7ff532012-08-31 13:40:12 -070036
37 enum {
38 // Video PES packets contain exactly one (aligned) access unit.
39 kFlagAlignedVideoData = 1,
Andreas Huberd5e56232013-03-12 11:01:43 -070040
41 // Timestamps are in ALooper::GetNowUs() units.
42 kFlagIsRealTimeData = 2,
Andreas Huberda7ff532012-08-31 13:40:12 -070043 };
44 virtual uint32_t flags() const { return 0; }
Andreas Hubere2b10282010-11-23 11:41:34 -080045};
46
47struct IStreamListener : public IInterface {
48 DECLARE_META_INTERFACE(StreamListener);
49
50 enum Command {
Andreas Huber14acc732010-12-06 10:36:06 -080051 EOS,
Andreas Hubere2b10282010-11-23 11:41:34 -080052 DISCONTINUITY,
Andreas Hubere2b10282010-11-23 11:41:34 -080053 };
54
55 virtual void queueBuffer(size_t index, size_t size) = 0;
Andreas Huber14acc732010-12-06 10:36:06 -080056
Andreas Huber32f3cef2011-03-02 15:34:46 -080057 // When signalling a discontinuity you can optionally
58 // specify an int64_t PTS timestamp in "msg".
59 // If present, rendering of data following the discontinuity
60 // will be suppressed until media time reaches this timestamp.
61 static const char *const kKeyResumeAtPTS;
62
Andreas Huber42e549e2011-07-13 09:36:11 -070063 // When signalling a discontinuity you can optionally
Andreas Huberbfcc8d82011-11-29 11:57:35 -080064 // specify the type(s) of discontinuity, i.e. if the
65 // audio format has changed, the video format has changed,
66 // time has jumped or any combination thereof.
67 // To do so, include a non-zero int32_t value
68 // under the key "kKeyDiscontinuityMask" when issuing the DISCONTINUITY
Andreas Huber42e549e2011-07-13 09:36:11 -070069 // command.
Andreas Huberbfcc8d82011-11-29 11:57:35 -080070 // If there is a change in audio/video format, The new logical stream
71 // must start with proper codec initialization
Andreas Huber42e549e2011-07-13 09:36:11 -070072 // information for playback to continue, i.e. SPS and PPS in the case
73 // of AVC video etc.
Andreas Huberbfcc8d82011-11-29 11:57:35 -080074 // If this key is not present, only a time discontinuity is assumed.
75 // The value should be a bitmask of values from
76 // ATSParser::DiscontinuityType.
77 static const char *const kKeyDiscontinuityMask;
Andreas Huber42e549e2011-07-13 09:36:11 -070078
Andreas Huberb7c8e912012-11-27 15:02:53 -080079 // Optionally signalled as part of a discontinuity that includes
80 // DISCONTINUITY_TIME. It indicates the media time (in us) to be associated
81 // with the next PTS occuring in the stream. The value is of type int64_t.
82 static const char *const kKeyMediaTimeUs;
83
Chong Zhangd47dfcb2015-03-27 15:53:45 -070084 // Optionally signalled as part of a discontinuity that includes
85 // DISCONTINUITY_TIME. It indicates the media time (in us) of a recent
86 // sample from the same content, and is used as a hint for the parser to
87 // handle PTS wraparound. This is required when a new parser is created
88 // to continue parsing content from the same timeline.
89 static const char *const kKeyRecentMediaTimeUs;
90
Andreas Huber14acc732010-12-06 10:36:06 -080091 virtual void issueCommand(
92 Command cmd, bool synchronous, const sp<AMessage> &msg = NULL) = 0;
Andreas Hubere2b10282010-11-23 11:41:34 -080093};
94
95////////////////////////////////////////////////////////////////////////////////
96
97struct BnStreamSource : public BnInterface<IStreamSource> {
98 virtual status_t onTransact(
99 uint32_t code, const Parcel &data, Parcel *reply,
100 uint32_t flags = 0);
101};
102
103struct BnStreamListener : public BnInterface<IStreamListener> {
104 virtual status_t onTransact(
105 uint32_t code, const Parcel &data, Parcel *reply,
106 uint32_t flags = 0);
107};
108
109} // namespace android
110
111#endif // ANDROID_ISTREAMSOURCE_H_