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

Unified Diff: content/renderer/media/media_stream_impl.cc

Issue 10038009: Revert 131949 (multiple memory leaks) - Adding JSEP PeerConnection glue. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 8 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 | « content/renderer/media/media_stream_impl.h ('k') | content/renderer/media/media_stream_impl_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/renderer/media/media_stream_impl.cc
===================================================================
--- content/renderer/media/media_stream_impl.cc (revision 131960)
+++ content/renderer/media/media_stream_impl.cc (working copy)
@@ -14,7 +14,6 @@
#include "content/renderer/media/media_stream_dependency_factory.h"
#include "content/renderer/media/media_stream_dispatcher.h"
#include "content/renderer/media/peer_connection_handler.h"
-#include "content/renderer/media/peer_connection_handler_jsep.h"
#include "content/renderer/media/video_capture_impl_manager.h"
#include "content/renderer/media/video_capture_module_impl.h"
#include "content/renderer/media/webrtc_audio_device_impl.h"
@@ -82,13 +81,15 @@
p2p_socket_dispatcher_(p2p_socket_dispatcher),
network_manager_(NULL),
vc_manager_(vc_manager),
+ peer_connection_handler_(NULL),
+ message_loop_proxy_(base::MessageLoopProxy::current()),
signaling_thread_(NULL),
worker_thread_(NULL),
chrome_worker_thread_("Chrome_libJingle_WorkerThread") {
}
MediaStreamImpl::~MediaStreamImpl() {
- DCHECK(peer_connection_handlers_.empty());
+ DCHECK(!peer_connection_handler_);
if (dependency_factory_.get())
dependency_factory_->ReleasePeerConnectionFactory();
if (network_manager_) {
@@ -111,46 +112,30 @@
WebKit::WebPeerConnectionHandler* MediaStreamImpl::CreatePeerConnectionHandler(
WebKit::WebPeerConnectionHandlerClient* client) {
DCHECK(CalledOnValidThread());
- if (!EnsurePeerConnectionFactory())
+ if (peer_connection_handler_) {
+ DVLOG(1) << "A PeerConnection already exists";
return NULL;
-
- PeerConnectionHandler* pc_handler = new PeerConnectionHandler(
- client,
- this,
- dependency_factory_.get());
- peer_connection_handlers_.push_back(pc_handler);
-
- return pc_handler;
-}
-
-WebKit::WebPeerConnection00Handler*
-MediaStreamImpl::CreatePeerConnectionHandlerJsep(
- WebKit::WebPeerConnection00HandlerClient* client) {
- DCHECK(CalledOnValidThread());
+ }
if (!EnsurePeerConnectionFactory())
return NULL;
- PeerConnectionHandlerJsep* pc_handler = new PeerConnectionHandlerJsep(
+ peer_connection_handler_ = new PeerConnectionHandler(
client,
this,
dependency_factory_.get());
- peer_connection_handlers_.push_back(pc_handler);
- return pc_handler;
+ return peer_connection_handler_;
}
-void MediaStreamImpl::ClosePeerConnection(
- PeerConnectionHandlerBase* pc_handler) {
+void MediaStreamImpl::ClosePeerConnection() {
DCHECK(CalledOnValidThread());
- VideoRendererMap::iterator vr_it = video_renderers_.begin();
- while (vr_it != video_renderers_.end()) {
- if (vr_it->second.second == pc_handler) {
- video_renderers_.erase(vr_it++);
- } else {
- ++vr_it;
- }
- }
- peer_connection_handlers_.remove(pc_handler);
+ video_renderer_ = NULL;
+ peer_connection_handler_ = NULL;
+ // TODO(grunell): This is a temporary workaround for an error in native
+ // PeerConnection where added live tracks are not seen on the remote side.
+ MediaStreamTrackPtrMap::const_iterator it = local_tracks_.begin();
+ for (; it != local_tracks_.end(); ++it)
+ it->second->set_state(webrtc::MediaStreamTrackInterface::kEnded);
}
webrtc::MediaStreamTrackInterface* MediaStreamImpl::GetLocalMediaStreamTrack(
@@ -159,8 +144,8 @@
MediaStreamTrackPtrMap::iterator it = local_tracks_.find(label);
if (it == local_tracks_.end())
return NULL;
- MediaStreamTrackPtr track = it->second;
- return track.get();
+ MediaStreamTrackPtr stream = it->second;
+ return stream.get();
}
void MediaStreamImpl::requestUserMedia(
@@ -251,34 +236,27 @@
capability);
} else {
// It's a remote stream.
- std::string desc_label = UTF16ToUTF8(descriptor.label());
- PeerConnectionHandlerBase* pc_handler = NULL;
- std::list<PeerConnectionHandlerBase*>::iterator it;
- for (it = peer_connection_handlers_.begin();
- it != peer_connection_handlers_.end(); ++it) {
- if ((*it)->HasStream(desc_label)) {
- pc_handler = *it;
- break;
+ if (!video_renderer_.get())
+ video_renderer_ = new talk_base::RefCountedObject<VideoRendererWrapper>();
+ if (video_renderer_->renderer()) {
+ // The renderer is used by PeerConnection, release it first.
+ if (peer_connection_handler_) {
+ peer_connection_handler_->SetVideoRenderer(
+ UTF16ToUTF8(descriptor.label()),
+ NULL);
}
+ video_renderer_->SetVideoDecoder(NULL);
}
- DCHECK(it != peer_connection_handlers_.end());
- // TODO(grunell): We are not informed when a renderer should be deleted.
- // When this has been fixed, ensure we delete it. For now, we hold on
- // to all renderers until a PeerConnectionHandler is closed or we are
- // deleted (then all renderers are deleted), so it sort of leaks.
- // TODO(grunell): There is no support for multiple decoders per stream, this
- // code will need to be updated when that is supported.
- talk_base::scoped_refptr<VideoRendererWrapper> video_renderer =
- new talk_base::RefCountedObject<VideoRendererWrapper>();
RTCVideoDecoder* rtc_video_decoder = new RTCVideoDecoder(
message_loop_factory->GetMessageLoop("RtcVideoDecoderThread"),
url.spec());
decoder = rtc_video_decoder;
- video_renderer->SetVideoDecoder(rtc_video_decoder);
- pc_handler->SetVideoRenderer(desc_label, video_renderer);
- video_renderers_.erase(desc_label); // Remove old renderer if exists.
- video_renderers_.insert(
- std::make_pair(desc_label, std::make_pair(video_renderer, pc_handler)));
+ video_renderer_->SetVideoDecoder(rtc_video_decoder);
+ if (peer_connection_handler_) {
+ peer_connection_handler_->SetVideoRenderer(
+ UTF16ToUTF8(descriptor.label()),
+ video_renderer_);
+ }
}
return decoder;
}
« no previous file with comments | « content/renderer/media/media_stream_impl.h ('k') | content/renderer/media/media_stream_impl_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698