blob: 7983184d549ff82d22c8d5007ea2016e5be98772 [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
Marco Nelissen98603d82018-07-17 11:06:55 -070027using namespace android;
28
Marco Nelissen0e043b62018-11-14 11:26:05 -080029namespace android {
Marco Nelissen98603d82018-07-17 11:06:55 -070030
31// private functions for conversion to/from AMessage
Marco Nelissen0e043b62018-11-14 11:26:05 -080032AMediaFormat* AMediaFormat_fromMsg(sp<AMessage> *data) {
Marco Nelissen98603d82018-07-17 11:06:55 -070033 ALOGV("private ctor");
34 AMediaFormat* mData = new AMediaFormat();
Marco Nelissen0e043b62018-11-14 11:26:05 -080035 mData->mFormat = *data;
Marco Nelissen98603d82018-07-17 11:06:55 -070036 if (mData->mFormat == NULL) {
37 ALOGW("got NULL format");
38 mData->mFormat = new AMessage;
39 }
40 return mData;
41}
42
Marco Nelissen0e043b62018-11-14 11:26:05 -080043void AMediaFormat_getFormat(const AMediaFormat* mData, sp<AMessage> *dest) {
44 *dest = mData->mFormat;
Marco Nelissen98603d82018-07-17 11:06:55 -070045}
46
Marco Nelissen0e043b62018-11-14 11:26:05 -080047} // namespace android
Marco Nelissen98603d82018-07-17 11:06:55 -070048
49