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/peer_connection_handler.h" | 5 #include "content/renderer/media/peer_connection_handler.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 13 matching lines...) Expand all Loading... |
24 MediaStreamDependencyFactory* dependency_factory) | 24 MediaStreamDependencyFactory* dependency_factory) |
25 : client_(client), | 25 : client_(client), |
26 media_stream_impl_(msi), | 26 media_stream_impl_(msi), |
27 dependency_factory_(dependency_factory), | 27 dependency_factory_(dependency_factory), |
28 message_loop_proxy_(base::MessageLoopProxy::current()) { | 28 message_loop_proxy_(base::MessageLoopProxy::current()) { |
29 } | 29 } |
30 | 30 |
31 PeerConnectionHandler::~PeerConnectionHandler() { | 31 PeerConnectionHandler::~PeerConnectionHandler() { |
32 } | 32 } |
33 | 33 |
| 34 bool PeerConnectionHandler::HasStream(const std::string& stream_label) { |
| 35 webrtc::MediaStreamInterface* stream = |
| 36 native_peer_connection_->remote_streams()->find(stream_label); |
| 37 return stream != NULL; |
| 38 } |
| 39 |
34 void PeerConnectionHandler::SetVideoRenderer( | 40 void PeerConnectionHandler::SetVideoRenderer( |
35 const std::string& stream_label, | 41 const std::string& stream_label, |
36 webrtc::VideoRendererWrapperInterface* renderer) { | 42 webrtc::VideoRendererWrapperInterface* renderer) { |
37 webrtc::MediaStreamInterface* stream = | 43 webrtc::MediaStreamInterface* stream = |
38 native_peer_connection_->remote_streams()->find(stream_label); | 44 native_peer_connection_->remote_streams()->find(stream_label); |
39 webrtc::VideoTracks* video_tracks = stream->video_tracks(); | 45 webrtc::VideoTracks* video_tracks = stream->video_tracks(); |
40 // We assume there is only one enabled video track. | 46 // We assume there is only one enabled video track. |
41 for(size_t i = 0; i < video_tracks->count(); ++i) { | 47 for (size_t i = 0; i < video_tracks->count(); ++i) { |
42 webrtc::VideoTrackInterface* video_track = video_tracks->at(i); | 48 webrtc::VideoTrackInterface* video_track = video_tracks->at(i); |
43 if (video_track->enabled()) { | 49 if (video_track->enabled()) { |
44 video_track->SetRenderer(renderer); | 50 video_track->SetRenderer(renderer); |
45 return; | 51 return; |
46 } | 52 } |
47 } | 53 } |
48 DVLOG(1) << "No enabled video track."; | 54 DVLOG(1) << "No enabled video track."; |
49 } | 55 } |
50 | 56 |
51 void PeerConnectionHandler::initialize( | 57 void PeerConnectionHandler::initialize( |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
87 size_t length) { | 93 size_t length) { |
88 // TODO(grunell): Implement. | 94 // TODO(grunell): Implement. |
89 NOTIMPLEMENTED(); | 95 NOTIMPLEMENTED(); |
90 } | 96 } |
91 | 97 |
92 void PeerConnectionHandler::stop() { | 98 void PeerConnectionHandler::stop() { |
93 // TODO(ronghuawu): There's an issue with signaling messages being sent during | 99 // TODO(ronghuawu): There's an issue with signaling messages being sent during |
94 // close. We need to investigate further. Not calling Close() on native | 100 // close. We need to investigate further. Not calling Close() on native |
95 // PeerConnection is OK for now. | 101 // PeerConnection is OK for now. |
96 native_peer_connection_ = NULL; | 102 native_peer_connection_ = NULL; |
97 media_stream_impl_->ClosePeerConnection(); | 103 media_stream_impl_->ClosePeerConnection(this); |
98 } | 104 } |
99 | 105 |
100 void PeerConnectionHandler::OnError() { | 106 void PeerConnectionHandler::OnError() { |
101 // TODO(grunell): Implement. | 107 // TODO(grunell): Implement. |
102 NOTIMPLEMENTED(); | 108 NOTIMPLEMENTED(); |
103 } | 109 } |
104 | 110 |
105 void PeerConnectionHandler::OnMessage(const std::string& msg) { | 111 void PeerConnectionHandler::OnMessage(const std::string& msg) { |
106 // TODO(grunell): Implement. | 112 // TODO(grunell): Implement. |
107 NOTIMPLEMENTED(); | 113 NOTIMPLEMENTED(); |
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
242 UTF8ToUTF16(video_track->label()), | 248 UTF8ToUTF16(video_track->label()), |
243 WebKit::WebMediaStreamSource::TypeVideo, | 249 WebKit::WebMediaStreamSource::TypeVideo, |
244 UTF8ToUTF16(video_track->label())); | 250 UTF8ToUTF16(video_track->label())); |
245 } | 251 } |
246 | 252 |
247 WebKit::WebMediaStreamDescriptor descriptor; | 253 WebKit::WebMediaStreamDescriptor descriptor; |
248 descriptor.initialize(UTF8ToUTF16(stream->label()), source_vector); | 254 descriptor.initialize(UTF8ToUTF16(stream->label()), source_vector); |
249 | 255 |
250 return descriptor; | 256 return descriptor; |
251 } | 257 } |
OLD | NEW |