summaryrefslogtreecommitdiffstats
path: root/mpeglib/lib/output/artsOutputStream.h
blob: 757022fd9f732d9f699e9178d3e18ac730cf6299 (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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
/*
  output to arts
  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 __ARTSOUTPUTSTREAM_H
#define __ARTSOUTPUTSTREAM_H

#include "outputStream.h"
#include "../input/bufferInputStream.h"
#include "audioTime.h"


class WindowOut;
class AVSyncer;




/**
   a word about synchronisation: Arts currently has not asynchronous
   starting of stream, which means, poll if stream is initialized
   or set a callbackfunction.

   mpeglib is threaded and would not have much problems
   with a "callback" but currently we only support blocking wait
   for initilisation.

   I think, if people realize that smooth mixing of streams
   is impossible(because of the blocking start behaviour),
   this will become a desired feature :-)

*/


/**
   This class offers a blocking device, its behaviour is similar
   to /dev/dsp we use a buffer to store the pcm data, if
   we open/close the buffer the stored data is removed
   and the blocking thread is "kicked"

   Arts must first wait for an init signal. it has its own
   method to check for eof. during seek we close this
   device, after seek we reopen it.

   close and open have the same functionality, they simply
   clear the buffer.
*/

   

class ArtsOutputStream : public OutputStream {

  BufferInputStream* stream;
  AudioTime* audioTime;

  void (*streamStateChangeCallback)(void*);

  WindowOut* x11Window;
  AVSyncer* avSyncer;
  int privateBufferSize;
  class ThreadQueue* threadQueue;

 public:
  ArtsOutputStream(void (*streamStateChangeCallback)(void*));
  ~ArtsOutputStream();

  // Audio part

  int audioSetup(int freq,int stereo,int sign,int big,int sampleSize);
  void audioClose();
  void audioOpen();
  void audioFlush();
  
  int audioPlay(TimeStamp* startStamp,
		TimeStamp* endStamp,char *buffer, int size);


  AudioTime* getAudioTime();

  int getPreferredDeliverSize();

  // Video part

  int openWindow(int width, int height,const char *title);
  int x11WindowId();
  void closeWindow();
  void flushWindow();

  PictureArray* lockPictureArray();
  void unlockPictureArray(PictureArray* pictureArray);

  int getFrameusec();

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

  // Remote read extension

  int read(char** buffer,int bytes);
  void forwardReadPtr(int bytes);

  // buffer control
  int getBufferFillgrade();

  // sync control
  void setAudioBufferSize(int size);
  
 private:
  void sendSignal(int state,int value);
  void initStream();
  
};
#endif