| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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 #include "content/renderer/media/peer_connection_tracker.h" | 4 #include "content/renderer/media/peer_connection_tracker.h" |
| 5 | 5 |
| 6 #include "base/utf_string_conversions.h" | 6 #include "base/utf_string_conversions.h" |
| 7 #include "content/common/media/peer_connection_tracker_messages.h" | 7 #include "content/common/media/peer_connection_tracker_messages.h" |
| 8 #include "content/renderer/media/rtc_media_constraints.h" | 8 #include "content/renderer/media/rtc_media_constraints.h" |
| 9 #include "content/renderer/media/rtc_peer_connection_handler.h" | 9 #include "content/renderer/media/rtc_peer_connection_handler.h" |
| 10 #include "content/renderer/render_thread_impl.h" | 10 #include "content/renderer/render_thread_impl.h" |
| 11 #include "third_party/WebKit/Source/Platform/chromium/public/WebMediaStreamCompo
nent.h" | 11 #include "third_party/WebKit/Source/Platform/chromium/public/WebMediaStream.h" |
| 12 #include "third_party/WebKit/Source/Platform/chromium/public/WebMediaStreamDescr
iptor.h" | |
| 13 #include "third_party/WebKit/Source/Platform/chromium/public/WebMediaStreamSourc
e.h" | 12 #include "third_party/WebKit/Source/Platform/chromium/public/WebMediaStreamSourc
e.h" |
| 13 #include "third_party/WebKit/Source/Platform/chromium/public/WebMediaStreamTrack
.h" |
| 14 #include "third_party/WebKit/Source/Platform/chromium/public/WebRTCICECandidate.
h" | 14 #include "third_party/WebKit/Source/Platform/chromium/public/WebRTCICECandidate.
h" |
| 15 #include "third_party/WebKit/Source/Platform/chromium/public/WebRTCPeerConnectio
nHandlerClient.h" | 15 #include "third_party/WebKit/Source/Platform/chromium/public/WebRTCPeerConnectio
nHandlerClient.h" |
| 16 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDocument.h" | 16 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDocument.h" |
| 17 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h" | 17 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h" |
| 18 | 18 |
| 19 using std::string; | 19 using std::string; |
| 20 using webrtc::MediaConstraintsInterface; | 20 using webrtc::MediaConstraintsInterface; |
| 21 using WebKit::WebRTCPeerConnectionHandlerClient; | 21 using WebKit::WebRTCPeerConnectionHandlerClient; |
| 22 | 22 |
| 23 namespace content { | 23 namespace content { |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 56 result += optional[i].key + ":" + optional[i].value; | 56 result += optional[i].key + ":" + optional[i].value; |
| 57 if (i != optional.size() - 1) | 57 if (i != optional.size() - 1) |
| 58 result += ", "; | 58 result += ", "; |
| 59 } | 59 } |
| 60 result += "}"; | 60 result += "}"; |
| 61 } | 61 } |
| 62 return result; | 62 return result; |
| 63 } | 63 } |
| 64 | 64 |
| 65 static string SerializeMediaStreamComponent( | 65 static string SerializeMediaStreamComponent( |
| 66 const WebKit::WebMediaStreamComponent component) { | 66 const WebKit::WebMediaStreamTrack component) { |
| 67 string id = UTF16ToUTF8(component.source().id()); | 67 string id = UTF16ToUTF8(component.source().id()); |
| 68 return id; | 68 return id; |
| 69 } | 69 } |
| 70 | 70 |
| 71 static string SerializeMediaDescriptor( | 71 static string SerializeMediaDescriptor( |
| 72 const WebKit::WebMediaStreamDescriptor& stream) { | 72 const WebKit::WebMediaStream& stream) { |
| 73 string label = UTF16ToUTF8(stream.label()); | 73 string label = UTF16ToUTF8(stream.label()); |
| 74 string result = "label: " + label; | 74 string result = "label: " + label; |
| 75 WebKit::WebVector<WebKit::WebMediaStreamComponent> sources; | 75 WebKit::WebVector<WebKit::WebMediaStreamTrack> sources; |
| 76 stream.audioSources(sources); | 76 stream.audioSources(sources); |
| 77 if (!sources.isEmpty()) { | 77 if (!sources.isEmpty()) { |
| 78 result += ", audio: ["; | 78 result += ", audio: ["; |
| 79 for (size_t i = 0; i < sources.size(); ++i) { | 79 for (size_t i = 0; i < sources.size(); ++i) { |
| 80 result += SerializeMediaStreamComponent(sources[i]); | 80 result += SerializeMediaStreamComponent(sources[i]); |
| 81 if (i != sources.size() - 1) | 81 if (i != sources.size() - 1) |
| 82 result += ", "; | 82 result += ", "; |
| 83 } | 83 } |
| 84 result += "]"; | 84 result += "]"; |
| 85 } | 85 } |
| (...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 229 Source source) { | 229 Source source) { |
| 230 string value = "mid: " + UTF16ToUTF8(candidate.sdpMid()) + ", " + | 230 string value = "mid: " + UTF16ToUTF8(candidate.sdpMid()) + ", " + |
| 231 "candidate: " + UTF16ToUTF8(candidate.candidate()); | 231 "candidate: " + UTF16ToUTF8(candidate.candidate()); |
| 232 SendPeerConnectionUpdate( | 232 SendPeerConnectionUpdate( |
| 233 pc_handler, | 233 pc_handler, |
| 234 source == SOURCE_LOCAL ? "onIceCandidate" : "addIceCandidate", value); | 234 source == SOURCE_LOCAL ? "onIceCandidate" : "addIceCandidate", value); |
| 235 } | 235 } |
| 236 | 236 |
| 237 void PeerConnectionTracker::TrackAddStream( | 237 void PeerConnectionTracker::TrackAddStream( |
| 238 RTCPeerConnectionHandler* pc_handler, | 238 RTCPeerConnectionHandler* pc_handler, |
| 239 const WebKit::WebMediaStreamDescriptor& stream, | 239 const WebKit::WebMediaStream& stream, |
| 240 Source source){ | 240 Source source){ |
| 241 SendPeerConnectionUpdate( | 241 SendPeerConnectionUpdate( |
| 242 pc_handler, source == SOURCE_LOCAL ? "addStream" : "onAddStream", | 242 pc_handler, source == SOURCE_LOCAL ? "addStream" : "onAddStream", |
| 243 SerializeMediaDescriptor(stream)); | 243 SerializeMediaDescriptor(stream)); |
| 244 } | 244 } |
| 245 | 245 |
| 246 void PeerConnectionTracker::TrackRemoveStream( | 246 void PeerConnectionTracker::TrackRemoveStream( |
| 247 RTCPeerConnectionHandler* pc_handler, | 247 RTCPeerConnectionHandler* pc_handler, |
| 248 const WebKit::WebMediaStreamDescriptor& stream, | 248 const WebKit::WebMediaStream& stream, |
| 249 Source source){ | 249 Source source){ |
| 250 SendPeerConnectionUpdate( | 250 SendPeerConnectionUpdate( |
| 251 pc_handler, source == SOURCE_LOCAL ? "removeStream" : "onRemoveStream", | 251 pc_handler, source == SOURCE_LOCAL ? "removeStream" : "onRemoveStream", |
| 252 SerializeMediaDescriptor(stream)); | 252 SerializeMediaDescriptor(stream)); |
| 253 } | 253 } |
| 254 | 254 |
| 255 void PeerConnectionTracker::TrackCreateDataChannel( | 255 void PeerConnectionTracker::TrackCreateDataChannel( |
| 256 RTCPeerConnectionHandler* pc_handler, | 256 RTCPeerConnectionHandler* pc_handler, |
| 257 const webrtc::DataChannelInterface* data_channel, | 257 const webrtc::DataChannelInterface* data_channel, |
| 258 Source source) { | 258 Source source) { |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 324 const std::string& value) { | 324 const std::string& value) { |
| 325 if (peer_connection_id_map_.find(pc_handler) == peer_connection_id_map_.end()) | 325 if (peer_connection_id_map_.find(pc_handler) == peer_connection_id_map_.end()) |
| 326 return; | 326 return; |
| 327 | 327 |
| 328 RenderThreadImpl::current()->Send( | 328 RenderThreadImpl::current()->Send( |
| 329 new PeerConnectionTrackerHost_UpdatePeerConnection( | 329 new PeerConnectionTrackerHost_UpdatePeerConnection( |
| 330 peer_connection_id_map_[pc_handler], type, value)); | 330 peer_connection_id_map_[pc_handler], type, value)); |
| 331 } | 331 } |
| 332 | 332 |
| 333 } // namespace content | 333 } // namespace content |
| OLD | NEW |