Squashed commit of the following:
commit 1efc38dc3c33fef57b759002db3965ed07a28cb0
Author: Andreas Huber <andih@google.com>
Date: Thu Nov 19 14:36:14 2009 -0800
Sending the SEEK-COMPLETE notification temporarily broke seeking backwards in time behaviour. This is now fixed.
Also, get rid of the semi-random delay after posting buffers to surface flinger in favour of delaying the buffer release until the next frame is displayed.
commit 51973062eb5ee63fd64b845d72bac517cc3369cf
Author: Andreas Huber <andih@google.com>
Date: Wed Nov 18 14:01:43 2009 -0800
Fix one more unit test, properly send seek-complete notification only after seek actually completed.
commit cb22250b34b1fcfe1bf459723a761fd003950229
Author: Andreas Huber <andih@google.com>
Date: Wed Nov 18 12:31:36 2009 -0800
Fix seek-while-paused in AwesomePlayer, revert to using FileSource if MmapSource fails.
commit 25eb9241138ddf7bb27ce90657116c5f8a94d880
Author: Andreas Huber <andih@google.com>
Date: Wed Nov 18 12:30:40 2009 -0800
Support seeking and duration in AMRExtractor, assuming all frames are the same size.
commit 44192f2ebb7ea3bbd3ba5910025692dbc6a08faa
Author: Andreas Huber <andih@google.com>
Date: Wed Nov 18 10:21:44 2009 -0800
MediaPlayerImpl is dead, long live AwesomePlayer.
commit c5b52d3c0674f5dc94db506afbce52401cceddac
Author: Andreas Huber <andih@google.com>
Date: Wed Nov 18 09:42:23 2009 -0800
New implementation of the stagefright mediaplayer.
diff --git a/include/media/MediaPlayerInterface.h b/include/media/MediaPlayerInterface.h
index f723cfd..6575da6 100644
--- a/include/media/MediaPlayerInterface.h
+++ b/include/media/MediaPlayerInterface.h
@@ -133,9 +133,9 @@
return INVALID_OPERATION;
};
-protected:
virtual void sendEvent(int msg, int ext1=0, int ext2=0) { if (mNotify) mNotify(mCookie, msg, ext1, ext2); }
+protected:
void* mCookie;
notify_callback_f mNotify;
};
diff --git a/include/media/stagefright/AudioPlayer.h b/include/media/stagefright/AudioPlayer.h
index 960eda3..71344e6 100644
--- a/include/media/stagefright/AudioPlayer.h
+++ b/include/media/stagefright/AudioPlayer.h
@@ -30,12 +30,20 @@
class AudioPlayer : public TimeSource {
public:
+ enum {
+ REACHED_EOS,
+ SEEK_COMPLETE
+ };
+
AudioPlayer(const sp<MediaPlayerBase::AudioSink> &audioSink);
virtual ~AudioPlayer();
// Caller retains ownership of "source".
void setSource(const sp<MediaSource> &source);
+ void setListenerCallback(
+ void (*notify)(void *cookie, int what), void *cookie);
+
// Return time in us.
virtual int64_t getRealTimeUs();
@@ -76,6 +84,9 @@
bool mStarted;
+ void (*mListenerCallback)(void *cookie, int what);
+ void *mListenerCookie;
+
sp<MediaPlayerBase::AudioSink> mAudioSink;
static void AudioCallback(int event, void *user, void *info);
diff --git a/include/media/stagefright/MediaPlayerImpl.h b/include/media/stagefright/MediaPlayerImpl.h
deleted file mode 100644
index 53a2088..0000000
--- a/include/media/stagefright/MediaPlayerImpl.h
+++ /dev/null
@@ -1,128 +0,0 @@
-/*
- * Copyright (C) 2009 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 MEDIA_PLAYER_IMPL_H_
-
-#define MEDIA_PLAYER_IMPL_H_
-
-#include <pthread.h>
-
-#include <media/MediaPlayerInterface.h>
-#include <media/stagefright/OMXClient.h>
-#include <utils/RefBase.h>
-#include <utils/threads.h>
-
-namespace android {
-
-class AudioPlayer;
-class IOMXRenderer;
-class ISurface;
-class MediaExtractor;
-class MediaBuffer;
-class MediaSource;
-class MemoryHeapPmem;
-class MetaData;
-class Surface;
-class TimeSource;
-
-class MediaPlayerImpl {
-public:
- MediaPlayerImpl(const char *uri);
-
- status_t initCheck() const;
-
- // Assumes ownership of "fd".
- MediaPlayerImpl(int fd, int64_t offset, int64_t length);
-
- ~MediaPlayerImpl();
-
- void play();
- void pause();
- bool isPlaying() const;
-
- void setSurface(const sp<Surface> &surface);
- void setISurface(const sp<ISurface> &isurface);
-
- void setAudioSink(const sp<MediaPlayerBase::AudioSink> &audioSink);
-
- int32_t getWidth() const { return mVideoWidth; }
- int32_t getHeight() const { return mVideoHeight; }
-
- int64_t getDuration();
- int64_t getPosition();
- status_t seekTo(int64_t time);
-
-private:
- status_t mInitCheck;
-
- OMXClient mClient;
-
- sp<MediaExtractor> mExtractor;
-
- TimeSource *mTimeSource;
-
- sp<MediaSource> mAudioSource;
- sp<MediaSource> mAudioDecoder;
- AudioPlayer *mAudioPlayer;
-
- sp<MediaSource> mVideoSource;
- sp<MediaSource> mVideoDecoder;
- int32_t mVideoWidth, mVideoHeight;
- int64_t mVideoPosition;
-
- int64_t mDuration;
-
- bool mPlaying;
- bool mPaused;
-
- int64_t mTimeSourceDeltaUs;
-
- sp<Surface> mSurface;
- sp<ISurface> mISurface;
- sp<IOMXRenderer> mVideoRenderer;
-
- sp<MediaPlayerBase::AudioSink> mAudioSink;
-
- Mutex mLock;
- pthread_t mVideoThread;
-
- bool mSeeking;
- int64_t mSeekTimeUs;
-
- void init();
-
- static void *VideoWrapper(void *me);
- void videoEntry();
-
- void setAudioSource(const sp<MediaSource> &source);
- void setVideoSource(const sp<MediaSource> &source);
-
- MediaSource *makeShoutcastSource(const char *path);
-
- void displayOrDiscardFrame(MediaBuffer *buffer, int64_t pts_us);
- void populateISurface();
- void depopulateISurface();
- void sendFrameToISurface(MediaBuffer *buffer);
-
- void stop();
-
- MediaPlayerImpl(const MediaPlayerImpl &);
- MediaPlayerImpl &operator=(const MediaPlayerImpl &);
-};
-
-} // namespace android
-
-#endif // MEDIA_PLAYER_IMPL_H_
diff --git a/include/media/stagefright/MmapSource.h b/include/media/stagefright/MmapSource.h
deleted file mode 100644
index 1b39d53..0000000
--- a/include/media/stagefright/MmapSource.h
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- * Copyright (C) 2009 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 MMAP_SOURCE_H_
-
-#define MMAP_SOURCE_H_
-
-#include <media/stagefright/DataSource.h>
-#include <media/stagefright/MediaErrors.h>
-
-namespace android {
-
-class MmapSource : public DataSource {
-public:
- MmapSource(const char *filename);
-
- // Assumes ownership of "fd".
- MmapSource(int fd, int64_t offset, int64_t length);
-
- virtual status_t initCheck() const;
-
- virtual ssize_t readAt(off_t offset, void *data, size_t size);
- virtual status_t getSize(off_t *size);
-
-protected:
- virtual ~MmapSource();
-
-private:
- int mFd;
- void *mBase;
- size_t mSize;
-
- MmapSource(const MmapSource &);
- MmapSource &operator=(const MmapSource &);
-};
-
-} // namespace android
-
-#endif // MMAP_SOURCE_H_
-