summaryrefslogtreecommitdiffstats
path: root/mpeglib/lib/output/avSyncer.h
blob: b5a7ae7d925838fe288c33a9dabbaab07173117f (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
93
94
95
96
/*
  encapsulates the syncing methods, to use it in other classes
  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 __AVSYNCER_H
#define __AVSYNCER_H

#include <stdlib.h>

#include "../util/render/yuvPicture.h"
#include "../util/syncClock.h"
#include "audioTime.h"

class Performance;
class AudioDataArray;
class AudioData;

class AVSyncer {

  AudioData* audioDataInsert;
  AudioData* audioDataCurrent;
  AudioDataArray* audioDataArray;
  Performance* performance;

  AudioTime* audioTime;
  int onePicFrameInAudioBytes;
  int oneFrameTime;

  int lAudioRunning;

  abs_thread_mutex_t writeInMut;
  abs_thread_mutex_t changeMut;


  int bufferSize;

  TimeStamp* startAudio;
  TimeStamp* endAudio;
  
  TimeStamp* videoTimeStamp;
  TimeStamp* diffTime;
  TimeStamp* waitTime;

  int lPerformance;
  int lavSync;
  int lastAudioPacket;
  double pts_jitter;


 public:
  AVSyncer(int bufferSize);
  ~AVSyncer();

  // audio
  int audioSetup(int frequency,int stereo,int sign,int big,int sixteen);
  int audioPlay(TimeStamp* startStamp,
		TimeStamp* endStamp,char *buffer, int size);
  void audioClose(void);
  void setAudioBufferSize(int size);

  int getPreferredDeliverSize();

  // video
  int getFrameusec();
  int syncPicture(YUVPicture* syncPic);

  void config(const char* key,const char* value,void* user_data);



 private:
  int getAudioRunning();
  void setAudioRunning(int lAudioRunning);

  void lockSyncData();
  void unlockSyncData();
  void setAudioSync(AudioData* audioData);
 
   // methods which belong not to the OutputStream interface
  int avSync(TimeStamp* startVideoStamp,
	     TimeStamp* waitTime,
	     TimeStamp* earlyTime,
	     float picPerSec);

};
#endif