You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
102 lines
3.5 KiB
102 lines
3.5 KiB
15 years ago
|
/***************************************************************************
|
||
|
encoder.h - description
|
||
|
-------------------
|
||
|
begin : Thu May 05 2005
|
||
|
copyright : (C) 2005 by 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_RECORDING_ENCODER_H
|
||
|
#define KRADIO_RECORDING_ENCODER_H
|
||
|
|
||
|
#ifdef HAVE_CONFIG_H
|
||
|
#include <config.h>
|
||
|
#endif
|
||
|
|
||
|
|
||
14 years ago
|
#include <tqobject.h>
|
||
|
#include <tqstring.h>
|
||
|
#include <tqthread.h>
|
||
15 years ago
|
|
||
|
#include "../../src/include/radiostation.h"
|
||
|
#include "../../src/include/multibuffer.h"
|
||
|
#include "../../src/include/sound_metadata.h"
|
||
|
#include "../../src/include/soundstreamid.h"
|
||
|
#include "recording-config.h"
|
||
|
|
||
|
class BufferSoundMetaData : public SoundMetaData
|
||
|
{
|
||
|
public:
|
||
|
BufferSoundMetaData()
|
||
|
: SoundMetaData(0, 0, 0, KURL()), m_BufferPosition(0) {}
|
||
|
BufferSoundMetaData(const SoundMetaData &md, size_t bufferpos)
|
||
|
: SoundMetaData(md), m_BufferPosition(bufferpos) {}
|
||
14 years ago
|
BufferSoundMetaData(TQ_INT64 pos, time_t rel, time_t abs, const KURL &url, size_t bufferpos)
|
||
15 years ago
|
: SoundMetaData(pos, rel, abs, url), m_BufferPosition(bufferpos) {}
|
||
|
|
||
|
size_t bufferPosition() const { return m_BufferPosition; }
|
||
|
|
||
|
protected:
|
||
|
size_t m_BufferPosition;
|
||
|
};
|
||
|
|
||
|
|
||
14 years ago
|
class RecordingEncoding : public TQThread
|
||
15 years ago
|
{
|
||
|
public:
|
||
13 years ago
|
RecordingEncoding(TQObject *parent, SoundStreamID id, const RecordingConfig &cfg, const RadioStation *rs, const TQString &filename);
|
||
15 years ago
|
virtual ~RecordingEncoding();
|
||
|
|
||
|
void run();
|
||
|
|
||
|
char *lockInputBuffer(size_t &bufferSize); // bytes we whish to write, returns number of bytes available
|
||
|
void unlockInputBuffer(size_t bufferSize, const SoundMetaData &md); // bytes we actually wrote
|
||
|
|
||
|
bool error() const { return m_error; }
|
||
14 years ago
|
const TQString &errorString() const { return m_errorString; }
|
||
15 years ago
|
|
||
|
void setDone();
|
||
|
bool IsDone() { return m_done; }
|
||
|
|
||
14 years ago
|
virtual bool openOutput(const TQString &outputFile) = 0;
|
||
15 years ago
|
virtual void closeOutput() = 0;
|
||
|
|
||
14 years ago
|
TQ_UINT64 encodedSize() const { return m_encodedSize; }
|
||
15 years ago
|
|
||
|
const RecordingConfig &config() const { return m_config; }
|
||
|
|
||
|
protected:
|
||
|
virtual void encode(const char *_buffer, size_t buffer_size, char *&export_buffer, size_t &export_buffer_size) = 0;
|
||
|
|
||
14 years ago
|
TQObject *m_parent;
|
||
15 years ago
|
RecordingConfig m_config;
|
||
|
RadioStation *m_RadioStation;
|
||
|
SoundStreamID m_SoundStreamID;
|
||
|
|
||
|
bool m_error;
|
||
14 years ago
|
TQString m_errorString;
|
||
15 years ago
|
bool m_done;
|
||
|
|
||
|
MultiBuffer m_InputBuffers;
|
||
14 years ago
|
TQPtrList<BufferSoundMetaData>
|
||
15 years ago
|
**m_buffersMetaData;
|
||
14 years ago
|
TQ_UINT64 m_encodedSize;
|
||
15 years ago
|
|
||
|
time_t m_InputStartTime;
|
||
14 years ago
|
TQ_UINT64 m_InputStartPosition;
|
||
15 years ago
|
|
||
|
KURL m_outputURL;
|
||
|
};
|
||
|
|
||
|
|
||
|
#endif
|