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
20 struct AudioTrackParam g_audioMpegPar = {
21 .fileName = "mpeg_44100_2.dat",
22 .mimeType = "audio/mpeg",
23 .sampleRate = 44100,
24 .channels = 2,
25 .frameSize = 1152,
26 };
27
28 struct 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
36 struct AudioTrackParam g_audioAmrNbPar = {
37 .fileName = "amrnb_8000_1.dat",
38 .mimeType = "audio/3gpp",
39 .sampleRate = 8000,
40 .channels = 1,
41 .frameSize = 1024,
42 };
43
44 struct 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
52 struct AudioTrackParam g_audioG711MUPar = {
53 .fileName = "g711mu_44100_2.dat",
54 .mimeType = "audio/g711mu",
55 .sampleRate = 44100,
56 .channels = 2,
57 .frameSize = 2048,
58 };
59
60 struct 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
68 struct AudioTrackParam g_audioFlacPar = {
69 .fileName = "flac_48000_1_s16le.dat",
70 .mimeType = "audio/flac",
71 .sampleRate = 48000,
72 .channels = 1,
73 .frameSize = 0,
74 };
75
76 struct VideoTrackParam g_videoH264Par = {
77 .fileName = "h264_720_480.dat",
78 .mimeType = "video/avc",
79 .width = 720,
80 .height = 480,
81 .frameRate = 60,
82 .videoDelay = 0,
83 .colorPrimaries = 2,
84 .colorTransfer = 2,
85 .colorMatrixCoeff = 2,
86 .colorRange = 0,
87 .isHdrVivid = 0,
88 };
89
90 struct VideoTrackParam g_videoMpeg4Par = {
91 .fileName = "mpeg4_720_480.dat",
92 .mimeType = "video/mp4v-es",
93 .width = 720,
94 .height = 480,
95 .frameRate = 60,
96 .videoDelay = 0,
97 .colorPrimaries = 2,
98 .colorTransfer = 2,
99 .colorMatrixCoeff = 2,
100 .colorRange = 0,
101 .isHdrVivid = 0,
102 };
103
104 struct VideoTrackParam g_videoH265Par = {
105 .fileName = "h265_720_480.dat",
106 .mimeType = "video/hevc",
107 .width = 720,
108 .height = 480,
109 .frameRate = 60,
110 .videoDelay = 2,
111 .colorPrimaries = 2,
112 .colorTransfer = 2,
113 .colorMatrixCoeff = 2,
114 .colorRange = 0,
115 .isHdrVivid = 0,
116 };
117
118 struct VideoTrackParam g_videoHdrPar = {
119 .fileName = "hdr_vivid_3840_2160.dat",
120 .mimeType = "video/hevc",
121 .width = 3840,
122 .height = 2160,
123 .frameRate = 30,
124 .videoDelay = 0,
125 .colorPrimaries = 9,
126 .colorTransfer = 18,
127 .colorMatrixCoeff = 9,
128 .colorRange = 0,
129 .isHdrVivid = 1,
130 };
131
132 struct VideoTrackParam g_jpegCoverPar = {
133 .fileName = "greatwall.jpg",
134 .mimeType = "image/jpeg",
135 .width = 352,
136 .height = 288,
137 };
138
139 struct VideoTrackParam g_pngCoverPar = {
140 .fileName = "greatwall.png",
141 .mimeType = "image/png",
142 .width = 352,
143 .height = 288,
144 };
145
146 struct VideoTrackParam g_bmpCoverPar = {
147 .fileName = "greatwall.bmp",
148 .mimeType = "image/bmp",
149 .width = 352,
150 .height = 288,
151 };
152
153 const char *RUN_NORMAL = "normal";
154 const char *RUN_MUL_THREAD = "multhrd";
155
GetTimestamp(void)156 long long GetTimestamp(void)
157 {
158 static const int timeScaleUs = 1000000;
159 long long tmp;
160 struct timeval tv;
161
162 gettimeofday(&tv, NULL);
163 tmp = tv.tv_sec;
164 tmp = tmp * timeScaleUs;
165 tmp = tmp + tv.tv_usec;
166
167 return tmp;
168 }