120111aa043c5f404472bc63b90bc5aad906b1101Andreas Huber/*
220111aa043c5f404472bc63b90bc5aad906b1101Andreas Huber * Copyright (C) 2009 The Android Open Source Project
320111aa043c5f404472bc63b90bc5aad906b1101Andreas Huber *
420111aa043c5f404472bc63b90bc5aad906b1101Andreas Huber * Licensed under the Apache License, Version 2.0 (the "License");
520111aa043c5f404472bc63b90bc5aad906b1101Andreas Huber * you may not use this file except in compliance with the License.
620111aa043c5f404472bc63b90bc5aad906b1101Andreas Huber * You may obtain a copy of the License at
720111aa043c5f404472bc63b90bc5aad906b1101Andreas Huber *
820111aa043c5f404472bc63b90bc5aad906b1101Andreas Huber *      http://www.apache.org/licenses/LICENSE-2.0
920111aa043c5f404472bc63b90bc5aad906b1101Andreas Huber *
1020111aa043c5f404472bc63b90bc5aad906b1101Andreas Huber * Unless required by applicable law or agreed to in writing, software
1120111aa043c5f404472bc63b90bc5aad906b1101Andreas Huber * distributed under the License is distributed on an "AS IS" BASIS,
1220111aa043c5f404472bc63b90bc5aad906b1101Andreas Huber * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1320111aa043c5f404472bc63b90bc5aad906b1101Andreas Huber * See the License for the specific language governing permissions and
1420111aa043c5f404472bc63b90bc5aad906b1101Andreas Huber * limitations under the License.
1520111aa043c5f404472bc63b90bc5aad906b1101Andreas Huber */
1620111aa043c5f404472bc63b90bc5aad906b1101Andreas Huber
17361f482fd229c4d0b683d04c93b9da4ab01660b7Marco Nelissen#include <stddef.h>
1820111aa043c5f404472bc63b90bc5aad906b1101Andreas Huber#include <sys/time.h>
1920111aa043c5f404472bc63b90bc5aad906b1101Andreas Huber
20af5dd7753e62353411cf0daf3b513c38818e9662Andreas Huber#include <media/stagefright/foundation/ALooper.h>
2120111aa043c5f404472bc63b90bc5aad906b1101Andreas Huber#include <media/stagefright/TimeSource.h>
2220111aa043c5f404472bc63b90bc5aad906b1101Andreas Huber
2320111aa043c5f404472bc63b90bc5aad906b1101Andreas Hubernamespace android {
2420111aa043c5f404472bc63b90bc5aad906b1101Andreas Huber
2520111aa043c5f404472bc63b90bc5aad906b1101Andreas HuberSystemTimeSource::SystemTimeSource()
26af5dd7753e62353411cf0daf3b513c38818e9662Andreas Huber    : mStartTimeUs(ALooper::GetNowUs()) {
2720111aa043c5f404472bc63b90bc5aad906b1101Andreas Huber}
2820111aa043c5f404472bc63b90bc5aad906b1101Andreas Huber
2920111aa043c5f404472bc63b90bc5aad906b1101Andreas Huberint64_t SystemTimeSource::getRealTimeUs() {
30af5dd7753e62353411cf0daf3b513c38818e9662Andreas Huber    return ALooper::GetNowUs() - mStartTimeUs;
3120111aa043c5f404472bc63b90bc5aad906b1101Andreas Huber}
3220111aa043c5f404472bc63b90bc5aad906b1101Andreas Huber
3320111aa043c5f404472bc63b90bc5aad906b1101Andreas Huber}  // namespace android
3420111aa043c5f404472bc63b90bc5aad906b1101Andreas Huber
35