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