From ec59caa0f62e7e6cba50251a70a500ec1e166998 Mon Sep 17 00:00:00 2001 From: Stefan Sayer Date: Wed, 19 Mar 2008 13:28:06 +0000 Subject: [PATCH] functions to o reset Audio format o get current payload (quiz? what comes next?) git-svn-id: http://svn.berlios.de/svnroot/repos/sems/trunk@819 8eb893ce-cfd4-0310-b710-fb5ebe64c474 --- core/AmAudio.cpp | 11 +++++++++-- core/AmAudio.h | 18 ++++++++++++------ core/AmAudioFile.h | 13 ++++--------- core/AmRtpAudio.cpp | 4 ++++ core/AmRtpAudio.h | 1 + 5 files changed, 30 insertions(+), 17 deletions(-) diff --git a/core/AmAudio.cpp b/core/AmAudio.cpp index 58c083ce..594436c4 100644 --- a/core/AmAudio.cpp +++ b/core/AmAudio.cpp @@ -223,6 +223,10 @@ void AmAudioFormat::destroyCodec() codec = NULL; } +void AmAudioFormat::resetCodec() { + codec = NULL; + getCodec(); +} amci_codec_t* AmAudioFormat::getCodec() { @@ -270,6 +274,11 @@ AmAudio::~AmAudio() #endif } +void AmAudio::setFormat(AmAudioFormat* new_fmt) { + fmt.reset(new_fmt); + fmt->resetCodec(); +} + void AmAudio::close() { } @@ -495,8 +504,6 @@ void DblBuffer::swap() active_buf = !active_buf; } - - int AmAudioRtpFormat::getCodecId() { if(!m_currentPayloadP){ diff --git a/core/AmAudio.h b/core/AmAudio.h index 9be89379..cc8187bc 100644 --- a/core/AmAudio.h +++ b/core/AmAudio.h @@ -109,11 +109,11 @@ public: int channels; /** Sampling rate. */ int rate; - /* frame length in samples (frame based codecs) */ + /* frame length in ms (frame based codecs) - unused */ int frame_length; - /* frame size in bytes */ + /* frame size in samples */ int frame_size; - /* encoded frame size in bytes */ + /* encoded frame size in bytes - unused */ int frame_encoded_size; string sdp_format_parameters; @@ -122,7 +122,9 @@ public: virtual ~AmAudioFormat(); /** @return The format's codec pointer. */ - amci_codec_t* getCodec(); + virtual amci_codec_t* getCodec(); + void resetCodec(); + /** @return Handler returned by the codec's init function.*/ long getHCodec(); long getHCodecNoInit() { return h_codec; } // do not initialize @@ -158,7 +160,7 @@ class AmAudioSimpleFormat: public AmAudioFormat int codec_id; protected: - int getCodecId() { return codec_id; } + virtual int getCodecId() { return codec_id; } public: AmAudioSimpleFormat(int codec_id); @@ -176,7 +178,7 @@ class AmAudioRtpFormat: public AmAudioFormat std::map m_codecContainerByPayload; protected: - int getCodecId(); + virtual int getCodecId(); public: /** @@ -191,6 +193,8 @@ public: * changes payload. returns != 0 on error. */ int setCurrentPayload(int payload); + + int getCurrentPayload() { return m_currentPayload; }; }; /** @@ -299,6 +303,8 @@ public: int incRecordTime(unsigned int samples); void setBufferedOutput(unsigned int buffer_size); + + void setFormat(AmAudioFormat* new_fmt); }; diff --git a/core/AmAudioFile.h b/core/AmAudioFile.h index f7b6d228..e9acbf35 100644 --- a/core/AmAudioFile.h +++ b/core/AmAudioFile.h @@ -54,20 +54,15 @@ public: * @param subtype Subtype for the file format (see amci.h). */ AmAudioFileFormat(const string& name, int subtype = -1); - /** - * Constructor for file based formats. - * All information are taken from the file descriptor. - * @param name The file format name (ex. "Wav"). - * @param fd A file descriptor filled by the a plug-in's open function. - */ - AmAudioFileFormat(const string& name, const amci_file_desc_t* fd); + + virtual ~AmAudioFileFormat() { } /** @return Format name. */ string getName() { return name; } /** @return Format subtype. */ int getSubtypeId() { return subtype; } /** @return Subtype pointer. */ - amci_subtype_t* getSubtype(); + virtual amci_subtype_t* getSubtype(); void setSubtypeId(int subtype_id); }; @@ -104,7 +99,7 @@ protected: int write(unsigned int user_ts, unsigned int size); /** @return a file format from file name. (ex: '1234.wav') */ - AmAudioFileFormat* fileName2Fmt(const string& name); + virtual AmAudioFileFormat* fileName2Fmt(const string& name); /** internal function for opening the file */ int fpopen_int(const string& filename, OpenMode mode, FILE* n_fp); diff --git a/core/AmRtpAudio.cpp b/core/AmRtpAudio.cpp index 3477b8a5..315038ec 100644 --- a/core/AmRtpAudio.cpp +++ b/core/AmRtpAudio.cpp @@ -157,6 +157,10 @@ int AmRtpAudio::setCurrentPayload(int payload) return res; } +int AmRtpAudio::getCurrentPayload() { + return ((AmAudioRtpFormat *) fmt.get())->getCurrentPayload(); +} + unsigned int AmRtpAudio::conceal_loss(unsigned int ts_diff, unsigned char *buffer) { int s=0; diff --git a/core/AmRtpAudio.h b/core/AmRtpAudio.h index 768a0fe2..8db4c612 100644 --- a/core/AmRtpAudio.h +++ b/core/AmRtpAudio.h @@ -100,6 +100,7 @@ public: bool sendIntReached(); int setCurrentPayload(int payload); + int getCurrentPayload(); int receive(unsigned int wallclock_ts);