summaryrefslogtreecommitdiffstats
path: root/media/libstagefright/include
diff options
context:
space:
mode:
Diffstat (limited to 'media/libstagefright/include')
-rw-r--r--media/libstagefright/include/AACDecoder.h6
-rw-r--r--media/libstagefright/include/AACEncoder.h81
-rw-r--r--media/libstagefright/include/AMRExtractor.h4
-rw-r--r--media/libstagefright/include/AMRNBEncoder.h4
-rw-r--r--media/libstagefright/include/AMRWBEncoder.h72
-rw-r--r--media/libstagefright/include/ARTSPController.h92
-rw-r--r--media/libstagefright/include/AVCDecoder.h8
-rw-r--r--media/libstagefright/include/AVCEncoder.h91
-rw-r--r--media/libstagefright/include/AwesomePlayer.h46
-rw-r--r--media/libstagefright/include/DRMExtractor.h4
-rw-r--r--media/libstagefright/include/G711Decoder.h57
-rw-r--r--media/libstagefright/include/ID3.h1
-rw-r--r--media/libstagefright/include/LiveSource.h88
-rw-r--r--media/libstagefright/include/M3UParser.h76
-rw-r--r--media/libstagefright/include/M4vH263Decoder.h1
-rw-r--r--media/libstagefright/include/M4vH263Encoder.h81
-rw-r--r--media/libstagefright/include/MP3Decoder.h7
-rw-r--r--media/libstagefright/include/MP3Extractor.h11
-rw-r--r--media/libstagefright/include/MPEG2TSExtractor.h60
-rw-r--r--media/libstagefright/include/MPEG4Extractor.h4
-rw-r--r--media/libstagefright/include/NuCachedSource2.h104
-rw-r--r--media/libstagefright/include/NuHTTPDataSource.h73
-rw-r--r--media/libstagefright/include/OMX.h11
-rw-r--r--media/libstagefright/include/OggExtractor.h4
-rw-r--r--media/libstagefright/include/Prefetcher.h70
-rw-r--r--media/libstagefright/include/SampleTable.h18
-rw-r--r--media/libstagefright/include/ThreadedSource.h73
-rw-r--r--media/libstagefright/include/ThrottledSource.h52
-rw-r--r--media/libstagefright/include/VPXDecoder.h62
-rw-r--r--media/libstagefright/include/VorbisDecoder.h1
-rw-r--r--media/libstagefright/include/WAVExtractor.h5
-rw-r--r--media/libstagefright/include/avc_utils.h44
32 files changed, 1210 insertions, 101 deletions
diff --git a/media/libstagefright/include/AACDecoder.h b/media/libstagefright/include/AACDecoder.h
index f09addd..886a3b7 100644
--- a/media/libstagefright/include/AACDecoder.h
+++ b/media/libstagefright/include/AACDecoder.h
@@ -25,6 +25,7 @@ struct tPVMP4AudioDecoderExternal;
namespace android {
struct MediaBufferGroup;
+struct MetaData;
struct AACDecoder : public MediaSource {
AACDecoder(const sp<MediaSource> &source);
@@ -41,6 +42,7 @@ protected:
virtual ~AACDecoder();
private:
+ sp<MetaData> mMeta;
sp<MediaSource> mSource;
bool mStarted;
@@ -50,9 +52,13 @@ private:
void *mDecoderBuf;
int64_t mAnchorTimeUs;
int64_t mNumSamplesOutput;
+ status_t mInitCheck;
+ int64_t mNumDecodedBuffers;
+ int32_t mUpsamplingFactor;
MediaBuffer *mInputBuffer;
+ status_t initCheck();
AACDecoder(const AACDecoder &);
AACDecoder &operator=(const AACDecoder &);
};
diff --git a/media/libstagefright/include/AACEncoder.h b/media/libstagefright/include/AACEncoder.h
new file mode 100644
index 0000000..ecc533f
--- /dev/null
+++ b/media/libstagefright/include/AACEncoder.h
@@ -0,0 +1,81 @@
+/*
+ * 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 AAC_ENCODER_H
+#define AAC_ENCODER_H
+
+#include <media/stagefright/MediaSource.h>
+#include <media/stagefright/MetaData.h>
+
+struct VO_AUDIO_CODECAPI;
+struct VO_MEM_OPERATOR;
+
+namespace android {
+
+struct MediaBufferGroup;
+
+class AACEncoder: public MediaSource {
+ public:
+ AACEncoder(const sp<MediaSource> &source, const sp<MetaData> &meta);
+
+ virtual status_t start(MetaData *params);
+ virtual status_t stop();
+ virtual sp<MetaData> getFormat();
+ virtual status_t read(
+ MediaBuffer **buffer, const ReadOptions *options);
+
+
+ protected:
+ virtual ~AACEncoder();
+
+ private:
+ sp<MediaSource> mSource;
+ sp<MetaData> mMeta;
+ bool mStarted;
+ MediaBufferGroup *mBufferGroup;
+ MediaBuffer *mInputBuffer;
+ status_t mInitCheck;
+ int32_t mSampleRate;
+ int32_t mChannels;
+ int32_t mBitRate;
+ int32_t mFrameCount;
+
+ int64_t mAnchorTimeUs;
+ int64_t mNumInputSamples;
+
+ enum {
+ kNumSamplesPerFrame = 1024,
+ };
+
+ int16_t mInputFrame[kNumSamplesPerFrame];
+
+ uint8_t mAudioSpecificConfigData[2]; // auido specific data
+ void *mEncoderHandle;
+ VO_AUDIO_CODECAPI *mApiHandle;
+ VO_MEM_OPERATOR *mMemOperator;
+
+ status_t setAudioSpecificConfigData();
+ status_t initCheck();
+
+ AACEncoder& operator=(const AACEncoder &rhs);
+ AACEncoder(const AACEncoder& copy);
+
+};
+
+}
+
+#endif //#ifndef AAC_ENCODER_H
+
diff --git a/media/libstagefright/include/AMRExtractor.h b/media/libstagefright/include/AMRExtractor.h
index db49fe4..1cdf36d 100644
--- a/media/libstagefright/include/AMRExtractor.h
+++ b/media/libstagefright/include/AMRExtractor.h
@@ -22,6 +22,7 @@
namespace android {
+struct AMessage;
class String8;
class AMRExtractor : public MediaExtractor {
@@ -49,7 +50,8 @@ private:
};
bool SniffAMR(
- const sp<DataSource> &source, String8 *mimeType, float *confidence);
+ const sp<DataSource> &source, String8 *mimeType, float *confidence,
+ sp<AMessage> *);
} // namespace android
diff --git a/media/libstagefright/include/AMRNBEncoder.h b/media/libstagefright/include/AMRNBEncoder.h
index 7167c00..71160e6 100644
--- a/media/libstagefright/include/AMRNBEncoder.h
+++ b/media/libstagefright/include/AMRNBEncoder.h
@@ -19,13 +19,14 @@
#define AMR_NB_ENCODER_H_
#include <media/stagefright/MediaSource.h>
+#include <media/stagefright/MetaData.h>
namespace android {
struct MediaBufferGroup;
struct AMRNBEncoder : public MediaSource {
- AMRNBEncoder(const sp<MediaSource> &source);
+ AMRNBEncoder(const sp<MediaSource> &source, const sp<MetaData> &meta);
virtual status_t start(MetaData *params);
virtual status_t stop();
@@ -40,6 +41,7 @@ protected:
private:
sp<MediaSource> mSource;
+ sp<MetaData> mMeta;
bool mStarted;
MediaBufferGroup *mBufferGroup;
diff --git a/media/libstagefright/include/AMRWBEncoder.h b/media/libstagefright/include/AMRWBEncoder.h
new file mode 100644
index 0000000..f2d155f
--- /dev/null
+++ b/media/libstagefright/include/AMRWBEncoder.h
@@ -0,0 +1,72 @@
+/*
+ * 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 AMR_WB_ENCODER_H
+#define AMR_WB_ENCODER_H
+
+#include <media/stagefright/MediaSource.h>
+#include <media/stagefright/MetaData.h>
+
+struct VO_AUDIO_CODECAPI;
+struct VO_MEM_OPERATOR;
+
+namespace android {
+
+struct MediaBufferGroup;
+
+class AMRWBEncoder: public MediaSource {
+ public:
+ AMRWBEncoder(const sp<MediaSource> &source, const sp<MetaData> &meta);
+
+ virtual status_t start(MetaData *params);
+ virtual status_t stop();
+ virtual sp<MetaData> getFormat();
+ virtual status_t read(
+ MediaBuffer **buffer, const ReadOptions *options);
+
+
+ protected:
+ virtual ~AMRWBEncoder();
+
+ private:
+ sp<MediaSource> mSource;
+ sp<MetaData> mMeta;
+ bool mStarted;
+ MediaBufferGroup *mBufferGroup;
+ MediaBuffer *mInputBuffer;
+ status_t mInitCheck;
+ int32_t mBitRate;
+ void *mEncoderHandle;
+ VO_AUDIO_CODECAPI *mApiHandle;
+ VO_MEM_OPERATOR *mMemOperator;
+
+ int64_t mAnchorTimeUs;
+ int64_t mNumFramesOutput;
+
+ int16_t mInputFrame[320];
+ int32_t mNumInputSamples;
+
+ status_t initCheck();
+
+ AMRWBEncoder& operator=(const AMRWBEncoder &rhs);
+ AMRWBEncoder(const AMRWBEncoder& copy);
+
+};
+
+}
+
+#endif //#ifndef AMR_WB_ENCODER_H
+
diff --git a/media/libstagefright/include/ARTSPController.h b/media/libstagefright/include/ARTSPController.h
new file mode 100644
index 0000000..ce7ffe5
--- /dev/null
+++ b/media/libstagefright/include/ARTSPController.h
@@ -0,0 +1,92 @@
+/*
+ * 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 A_RTSP_CONTROLLER_H_
+
+#define A_RTSP_CONTROLLER_H_
+
+#include <media/stagefright/foundation/ABase.h>
+#include <media/stagefright/foundation/AHandlerReflector.h>
+#include <media/stagefright/MediaExtractor.h>
+
+namespace android {
+
+struct ALooper;
+struct MyHandler;
+
+struct ARTSPController : public MediaExtractor {
+ ARTSPController(const sp<ALooper> &looper);
+
+ status_t connect(const char *url);
+ void disconnect();
+
+ void seekAsync(int64_t timeUs, void (*seekDoneCb)(void *), void *cookie);
+
+ virtual size_t countTracks();
+ virtual sp<MediaSource> getTrack(size_t index);
+
+ virtual sp<MetaData> getTrackMetaData(
+ size_t index, uint32_t flags);
+
+ int64_t getNormalPlayTimeUs();
+ int64_t getQueueDurationUs(bool *eos);
+
+ void onMessageReceived(const sp<AMessage> &msg);
+
+ virtual uint32_t flags() const {
+ // Seeking 10secs forward or backward is a very expensive operation
+ // for rtsp, so let's not enable that.
+ // The user can always use the seek bar.
+
+ return CAN_PAUSE | CAN_SEEK;
+ }
+
+protected:
+ virtual ~ARTSPController();
+
+private:
+ enum {
+ kWhatConnectDone = 'cdon',
+ kWhatDisconnectDone = 'ddon',
+ kWhatSeekDone = 'sdon',
+ };
+
+ enum State {
+ DISCONNECTED,
+ CONNECTED,
+ CONNECTING,
+ };
+
+ Mutex mLock;
+ Condition mCondition;
+
+ State mState;
+ status_t mConnectionResult;
+
+ sp<ALooper> mLooper;
+ sp<MyHandler> mHandler;
+ sp<AHandlerReflector<ARTSPController> > mReflector;
+
+ void (*mSeekDoneCb)(void *);
+ void *mSeekDoneCookie;
+ int64_t mLastSeekCompletedTimeUs;
+
+ DISALLOW_EVIL_CONSTRUCTORS(ARTSPController);
+};
+
+} // namespace android
+
+#endif // A_RTSP_CONTROLLER_H_
diff --git a/media/libstagefright/include/AVCDecoder.h b/media/libstagefright/include/AVCDecoder.h
index 621aa9a..eb3b142 100644
--- a/media/libstagefright/include/AVCDecoder.h
+++ b/media/libstagefright/include/AVCDecoder.h
@@ -58,6 +58,12 @@ private:
int64_t mAnchorTimeUs;
int64_t mNumSamplesOutput;
int64_t mPendingSeekTimeUs;
+ MediaSource::ReadOptions::SeekMode mPendingSeekMode;
+
+ int64_t mTargetTimeUs;
+
+ bool mSPSSeen;
+ bool mPPSSeen;
void addCodecSpecificData(const uint8_t *data, size_t size);
@@ -76,6 +82,8 @@ private:
void releaseFrames();
+ MediaBuffer *drainOutputBuffer();
+
AVCDecoder(const AVCDecoder &);
AVCDecoder &operator=(const AVCDecoder &);
};
diff --git a/media/libstagefright/include/AVCEncoder.h b/media/libstagefright/include/AVCEncoder.h
new file mode 100644
index 0000000..83e1f97
--- /dev/null
+++ b/media/libstagefright/include/AVCEncoder.h
@@ -0,0 +1,91 @@
+/*
+ * 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 AVC_ENCODER_H_
+
+#define AVC_ENCODER_H_
+
+#include <media/stagefright/MediaBuffer.h>
+#include <media/stagefright/MediaSource.h>
+#include <utils/Vector.h>
+
+struct tagAVCHandle;
+struct tagAVCEncParam;
+
+namespace android {
+
+struct MediaBuffer;
+struct MediaBufferGroup;
+
+struct AVCEncoder : public MediaSource,
+ public MediaBufferObserver {
+ AVCEncoder(const sp<MediaSource> &source,
+ const sp<MetaData>& meta);
+
+ virtual status_t start(MetaData *params);
+ virtual status_t stop();
+
+ virtual sp<MetaData> getFormat();
+
+ virtual status_t read(
+ MediaBuffer **buffer, const ReadOptions *options);
+
+ virtual void signalBufferReturned(MediaBuffer *buffer);
+
+ // Callbacks required by the encoder
+ int32_t allocOutputBuffers(unsigned int sizeInMbs, unsigned int numBuffers);
+ void unbindOutputBuffer(int32_t index);
+ int32_t bindOutputBuffer(int32_t index, uint8_t **yuv);
+
+protected:
+ virtual ~AVCEncoder();
+
+private:
+ sp<MediaSource> mSource;
+ sp<MetaData> mFormat;
+ sp<MetaData> mMeta;
+
+ int32_t mVideoWidth;
+ int32_t mVideoHeight;
+ int32_t mVideoFrameRate;
+ int32_t mVideoBitRate;
+ int32_t mVideoColorFormat;
+ int64_t mNumInputFrames;
+ int64_t mPrevTimestampUs;
+ status_t mInitCheck;
+ bool mStarted;
+ bool mSpsPpsHeaderReceived;
+ bool mReadyForNextFrame;
+ int32_t mIsIDRFrame; // for set kKeyIsSyncFrame
+
+ tagAVCHandle *mHandle;
+ tagAVCEncParam *mEncParams;
+ MediaBuffer *mInputBuffer;
+ uint8_t *mInputFrameData;
+ MediaBufferGroup *mGroup;
+ Vector<MediaBuffer *> mOutputBuffers;
+
+
+ status_t initCheck(const sp<MetaData>& meta);
+ void releaseOutputBuffers();
+
+ AVCEncoder(const AVCEncoder &);
+ AVCEncoder &operator=(const AVCEncoder &);
+};
+
+} // namespace android
+
+#endif // AVC_ENCODER_H_
diff --git a/media/libstagefright/include/AwesomePlayer.h b/media/libstagefright/include/AwesomePlayer.h
index f0fd0f2..4526bf1 100644
--- a/media/libstagefright/include/AwesomePlayer.h
+++ b/media/libstagefright/include/AwesomePlayer.h
@@ -18,12 +18,13 @@
#define AWESOME_PLAYER_H_
+#include "NuHTTPDataSource.h"
#include "TimedEventQueue.h"
#include <media/MediaPlayerInterface.h>
#include <media/stagefright/DataSource.h>
-#include <media/stagefright/HTTPDataSource.h>
#include <media/stagefright/OMXClient.h>
+#include <media/stagefright/TimeSource.h>
#include <utils/threads.h>
#include <drm/DrmManagerClient.h>
@@ -34,8 +35,13 @@ struct DataSource;
struct MediaBuffer;
struct MediaExtractor;
struct MediaSource;
-struct Prefetcher;
-struct TimeSource;
+struct NuCachedSource2;
+
+struct ALooper;
+struct ARTSPController;
+struct ARTPSession;
+struct UDPPusher;
+
class DrmManagerClinet;
class DecryptHandle;
@@ -90,6 +96,9 @@ struct AwesomePlayer {
// This is a mask of MediaExtractor::Flags.
uint32_t flags() const;
+ void postAudioEOS();
+ void postAudioSeekComplete();
+
private:
friend struct AwesomeEvent;
@@ -101,6 +110,10 @@ private:
PREPARED = 16,
AT_EOS = 32,
PREPARE_CANCELLED = 64,
+ CACHE_UNDERRUN = 128,
+ AUDIO_AT_EOS = 256,
+ VIDEO_AT_EOS = 512,
+ AUTO_LOOPING = 1024,
};
mutable Mutex mLock;
@@ -114,6 +127,7 @@ private:
sp<ISurface> mISurface;
sp<MediaPlayerBase::AudioSink> mAudioSink;
+ SystemTimeSource mSystemTimeSource;
TimeSource *mTimeSource;
String8 mUri;
@@ -142,6 +156,8 @@ private:
bool mSeekNotificationSent;
int64_t mSeekTimeUs;
+ int64_t mBitrate; // total bitrate of the file (in bps) or -1 if unknown.
+
bool mWatchForAudioSeekComplete;
bool mWatchForAudioEOS;
@@ -169,8 +185,13 @@ private:
MediaBuffer *mLastVideoBuffer;
MediaBuffer *mVideoBuffer;
- sp<Prefetcher> mPrefetcher;
- sp<HTTPDataSource> mConnectingDataSource;
+ sp<NuHTTPDataSource> mConnectingDataSource;
+ sp<NuCachedSource2> mCachedSource;
+
+ sp<ALooper> mLooper;
+ sp<ARTSPController> mRTSPController;
+ sp<ARTPSession> mRTPSession;
+ sp<UDPPusher> mRTPPusher, mRTCPPusher;
struct SuspensionState {
String8 mUri;
@@ -208,8 +229,9 @@ private:
status_t setDataSource_l(const sp<DataSource> &dataSource);
status_t setDataSource_l(const sp<MediaExtractor> &extractor);
void reset_l();
+ void partial_reset_l();
status_t seekTo_l(int64_t timeUs);
- status_t pause_l();
+ status_t pause_l(bool at_eos = false);
void initRenderer_l();
void seekAudioIfNecessary_l();
@@ -219,7 +241,7 @@ private:
status_t initAudioDecoder();
void setVideoSource(sp<MediaSource> source);
- status_t initVideoDecoder();
+ status_t initVideoDecoder(uint32_t flags = 0);
void onStreamDone();
@@ -230,11 +252,21 @@ private:
void onCheckAudioStatus();
void onPrepareAsyncEvent();
void abortPrepare(status_t err);
+ void finishAsyncPrepare_l();
+
+ bool getCachedDuration_l(int64_t *durationUs, bool *eos);
status_t finishSetDataSource_l();
static bool ContinuePreparation(void *cookie);
+ static void OnRTSPSeekDoneWrapper(void *cookie);
+ void onRTSPSeekDone();
+
+ bool getBitrate(int64_t *bitrate);
+
+ void finishSeekIfNecessary(int64_t videoTimeUs);
+
AwesomePlayer(const AwesomePlayer &);
AwesomePlayer &operator=(const AwesomePlayer &);
};
diff --git a/media/libstagefright/include/DRMExtractor.h b/media/libstagefright/include/DRMExtractor.h
index 01e226e..cafc812 100644
--- a/media/libstagefright/include/DRMExtractor.h
+++ b/media/libstagefright/include/DRMExtractor.h
@@ -23,6 +23,7 @@
namespace android {
+struct AMessage;
class DataSource;
class SampleTable;
class String8;
@@ -51,7 +52,8 @@ private:
};
bool SniffDRM(
- const sp<DataSource> &source, String8 *mimeType, float *confidence);
+ const sp<DataSource> &source, String8 *mimeType, float *confidence,
+ sp<AMessage> *);
} // namespace android
diff --git a/media/libstagefright/include/G711Decoder.h b/media/libstagefright/include/G711Decoder.h
new file mode 100644
index 0000000..8b5143a
--- /dev/null
+++ b/media/libstagefright/include/G711Decoder.h
@@ -0,0 +1,57 @@
+/*
+ * 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 G711_DECODER_H_
+
+#define G711_DECODER_H_
+
+#include <media/stagefright/MediaSource.h>
+
+namespace android {
+
+struct MediaBufferGroup;
+
+struct G711Decoder : public MediaSource {
+ G711Decoder(const sp<MediaSource> &source);
+
+ virtual status_t start(MetaData *params);
+ virtual status_t stop();
+
+ virtual sp<MetaData> getFormat();
+
+ virtual status_t read(
+ MediaBuffer **buffer, const ReadOptions *options);
+
+protected:
+ virtual ~G711Decoder();
+
+private:
+ sp<MediaSource> mSource;
+ bool mStarted;
+ bool mIsMLaw;
+
+ MediaBufferGroup *mBufferGroup;
+
+ static void DecodeALaw(int16_t *out, const uint8_t *in, size_t inSize);
+ static void DecodeMLaw(int16_t *out, const uint8_t *in, size_t inSize);
+
+ G711Decoder(const G711Decoder &);
+ G711Decoder &operator=(const G711Decoder &);
+};
+
+} // namespace android
+
+#endif // G711_DECODER_H_
diff --git a/media/libstagefright/include/ID3.h b/media/libstagefright/include/ID3.h
index c6b1a8b..7ddbb41 100644
--- a/media/libstagefright/include/ID3.h
+++ b/media/libstagefright/include/ID3.h
@@ -80,6 +80,7 @@ private:
bool parseV1(const sp<DataSource> &source);
bool parseV2(const sp<DataSource> &source);
void removeUnsynchronization();
+ bool removeUnsynchronizationV2_4();
static bool ParseSyncsafeInteger(const uint8_t encoded[4], size_t *x);
diff --git a/media/libstagefright/include/LiveSource.h b/media/libstagefright/include/LiveSource.h
new file mode 100644
index 0000000..55dd45e
--- /dev/null
+++ b/media/libstagefright/include/LiveSource.h
@@ -0,0 +1,88 @@
+/*
+ * 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 NuHTTPDataSource;
+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;
+ }
+
+ 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;
+ off_t mSourceSize;
+ off_t mOffsetBias;
+
+ bool mSignalDiscontinuity;
+ ssize_t mPrevBandwidthIndex;
+
+ status_t fetchM3U(const char *url, sp<ABuffer> *buffer);
+
+ static int SortByBandwidth(const BandwidthItem *a, const BandwidthItem *b);
+
+ bool switchToNext();
+ bool loadPlaylist(bool fetchMaster);
+ void determineSeekability();
+
+ 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..bd9eebe
--- /dev/null
+++ b/media/libstagefright/include/M3UParser.h
@@ -0,0 +1,76 @@
+/*
+ * 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;
+ bool isComplete() 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;
+ bool mIsComplete;
+
+ 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 parseStreamInf(
+ const AString &line, sp<AMessage> *meta);
+
+ static status_t ParseInt32(const char *s, int32_t *x);
+
+ DISALLOW_EVIL_CONSTRUCTORS(M3UParser);
+};
+
+} // namespace android
+
+#endif // M3U_PARSER_H_
diff --git a/media/libstagefright/include/M4vH263Decoder.h b/media/libstagefright/include/M4vH263Decoder.h
index ec49e80..7d73e30 100644
--- a/media/libstagefright/include/M4vH263Decoder.h
+++ b/media/libstagefright/include/M4vH263Decoder.h
@@ -54,6 +54,7 @@ private:
MediaBuffer *mInputBuffer;
int64_t mNumSamplesOutput;
+ int64_t mTargetTimeUs;
void allocateFrames(int32_t width, int32_t height);
void releaseFrames();
diff --git a/media/libstagefright/include/M4vH263Encoder.h b/media/libstagefright/include/M4vH263Encoder.h
new file mode 100644
index 0000000..dbe9fd0
--- /dev/null
+++ b/media/libstagefright/include/M4vH263Encoder.h
@@ -0,0 +1,81 @@
+/*
+ * 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 M4V_H263_ENCODER_H_
+
+#define M4V_H263_ENCODER_H_
+
+#include <media/stagefright/MediaBuffer.h>
+#include <media/stagefright/MediaSource.h>
+
+struct tagvideoEncControls;
+struct tagvideoEncOptions;
+
+namespace android {
+
+struct MediaBuffer;
+struct MediaBufferGroup;
+
+struct M4vH263Encoder : public MediaSource,
+ public MediaBufferObserver {
+ M4vH263Encoder(const sp<MediaSource> &source,
+ const sp<MetaData>& meta);
+
+ virtual status_t start(MetaData *params);
+ virtual status_t stop();
+
+ virtual sp<MetaData> getFormat();
+
+ virtual status_t read(
+ MediaBuffer **buffer, const ReadOptions *options);
+
+ virtual void signalBufferReturned(MediaBuffer *buffer);
+
+protected:
+ virtual ~M4vH263Encoder();
+
+private:
+ sp<MediaSource> mSource;
+ sp<MetaData> mFormat;
+ sp<MetaData> mMeta;
+
+ int32_t mVideoWidth;
+ int32_t mVideoHeight;
+ int32_t mVideoFrameRate;
+ int32_t mVideoBitRate;
+ int32_t mVideoColorFormat;
+ int64_t mNumInputFrames;
+ int64_t mNextModTimeUs;
+ int64_t mPrevTimestampUs;
+ status_t mInitCheck;
+ bool mStarted;
+
+ tagvideoEncControls *mHandle;
+ tagvideoEncOptions *mEncParams;
+ MediaBuffer *mInputBuffer;
+ uint8_t *mInputFrameData;
+ MediaBufferGroup *mGroup;
+
+ status_t initCheck(const sp<MetaData>& meta);
+ void releaseOutputBuffers();
+
+ M4vH263Encoder(const M4vH263Encoder &);
+ M4vH263Encoder &operator=(const M4vH263Encoder &);
+};
+
+} // namespace android
+
+#endif // M4V_H263_ENCODER_H_
diff --git a/media/libstagefright/include/MP3Decoder.h b/media/libstagefright/include/MP3Decoder.h
index 88aa4c6..4086fb6 100644
--- a/media/libstagefright/include/MP3Decoder.h
+++ b/media/libstagefright/include/MP3Decoder.h
@@ -42,6 +42,9 @@ protected:
private:
sp<MediaSource> mSource;
+ sp<MetaData> mMeta;
+ int32_t mNumChannels;
+
bool mStarted;
MediaBufferGroup *mBufferGroup;
@@ -49,10 +52,12 @@ private:
tPVMP3DecoderExternal *mConfig;
void *mDecoderBuf;
int64_t mAnchorTimeUs;
- int64_t mNumSamplesOutput;
+ int64_t mNumFramesOutput;
MediaBuffer *mInputBuffer;
+ void init();
+
MP3Decoder(const MP3Decoder &);
MP3Decoder &operator=(const MP3Decoder &);
};
diff --git a/media/libstagefright/include/MP3Extractor.h b/media/libstagefright/include/MP3Extractor.h
index 3ce6df3..30136e7 100644
--- a/media/libstagefright/include/MP3Extractor.h
+++ b/media/libstagefright/include/MP3Extractor.h
@@ -22,13 +22,14 @@
namespace android {
+struct AMessage;
class DataSource;
class String8;
class MP3Extractor : public MediaExtractor {
public:
// Extractor assumes ownership of "source".
- MP3Extractor(const sp<DataSource> &source);
+ MP3Extractor(const sp<DataSource> &source, const sp<AMessage> &meta);
virtual size_t countTracks();
virtual sp<MediaSource> getTrack(size_t index);
@@ -36,10 +37,9 @@ public:
virtual sp<MetaData> getMetaData();
-protected:
- virtual ~MP3Extractor();
-
private:
+ status_t mInitCheck;
+
sp<DataSource> mDataSource;
off_t mFirstFramePos;
sp<MetaData> mMeta;
@@ -52,7 +52,8 @@ private:
};
bool SniffMP3(
- const sp<DataSource> &source, String8 *mimeType, float *confidence);
+ const sp<DataSource> &source, String8 *mimeType, float *confidence,
+ sp<AMessage> *meta);
} // namespace android
diff --git a/media/libstagefright/include/MPEG2TSExtractor.h b/media/libstagefright/include/MPEG2TSExtractor.h
new file mode 100644
index 0000000..d83b538
--- /dev/null
+++ b/media/libstagefright/include/MPEG2TSExtractor.h
@@ -0,0 +1,60 @@
+#ifndef MPEG2_TS_EXTRACTOR_H_
+
+#define MPEG2_TS_EXTRACTOR_H_
+
+#include <media/stagefright/foundation/ABase.h>
+#include <media/stagefright/MediaExtractor.h>
+#include <utils/threads.h>
+#include <utils/Vector.h>
+
+namespace android {
+
+struct AMessage;
+struct AnotherPacketSource;
+struct ATSParser;
+struct DataSource;
+struct MPEG2TSSource;
+struct String8;
+struct LiveSource;
+
+struct MPEG2TSExtractor : public MediaExtractor {
+ MPEG2TSExtractor(const sp<DataSource> &source);
+
+ virtual size_t countTracks();
+ virtual sp<MediaSource> getTrack(size_t index);
+ virtual sp<MetaData> getTrackMetaData(size_t index, uint32_t flags);
+
+ virtual sp<MetaData> getMetaData();
+
+ virtual uint32_t flags() const;
+
+ void setLiveSource(const sp<LiveSource> &liveSource);
+ void seekTo(int64_t seekTimeUs);
+
+private:
+ friend struct MPEG2TSSource;
+
+ mutable Mutex mLock;
+
+ sp<DataSource> mDataSource;
+ sp<LiveSource> mLiveSource;
+
+ sp<ATSParser> mParser;
+
+ Vector<sp<AnotherPacketSource> > mSourceImpls;
+
+ off_t mOffset;
+
+ void init();
+ status_t feedMore();
+
+ DISALLOW_EVIL_CONSTRUCTORS(MPEG2TSExtractor);
+};
+
+bool SniffMPEG2TS(
+ const sp<DataSource> &source, String8 *mimeType, float *confidence,
+ sp<AMessage> *);
+
+} // namespace android
+
+#endif // MPEG2_TS_EXTRACTOR_H_
diff --git a/media/libstagefright/include/MPEG4Extractor.h b/media/libstagefright/include/MPEG4Extractor.h
index 849bc89..4e31059 100644
--- a/media/libstagefright/include/MPEG4Extractor.h
+++ b/media/libstagefright/include/MPEG4Extractor.h
@@ -23,6 +23,7 @@
namespace android {
+struct AMessage;
class DataSource;
class SampleTable;
class String8;
@@ -92,7 +93,8 @@ private:
};
bool SniffMPEG4(
- const sp<DataSource> &source, String8 *mimeType, float *confidence);
+ const sp<DataSource> &source, String8 *mimeType, float *confidence,
+ sp<AMessage> *);
} // namespace android
diff --git a/media/libstagefright/include/NuCachedSource2.h b/media/libstagefright/include/NuCachedSource2.h
new file mode 100644
index 0000000..1fb2088
--- /dev/null
+++ b/media/libstagefright/include/NuCachedSource2.h
@@ -0,0 +1,104 @@
+/*
+ * 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 NU_CACHED_SOURCE_2_H_
+
+#define NU_CACHED_SOURCE_2_H_
+
+#include <media/stagefright/foundation/ABase.h>
+#include <media/stagefright/foundation/AHandlerReflector.h>
+#include <media/stagefright/DataSource.h>
+
+namespace android {
+
+struct ALooper;
+struct PageCache;
+
+struct NuCachedSource2 : public DataSource {
+ NuCachedSource2(const sp<DataSource> &source);
+
+ virtual status_t initCheck() const;
+
+ virtual ssize_t readAt(off_t offset, void *data, size_t size);
+
+ virtual status_t getSize(off_t *size);
+ virtual uint32_t flags();
+
+ ////////////////////////////////////////////////////////////////////////////
+
+ size_t cachedSize();
+ size_t approxDataRemaining(bool *eos);
+
+ void suspend();
+ void clearCacheAndResume();
+
+protected:
+ virtual ~NuCachedSource2();
+
+private:
+ friend struct AHandlerReflector<NuCachedSource2>;
+
+ enum {
+ kPageSize = 65536,
+ kHighWaterThreshold = 5 * 1024 * 1024,
+ kLowWaterThreshold = 512 * 1024,
+
+ // Read data after a 15 sec timeout whether we're actively
+ // fetching or not.
+ kKeepAliveIntervalUs = 15000000,
+ };
+
+ enum {
+ kWhatFetchMore = 'fetc',
+ kWhatRead = 'read',
+ kWhatSuspend = 'susp',
+ };
+
+ sp<DataSource> mSource;
+ sp<AHandlerReflector<NuCachedSource2> > mReflector;
+ sp<ALooper> mLooper;
+
+ Mutex mSerializer;
+ Mutex mLock;
+ Condition mCondition;
+
+ PageCache *mCache;
+ off_t mCacheOffset;
+ status_t mFinalStatus;
+ off_t mLastAccessPos;
+ 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(off_t offset, void *data, size_t size);
+ status_t seekInternal_l(off_t offset);
+
+ size_t approxDataRemaining_l(bool *eos);
+ void restartPrefetcherIfNecessary_l();
+
+ DISALLOW_EVIL_CONSTRUCTORS(NuCachedSource2);
+};
+
+} // namespace android
+
+#endif // NU_CACHED_SOURCE_2_H_
diff --git a/media/libstagefright/include/NuHTTPDataSource.h b/media/libstagefright/include/NuHTTPDataSource.h
new file mode 100644
index 0000000..8593a91
--- /dev/null
+++ b/media/libstagefright/include/NuHTTPDataSource.h
@@ -0,0 +1,73 @@
+#ifndef NU_HTTP_DATA_SOURCE_H_
+
+#define NU_HTTP_DATA_SOURCE_H_
+
+#include <media/stagefright/DataSource.h>
+#include <utils/String8.h>
+#include <utils/threads.h>
+
+#include "HTTPStream.h"
+
+namespace android {
+
+struct NuHTTPDataSource : public DataSource {
+ NuHTTPDataSource();
+
+ status_t connect(
+ const char *uri,
+ const KeyedVector<String8, String8> *headers = NULL,
+ off_t offset = 0);
+
+ void disconnect();
+
+ virtual status_t initCheck() const;
+
+ virtual ssize_t readAt(off_t offset, void *data, size_t size);
+ virtual status_t getSize(off_t *size);
+ virtual uint32_t flags();
+
+protected:
+ virtual ~NuHTTPDataSource();
+
+private:
+ enum State {
+ DISCONNECTED,
+ CONNECTING,
+ CONNECTED
+ };
+
+ Mutex mLock;
+
+ State mState;
+
+ String8 mHost;
+ unsigned mPort;
+ String8 mPath;
+ String8 mHeaders;
+
+ HTTPStream mHTTP;
+ off_t mOffset;
+ off_t mContentLength;
+ bool mContentLengthValid;
+
+ status_t connect(
+ const char *uri, const String8 &headers, off_t offset);
+
+ status_t connect(
+ const char *host, unsigned port, const char *path,
+ const String8 &headers,
+ off_t offset);
+
+ void applyTimeoutResponse();
+
+ static void MakeFullHeaders(
+ const KeyedVector<String8, String8> *overrides,
+ String8 *headers);
+
+ NuHTTPDataSource(const NuHTTPDataSource &);
+ NuHTTPDataSource &operator=(const NuHTTPDataSource &);
+};
+
+} // namespace android
+
+#endif // NU_HTTP_DATA_SOURCE_H_
diff --git a/media/libstagefright/include/OMX.h b/media/libstagefright/include/OMX.h
index ea131e8..c99da59 100644
--- a/media/libstagefright/include/OMX.h
+++ b/media/libstagefright/include/OMX.h
@@ -102,7 +102,7 @@ public:
OMX_IN OMX_U32 nData1,
OMX_IN OMX_U32 nData2,
OMX_IN OMX_PTR pEventData);
-
+
OMX_ERRORTYPE OnEmptyBufferDone(
node_id node, OMX_IN OMX_BUFFERHEADERTYPE *pBuffer);
@@ -115,20 +115,19 @@ protected:
virtual ~OMX();
private:
- Mutex mLock;
-
- OMXMaster *mMaster;
-
struct CallbackDispatcher;
- sp<CallbackDispatcher> mDispatcher;
+ Mutex mLock;
+ OMXMaster *mMaster;
int32_t mNodeCounter;
KeyedVector<wp<IBinder>, OMXNodeInstance *> mLiveNodes;
KeyedVector<node_id, OMXNodeInstance *> mNodeIDToInstance;
+ KeyedVector<node_id, sp<CallbackDispatcher> > mDispatchers;
node_id makeNodeID(OMXNodeInstance *instance);
OMXNodeInstance *findInstance(node_id node);
+ sp<CallbackDispatcher> findDispatcher(node_id node);
void invalidateNodeID_l(node_id node);
diff --git a/media/libstagefright/include/OggExtractor.h b/media/libstagefright/include/OggExtractor.h
index 7066669..1eda025 100644
--- a/media/libstagefright/include/OggExtractor.h
+++ b/media/libstagefright/include/OggExtractor.h
@@ -22,6 +22,7 @@
namespace android {
+struct AMessage;
class DataSource;
class String8;
@@ -53,7 +54,8 @@ private:
};
bool SniffOgg(
- const sp<DataSource> &source, String8 *mimeType, float *confidence);
+ const sp<DataSource> &source, String8 *mimeType, float *confidence,
+ sp<AMessage> *);
} // namespace android
diff --git a/media/libstagefright/include/Prefetcher.h b/media/libstagefright/include/Prefetcher.h
deleted file mode 100644
index b411d1b..0000000
--- a/media/libstagefright/include/Prefetcher.h
+++ /dev/null
@@ -1,70 +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 PREFETCHER_H_
-
-#define PREFETCHER_H_
-
-#include <utils/RefBase.h>
-#include <utils/Vector.h>
-#include <utils/threads.h>
-
-namespace android {
-
-struct MediaSource;
-struct PrefetchedSource;
-
-struct Prefetcher : public RefBase {
- Prefetcher();
-
- // Given an existing MediaSource returns a new MediaSource
- // that will benefit from prefetching/caching the original one.
- sp<MediaSource> addSource(const sp<MediaSource> &source);
-
- int64_t getCachedDurationUs(bool *noMoreData = NULL);
-
- // If provided (non-NULL), "continueFunc" will be called repeatedly
- // while preparing and preparation will finish early if it returns
- // false. In this case "-EINTR" is returned as a result.
- status_t prepare(
- bool (*continueFunc)(void *cookie) = NULL,
- void *cookie = NULL);
-
-protected:
- virtual ~Prefetcher();
-
-private:
- Mutex mLock;
- Condition mCondition;
-
- Vector<wp<PrefetchedSource> > mSources;
- android_thread_id_t mThread;
- bool mDone;
- bool mThreadExited;
-
- void startThread();
- void stopThread();
-
- static int ThreadWrapper(void *me);
- void threadFunc();
-
- Prefetcher(const Prefetcher &);
- Prefetcher &operator=(const Prefetcher &);
-};
-
-} // namespace android
-
-#endif // PREFETCHER_H_
diff --git a/media/libstagefright/include/SampleTable.h b/media/libstagefright/include/SampleTable.h
index 533ce84..f830690 100644
--- a/media/libstagefright/include/SampleTable.h
+++ b/media/libstagefright/include/SampleTable.h
@@ -60,14 +60,21 @@ public:
uint32_t sampleIndex,
off_t *offset,
size_t *size,
- uint32_t *decodingTime);
+ uint32_t *decodingTime,
+ bool *isSyncSample = NULL);
enum {
- kSyncSample_Flag = 1
+ kFlagBefore,
+ kFlagAfter,
+ kFlagClosest
};
- status_t findClosestSample(
+ status_t findSampleAtTime(
uint32_t req_time, uint32_t *sample_index, uint32_t flags);
+ status_t findSyncSampleNear(
+ uint32_t start_sample_index, uint32_t *sample_index,
+ uint32_t flags);
+
status_t findThumbnailSample(uint32_t *sample_index);
protected:
@@ -99,6 +106,8 @@ private:
off_t mSyncSampleOffset;
uint32_t mNumSyncSamples;
+ uint32_t *mSyncSamples;
+ size_t mLastSyncSampleIndex;
SampleIterator *mSampleIterator;
@@ -111,9 +120,6 @@ private:
friend struct SampleIterator;
- status_t findClosestSyncSample_l(
- uint32_t start_sample_index, uint32_t *sample_index);
-
status_t getSampleSize_l(uint32_t sample_index, size_t *sample_size);
SampleTable(const SampleTable &);
diff --git a/media/libstagefright/include/ThreadedSource.h b/media/libstagefright/include/ThreadedSource.h
new file mode 100644
index 0000000..c67295c
--- /dev/null
+++ b/media/libstagefright/include/ThreadedSource.h
@@ -0,0 +1,73 @@
+/*
+ * 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 THREADED_SOURCE_H_
+
+#define THREADED_SOURCE_H_
+
+#include <media/stagefright/foundation/ABase.h>
+#include <media/stagefright/foundation/AHandlerReflector.h>
+#include <media/stagefright/foundation/ALooper.h>
+#include <media/stagefright/MediaSource.h>
+#include <utils/threads.h>
+
+namespace android {
+
+struct ThreadedSource : public MediaSource {
+ ThreadedSource(const sp<MediaSource> &source);
+
+ virtual status_t start(MetaData *params);
+ virtual status_t stop();
+
+ virtual sp<MetaData> getFormat();
+
+ virtual status_t read(
+ MediaBuffer **buffer, const ReadOptions *options);
+
+ virtual void onMessageReceived(const sp<AMessage> &msg);
+
+protected:
+ virtual ~ThreadedSource();
+
+private:
+ enum {
+ kWhatDecodeMore = 'deco',
+ kWhatSeek = 'seek',
+ };
+
+ sp<MediaSource> mSource;
+ sp<AHandlerReflector<ThreadedSource> > mReflector;
+ sp<ALooper> mLooper;
+
+ Mutex mLock;
+ Condition mCondition;
+ List<MediaBuffer *> mQueue;
+ status_t mFinalResult;
+ bool mDecodePending;
+ bool mStarted;
+
+ int64_t mSeekTimeUs;
+ ReadOptions::SeekMode mSeekMode;
+
+ void postDecodeMore_l();
+ void clearQueue_l();
+
+ DISALLOW_EVIL_CONSTRUCTORS(ThreadedSource);
+};
+
+} // namespace android
+
+#endif // THREADED_SOURCE_H_
diff --git a/media/libstagefright/include/ThrottledSource.h b/media/libstagefright/include/ThrottledSource.h
new file mode 100644
index 0000000..88164b3
--- /dev/null
+++ b/media/libstagefright/include/ThrottledSource.h
@@ -0,0 +1,52 @@
+/*
+ * 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 THROTTLED_SOURCE_H_
+
+#define THROTTLED_SOURCE_H_
+
+#include <media/stagefright/DataSource.h>
+#include <utils/threads.h>
+
+namespace android {
+
+struct ThrottledSource : public DataSource {
+ ThrottledSource(
+ const sp<DataSource> &source,
+ int32_t bandwidthLimitBytesPerSecond);
+
+ virtual status_t initCheck() const;
+
+ virtual ssize_t readAt(off_t offset, void *data, size_t size);
+
+ virtual status_t getSize(off_t *size);
+ virtual uint32_t flags();
+
+private:
+ Mutex mLock;
+
+ sp<DataSource> mSource;
+ int32_t mBandwidthLimitBytesPerSecond;
+ int64_t mStartTimeUs;
+ size_t mTotalTransferred;
+
+ ThrottledSource(const ThrottledSource &);
+ ThrottledSource &operator=(const ThrottledSource &);
+};
+
+} // namespace android
+
+#endif // THROTTLED_SOURCE_H_
diff --git a/media/libstagefright/include/VPXDecoder.h b/media/libstagefright/include/VPXDecoder.h
new file mode 100644
index 0000000..3b8362d
--- /dev/null
+++ b/media/libstagefright/include/VPXDecoder.h
@@ -0,0 +1,62 @@
+/*
+ * 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 VPX_DECODER_H_
+
+#define VPX_DECODER_H_
+
+#include <media/stagefright/MediaSource.h>
+#include <utils/Vector.h>
+
+namespace android {
+
+struct MediaBufferGroup;
+
+struct VPXDecoder : public MediaSource {
+ VPXDecoder(const sp<MediaSource> &source);
+
+ virtual status_t start(MetaData *params);
+ virtual status_t stop();
+
+ virtual sp<MetaData> getFormat();
+
+ virtual status_t read(
+ MediaBuffer **buffer, const ReadOptions *options);
+
+protected:
+ virtual ~VPXDecoder();
+
+private:
+ sp<MediaSource> mSource;
+ bool mStarted;
+ int32_t mWidth, mHeight;
+ size_t mBufferSize;
+
+ void *mCtx;
+ MediaBufferGroup *mBufferGroup;
+
+ int64_t mTargetTimeUs;
+
+ sp<MetaData> mFormat;
+
+ VPXDecoder(const VPXDecoder &);
+ VPXDecoder &operator=(const VPXDecoder &);
+};
+
+} // namespace android
+
+#endif // VPX_DECODER_H_
+
diff --git a/media/libstagefright/include/VorbisDecoder.h b/media/libstagefright/include/VorbisDecoder.h
index e9a488a..13e8b77 100644
--- a/media/libstagefright/include/VorbisDecoder.h
+++ b/media/libstagefright/include/VorbisDecoder.h
@@ -55,6 +55,7 @@ private:
int32_t mSampleRate;
int64_t mAnchorTimeUs;
int64_t mNumFramesOutput;
+ int32_t mNumFramesLeftOnPage;
vorbis_dsp_state *mState;
vorbis_info *mVi;
diff --git a/media/libstagefright/include/WAVExtractor.h b/media/libstagefright/include/WAVExtractor.h
index 9384942..df6d3e7 100644
--- a/media/libstagefright/include/WAVExtractor.h
+++ b/media/libstagefright/include/WAVExtractor.h
@@ -22,6 +22,7 @@
namespace android {
+struct AMessage;
class DataSource;
class String8;
@@ -43,6 +44,7 @@ private:
sp<DataSource> mDataSource;
status_t mInitCheck;
bool mValidFormat;
+ uint16_t mWaveFormat;
uint16_t mNumChannels;
uint32_t mSampleRate;
uint16_t mBitsPerSample;
@@ -57,7 +59,8 @@ private:
};
bool SniffWAV(
- const sp<DataSource> &source, String8 *mimeType, float *confidence);
+ const sp<DataSource> &source, String8 *mimeType, float *confidence,
+ sp<AMessage> *);
} // namespace android
diff --git a/media/libstagefright/include/avc_utils.h b/media/libstagefright/include/avc_utils.h
new file mode 100644
index 0000000..62cfc36
--- /dev/null
+++ b/media/libstagefright/include/avc_utils.h
@@ -0,0 +1,44 @@
+/*
+ * 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 AVC_UTILS_H_
+
+#define AVC_UTILS_H_
+
+#include <media/stagefright/foundation/ABuffer.h>
+
+namespace android {
+
+struct ABitReader;
+
+void FindAVCDimensions(
+ const sp<ABuffer> &seqParamSet, int32_t *width, int32_t *height);
+
+unsigned parseUE(ABitReader *br);
+
+status_t getNextNALUnit(
+ const uint8_t **_data, size_t *_size,
+ const uint8_t **nalStart, size_t *nalSize,
+ bool startCodeFollows = false);
+
+struct MetaData;
+sp<MetaData> MakeAVCCodecSpecificData(const sp<ABuffer> &accessUnit);
+
+bool IsIDR(const sp<ABuffer> &accessUnit);
+
+} // namespace android
+
+#endif // AVC_UTILS_H_