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

Unified Diff: content/renderer/render_view_impl.cc

Issue 8060055: Adding support for MediaStream and PeerConnection functionality (Closed) Base URL: http://git.chromium.org/chromium/chromium.git@trunk
Patch Set: Code review fixes. Created 9 years 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
Index: content/renderer/render_view_impl.cc
diff --git a/content/renderer/render_view_impl.cc b/content/renderer/render_view_impl.cc
index ce57e9c265a0d9a6837cd06efc513f1f67e496e5..49383a22eb7fec7394efce64683b89aacebdafda 100644
--- a/content/renderer/render_view_impl.cc
+++ b/content/renderer/render_view_impl.cc
@@ -59,6 +59,8 @@
#include "content/renderer/load_progress_tracker.h"
#include "content/renderer/media/audio_message_filter.h"
#include "content/renderer/media/audio_renderer_impl.h"
+#include "content/renderer/media/media_stream_dependency_factory.h"
+#include "content/renderer/media/media_stream_dispatcher.h"
#include "content/renderer/media/media_stream_impl.h"
#include "content/renderer/media/render_media_log.h"
#include "content/renderer/mhtml_generator.h"
@@ -116,12 +118,15 @@
#include "third_party/WebKit/Source/WebKit/chromium/public/WebSettings.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/WebStorageNamespace.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/WebStorageQuotaCallbacks.h"
+#include "third_party/WebKit/Source/WebKit/chromium/public/WebUserMediaClient.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/WebWindowFeatures.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebCString.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebDragData.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebGraphicsContext3D.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebImage.h"
+#include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebPeerConnectionHandler.h"
+#include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebPeerConnectionHandlerClient.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebPoint.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebRect.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebSize.h"
@@ -358,6 +363,7 @@ RenderViewImpl::RenderViewImpl(
geolocation_dispatcher_(NULL),
speech_input_dispatcher_(NULL),
device_orientation_dispatcher_(NULL),
+ media_stream_dispatcher_(NULL),
p2p_socket_dispatcher_(NULL),
devtools_agent_(NULL),
renderer_accessibility_(NULL),
@@ -419,7 +425,8 @@ RenderViewImpl::RenderViewImpl(
host_window_ = parent_hwnd;
#if defined(ENABLE_P2P_APIS)
- p2p_socket_dispatcher_ = new content::P2PSocketDispatcher(this);
+ if (!p2p_socket_dispatcher_)
+ p2p_socket_dispatcher_ = new content::P2PSocketDispatcher(this);
#endif
new MHTMLGenerator(this);
@@ -433,12 +440,6 @@ RenderViewImpl::RenderViewImpl(
new IdleUserDetector(this);
- const CommandLine& command_line = *CommandLine::ForCurrentProcess();
- if (command_line.HasSwitch(switches::kEnableMediaStream)) {
- media_stream_impl_ = new MediaStreamImpl(
- RenderThreadImpl::current()->video_capture_impl_manager());
- }
-
content::GetContentClient()->renderer()->RenderViewCreated(this);
}
@@ -474,6 +475,10 @@ RenderViewImpl::~RenderViewImpl() {
DCHECK_NE(this, it->second) << "Failed to call Close?";
#endif
+ // MediaStreamImpl holds weak references to RenderViewObserver objects,
+ // ensure it's deleted before the observers.
+ media_stream_impl_ = NULL;
+
FOR_EACH_OBSERVER(RenderViewObserver, observers_, RenderViewGone());
FOR_EACH_OBSERVER(RenderViewObserver, observers_, OnDestruct());
}
@@ -524,6 +529,15 @@ RenderViewImpl* RenderViewImpl::Create(
next_page_id); // adds reference
}
+WebKit::WebPeerConnectionHandler* RenderViewImpl::CreatePeerConnectionHandler(
+ WebKit::WebPeerConnectionHandlerClient* client) {
+ const CommandLine* cmd_line = CommandLine::ForCurrentProcess();
+ if (!cmd_line->HasSwitch(switches::kEnableMediaStream))
+ return NULL;
+ EnsureMediaStreamImpl();
+ return media_stream_impl_->CreatePeerConnectionHandler(client);
+}
+
void RenderViewImpl::AddObserver(RenderViewObserver* observer) {
observers_.AddObserver(observer);
}
@@ -2962,6 +2976,25 @@ void RenderViewImpl::CheckPreferredSize() {
preferred_size_));
}
+void RenderViewImpl::EnsureMediaStreamImpl() {
+#if defined(ENABLE_P2P_APIS)
+ if (!p2p_socket_dispatcher_)
+ p2p_socket_dispatcher_ = new content::P2PSocketDispatcher(this);
+#endif
+
+ if (!media_stream_dispatcher_)
+ media_stream_dispatcher_ = new MediaStreamDispatcher(this);
+
+ if (!media_stream_impl_.get()) {
+ MediaStreamDependencyFactory* factory = new MediaStreamDependencyFactory();
+ media_stream_impl_ = new MediaStreamImpl(
+ media_stream_dispatcher_,
+ p2p_socket_dispatcher_,
+ RenderThreadImpl::current()->video_capture_impl_manager(),
+ factory);
+ }
+}
+
void RenderViewImpl::didChangeContentsSize(WebFrame* frame,
const WebSize& size) {
if (webview()->mainFrame() != frame)
@@ -4674,6 +4707,14 @@ WebKit::WebPageVisibilityState RenderViewImpl::visibilityState() const {
return current_state;
}
+WebKit::WebUserMediaClient* RenderViewImpl::userMediaClient() {
+ const CommandLine* cmd_line = CommandLine::ForCurrentProcess();
+ if (!cmd_line->HasSwitch(switches::kEnableMediaStream))
+ return NULL;
+ EnsureMediaStreamImpl();
+ return media_stream_impl_;
+}
+
bool RenderViewImpl::IsNonLocalTopLevelNavigation(
const GURL& url, WebKit::WebFrame* frame, WebKit::WebNavigationType type) {
// Must be a top level frame.

Powered by Google App Engine
This is Rietveld 408576698