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 
22 #include <utils/Log.h>
23 #include <utils/StrongPointer.h>
24 #include <media/NdkMediaFormatPriv.h>
25 #include <media/stagefright/foundation/AMessage.h>
26 
27 using namespace android;
28 
29 namespace android {
30 
31 // private functions for conversion to/from AMessage
AMediaFormat_fromMsg(sp<AMessage> * data)32 AMediaFormat* AMediaFormat_fromMsg(sp<AMessage> *data) {
33     ALOGV("private ctor");
34     AMediaFormat* mData = new AMediaFormat();
35     mData->mFormat = *data;
36     if (mData->mFormat == NULL) {
37         ALOGW("got NULL format");
38         mData->mFormat = new AMessage;
39     }
40     return mData;
41 }
42 
AMediaFormat_getFormat(const AMediaFormat * mData,sp<AMessage> * dest)43 void AMediaFormat_getFormat(const AMediaFormat* mData, sp<AMessage> *dest) {
44     *dest = mData->mFormat;
45 }
46 
47 } // namespace android
48 
49 
50