blob: e0cd20fe4b31cdb44bc41728b18c01ee5746b5d7 [file] [log] [blame]
Andreas Huberafed0e12011-09-20 15:39:58 -07001/*
2 * Copyright (C) 2012 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 GENERIC_SOURCE_H_
18
19#define GENERIC_SOURCE_H_
20
21#include "NuPlayer.h"
22#include "NuPlayerSource.h"
23
24#include "ATSParser.h"
25
26namespace android {
27
28struct AnotherPacketSource;
29struct ARTSPController;
30struct DataSource;
31struct MediaSource;
32
33struct NuPlayer::GenericSource : public NuPlayer::Source {
34 GenericSource(
Andreas Huberb5f25f02013-02-05 10:14:26 -080035 const sp<AMessage> &notify,
Andreas Huber1b86fe02014-01-29 11:13:26 -080036 const sp<IMediaHTTPService> &httpService,
Andreas Huberafed0e12011-09-20 15:39:58 -070037 const char *url,
Andreas Huber81e68442014-02-05 11:52:33 -080038 const KeyedVector<String8, String8> *headers);
Andreas Huberafed0e12011-09-20 15:39:58 -070039
Andreas Huberb5f25f02013-02-05 10:14:26 -080040 GenericSource(
41 const sp<AMessage> &notify,
42 int fd, int64_t offset, int64_t length);
Andreas Huberafed0e12011-09-20 15:39:58 -070043
Andreas Huber9575c962013-02-05 13:59:56 -080044 virtual void prepareAsync();
45
Andreas Huberafed0e12011-09-20 15:39:58 -070046 virtual void start();
47
48 virtual status_t feedMoreTSData();
49
Andreas Huberafed0e12011-09-20 15:39:58 -070050 virtual status_t dequeueAccessUnit(bool audio, sp<ABuffer> *accessUnit);
51
52 virtual status_t getDuration(int64_t *durationUs);
Robert Shihdd235722014-06-12 14:49:23 -070053 virtual size_t getTrackCount() const;
54 virtual sp<AMessage> getTrackInfo(size_t trackIndex) const;
Andreas Huberafed0e12011-09-20 15:39:58 -070055 virtual status_t seekTo(int64_t seekTimeUs);
Andreas Huberb7c8e912012-11-27 15:02:53 -080056
Andreas Huberafed0e12011-09-20 15:39:58 -070057protected:
58 virtual ~GenericSource();
59
Andreas Huber84066782011-08-16 09:34:26 -070060 virtual sp<MetaData> getFormatMeta(bool audio);
61
Andreas Huberafed0e12011-09-20 15:39:58 -070062private:
Robert Shihdd235722014-06-12 14:49:23 -070063 Vector<sp<MediaSource> > mSources;
64
Andreas Huberafed0e12011-09-20 15:39:58 -070065 struct Track {
Robert Shihdd235722014-06-12 14:49:23 -070066 size_t mIndex;
Andreas Huberafed0e12011-09-20 15:39:58 -070067 sp<MediaSource> mSource;
68 sp<AnotherPacketSource> mPackets;
69 };
70
71 Track mAudioTrack;
72 Track mVideoTrack;
73
74 int64_t mDurationUs;
75 bool mAudioIsVorbis;
76
77 void initFromDataSource(const sp<DataSource> &dataSource);
78
79 void readBuffer(
80 bool audio,
81 int64_t seekTimeUs = -1ll, int64_t *actualTimeUs = NULL);
82
83 DISALLOW_EVIL_CONSTRUCTORS(GenericSource);
84};
85
86} // namespace android
87
88#endif // GENERIC_SOURCE_H_