blob: c7b986e06009a8b746f75445511fd66a5b7f698e (
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
|
/***************************************************************************
soundstreamevent.h - description
-------------------
begin : Fri May 06 2005
copyright : (C) 2005 by Martin Witte
email : [email protected]
***************************************************************************/
/***************************************************************************
* *
* 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_RECORDING_SOUNDSTREAM_EVENT_H
#define KRADIO_RECORDING_SOUNDSTREAM_EVENT_H
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include <tqevent.h>
#include "../../src/include/sound_metadata.h"
const TQEvent::Type EncodingTerminated = (TQEvent::Type)(TQEvent::User+1);
const TQEvent::Type EncodingStep = (TQEvent::Type)(TQEvent::User+2);
class SoundStreamEvent : public TQEvent
{
public:
SoundStreamEvent(TQEvent::Type t, SoundStreamID id) : TQEvent(t), m_SSID(id) {}
const SoundStreamID &getSoundStreamID() const { return m_SSID; }
static bool isSoundStreamEvent (const TQEvent *e) { return e && ((e->type() == EncodingTerminated) || (e->type() == EncodingStep)); }
protected:
SoundStreamID m_SSID;
};
class SoundStreamEncodingTerminatedEvent : public SoundStreamEvent
{
public:
SoundStreamEncodingTerminatedEvent(SoundStreamID id) : SoundStreamEvent(EncodingTerminated, id) {}
};
class SoundStreamEncodingStepEvent : public SoundStreamEvent
{
public:
SoundStreamEncodingStepEvent(SoundStreamID id, const char *data, size_t size, const SoundMetaData &md)
: SoundStreamEvent(EncodingStep, id),
m_Size(size),
m_MetaData(md)
{
m_Data = new char [m_Size];
memcpy (m_Data, data, m_Size);
}
virtual ~SoundStreamEncodingStepEvent() { freeData(); }
void freeData() { if (m_Data) delete m_Data; m_Data = NULL; m_Size = 0; } // _MUST_ be called by event receiver
const char *data() const { return m_Data; }
size_t size() const { return m_Size; }
const SoundMetaData &metaData() const { return m_MetaData; }
static bool isSoundStreamEncodingStep (const TQEvent *e) { return e && (e->type() == EncodingStep); }
protected:
char *m_Data;
size_t m_Size;
SoundMetaData m_MetaData;
};
#endif
|