Fix valgrind issue.
Code was removed by mistake in r2983. BUG=1020 Review URL: https://webrtc-codereview.appspot.com/938006 git-svn-id: http://webrtc.googlecode.com/svn/trunk@3021 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
parent
f6a4a49ab8
commit
c381a8487a
@ -25,45 +25,41 @@ VideoFramesQueue::VideoFramesQueue()
|
||||
{
|
||||
}
|
||||
|
||||
VideoFramesQueue::~VideoFramesQueue()
|
||||
{
|
||||
while (!_incomingFrames.Empty())
|
||||
{
|
||||
VideoFramesQueue::~VideoFramesQueue() {
|
||||
while (!_incomingFrames.Empty()) {
|
||||
ListItem* item = _incomingFrames.First();
|
||||
if (item)
|
||||
{
|
||||
I420VideoFrame* ptrFrame =
|
||||
static_cast<I420VideoFrame*>(item->GetItem());
|
||||
if (item) {
|
||||
I420VideoFrame* ptrFrame = static_cast<I420VideoFrame*>(item->GetItem());
|
||||
assert(ptrFrame != NULL);
|
||||
delete ptrFrame;
|
||||
}
|
||||
_incomingFrames.Erase(item);
|
||||
}
|
||||
while (!_emptyFrames.Empty())
|
||||
{
|
||||
while (!_emptyFrames.Empty()) {
|
||||
ListItem* item = _emptyFrames.First();
|
||||
if (item) {
|
||||
I420VideoFrame* ptrFrame =
|
||||
static_cast<I420VideoFrame*>(item->GetItem());
|
||||
assert(ptrFrame != NULL);
|
||||
delete ptrFrame;
|
||||
}
|
||||
_emptyFrames.Erase(item);
|
||||
}
|
||||
}
|
||||
|
||||
WebRtc_Word32 VideoFramesQueue::AddFrame(const I420VideoFrame& newFrame)
|
||||
{
|
||||
WebRtc_Word32 VideoFramesQueue::AddFrame(const I420VideoFrame& newFrame) {
|
||||
I420VideoFrame* ptrFrameToAdd = NULL;
|
||||
// Try to re-use a VideoFrame. Only allocate new memory if it is necessary.
|
||||
if (!_emptyFrames.Empty())
|
||||
{
|
||||
if (!_emptyFrames.Empty()) {
|
||||
ListItem* item = _emptyFrames.First();
|
||||
if (item)
|
||||
{
|
||||
if (item) {
|
||||
ptrFrameToAdd = static_cast<I420VideoFrame*>(item->GetItem());
|
||||
_emptyFrames.Erase(item);
|
||||
}
|
||||
}
|
||||
if (!ptrFrameToAdd)
|
||||
{
|
||||
if (!ptrFrameToAdd) {
|
||||
if (_emptyFrames.GetSize() + _incomingFrames.GetSize() >
|
||||
KMaxNumberOfFrames)
|
||||
{
|
||||
KMaxNumberOfFrames) {
|
||||
WEBRTC_TRACE(kTraceWarning, kTraceVideoRenderer, -1,
|
||||
"%s: too many frames, limit: %d", __FUNCTION__,
|
||||
KMaxNumberOfFrames);
|
||||
@ -75,8 +71,7 @@ WebRtc_Word32 VideoFramesQueue::AddFrame(const I420VideoFrame& newFrame)
|
||||
_emptyFrames.GetSize() + _incomingFrames.GetSize());
|
||||
|
||||
ptrFrameToAdd = new I420VideoFrame();
|
||||
if (!ptrFrameToAdd)
|
||||
{
|
||||
if (!ptrFrameToAdd) {
|
||||
WEBRTC_TRACE(kTraceError, kTraceVideoRenderer, -1,
|
||||
"%s: could not create new frame for", __FUNCTION__);
|
||||
return -1;
|
||||
@ -91,19 +86,15 @@ WebRtc_Word32 VideoFramesQueue::AddFrame(const I420VideoFrame& newFrame)
|
||||
// lower than current time in ms (TickTime::MillisecondTimestamp()).
|
||||
// Note _incomingFrames is sorted so that the oldest frame is first.
|
||||
// Recycle all frames that are older than the most recent frame.
|
||||
I420VideoFrame* VideoFramesQueue::FrameToRecord()
|
||||
{
|
||||
I420VideoFrame* VideoFramesQueue::FrameToRecord() {
|
||||
I420VideoFrame* ptrRenderFrame = NULL;
|
||||
ListItem* item = _incomingFrames.First();
|
||||
while(item)
|
||||
{
|
||||
while(item) {
|
||||
I420VideoFrame* ptrOldestFrameInList =
|
||||
static_cast<I420VideoFrame*>(item->GetItem());
|
||||
if (ptrOldestFrameInList->render_time_ms() <=
|
||||
TickTime::MillisecondTimestamp() + _renderDelayMs)
|
||||
{
|
||||
if (ptrRenderFrame)
|
||||
{
|
||||
TickTime::MillisecondTimestamp() + _renderDelayMs) {
|
||||
if (ptrRenderFrame) {
|
||||
// List is traversed beginning to end. If ptrRenderFrame is not
|
||||
// NULL it must be the first, and thus oldest, VideoFrame in the
|
||||
// queue. It can be recycled.
|
||||
@ -112,8 +103,7 @@ I420VideoFrame* VideoFramesQueue::FrameToRecord()
|
||||
}
|
||||
item = _incomingFrames.Next(item);
|
||||
ptrRenderFrame = ptrOldestFrameInList;
|
||||
}else
|
||||
{
|
||||
} else {
|
||||
// All VideoFrames following this one will be even newer. No match
|
||||
// will be found.
|
||||
break;
|
||||
@ -122,8 +112,7 @@ I420VideoFrame* VideoFramesQueue::FrameToRecord()
|
||||
return ptrRenderFrame;
|
||||
}
|
||||
|
||||
WebRtc_Word32 VideoFramesQueue::ReturnFrame(I420VideoFrame* ptrOldFrame)
|
||||
{
|
||||
WebRtc_Word32 VideoFramesQueue::ReturnFrame(I420VideoFrame* ptrOldFrame) {
|
||||
ptrOldFrame->set_timestamp(0);
|
||||
ptrOldFrame->set_width(0);
|
||||
ptrOldFrame->set_height(0);
|
||||
@ -133,9 +122,7 @@ WebRtc_Word32 VideoFramesQueue::ReturnFrame(I420VideoFrame* ptrOldFrame)
|
||||
return 0;
|
||||
}
|
||||
|
||||
//
|
||||
WebRtc_Word32 VideoFramesQueue::SetRenderDelay(WebRtc_UWord32 renderDelay)
|
||||
{
|
||||
WebRtc_Word32 VideoFramesQueue::SetRenderDelay(WebRtc_UWord32 renderDelay) {
|
||||
_renderDelayMs = renderDelay;
|
||||
return 0;
|
||||
}
|
||||
|
@ -20,9 +20,8 @@
|
||||
|
||||
namespace webrtc {
|
||||
|
||||
class VideoFramesQueue
|
||||
{
|
||||
public:
|
||||
class VideoFramesQueue {
|
||||
public:
|
||||
VideoFramesQueue();
|
||||
~VideoFramesQueue();
|
||||
|
||||
@ -37,12 +36,12 @@ public:
|
||||
// Set the render delay estimate to renderDelay ms.
|
||||
WebRtc_Word32 SetRenderDelay(WebRtc_UWord32 renderDelay);
|
||||
|
||||
protected:
|
||||
protected:
|
||||
// Make ptrOldFrame available for re-use. I.e. put it in the empty frames
|
||||
// queue.
|
||||
WebRtc_Word32 ReturnFrame(I420VideoFrame* ptrOldFrame);
|
||||
|
||||
private:
|
||||
private:
|
||||
// Don't allow the buffer to expand beyond KMaxNumberOfFrames VideoFrames.
|
||||
// 300 frames correspond to 10 seconds worth of frames at 30 fps.
|
||||
enum {KMaxNumberOfFrames = 300};
|
||||
|
Loading…
x
Reference in New Issue
Block a user