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/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
| (...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 140 NOTREACHED(); | 140 NOTREACHED(); |
| 141 } | 141 } |
| 142 | 142 |
| 143 WebKit::WebString MediaStreamCenter::constructSDP( | 143 WebKit::WebString MediaStreamCenter::constructSDP( |
| 144 const WebKit::WebICECandidateDescriptor& candidate) { | 144 const WebKit::WebICECandidateDescriptor& candidate) { |
| 145 int m_line_index = -1; | 145 int m_line_index = -1; |
| 146 if (!base::StringToInt(UTF16ToUTF8(candidate.label()), &m_line_index)) { | 146 if (!base::StringToInt(UTF16ToUTF8(candidate.label()), &m_line_index)) { |
| 147 LOG(ERROR) << "Invalid candidate label: " << UTF16ToUTF8(candidate.label()); | 147 LOG(ERROR) << "Invalid candidate label: " << UTF16ToUTF8(candidate.label()); |
| 148 return WebKit::WebString(); | 148 return WebKit::WebString(); |
| 149 } | 149 } |
| 150 // TODO(ronghuawu): Get sdp_mid from WebKit when is available. | |
| 151 const std::string sdp_mid = ""; | |
|
wjia(left Chromium)
2012/08/02 22:09:20
std::string's default ctor make it an empty string
Ronghua Wu (Left Chromium)
2012/08/02 22:14:48
Was thinking maybe it's easier to read - people wo
| |
| 150 scoped_ptr<webrtc::IceCandidateInterface> native_candidate( | 152 scoped_ptr<webrtc::IceCandidateInterface> native_candidate( |
| 151 webrtc::CreateIceCandidate(UTF16ToUTF8(candidate.label()), | 153 webrtc::CreateIceCandidate(sdp_mid, |
| 152 m_line_index, | 154 m_line_index, |
| 153 UTF16ToUTF8(candidate.candidateLine()))); | 155 UTF16ToUTF8(candidate.candidateLine()))); |
| 154 std::string sdp; | 156 std::string sdp; |
| 155 if (!native_candidate->ToString(&sdp)) | 157 if (!native_candidate->ToString(&sdp)) |
| 156 LOG(ERROR) << "Could not create SDP string"; | 158 LOG(ERROR) << "Could not create SDP string"; |
| 157 return UTF8ToUTF16(sdp); | 159 return UTF8ToUTF16(sdp); |
| 158 } | 160 } |
| 159 | 161 |
| 160 WebKit::WebString MediaStreamCenter::constructSDP( | 162 WebKit::WebString MediaStreamCenter::constructSDP( |
| 161 const WebKit::WebSessionDescriptionDescriptor& description) { | 163 const WebKit::WebSessionDescriptionDescriptor& description) { |
| 162 scoped_ptr<webrtc::SessionDescriptionInterface> native_desc( | 164 scoped_ptr<webrtc::SessionDescriptionInterface> native_desc( |
| 163 webrtc::CreateSessionDescription(UTF16ToUTF8(description.initialSDP()))); | 165 webrtc::CreateSessionDescription(UTF16ToUTF8(description.initialSDP()))); |
| 164 if (!native_desc.get()) | 166 if (!native_desc.get()) |
| 165 return WebKit::WebString(); | 167 return WebKit::WebString(); |
| 166 | 168 |
| 167 for (size_t i = 0; i < description.numberOfAddedCandidates(); ++i) { | 169 for (size_t i = 0; i < description.numberOfAddedCandidates(); ++i) { |
| 168 WebKit::WebICECandidateDescriptor candidate = description.candidate(i); | 170 WebKit::WebICECandidateDescriptor candidate = description.candidate(i); |
| 169 int m_line_index = -1; | 171 int m_line_index = -1; |
| 170 if (!base::StringToInt(UTF16ToUTF8(candidate.label()), &m_line_index)) { | 172 if (!base::StringToInt(UTF16ToUTF8(candidate.label()), &m_line_index)) { |
| 171 LOG(ERROR) << "Invalid candidate label: " | 173 LOG(ERROR) << "Invalid candidate label: " |
| 172 << UTF16ToUTF8(candidate.label()); | 174 << UTF16ToUTF8(candidate.label()); |
| 173 continue; | 175 continue; |
| 174 } | 176 } |
| 177 // TODO(ronghuawu): Get sdp_mid from WebKit when is available. | |
| 178 const std::string sdp_mid = ""; | |
|
wjia(left Chromium)
2012/08/02 22:09:20
ditto.
Ronghua Wu (Left Chromium)
2012/08/02 22:14:48
Done.
| |
| 175 scoped_ptr<webrtc::IceCandidateInterface> native_candidate( | 179 scoped_ptr<webrtc::IceCandidateInterface> native_candidate( |
| 176 webrtc::CreateIceCandidate(UTF16ToUTF8(candidate.label()), | 180 webrtc::CreateIceCandidate(sdp_mid, |
| 177 m_line_index, | 181 m_line_index, |
| 178 UTF16ToUTF8(candidate.candidateLine()))); | 182 UTF16ToUTF8(candidate.candidateLine()))); |
| 179 native_desc->AddCandidate(native_candidate.get()); | 183 if (!native_desc->AddCandidate(native_candidate.get())) { |
| 184 LOG(ERROR) << "Failed to add candidate to SessionDescription."; | |
| 185 continue; | |
| 186 } | |
| 180 } | 187 } |
| 181 | 188 |
| 182 std::string sdp; | 189 std::string sdp; |
| 183 if (!native_desc->ToString(&sdp)) | 190 if (!native_desc->ToString(&sdp)) |
| 184 LOG(ERROR) << "Could not create SDP string"; | 191 LOG(ERROR) << "Could not create SDP string"; |
| 185 return UTF8ToUTF16(sdp); | 192 return UTF8ToUTF16(sdp); |
| 186 } | 193 } |
| 187 | 194 |
| 188 } // namespace content | 195 } // namespace content |
| OLD | NEW |