Chromium Code Reviews| 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/string_number_conversions.h" | |
|
wjia(left Chromium)
2012/07/30 18:19:10
file order.
Mallinath (Gone from Chromium)
2012/07/30 18:42:08
Done.
| |
| 10 #include "base/memory/scoped_ptr.h" | 11 #include "base/memory/scoped_ptr.h" |
| 11 #include "base/utf_string_conversions.h" | 12 #include "base/utf_string_conversions.h" |
| 12 #include "content/renderer/media/media_stream_impl.h" | 13 #include "content/renderer/media/media_stream_impl.h" |
| 13 #include "content/renderer/media/media_stream_extra_data.h" | 14 #include "content/renderer/media/media_stream_extra_data.h" |
| 14 #include "content/renderer/render_view_impl.h" | 15 #include "content/renderer/render_view_impl.h" |
| 15 #include "third_party/libjingle/source/talk/app/webrtc/jsep.h" | 16 #include "third_party/libjingle/source/talk/app/webrtc/jsep.h" |
| 16 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebICECandid ateDescriptor.h" | 17 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebICECandid ateDescriptor.h" |
| 17 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebMediaStre amCenterClient.h" | 18 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebMediaStre amCenterClient.h" |
| 18 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebMediaStre amComponent.h" | 19 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebMediaStre amComponent.h" |
| 19 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebMediaStre amDescriptor.h" | 20 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebMediaStre amDescriptor.h" |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 134 MediaStreamImpl* ms_impl = GetMediaStreamImpl(web_frame); | 135 MediaStreamImpl* ms_impl = GetMediaStreamImpl(web_frame); |
| 135 if (ms_impl) { | 136 if (ms_impl) { |
| 136 ms_impl->CreateMediaStream(web_frame, &stream); | 137 ms_impl->CreateMediaStream(web_frame, &stream); |
| 137 return; | 138 return; |
| 138 } | 139 } |
| 139 NOTREACHED(); | 140 NOTREACHED(); |
| 140 } | 141 } |
| 141 | 142 |
| 142 WebKit::WebString MediaStreamCenter::constructSDP( | 143 WebKit::WebString MediaStreamCenter::constructSDP( |
| 143 const WebKit::WebICECandidateDescriptor& candidate) { | 144 const WebKit::WebICECandidateDescriptor& candidate) { |
| 145 int m_line_index = -1; | |
| 146 if (!base::StringToInt(UTF16ToUTF8(candidate.label()), &m_line_index)) { | |
| 147 LOG(ERROR) << "Invalid candidate label: " << UTF16ToUTF8(candidate.label()); | |
| 148 return WebKit::WebString(); | |
| 149 } | |
| 144 scoped_ptr<webrtc::IceCandidateInterface> native_candidate( | 150 scoped_ptr<webrtc::IceCandidateInterface> native_candidate( |
| 145 webrtc::CreateIceCandidate(UTF16ToUTF8(candidate.label()), | 151 webrtc::CreateIceCandidate(UTF16ToUTF8(candidate.label()), |
| 152 m_line_index, | |
| 146 UTF16ToUTF8(candidate.candidateLine()))); | 153 UTF16ToUTF8(candidate.candidateLine()))); |
| 147 std::string sdp; | 154 std::string sdp; |
| 148 if (!native_candidate->ToString(&sdp)) | 155 if (!native_candidate->ToString(&sdp)) |
| 149 LOG(ERROR) << "Could not create SDP string"; | 156 LOG(ERROR) << "Could not create SDP string"; |
| 150 return UTF8ToUTF16(sdp); | 157 return UTF8ToUTF16(sdp); |
| 151 } | 158 } |
| 152 | 159 |
| 153 WebKit::WebString MediaStreamCenter::constructSDP( | 160 WebKit::WebString MediaStreamCenter::constructSDP( |
| 154 const WebKit::WebSessionDescriptionDescriptor& description) { | 161 const WebKit::WebSessionDescriptionDescriptor& description) { |
| 155 scoped_ptr<webrtc::SessionDescriptionInterface> native_desc( | 162 scoped_ptr<webrtc::SessionDescriptionInterface> native_desc( |
| 156 webrtc::CreateSessionDescription(UTF16ToUTF8(description.initialSDP()))); | 163 webrtc::CreateSessionDescription(UTF16ToUTF8(description.initialSDP()))); |
| 157 if (!native_desc.get()) | 164 if (!native_desc.get()) |
| 158 return WebKit::WebString(); | 165 return WebKit::WebString(); |
| 159 | 166 |
| 160 for (size_t i = 0; i < description.numberOfAddedCandidates(); ++i) { | 167 for (size_t i = 0; i < description.numberOfAddedCandidates(); ++i) { |
| 161 WebKit::WebICECandidateDescriptor candidate = description.candidate(i); | 168 WebKit::WebICECandidateDescriptor candidate = description.candidate(i); |
| 169 int m_line_index = -1; | |
| 170 if (!base::StringToInt(UTF16ToUTF8(candidate.label()), &m_line_index)) { | |
| 171 LOG(ERROR) << "Invalid candidate label: " | |
| 172 << UTF16ToUTF8(candidate.label()); | |
| 173 continue; | |
| 174 } | |
| 162 scoped_ptr<webrtc::IceCandidateInterface> native_candidate( | 175 scoped_ptr<webrtc::IceCandidateInterface> native_candidate( |
| 163 webrtc::CreateIceCandidate(UTF16ToUTF8(candidate.label()), | 176 webrtc::CreateIceCandidate(UTF16ToUTF8(candidate.label()), |
| 177 m_line_index, | |
| 164 UTF16ToUTF8(candidate.candidateLine()))); | 178 UTF16ToUTF8(candidate.candidateLine()))); |
| 165 native_desc->AddCandidate(native_candidate.get()); | 179 native_desc->AddCandidate(native_candidate.get()); |
| 166 } | 180 } |
| 167 | 181 |
| 168 std::string sdp; | 182 std::string sdp; |
| 169 if (!native_desc->ToString(&sdp)) | 183 if (!native_desc->ToString(&sdp)) |
| 170 LOG(ERROR) << "Could not create SDP string"; | 184 LOG(ERROR) << "Could not create SDP string"; |
| 171 return UTF8ToUTF16(sdp); | 185 return UTF8ToUTF16(sdp); |
| 172 } | 186 } |
| 173 | 187 |
| 174 } // namespace content | 188 } // namespace content |
| OLD | NEW |