Use size_t more consistently for packet/payload lengths.
See design doc at https://docs.google.com/a/chromium.org/document/d/1I6nmE9D_BmCY-IoV6MDPY2V6WYpEI-dg2apWXTfZyUI/edit?usp=sharing for more information. This CL was reviewed and approved in pieces in the following CLs: https://webrtc-codereview.appspot.com/24209004/ https://webrtc-codereview.appspot.com/24229004/ https://webrtc-codereview.appspot.com/24259004/ https://webrtc-codereview.appspot.com/25109004/ https://webrtc-codereview.appspot.com/26099004/ https://webrtc-codereview.appspot.com/27069004/ https://webrtc-codereview.appspot.com/27969004/ https://webrtc-codereview.appspot.com/27989004/ https://webrtc-codereview.appspot.com/29009004/ https://webrtc-codereview.appspot.com/30929004/ https://webrtc-codereview.appspot.com/30939004/ https://webrtc-codereview.appspot.com/31999004/ Committing as TBR to the original reviewers. BUG=chromium:81439 TEST=none TBR=pthatcher,henrik.lundin,tina.legrand,stefan,tkchin,glaznev,kjellander,perkj,mflodman,henrika,asapersson,niklas.enbom Review URL: https://webrtc-codereview.appspot.com/23129004 git-svn-id: http://webrtc.googlecode.com/svn/trunk@7726 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
@ -136,10 +136,10 @@ class RTPFragmentationHeader {
|
||||
if (src.fragmentationVectorSize > 0) {
|
||||
// allocate new
|
||||
if (src.fragmentationOffset) {
|
||||
fragmentationOffset = new uint32_t[src.fragmentationVectorSize];
|
||||
fragmentationOffset = new size_t[src.fragmentationVectorSize];
|
||||
}
|
||||
if (src.fragmentationLength) {
|
||||
fragmentationLength = new uint32_t[src.fragmentationVectorSize];
|
||||
fragmentationLength = new size_t[src.fragmentationVectorSize];
|
||||
}
|
||||
if (src.fragmentationTimeDiff) {
|
||||
fragmentationTimeDiff = new uint16_t[src.fragmentationVectorSize];
|
||||
@ -156,11 +156,11 @@ class RTPFragmentationHeader {
|
||||
// copy values
|
||||
if (src.fragmentationOffset) {
|
||||
memcpy(fragmentationOffset, src.fragmentationOffset,
|
||||
src.fragmentationVectorSize * sizeof(uint32_t));
|
||||
src.fragmentationVectorSize * sizeof(size_t));
|
||||
}
|
||||
if (src.fragmentationLength) {
|
||||
memcpy(fragmentationLength, src.fragmentationLength,
|
||||
src.fragmentationVectorSize * sizeof(uint32_t));
|
||||
src.fragmentationVectorSize * sizeof(size_t));
|
||||
}
|
||||
if (src.fragmentationTimeDiff) {
|
||||
memcpy(fragmentationTimeDiff, src.fragmentationTimeDiff,
|
||||
@ -178,23 +178,23 @@ class RTPFragmentationHeader {
|
||||
uint16_t oldVectorSize = fragmentationVectorSize;
|
||||
{
|
||||
// offset
|
||||
uint32_t* oldOffsets = fragmentationOffset;
|
||||
fragmentationOffset = new uint32_t[size];
|
||||
size_t* oldOffsets = fragmentationOffset;
|
||||
fragmentationOffset = new size_t[size];
|
||||
memset(fragmentationOffset + oldVectorSize, 0,
|
||||
sizeof(uint32_t) * (size - oldVectorSize));
|
||||
sizeof(size_t) * (size - oldVectorSize));
|
||||
// copy old values
|
||||
memcpy(fragmentationOffset, oldOffsets,
|
||||
sizeof(uint32_t) * oldVectorSize);
|
||||
sizeof(size_t) * oldVectorSize);
|
||||
delete[] oldOffsets;
|
||||
}
|
||||
// length
|
||||
{
|
||||
uint32_t* oldLengths = fragmentationLength;
|
||||
fragmentationLength = new uint32_t[size];
|
||||
size_t* oldLengths = fragmentationLength;
|
||||
fragmentationLength = new size_t[size];
|
||||
memset(fragmentationLength + oldVectorSize, 0,
|
||||
sizeof(uint32_t) * (size - oldVectorSize));
|
||||
sizeof(size_t) * (size - oldVectorSize));
|
||||
memcpy(fragmentationLength, oldLengths,
|
||||
sizeof(uint32_t) * oldVectorSize);
|
||||
sizeof(size_t) * oldVectorSize);
|
||||
delete[] oldLengths;
|
||||
}
|
||||
// time diff
|
||||
@ -222,11 +222,12 @@ class RTPFragmentationHeader {
|
||||
}
|
||||
|
||||
uint16_t fragmentationVectorSize; // Number of fragmentations
|
||||
uint32_t* fragmentationOffset; // Offset of pointer to data for each fragm.
|
||||
uint32_t* fragmentationLength; // Data size for each fragmentation
|
||||
uint16_t* fragmentationTimeDiff; // Timestamp difference relative "now" for
|
||||
// each fragmentation
|
||||
uint8_t* fragmentationPlType; // Payload type of each fragmentation
|
||||
size_t* fragmentationOffset; // Offset of pointer to data for each
|
||||
// fragmentation
|
||||
size_t* fragmentationLength; // Data size for each fragmentation
|
||||
uint16_t* fragmentationTimeDiff; // Timestamp difference relative "now" for
|
||||
// each fragmentation
|
||||
uint8_t* fragmentationPlType; // Payload type of each fragmentation
|
||||
|
||||
private:
|
||||
DISALLOW_COPY_AND_ASSIGN(RTPFragmentationHeader);
|
||||
@ -348,7 +349,7 @@ class EncodedVideoData {
|
||||
}
|
||||
return *this;
|
||||
};
|
||||
void VerifyAndAllocate(const uint32_t size) {
|
||||
void VerifyAndAllocate(const size_t size) {
|
||||
if (bufferSize < size) {
|
||||
uint8_t* oldPayload = payloadData;
|
||||
payloadData = new uint8_t[size];
|
||||
@ -367,8 +368,8 @@ class EncodedVideoData {
|
||||
bool completeFrame;
|
||||
bool missingFrame;
|
||||
uint8_t* payloadData;
|
||||
uint32_t payloadSize;
|
||||
uint32_t bufferSize;
|
||||
size_t payloadSize;
|
||||
size_t bufferSize;
|
||||
RTPFragmentationHeader fragmentationHeader;
|
||||
FrameType frameType;
|
||||
VideoCodecType codec;
|
||||
@ -414,17 +415,17 @@ class VideoFrame {
|
||||
* is copied to the new buffer.
|
||||
* Buffer size is updated to minimumSize.
|
||||
*/
|
||||
int32_t VerifyAndAllocate(const uint32_t minimumSize);
|
||||
int32_t VerifyAndAllocate(const size_t minimumSize);
|
||||
/**
|
||||
* Update length of data buffer in frame. Function verifies that new length
|
||||
* is less or
|
||||
* equal to allocated size.
|
||||
*/
|
||||
int32_t SetLength(const uint32_t newLength);
|
||||
int32_t SetLength(const size_t newLength);
|
||||
/*
|
||||
* Swap buffer and size data
|
||||
*/
|
||||
int32_t Swap(uint8_t*& newMemory, uint32_t& newLength, uint32_t& newSize);
|
||||
int32_t Swap(uint8_t*& newMemory, size_t& newLength, size_t& newSize);
|
||||
/*
|
||||
* Swap buffer and size data
|
||||
*/
|
||||
@ -440,7 +441,7 @@ class VideoFrame {
|
||||
* size length
|
||||
* is allocated.
|
||||
*/
|
||||
int32_t CopyFrame(uint32_t length, const uint8_t* sourceBuffer);
|
||||
int32_t CopyFrame(size_t length, const uint8_t* sourceBuffer);
|
||||
/**
|
||||
* Delete VideoFrame and resets members to zero
|
||||
*/
|
||||
@ -459,11 +460,11 @@ class VideoFrame {
|
||||
/**
|
||||
* Get allocated buffer size
|
||||
*/
|
||||
uint32_t Size() const { return _bufferSize; }
|
||||
size_t Size() const { return _bufferSize; }
|
||||
/**
|
||||
* Get frame length
|
||||
*/
|
||||
uint32_t Length() const { return _bufferLength; }
|
||||
size_t Length() const { return _bufferLength; }
|
||||
/**
|
||||
* Get frame timestamp (90kHz)
|
||||
*/
|
||||
@ -498,10 +499,10 @@ class VideoFrame {
|
||||
private:
|
||||
void Set(uint8_t* buffer, uint32_t size, uint32_t length, uint32_t timeStamp);
|
||||
|
||||
uint8_t* _buffer; // Pointer to frame buffer
|
||||
uint32_t _bufferSize; // Allocated buffer size
|
||||
uint32_t _bufferLength; // Length (in bytes) of buffer
|
||||
uint32_t _timeStamp; // Timestamp of frame (90kHz)
|
||||
uint8_t* _buffer; // Pointer to frame buffer
|
||||
size_t _bufferSize; // Allocated buffer size
|
||||
size_t _bufferLength; // Length (in bytes) of buffer
|
||||
uint32_t _timeStamp; // Timestamp of frame (90kHz)
|
||||
uint32_t _width;
|
||||
uint32_t _height;
|
||||
int64_t _renderTimeMs;
|
||||
@ -525,7 +526,7 @@ inline VideoFrame::~VideoFrame() {
|
||||
}
|
||||
}
|
||||
|
||||
inline int32_t VideoFrame::VerifyAndAllocate(const uint32_t minimumSize) {
|
||||
inline int32_t VideoFrame::VerifyAndAllocate(const size_t minimumSize) {
|
||||
if (minimumSize < 1) {
|
||||
return -1;
|
||||
}
|
||||
@ -545,7 +546,7 @@ inline int32_t VideoFrame::VerifyAndAllocate(const uint32_t minimumSize) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
inline int32_t VideoFrame::SetLength(const uint32_t newLength) {
|
||||
inline int32_t VideoFrame::SetLength(const size_t newLength) {
|
||||
if (newLength > _bufferSize) { // can't accomodate new value
|
||||
return -1;
|
||||
}
|
||||
@ -573,21 +574,15 @@ inline int32_t VideoFrame::SwapFrame(VideoFrame& videoFrame) {
|
||||
videoFrame._bufferSize);
|
||||
}
|
||||
|
||||
inline int32_t VideoFrame::Swap(uint8_t*& newMemory, uint32_t& newLength,
|
||||
uint32_t& newSize) {
|
||||
uint8_t* tmpBuffer = _buffer;
|
||||
uint32_t tmpLength = _bufferLength;
|
||||
uint32_t tmpSize = _bufferSize;
|
||||
_buffer = newMemory;
|
||||
_bufferLength = newLength;
|
||||
_bufferSize = newSize;
|
||||
newMemory = tmpBuffer;
|
||||
newLength = tmpLength;
|
||||
newSize = tmpSize;
|
||||
inline int32_t VideoFrame::Swap(uint8_t*& newMemory, size_t& newLength,
|
||||
size_t& newSize) {
|
||||
std::swap(_buffer, newMemory);
|
||||
std::swap(_bufferLength, newLength);
|
||||
std::swap(_bufferSize, newSize);
|
||||
return 0;
|
||||
}
|
||||
|
||||
inline int32_t VideoFrame::CopyFrame(uint32_t length,
|
||||
inline int32_t VideoFrame::CopyFrame(size_t length,
|
||||
const uint8_t* sourceBuffer) {
|
||||
if (length > _bufferSize) {
|
||||
int32_t ret = VerifyAndAllocate(length);
|
||||
|
||||
Reference in New Issue
Block a user