summaryrefslogtreecommitdiffstats
path: root/mpeglib/lib/output/threadSafeOutputStream.h
blob: c9852a373359242839cf8a59cf01521e850c18dc (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
/*
  thread safe wrapper for output Stream
  Copyright (C) 2000  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 __THREADSAFEOUTPUTSTREAM_H
#define __THREADSAFEOUTPUTSTREAM_H

// read INTRO in threadQueue.h
// This class makes the outputStream (given in constructor)
// threadsafe by wrapping each call with a threadqueue.
//
// Important NOTE: the output pointer is the owned by this class !!!
//                 which means: we call delete on it!
// More Important NOTES:
//
// We make the audio and video calls seperate threadsafe
// and ONLY the config call threadsafe to both!

#include "../util/abstract/threadQueue.h"
#include "outputStream.h"


class ThreadSafeOutputStream : public OutputStream {

  ThreadQueue* threadQueueAudio;
  ThreadQueue* threadQueueVideo;
  OutputStream* output;

 public:
  ThreadSafeOutputStream(OutputStream* output);
  ~ThreadSafeOutputStream();

  // Thread safe Audio Stream handling
  int audioInit();
  int audioSetup(int freq,int stereo,int sign,int big,int sampleSize);
  int audioPlay(TimeStamp* startStamp,
		TimeStamp* endStamp,char *buffer, int size);  
  void audioFlush();
  void audioClose();
  void audioOpen();
  int getPreferredDeliverSize();
  
  
  // Video Output
  int videoInit();
  int openWindow(int width, int height,const char *title);
  void closeWindow();
  void flushWindow();
  PictureArray* lockPictureArray();
  void unlockPictureArray(PictureArray* pictureArray);
  int getFrameusec();
  
  // config Output
  void config(const char* key, 
	      const char* value,void* user_data);


};
#endif