Author: sayer
Date: 2009-05-07 22:42:56 +0200 (Thu, 07 May 2009)
New Revision: 1370
Modified:
branches/wb/core/AmAudio.cpp
branches/wb/core/AmAudio.h
branches/wb/core/AmPrecodedFile.h
branches/wb/core/AmRtpAudio.cpp
branches/wb/core/AmRtpAudio.h
Log:
moved AmAudioRtpFormat to AmRtpAudio.cpp/.h
Modified: branches/wb/core/AmAudio.cpp
===================================================================
--- branches/wb/core/AmAudio.cpp 2009-05-07 20:36:26 UTC (rev 1369)
+++ branches/wb/core/AmAudio.cpp 2009-05-07 20:42:56 UTC (rev 1370)
@@ -39,93 +39,6 @@
#include <typeinfo>
-/** \brief structure to hold loaded codec instances */
-struct CodecContainer
-{
- amci_codec_t *codec;
- int frame_size;
- int frame_length;
- long h_codec;
-};
-
-AmAudioRtpFormat::AmAudioRtpFormat(const vector<SdpPayload *>& payloads)
- : AmAudioFormat(), m_payloads(payloads), m_currentPayload(-1)
-{
- for (vector<SdpPayload *>::iterator it = m_payloads.begin();
- it != m_payloads.end(); ++it)
- {
- m_sdpPayloadByPayload[(*it)->payload_type] = *it;
- }
- setCurrentPayload(m_payloads[0]->payload_type);
-}
-
-int AmAudioRtpFormat::setCurrentPayload(int payload)
-{
- if (m_currentPayload != payload)
- {
- std::map<int, SdpPayload *>::iterator p =
m_sdpPayloadByPayload.find(payload);
- if (p == m_sdpPayloadByPayload.end())
- {
- ERROR("Could not find payload <%i>\n", payload);
- return -1;
- }
- std::map<int, amci_payload_t *>::iterator pp =
m_payloadPByPayload.find(payload);
- if (pp == m_payloadPByPayload.end())
- {
- m_currentPayloadP = AmPlugIn::instance()->payload(p->second->int_pt);
- if (m_currentPayloadP == NULL)
- {
- ERROR("Could not find payload <%i>\n", payload);
- return -1;
- }
- m_payloadPByPayload[payload] = m_currentPayloadP;
- }
- else
- m_currentPayloadP = pp->second;
- m_currentPayload = payload;
- sdp_format_parameters = p->second->sdp_format_parameters;
-
- std::map<int, CodecContainer *>::iterator c =
m_codecContainerByPayload.find(payload);
- if (c == m_codecContainerByPayload.end())
- {
- codec = NULL;
- getCodec();
- if (codec)
- {
- CodecContainer *cc = new CodecContainer();
- cc->codec = codec;
- cc->frame_size = frame_size;
- cc->frame_length = frame_length;
- cc->h_codec = h_codec;
- m_codecContainerByPayload[payload] = cc;
- }
- }
- else
- {
- codec = c->second->codec;
- frame_size = c->second->frame_size;
- frame_length = c->second->frame_length;
- h_codec = c->second->h_codec;
- }
- if (m_currentPayloadP && codec) {
- channels = m_currentPayloadP->channels;
- rate = m_currentPayloadP->sample_rate;
- advertised_rate = m_currentPayloadP->advertised_sample_rate;
- } else {
- ERROR("Could not find payload <%i>\n", payload);
- return -1;
- }
- }
- return 0;
-}
-
-AmAudioRtpFormat::~AmAudioRtpFormat()
-{
- for (std::map<int, CodecContainer *>::iterator it =
- m_codecContainerByPayload.begin(); it !=
m_codecContainerByPayload.end(); ++it)
- delete it->second;
-}
-
AmAudioFormat::AmAudioFormat()
: channels(-1), rate(-1), advertised_rate(-1), codec(NULL),
frame_length(20), frame_size(20*SYSTEM_SAMPLERATE/1000)
@@ -555,13 +468,3 @@
{
active_buf = !active_buf;
}
-
-int AmAudioRtpFormat::getCodecId()
-{
- if(!m_currentPayloadP){
- ERROR("AmAudioRtpFormat::getCodecId: could not find payload %i\n",
m_currentPayload);
- return -1;
- }
- else
- return m_currentPayloadP->codec_id;
-}
Modified: branches/wb/core/AmAudio.h
===================================================================
--- branches/wb/core/AmAudio.h 2009-05-07 20:36:26 UTC (rev 1369)
+++ branches/wb/core/AmAudio.h 2009-05-07 20:42:56 UTC (rev 1370)
@@ -168,37 +168,6 @@
AmAudioSimpleFormat(int codec_id);
};
-
-/** \brief RTP audio format */
-class AmAudioRtpFormat: public AmAudioFormat
-{
- vector<SdpPayload *> m_payloads;
- int m_currentPayload;
- amci_payload_t *m_currentPayloadP;
- std::map<int, SdpPayload *> m_sdpPayloadByPayload;
- std::map<int, amci_payload_t *> m_payloadPByPayload;
- std::map<int, CodecContainer *> m_codecContainerByPayload;
-
-protected:
- virtual int getCodecId();
-
-public:
- /**
- * Constructor for payload based formats.
- * All the information are taken from the
- * payload description in the originating plug-in.
- */
- AmAudioRtpFormat(const vector<SdpPayload *>& payloads);
- ~AmAudioRtpFormat();
-
- /**
- * changes payload. returns != 0 on error.
- */
- int setCurrentPayload(int payload);
-
- int getCurrentPayload() { return m_currentPayload; };
-};
-
// for resampling
struct src_state {
#ifdef USE_LIBSAMPLERATE
Modified: branches/wb/core/AmPrecodedFile.h
===================================================================
--- branches/wb/core/AmPrecodedFile.h 2009-05-07 20:36:26 UTC (rev 1369)
+++ branches/wb/core/AmPrecodedFile.h 2009-05-07 20:42:56 UTC (rev 1370)
@@ -33,6 +33,7 @@
#include "amci/amci.h"
#include "AmAudioFile.h"
#include "AmAudio.h"
+#include "AmRtpAudio.h"
#include <string>
#include <map>
Modified: branches/wb/core/AmRtpAudio.cpp
===================================================================
--- branches/wb/core/AmRtpAudio.cpp 2009-05-07 20:36:26 UTC (rev 1369)
+++ branches/wb/core/AmRtpAudio.cpp 2009-05-07 20:42:56 UTC (rev 1370)
@@ -32,6 +32,108 @@
#include "AmPlayoutBuffer.h"
#include "amci/codecs.h"
+
+/** AmAudioRtpFormat */
+
+/** \brief structure to hold loaded codec instances */
+struct CodecContainer
+{
+ amci_codec_t *codec;
+ int frame_size;
+ int frame_length;
+ long h_codec;
+};
+
+AmAudioRtpFormat::AmAudioRtpFormat(const vector<SdpPayload *>& payloads)
+ : AmAudioFormat(), m_payloads(payloads), m_currentPayload(-1)
+{
+ for (vector<SdpPayload *>::iterator it = m_payloads.begin();
+ it != m_payloads.end(); ++it)
+ {
+ m_sdpPayloadByPayload[(*it)->payload_type] = *it;
+ }
+ setCurrentPayload(m_payloads[0]->payload_type);
+}
+
+int AmAudioRtpFormat::setCurrentPayload(int payload)
+{
+ if (m_currentPayload != payload)
+ {
+ std::map<int, SdpPayload *>::iterator p =
m_sdpPayloadByPayload.find(payload);
+ if (p == m_sdpPayloadByPayload.end())
+ {
+ ERROR("Could not find payload <%i>\n", payload);
+ return -1;
+ }
+ std::map<int, amci_payload_t *>::iterator pp =
m_payloadPByPayload.find(payload);
+ if (pp == m_payloadPByPayload.end())
+ {
+ m_currentPayloadP = AmPlugIn::instance()->payload(p->second->int_pt);
+ if (m_currentPayloadP == NULL)
+ {
+ ERROR("Could not find payload <%i>\n", payload);
+ return -1;
+ }
+ m_payloadPByPayload[payload] = m_currentPayloadP;
+ }
+ else
+ m_currentPayloadP = pp->second;
+ m_currentPayload = payload;
+ sdp_format_parameters = p->second->sdp_format_parameters;
+
+ std::map<int, CodecContainer *>::iterator c =
m_codecContainerByPayload.find(payload);
+ if (c == m_codecContainerByPayload.end())
+ {
+ codec = NULL;
+ getCodec();
+ if (codec)
+ {
+ CodecContainer *cc = new CodecContainer();
+ cc->codec = codec;
+ cc->frame_size = frame_size;
+ cc->frame_length = frame_length;
+ cc->h_codec = h_codec;
+ m_codecContainerByPayload[payload] = cc;
+ }
+ }
+ else
+ {
+ codec = c->second->codec;
+ frame_size = c->second->frame_size;
+ frame_length = c->second->frame_length;
+ h_codec = c->second->h_codec;
+ }
+ if (m_currentPayloadP && codec) {
+ channels = m_currentPayloadP->channels;
+ rate = m_currentPayloadP->sample_rate;
+ advertised_rate = m_currentPayloadP->advertised_sample_rate;
+ } else {
+ ERROR("Could not find payload <%i>\n", payload);
+ return -1;
+ }
+ }
+ return 0;
+}
+
+AmAudioRtpFormat::~AmAudioRtpFormat()
+{
+ for (std::map<int, CodecContainer *>::iterator it =
+ m_codecContainerByPayload.begin(); it !=
m_codecContainerByPayload.end(); ++it)
+ delete it->second;
+}
+
+
+int AmAudioRtpFormat::getCodecId()
+{
+ if(!m_currentPayloadP){
+ ERROR("AmAudioRtpFormat::getCodecId: could not find payload %i\n",
m_currentPayload);
+ return -1;
+ }
+ else
+ return m_currentPayloadP->codec_id;
+}
+
+/** AmRtpAudio */
AmRtpAudio::AmRtpAudio(AmSession* _s)
: AmRtpStream(_s), AmAudio(0),
use_default_plc(true),
Modified: branches/wb/core/AmRtpAudio.h
===================================================================
--- branches/wb/core/AmRtpAudio.h 2009-05-07 20:36:26 UTC (rev 1369)
+++ branches/wb/core/AmRtpAudio.h 2009-05-07 20:42:56 UTC (rev 1370)
@@ -45,8 +45,6 @@
SIMPLE_PLAYOUT
};
-
-
/**
* \brief interface for PLC buffer
*/
@@ -63,6 +61,36 @@
virtual ~AmPLCBuffer() { }
};
+/** \brief RTP audio format */
+class AmAudioRtpFormat: public AmAudioFormat
+{
+ vector<SdpPayload *> m_payloads;
+ int m_currentPayload;
+ amci_payload_t *m_currentPayloadP;
+ std::map<int, SdpPayload *> m_sdpPayloadByPayload;
+ std::map<int, amci_payload_t *> m_payloadPByPayload;
+ std::map<int, CodecContainer *> m_codecContainerByPayload;
+
+protected:
+ virtual int getCodecId();
+
+public:
+ /**
+ * Constructor for payload based formats.
+ * All the information are taken from the
+ * payload description in the originating plug-in.
+ */
+ AmAudioRtpFormat(const vector<SdpPayload *>& payloads);
+ ~AmAudioRtpFormat();
+
+ /**
+ * changes payload. returns != 0 on error.
+ */
+ int setCurrentPayload(int payload);
+
+ int getCurrentPayload() { return m_currentPayload; };
+};
+
/**
* \brief binds together a \ref AmRtpStream and an \ref AmAudio for a session
*/
_______________________________________________
Semsdev mailing list
[email protected]
http://lists.iptel.org/mailman/listinfo/semsdev