RetroShare/plugins/VOIP/services/rsVOIPItems.cc

77 lines
2.8 KiB
C++
Raw Normal View History

/****************************************************************
* RetroShare is distributed under the following license:
*
* Copyright (C) 2015
*
* 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.
*
* 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.
*
* 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.
****************************************************************/
#include <stdexcept>
2017-05-02 16:05:54 -04:00
#include "serialiser/rstypeserializer.h"
#include "services/rsVOIPItems.h"
/***
#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
{
2017-05-02 16:05:54 -04:00
if(service != RS_SERVICE_TYPE_VOIP_PLUGIN)
return NULL ;
2017-05-02 16:05:54 -04:00
switch(item_subtype)
{
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 ;
}
}
2017-05-02 16:05:54 -04:00
void RsVOIPProtocolItem::serial_process(RsGenericSerializer::SerializeJob j,RsGenericSerializer::SerializeContext& ctx)
{
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") ;
}
2017-05-02 16:05:54 -04:00
void RsVOIPPingItem::serial_process(RsGenericSerializer::SerializeJob j,RsGenericSerializer::SerializeContext& ctx)
{
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") ;
}
2017-05-02 16:05:54 -04:00
void RsVOIPPongItem::serial_process(RsGenericSerializer::SerializeJob j,RsGenericSerializer::SerializeContext& ctx)
{
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") ;
}
2017-05-02 16:05:54 -04:00
void RsVOIPDataItem::serial_process(RsGenericSerializer::SerializeJob j,RsGenericSerializer::SerializeContext& ctx)
{
2017-05-02 16:05:54 -04:00
RsTypeSerializer::serial_process<uint32_t>(j,ctx,flags ,"flags") ;
2017-05-02 16:05:54 -04:00
RsTypeSerializer::TlvMemBlock_proxy prox((uint8_t*&)voip_data,data_size) ;
2017-05-02 16:05:54 -04:00
RsTypeSerializer::serial_process(j,ctx,prox,"data") ;
}
/*************************************************************************/