Removes usage of ListWrapper from several files.

BUG=2164
R=andrew@webrtc.org, pbos@webrtc.org

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

git-svn-id: http://webrtc.googlecode.com/svn/trunk@5373 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
henrike@webrtc.org
2014-01-13 15:21:30 +00:00
parent d0b436a935
commit 79cf3acc79
23 changed files with 314 additions and 449 deletions

View File

@ -8,7 +8,7 @@
* be found in the AUTHORS file in the root of the source tree.
*/
#include "webrtc/modules/video_render//video_render_frames.h"
#include "webrtc/modules/video_render/video_render_frames.h"
#include <assert.h>
@ -19,13 +19,12 @@
namespace webrtc {
const int32_t KEventMaxWaitTimeMs = 200;
const uint32_t KEventMaxWaitTimeMs = 200;
const uint32_t kMinRenderDelayMs = 10;
const uint32_t kMaxRenderDelayMs= 500;
VideoRenderFrames::VideoRenderFrames()
: incoming_frames_(),
render_delay_ms_(10) {
: render_delay_ms_(10) {
}
VideoRenderFrames::~VideoRenderFrames() {
@ -37,7 +36,7 @@ int32_t VideoRenderFrames::AddFrame(I420VideoFrame* new_frame) {
// Drop old frames only when there are other frames in the queue, otherwise, a
// really slow system never renders any frames.
if (!incoming_frames_.Empty() &&
if (!incoming_frames_.empty() &&
new_frame->render_time_ms() + KOldRenderTimestampMS < time_now) {
WEBRTC_TRACE(kTraceWarning,
kTraceVideoRenderer,
@ -56,26 +55,23 @@ int32_t VideoRenderFrames::AddFrame(I420VideoFrame* new_frame) {
}
if (new_frame->native_handle() != NULL) {
incoming_frames_.PushBack(new TextureVideoFrame(
incoming_frames_.push_back(new TextureVideoFrame(
static_cast<NativeHandle*>(new_frame->native_handle()),
new_frame->width(),
new_frame->height(),
new_frame->timestamp(),
new_frame->render_time_ms()));
return incoming_frames_.GetSize();
return static_cast<int32_t>(incoming_frames_.size());
}
// Get an empty frame
I420VideoFrame* frame_to_add = NULL;
if (!empty_frames_.Empty()) {
ListItem* item = empty_frames_.First();
if (item) {
frame_to_add = static_cast<I420VideoFrame*>(item->GetItem());
empty_frames_.Erase(item);
}
if (!empty_frames_.empty()) {
frame_to_add = empty_frames_.front();
empty_frames_.pop_front();
}
if (!frame_to_add) {
if (empty_frames_.GetSize() + incoming_frames_.GetSize() >
if (empty_frames_.size() + incoming_frames_.size() >
KMaxNumberOfFrames) {
// Already allocated too many frames.
WEBRTC_TRACE(kTraceWarning, kTraceVideoRenderer,
@ -87,7 +83,7 @@ int32_t VideoRenderFrames::AddFrame(I420VideoFrame* new_frame) {
// Allocate new memory.
WEBRTC_TRACE(kTraceMemory, kTraceVideoRenderer, -1,
"%s: allocating buffer %d", __FUNCTION__,
empty_frames_.GetSize() + incoming_frames_.GetSize());
empty_frames_.size() + incoming_frames_.size());
frame_to_add = new I420VideoFrame();
if (!frame_to_add) {
@ -104,33 +100,28 @@ int32_t VideoRenderFrames::AddFrame(I420VideoFrame* new_frame) {
// TODO(mflodman) Change this!
// Remove const ness. Copying will be costly.
frame_to_add->SwapFrame(new_frame);
incoming_frames_.PushBack(frame_to_add);
incoming_frames_.push_back(frame_to_add);
return incoming_frames_.GetSize();
return static_cast<int32_t>(incoming_frames_.size());
}
I420VideoFrame* VideoRenderFrames::FrameToRender() {
I420VideoFrame* render_frame = NULL;
while (!incoming_frames_.Empty()) {
ListItem* item = incoming_frames_.First();
if (item) {
I420VideoFrame* oldest_frame_in_list =
static_cast<I420VideoFrame*>(item->GetItem());
if (oldest_frame_in_list->render_time_ms() <=
TickTime::MillisecondTimestamp() + render_delay_ms_) {
// This is the oldest one so far and it's OK to render.
if (render_frame) {
// This one is older than the newly found frame, remove this one.
ReturnFrame(render_frame);
}
render_frame = oldest_frame_in_list;
incoming_frames_.Erase(item);
} else {
// We can't release this one yet, we're done here.
break;
FrameList::iterator iter = incoming_frames_.begin();
while(iter != incoming_frames_.end()) {
I420VideoFrame* oldest_frame_in_list = *iter;
if (oldest_frame_in_list->render_time_ms() <=
TickTime::MillisecondTimestamp() + render_delay_ms_) {
// This is the oldest one so far and it's OK to render.
if (render_frame) {
// This one is older than the newly found frame, remove this one.
ReturnFrame(render_frame);
}
render_frame = oldest_frame_in_list;
iter = incoming_frames_.erase(iter);
} else {
assert(false);
// We can't release this one yet, we're done here.
break;
}
}
return render_frame;
@ -142,7 +133,7 @@ int32_t VideoRenderFrames::ReturnFrame(I420VideoFrame* old_frame) {
old_frame->ResetSize();
old_frame->set_timestamp(0);
old_frame->set_render_time_ms(0);
empty_frames_.PushBack(old_frame);
empty_frames_.push_back(old_frame);
} else {
delete old_frame;
}
@ -150,40 +141,29 @@ int32_t VideoRenderFrames::ReturnFrame(I420VideoFrame* old_frame) {
}
int32_t VideoRenderFrames::ReleaseAllFrames() {
while (!incoming_frames_.Empty()) {
ListItem* item = incoming_frames_.First();
if (item) {
I420VideoFrame* frame = static_cast<I420VideoFrame*>(item->GetItem());
assert(frame != NULL);
delete frame;
}
incoming_frames_.Erase(item);
for (FrameList::iterator iter = incoming_frames_.begin();
iter != incoming_frames_.end(); ++iter) {
delete *iter;
}
while (!empty_frames_.Empty()) {
ListItem* item = empty_frames_.First();
if (item) {
I420VideoFrame* frame = static_cast<I420VideoFrame*>(item->GetItem());
assert(frame != NULL);
delete frame;
}
empty_frames_.Erase(item);
incoming_frames_.clear();
for (FrameList::iterator iter = empty_frames_.begin();
iter != empty_frames_.end(); ++iter) {
delete *iter;
}
empty_frames_.clear();
return 0;
}
uint32_t VideoRenderFrames::TimeToNextFrameRelease() {
int64_t time_to_release = 0;
ListItem* item = incoming_frames_.First();
if (item) {
I420VideoFrame* oldest_frame =
static_cast<I420VideoFrame*>(item->GetItem());
time_to_release = oldest_frame->render_time_ms() - render_delay_ms_
- TickTime::MillisecondTimestamp();
if (time_to_release < 0) {
time_to_release = 0;
}
} else {
time_to_release = KEventMaxWaitTimeMs;
if (incoming_frames_.empty()) {
return KEventMaxWaitTimeMs;
}
I420VideoFrame* oldest_frame = incoming_frames_.front();
int64_t time_to_release = oldest_frame->render_time_ms() - render_delay_ms_
- TickTime::MillisecondTimestamp();
if (time_to_release < 0) {
time_to_release = 0;
}
return static_cast<uint32_t>(time_to_release);
}