summaryrefslogtreecommitdiffstats
path: root/mpeglib/lib/util/timeStamp.h
blob: a45bb582f01ae8f51d577e8e726e6eb8fe6f30bc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
/*
  class for managing byte positions and associated time positions
  Copyright (C) 1999  Martin Vogt

  This program is free software; you can redistribute it and/or modify
  it under the terms of the GNU Library General Public License as published by
  the Free Software Foundation.

  For more information look at the file COPYRIGHT in this package

 */


#ifndef __TIMESTAMP_H
#define __TIMESTAMP_H


#include "syncClock.h"


class TimeStamp {

  long key;
  int keylen;

  int videoFrameCounter;

  timeval_t time;

  int lPTSFlag;

  double ptsTimeStamp;
  double scrTimeStamp;
  double dtsTimeStamp;

  class SyncClock* syncClock;

 public:
  TimeStamp();
  ~TimeStamp();
  
  void gettimeofday();
  void set(long sec,long usec);

  void addOffset(TimeStamp* stamp);
  void addOffset(int sec,long usec);
  void copyTo(TimeStamp* dest);

  long getKey();
  int getKeyLen();
  void setKey(long key,int keylen);

  int getPTSFlag();
  void setPTSFlag(int lPTSFlag);
 

  double getPTSTimeStamp();
  void setPTSTimeStamp(double ptsTimeStamp);

  double getDTSTimeStamp();
  void setDTSTimeStamp(double dtsTimeStamp);

  double getSCRTimeStamp();
  void setSCRTimeStamp(double scrTimeStamp);

  int getVideoFrameCounter();
  void setVideoFrameCounter(int nr);

  SyncClock* getSyncClock();
  void setSyncClock(class SyncClock* syncClock);


  void print(const char* name);
  void minus(TimeStamp* stamp,TimeStamp* dest);
  void minus(int sec,long usec);
  int lessThan(TimeStamp* stamp);
  int lessThan(int sec,long usec);
  double getAsSeconds();

  void waitForIt();
  timeval_t* getTime();

  int isPositive();
  int isNegative();

 private:
  void setTime(timeval_t* newTime);
  void normalize();


};
#endif