summaryrefslogtreecommitdiffstats
path: root/media/libstagefright/include
diff options
context:
space:
mode:
authorAndreas Huber <andih@google.com>2010-06-07 14:35:29 -0700
committerAndreas Huber <andih@google.com>2010-06-07 14:35:29 -0700
commite71d10e7ad55ccbcb0756c007caef1c959090384 (patch)
tree42991995bb9ec7c3017f4ad59a3fe761d7aaf772 /media/libstagefright/include
parentcda17c606b0fe3ccda4dc68a6d43882410ea2462 (diff)
downloadframeworks_av-e71d10e7ad55ccbcb0756c007caef1c959090384.zip
frameworks_av-e71d10e7ad55ccbcb0756c007caef1c959090384.tar.gz
frameworks_av-e71d10e7ad55ccbcb0756c007caef1c959090384.tar.bz2
Initial checkin of preliminary support for "http live" streaming in stagefright.
Change-Id: I20399f63d63af86a3ba22641c0e43385a108fb3f
Diffstat (limited to 'media/libstagefright/include')
-rw-r--r--media/libstagefright/include/LiveSource.h69
-rw-r--r--media/libstagefright/include/M3UParser.h71
2 files changed, 140 insertions, 0 deletions
diff --git a/media/libstagefright/include/LiveSource.h b/media/libstagefright/include/LiveSource.h
new file mode 100644
index 0000000..3218633
--- /dev/null
+++ b/media/libstagefright/include/LiveSource.h
@@ -0,0 +1,69 @@
+/*
+ * 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/Vector.h>
+
+namespace android {
+
+struct ABuffer;
+struct HTTPDataSource;
+struct M3UParser;
+
+struct LiveSource : public DataSource {
+ LiveSource(const char *url);
+
+ virtual status_t initCheck() const;
+
+ virtual ssize_t readAt(off_t offset, void *data, size_t size);
+
+ virtual uint32_t flags() {
+ return kWantsPrefetching;
+ }
+
+protected:
+ virtual ~LiveSource();
+
+private:
+ AString mURL;
+ status_t mInitCheck;
+
+ sp<M3UParser> mPlaylist;
+ int32_t mFirstItemSequenceNumber;
+ size_t mPlaylistIndex;
+ int64_t mLastFetchTimeUs;
+
+ sp<HTTPDataSource> mSource;
+ off_t mSourceSize;
+ off_t mOffsetBias;
+
+ status_t fetchM3U(const char *url, sp<ABuffer> *buffer);
+
+ bool switchToNext();
+ bool loadPlaylist();
+
+ DISALLOW_EVIL_CONSTRUCTORS(LiveSource);
+};
+
+} // namespace android
+
+#endif // LIVE_SOURCE_H_
diff --git a/media/libstagefright/include/M3UParser.h b/media/libstagefright/include/M3UParser.h
new file mode 100644
index 0000000..36553de
--- /dev/null
+++ b/media/libstagefright/include/M3UParser.h
@@ -0,0 +1,71 @@
+/*
+ * 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 M3U_PARSER_H_
+
+#define M3U_PARSER_H_
+
+#include <media/stagefright/foundation/ABase.h>
+#include <media/stagefright/foundation/AMessage.h>
+#include <media/stagefright/foundation/AString.h>
+#include <utils/Vector.h>
+
+namespace android {
+
+struct M3UParser : public RefBase {
+ M3UParser(const char *baseURI, const void *data, size_t size);
+
+ status_t initCheck() const;
+
+ bool isExtM3U() const;
+ bool isVariantPlaylist() const;
+
+ sp<AMessage> meta();
+
+ size_t size();
+ bool itemAt(size_t index, AString *uri, sp<AMessage> *meta = NULL);
+
+protected:
+ virtual ~M3UParser();
+
+private:
+ struct Item {
+ AString mURI;
+ sp<AMessage> mMeta;
+ };
+
+ status_t mInitCheck;
+
+ AString mBaseURI;
+ bool mIsExtM3U;
+ bool mIsVariantPlaylist;
+
+ sp<AMessage> mMeta;
+ Vector<Item> mItems;
+
+ status_t parse(const void *data, size_t size);
+
+ static status_t parseMetaData(
+ const AString &line, sp<AMessage> *meta, const char *key);
+
+ static status_t ParseInt32(const char *s, int32_t *x);
+
+ DISALLOW_EVIL_CONSTRUCTORS(M3UParser);
+};
+
+} // namespace android
+
+#endif // M3U_PARSER_H_