1 /*
2  * Copyright (c) 2021-2022 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 #ifndef TIMESTAMP_H
16 #define TIMESTAMP_H
17 #ifdef __MUSL__
18 #include <sys/time.h>
19 
20 #include <stdint.h>
21 #endif // __MUSL__
22 #include <unistd.h>
23 
24 namespace OHOS {
25 namespace AudioStandard {
26 /**
27  * @brief Represents Timestamp information, including the frame position information and high-resolution time source.
28  */
29 class Timestamp {
30 public:
Timestamp()31     Timestamp() : framePosition(0)
32     {
33         time.tv_sec = 0;
34         time.tv_nsec = 0;
35     }
36     virtual ~Timestamp() = default;
37     uint32_t framePosition;
38     struct timespec time;
39 
40     /**
41      * @brief Enumerates the time base of this <b>Timestamp</b>. Different timing methods are supported.
42      *
43      */
44     enum Timestampbase {
45         /** Monotonically increasing time, excluding the system sleep time */
46         MONOTONIC = 0
47     };
48 };
49 } // namespace AudioStandard
50 } // namespace OHOS
51 #endif // TIMESTAMP_H
52