1 /* 2 * Copyright (C) 2019 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 #ifndef MEDIACTSNATIVE_NATIVE_MEDIA_COMMON_H 18 #define MEDIACTSNATIVE_NATIVE_MEDIA_COMMON_H 19 20 #include <inttypes.h> 21 #include <NdkMediaFormat.h> 22 23 extern const char* AMEDIA_MIMETYPE_VIDEO_VP8; 24 extern const char* AMEDIA_MIMETYPE_VIDEO_VP9; 25 extern const char* AMEDIA_MIMETYPE_VIDEO_AV1; 26 extern const char* AMEDIA_MIMETYPE_VIDEO_AVC; 27 extern const char* AMEDIA_MIMETYPE_VIDEO_HEVC; 28 extern const char* AMEDIA_MIMETYPE_VIDEO_MPEG4; 29 extern const char* AMEDIA_MIMETYPE_VIDEO_H263; 30 31 extern const char* AMEDIA_MIMETYPE_AUDIO_AMR_NB; 32 extern const char* AMEDIA_MIMETYPE_AUDIO_AMR_WB; 33 extern const char* AMEDIA_MIMETYPE_AUDIO_AAC; 34 extern const char* AMEDIA_MIMETYPE_AUDIO_FLAC; 35 extern const char* AMEDIA_MIMETYPE_AUDIO_VORBIS; 36 extern const char* AMEDIA_MIMETYPE_AUDIO_OPUS; 37 38 extern const float kRmsErrorTolerance; 39 40 extern const long kQDeQTimeOutUs; 41 extern const int kRetryLimit; 42 43 // TODO(b/146420990) 44 typedef enum { 45 OUTPUT_FORMAT_START = 0, 46 OUTPUT_FORMAT_MPEG_4 = OUTPUT_FORMAT_START, 47 OUTPUT_FORMAT_WEBM = OUTPUT_FORMAT_START + 1, 48 OUTPUT_FORMAT_THREE_GPP = OUTPUT_FORMAT_START + 2, 49 OUTPUT_FORMAT_HEIF = OUTPUT_FORMAT_START + 3, 50 OUTPUT_FORMAT_OGG = OUTPUT_FORMAT_START + 4, 51 OUTPUT_FORMAT_LIST_END = OUTPUT_FORMAT_START + 4, 52 } MuxerFormat; 53 54 // Color formats supported by encoder - should mirror supportedColorList 55 // from MediaCodecConstants.h (are these going to be deprecated) 56 constexpr int COLOR_FormatYUV420SemiPlanar = 21; 57 constexpr int COLOR_FormatYUV420Flexible = 0x7F420888; 58 constexpr int COLOR_FormatSurface = 0x7f000789; 59 60 // constants not defined in NDK 61 extern const char* TBD_AMEDIACODEC_PARAMETER_KEY_REQUEST_SYNC_FRAME; 62 extern const char* TBD_AMEDIACODEC_PARAMETER_KEY_VIDEO_BITRATE; 63 extern const char* TBD_AMEDIACODEC_PARAMETER_KEY_MAX_B_FRAMES; 64 extern const char* TBD_AMEDIAFORMAT_KEY_BIT_RATE_MODE; 65 static const int TBD_AMEDIACODEC_BUFFER_FLAG_KEY_FRAME = 0x1; 66 67 static const int kBitrateModeConstant = 2; 68 69 // common utility functions 70 bool isCSDIdentical(AMediaFormat* refFormat, AMediaFormat* testFormat); 71 bool isFormatSimilar(AMediaFormat* refFormat, AMediaFormat* testFormat); 72 73 template <class T> 74 void flattenField(uint8_t* buffer, int* pos, T value); 75 76 #endif // MEDIACTSNATIVE_NATIVE_MEDIA_COMMON_H 77