Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(171)

Side by Side Diff: webrtc/api/test/peerconnectiontestwrapper.cc

Issue 1972793003: Use scoped_refptr for On(Add|Remove)Stream and OnDataChannel. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Adding "deprecated" comments. Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright 2013 The WebRTC project authors. All Rights Reserved. 2 * Copyright 2013 The WebRTC project authors. All Rights Reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source 5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 */ 9 */
10 10
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
85 return peer_connection_.get() != NULL; 85 return peer_connection_.get() != NULL;
86 } 86 }
87 87
88 rtc::scoped_refptr<webrtc::DataChannelInterface> 88 rtc::scoped_refptr<webrtc::DataChannelInterface>
89 PeerConnectionTestWrapper::CreateDataChannel( 89 PeerConnectionTestWrapper::CreateDataChannel(
90 const std::string& label, 90 const std::string& label,
91 const webrtc::DataChannelInit& init) { 91 const webrtc::DataChannelInit& init) {
92 return peer_connection_->CreateDataChannel(label, &init); 92 return peer_connection_->CreateDataChannel(label, &init);
93 } 93 }
94 94
95 void PeerConnectionTestWrapper::OnAddStream(MediaStreamInterface* stream) { 95 void PeerConnectionTestWrapper::OnAddStream(
96 rtc::scoped_refptr<MediaStreamInterface> stream) {
96 LOG(LS_INFO) << "PeerConnectionTestWrapper " << name_ 97 LOG(LS_INFO) << "PeerConnectionTestWrapper " << name_
97 << ": OnAddStream"; 98 << ": OnAddStream";
98 // TODO(ronghuawu): support multiple streams. 99 // TODO(ronghuawu): support multiple streams.
99 if (stream->GetVideoTracks().size() > 0) { 100 if (stream->GetVideoTracks().size() > 0) {
100 renderer_.reset(new FakeVideoTrackRenderer(stream->GetVideoTracks()[0])); 101 renderer_.reset(new FakeVideoTrackRenderer(stream->GetVideoTracks()[0]));
101 } 102 }
102 } 103 }
103 104
104 void PeerConnectionTestWrapper::OnIceCandidate( 105 void PeerConnectionTestWrapper::OnIceCandidate(
105 const IceCandidateInterface* candidate) { 106 const IceCandidateInterface* candidate) {
106 std::string sdp; 107 std::string sdp;
107 EXPECT_TRUE(candidate->ToString(&sdp)); 108 EXPECT_TRUE(candidate->ToString(&sdp));
108 // Give the user a chance to modify sdp for testing. 109 // Give the user a chance to modify sdp for testing.
109 SignalOnIceCandidateCreated(&sdp); 110 SignalOnIceCandidateCreated(&sdp);
110 SignalOnIceCandidateReady(candidate->sdp_mid(), candidate->sdp_mline_index(), 111 SignalOnIceCandidateReady(candidate->sdp_mid(), candidate->sdp_mline_index(),
111 sdp); 112 sdp);
112 } 113 }
113 114
114 void PeerConnectionTestWrapper::OnDataChannel( 115 void PeerConnectionTestWrapper::OnDataChannel(
115 webrtc::DataChannelInterface* data_channel) { 116 rtc::scoped_refptr<webrtc::DataChannelInterface> data_channel) {
116 SignalOnDataChannel(data_channel); 117 SignalOnDataChannel(data_channel);
117 } 118 }
118 119
119 void PeerConnectionTestWrapper::OnSuccess(SessionDescriptionInterface* desc) { 120 void PeerConnectionTestWrapper::OnSuccess(SessionDescriptionInterface* desc) {
120 // This callback should take the ownership of |desc|. 121 // This callback should take the ownership of |desc|.
121 std::unique_ptr<SessionDescriptionInterface> owned_desc(desc); 122 std::unique_ptr<SessionDescriptionInterface> owned_desc(desc);
122 std::string sdp; 123 std::string sdp;
123 EXPECT_TRUE(desc->ToString(&sdp)); 124 EXPECT_TRUE(desc->ToString(&sdp));
124 125
125 LOG(LS_INFO) << "PeerConnectionTestWrapper " << name_ 126 LOG(LS_INFO) << "PeerConnectionTestWrapper " << name_
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after
271 peer_connection_factory_->CreateVideoSource( 272 peer_connection_factory_->CreateVideoSource(
272 new webrtc::FakePeriodicVideoCapturer(), &constraints); 273 new webrtc::FakePeriodicVideoCapturer(), &constraints);
273 std::string videotrack_label = label + kVideoTrackLabelBase; 274 std::string videotrack_label = label + kVideoTrackLabelBase;
274 rtc::scoped_refptr<webrtc::VideoTrackInterface> video_track( 275 rtc::scoped_refptr<webrtc::VideoTrackInterface> video_track(
275 peer_connection_factory_->CreateVideoTrack(videotrack_label, source)); 276 peer_connection_factory_->CreateVideoTrack(videotrack_label, source));
276 277
277 stream->AddTrack(video_track); 278 stream->AddTrack(video_track);
278 } 279 }
279 return stream; 280 return stream;
280 } 281 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698