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