blob: 4b89c38f7f4b95b0b6e1096dff71dd63846b88ee [file] [log] [blame]
Wei Jia53692fa2017-12-11 10:33:46 -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 STREAMING_SOURCE_H_
18
19#define STREAMING_SOURCE_H_
20
21#include "NuPlayer2.h"
22#include "NuPlayer2Source.h"
23
24namespace android {
25
26struct ABuffer;
27struct ATSParser;
28struct AnotherPacketSource;
29
30struct NuPlayer2::StreamingSource : public NuPlayer2::Source {
31 StreamingSource(
32 const sp<AMessage> &notify,
33 const sp<IStreamSource> &source);
34
35 virtual status_t getBufferingSettings(
36 BufferingSettings* buffering /* nonnull */) override;
37 virtual status_t setBufferingSettings(const BufferingSettings& buffering) override;
38
39 virtual void prepareAsync();
40 virtual void start();
41
42 virtual status_t feedMoreTSData();
43
44 virtual status_t dequeueAccessUnit(bool audio, sp<ABuffer> *accessUnit);
45
46 virtual bool isRealTime() const;
47
48protected:
49 virtual ~StreamingSource();
50
51 virtual void onMessageReceived(const sp<AMessage> &msg);
52
53 virtual sp<AMessage> getFormat(bool audio);
54
55private:
56 enum {
57 kWhatReadBuffer,
58 };
59 sp<IStreamSource> mSource;
60 status_t mFinalResult;
61 sp<StreamListener> mStreamListener;
62 sp<ATSParser> mTSParser;
63
64 bool mBuffering;
65 Mutex mBufferingLock;
66 sp<ALooper> mLooper;
67
68 void setError(status_t err);
69 sp<AnotherPacketSource> getSource(bool audio);
70 bool haveSufficientDataOnAllTracks();
71 status_t postReadBuffer();
72 void onReadBuffer();
73
74 DISALLOW_EVIL_CONSTRUCTORS(StreamingSource);
75};
76
77} // namespace android
78
79#endif // STREAMING_SOURCE_H_