2015-05-11 15:40:07 -04:00
|
|
|
/****************************************************************
|
|
|
|
* RetroShare is distributed under the following license:
|
2012-02-19 03:32:47 -05:00
|
|
|
*
|
2015-05-11 15:40:07 -04:00
|
|
|
* Copyright (C) 2015
|
2012-02-19 03:32:47 -05:00
|
|
|
*
|
2015-05-11 15:40:07 -04:00
|
|
|
* 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.
|
2012-02-19 03:32:47 -05:00
|
|
|
*
|
2015-05-11 15:40:07 -04:00
|
|
|
* 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 General Public License for more details.
|
2012-02-19 03:32:47 -05:00
|
|
|
*
|
2015-05-11 15:40:07 -04:00
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
|
|
|
* Boston, MA 02110-1301, USA.
|
|
|
|
****************************************************************/
|
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
|
|
|
}
|
|
|
|
|
|
|
|
/*************************************************************************/
|
|
|
|
|