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

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

Issue 10947030: Removed the use of WebFrame::frameForCurrentContext() in MediaStreamCenter::didStopLocalMediaStream (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Addressing code review comments found by Tommi. Created 8 years, 3 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
« no previous file with comments | « no previous file | content/renderer/media/media_stream_dependency_factory.h » ('j') | 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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/media_stream_center.h" 5 #include "content/renderer/media/media_stream_center.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/memory/scoped_ptr.h" 10 #include "base/memory/scoped_ptr.h"
11 #include "base/string_number_conversions.h" 11 #include "base/string_number_conversions.h"
12 #include "base/utf_string_conversions.h" 12 #include "base/utf_string_conversions.h"
13 #include "content/renderer/media/media_stream_extra_data.h" 13 #include "content/renderer/media/media_stream_extra_data.h"
14 #include "content/renderer/media/media_stream_dependency_factory.h" 14 #include "content/renderer/media/media_stream_dependency_factory.h"
15 #include "content/renderer/media/media_stream_impl.h" 15 #include "content/renderer/media/media_stream_impl.h"
16 #include "content/renderer/render_view_impl.h" 16 #include "content/renderer/render_view_impl.h"
17 #include "third_party/libjingle/source/talk/app/webrtc/jsep.h" 17 #include "third_party/libjingle/source/talk/app/webrtc/jsep.h"
18 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebICECandid ateDescriptor.h" 18 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebICECandid ateDescriptor.h"
19 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebMediaStre amCenterClient.h" 19 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebMediaStre amCenterClient.h"
20 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebMediaStre amComponent.h" 20 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebMediaStre amComponent.h"
21 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebMediaStre amDescriptor.h" 21 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebMediaStre amDescriptor.h"
22 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebMediaStre amSource.h" 22 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebMediaStre amSource.h"
23 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebMediaStre amSourcesRequest.h" 23 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebMediaStre amSourcesRequest.h"
24 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebSessionDe scriptionDescriptor.h" 24 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebSessionDe scriptionDescriptor.h"
25 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebVector.h" 25 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebVector.h"
26 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h" 26 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h"
27 27
28 namespace content { 28 namespace content {
29 29
30 static MediaStreamImpl* GetMediaStreamImpl(WebKit::WebFrame* web_frame) {
31 RenderViewImpl* render_view = RenderViewImpl::FromWebView(web_frame->view());
32 if (!render_view)
33 return NULL;
34
35 // TODO(perkj): Avoid this cast?
36 return static_cast<MediaStreamImpl*>(render_view->userMediaClient());
37 }
38
39 static webrtc::MediaStreamInterface* GetNativeMediaStream( 30 static webrtc::MediaStreamInterface* GetNativeMediaStream(
40 const WebKit::WebMediaStreamDescriptor& stream) { 31 const WebKit::WebMediaStreamDescriptor& stream) {
41 MediaStreamExtraData* extra_data = 32 MediaStreamExtraData* extra_data =
42 static_cast<MediaStreamExtraData*>(stream.extraData()); 33 static_cast<MediaStreamExtraData*>(stream.extraData());
43 if (extra_data && extra_data->remote_stream()) 34 if (extra_data && extra_data->remote_stream())
44 return extra_data->remote_stream(); 35 return extra_data->remote_stream();
45 36
46 if (extra_data && extra_data->local_stream()) 37 if (extra_data && extra_data->local_stream())
47 return extra_data->local_stream(); 38 return extra_data->local_stream();
48 39
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
109 const WebKit::WebMediaStreamComponent& component) { 100 const WebKit::WebMediaStreamComponent& component) {
110 webrtc::MediaStreamTrackInterface* track = 101 webrtc::MediaStreamTrackInterface* track =
111 GetNativeMediaStreamTrack(stream, component); 102 GetNativeMediaStreamTrack(stream, component);
112 if (track) 103 if (track)
113 track->set_enabled(false); 104 track->set_enabled(false);
114 } 105 }
115 106
116 void MediaStreamCenter::didStopLocalMediaStream( 107 void MediaStreamCenter::didStopLocalMediaStream(
117 const WebKit::WebMediaStreamDescriptor& stream) { 108 const WebKit::WebMediaStreamDescriptor& stream) {
118 DVLOG(1) << "MediaStreamCenter::didStopLocalMediaStream"; 109 DVLOG(1) << "MediaStreamCenter::didStopLocalMediaStream";
119 WebKit::WebFrame* web_frame = WebKit::WebFrame::frameForCurrentContext(); 110 MediaStreamExtraData* extra_data =
120 if (!web_frame) 111 static_cast<MediaStreamExtraData*>(stream.extraData());
121 return; 112 if (!extra_data) {
122 MediaStreamImpl* ms_impl = GetMediaStreamImpl(web_frame); 113 NOTREACHED();
123 if (ms_impl) {
124 ms_impl->StopLocalMediaStream(stream);
125 return; 114 return;
126 } 115 }
127 116
128 NOTREACHED(); 117 extra_data->OnLocalStreamStop();
129 } 118 }
130 119
131 void MediaStreamCenter::didCreateMediaStream( 120 void MediaStreamCenter::didCreateMediaStream(
132 WebKit::WebMediaStreamDescriptor& stream) { 121 WebKit::WebMediaStreamDescriptor& stream) {
133 if (!rtc_factory_) 122 if (!rtc_factory_)
134 return; 123 return;
135 rtc_factory_->CreateNativeLocalMediaStream(&stream); 124 rtc_factory_->CreateNativeLocalMediaStream(&stream);
136 } 125 }
137 126
138 WebKit::WebString MediaStreamCenter::constructSDP( 127 WebKit::WebString MediaStreamCenter::constructSDP(
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
181 } 170 }
182 } 171 }
183 172
184 std::string sdp; 173 std::string sdp;
185 if (!native_desc->ToString(&sdp)) 174 if (!native_desc->ToString(&sdp))
186 LOG(ERROR) << "Could not create SDP string"; 175 LOG(ERROR) << "Could not create SDP string";
187 return UTF8ToUTF16(sdp); 176 return UTF8ToUTF16(sdp);
188 } 177 }
189 178
190 } // namespace content 179 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | content/renderer/media/media_stream_dependency_factory.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698