2018-11-04 10:19:17 -05:00
|
|
|
/*******************************************************************************
|
|
|
|
* plugins/VOIP/services/rsVOIPItem.cc *
|
|
|
|
* *
|
|
|
|
* Copyright 2011 by Robert Fernie <retroshare.project@gmail.com> *
|
|
|
|
* *
|
|
|
|
* This program is free software: you can redistribute it and/or modify *
|
|
|
|
* it under the terms of the GNU Affero General Public License as *
|
|
|
|
* published by the Free Software Foundation, either version 3 of the *
|
|
|
|
* License, or (at your option) any later version. *
|
|
|
|
* *
|
|
|
|
* This program is distributed in the hope that it will be useful, *
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
|
|
|
* GNU Affero General Public License for more details. *
|
|
|
|
* *
|
|
|
|
* You should have received a copy of the GNU Affero General Public License *
|
|
|
|
* along with this program. If not, see <https://www.gnu.org/licenses/>. *
|
|
|
|
* *
|
|
|
|
*******************************************************************************/
|
2012-02-19 03:32:47 -05:00
|
|
|
|
2012-02-19 16:13:20 -05:00
|
|
|
#include <stdexcept>
|
2017-05-02 16:05:54 -04:00
|
|
|
#include "serialiser/rstypeserializer.h"
|
2012-02-19 03:32:47 -05:00
|
|
|
|
2015-05-11 15:40:07 -04:00
|
|
|
#include "services/rsVOIPItems.h"
|
2012-02-19 10:07:47 -05:00
|
|
|
|
2012-02-19 03:32:47 -05:00
|
|
|
/***
|
|
|
|
#define RSSERIAL_DEBUG 1
|
|
|
|
***/
|
|
|
|
|
|
|
|
#include <iostream>
|
|
|
|
|
2017-05-02 16:05:54 -04:00
|
|
|
RsItem *RsVOIPSerialiser::create_item(uint16_t service,uint8_t item_subtype) const
|
2015-08-10 22:13:50 -04:00
|
|
|
{
|
2017-05-02 16:05:54 -04:00
|
|
|
if(service != RS_SERVICE_TYPE_VOIP_PLUGIN)
|
|
|
|
return NULL ;
|
2012-02-19 03:32:47 -05:00
|
|
|
|
2017-05-02 16:05:54 -04:00
|
|
|
switch(item_subtype)
|
2012-02-19 03:32:47 -05:00
|
|
|
{
|
2017-05-02 16:05:54 -04:00
|
|
|
case RS_PKT_SUBTYPE_VOIP_PING: return new RsVOIPPingItem();
|
|
|
|
case RS_PKT_SUBTYPE_VOIP_PONG: return new RsVOIPPongItem();
|
|
|
|
case RS_PKT_SUBTYPE_VOIP_PROTOCOL: return new RsVOIPProtocolItem();
|
|
|
|
case RS_PKT_SUBTYPE_VOIP_DATA: return new RsVOIPDataItem();
|
|
|
|
default:
|
|
|
|
return NULL ;
|
2012-02-19 03:32:47 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-05-02 16:05:54 -04:00
|
|
|
void RsVOIPProtocolItem::serial_process(RsGenericSerializer::SerializeJob j,RsGenericSerializer::SerializeContext& ctx)
|
2012-02-19 03:32:47 -05:00
|
|
|
{
|
2017-05-02 16:05:54 -04:00
|
|
|
RsTypeSerializer::serial_process<uint32_t>(j,ctx,protocol,"protocol") ;
|
|
|
|
RsTypeSerializer::serial_process<uint32_t>(j,ctx,flags ,"flags") ;
|
2012-02-19 03:32:47 -05:00
|
|
|
}
|
|
|
|
|
2017-05-02 16:05:54 -04:00
|
|
|
void RsVOIPPingItem::serial_process(RsGenericSerializer::SerializeJob j,RsGenericSerializer::SerializeContext& ctx)
|
2012-02-19 03:32:47 -05:00
|
|
|
{
|
2017-05-02 16:05:54 -04:00
|
|
|
RsTypeSerializer::serial_process<uint32_t>(j,ctx,mSeqNo,"mSeqNo") ;
|
|
|
|
RsTypeSerializer::serial_process<uint64_t>(j,ctx,mPingTS,"mPingTS") ;
|
2012-02-19 03:32:47 -05:00
|
|
|
}
|
2017-05-02 16:05:54 -04:00
|
|
|
void RsVOIPPongItem::serial_process(RsGenericSerializer::SerializeJob j,RsGenericSerializer::SerializeContext& ctx)
|
2012-02-19 03:32:47 -05:00
|
|
|
{
|
2017-05-02 16:05:54 -04:00
|
|
|
RsTypeSerializer::serial_process<uint32_t>(j,ctx,mSeqNo,"mSeqNo") ;
|
|
|
|
RsTypeSerializer::serial_process<uint64_t>(j,ctx,mPingTS,"mPingTS") ;
|
|
|
|
RsTypeSerializer::serial_process<uint64_t>(j,ctx,mPongTS,"mPongTS") ;
|
2012-02-19 03:32:47 -05:00
|
|
|
}
|
2017-05-02 16:05:54 -04:00
|
|
|
void RsVOIPDataItem::serial_process(RsGenericSerializer::SerializeJob j,RsGenericSerializer::SerializeContext& ctx)
|
2012-02-19 16:13:20 -05:00
|
|
|
{
|
2017-05-02 16:05:54 -04:00
|
|
|
RsTypeSerializer::serial_process<uint32_t>(j,ctx,flags ,"flags") ;
|
2012-02-19 03:32:47 -05:00
|
|
|
|
2017-05-02 16:05:54 -04:00
|
|
|
RsTypeSerializer::TlvMemBlock_proxy prox((uint8_t*&)voip_data,data_size) ;
|
2012-02-19 03:32:47 -05:00
|
|
|
|
2017-05-02 16:05:54 -04:00
|
|
|
RsTypeSerializer::serial_process(j,ctx,prox,"data") ;
|
2012-02-19 03:32:47 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
/*************************************************************************/
|
|
|
|
|