blob: 2da680c763fc5638b05ee7097afcb27302363bf3 [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 Huberafed0e12011-09-20 15:39:58 -070036 const char *url,
37 const KeyedVector<String8, String8> *headers,
38 bool uidValid = false,
39 uid_t uid = 0);
40
Andreas Huberb5f25f02013-02-05 10:14:26 -080041 GenericSource(
42 const sp<AMessage> &notify,
43 int fd, int64_t offset, int64_t length);
Andreas Huberafed0e12011-09-20 15:39:58 -070044
Andreas Huber9575c962013-02-05 13:59:56 -080045 virtual void prepareAsync();
46
Andreas Huberafed0e12011-09-20 15:39:58 -070047 virtual void start();
48
49 virtual status_t feedMoreTSData();
50
Andreas Huberafed0e12011-09-20 15:39:58 -070051 virtual status_t dequeueAccessUnit(bool audio, sp<ABuffer> *accessUnit);
52
53 virtual status_t getDuration(int64_t *durationUs);
54 virtual status_t seekTo(int64_t seekTimeUs);
Andreas Huberb7c8e912012-11-27 15:02:53 -080055
Andreas Huberafed0e12011-09-20 15:39:58 -070056protected:
57 virtual ~GenericSource();
58
Andreas Huber84066782011-08-16 09:34:26 -070059 virtual sp<MetaData> getFormatMeta(bool audio);
60
Andreas Huberafed0e12011-09-20 15:39:58 -070061private:
62 struct Track {
63 sp<MediaSource> mSource;
64 sp<AnotherPacketSource> mPackets;
65 };
66
67 Track mAudioTrack;
68 Track mVideoTrack;
69
70 int64_t mDurationUs;
71 bool mAudioIsVorbis;
72
73 void initFromDataSource(const sp<DataSource> &dataSource);
74
75 void readBuffer(
76 bool audio,
77 int64_t seekTimeUs = -1ll, int64_t *actualTimeUs = NULL);
78
79 DISALLOW_EVIL_CONSTRUCTORS(GenericSource);
80};
81
82} // namespace android
83
84#endif // GENERIC_SOURCE_H_