VideoFrameScheduler.h revision dc43dfa1294470a4413c37e863ef3b621da8681f
1/*
2 * Copyright 2014, 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 VIDEO_FRAME_SCHEDULER_H_
18#define VIDEO_FRAME_SCHEDULER_H_
19
20#include <utils/RefBase.h>
21#include <utils/Timers.h>
22
23#include <media/stagefright/foundation/ABase.h>
24
25namespace android {
26
27struct ISurfaceComposer;
28
29struct VideoFrameScheduler : public RefBase {
30    VideoFrameScheduler();
31
32    // (re)initialize scheduler
33    void init();
34    // get adjusted nanotime for a video frame render at renderTime
35    nsecs_t schedule(nsecs_t renderTime);
36
37    // returns the vsync period for the main display
38    nsecs_t getVsyncPeriod();
39
40    void release();
41
42protected:
43    virtual ~VideoFrameScheduler();
44
45private:
46    void updateVsync();
47
48    nsecs_t mVsyncTime;        // vsync timing from display
49    nsecs_t mVsyncPeriod;
50    nsecs_t mVsyncRefreshAt;   // next time to refresh timing info
51
52    sp<ISurfaceComposer> mComposer;
53
54    DISALLOW_EVIL_CONSTRUCTORS(VideoFrameScheduler);
55};
56
57}  // namespace android
58
59#endif  // VIDEO_FRAME_SCHEDULER_H_
60
61