Exemplo n.º 1
0
unsigned EthernetFrame::extractPayloadLength() const {
	ACE_TRACE("EthernetFrame::extractPayloadLength");
	
	if ( getPayloadType() <= 1500 ) return getPayloadType();
	
	unsigned len = 0; 
	
	switch ((PayloadType) getPayloadType()) {
		case Eth_IPv4:
			len = to_u16_(ptrPayload() + 2);
			break;
			
		case Eth_ARP:
			len = 46;
			break;
			
		case Eth_IPv6:
			len = 40 + to_u16_(ptrPayload() + 4);
			break;
			
		default:
			throw nd_error("EthernetFrame::extractPayloadLength() attempted on unrecognized payload.");
	}
	
	return len;
}
Exemplo n.º 2
0
OsStatus MpdPtAVT::initDecode(MpConnection* pConnection)
{
   int res = 0;
   debugCtr = 0;

   if (NULL != mpJBState) {
      return OS_SUCCESS;  // we already did this, no need to do it again.
   }

   //Get JB pointer
   mpJBState = pConnection->getJBinst(TRUE);

   if (NULL != mpJBState) {
      int payloadType = getPayloadType();

      res = JB_initCodepoint(mpJBState,
         (char*) ("audio/telephone-event"), 8000, payloadType);

      OsSysLog::add(FAC_MP, PRI_DEBUG, "%sMpdAVT: registered with JB (pt=%d), res=%d\n",
         ((0==res) ? "" : " ***** "), payloadType, res);
   } else {
      OsSysLog::add(FAC_MP, PRI_DEBUG, "MpdAVT: NOT registering with JB\n");
   }

   return (0 == res) ? OS_SUCCESS : OS_UNSPECIFIED;
}
Exemplo n.º 3
0
std::string EthernetFrame::getEtherTypeStr() {
	ACE_TRACE("EthernetFrame::getEtherTypeStr");
	
	switch (getPayloadType()) {
		case Eth_IPv4: return "IPv4";
		case Eth_ARP: return "ARP";
		case Eth_IPv6: return "IPv6";
		default: return "Unhandled type";
	}
}
Exemplo n.º 4
0
OsStatus MpdSipxPcma::initDecode(MpConnection* pConnection)
{
   //Get JB pointer
   pJBState = pConnection->getJBinst();

   // Set the payload number for JB
   JB_initCodepoint(pJBState, "PCMA", 8000, getPayloadType());

   return OS_SUCCESS;
}
Exemplo n.º 5
0
OsStatus MpdGIPSPCMA::initDecode(MpConnection* pConnection)
{
   //Get NetEq pointer
   mpJBState = pConnection->getJBinst();

   // Set the payload number for NetEq
   NETEQ_GIPS_10MS16B_initCodepoint(mpJBState, const_cast <char*> ("PCMA"),
                                    8000, getPayloadType());

   return OS_SUCCESS;
}
Exemplo n.º 6
0
bool MIPRTPL16Encoder::push(const MIPComponentChain &chain, int64_t iteration, MIPMessage *pMsg)
{
	if (!m_init)
	{
		setErrorString(MIPRTPL16ENCODER_ERRSTR_NOTINIT);
		return false;
	}
	
	if (m_prevIteration != iteration)
	{
		m_prevIteration = iteration;
		clearMessages();
	}
	
	if (!(pMsg->getMessageType() == MIPMESSAGE_TYPE_AUDIO_RAW && pMsg->getMessageSubtype() == MIPRAWAUDIOMESSAGE_TYPE_S16BE))
	{
		setErrorString(MIPRTPL16ENCODER_ERRSTR_BADMESSAGE);
		return false;
	}
	
	MIPRaw16bitAudioMessage *pRawMsg = (MIPRaw16bitAudioMessage *)pMsg;
	int sampRate = pRawMsg->getSamplingRate();
	int channels = pRawMsg->getNumberOfChannels();
	
	if (sampRate != m_sampRate)
	{
		setErrorString(MIPRTPL16ENCODER_ERRSTR_BADSAMPLINGRATE);
		return false;
	}
	if (channels != m_channels)
	{
		setErrorString(MIPRTPL16ENCODER_ERRSTR_BADCHANNELS);
		return false;
	}
	
	const uint16_t *pFrames = pRawMsg->getFrames();
	bool marker = false;
	size_t length = pRawMsg->getNumberOfFrames() * m_channels * sizeof(uint16_t);
	uint8_t *pPayload = new uint8_t [length];

	memcpy(pPayload,pFrames,length);

	MIPRTPSendMessage *pNewMsg;

	pNewMsg = new MIPRTPSendMessage(pPayload,length,getPayloadType(),marker,pRawMsg->getNumberOfFrames());
	pNewMsg->setSamplingInstant(pRawMsg->getTime());
	
	m_messages.push_back(pNewMsg);
	m_msgIt = m_messages.begin();
		
	return true;
}
Exemplo n.º 7
0
bool MIPRTPULawEncoder::push(const MIPComponentChain &chain, int64_t iteration, MIPMessage *pMsg)
{
	if (!m_init)
	{
		setErrorString(MIPRTPULAWENCODER_ERRSTR_NOTINIT);
		return false;
	}
	
	if (m_prevIteration != iteration)
	{
		m_prevIteration = iteration;
		clearMessages();
	}
	
	if (!(pMsg->getMessageType() == MIPMESSAGE_TYPE_AUDIO_ENCODED && pMsg->getMessageSubtype() == MIPENCODEDAUDIOMESSAGE_TYPE_ULAW))
	{
		setErrorString(MIPRTPULAWENCODER_ERRSTR_BADMESSAGE);
		return false;
	}
	
	MIPEncodedAudioMessage *pEncMsg = (MIPEncodedAudioMessage *)pMsg;
	int sampRate = pEncMsg->getSamplingRate();
	int channels = pEncMsg->getNumberOfChannels();
	
	if (sampRate != 8000)
	{
		setErrorString(MIPRTPULAWENCODER_ERRSTR_BADSAMPLINGRATE);
		return false;
	}
	if (channels != 1)
	{
		setErrorString(MIPRTPULAWENCODER_ERRSTR_BADCHANNELS);
		return false;
	}
	
	const void *pData = pEncMsg->getData();
	bool marker = false;
	size_t length = pEncMsg->getDataLength();
	uint8_t *pPayload = new uint8_t [length];

	memcpy(pPayload,pData,length);

	MIPRTPSendMessage *pNewMsg;

	pNewMsg = new MIPRTPSendMessage(pPayload,length,getPayloadType(),marker,pEncMsg->getNumberOfFrames());
	pNewMsg->setSamplingInstant(pEncMsg->getTime());
	
	m_messages.push_back(pNewMsg);
	m_msgIt = m_messages.begin();
		
	return true;
}
Exemplo n.º 8
0
OsStatus MpdGIPSiPCMU::initDecode(MpConnection* pConnection)
{
   int res = 0;

   //Get NetEq pointer
   mpJBState = pConnection->getJBinst();
   assert(NULL != mpJBState);

   //Allocate memory, only once though
   if (NULL == pDecoderState) {
      res += EG711U_GIPS_10MS16B_create(&pDecoderState);
   }

   // Set the payload number for NetEq
   NETEQ_GIPS_10MS16B_initCodepoint(mpJBState, const_cast <char*> ("EG711U"),
                                    8000, getPayloadType());

   //Attach the decoder to NetEq instance
   res += NETEQEG711U_GIPS_10MS16B_init(mpJBState, pDecoderState);

   osPrintf("MpdGIPSiPCMU::initDecode: payloadType=%d\n", getPayloadType());
   return ((0==res) ? OS_SUCCESS : OS_NO_MEMORY);
}
Exemplo n.º 9
0
IncomingRTPPkt::IncomingRTPPkt(const unsigned char* const block, size_t len) :
RTPPacket(block,len)
{
    // first, perform validity check:
    // 1) check protocol version
    // 2) it is not an SR nor an RR
    // 3) consistent length field value (taking CC value and P and
    //    X bits into account)
    if ( getProtocolVersion() != CCRTP_VERSION || (getPayloadType() & RTP_INVALID_PT_MASK) == RTP_INVALID_PT_VALUE) {
            /*
         ||
         getPayloadSize() <= 0 ) {
            */
        headerValid = false;
        return;
    }
    headerValid = true;
    cachedTimestamp = getRawTimestamp();
    cachedSeqNum = ntohs(getHeader()->sequence);
    cachedSSRC = ntohl(getHeader()->sources[0]);
}
Exemplo n.º 10
0
SdpPtr createSdp(std::wstring request_uri)
{
    SdpPtr sdp_instance;

    std::string request_uri_utf8;
    util::convertUtf16ToUtf8(request_uri, request_uri_utf8);

    payload::PayloadType request_payload_type = getPayloadType(request_uri_utf8);
    switch (request_payload_type)
    {
    case payload::MJPEG_PAYLOAD_TYPE: sdp_instance.reset(new sdp::SdpMjpeg); break;
    case payload::H264_PAYLOAD_TYPE:  sdp_instance.reset(new sdp::SdpH264);  break;
    default:
        {
            BOOST_ASSERT(false);
            return NULL_SHARED_PTR(SdpPtr);
        }
    }

    return sdp_instance;
}
Exemplo n.º 11
0
OsStatus MpdGIPSiPCMWB::initDecode(MpConnection* pConnection)
{
#ifdef NOT_YET /* [ */
   int res = 0;

   //Get NetEq pointer
   mpJBState = pConnection->getJBinst();

   //Allocate memory, only once though
   if(pDecoderState==NULL)
      res += IPCMWB_GIPS_10MS16B_create(&pDecoderState);

   // Set the payload number for NetEq
   NETEQ_GIPS_10MS16B_initCodepoint(mpJBState,
                         "IPCMWB", 16000, getPayloadType());

   //Attach the decoder to NetEq instance
   res += NETEQIPCMWB_GIPS_10MS16B_init(mpJBState,pDecoderState);

   return ((0==res) ? OS_SUCCESS : OS_NO_MEMORY);
#endif /* NOT_YET ] */
   return OS_NOT_YET_IMPLEMENTED;
}