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

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: Merge Created 8 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 | « content/renderer/render_view_impl.h ('k') | content/renderer/renderer_webkitplatformsupport_impl.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/renderer/render_view_impl.cc
diff --git a/content/renderer/render_view_impl.cc b/content/renderer/render_view_impl.cc
index d92ef494e1634fcdd46b7473cd4920ab7af97bf5..dcce65c7e6613735ef2ef8d2ca19f52e3c29da78 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"
@@ -118,12 +120,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"
@@ -360,6 +365,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),
@@ -421,7 +427,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);
@@ -435,12 +442,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);
}
@@ -476,6 +477,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());
}
@@ -526,6 +531,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);
}
@@ -2982,6 +2996,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)
@@ -4710,6 +4743,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.
« no previous file with comments | « content/renderer/render_view_impl.h ('k') | content/renderer/renderer_webkitplatformsupport_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698