RTCPacketOptions.cpp [plain text]
#include "config.h"
#include "RTCPacketOptions.h"
#if USE(LIBWEBRTC)
#include "DataReference.h"
#include "WebCoreArgumentCoders.h"
namespace WebKit {
void RTCPacketOptions::encode(IPC::Encoder& encoder) const
{
encoder.encodeEnum(options.dscp);
encoder << safeCast<int32_t>(options.packet_id);
encoder << options.packet_time_params.rtp_sendtime_extension_id;
encoder << static_cast<int64_t>(options.packet_time_params.srtp_auth_tag_len);
if (options.packet_time_params.srtp_auth_tag_len > 0)
encoder << IPC::DataReference(reinterpret_cast<const uint8_t*>(options.packet_time_params.srtp_auth_key.data()), options.packet_time_params.srtp_auth_key.size());
encoder << options.packet_time_params.srtp_packet_index;
}
bool RTCPacketOptions::decode(IPC::Decoder& decoder, RTCPacketOptions& options)
{
rtc::PacketTimeUpdateParams params;
if (!decoder.decodeEnum(options.options.dscp))
return false;
int32_t packetId;
if (!decoder.decode(packetId))
return false;
options.options.packet_id = packetId;
if (!decoder.decode(params.rtp_sendtime_extension_id))
return false;
int64_t srtpAuthTagLength;
if (!decoder.decode(srtpAuthTagLength))
return false;
params.srtp_auth_tag_len = srtpAuthTagLength;
if (params.srtp_auth_tag_len > 0) {
IPC::DataReference srtpAuthKey;
if (!decoder.decode(srtpAuthKey))
return false;
params.srtp_auth_key = std::vector<char>(static_cast<size_t>(srtpAuthKey.size()));
memcpy(params.srtp_auth_key.data(), reinterpret_cast<const char*>(srtpAuthKey.data()), srtpAuthKey.size() * sizeof(char));
}
if (!decoder.decode(params.srtp_packet_index))
return false;
options.options.packet_time_params = WTFMove(params);
return true;
}
}
#endif // USE(LIBWEBRTC)