Index: content/renderer/media/media_stream_center.cc |
diff --git a/content/renderer/media/media_stream_center.cc b/content/renderer/media/media_stream_center.cc |
index 172a1512003992bc6090756e05c3415d65d452f3..75b266dc49187d94d2be4d1ca66d02897d941e2b 100644 |
--- a/content/renderer/media/media_stream_center.cc |
+++ b/content/renderer/media/media_stream_center.cc |
@@ -4,10 +4,18 @@ |
#include "content/renderer/media/media_stream_center.h" |
+#include <string> |
+ |
+#include "base/logging.h" |
+#include "base/memory/scoped_ptr.h" |
+#include "base/utf_string_conversions.h" |
+#include "third_party/libjingle/source/talk/app/webrtc/jsep.h" |
+#include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebICECandidateDescriptor.h" |
#include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebMediaStreamCenterClient.h" |
#include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebMediaStreamDescriptor.h" |
#include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebMediaStreamSource.h" |
#include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebMediaStreamSourcesRequest.h" |
+#include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebSessionDescriptionDescriptor.h" |
#include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebVector.h" |
namespace content { |
@@ -41,4 +49,36 @@ void MediaStreamCenter::didConstructMediaStream( |
const WebKit::WebMediaStreamDescriptor& stream) { |
} |
+WebKit::WebString MediaStreamCenter::constructSDP( |
+ const WebKit::WebICECandidateDescriptor& candidate) { |
+ scoped_ptr<webrtc::IceCandidateInterface> native_candidate( |
+ webrtc::CreateIceCandidate(UTF16ToUTF8(candidate.label()), |
+ UTF16ToUTF8(candidate.candidateLine()))); |
+ std::string sdp; |
+ if (!native_candidate->ToString(&sdp)) |
+ LOG(ERROR) << "Could not create SDP string"; |
+ return UTF8ToUTF16(sdp); |
+} |
+ |
+WebKit::WebString MediaStreamCenter::constructSDP( |
+ const WebKit::WebSessionDescriptionDescriptor& description) { |
+ scoped_ptr<webrtc::SessionDescriptionInterface> native_desc( |
+ webrtc::CreateSessionDescription(UTF16ToUTF8(description.initialSDP()))); |
+ if (!native_desc.get()) |
+ return WebKit::WebString(); |
+ |
+ for (size_t i = 0; i < description.numberOfAddedCandidates(); ++i) { |
+ WebKit::WebICECandidateDescriptor candidate = description.candidate(i); |
+ scoped_ptr<webrtc::IceCandidateInterface> native_candidate( |
+ webrtc::CreateIceCandidate(UTF16ToUTF8(candidate.label()), |
+ UTF16ToUTF8(candidate.candidateLine()))); |
+ native_desc->AddCandidate(native_candidate.get()); |
+ } |
+ |
+ std::string sdp; |
+ if (!native_desc->ToString(&sdp)) |
+ LOG(ERROR) << "Could not create SDP string"; |
+ return UTF8ToUTF16(sdp); |
+} |
+ |
} // namespace content |