summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLajos Molnar <lajos@google.com>2014-07-07 10:30:54 -0700
committerLajos Molnar <lajos@google.com>2014-07-07 16:40:21 -0700
commit05ca3bfb847ff3c1980f2f0922a4d494c0e7ebab (patch)
tree4f7261e870bb514c6f935aef7a60a577c07e4502
parent2e8863b31e987f9bb54e52645e03e75120863a2e (diff)
downloadframeworks_av-05ca3bfb847ff3c1980f2f0922a4d494c0e7ebab.zip
frameworks_av-05ca3bfb847ff3c1980f2f0922a4d494c0e7ebab.tar.gz
frameworks_av-05ca3bfb847ff3c1980f2f0922a4d494c0e7ebab.tar.bz2
stagefright: create CodecBase interface (abstract class)
This abstracts out the ACodec dependency in MediaCodec. Bug: 11784825 Change-Id: I0aa8b56c6414865fd4b0646e2c5bd1b62d030682
-rw-r--r--include/media/stagefright/ACodec.h59
-rw-r--r--include/media/stagefright/CodecBase.h88
-rw-r--r--include/media/stagefright/foundation/AHierarchicalStateMachine.h4
-rw-r--r--media/libstagefright/Android.mk1
-rw-r--r--media/libstagefright/CodecBase.cpp38
-rw-r--r--media/libstagefright/foundation/AHierarchicalStateMachine.cpp2
6 files changed, 163 insertions, 29 deletions
diff --git a/include/media/stagefright/ACodec.h b/include/media/stagefright/ACodec.h
index 84b6bab..14750c6 100644
--- a/include/media/stagefright/ACodec.h
+++ b/include/media/stagefright/ACodec.h
@@ -22,6 +22,7 @@
#include <android/native_window.h>
#include <media/IOMX.h>
#include <media/stagefright/foundation/AHierarchicalStateMachine.h>
+#include <media/stagefright/CodecBase.h>
#include <media/stagefright/SkipCutBuffer.h>
#include <OMX_Audio.h>
@@ -32,42 +33,47 @@ namespace android {
struct ABuffer;
struct MemoryDealer;
-struct ACodec : public AHierarchicalStateMachine {
+struct ACodec : public AHierarchicalStateMachine, public CodecBase {
enum {
- kWhatFillThisBuffer = 'fill',
- kWhatDrainThisBuffer = 'drai',
- kWhatEOS = 'eos ',
- kWhatShutdownCompleted = 'scom',
- kWhatFlushCompleted = 'fcom',
- kWhatOutputFormatChanged = 'outC',
- kWhatError = 'erro',
- kWhatComponentAllocated = 'cAll',
- kWhatComponentConfigured = 'cCon',
- kWhatInputSurfaceCreated = 'isfc',
- kWhatSignaledInputEOS = 'seos',
- kWhatBuffersAllocated = 'allc',
- kWhatOMXDied = 'OMXd',
+ kWhatFillThisBuffer = CodecBase::kWhatFillThisBuffer,
+ kWhatDrainThisBuffer = CodecBase::kWhatDrainThisBuffer,
+ kWhatEOS = CodecBase::kWhatEOS,
+ kWhatShutdownCompleted = CodecBase::kWhatShutdownCompleted,
+ kWhatFlushCompleted = CodecBase::kWhatFlushCompleted,
+ kWhatOutputFormatChanged = CodecBase::kWhatOutputFormatChanged,
+ kWhatError = CodecBase::kWhatError,
+ kWhatComponentAllocated = CodecBase::kWhatComponentAllocated,
+ kWhatComponentConfigured = CodecBase::kWhatComponentConfigured,
+ kWhatInputSurfaceCreated = CodecBase::kWhatInputSurfaceCreated,
+ kWhatSignaledInputEOS = CodecBase::kWhatSignaledInputEOS,
+ kWhatBuffersAllocated = CodecBase::kWhatBuffersAllocated,
};
ACodec();
- void setNotificationMessage(const sp<AMessage> &msg);
+ virtual void setNotificationMessage(const sp<AMessage> &msg);
+
void initiateSetup(const sp<AMessage> &msg);
- void signalFlush();
- void signalResume();
- void initiateShutdown(bool keepComponentAllocated = false);
- void signalSetParameters(const sp<AMessage> &msg);
- void signalEndOfInputStream();
+ virtual void initiateAllocateComponent(const sp<AMessage> &msg);
+ virtual void initiateConfigureComponent(const sp<AMessage> &msg);
+ virtual void initiateCreateInputSurface();
+ virtual void initiateStart();
+ virtual void initiateShutdown(bool keepComponentAllocated = false);
+
+ virtual void signalFlush();
+ virtual void signalResume();
- void initiateAllocateComponent(const sp<AMessage> &msg);
- void initiateConfigureComponent(const sp<AMessage> &msg);
- void initiateCreateInputSurface();
- void initiateStart();
+ virtual void signalSetParameters(const sp<AMessage> &msg);
+ virtual void signalEndOfInputStream();
+ virtual void signalRequestIDRFrame();
- void signalRequestIDRFrame();
+ // AHierarchicalStateMachine implements the message handling
+ virtual void onMessageReceived(const sp<AMessage> &msg) {
+ handleMessage(msg);
+ }
- struct PortDescription : public RefBase {
+ struct PortDescription : public CodecBase::PortDescription {
size_t countBuffers();
IOMX::buffer_id bufferIDAt(size_t index) const;
sp<ABuffer> bufferAt(size_t index) const;
@@ -117,6 +123,7 @@ private:
kWhatRequestIDRFrame = 'ridr',
kWhatSetParameters = 'setP',
kWhatSubmitOutputMetaDataBufferIfEOS = 'subm',
+ kWhatOMXDied = 'OMXd',
};
enum {
diff --git a/include/media/stagefright/CodecBase.h b/include/media/stagefright/CodecBase.h
new file mode 100644
index 0000000..1bf27a6
--- /dev/null
+++ b/include/media/stagefright/CodecBase.h
@@ -0,0 +1,88 @@
+/*
+ * Copyright (C) 2014 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 CODEC_BASE_H_
+
+#define CODEC_BASE_H_
+
+#include <stdint.h>
+#include <media/IOMX.h>
+
+#include <media/stagefright/foundation/AHandler.h>
+
+namespace android {
+
+struct ABuffer;
+
+struct CodecBase : public AHandler {
+ enum {
+ kWhatFillThisBuffer = 'fill',
+ kWhatDrainThisBuffer = 'drai',
+ kWhatEOS = 'eos ',
+ kWhatShutdownCompleted = 'scom',
+ kWhatFlushCompleted = 'fcom',
+ kWhatOutputFormatChanged = 'outC',
+ kWhatError = 'erro',
+ kWhatComponentAllocated = 'cAll',
+ kWhatComponentConfigured = 'cCon',
+ kWhatInputSurfaceCreated = 'isfc',
+ kWhatSignaledInputEOS = 'seos',
+ kWhatBuffersAllocated = 'allc',
+ };
+
+ virtual void setNotificationMessage(const sp<AMessage> &msg) = 0;
+
+ virtual void initiateAllocateComponent(const sp<AMessage> &msg) = 0;
+ virtual void initiateConfigureComponent(const sp<AMessage> &msg) = 0;
+ virtual void initiateCreateInputSurface() = 0;
+ virtual void initiateStart() = 0;
+ virtual void initiateShutdown(bool keepComponentAllocated = false) = 0;
+
+ // require an explicit message handler
+ virtual void onMessageReceived(const sp<AMessage> &msg) = 0;
+
+ virtual void signalFlush() = 0;
+ virtual void signalResume() = 0;
+
+ virtual void signalRequestIDRFrame() = 0;
+ virtual void signalSetParameters(const sp<AMessage> &msg) = 0;
+ virtual void signalEndOfInputStream() = 0;
+
+ struct PortDescription : public RefBase {
+ virtual size_t countBuffers() = 0;
+ virtual IOMX::buffer_id bufferIDAt(size_t index) const = 0;
+ virtual sp<ABuffer> bufferAt(size_t index) const = 0;
+
+ protected:
+ PortDescription();
+ virtual ~PortDescription();
+
+ private:
+ DISALLOW_EVIL_CONSTRUCTORS(PortDescription);
+ };
+
+protected:
+ CodecBase();
+ virtual ~CodecBase();
+
+private:
+ DISALLOW_EVIL_CONSTRUCTORS(CodecBase);
+};
+
+} // namespace android
+
+#endif // CODEC_BASE_H_
+
diff --git a/include/media/stagefright/foundation/AHierarchicalStateMachine.h b/include/media/stagefright/foundation/AHierarchicalStateMachine.h
index d2e6b28..3bb7d75 100644
--- a/include/media/stagefright/foundation/AHierarchicalStateMachine.h
+++ b/include/media/stagefright/foundation/AHierarchicalStateMachine.h
@@ -43,13 +43,13 @@ private:
DISALLOW_EVIL_CONSTRUCTORS(AState);
};
-struct AHierarchicalStateMachine : public AHandler {
+struct AHierarchicalStateMachine {
AHierarchicalStateMachine();
protected:
virtual ~AHierarchicalStateMachine();
- virtual void onMessageReceived(const sp<AMessage> &msg);
+ virtual void handleMessage(const sp<AMessage> &msg);
// Only to be called in response to a message.
void changeState(const sp<AState> &state);
diff --git a/media/libstagefright/Android.mk b/media/libstagefright/Android.mk
index 11c5970..99c8e9f 100644
--- a/media/libstagefright/Android.mk
+++ b/media/libstagefright/Android.mk
@@ -15,6 +15,7 @@ LOCAL_SRC_FILES:= \
CameraSource.cpp \
CameraSourceTimeLapse.cpp \
ClockEstimator.cpp \
+ CodecBase.cpp \
DataSource.cpp \
DataURISource.cpp \
DRMExtractor.cpp \
diff --git a/media/libstagefright/CodecBase.cpp b/media/libstagefright/CodecBase.cpp
new file mode 100644
index 0000000..f729d4d
--- /dev/null
+++ b/media/libstagefright/CodecBase.cpp
@@ -0,0 +1,38 @@
+/*
+ * Copyright (C) 2014 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.
+ */
+
+//#define LOG_NDEBUG 0
+#define LOG_TAG "CodecBase"
+
+#include <inttypes.h>
+
+#include <media/stagefright/CodecBase.h>
+
+namespace android {
+
+CodecBase::CodecBase() {
+}
+
+CodecBase::~CodecBase() {
+}
+
+CodecBase::PortDescription::PortDescription() {
+}
+
+CodecBase::PortDescription::~PortDescription() {
+}
+
+} // namespace android
diff --git a/media/libstagefright/foundation/AHierarchicalStateMachine.cpp b/media/libstagefright/foundation/AHierarchicalStateMachine.cpp
index f7a00d8..5f7c70d 100644
--- a/media/libstagefright/foundation/AHierarchicalStateMachine.cpp
+++ b/media/libstagefright/foundation/AHierarchicalStateMachine.cpp
@@ -51,7 +51,7 @@ AHierarchicalStateMachine::AHierarchicalStateMachine() {
AHierarchicalStateMachine::~AHierarchicalStateMachine() {
}
-void AHierarchicalStateMachine::onMessageReceived(const sp<AMessage> &msg) {
+void AHierarchicalStateMachine::handleMessage(const sp<AMessage> &msg) {
sp<AState> save = mState;
sp<AState> cur = mState;