Remove operator overloading from RTPFragmentationHeader.

Instead supply a CopyFrom() method.

TEST=vie_auto_test

Review URL: https://webrtc-codereview.appspot.com/972004

git-svn-id: http://webrtc.googlecode.com/svn/trunk@3158 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
andrew@webrtc.org 2012-11-23 19:17:23 +00:00
parent ad7f1fefad
commit 418443c531
4 changed files with 43 additions and 40 deletions

View File

@ -14,16 +14,17 @@
#include <cstring> // memcpy
#include <assert.h>
#include "typedefs.h"
#include "common_types.h"
#include "webrtc/common_types.h"
#include "webrtc/system_wrappers/interface/constructor_magic.h"
#include "webrtc/typedefs.h"
#ifdef _WIN32
#pragma warning(disable:4351) // remove warning "new behavior: elements of array
// 'array' will be default initialized"
#endif
namespace webrtc
{
namespace webrtc {
struct RTPHeader
{
bool markerBit;
@ -144,14 +145,14 @@ public:
delete [] fragmentationPlType;
}
RTPFragmentationHeader& operator=(const RTPFragmentationHeader& header)
void CopyFrom(const RTPFragmentationHeader& src)
{
if(this == &header)
if(this == &src)
{
return *this;
return;
}
if(header.fragmentationVectorSize != fragmentationVectorSize)
if(src.fragmentationVectorSize != fragmentationVectorSize)
{
// new size of vectors
@ -165,59 +166,59 @@ public:
delete [] fragmentationPlType;
fragmentationPlType = NULL;
if(header.fragmentationVectorSize > 0)
if(src.fragmentationVectorSize > 0)
{
// allocate new
if(header.fragmentationOffset)
if(src.fragmentationOffset)
{
fragmentationOffset = new WebRtc_UWord32[header.fragmentationVectorSize];
fragmentationOffset = new WebRtc_UWord32[src.fragmentationVectorSize];
}
if(header.fragmentationLength)
if(src.fragmentationLength)
{
fragmentationLength = new WebRtc_UWord32[header.fragmentationVectorSize];
fragmentationLength = new WebRtc_UWord32[src.fragmentationVectorSize];
}
if(header.fragmentationTimeDiff)
if(src.fragmentationTimeDiff)
{
fragmentationTimeDiff = new WebRtc_UWord16[header.fragmentationVectorSize];
fragmentationTimeDiff = new WebRtc_UWord16[src.fragmentationVectorSize];
}
if(header.fragmentationPlType)
if(src.fragmentationPlType)
{
fragmentationPlType = new WebRtc_UWord8[header.fragmentationVectorSize];
fragmentationPlType = new WebRtc_UWord8[src.fragmentationVectorSize];
}
}
// set new size
fragmentationVectorSize = header.fragmentationVectorSize;
fragmentationVectorSize = src.fragmentationVectorSize;
}
if(header.fragmentationVectorSize > 0)
if(src.fragmentationVectorSize > 0)
{
// copy values
if(header.fragmentationOffset)
if(src.fragmentationOffset)
{
memcpy(fragmentationOffset, header.fragmentationOffset,
header.fragmentationVectorSize * sizeof(WebRtc_UWord32));
memcpy(fragmentationOffset, src.fragmentationOffset,
src.fragmentationVectorSize * sizeof(WebRtc_UWord32));
}
if(header.fragmentationLength)
if(src.fragmentationLength)
{
memcpy(fragmentationLength, header.fragmentationLength,
header.fragmentationVectorSize * sizeof(WebRtc_UWord32));
memcpy(fragmentationLength, src.fragmentationLength,
src.fragmentationVectorSize * sizeof(WebRtc_UWord32));
}
if(header.fragmentationTimeDiff)
if(src.fragmentationTimeDiff)
{
memcpy(fragmentationTimeDiff, header.fragmentationTimeDiff,
header.fragmentationVectorSize * sizeof(WebRtc_UWord16));
memcpy(fragmentationTimeDiff, src.fragmentationTimeDiff,
src.fragmentationVectorSize * sizeof(WebRtc_UWord16));
}
if(header.fragmentationPlType)
if(src.fragmentationPlType)
{
memcpy(fragmentationPlType, header.fragmentationPlType,
header.fragmentationVectorSize * sizeof(WebRtc_UWord8));
memcpy(fragmentationPlType, src.fragmentationPlType,
src.fragmentationVectorSize * sizeof(WebRtc_UWord8));
}
}
return *this;
}
void VerifyAndAllocateFragmentationHeader( const WebRtc_UWord16 size)
void VerifyAndAllocateFragmentationHeader(const WebRtc_UWord16 size)
{
if( fragmentationVectorSize < size)
if(fragmentationVectorSize < size)
{
WebRtc_UWord16 oldVectorSize = fragmentationVectorSize;
{
@ -270,6 +271,9 @@ public:
WebRtc_UWord16* fragmentationTimeDiff; // Timestamp difference relative "now" for
// each fragmentation
WebRtc_UWord8* fragmentationPlType; // Payload type of each fragmentation
private:
DISALLOW_COPY_AND_ASSIGN(RTPFragmentationHeader);
};
struct RTCPVoIPMetric
@ -344,7 +348,7 @@ public:
completeFrame = data.completeFrame;
missingFrame = data.missingFrame;
payloadSize = data.payloadSize;
fragmentationHeader = data.fragmentationHeader;
fragmentationHeader.CopyFrom(data.fragmentationHeader);
frameType = data.frameType;
codec = data.codec;
if (data.payloadSize > 0)
@ -378,7 +382,7 @@ public:
completeFrame = data.completeFrame;
missingFrame = data.missingFrame;
payloadSize = data.payloadSize;
fragmentationHeader = data.fragmentationHeader;
fragmentationHeader.CopyFrom(data.fragmentationHeader);
frameType = data.frameType;
codec = data.codec;
if (data.payloadSize > 0)

View File

@ -44,7 +44,7 @@ RtpFormatVp8::RtpFormatVp8(const WebRtc_UWord8* payload_data,
num_partitions_(fragmentation.fragmentationVectorSize),
max_payload_len_(max_payload_len),
packets_calculated_(false) {
part_info_ = fragmentation;
part_info_.CopyFrom(fragmentation);
}
RtpFormatVp8::RtpFormatVp8(const WebRtc_UWord8* payload_data,

View File

@ -142,7 +142,7 @@ WebRtc_Word32 VideoCoder::SendData(
_videoEncodedData->frameType = frameType;
_videoEncodedData->payloadType = payloadType;
_videoEncodedData->timeStamp = timeStamp;
_videoEncodedData->fragmentationHeader = fragmentationHeader;
_videoEncodedData->fragmentationHeader.CopyFrom(fragmentationHeader);
memcpy(_videoEncodedData->payloadData, payloadData,
sizeof(WebRtc_UWord8) * payloadSize);
_videoEncodedData->payloadSize = payloadSize;

View File

@ -65,8 +65,7 @@ VCMEncodedFrame::VCMEncodedFrame(const VCMEncodedFrame& rhs)
memcpy(_buffer, rhs._buffer, rhs._length);
_length = rhs._length;
}
// Deep operator=
_fragmentation = rhs._fragmentation;
_fragmentation.CopyFrom(rhs._fragmentation);
}
VCMEncodedFrame::~VCMEncodedFrame()