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> |
| 8 |
| 9 #include "base/logging.h" |
| 10 #include "base/memory/scoped_ptr.h" |
| 11 #include "base/utf_string_conversions.h" |
| 12 #include "third_party/libjingle/source/talk/app/webrtc/jsep.h" |
| 13 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebICECandid
ateDescriptor.h" |
7 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebMediaStre
amCenterClient.h" | 14 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebMediaStre
amCenterClient.h" |
8 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebMediaStre
amDescriptor.h" | 15 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebMediaStre
amDescriptor.h" |
9 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebMediaStre
amSource.h" | 16 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebMediaStre
amSource.h" |
10 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebMediaStre
amSourcesRequest.h" | 17 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebMediaStre
amSourcesRequest.h" |
| 18 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebSessionDe
scriptionDescriptor.h" |
11 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebVector.h" | 19 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebVector.h" |
12 | 20 |
13 namespace content { | 21 namespace content { |
14 | 22 |
15 MediaStreamCenter::MediaStreamCenter( | 23 MediaStreamCenter::MediaStreamCenter( |
16 WebKit::WebMediaStreamCenterClient* client) | 24 WebKit::WebMediaStreamCenterClient* client) |
17 : client_(client) { | 25 : client_(client) { |
18 } | 26 } |
19 | 27 |
20 void MediaStreamCenter::queryMediaStreamSources( | 28 void MediaStreamCenter::queryMediaStreamSources( |
(...skipping 13 matching lines...) Expand all Loading... |
34 } | 42 } |
35 | 43 |
36 void MediaStreamCenter::didStopLocalMediaStream( | 44 void MediaStreamCenter::didStopLocalMediaStream( |
37 const WebKit::WebMediaStreamDescriptor& stream) { | 45 const WebKit::WebMediaStreamDescriptor& stream) { |
38 } | 46 } |
39 | 47 |
40 void MediaStreamCenter::didConstructMediaStream( | 48 void MediaStreamCenter::didConstructMediaStream( |
41 const WebKit::WebMediaStreamDescriptor& stream) { | 49 const WebKit::WebMediaStreamDescriptor& stream) { |
42 } | 50 } |
43 | 51 |
| 52 WebKit::WebString MediaStreamCenter::constructSDP( |
| 53 const WebKit::WebICECandidateDescriptor& candidate) { |
| 54 scoped_ptr<webrtc::IceCandidateInterface> native_candidate( |
| 55 webrtc::CreateIceCandidate(UTF16ToUTF8(candidate.label()), |
| 56 UTF16ToUTF8(candidate.candidateLine()))); |
| 57 std::string sdp; |
| 58 if (!native_candidate->ToString(&sdp)) |
| 59 LOG(ERROR) << "Could not create SDP string"; |
| 60 return UTF8ToUTF16(sdp); |
| 61 } |
| 62 |
| 63 WebKit::WebString MediaStreamCenter::constructSDP( |
| 64 const WebKit::WebSessionDescriptionDescriptor& description) { |
| 65 scoped_ptr<webrtc::SessionDescriptionInterface> native_desc( |
| 66 webrtc::CreateSessionDescription(UTF16ToUTF8(description.initialSDP()))); |
| 67 if (!native_desc.get()) |
| 68 return WebKit::WebString(); |
| 69 |
| 70 for (size_t i = 0; i < description.numberOfAddedCandidates(); ++i) { |
| 71 WebKit::WebICECandidateDescriptor candidate = description.candidate(i); |
| 72 scoped_ptr<webrtc::IceCandidateInterface> native_candidate( |
| 73 webrtc::CreateIceCandidate(UTF16ToUTF8(candidate.label()), |
| 74 UTF16ToUTF8(candidate.candidateLine()))); |
| 75 native_desc->AddCandidate(native_candidate.get()); |
| 76 } |
| 77 |
| 78 std::string sdp; |
| 79 if (!native_desc->ToString(&sdp)) |
| 80 LOG(ERROR) << "Could not create SDP string"; |
| 81 return UTF8ToUTF16(sdp); |
| 82 } |
| 83 |
44 } // namespace content | 84 } // namespace content |
OLD | NEW |