summaryrefslogtreecommitdiffstats
path: root/tderadio3/plugins/timeshifter/timeshifter.h
blob: cada015d85388cf8b89ab68c115384ede81ac316 (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
/***************************************************************************
                          timeshifter.h  -  description
                             -------------------
    begin                : May 16 2005
    copyright            : (C) 2005 Ernst Martin Witte
    email                : witte@kawo1.rwth-aachen.de
 ***************************************************************************/

/***************************************************************************
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
 ***************************************************************************/

#ifndef KRADIO_TIMESHIFTER_H
#define KRADIO_TIMESHIFTER_H

#ifdef HAVE_CONFIG_H
#include <config.h>
#endif

#include "../../src/include/plugins.h"
#include "../../src/include/soundstreamclient_interfaces.h"
#include "../../src/include/fileringbuffer.h"


class TimeShifter : public TQObject,
                    public PluginBase,
                    public ISoundStreamClient
{
Q_OBJECT
  
public:
    TimeShifter (const TQString &name);
    virtual ~TimeShifter ();

    virtual bool connectI (Interface *);
    virtual bool disconnectI (Interface *);

    virtual TQString pluginClassName() const { return "TimeShifter"; }

    virtual const TQString &name() const { return PluginBase::name(); }
    virtual       TQString &name()       { return PluginBase::name(); }

    // config

    const TQString &getPlaybackMixer()        const { return m_PlaybackMixerID; }
    const TQString &getPlaybackMixerChannel() const { return m_PlaybackMixerChannel; }
    const TQString &getTempFileName()         const { return m_TempFileName; }
    TQ_UINT64       getTempFileMaxSize()      const { return m_TempFileMaxSize; }

    void setTempFile(const TQString &filename, TQ_UINT64 s);
    bool setPlaybackMixer(const TQString &soundStreamClientID, const TQString &ch);

    // PluginBase

public:
    virtual void   saveState    (TDEConfig *) const;
    virtual void   restoreState (TDEConfig *);

    virtual ConfigPageInfo  createConfigurationPage();
    virtual AboutPageInfo   createAboutPage();

protected:

    ISoundStreamClient *searchPlaybackMixer();

    size_t writeMetaDataToBuffer(const SoundMetaData &md, char *buffer,  size_t buffer_size);
    size_t readMetaDataFromBuffer(SoundMetaData &md, const char *buffer, size_t buffer_size);
    void skipPacketInRingBuffer();

    // SoundStreamClient
    void noticeConnectedI (ISoundStreamServer *s, bool pointer_valid);

    bool startCaptureWithFormat(SoundStreamID      id,
                      const SoundFormat &proposed_format,
                      SoundFormat       &real_format,
                      bool               force_format);
    bool stopCapture(SoundStreamID id);
    bool noticeSoundStreamClosed(SoundStreamID id);
    bool startPlayback(SoundStreamID id);
    bool stopPlayback(SoundStreamID id);
    bool pausePlayback(SoundStreamID id);
    bool noticeSoundStreamData(SoundStreamID id, const SoundFormat &sf, const char *data, size_t size, size_t &consumed_size, const SoundMetaData &md);
    bool noticeReadyForPlaybackData(SoundStreamID id, size_t size);

    bool getSoundStreamDescription(SoundStreamID id, TQString &descr) const;

    // FIXME: react on redirect request

signals:

    void sigUpdateConfig();

protected:

    TQString             m_TempFileName;
    size_t              m_TempFileMaxSize;
    SoundFormat         m_SoundFormat;
    SoundFormat         m_realSoundFormat;

    TQString             m_PlaybackMixerID;
    TQString             m_PlaybackMixerChannel;

    TQString             m_StreamFile;
    bool                m_StreamPaused;
    SoundStreamID       m_OrgStreamID;
    SoundStreamID       m_NewStreamID;
    SoundFormat         m_RealSoundFormat;
    float               m_orgVolume;

    SoundMetaData       m_PlaybackMetaData;
    size_t              m_PlaybackDataLeftInBuffer;

    FileRingBuffer      m_RingBuffer;
};

#endif