summaryrefslogtreecommitdiffstats
path: root/media/ndk/NdkMediaMuxer.cpp
diff options
context:
space:
mode:
authorMarco Nelissen <marcone@google.com>2014-05-06 16:08:19 -0700
committerMarco Nelissen <marcone@google.com>2014-05-07 09:57:08 -0700
commit08aaabe87960c04ecac180db1fe88b5a7bc2ed3b (patch)
tree740a80ccc357b0a138445b2728c32ee9762db745 /media/ndk/NdkMediaMuxer.cpp
parent8e085cbeccb1138d52a0a423af02e6ab41b4fee4 (diff)
downloadframeworks_av-08aaabe87960c04ecac180db1fe88b5a7bc2ed3b.zip
frameworks_av-08aaabe87960c04ecac180db1fe88b5a7bc2ed3b.tar.gz
frameworks_av-08aaabe87960c04ecac180db1fe88b5a7bc2ed3b.tar.bz2
Add NDK version of MediaMuxer
and add some constness here and there. Change-Id: Ib3caa8310691e8f27aaa1afcfaec0b384513d4f1
Diffstat (limited to 'media/ndk/NdkMediaMuxer.cpp')
-rw-r--r--media/ndk/NdkMediaMuxer.cpp99
1 files changed, 99 insertions, 0 deletions
diff --git a/media/ndk/NdkMediaMuxer.cpp b/media/ndk/NdkMediaMuxer.cpp
new file mode 100644
index 0000000..98129cb
--- /dev/null
+++ b/media/ndk/NdkMediaMuxer.cpp
@@ -0,0 +1,99 @@
+/*
+ * 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 "NdkMediaMuxer"
+
+
+#include "NdkMediaMuxer.h"
+#include "NdkMediaCodec.h"
+#include "NdkMediaFormatPriv.h"
+
+
+#include <utils/Log.h>
+#include <utils/StrongPointer.h>
+#include <media/stagefright/foundation/ABuffer.h>
+#include <media/stagefright/foundation/AMessage.h>
+#include <media/stagefright/MetaData.h>
+#include <media/stagefright/MediaMuxer.h>
+#include <media/IMediaHTTPService.h>
+#include <android_runtime/AndroidRuntime.h>
+#include <android_util_Binder.h>
+
+#include <jni.h>
+
+using namespace android;
+
+static int translate_error(status_t err) {
+ if (err == OK) {
+ return OK;
+ }
+ ALOGE("sf error code: %d", err);
+ return -1000;
+}
+
+struct AMediaMuxer {
+ sp<MediaMuxer> mImpl;
+
+};
+
+extern "C" {
+
+AMediaMuxer* AMediaMuxer_new(int fd, OutputFormat format) {
+ ALOGV("ctor");
+ AMediaMuxer *mData = new AMediaMuxer();
+ mData->mImpl = new MediaMuxer(fd, (android::MediaMuxer::OutputFormat)format);
+ return mData;
+}
+
+int AMediaMuxer_delete(AMediaMuxer *muxer) {
+ ALOGV("dtor");
+ delete muxer;
+ return OK;
+}
+
+int AMediaMuxer_setLocation(AMediaMuxer *muxer, float latitude, float longtitude) {
+ return translate_error(muxer->mImpl->setLocation(latitude * 10000, longtitude * 10000));
+}
+
+int AMediaMuxer_setOrientationHint(AMediaMuxer *muxer, int degrees) {
+ return translate_error(muxer->mImpl->setOrientationHint(degrees));
+}
+
+ssize_t AMediaMuxer_addTrack(AMediaMuxer *muxer, const AMediaFormat *format) {
+ sp<AMessage> msg;
+ AMediaFormat_getFormat(format, &msg);
+ return translate_error(muxer->mImpl->addTrack(msg));
+}
+
+int AMediaMuxer_start(AMediaMuxer *muxer) {
+ return translate_error(muxer->mImpl->start());
+}
+
+int AMediaMuxer_stop(AMediaMuxer *muxer) {
+ return translate_error(muxer->mImpl->stop());
+}
+
+int AMediaMuxer_writeSampleData(AMediaMuxer *muxer,
+ size_t trackIdx, const uint8_t *data, const AMediaCodecBufferInfo &info) {
+ sp<ABuffer> buf = new ABuffer((void*)(data + info.offset), info.size);
+ return translate_error(
+ muxer->mImpl->writeSampleData(buf, trackIdx, info.presentationTimeUs, info.flags));
+}
+
+
+} // extern "C"
+