~ubuntu-branches/ubuntu/hoary/kdemultimedia/hoary

« back to all changes in this revision

Viewing changes to mpeglib/lib/util/syncClockMPEG.h

  • Committer: Bazaar Package Importer
  • Author(s): Martin Schulze
  • Date: 2003-01-22 15:00:51 UTC
  • Revision ID: james.westby@ubuntu.com-20030122150051-uihwkdoxf15mi1tn
Tags: upstream-2.2.2
ImportĀ upstreamĀ versionĀ 2.2.2

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
  synchronisation of audio/video (PTS) against system clock stamps (SCR)
 
3
  Copyright (C) 2000 Martin Vogt
 
4
 
 
5
  This program is free software; you can redistribute it and/or modify
 
6
  it under the terms of the GNU Library General Public License as published by
 
7
  the Free Software Foundation.
 
8
 
 
9
  For more information look at the file COPYRIGHT in this package
 
10
 
 
11
 */
 
12
 
 
13
 
 
14
#ifndef __SYNCCLOCKMPEG_H
 
15
#define __SYNCCLOCKMPEG_H
 
16
 
 
17
 
 
18
#include "syncClock.h"
 
19
 
 
20
/**
 
21
   The idea is similar to this:
 
22
   We start a clock and selext a synchronisation mode.
 
23
   (AUDIO,VIDEO,BOTH,NONE)
 
24
   Assume we select AUDIO. When the audio thread delivers an SCR
 
25
   and an PTS, we set the SCR from this set, as the new
 
26
   time reference fo rthis clock.
 
27
   If a video thread enters the class, with an SCR,PTS we wait,
 
28
   or directly return if the PTS is in time or out of time,
 
29
   but we never set the SCR.
 
30
*/
 
31
 
 
32
class SyncClockMPEG : public SyncClock {   
 
33
 
 
34
  int syncMode;
 
35
  double lastSCR;
 
36
  double lastPTS;
 
37
  double jitter;
 
38
  double oldjitter;
 
39
  timeval_t lastSCR_time;
 
40
  timeval_t lastPTS_time;
 
41
  timeval_t drift_time;
 
42
 
 
43
 public:
 
44
  SyncClockMPEG();
 
45
  ~SyncClockMPEG();
 
46
 
 
47
  int getSyncMode();
 
48
  void setSyncMode(int syncMode);
 
49
 
 
50
  
 
51
  int syncAudio(double pts,double scr);
 
52
  int syncVideo(double pts,double scr,
 
53
                class TimeStamp* earlyTime,class TimeStamp* waitTime);
 
54
 
 
55
  void print(char* text);
 
56
 
 
57
  double getPTSTime(double* window);
 
58
 private:
 
59
 
 
60
  void printTime(timeval_t* a,char* text);
 
61
  void markLastPTSTime(double scr,double pts);
 
62
  int gowait(double scr,double pts,
 
63
             class TimeStamp* earlyTime,class TimeStamp* waitTime);
 
64
  int a_Minus_b_Is_C(timeval_t* a,timeval_t* b,timeval_t* c);
 
65
  double timeval2Double(timeval_t* a);
 
66
  void double2Timeval(double a,timeval_t* dest);
 
67
 
 
68
  void lockSyncClock();
 
69
  void unlockSyncClock();
 
70
 
 
71
  abs_thread_mutex_t scrMut; 
 
72
  abs_thread_mutex_t changeMut; 
 
73
 
 
74
 
 
75
};
 
76
#endif
 
77