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

Side by Side Diff: content/renderer/media/video_source_handler.cc

Issue 14969013: Replace ASSERT with DCHECK per chromium style guide. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 7 years, 7 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « content/renderer/media/video_destination_handler.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "content/renderer/media/video_source_handler.h" 5 #include "content/renderer/media/video_source_handler.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "content/renderer/media/media_stream_dependency_factory.h" 10 #include "content/renderer/media/media_stream_dependency_factory.h"
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
55 DISALLOW_COPY_AND_ASSIGN(PpFrameReceiver); 55 DISALLOW_COPY_AND_ASSIGN(PpFrameReceiver);
56 }; 56 };
57 57
58 VideoSourceHandler::VideoSourceHandler( 58 VideoSourceHandler::VideoSourceHandler(
59 MediaStreamRegistryInterface* registry) 59 MediaStreamRegistryInterface* registry)
60 : registry_(registry) { 60 : registry_(registry) {
61 } 61 }
62 62
63 VideoSourceHandler::~VideoSourceHandler() { 63 VideoSourceHandler::~VideoSourceHandler() {
64 // All the opened readers should have been closed by now. 64 // All the opened readers should have been closed by now.
65 ASSERT(reader_to_receiver_.empty()); 65 DCHECK(reader_to_receiver_.empty());
66 } 66 }
67 67
68 bool VideoSourceHandler::Open(const std::string& url, 68 bool VideoSourceHandler::Open(const std::string& url,
69 FrameReaderInterface* reader) { 69 FrameReaderInterface* reader) {
70 scoped_refptr<webrtc::VideoSourceInterface> source = GetFirstVideoSource(url); 70 scoped_refptr<webrtc::VideoSourceInterface> source = GetFirstVideoSource(url);
71 if (!source.get()) { 71 if (!source.get()) {
72 return false; 72 return false;
73 } 73 }
74 PpFrameReceiver* receiver = new PpFrameReceiver(); 74 PpFrameReceiver* receiver = new PpFrameReceiver();
75 receiver->SetReader(reader); 75 receiver->SetReader(reader);
76 source->AddSink(receiver); 76 source->AddSink(receiver);
77 reader_to_receiver_[reader] = receiver; 77 reader_to_receiver_[reader] = receiver;
78 return true; 78 return true;
79 } 79 }
80 80
81 bool VideoSourceHandler::Close(const std::string& url, 81 bool VideoSourceHandler::Close(const std::string& url,
82 FrameReaderInterface* reader) { 82 FrameReaderInterface* reader) {
83 scoped_refptr<webrtc::VideoSourceInterface> source = GetFirstVideoSource(url); 83 scoped_refptr<webrtc::VideoSourceInterface> source = GetFirstVideoSource(url);
84 if (!source.get()) { 84 if (!source.get()) {
85 LOG(ERROR) << "VideoSourceHandler::Close - Failed to get the video source " 85 LOG(ERROR) << "VideoSourceHandler::Close - Failed to get the video source "
86 << "from MediaStream with url: " << url; 86 << "from MediaStream with url: " << url;
87 return false; 87 return false;
88 } 88 }
89 PpFrameReceiver* receiver = 89 PpFrameReceiver* receiver =
90 static_cast<PpFrameReceiver*>(GetReceiver(reader)); 90 static_cast<PpFrameReceiver*>(GetReceiver(reader));
91 ASSERT(receiver != NULL); 91 if (!receiver) {
92 LOG(ERROR) << "VideoSourceHandler::Close - Failed to find receiver that "
93 << "is associated with the given reader.";
94 return false;
95 }
92 receiver->SetReader(NULL); 96 receiver->SetReader(NULL);
93 source->RemoveSink(receiver); 97 source->RemoveSink(receiver);
94 reader_to_receiver_.erase(reader); 98 reader_to_receiver_.erase(reader);
95 delete receiver; 99 delete receiver;
96 return true; 100 return true;
97 } 101 }
98 102
99 scoped_refptr<VideoSourceInterface> VideoSourceHandler::GetFirstVideoSource( 103 scoped_refptr<VideoSourceInterface> VideoSourceHandler::GetFirstVideoSource(
100 const std::string& url) { 104 const std::string& url) {
101 scoped_refptr<webrtc::VideoSourceInterface> source; 105 scoped_refptr<webrtc::VideoSourceInterface> source;
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
138 std::map<FrameReaderInterface*, VideoRenderer*>::iterator it; 142 std::map<FrameReaderInterface*, VideoRenderer*>::iterator it;
139 it = reader_to_receiver_.find(reader); 143 it = reader_to_receiver_.find(reader);
140 if (it == reader_to_receiver_.end()) { 144 if (it == reader_to_receiver_.end()) {
141 return NULL; 145 return NULL;
142 } 146 }
143 return it->second; 147 return it->second;
144 } 148 }
145 149
146 } // namespace content 150 } // namespace content
147 151
OLDNEW
« no previous file with comments | « content/renderer/media/video_destination_handler.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698