blob: 3a9fb8b7272486df6ce6cefa07da77cf166dde89 [file] [log] [blame]
Marco Nelissen98603d82018-07-17 11:06:55 -07001/*
2 * Copyright (C) 2018 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17//#define LOG_NDEBUG 0
18#define LOG_TAG "NdkMediaFormat"
19
20#include <inttypes.h>
21
Marco Nelissen98603d82018-07-17 11:06:55 -070022#include <utils/Log.h>
23#include <utils/StrongPointer.h>
24#include <media/NdkMediaFormatPriv.h>
Marco Nelissen98603d82018-07-17 11:06:55 -070025#include <media/stagefright/foundation/AMessage.h>
Marco Nelissen98603d82018-07-17 11:06:55 -070026
27#include <jni.h>
28
29using namespace android;
30
Marco Nelissen0e043b62018-11-14 11:26:05 -080031namespace android {
Marco Nelissen98603d82018-07-17 11:06:55 -070032
33// private functions for conversion to/from AMessage
Marco Nelissen0e043b62018-11-14 11:26:05 -080034AMediaFormat* AMediaFormat_fromMsg(sp<AMessage> *data) {
Marco Nelissen98603d82018-07-17 11:06:55 -070035 ALOGV("private ctor");
36 AMediaFormat* mData = new AMediaFormat();
Marco Nelissen0e043b62018-11-14 11:26:05 -080037 mData->mFormat = *data;
Marco Nelissen98603d82018-07-17 11:06:55 -070038 if (mData->mFormat == NULL) {
39 ALOGW("got NULL format");
40 mData->mFormat = new AMessage;
41 }
42 return mData;
43}
44
Marco Nelissen0e043b62018-11-14 11:26:05 -080045void AMediaFormat_getFormat(const AMediaFormat* mData, sp<AMessage> *dest) {
46 *dest = mData->mFormat;
Marco Nelissen98603d82018-07-17 11:06:55 -070047}
48
Marco Nelissen0e043b62018-11-14 11:26:05 -080049} // namespace android
Marco Nelissen98603d82018-07-17 11:06:55 -070050
51