Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(83)

Unified Diff: talk/media/base/capturerenderadapter.cc

Issue 1603423002: Simplify CaptureRenderAdapter. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Delete test of RemoveVideoRenderer return value Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « talk/media/base/capturerenderadapter.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: talk/media/base/capturerenderadapter.cc
diff --git a/talk/media/base/capturerenderadapter.cc b/talk/media/base/capturerenderadapter.cc
index 3fdb68be9bb2340ee9293db4d2720ad373236939..e5e8f4c58baaf3ed6db0723fd9a142aaa801b5db 100644
--- a/talk/media/base/capturerenderadapter.cc
+++ b/talk/media/base/capturerenderadapter.cc
@@ -61,31 +61,32 @@ CaptureRenderAdapter* CaptureRenderAdapter::Create(
return return_value;
}
-bool CaptureRenderAdapter::AddRenderer(VideoRenderer* video_renderer) {
- if (!video_renderer) {
- return false;
- }
+void CaptureRenderAdapter::AddRenderer(VideoRenderer* video_renderer) {
+ RTC_DCHECK(video_renderer);
+
rtc::CritScope cs(&capture_crit_);
- if (IsRendererRegistered(*video_renderer)) {
- return false;
- }
- video_renderers_.push_back(VideoRendererInfo(video_renderer));
- return true;
+ // This implements set semantics, the same renderer can only be
+ // added once.
+ // TODO(nisse): Is this really needed?
+ if (std::find(video_renderers_.begin(), video_renderers_.end(),
+ video_renderer) == video_renderers_.end())
+ video_renderers_.push_back(video_renderer);
}
-bool CaptureRenderAdapter::RemoveRenderer(VideoRenderer* video_renderer) {
- if (!video_renderer) {
- return false;
- }
+void CaptureRenderAdapter::RemoveRenderer(VideoRenderer* video_renderer) {
+ RTC_DCHECK(video_renderer);
+
rtc::CritScope cs(&capture_crit_);
+ // TODO(nisse): Switch to using std::list, and use its remove
+ // method. And similarly in VideoTrackRenderers, which this class
+ // mostly duplicates.
for (VideoRenderers::iterator iter = video_renderers_.begin();
iter != video_renderers_.end(); ++iter) {
- if (video_renderer == iter->renderer) {
+ if (video_renderer == *iter) {
video_renderers_.erase(iter);
- return true;
+ break;
}
}
- return false;
}
void CaptureRenderAdapter::Init() {
@@ -100,38 +101,9 @@ void CaptureRenderAdapter::OnVideoFrame(VideoCapturer* capturer,
if (video_renderers_.empty()) {
return;
}
- MaybeSetRenderingSize(video_frame);
-
- for (VideoRenderers::iterator iter = video_renderers_.begin();
- iter != video_renderers_.end(); ++iter) {
- VideoRenderer* video_renderer = iter->renderer;
- video_renderer->RenderFrame(video_frame);
- }
-}
-// The renderer_crit_ lock needs to be taken when calling this function.
-void CaptureRenderAdapter::MaybeSetRenderingSize(const VideoFrame* frame) {
- for (VideoRenderers::iterator iter = video_renderers_.begin();
- iter != video_renderers_.end(); ++iter) {
- const bool new_resolution = iter->render_width != frame->GetWidth() ||
- iter->render_height != frame->GetHeight();
- if (new_resolution) {
- iter->render_width = frame->GetWidth();
- iter->render_height = frame->GetHeight();
- }
- }
-}
-
-// The renderer_crit_ lock needs to be taken when calling this function.
-bool CaptureRenderAdapter::IsRendererRegistered(
- const VideoRenderer& video_renderer) const {
- for (VideoRenderers::const_iterator iter = video_renderers_.begin();
- iter != video_renderers_.end(); ++iter) {
- if (&video_renderer == iter->renderer) {
- return true;
- }
- }
- return false;
+ for (auto* renderer : video_renderers_)
+ renderer->RenderFrame(video_frame);
}
} // namespace cricket
« no previous file with comments | « talk/media/base/capturerenderadapter.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698