blob: 9dcb42368d68db22614550c10f3e4347eb281daa [file] [log] [blame]
Ajit Khare73cfaf42013-01-07 23:28:47 -08001/*
2 * Copyright (c) 2013, The Linux Foundation. All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above
10 * copyright notice, this list of conditions and the following
11 * disclaimer in the documentation and/or other materials provided
12 * with the distribution.
13 * * Neither the name of The Linux Foundation nor the names of its
14 * contributors may be used to endorse or promote products derived
15 * from this software without specific prior written permission.
16 *
17 * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
18 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
19 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
20 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
21 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
22 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
23 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
24 * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
25 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
26 * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
27 * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 */
29
30#ifndef DASHPLAYER_STATS_H_
31
32#define DASHPLAYER_STATS_H_
33
34#include <utils/RefBase.h>
35#include <utils/threads.h>
36
37namespace android {
38
39class DashPlayerStats : public RefBase {
40 public:
41 DashPlayerStats();
42 ~DashPlayerStats();
43
44 void setMime(const char* mime);
45 void setVeryFirstFrame(bool vff);
46 void notifySeek();
47 void incrementTotalFrames();
48 void incrementDroppedFrames();
49 void logStatistics();
50 void logPause(int64_t positionUs);
51 void logSeek(int64_t seekTimeUs);
52 void recordLate(int64_t ts, int64_t clock, int64_t delta, int64_t anchorTime);
53 void recordOnTime(int64_t ts, int64_t clock, int64_t delta);
54 void logSyncLoss();
55 void logFps();
56 void logFpsSummary();
57 static int64_t getTimeOfDayUs();
58 void incrementTotalRenderingFrames();
Naupada Dharmendra Patnaik84a8aa12013-02-01 14:34:07 +053059 void notifyBufferingEvent();
Surajit Podder852ebd52013-02-21 15:05:18 +053060 void setFileDescAndOutputStream(int fd);
Ajit Khare73cfaf42013-01-07 23:28:47 -080061
62 private:
63 void logFirstFrame();
64 void logCatchUp(int64_t ts, int64_t clock, int64_t delta);
65 void logLate(int64_t ts, int64_t clock, int64_t delta);
66 void logOnTime(int64_t ts, int64_t clock, int64_t delta);
67
68 mutable Mutex mStatsLock;
69 bool mStatistics;
70 char* mMIME;
71 int64_t mNumVideoFramesDecoded;
72 int64_t mNumVideoFramesDropped;
73 int64_t mConsecutiveFramesDropped;
74 uint32_t mCatchupTimeStart;
75 uint32_t mNumTimesSyncLoss;
76 uint32_t mMaxEarlyDelta;
77 uint32_t mMaxLateDelta;
78 uint32_t mMaxTimeSyncLoss;
79 uint64_t mTotalFrames;
80 int64_t mFirstFrameLatencyStartUs;
81 int64_t mLastFrame;
82 int64_t mLastFrameUs;
83 double mFPSSumUs;
84 int64_t mStatisticsFrames;
85 bool mVeryFirstFrame;
86 bool mSeekPerformed;
87 int64_t mTotalTime;
88 int64_t mFirstFrameTime;
89 uint64_t mTotalRenderingFrames;
Naupada Dharmendra Patnaik84a8aa12013-02-01 14:34:07 +053090 bool mBufferingEvent;
Surajit Podder852ebd52013-02-21 15:05:18 +053091 int mFd;
92 FILE *mFileOut;
Ajit Khare73cfaf42013-01-07 23:28:47 -080093};
94
95} // namespace android
96
97#endif // DASHPLAYER_STATS_H_