summaryrefslogtreecommitdiffstats
path: root/media/libstagefright/include
diff options
context:
space:
mode:
authorAndreas Huber <andih@google.com>2010-12-03 16:12:25 -0800
committerAndreas Huber <andih@google.com>2010-12-06 08:28:36 -0800
commita44153c1a57202fb538659eb50706e60454d6273 (patch)
tree4ba43d350d44fb4bd052ce3c562c4a2ad6658270 /media/libstagefright/include
parent16afe2fb439cab6125bb46a07a8078d4ce1c1ea5 (diff)
downloadframeworks_av-a44153c1a57202fb538659eb50706e60454d6273.zip
frameworks_av-a44153c1a57202fb538659eb50706e60454d6273.tar.gz
frameworks_av-a44153c1a57202fb538659eb50706e60454d6273.tar.bz2
Squashed commit of the following:
commit 9254c845d7c82976fd4b8be406ce4b17eeb0e119 Author: Andreas Huber <andih@google.com> Date: Fri Dec 3 15:26:12 2010 -0800 Remove obsolete code from the cached data source. Change-Id: I794b986ac8977cbc834dff189221a636ba564e36 commit 2ee33711064c58c53ba65ed9e63dd4b01ec2380e Author: Andreas Huber <andih@google.com> Date: Fri Dec 3 15:23:13 2010 -0800 LiveSource is dead, long live LiveSession. Change-Id: Ibcd0731ecf9c94f0b3e5db3d53d012d9da2a1c66 commit 9eabb2c3cd8571ab859bdeae0aa7f655c414d8fa Author: Andreas Huber <andih@google.com> Date: Fri Dec 3 12:49:31 2010 -0800 Respect explicitly signalled discontinuities. Change-Id: I3c0c16a2de7a99742d25db7d1b2ff0258de52271 commit 7f7f7b6b906b6ece6e4d43af7fd5f494e805c5e5 Author: Andreas Huber <andih@google.com> Date: Fri Dec 3 11:45:57 2010 -0800 Better protection against syncword emulation in AAC ADTS content. Change-Id: I867e80a4556dd46d24ab3e781177c248a5221719 commit fe765766582efcc350aed01135ea603576adccf6 Author: Andreas Huber <andih@google.com> Date: Fri Dec 3 09:15:59 2010 -0800 New implementation of http live driving code. Change-Id: I31ddf3d6a0d5929b121be704a2b9c3d6775f7737 Change-Id: Id8d1829c8fcb173756965013f848c1d426ef1048
Diffstat (limited to 'media/libstagefright/include')
-rw-r--r--media/libstagefright/include/AwesomePlayer.h4
-rw-r--r--media/libstagefright/include/LiveSession.h115
-rw-r--r--media/libstagefright/include/LiveSource.h98
-rw-r--r--media/libstagefright/include/MPEG2TSExtractor.h6
-rw-r--r--media/libstagefright/include/NuCachedSource2.h6
5 files changed, 122 insertions, 107 deletions
diff --git a/media/libstagefright/include/AwesomePlayer.h b/media/libstagefright/include/AwesomePlayer.h
index 46f4a35..0c67432 100644
--- a/media/libstagefright/include/AwesomePlayer.h
+++ b/media/libstagefright/include/AwesomePlayer.h
@@ -45,6 +45,8 @@ struct UDPPusher;
class DrmManagerClinet;
class DecryptHandle;
+struct LiveSession;
+
struct AwesomeRenderer : public RefBase {
AwesomeRenderer() {}
@@ -193,6 +195,8 @@ private:
sp<ARTPSession> mRTPSession;
sp<UDPPusher> mRTPPusher, mRTCPPusher;
+ sp<LiveSession> mLiveSession;
+
DrmManagerClient *mDrmManagerClient;
DecryptHandle *mDecryptHandle;
diff --git a/media/libstagefright/include/LiveSession.h b/media/libstagefright/include/LiveSession.h
new file mode 100644
index 0000000..50c0a99
--- /dev/null
+++ b/media/libstagefright/include/LiveSession.h
@@ -0,0 +1,115 @@
+/*
+ * Copyright (C) 2010 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef LIVE_SESSION_H_
+
+#define LIVE_SESSION_H_
+
+#include <media/stagefright/foundation/AHandler.h>
+
+namespace android {
+
+struct ABuffer;
+struct DataSource;
+struct LiveDataSource;
+struct M3UParser;
+struct NuHTTPDataSource;
+
+struct LiveSession : public AHandler {
+ LiveSession();
+
+ sp<DataSource> getDataSource();
+
+ void connect(const char *url);
+ void disconnect();
+
+ // Blocks until seek is complete.
+ void seekTo(int64_t timeUs);
+
+ status_t getDuration(int64_t *durationUs);
+ bool isSeekable();
+
+protected:
+ virtual ~LiveSession();
+
+ virtual void onMessageReceived(const sp<AMessage> &msg);
+
+private:
+ enum {
+ kMaxNumQueuedFragments = 2,
+ kMaxNumRetries = 3,
+ };
+
+ static const int64_t kMaxPlaylistAgeUs;
+
+ enum {
+ kWhatConnect = 'conn',
+ kWhatDisconnect = 'disc',
+ kWhatMonitorQueue = 'moni',
+ kWhatSeek = 'seek',
+ };
+
+ struct BandwidthItem {
+ AString mURI;
+ unsigned long mBandwidth;
+ };
+
+ sp<LiveDataSource> mDataSource;
+
+ sp<NuHTTPDataSource> mHTTPDataSource;
+
+ AString mMasterURL;
+ Vector<BandwidthItem> mBandwidthItems;
+
+ KeyedVector<AString, sp<ABuffer> > mAESKeyForURI;
+
+ ssize_t mPrevBandwidthIndex;
+ int64_t mLastPlaylistFetchTimeUs;
+ sp<M3UParser> mPlaylist;
+ int32_t mSeqNumber;
+ int64_t mSeekTimeUs;
+ int32_t mNumRetries;
+
+ Mutex mLock;
+ Condition mCondition;
+ int64_t mDurationUs;
+ bool mSeekDone;
+
+ int32_t mMonitorQueueGeneration;
+
+ void onConnect(const sp<AMessage> &msg);
+ void onDisconnect();
+ void onDownloadNext();
+ void onMonitorQueue();
+ void onSeek(const sp<AMessage> &msg);
+
+ status_t fetchFile(const char *url, sp<ABuffer> *out);
+ sp<M3UParser> fetchPlaylist(const char *url);
+ size_t getBandwidthIndex();
+
+ status_t decryptBuffer(
+ size_t playlistIndex, const sp<ABuffer> &buffer);
+
+ void postMonitorQueue(int64_t delayUs = 0);
+
+ static int SortByBandwidth(const BandwidthItem *, const BandwidthItem *);
+
+ DISALLOW_EVIL_CONSTRUCTORS(LiveSession);
+};
+
+} // namespace android
+
+#endif // LIVE_SESSION_H_
diff --git a/media/libstagefright/include/LiveSource.h b/media/libstagefright/include/LiveSource.h
deleted file mode 100644
index 38fe328..0000000
--- a/media/libstagefright/include/LiveSource.h
+++ /dev/null
@@ -1,98 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef LIVE_SOURCE_H_
-
-#define LIVE_SOURCE_H_
-
-#include <media/stagefright/foundation/ABase.h>
-#include <media/stagefright/foundation/AString.h>
-#include <media/stagefright/DataSource.h>
-#include <utils/KeyedVector.h>
-#include <utils/Vector.h>
-
-namespace android {
-
-struct ABuffer;
-struct NuHTTPDataSource;
-struct M3UParser;
-
-struct LiveSource : public DataSource {
- LiveSource(const char *url);
-
- virtual status_t initCheck() const;
-
- virtual ssize_t readAt(off64_t offset, void *data, size_t size);
-
- virtual uint32_t flags() {
- return kWantsPrefetching;
- }
-
- bool getDuration(int64_t *durationUs) const;
-
- bool isSeekable() const;
- bool seekTo(int64_t seekTimeUs);
-
-protected:
- virtual ~LiveSource();
-
-private:
- struct BandwidthItem {
- AString mURI;
- unsigned long mBandwidth;
- };
- Vector<BandwidthItem> mBandwidthItems;
-
- AString mMasterURL;
- AString mURL;
- status_t mInitCheck;
- int64_t mDurationUs;
-
- sp<M3UParser> mPlaylist;
- int32_t mFirstItemSequenceNumber;
- size_t mPlaylistIndex;
- int64_t mLastFetchTimeUs;
-
- sp<NuHTTPDataSource> mSource;
- off64_t mSourceSize;
- off64_t mOffsetBias;
-
- bool mSignalDiscontinuity;
- ssize_t mPrevBandwidthIndex;
-
- void *mAESKey;
- unsigned char mAESIVec[16];
- bool mStreamEncrypted;
-
- KeyedVector<AString, sp<ABuffer> > mAESKeyForURI;
-
- status_t fetchM3U(const char *url, sp<ABuffer> *buffer);
-
- static int SortByBandwidth(const BandwidthItem *a, const BandwidthItem *b);
-
- bool switchToNext();
- bool loadPlaylist(bool fetchMaster, size_t bandwidthIndex);
- void determineSeekability();
-
- size_t getBandwidthIndex();
- bool setupCipher();
-
- DISALLOW_EVIL_CONSTRUCTORS(LiveSource);
-};
-
-} // namespace android
-
-#endif // LIVE_SOURCE_H_
diff --git a/media/libstagefright/include/MPEG2TSExtractor.h b/media/libstagefright/include/MPEG2TSExtractor.h
index 58401d4..efe7496 100644
--- a/media/libstagefright/include/MPEG2TSExtractor.h
+++ b/media/libstagefright/include/MPEG2TSExtractor.h
@@ -15,7 +15,7 @@ struct ATSParser;
struct DataSource;
struct MPEG2TSSource;
struct String8;
-struct LiveSource;
+struct LiveSession;
struct MPEG2TSExtractor : public MediaExtractor {
MPEG2TSExtractor(const sp<DataSource> &source);
@@ -28,7 +28,7 @@ struct MPEG2TSExtractor : public MediaExtractor {
virtual uint32_t flags() const;
- void setLiveSource(const sp<LiveSource> &liveSource);
+ void setLiveSession(const sp<LiveSession> &liveSession);
void seekTo(int64_t seekTimeUs);
private:
@@ -37,7 +37,7 @@ private:
mutable Mutex mLock;
sp<DataSource> mDataSource;
- sp<LiveSource> mLiveSource;
+ sp<LiveSession> mLiveSession;
sp<ATSParser> mParser;
diff --git a/media/libstagefright/include/NuCachedSource2.h b/media/libstagefright/include/NuCachedSource2.h
index f0f7daf..78719c1 100644
--- a/media/libstagefright/include/NuCachedSource2.h
+++ b/media/libstagefright/include/NuCachedSource2.h
@@ -45,9 +45,6 @@ struct NuCachedSource2 : public DataSource {
size_t cachedSize();
size_t approxDataRemaining(bool *eos);
- void suspend();
- void clearCacheAndResume();
-
void resumeFetchingIfNecessary();
protected:
@@ -69,7 +66,6 @@ private:
enum {
kWhatFetchMore = 'fetc',
kWhatRead = 'read',
- kWhatSuspend = 'susp',
};
sp<DataSource> mSource;
@@ -87,12 +83,10 @@ private:
sp<AMessage> mAsyncResult;
bool mFetching;
int64_t mLastFetchTimeUs;
- bool mSuspended;
void onMessageReceived(const sp<AMessage> &msg);
void onFetch();
void onRead(const sp<AMessage> &msg);
- void onSuspend();
void fetchInternal();
ssize_t readInternal(off64_t offset, void *data, size_t size);