1/* 2 * Copyright (C) 2023 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16#include "avmuxer_demo_common.h" 17#include <sys/time.h> 18#include <time.h> 19 20struct AudioTrackParam g_audioMpegPar = { 21 .fileName = "mpeg_44100_2.dat", 22 .mimeType = "audio/mpeg", 23 .sampleRate = 44100, 24 .channels = 2, 25 .frameSize = 1152, 26}; 27 28struct AudioTrackParam g_audioAacPar = { 29 .fileName = "aac_44100_2.dat", 30 .mimeType = "audio/mp4a-latm", 31 .sampleRate = 44100, 32 .channels = 2, 33 .frameSize = 1024, 34}; 35 36struct AudioTrackParam g_audioAmrNbPar = { 37 .fileName = "amrnb_8000_1.dat", 38 .mimeType = "audio/3gpp", 39 .sampleRate = 8000, 40 .channels = 1, 41 .frameSize = 1024, 42}; 43 44struct AudioTrackParam g_audioAmrWbPar = { 45 .fileName = "amrwb_16000_1.dat", 46 .mimeType = "audio/amr-wb", 47 .sampleRate = 16000, 48 .channels = 1, 49 .frameSize = 1024, 50}; 51 52struct AudioTrackParam g_audioG711MUPar = { 53 .fileName = "g711mu_44100_2.dat", 54 .mimeType = "audio/g711mu", 55 .sampleRate = 44100, 56 .channels = 2, 57 .frameSize = 2048, 58}; 59 60struct AudioTrackParam g_audioRawPar = { 61 .fileName = "pcm_44100_2_s16le.dat", 62 .mimeType = "audio/raw", 63 .sampleRate = 44100, 64 .channels = 2, 65 .frameSize = 1024, 66}; 67 68struct VideoTrackParam g_videoH264Par = { 69 .fileName = "h264_720_480.dat", 70 .mimeType = "video/avc", 71 .width = 720, 72 .height = 480, 73 .frameRate = 60, 74 .videoDelay = 0, 75 .colorPrimaries = 2, 76 .colorTransfer = 2, 77 .colorMatrixCoeff = 2, 78 .colorRange = 0, 79 .isHdrVivid = 0, 80}; 81 82struct VideoTrackParam g_videoMpeg4Par = { 83 .fileName = "mpeg4_720_480.dat", 84 .mimeType = "video/mp4v-es", 85 .width = 720, 86 .height = 480, 87 .frameRate = 60, 88 .videoDelay = 0, 89 .colorPrimaries = 2, 90 .colorTransfer = 2, 91 .colorMatrixCoeff = 2, 92 .colorRange = 0, 93 .isHdrVivid = 0, 94}; 95 96struct VideoTrackParam g_videoH265Par = { 97 .fileName = "h265_720_480.dat", 98 .mimeType = "video/hevc", 99 .width = 720, 100 .height = 480, 101 .frameRate = 60, 102 .videoDelay = 2, 103 .colorPrimaries = 2, 104 .colorTransfer = 2, 105 .colorMatrixCoeff = 2, 106 .colorRange = 0, 107 .isHdrVivid = 0, 108}; 109 110struct VideoTrackParam g_videoHdrPar = { 111 .fileName = "hdr_vivid_3840_2160.dat", 112 .mimeType = "video/hevc", 113 .width = 3840, 114 .height = 2160, 115 .frameRate = 30, 116 .videoDelay = 0, 117 .colorPrimaries = 9, 118 .colorTransfer = 18, 119 .colorMatrixCoeff = 9, 120 .colorRange = 0, 121 .isHdrVivid = 1, 122}; 123 124struct VideoTrackParam g_jpegCoverPar = { 125 .fileName = "greatwall.jpg", 126 .mimeType = "image/jpeg", 127 .width = 352, 128 .height = 288, 129}; 130 131struct VideoTrackParam g_pngCoverPar = { 132 .fileName = "greatwall.png", 133 .mimeType = "image/png", 134 .width = 352, 135 .height = 288, 136}; 137 138struct VideoTrackParam g_bmpCoverPar = { 139 .fileName = "greatwall.bmp", 140 .mimeType = "image/bmp", 141 .width = 352, 142 .height = 288, 143}; 144 145const char *RUN_NORMAL = "normal"; 146const char *RUN_MUL_THREAD = "multhrd"; 147 148long long GetTimestamp(void) 149{ 150 static const int timeScaleUs = 1000000; 151 long long tmp; 152 struct timeval tv; 153 154 gettimeofday(&tv, NULL); 155 tmp = tv.tv_sec; 156 tmp = tmp * timeScaleUs; 157 tmp = tmp + tv.tv_usec; 158 159 return tmp; 160}