summaryrefslogtreecommitdiffstats
path: root/cmds/stagefright
diff options
context:
space:
mode:
authorAndreas Huber <andih@google.com>2009-08-27 14:50:58 -0700
committerAndreas Huber <andih@google.com>2009-08-27 14:50:58 -0700
commit329577aa6d422d1dbb33f4771fc5e2949b4ad312 (patch)
tree6240bac8ea8e41ada57f30fe41f4a69f1ad97edc /cmds/stagefright
parente18d4d01152071f3a489a0d3077ad89dfa1f3851 (diff)
downloadframeworks_base-329577aa6d422d1dbb33f4771fc5e2949b4ad312.zip
frameworks_base-329577aa6d422d1dbb33f4771fc5e2949b4ad312.tar.gz
frameworks_base-329577aa6d422d1dbb33f4771fc5e2949b4ad312.tar.bz2
Squashed commit of the following:
commit 3fa5f3ce910f34da0cedb8bcce1bd593db7eb740 Author: Andreas Huber <andih@google.com> Date: Thu Aug 27 14:48:54 2009 -0700 Getting rid of more code now obsolete with the departure of OMXDecoder. commit e0d923ec0c7bb60bec8eb97739036a4c70c0feef Author: Andreas Huber <andih@google.com> Date: Thu Aug 27 14:33:06 2009 -0700 Remove obsoleted OMXDecoder class. OMXDecoder is dead, long live OMXCodec.
Diffstat (limited to 'cmds/stagefright')
-rw-r--r--cmds/stagefright/Android.mk20
-rw-r--r--cmds/stagefright/play.cpp295
-rw-r--r--cmds/stagefright/record.cpp13
-rw-r--r--cmds/stagefright/stagefright.cpp8
4 files changed, 0 insertions, 336 deletions
diff --git a/cmds/stagefright/Android.mk b/cmds/stagefright/Android.mk
index 697d67a..ef67611 100644
--- a/cmds/stagefright/Android.mk
+++ b/cmds/stagefright/Android.mk
@@ -38,23 +38,3 @@ LOCAL_CFLAGS += -Wno-multichar
LOCAL_MODULE:= record
include $(BUILD_EXECUTABLE)
-
-################################################################################
-
-# include $(CLEAR_VARS)
-#
-# LOCAL_SRC_FILES:= \
-# play.cpp
-#
-# LOCAL_SHARED_LIBRARIES := \
-# libstagefright
-#
-# LOCAL_C_INCLUDES:= \
-# frameworks/base/media/libstagefright \
-# $(TOP)/external/opencore/extern_libs_v2/khronos/openmax/include
-#
-# LOCAL_CFLAGS += -Wno-multichar
-#
-# LOCAL_MODULE:= play
-#
-# include $(BUILD_EXECUTABLE)
diff --git a/cmds/stagefright/play.cpp b/cmds/stagefright/play.cpp
deleted file mode 100644
index c6e778e..0000000
--- a/cmds/stagefright/play.cpp
+++ /dev/null
@@ -1,295 +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.
- */
-
-#include <binder/ProcessState.h>
-#include <media/stagefright/OMXClient.h>
-#include <media/stagefright/TimedEventQueue.h>
-#include <media/stagefright/MPEG4Extractor.h>
-#include <media/stagefright/MediaSource.h>
-#include <media/stagefright/MetaData.h>
-#include <media/stagefright/MmapSource.h>
-#include <media/stagefright/OMXDecoder.h>
-
-using namespace android;
-
-struct NewPlayer {
- NewPlayer();
- ~NewPlayer();
-
- void setSource(const char *uri);
- void start();
- void pause();
- void stop();
-
-private:
- struct PlayerEvent : public TimedEventQueue::Event {
- PlayerEvent(NewPlayer *player,
- void (NewPlayer::*method)(int64_t realtime_us))
- : mPlayer(player),
- mMethod(method) {
- }
-
- virtual void fire(TimedEventQueue *queue, int64_t realtime_us) {
- (mPlayer->*mMethod)(realtime_us);
- }
-
- private:
- NewPlayer *mPlayer;
- void (NewPlayer::*mMethod)(int64_t realtime_us);
-
- PlayerEvent(const PlayerEvent &);
- PlayerEvent &operator=(const PlayerEvent &);
- };
-
- struct PlayVideoFrameEvent : public TimedEventQueue::Event {
- PlayVideoFrameEvent(NewPlayer *player, MediaBuffer *buffer)
- : mPlayer(player),
- mBuffer(buffer) {
- }
-
- virtual ~PlayVideoFrameEvent() {
- if (mBuffer != NULL) {
- mBuffer->release();
- mBuffer = NULL;
- }
- }
-
- virtual void fire(TimedEventQueue *queue, int64_t realtime_us) {
- mPlayer->onPlayVideoFrame(realtime_us, mBuffer);
- mBuffer = NULL;
- }
-
- private:
- NewPlayer *mPlayer;
- MediaBuffer *mBuffer;
-
- PlayVideoFrameEvent(const PlayVideoFrameEvent &);
- PlayVideoFrameEvent &operator=(const PlayVideoFrameEvent &);
- };
-
- OMXClient mClient;
-
- MPEG4Extractor *mExtractor;
- MediaSource *mAudioSource;
- OMXDecoder *mAudioDecoder;
- MediaSource *mVideoSource;
- OMXDecoder *mVideoDecoder;
-
- int32_t mVideoWidth, mVideoHeight;
-
- TimedEventQueue mQueue;
- wp<TimedEventQueue::Event> mPlayVideoFrameEvent;
-
- int64_t mMediaTimeUsStart;
- int64_t mRealTimeUsStart;
-
- void setAudioSource(MediaSource *source);
- void setVideoSource(MediaSource *source);
-
- int64_t approxRealTime(int64_t mediatime_us) const;
-
- void onStart(int64_t realtime_us);
- void onPause(int64_t realtime_us);
- void onFetchVideoFrame(int64_t realtime_us);
- void onPlayVideoFrame(int64_t realtime_us, MediaBuffer *buffer);
-
- static int64_t getMediaBufferTimeUs(MediaBuffer *buffer);
-
- NewPlayer(const NewPlayer &);
- NewPlayer &operator=(const NewPlayer &);
-};
-
-NewPlayer::NewPlayer()
- : mExtractor(NULL),
- mAudioSource(NULL),
- mAudioDecoder(NULL),
- mVideoSource(NULL),
- mVideoDecoder(NULL),
- mVideoWidth(0),
- mVideoHeight(0) {
- status_t err = mClient.connect();
- assert(err == OK);
-}
-
-NewPlayer::~NewPlayer() {
- stop();
-
- mClient.disconnect();
-}
-
-void NewPlayer::setSource(const char *uri) {
- stop();
-
- mExtractor = new MPEG4Extractor(new MmapSource(uri));
-
- int num_tracks;
- status_t err = mExtractor->countTracks(&num_tracks);
- assert(err == OK);
-
- for (int i = 0; i < num_tracks; ++i) {
- const sp<MetaData> meta = mExtractor->getTrackMetaData(i);
- assert(meta != NULL);
-
- const char *mime;
- if (!meta->findCString(kKeyMIMEType, &mime)) {
- continue;
- }
-
- bool is_audio = false;
- bool is_acceptable = false;
- if (!strncasecmp(mime, "audio/", 6)) {
- is_audio = true;
- is_acceptable = (mAudioSource == NULL);
- } else if (!strncasecmp(mime, "video/", 6)) {
- is_acceptable = (mVideoSource == NULL);
- }
-
- if (!is_acceptable) {
- continue;
- }
-
- MediaSource *source;
- if (mExtractor->getTrack(i, &source) != OK) {
- continue;
- }
-
- if (is_audio) {
- setAudioSource(source);
- } else {
- setVideoSource(source);
- }
- }
-}
-
-void NewPlayer::setAudioSource(MediaSource *source) {
- mAudioSource = source;
-
- sp<MetaData> meta = source->getFormat();
-
- mAudioDecoder = OMXDecoder::Create(&mClient, meta);
- mAudioDecoder->setSource(source);
-}
-
-void NewPlayer::setVideoSource(MediaSource *source) {
- mVideoSource = source;
-
- sp<MetaData> meta = source->getFormat();
-
- bool success = meta->findInt32(kKeyWidth, &mVideoWidth);
- assert(success);
-
- success = meta->findInt32(kKeyHeight, &mVideoHeight);
- assert(success);
-
- mVideoDecoder = OMXDecoder::Create(&mClient, meta);
- mVideoDecoder->setSource(source);
-}
-
-void NewPlayer::start() {
- mQueue.start();
- mQueue.postEvent(new PlayerEvent(this, &NewPlayer::onStart));
-}
-
-void NewPlayer::pause() {
- mQueue.postEvent(new PlayerEvent(this, &NewPlayer::onPause));
-}
-
-void NewPlayer::stop() {
- mQueue.stop();
-
- delete mVideoDecoder;
- mVideoDecoder = NULL;
- delete mVideoSource;
- mVideoSource = NULL;
- mVideoWidth = mVideoHeight = 0;
-
- delete mAudioDecoder;
- mAudioDecoder = NULL;
- delete mAudioSource;
- mAudioSource = NULL;
-
- delete mExtractor;
- mExtractor = NULL;
-}
-
-int64_t NewPlayer::approxRealTime(int64_t mediatime_us) const {
- return mRealTimeUsStart + (mediatime_us - mMediaTimeUsStart);
-}
-
-void NewPlayer::onStart(int64_t realtime_us) {
- mRealTimeUsStart = TimedEventQueue::getRealTimeUs();
-
- if (mVideoDecoder != NULL) {
- mQueue.postEvent(new PlayerEvent(this, &NewPlayer::onFetchVideoFrame));
- }
-}
-
-void NewPlayer::onFetchVideoFrame(int64_t realtime_us) {
- MediaBuffer *buffer;
- status_t err = mVideoDecoder->read(&buffer);
- assert(err == OK);
-
- int64_t mediatime_us = getMediaBufferTimeUs(buffer);
-
- sp<TimedEventQueue::Event> event = new PlayVideoFrameEvent(this, buffer);
- mPlayVideoFrameEvent = event;
-
- mQueue.postTimedEvent(event, approxRealTime(mediatime_us));
-}
-
-// static
-int64_t NewPlayer::getMediaBufferTimeUs(MediaBuffer *buffer) {
- int32_t units, scale;
- bool success =
- buffer->meta_data()->findInt32(kKeyTimeUnits, &units);
- assert(success);
- success =
- buffer->meta_data()->findInt32(kKeyTimeScale, &scale);
- assert(success);
-
- return (int64_t)units * 1000000 / scale;
-}
-
-void NewPlayer::onPlayVideoFrame(int64_t realtime_us, MediaBuffer *buffer) {
- LOGI("playing video frame (mediatime: %.2f sec)\n",
- getMediaBufferTimeUs(buffer) / 1E6);
- fflush(stdout);
-
- buffer->release();
- buffer = NULL;
-
- mQueue.postEvent(new PlayerEvent(this, &NewPlayer::onFetchVideoFrame));
-}
-
-void NewPlayer::onPause(int64_t realtime_us) {
-}
-
-int main(int argc, char **argv) {
- android::ProcessState::self()->startThreadPool();
-
- if (argc != 2) {
- fprintf(stderr, "usage: %s filename\n", argv[0]);
- return 1;
- }
-
- NewPlayer player;
- player.setSource(argv[1]);
- player.start();
- sleep(10);
- player.stop();
-
- return 0;
-}
diff --git a/cmds/stagefright/record.cpp b/cmds/stagefright/record.cpp
index cf2962b..9a2416b 100644
--- a/cmds/stagefright/record.cpp
+++ b/cmds/stagefright/record.cpp
@@ -26,7 +26,6 @@
#include <media/stagefright/MmapSource.h>
#include <media/stagefright/OMXClient.h>
#include <media/stagefright/OMXCodec.h>
-#include <media/stagefright/OMXDecoder.h>
using namespace android;
@@ -87,8 +86,6 @@ private:
DummySource &operator=(const DummySource &);
};
-#define USE_OMX_CODEC 1
-
sp<MediaSource> createSource(const char *filename) {
sp<MediaSource> source;
@@ -140,13 +137,8 @@ int main(int argc, char **argv) {
sp<MetaData> meta = source->getFormat();
-#if USE_OMX_CODEC
sp<OMXCodec> decoder = OMXCodec::Create(
client.interface(), meta, false /* createEncoder */, source);
-#else
- sp<OMXDecoder> decoder = OMXDecoder::Create(
- &client, meta, false /* createEncoder */, source);
-#endif
int width, height;
bool success = meta->findInt32(kKeyWidth, &width);
@@ -164,14 +156,9 @@ int main(int argc, char **argv) {
enc_meta->setInt32(kKeyWidth, width);
enc_meta->setInt32(kKeyHeight, height);
-#if USE_OMX_CODEC
sp<OMXCodec> encoder =
OMXCodec::Create(
client.interface(), enc_meta, true /* createEncoder */, decoder);
-#else
- sp<OMXDecoder> encoder = OMXDecoder::Create(
- &client, enc_meta, true /* createEncoder */, decoder);
-#endif
#if 1
sp<MPEG4Writer> writer = new MPEG4Writer("/sdcard/output.mp4");
diff --git a/cmds/stagefright/stagefright.cpp b/cmds/stagefright/stagefright.cpp
index e927aae..baa00da 100644
--- a/cmds/stagefright/stagefright.cpp
+++ b/cmds/stagefright/stagefright.cpp
@@ -33,7 +33,6 @@
#include <media/stagefright/MmapSource.h>
#include <media/stagefright/OMXClient.h>
#include <media/stagefright/OMXCodec.h>
-#include <media/stagefright/OMXDecoder.h>
#include "JPEGSource.h"
@@ -50,18 +49,11 @@ static int64_t getNowUs() {
return (int64_t)tv.tv_usec + tv.tv_sec * 1000000;
}
-#define USE_OMX_CODEC 1
-
static void playSource(OMXClient *client, const sp<MediaSource> &source) {
sp<MetaData> meta = source->getFormat();
-#if !USE_OMX_CODEC
- sp<OMXDecoder> decoder = OMXDecoder::Create(
- client, meta, false /* createEncoder */, source);
-#else
sp<OMXCodec> decoder = OMXCodec::Create(
client->interface(), meta, false /* createEncoder */, source);
-#endif
if (decoder == NULL) {
return;