| OLD | NEW |
| 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 603 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 614 if (FindSenderForTrack(track) != senders_.end()) { | 614 if (FindSenderForTrack(track) != senders_.end()) { |
| 615 LOG(LS_ERROR) << "Sender for track " << track->id() << " already exists."; | 615 LOG(LS_ERROR) << "Sender for track " << track->id() << " already exists."; |
| 616 return nullptr; | 616 return nullptr; |
| 617 } | 617 } |
| 618 | 618 |
| 619 // TODO(deadbeef): Support adding a track to multiple streams. | 619 // TODO(deadbeef): Support adding a track to multiple streams. |
| 620 rtc::scoped_refptr<RtpSenderProxyWithInternal<RtpSenderInternal>> new_sender; | 620 rtc::scoped_refptr<RtpSenderProxyWithInternal<RtpSenderInternal>> new_sender; |
| 621 if (track->kind() == MediaStreamTrackInterface::kAudioKind) { | 621 if (track->kind() == MediaStreamTrackInterface::kAudioKind) { |
| 622 new_sender = RtpSenderProxyWithInternal<RtpSenderInternal>::Create( | 622 new_sender = RtpSenderProxyWithInternal<RtpSenderInternal>::Create( |
| 623 signaling_thread(), | 623 signaling_thread(), |
| 624 new AudioRtpSender(static_cast<AudioTrackInterface*>(track), | 624 new rtc::RefCountedObject<AudioRtpSender>( |
| 625 session_->voice_channel(), stats_.get())); | 625 static_cast<AudioTrackInterface*>(track), |
| 626 session_->voice_channel(), stats_.get())); |
| 626 if (!streams.empty()) { | 627 if (!streams.empty()) { |
| 627 new_sender->internal()->set_stream_id(streams[0]->label()); | 628 new_sender->internal()->set_stream_id(streams[0]->label()); |
| 628 } | 629 } |
| 629 const TrackInfo* track_info = FindTrackInfo( | 630 const TrackInfo* track_info = FindTrackInfo( |
| 630 local_audio_tracks_, new_sender->internal()->stream_id(), track->id()); | 631 local_audio_tracks_, new_sender->internal()->stream_id(), track->id()); |
| 631 if (track_info) { | 632 if (track_info) { |
| 632 new_sender->internal()->SetSsrc(track_info->ssrc); | 633 new_sender->internal()->SetSsrc(track_info->ssrc); |
| 633 } | 634 } |
| 634 } else if (track->kind() == MediaStreamTrackInterface::kVideoKind) { | 635 } else if (track->kind() == MediaStreamTrackInterface::kVideoKind) { |
| 635 new_sender = RtpSenderProxyWithInternal<RtpSenderInternal>::Create( | 636 new_sender = RtpSenderProxyWithInternal<RtpSenderInternal>::Create( |
| 636 signaling_thread(), | 637 signaling_thread(), |
| 637 new VideoRtpSender(static_cast<VideoTrackInterface*>(track), | 638 new rtc::RefCountedObject<VideoRtpSender>( |
| 638 session_->video_channel())); | 639 static_cast<VideoTrackInterface*>(track), |
| 640 session_->video_channel())); |
| 639 if (!streams.empty()) { | 641 if (!streams.empty()) { |
| 640 new_sender->internal()->set_stream_id(streams[0]->label()); | 642 new_sender->internal()->set_stream_id(streams[0]->label()); |
| 641 } | 643 } |
| 642 const TrackInfo* track_info = FindTrackInfo( | 644 const TrackInfo* track_info = FindTrackInfo( |
| 643 local_video_tracks_, new_sender->internal()->stream_id(), track->id()); | 645 local_video_tracks_, new_sender->internal()->stream_id(), track->id()); |
| 644 if (track_info) { | 646 if (track_info) { |
| 645 new_sender->internal()->SetSsrc(track_info->ssrc); | 647 new_sender->internal()->SetSsrc(track_info->ssrc); |
| 646 } | 648 } |
| 647 } else { | 649 } else { |
| 648 LOG(LS_ERROR) << "CreateSender called with invalid kind: " << track->kind(); | 650 LOG(LS_ERROR) << "CreateSender called with invalid kind: " << track->kind(); |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 695 const std::string& kind, | 697 const std::string& kind, |
| 696 const std::string& stream_id) { | 698 const std::string& stream_id) { |
| 697 TRACE_EVENT0("webrtc", "PeerConnection::CreateSender"); | 699 TRACE_EVENT0("webrtc", "PeerConnection::CreateSender"); |
| 698 if (IsClosed()) { | 700 if (IsClosed()) { |
| 699 return nullptr; | 701 return nullptr; |
| 700 } | 702 } |
| 701 rtc::scoped_refptr<RtpSenderProxyWithInternal<RtpSenderInternal>> new_sender; | 703 rtc::scoped_refptr<RtpSenderProxyWithInternal<RtpSenderInternal>> new_sender; |
| 702 if (kind == MediaStreamTrackInterface::kAudioKind) { | 704 if (kind == MediaStreamTrackInterface::kAudioKind) { |
| 703 new_sender = RtpSenderProxyWithInternal<RtpSenderInternal>::Create( | 705 new_sender = RtpSenderProxyWithInternal<RtpSenderInternal>::Create( |
| 704 signaling_thread(), | 706 signaling_thread(), |
| 705 new AudioRtpSender(session_->voice_channel(), stats_.get())); | 707 new rtc::RefCountedObject<AudioRtpSender>( |
| 708 session_->voice_channel(), stats_.get())); |
| 706 } else if (kind == MediaStreamTrackInterface::kVideoKind) { | 709 } else if (kind == MediaStreamTrackInterface::kVideoKind) { |
| 707 new_sender = RtpSenderProxyWithInternal<RtpSenderInternal>::Create( | 710 new_sender = RtpSenderProxyWithInternal<RtpSenderInternal>::Create( |
| 708 signaling_thread(), new VideoRtpSender(session_->video_channel())); | 711 signaling_thread(), new rtc::RefCountedObject<VideoRtpSender>( |
| 712 session_->video_channel())); |
| 709 } else { | 713 } else { |
| 710 LOG(LS_ERROR) << "CreateSender called with invalid kind: " << kind; | 714 LOG(LS_ERROR) << "CreateSender called with invalid kind: " << kind; |
| 711 return new_sender; | 715 return new_sender; |
| 712 } | 716 } |
| 713 if (!stream_id.empty()) { | 717 if (!stream_id.empty()) { |
| 714 new_sender->internal()->set_stream_id(stream_id); | 718 new_sender->internal()->set_stream_id(stream_id); |
| 715 } | 719 } |
| 716 senders_.push_back(new_sender); | 720 senders_.push_back(new_sender); |
| 717 return new_sender; | 721 return new_sender; |
| 718 } | 722 } |
| (...skipping 696 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1415 break; | 1419 break; |
| 1416 } | 1420 } |
| 1417 } | 1421 } |
| 1418 | 1422 |
| 1419 void PeerConnection::CreateAudioReceiver(MediaStreamInterface* stream, | 1423 void PeerConnection::CreateAudioReceiver(MediaStreamInterface* stream, |
| 1420 const std::string& track_id, | 1424 const std::string& track_id, |
| 1421 uint32_t ssrc) { | 1425 uint32_t ssrc) { |
| 1422 rtc::scoped_refptr<RtpReceiverProxyWithInternal<RtpReceiverInternal>> | 1426 rtc::scoped_refptr<RtpReceiverProxyWithInternal<RtpReceiverInternal>> |
| 1423 receiver = RtpReceiverProxyWithInternal<RtpReceiverInternal>::Create( | 1427 receiver = RtpReceiverProxyWithInternal<RtpReceiverInternal>::Create( |
| 1424 signaling_thread(), | 1428 signaling_thread(), |
| 1425 new AudioRtpReceiver(track_id, ssrc, session_->voice_channel())); | 1429 new rtc::RefCountedObject<AudioRtpReceiver>( |
| 1430 track_id, ssrc, session_->voice_channel())); |
| 1426 stream->AddTrack( | 1431 stream->AddTrack( |
| 1427 static_cast<AudioTrackInterface*>(receiver->internal()->track().get())); | 1432 static_cast<AudioTrackInterface*>(receiver->internal()->track().get())); |
| 1428 receivers_.push_back(receiver); | 1433 receivers_.push_back(receiver); |
| 1429 std::vector<rtc::scoped_refptr<MediaStreamInterface>> streams; | 1434 std::vector<rtc::scoped_refptr<MediaStreamInterface>> streams; |
| 1430 streams.push_back(rtc::scoped_refptr<MediaStreamInterface>(stream)); | 1435 streams.push_back(rtc::scoped_refptr<MediaStreamInterface>(stream)); |
| 1431 observer_->OnAddTrack(receiver, streams); | 1436 observer_->OnAddTrack(receiver, streams); |
| 1432 } | 1437 } |
| 1433 | 1438 |
| 1434 void PeerConnection::CreateVideoReceiver(MediaStreamInterface* stream, | 1439 void PeerConnection::CreateVideoReceiver(MediaStreamInterface* stream, |
| 1435 const std::string& track_id, | 1440 const std::string& track_id, |
| 1436 uint32_t ssrc) { | 1441 uint32_t ssrc) { |
| 1437 rtc::scoped_refptr<RtpReceiverProxyWithInternal<RtpReceiverInternal>> | 1442 rtc::scoped_refptr<RtpReceiverProxyWithInternal<RtpReceiverInternal>> |
| 1438 receiver = RtpReceiverProxyWithInternal<RtpReceiverInternal>::Create( | 1443 receiver = RtpReceiverProxyWithInternal<RtpReceiverInternal>::Create( |
| 1439 signaling_thread(), | 1444 signaling_thread(), |
| 1440 new VideoRtpReceiver(track_id, factory_->worker_thread(), ssrc, | 1445 new rtc::RefCountedObject<VideoRtpReceiver>( |
| 1441 session_->video_channel())); | 1446 track_id, factory_->worker_thread(), ssrc, |
| 1447 session_->video_channel())); |
| 1442 stream->AddTrack( | 1448 stream->AddTrack( |
| 1443 static_cast<VideoTrackInterface*>(receiver->internal()->track().get())); | 1449 static_cast<VideoTrackInterface*>(receiver->internal()->track().get())); |
| 1444 receivers_.push_back(receiver); | 1450 receivers_.push_back(receiver); |
| 1445 std::vector<rtc::scoped_refptr<MediaStreamInterface>> streams; | 1451 std::vector<rtc::scoped_refptr<MediaStreamInterface>> streams; |
| 1446 streams.push_back(rtc::scoped_refptr<MediaStreamInterface>(stream)); | 1452 streams.push_back(rtc::scoped_refptr<MediaStreamInterface>(stream)); |
| 1447 observer_->OnAddTrack(receiver, streams); | 1453 observer_->OnAddTrack(receiver, streams); |
| 1448 } | 1454 } |
| 1449 | 1455 |
| 1450 // TODO(deadbeef): Keep RtpReceivers around even if track goes away in remote | 1456 // TODO(deadbeef): Keep RtpReceivers around even if track goes away in remote |
| 1451 // description. | 1457 // description. |
| (...skipping 16 matching lines...) Expand all Loading... |
| 1468 // We already have a sender for this track, so just change the stream_id | 1474 // We already have a sender for this track, so just change the stream_id |
| 1469 // so that it's correct in the next call to CreateOffer. | 1475 // so that it's correct in the next call to CreateOffer. |
| 1470 (*sender)->internal()->set_stream_id(stream->label()); | 1476 (*sender)->internal()->set_stream_id(stream->label()); |
| 1471 return; | 1477 return; |
| 1472 } | 1478 } |
| 1473 | 1479 |
| 1474 // Normal case; we've never seen this track before. | 1480 // Normal case; we've never seen this track before. |
| 1475 rtc::scoped_refptr<RtpSenderProxyWithInternal<RtpSenderInternal>> new_sender = | 1481 rtc::scoped_refptr<RtpSenderProxyWithInternal<RtpSenderInternal>> new_sender = |
| 1476 RtpSenderProxyWithInternal<RtpSenderInternal>::Create( | 1482 RtpSenderProxyWithInternal<RtpSenderInternal>::Create( |
| 1477 signaling_thread(), | 1483 signaling_thread(), |
| 1478 new AudioRtpSender(track, {stream->label()}, | 1484 new rtc::RefCountedObject<AudioRtpSender>( |
| 1479 session_->voice_channel(), stats_.get())); | 1485 track, std::vector<std::string>({stream->label()}), |
| 1486 session_->voice_channel(), stats_.get())); |
| 1480 senders_.push_back(new_sender); | 1487 senders_.push_back(new_sender); |
| 1481 // If the sender has already been configured in SDP, we call SetSsrc, | 1488 // If the sender has already been configured in SDP, we call SetSsrc, |
| 1482 // which will connect the sender to the underlying transport. This can | 1489 // which will connect the sender to the underlying transport. This can |
| 1483 // occur if a local session description that contains the ID of the sender | 1490 // occur if a local session description that contains the ID of the sender |
| 1484 // is set before AddStream is called. It can also occur if the local | 1491 // is set before AddStream is called. It can also occur if the local |
| 1485 // session description is not changed and RemoveStream is called, and | 1492 // session description is not changed and RemoveStream is called, and |
| 1486 // later AddStream is called again with the same stream. | 1493 // later AddStream is called again with the same stream. |
| 1487 const TrackInfo* track_info = | 1494 const TrackInfo* track_info = |
| 1488 FindTrackInfo(local_audio_tracks_, stream->label(), track->id()); | 1495 FindTrackInfo(local_audio_tracks_, stream->label(), track->id()); |
| 1489 if (track_info) { | 1496 if (track_info) { |
| (...skipping 23 matching lines...) Expand all Loading... |
| 1513 if (sender != senders_.end()) { | 1520 if (sender != senders_.end()) { |
| 1514 // We already have a sender for this track, so just change the stream_id | 1521 // We already have a sender for this track, so just change the stream_id |
| 1515 // so that it's correct in the next call to CreateOffer. | 1522 // so that it's correct in the next call to CreateOffer. |
| 1516 (*sender)->internal()->set_stream_id(stream->label()); | 1523 (*sender)->internal()->set_stream_id(stream->label()); |
| 1517 return; | 1524 return; |
| 1518 } | 1525 } |
| 1519 | 1526 |
| 1520 // Normal case; we've never seen this track before. | 1527 // Normal case; we've never seen this track before. |
| 1521 rtc::scoped_refptr<RtpSenderProxyWithInternal<RtpSenderInternal>> new_sender = | 1528 rtc::scoped_refptr<RtpSenderProxyWithInternal<RtpSenderInternal>> new_sender = |
| 1522 RtpSenderProxyWithInternal<RtpSenderInternal>::Create( | 1529 RtpSenderProxyWithInternal<RtpSenderInternal>::Create( |
| 1523 signaling_thread(), new VideoRtpSender(track, {stream->label()}, | 1530 signaling_thread(), new rtc::RefCountedObject<VideoRtpSender>( |
| 1524 session_->video_channel())); | 1531 track, |
| 1532 std::vector<std::string>({stream->label()}), |
| 1533 session_->video_channel())); |
| 1525 senders_.push_back(new_sender); | 1534 senders_.push_back(new_sender); |
| 1526 const TrackInfo* track_info = | 1535 const TrackInfo* track_info = |
| 1527 FindTrackInfo(local_video_tracks_, stream->label(), track->id()); | 1536 FindTrackInfo(local_video_tracks_, stream->label(), track->id()); |
| 1528 if (track_info) { | 1537 if (track_info) { |
| 1529 new_sender->internal()->SetSsrc(track_info->ssrc); | 1538 new_sender->internal()->SetSsrc(track_info->ssrc); |
| 1530 } | 1539 } |
| 1531 } | 1540 } |
| 1532 | 1541 |
| 1533 void PeerConnection::RemoveVideoTrack(VideoTrackInterface* track, | 1542 void PeerConnection::RemoveVideoTrack(VideoTrackInterface* track, |
| 1534 MediaStreamInterface* stream) { | 1543 MediaStreamInterface* stream) { |
| (...skipping 991 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2526 return event_log_->StartLogging(file, max_size_bytes); | 2535 return event_log_->StartLogging(file, max_size_bytes); |
| 2527 } | 2536 } |
| 2528 | 2537 |
| 2529 void PeerConnection::StopRtcEventLog_w() { | 2538 void PeerConnection::StopRtcEventLog_w() { |
| 2530 if (event_log_) { | 2539 if (event_log_) { |
| 2531 event_log_->StopLogging(); | 2540 event_log_->StopLogging(); |
| 2532 } | 2541 } |
| 2533 } | 2542 } |
| 2534 | 2543 |
| 2535 } // namespace webrtc | 2544 } // namespace webrtc |
| OLD | NEW |