• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 VideoTrackParam g_videoH264Par = {
37     .fileName = "h264_720_480.dat",
38     .mimeType = "video/avc",
39     .width = 720,
40     .height = 480,
41     .frameRate = 60,
42     .videoDelay = 0,
43     .colorPrimaries = 2,
44     .colorTransfer = 2,
45     .colorMatrixCoeff = 2,
46     .colorRange = 0,
47     .isHdrVivid = 0,
48 };
49 
50 struct VideoTrackParam g_videoMpeg4Par = {
51     .fileName = "mpeg4_720_480.dat",
52     .mimeType = "video/mp4v-es",
53     .width = 720,
54     .height = 480,
55     .frameRate = 60,
56     .videoDelay = 0,
57     .colorPrimaries = 2,
58     .colorTransfer = 2,
59     .colorMatrixCoeff = 2,
60     .colorRange = 0,
61     .isHdrVivid = 0,
62 };
63 
64 struct VideoTrackParam g_videoH265Par = {
65     .fileName = "h265_720_480.dat",
66     .mimeType = "video/hevc",
67     .width = 720,
68     .height = 480,
69     .frameRate = 60,
70     .videoDelay = 2,
71     .colorPrimaries = 2,
72     .colorTransfer = 2,
73     .colorMatrixCoeff = 2,
74     .colorRange = 0,
75     .isHdrVivid = 0,
76 };
77 
78 struct VideoTrackParam g_videoHdrPar = {
79     .fileName = "hdr_vivid_3840_2160.dat",
80     .mimeType = "video/hevc",
81     .width = 3840,
82     .height = 2160,
83     .frameRate = 30,
84     .videoDelay = 0,
85     .colorPrimaries = 9,
86     .colorTransfer = 18,
87     .colorMatrixCoeff = 9,
88     .colorRange = 0,
89     .isHdrVivid = 1,
90 };
91 
92 struct VideoTrackParam g_jpegCoverPar = {
93     .fileName = "greatwall.jpg",
94     .mimeType = "image/jpeg",
95     .width = 352,
96     .height = 288,
97 };
98 
99 struct VideoTrackParam g_pngCoverPar = {
100     .fileName = "greatwall.png",
101     .mimeType = "image/png",
102     .width = 352,
103     .height = 288,
104 };
105 
106 struct VideoTrackParam g_bmpCoverPar = {
107     .fileName = "greatwall.bmp",
108     .mimeType = "image/bmp",
109     .width = 352,
110     .height = 288,
111 };
112 
113 const char *RUN_NORMAL = "normal";
114 const char *RUN_MUL_THREAD = "multhrd";
115 
GetTimestamp(void)116 long long GetTimestamp(void)
117 {
118     static const int timeScaleUs = 1000000;
119     long long tmp;
120     struct timeval tv;
121 
122     gettimeofday(&tv, NULL);
123     tmp = tv.tv_sec;
124     tmp = tmp * timeScaleUs;
125     tmp = tmp + tv.tv_usec;
126 
127     return tmp;
128 }