blob: c86f503514c12457e4187d1f8d3ac39f16e3403c [file] [log] [blame]
John Grossmanbd085622012-01-17 18:52:32 -08001/*
2 * Copyright (C) 2011 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 __CC_HELPER_H__
18#define __CC_HELPER_H__
19
20#include <stdint.h>
21#include <utils/threads.h>
22
23namespace android {
24
25class ICommonClock;
26
27// CCHelper is a simple wrapper class to help with centralizing access to the
28// Common Clock service as well as to implement a simple policy of making a
29// basic attempt to reconnect to the common clock service when things go wrong.
30class CCHelper {
31 public:
32 static status_t isCommonTimeValid(bool* valid, uint32_t* timelineID);
33 static status_t commonTimeToLocalTime(int64_t commonTime, int64_t* localTime);
34 static status_t localTimeToCommonTime(int64_t localTime, int64_t* commonTime);
35 static status_t getCommonTime(int64_t* commonTime);
36 static status_t getCommonFreq(uint64_t* freq);
37 static status_t getLocalTime(int64_t* localTime);
38 static status_t getLocalFreq(uint64_t* freq);
39
40 private:
41 static bool verifyClock_l();
42
43 static Mutex lock_;
44 static sp<ICommonClock> common_clock_;
45};
46
47
48} // namespace android
49#endif // __CC_HELPER_H__