Marco Nelissen | 98603d8 | 2018-07-17 11:06:55 -0700 | [diff] [blame] | 1 | /* |
| 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 Nelissen | 98603d8 | 2018-07-17 11:06:55 -0700 | [diff] [blame] | 22 | #include <utils/Log.h> |
| 23 | #include <utils/StrongPointer.h> |
| 24 | #include <media/NdkMediaFormatPriv.h> |
Marco Nelissen | 98603d8 | 2018-07-17 11:06:55 -0700 | [diff] [blame] | 25 | #include <media/stagefright/foundation/AMessage.h> |
Marco Nelissen | 98603d8 | 2018-07-17 11:06:55 -0700 | [diff] [blame] | 26 | |
| 27 | #include <jni.h> |
| 28 | |
| 29 | using namespace android; |
| 30 | |
Marco Nelissen | 0e043b6 | 2018-11-14 11:26:05 -0800 | [diff] [blame] | 31 | namespace android { |
Marco Nelissen | 98603d8 | 2018-07-17 11:06:55 -0700 | [diff] [blame] | 32 | |
| 33 | // private functions for conversion to/from AMessage |
Marco Nelissen | 0e043b6 | 2018-11-14 11:26:05 -0800 | [diff] [blame] | 34 | AMediaFormat* AMediaFormat_fromMsg(sp<AMessage> *data) { |
Marco Nelissen | 98603d8 | 2018-07-17 11:06:55 -0700 | [diff] [blame] | 35 | ALOGV("private ctor"); |
| 36 | AMediaFormat* mData = new AMediaFormat(); |
Marco Nelissen | 0e043b6 | 2018-11-14 11:26:05 -0800 | [diff] [blame] | 37 | mData->mFormat = *data; |
Marco Nelissen | 98603d8 | 2018-07-17 11:06:55 -0700 | [diff] [blame] | 38 | if (mData->mFormat == NULL) { |
| 39 | ALOGW("got NULL format"); |
| 40 | mData->mFormat = new AMessage; |
| 41 | } |
| 42 | return mData; |
| 43 | } |
| 44 | |
Marco Nelissen | 0e043b6 | 2018-11-14 11:26:05 -0800 | [diff] [blame] | 45 | void AMediaFormat_getFormat(const AMediaFormat* mData, sp<AMessage> *dest) { |
| 46 | *dest = mData->mFormat; |
Marco Nelissen | 98603d8 | 2018-07-17 11:06:55 -0700 | [diff] [blame] | 47 | } |
| 48 | |
Marco Nelissen | 0e043b6 | 2018-11-14 11:26:05 -0800 | [diff] [blame] | 49 | } // namespace android |
Marco Nelissen | 98603d8 | 2018-07-17 11:06:55 -0700 | [diff] [blame] | 50 | |
| 51 | |