OLD | NEW |
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" |
| 14 #include "content/renderer/media/media_stream_dependency_factory.h" |
13 #include "content/renderer/media/media_stream_impl.h" | 15 #include "content/renderer/media/media_stream_impl.h" |
14 #include "content/renderer/media/media_stream_extra_data.h" | |
15 #include "content/renderer/render_view_impl.h" | 16 #include "content/renderer/render_view_impl.h" |
16 #include "third_party/libjingle/source/talk/app/webrtc/jsep.h" | 17 #include "third_party/libjingle/source/talk/app/webrtc/jsep.h" |
17 #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" |
18 #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" |
19 #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" |
20 #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" |
21 #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" |
22 #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" |
23 #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" |
24 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebVector.h" | 25 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebVector.h" |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
76 return GetTrack<webrtc::VideoTracks>( | 77 return GetTrack<webrtc::VideoTracks>( |
77 source_id, native_stream->video_tracks()); | 78 source_id, native_stream->video_tracks()); |
78 } | 79 } |
79 } | 80 } |
80 // TODO(perkj): This can occur if a JS create a new MediaStream based on an | 81 // TODO(perkj): This can occur if a JS create a new MediaStream based on an |
81 // existing MediaStream. | 82 // existing MediaStream. |
82 NOTIMPLEMENTED(); | 83 NOTIMPLEMENTED(); |
83 return NULL; | 84 return NULL; |
84 } | 85 } |
85 | 86 |
86 MediaStreamCenter::MediaStreamCenter(WebKit::WebMediaStreamCenterClient*) {} | 87 MediaStreamCenter::MediaStreamCenter(WebKit::WebMediaStreamCenterClient* client, |
| 88 MediaStreamDependencyFactory* factory) |
| 89 : rtc_factory_(factory) { |
| 90 } |
87 | 91 |
88 void MediaStreamCenter::queryMediaStreamSources( | 92 void MediaStreamCenter::queryMediaStreamSources( |
89 const WebKit::WebMediaStreamSourcesRequest& request) { | 93 const WebKit::WebMediaStreamSourcesRequest& request) { |
90 WebKit::WebVector<WebKit::WebMediaStreamSource> audioSources, videoSources; | 94 WebKit::WebVector<WebKit::WebMediaStreamSource> audioSources, videoSources; |
91 request.didCompleteQuery(audioSources, videoSources); | 95 request.didCompleteQuery(audioSources, videoSources); |
92 } | 96 } |
93 | 97 |
94 void MediaStreamCenter::didEnableMediaStreamTrack( | 98 void MediaStreamCenter::didEnableMediaStreamTrack( |
95 const WebKit::WebMediaStreamDescriptor& stream, | 99 const WebKit::WebMediaStreamDescriptor& stream, |
96 const WebKit::WebMediaStreamComponent& component) { | 100 const WebKit::WebMediaStreamComponent& component) { |
(...skipping 22 matching lines...) Expand all Loading... |
119 if (ms_impl) { | 123 if (ms_impl) { |
120 ms_impl->StopLocalMediaStream(stream); | 124 ms_impl->StopLocalMediaStream(stream); |
121 return; | 125 return; |
122 } | 126 } |
123 | 127 |
124 NOTREACHED(); | 128 NOTREACHED(); |
125 } | 129 } |
126 | 130 |
127 void MediaStreamCenter::didCreateMediaStream( | 131 void MediaStreamCenter::didCreateMediaStream( |
128 WebKit::WebMediaStreamDescriptor& stream) { | 132 WebKit::WebMediaStreamDescriptor& stream) { |
129 WebKit::WebFrame* web_frame = WebKit::WebFrame::frameForCurrentContext(); | 133 if (!rtc_factory_) |
130 if (!web_frame) | |
131 return; | 134 return; |
132 MediaStreamImpl* ms_impl = GetMediaStreamImpl(web_frame); | 135 rtc_factory_->CreateNativeLocalMediaStream(&stream); |
133 if (ms_impl) { | |
134 ms_impl->CreateMediaStream(web_frame, &stream); | |
135 return; | |
136 } | |
137 NOTREACHED(); | |
138 } | 136 } |
139 | 137 |
140 WebKit::WebString MediaStreamCenter::constructSDP( | 138 WebKit::WebString MediaStreamCenter::constructSDP( |
141 const WebKit::WebICECandidateDescriptor& candidate) { | 139 const WebKit::WebICECandidateDescriptor& candidate) { |
142 int m_line_index = -1; | 140 int m_line_index = -1; |
143 if (!base::StringToInt(UTF16ToUTF8(candidate.label()), &m_line_index)) { | 141 if (!base::StringToInt(UTF16ToUTF8(candidate.label()), &m_line_index)) { |
144 LOG(ERROR) << "Invalid candidate label: " << UTF16ToUTF8(candidate.label()); | 142 LOG(ERROR) << "Invalid candidate label: " << UTF16ToUTF8(candidate.label()); |
145 return WebKit::WebString(); | 143 return WebKit::WebString(); |
146 } | 144 } |
147 // TODO(ronghuawu): Get sdp_mid from WebKit when is available. | 145 // TODO(ronghuawu): Get sdp_mid from WebKit when is available. |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
183 } | 181 } |
184 } | 182 } |
185 | 183 |
186 std::string sdp; | 184 std::string sdp; |
187 if (!native_desc->ToString(&sdp)) | 185 if (!native_desc->ToString(&sdp)) |
188 LOG(ERROR) << "Could not create SDP string"; | 186 LOG(ERROR) << "Could not create SDP string"; |
189 return UTF8ToUTF16(sdp); | 187 return UTF8ToUTF16(sdp); |
190 } | 188 } |
191 | 189 |
192 } // namespace content | 190 } // namespace content |
OLD | NEW |