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

Side by Side Diff: webrtc/api/peerconnection.cc

Issue 1871833002: Rename BEGIN_PROXY_MAP --> BEGIN_SIGNALLING_PROXY_MAP. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Created 4 years, 8 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 2012 The WebRTC project authors. All Rights Reserved. 2 * Copyright 2012 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 670 matching lines...) Expand 10 before | Expand all | Expand 10 after
681 } 681 }
682 // TODO(deadbeef): Support adding a track to two different senders. 682 // TODO(deadbeef): Support adding a track to two different senders.
683 if (FindSenderForTrack(track) != senders_.end()) { 683 if (FindSenderForTrack(track) != senders_.end()) {
684 LOG(LS_ERROR) << "Sender for track " << track->id() << " already exists."; 684 LOG(LS_ERROR) << "Sender for track " << track->id() << " already exists.";
685 return nullptr; 685 return nullptr;
686 } 686 }
687 687
688 // TODO(deadbeef): Support adding a track to multiple streams. 688 // TODO(deadbeef): Support adding a track to multiple streams.
689 rtc::scoped_refptr<RtpSenderInterface> new_sender; 689 rtc::scoped_refptr<RtpSenderInterface> new_sender;
690 if (track->kind() == MediaStreamTrackInterface::kAudioKind) { 690 if (track->kind() == MediaStreamTrackInterface::kAudioKind) {
691 new_sender = RtpSenderProxy::Create( 691 new_sender = RtpSenderSignallingProxy::Create(
tommi 2016/04/08 09:00:22 ah, I didn't think through my class-renaming sugge
692 signaling_thread(), 692 signaling_thread(),
693 new AudioRtpSender(static_cast<AudioTrackInterface*>(track), 693 new AudioRtpSender(static_cast<AudioTrackInterface*>(track),
694 session_.get(), stats_.get())); 694 session_.get(), stats_.get()));
695 if (!streams.empty()) { 695 if (!streams.empty()) {
696 new_sender->set_stream_id(streams[0]->label()); 696 new_sender->set_stream_id(streams[0]->label());
697 } 697 }
698 const TrackInfo* track_info = FindTrackInfo( 698 const TrackInfo* track_info = FindTrackInfo(
699 local_audio_tracks_, new_sender->stream_id(), track->id()); 699 local_audio_tracks_, new_sender->stream_id(), track->id());
700 if (track_info) { 700 if (track_info) {
701 new_sender->SetSsrc(track_info->ssrc); 701 new_sender->SetSsrc(track_info->ssrc);
702 } 702 }
703 } else if (track->kind() == MediaStreamTrackInterface::kVideoKind) { 703 } else if (track->kind() == MediaStreamTrackInterface::kVideoKind) {
704 new_sender = RtpSenderProxy::Create( 704 new_sender = RtpSenderSignallingProxy::Create(
705 signaling_thread(), 705 signaling_thread(),
706 new VideoRtpSender(static_cast<VideoTrackInterface*>(track), 706 new VideoRtpSender(static_cast<VideoTrackInterface*>(track),
707 session_.get())); 707 session_.get()));
708 if (!streams.empty()) { 708 if (!streams.empty()) {
709 new_sender->set_stream_id(streams[0]->label()); 709 new_sender->set_stream_id(streams[0]->label());
710 } 710 }
711 const TrackInfo* track_info = FindTrackInfo( 711 const TrackInfo* track_info = FindTrackInfo(
712 local_video_tracks_, new_sender->stream_id(), track->id()); 712 local_video_tracks_, new_sender->stream_id(), track->id());
713 if (track_info) { 713 if (track_info) {
714 new_sender->SetSsrc(track_info->ssrc); 714 new_sender->SetSsrc(track_info->ssrc);
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
752 LOG(LS_ERROR) << "CreateDtmfSender is called with a non local audio track."; 752 LOG(LS_ERROR) << "CreateDtmfSender is called with a non local audio track.";
753 return NULL; 753 return NULL;
754 } 754 }
755 755
756 rtc::scoped_refptr<DtmfSenderInterface> sender( 756 rtc::scoped_refptr<DtmfSenderInterface> sender(
757 DtmfSender::Create(track, signaling_thread(), session_.get())); 757 DtmfSender::Create(track, signaling_thread(), session_.get()));
758 if (!sender.get()) { 758 if (!sender.get()) {
759 LOG(LS_ERROR) << "CreateDtmfSender failed on DtmfSender::Create."; 759 LOG(LS_ERROR) << "CreateDtmfSender failed on DtmfSender::Create.";
760 return NULL; 760 return NULL;
761 } 761 }
762 return DtmfSenderProxy::Create(signaling_thread(), sender.get()); 762 return DtmfSenderSignallingProxy::Create(signaling_thread(), sender.get());
763 } 763 }
764 764
765 rtc::scoped_refptr<RtpSenderInterface> PeerConnection::CreateSender( 765 rtc::scoped_refptr<RtpSenderInterface> PeerConnection::CreateSender(
766 const std::string& kind, 766 const std::string& kind,
767 const std::string& stream_id) { 767 const std::string& stream_id) {
768 TRACE_EVENT0("webrtc", "PeerConnection::CreateSender"); 768 TRACE_EVENT0("webrtc", "PeerConnection::CreateSender");
769 rtc::scoped_refptr<RtpSenderInterface> new_sender; 769 rtc::scoped_refptr<RtpSenderInterface> new_sender;
770 if (kind == MediaStreamTrackInterface::kAudioKind) { 770 if (kind == MediaStreamTrackInterface::kAudioKind) {
771 new_sender = RtpSenderProxy::Create( 771 new_sender = RtpSenderSignallingProxy::Create(
772 signaling_thread(), new AudioRtpSender(session_.get(), stats_.get())); 772 signaling_thread(), new AudioRtpSender(session_.get(), stats_.get()));
773 } else if (kind == MediaStreamTrackInterface::kVideoKind) { 773 } else if (kind == MediaStreamTrackInterface::kVideoKind) {
774 new_sender = RtpSenderProxy::Create(signaling_thread(), 774 new_sender = RtpSenderSignallingProxy::Create(
775 new VideoRtpSender(session_.get())); 775 signaling_thread(), new VideoRtpSender(session_.get()));
776 } else { 776 } else {
777 LOG(LS_ERROR) << "CreateSender called with invalid kind: " << kind; 777 LOG(LS_ERROR) << "CreateSender called with invalid kind: " << kind;
778 return new_sender; 778 return new_sender;
779 } 779 }
780 if (!stream_id.empty()) { 780 if (!stream_id.empty()) {
781 new_sender->set_stream_id(stream_id); 781 new_sender->set_stream_id(stream_id);
782 } 782 }
783 senders_.push_back(new_sender); 783 senders_.push_back(new_sender);
784 return new_sender; 784 return new_sender;
785 } 785 }
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
844 if (!channel.get()) { 844 if (!channel.get()) {
845 return nullptr; 845 return nullptr;
846 } 846 }
847 847
848 // Trigger the onRenegotiationNeeded event for every new RTP DataChannel, or 848 // Trigger the onRenegotiationNeeded event for every new RTP DataChannel, or
849 // the first SCTP DataChannel. 849 // the first SCTP DataChannel.
850 if (session_->data_channel_type() == cricket::DCT_RTP || first_datachannel) { 850 if (session_->data_channel_type() == cricket::DCT_RTP || first_datachannel) {
851 observer_->OnRenegotiationNeeded(); 851 observer_->OnRenegotiationNeeded();
852 } 852 }
853 853
854 return DataChannelProxy::Create(signaling_thread(), channel.get()); 854 return DataChannelSignallingProxy::Create(signaling_thread(), channel.get());
855 } 855 }
856 856
857 void PeerConnection::CreateOffer(CreateSessionDescriptionObserver* observer, 857 void PeerConnection::CreateOffer(CreateSessionDescriptionObserver* observer,
858 const MediaConstraintsInterface* constraints) { 858 const MediaConstraintsInterface* constraints) {
859 TRACE_EVENT0("webrtc", "PeerConnection::CreateOffer"); 859 TRACE_EVENT0("webrtc", "PeerConnection::CreateOffer");
860 if (!VERIFY(observer != nullptr)) { 860 if (!VERIFY(observer != nullptr)) {
861 LOG(LS_ERROR) << "CreateOffer - observer is NULL."; 861 LOG(LS_ERROR) << "CreateOffer - observer is NULL.";
862 return; 862 return;
863 } 863 }
864 RTCOfferAnswerOptions options; 864 RTCOfferAnswerOptions options;
(...skipping 410 matching lines...) Expand 10 before | Expand all | Expand 10 after
1275 } 1275 }
1276 default: 1276 default:
1277 RTC_DCHECK(false && "Not implemented"); 1277 RTC_DCHECK(false && "Not implemented");
1278 break; 1278 break;
1279 } 1279 }
1280 } 1280 }
1281 1281
1282 void PeerConnection::CreateAudioReceiver(MediaStreamInterface* stream, 1282 void PeerConnection::CreateAudioReceiver(MediaStreamInterface* stream,
1283 const std::string& track_id, 1283 const std::string& track_id,
1284 uint32_t ssrc) { 1284 uint32_t ssrc) {
1285 receivers_.push_back(RtpReceiverProxy::Create( 1285 receivers_.push_back(RtpReceiverSignallingProxy::Create(
1286 signaling_thread(), 1286 signaling_thread(),
1287 new AudioRtpReceiver(stream, track_id, ssrc, session_.get()))); 1287 new AudioRtpReceiver(stream, track_id, ssrc, session_.get())));
1288 } 1288 }
1289 1289
1290 void PeerConnection::CreateVideoReceiver(MediaStreamInterface* stream, 1290 void PeerConnection::CreateVideoReceiver(MediaStreamInterface* stream,
1291 const std::string& track_id, 1291 const std::string& track_id,
1292 uint32_t ssrc) { 1292 uint32_t ssrc) {
1293 receivers_.push_back(RtpReceiverProxy::Create( 1293 receivers_.push_back(RtpReceiverSignallingProxy::Create(
1294 signaling_thread(), 1294 signaling_thread(),
1295 new VideoRtpReceiver(stream, track_id, factory_->worker_thread(), ssrc, 1295 new VideoRtpReceiver(stream, track_id, factory_->worker_thread(), ssrc,
1296 session_.get()))); 1296 session_.get())));
1297 } 1297 }
1298 1298
1299 // TODO(deadbeef): Keep RtpReceivers around even if track goes away in remote 1299 // TODO(deadbeef): Keep RtpReceivers around even if track goes away in remote
1300 // description. 1300 // description.
1301 void PeerConnection::DestroyReceiver(const std::string& track_id) { 1301 void PeerConnection::DestroyReceiver(const std::string& track_id) {
1302 auto it = FindReceiverForTrack(track_id); 1302 auto it = FindReceiverForTrack(track_id);
1303 if (it == receivers_.end()) { 1303 if (it == receivers_.end()) {
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
1378 MediaStreamInterface* stream) { 1378 MediaStreamInterface* stream) {
1379 auto sender = FindSenderForTrack(track); 1379 auto sender = FindSenderForTrack(track);
1380 if (sender != senders_.end()) { 1380 if (sender != senders_.end()) {
1381 // We already have a sender for this track, so just change the stream_id 1381 // We already have a sender for this track, so just change the stream_id
1382 // so that it's correct in the next call to CreateOffer. 1382 // so that it's correct in the next call to CreateOffer.
1383 (*sender)->set_stream_id(stream->label()); 1383 (*sender)->set_stream_id(stream->label());
1384 return; 1384 return;
1385 } 1385 }
1386 1386
1387 // Normal case; we've never seen this track before. 1387 // Normal case; we've never seen this track before.
1388 rtc::scoped_refptr<RtpSenderInterface> new_sender = RtpSenderProxy::Create( 1388 rtc::scoped_refptr<RtpSenderInterface> new_sender =
1389 signaling_thread(), 1389 RtpSenderSignallingProxy::Create(
1390 new AudioRtpSender(track, stream->label(), session_.get(), stats_.get())); 1390 signaling_thread(), new AudioRtpSender(track, stream->label(),
1391 session_.get(), stats_.get()));
1391 senders_.push_back(new_sender); 1392 senders_.push_back(new_sender);
1392 // If the sender has already been configured in SDP, we call SetSsrc, 1393 // If the sender has already been configured in SDP, we call SetSsrc,
1393 // which will connect the sender to the underlying transport. This can 1394 // which will connect the sender to the underlying transport. This can
1394 // occur if a local session description that contains the ID of the sender 1395 // occur if a local session description that contains the ID of the sender
1395 // is set before AddStream is called. It can also occur if the local 1396 // is set before AddStream is called. It can also occur if the local
1396 // session description is not changed and RemoveStream is called, and 1397 // session description is not changed and RemoveStream is called, and
1397 // later AddStream is called again with the same stream. 1398 // later AddStream is called again with the same stream.
1398 const TrackInfo* track_info = 1399 const TrackInfo* track_info =
1399 FindTrackInfo(local_audio_tracks_, stream->label(), track->id()); 1400 FindTrackInfo(local_audio_tracks_, stream->label(), track->id());
1400 if (track_info) { 1401 if (track_info) {
(...skipping 19 matching lines...) Expand all
1420 MediaStreamInterface* stream) { 1421 MediaStreamInterface* stream) {
1421 auto sender = FindSenderForTrack(track); 1422 auto sender = FindSenderForTrack(track);
1422 if (sender != senders_.end()) { 1423 if (sender != senders_.end()) {
1423 // We already have a sender for this track, so just change the stream_id 1424 // We already have a sender for this track, so just change the stream_id
1424 // so that it's correct in the next call to CreateOffer. 1425 // so that it's correct in the next call to CreateOffer.
1425 (*sender)->set_stream_id(stream->label()); 1426 (*sender)->set_stream_id(stream->label());
1426 return; 1427 return;
1427 } 1428 }
1428 1429
1429 // Normal case; we've never seen this track before. 1430 // Normal case; we've never seen this track before.
1430 rtc::scoped_refptr<RtpSenderInterface> new_sender = RtpSenderProxy::Create( 1431 rtc::scoped_refptr<RtpSenderInterface> new_sender =
1431 signaling_thread(), 1432 RtpSenderSignallingProxy::Create(
1432 new VideoRtpSender(track, stream->label(), session_.get())); 1433 signaling_thread(),
1434 new VideoRtpSender(track, stream->label(), session_.get()));
1433 senders_.push_back(new_sender); 1435 senders_.push_back(new_sender);
1434 const TrackInfo* track_info = 1436 const TrackInfo* track_info =
1435 FindTrackInfo(local_video_tracks_, stream->label(), track->id()); 1437 FindTrackInfo(local_video_tracks_, stream->label(), track->id());
1436 if (track_info) { 1438 if (track_info) {
1437 new_sender->SetSsrc(track_info->ssrc); 1439 new_sender->SetSsrc(track_info->ssrc);
1438 } 1440 }
1439 } 1441 }
1440 1442
1441 void PeerConnection::OnVideoTrackRemoved(VideoTrackInterface* track, 1443 void PeerConnection::OnVideoTrackRemoved(VideoTrackInterface* track,
1442 MediaStreamInterface* stream) { 1444 MediaStreamInterface* stream) {
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
1592 // The sync_label is the MediaStream label and the |stream.id| is the 1594 // The sync_label is the MediaStream label and the |stream.id| is the
1593 // track id. 1595 // track id.
1594 const std::string& stream_label = params.sync_label; 1596 const std::string& stream_label = params.sync_label;
1595 const std::string& track_id = params.id; 1597 const std::string& track_id = params.id;
1596 uint32_t ssrc = params.first_ssrc(); 1598 uint32_t ssrc = params.first_ssrc();
1597 1599
1598 rtc::scoped_refptr<MediaStreamInterface> stream = 1600 rtc::scoped_refptr<MediaStreamInterface> stream =
1599 remote_streams_->find(stream_label); 1601 remote_streams_->find(stream_label);
1600 if (!stream) { 1602 if (!stream) {
1601 // This is a new MediaStream. Create a new remote MediaStream. 1603 // This is a new MediaStream. Create a new remote MediaStream.
1602 stream = MediaStreamProxy::Create(rtc::Thread::Current(), 1604 stream = MediaStreamSignallingProxy::Create(
1603 MediaStream::Create(stream_label)); 1605 rtc::Thread::Current(), MediaStream::Create(stream_label));
1604 remote_streams_->AddStream(stream); 1606 remote_streams_->AddStream(stream);
1605 new_streams->AddStream(stream); 1607 new_streams->AddStream(stream);
1606 } 1608 }
1607 1609
1608 const TrackInfo* track_info = 1610 const TrackInfo* track_info =
1609 FindTrackInfo(*current_tracks, stream_label, track_id); 1611 FindTrackInfo(*current_tracks, stream_label, track_id);
1610 if (!track_info) { 1612 if (!track_info) {
1611 current_tracks->push_back(TrackInfo(stream_label, track_id, ssrc)); 1613 current_tracks->push_back(TrackInfo(stream_label, track_id, ssrc));
1612 OnRemoteTrackSeen(stream_label, track_id, ssrc, media_type); 1614 OnRemoteTrackSeen(stream_label, track_id, ssrc, media_type);
1613 } 1615 }
1614 } 1616 }
1615 1617
1616 // Add default track if necessary. 1618 // Add default track if necessary.
1617 if (default_track_needed) { 1619 if (default_track_needed) {
1618 rtc::scoped_refptr<MediaStreamInterface> default_stream = 1620 rtc::scoped_refptr<MediaStreamInterface> default_stream =
1619 remote_streams_->find(kDefaultStreamLabel); 1621 remote_streams_->find(kDefaultStreamLabel);
1620 if (!default_stream) { 1622 if (!default_stream) {
1621 // Create the new default MediaStream. 1623 // Create the new default MediaStream.
1622 default_stream = MediaStreamProxy::Create( 1624 default_stream = MediaStreamSignallingProxy::Create(
1623 rtc::Thread::Current(), MediaStream::Create(kDefaultStreamLabel)); 1625 rtc::Thread::Current(), MediaStream::Create(kDefaultStreamLabel));
1624 remote_streams_->AddStream(default_stream); 1626 remote_streams_->AddStream(default_stream);
1625 new_streams->AddStream(default_stream); 1627 new_streams->AddStream(default_stream);
1626 } 1628 }
1627 std::string default_track_id = (media_type == cricket::MEDIA_TYPE_AUDIO) 1629 std::string default_track_id = (media_type == cricket::MEDIA_TYPE_AUDIO)
1628 ? kDefaultAudioTrackLabel 1630 ? kDefaultAudioTrackLabel
1629 : kDefaultVideoTrackLabel; 1631 : kDefaultVideoTrackLabel;
1630 const TrackInfo* default_track_info = 1632 const TrackInfo* default_track_info =
1631 FindTrackInfo(*current_tracks, kDefaultStreamLabel, default_track_id); 1633 FindTrackInfo(*current_tracks, kDefaultStreamLabel, default_track_id);
1632 if (!default_track_info) { 1634 if (!default_track_info) {
(...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after
1858 uint32_t remote_ssrc) { 1860 uint32_t remote_ssrc) {
1859 rtc::scoped_refptr<DataChannel> channel( 1861 rtc::scoped_refptr<DataChannel> channel(
1860 InternalCreateDataChannel(label, nullptr)); 1862 InternalCreateDataChannel(label, nullptr));
1861 if (!channel.get()) { 1863 if (!channel.get()) {
1862 LOG(LS_WARNING) << "Remote peer requested a DataChannel but" 1864 LOG(LS_WARNING) << "Remote peer requested a DataChannel but"
1863 << "CreateDataChannel failed."; 1865 << "CreateDataChannel failed.";
1864 return; 1866 return;
1865 } 1867 }
1866 channel->SetReceiveSsrc(remote_ssrc); 1868 channel->SetReceiveSsrc(remote_ssrc);
1867 observer_->OnDataChannel( 1869 observer_->OnDataChannel(
1868 DataChannelProxy::Create(signaling_thread(), channel)); 1870 DataChannelSignallingProxy::Create(signaling_thread(), channel));
1869 } 1871 }
1870 1872
1871 rtc::scoped_refptr<DataChannel> PeerConnection::InternalCreateDataChannel( 1873 rtc::scoped_refptr<DataChannel> PeerConnection::InternalCreateDataChannel(
1872 const std::string& label, 1874 const std::string& label,
1873 const InternalDataChannelInit* config) { 1875 const InternalDataChannelInit* config) {
1874 if (IsClosed()) { 1876 if (IsClosed()) {
1875 return nullptr; 1877 return nullptr;
1876 } 1878 }
1877 if (session_->data_channel_type() == cricket::DCT_NONE) { 1879 if (session_->data_channel_type() == cricket::DCT_NONE) {
1878 LOG(LS_ERROR) 1880 LOG(LS_ERROR)
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
1989 const std::string& label, 1991 const std::string& label,
1990 const InternalDataChannelInit& config) { 1992 const InternalDataChannelInit& config) {
1991 rtc::scoped_refptr<DataChannel> channel( 1993 rtc::scoped_refptr<DataChannel> channel(
1992 InternalCreateDataChannel(label, &config)); 1994 InternalCreateDataChannel(label, &config));
1993 if (!channel.get()) { 1995 if (!channel.get()) {
1994 LOG(LS_ERROR) << "Failed to create DataChannel from the OPEN message."; 1996 LOG(LS_ERROR) << "Failed to create DataChannel from the OPEN message.";
1995 return; 1997 return;
1996 } 1998 }
1997 1999
1998 observer_->OnDataChannel( 2000 observer_->OnDataChannel(
1999 DataChannelProxy::Create(signaling_thread(), channel)); 2001 DataChannelSignallingProxy::Create(signaling_thread(), channel));
2000 } 2002 }
2001 2003
2002 RtpSenderInterface* PeerConnection::FindSenderById(const std::string& id) { 2004 RtpSenderInterface* PeerConnection::FindSenderById(const std::string& id) {
2003 auto it = 2005 auto it =
2004 std::find_if(senders_.begin(), senders_.end(), 2006 std::find_if(senders_.begin(), senders_.end(),
2005 [id](const rtc::scoped_refptr<RtpSenderInterface>& sender) { 2007 [id](const rtc::scoped_refptr<RtpSenderInterface>& sender) {
2006 return sender->id() == id; 2008 return sender->id() == id;
2007 }); 2009 });
2008 return it != senders_.end() ? it->get() : nullptr; 2010 return it != senders_.end() ? it->get() : nullptr;
2009 } 2011 }
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
2058 DataChannel* PeerConnection::FindDataChannelBySid(int sid) const { 2060 DataChannel* PeerConnection::FindDataChannelBySid(int sid) const {
2059 for (const auto& channel : sctp_data_channels_) { 2061 for (const auto& channel : sctp_data_channels_) {
2060 if (channel->id() == sid) { 2062 if (channel->id() == sid) {
2061 return channel; 2063 return channel;
2062 } 2064 }
2063 } 2065 }
2064 return nullptr; 2066 return nullptr;
2065 } 2067 }
2066 2068
2067 } // namespace webrtc 2069 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698