summaryrefslogtreecommitdiffstats
path: root/mpeglib_artsplug/decoderBaseObject_impl.h
blob: 6ed3f6da08f616ceabdae0e6f23f0fcc84de0654 (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
/*
  base class for all mpeglib decoders
  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 __DECODERBASEOBJECT_IMPL_H
#define __DECODERBASEOBJECT_IMPL_H


#include <math.h>
#include "decoderBaseObject.h"
#include "stdsynthmodule.h"
#include "convert.h"
#include <X11/Xlib.h>
#include <audiosubsys.h>
#include <stdio.h>
#include <string.h>

#include <arts/kmedia2.h>

#define _THREADSTATE_INIT         0
#define _THREADSTATE_OPENED       1
#define _THREADSTATE_PAUSED       2
#define _THREADSTATE_PLAYING      3
#define _THREADSTATE_CLOSED       4

#include <queue>

class DecoderPlugin;
class InputStream;
class ArtsOutputStream;

using namespace std;
using Arts::poState;
using Arts::poTime;
using Arts::poCapabilities;
using Arts::DataPacket;
using Arts::mcopbyte;

class DecoderBaseObject_impl :
  virtual public Arts::StdSynthModule,
  virtual public DecoderBaseObject_skel {

  poState _state;
  InputStream* m_inputStream;
  Arts::InputStream m_artsInputStream;
  ArtsOutputStream* m_outputStream;
  
  double flpos;
  float startTime;
  int instance;
  int lastAudioBufferSize;
  int streamState;
  bool _blocking;
  float _speed;

  bool m_streaming;

  queue<DataPacket<mcopbyte>*> *m_packetQueue;

public:

  DecoderBaseObject_impl();
  virtual ~DecoderBaseObject_impl();

  virtual DecoderPlugin* createPlugin();
  virtual InputStream* createInputStream(const char* url);
  virtual bool doFloat() { return false; }

  bool loadMedia(const string &filename);
  bool streamMedia(Arts::InputStream instream);
  void process_indata(DataPacket<mcopbyte>* inpacket);
  Arts::InputStream inputStream() { return m_artsInputStream; }

  string description();
  void description(const string &);

  poTime currentTime();
  poTime overallTime();

  poCapabilities capabilities();
  string mediaName();
  poState state();
  void play();
  void halt();

  void blocking(bool newvalue);
  bool blocking();

  void speed(float newValue);
  float speed();

  void seek(const class poTime &);
  void pause();
  void streamInit();
  void streamStart();
  void calculateBlock(unsigned long samples,float* left,float* right);
  void streamEnd();
 
  DecoderPlugin* decoderPlugin;
  
 private:
  void shudownPlugins();
  int getBufferSize();
  int fillArts(unsigned long samples,float* left , float* right);
  void setStreamState(int state);
  void processQueue();

};



#endif