• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
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 
26 namespace android {
27 
28 struct AnotherPacketSource;
29 struct ARTSPController;
30 struct DataSource;
31 struct MediaSource;
32 
33 struct NuPlayer::GenericSource : public NuPlayer::Source {
34     GenericSource(
35             const char *url,
36             const KeyedVector<String8, String8> *headers,
37             bool uidValid = false,
38             uid_t uid = 0);
39 
40     GenericSource(int fd, int64_t offset, int64_t length);
41 
42     virtual void start();
43 
44     virtual status_t feedMoreTSData();
45 
46     virtual sp<MetaData> getFormat(bool audio);
47     virtual status_t dequeueAccessUnit(bool audio, sp<ABuffer> *accessUnit);
48 
49     virtual status_t getDuration(int64_t *durationUs);
50     virtual status_t seekTo(int64_t seekTimeUs);
51     virtual bool isSeekable();
52 
53 protected:
54     virtual ~GenericSource();
55 
56 private:
57     struct Track {
58         sp<MediaSource> mSource;
59         sp<AnotherPacketSource> mPackets;
60     };
61 
62     Track mAudioTrack;
63     Track mVideoTrack;
64 
65     int64_t mDurationUs;
66     bool mAudioIsVorbis;
67 
68     void initFromDataSource(const sp<DataSource> &dataSource);
69 
70     void readBuffer(
71             bool audio,
72             int64_t seekTimeUs = -1ll, int64_t *actualTimeUs = NULL);
73 
74     DISALLOW_EVIL_CONSTRUCTORS(GenericSource);
75 };
76 
77 }  // namespace android
78 
79 #endif  // GENERIC_SOURCE_H_
80