| OLD | NEW |
| 1 /* | 1 /* |
| 2 * libjingle | 2 * libjingle |
| 3 * Copyright 2012 Google Inc. | 3 * Copyright 2012 Google Inc. |
| 4 * | 4 * |
| 5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
| 6 * modification, are permitted provided that the following conditions are met: | 6 * modification, are permitted provided that the following conditions are met: |
| 7 * | 7 * |
| 8 * 1. Redistributions of source code must retain the above copyright notice, | 8 * 1. Redistributions of source code must retain the above copyright notice, |
| 9 * this list of conditions and the following disclaimer. | 9 * this list of conditions and the following disclaimer. |
| 10 * 2. Redistributions in binary form must reproduce the above copyright notice, | 10 * 2. Redistributions in binary form must reproduce the above copyright notice, |
| (...skipping 594 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 605 } | 605 } |
| 606 } | 606 } |
| 607 | 607 |
| 608 // Find new and active tracks. | 608 // Find new and active tracks. |
| 609 for (cricket::StreamParamsVec::const_iterator it = streams.begin(); | 609 for (cricket::StreamParamsVec::const_iterator it = streams.begin(); |
| 610 it != streams.end(); ++it) { | 610 it != streams.end(); ++it) { |
| 611 // The sync_label is the MediaStream label and the |stream.id| is the | 611 // The sync_label is the MediaStream label and the |stream.id| is the |
| 612 // track id. | 612 // track id. |
| 613 const std::string& stream_label = it->sync_label; | 613 const std::string& stream_label = it->sync_label; |
| 614 const std::string& track_id = it->id; | 614 const std::string& track_id = it->id; |
| 615 uint32 ssrc = it->first_ssrc(); | 615 uint32_t ssrc = it->first_ssrc(); |
| 616 | 616 |
| 617 rtc::scoped_refptr<MediaStreamInterface> stream = | 617 rtc::scoped_refptr<MediaStreamInterface> stream = |
| 618 remote_streams_->find(stream_label); | 618 remote_streams_->find(stream_label); |
| 619 if (!stream) { | 619 if (!stream) { |
| 620 // This is a new MediaStream. Create a new remote MediaStream. | 620 // This is a new MediaStream. Create a new remote MediaStream. |
| 621 stream = remote_stream_factory_->CreateMediaStream(stream_label); | 621 stream = remote_stream_factory_->CreateMediaStream(stream_label); |
| 622 remote_streams_->AddStream(stream); | 622 remote_streams_->AddStream(stream); |
| 623 new_streams->AddStream(stream); | 623 new_streams->AddStream(stream); |
| 624 } | 624 } |
| 625 | 625 |
| 626 const TrackInfo* track_info = FindTrackInfo(*current_tracks, stream_label, | 626 const TrackInfo* track_info = FindTrackInfo(*current_tracks, stream_label, |
| 627 track_id); | 627 track_id); |
| 628 if (!track_info) { | 628 if (!track_info) { |
| 629 current_tracks->push_back(TrackInfo(stream_label, track_id, ssrc)); | 629 current_tracks->push_back(TrackInfo(stream_label, track_id, ssrc)); |
| 630 OnRemoteTrackSeen(stream_label, track_id, it->first_ssrc(), media_type); | 630 OnRemoteTrackSeen(stream_label, track_id, it->first_ssrc(), media_type); |
| 631 } | 631 } |
| 632 } | 632 } |
| 633 } | 633 } |
| 634 | 634 |
| 635 void MediaStreamSignaling::OnRemoteTrackSeen(const std::string& stream_label, | 635 void MediaStreamSignaling::OnRemoteTrackSeen(const std::string& stream_label, |
| 636 const std::string& track_id, | 636 const std::string& track_id, |
| 637 uint32 ssrc, | 637 uint32_t ssrc, |
| 638 cricket::MediaType media_type) { | 638 cricket::MediaType media_type) { |
| 639 MediaStreamInterface* stream = remote_streams_->find(stream_label); | 639 MediaStreamInterface* stream = remote_streams_->find(stream_label); |
| 640 | 640 |
| 641 if (media_type == cricket::MEDIA_TYPE_AUDIO) { | 641 if (media_type == cricket::MEDIA_TYPE_AUDIO) { |
| 642 AudioTrackInterface* audio_track = | 642 AudioTrackInterface* audio_track = |
| 643 remote_stream_factory_->AddAudioTrack(stream, track_id); | 643 remote_stream_factory_->AddAudioTrack(stream, track_id); |
| 644 stream_observer_->OnAddRemoteAudioTrack(stream, audio_track, ssrc); | 644 stream_observer_->OnAddRemoteAudioTrack(stream, audio_track, ssrc); |
| 645 } else if (media_type == cricket::MEDIA_TYPE_VIDEO) { | 645 } else if (media_type == cricket::MEDIA_TYPE_VIDEO) { |
| 646 VideoTrackInterface* video_track = | 646 VideoTrackInterface* video_track = |
| 647 remote_stream_factory_->AddVideoTrack(stream, track_id); | 647 remote_stream_factory_->AddVideoTrack(stream, track_id); |
| (...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 794 } | 794 } |
| 795 } | 795 } |
| 796 | 796 |
| 797 // Find new and active tracks. | 797 // Find new and active tracks. |
| 798 for (cricket::StreamParamsVec::const_iterator it = streams.begin(); | 798 for (cricket::StreamParamsVec::const_iterator it = streams.begin(); |
| 799 it != streams.end(); ++it) { | 799 it != streams.end(); ++it) { |
| 800 // The sync_label is the MediaStream label and the |stream.id| is the | 800 // The sync_label is the MediaStream label and the |stream.id| is the |
| 801 // track id. | 801 // track id. |
| 802 const std::string& stream_label = it->sync_label; | 802 const std::string& stream_label = it->sync_label; |
| 803 const std::string& track_id = it->id; | 803 const std::string& track_id = it->id; |
| 804 uint32 ssrc = it->first_ssrc(); | 804 uint32_t ssrc = it->first_ssrc(); |
| 805 const TrackInfo* track_info = FindTrackInfo(*current_tracks, | 805 const TrackInfo* track_info = FindTrackInfo(*current_tracks, |
| 806 stream_label, | 806 stream_label, |
| 807 track_id); | 807 track_id); |
| 808 if (!track_info) { | 808 if (!track_info) { |
| 809 current_tracks->push_back(TrackInfo(stream_label, track_id, ssrc)); | 809 current_tracks->push_back(TrackInfo(stream_label, track_id, ssrc)); |
| 810 OnLocalTrackSeen(stream_label, track_id, it->first_ssrc(), media_type); | 810 OnLocalTrackSeen(stream_label, track_id, it->first_ssrc(), media_type); |
| 811 } | 811 } |
| 812 } | 812 } |
| 813 } | 813 } |
| 814 | 814 |
| 815 void MediaStreamSignaling::OnLocalTrackSeen(const std::string& stream_label, | 815 void MediaStreamSignaling::OnLocalTrackSeen(const std::string& stream_label, |
| 816 const std::string& track_id, | 816 const std::string& track_id, |
| 817 uint32 ssrc, | 817 uint32_t ssrc, |
| 818 cricket::MediaType media_type) { | 818 cricket::MediaType media_type) { |
| 819 MediaStreamInterface* stream = local_streams_->find(stream_label); | 819 MediaStreamInterface* stream = local_streams_->find(stream_label); |
| 820 if (!stream) { | 820 if (!stream) { |
| 821 LOG(LS_WARNING) << "An unknown local MediaStream with label " | 821 LOG(LS_WARNING) << "An unknown local MediaStream with label " |
| 822 << stream_label << " has been configured."; | 822 << stream_label << " has been configured."; |
| 823 return; | 823 return; |
| 824 } | 824 } |
| 825 | 825 |
| 826 if (media_type == cricket::MEDIA_TYPE_AUDIO) { | 826 if (media_type == cricket::MEDIA_TYPE_AUDIO) { |
| 827 AudioTrackInterface* audio_track = stream->FindAudioTrack(track_id); | 827 AudioTrackInterface* audio_track = stream->FindAudioTrack(track_id); |
| 828 if (!audio_track) { | 828 if (!audio_track) { |
| 829 LOG(LS_WARNING) << "An unknown local AudioTrack with id , " | 829 LOG(LS_WARNING) << "An unknown local AudioTrack with id , " |
| 830 << track_id << " has been configured."; | 830 << track_id << " has been configured."; |
| 831 return; | 831 return; |
| 832 } | 832 } |
| 833 stream_observer_->OnAddLocalAudioTrack(stream, audio_track, ssrc); | 833 stream_observer_->OnAddLocalAudioTrack(stream, audio_track, ssrc); |
| 834 } else if (media_type == cricket::MEDIA_TYPE_VIDEO) { | 834 } else if (media_type == cricket::MEDIA_TYPE_VIDEO) { |
| 835 VideoTrackInterface* video_track = stream->FindVideoTrack(track_id); | 835 VideoTrackInterface* video_track = stream->FindVideoTrack(track_id); |
| 836 if (!video_track) { | 836 if (!video_track) { |
| 837 LOG(LS_WARNING) << "An unknown local VideoTrack with id , " | 837 LOG(LS_WARNING) << "An unknown local VideoTrack with id , " |
| 838 << track_id << " has been configured."; | 838 << track_id << " has been configured."; |
| 839 return; | 839 return; |
| 840 } | 840 } |
| 841 stream_observer_->OnAddLocalVideoTrack(stream, video_track, ssrc); | 841 stream_observer_->OnAddLocalVideoTrack(stream, video_track, ssrc); |
| 842 } else { | 842 } else { |
| 843 ASSERT(false && "Invalid media type"); | 843 ASSERT(false && "Invalid media type"); |
| 844 } | 844 } |
| 845 } | 845 } |
| 846 | 846 |
| 847 void MediaStreamSignaling::OnLocalTrackRemoved( | 847 void MediaStreamSignaling::OnLocalTrackRemoved(const std::string& stream_label, |
| 848 const std::string& stream_label, | 848 const std::string& track_id, |
| 849 const std::string& track_id, | 849 uint32_t ssrc, |
| 850 uint32 ssrc, | 850 cricket::MediaType media_type) { |
| 851 cricket::MediaType media_type) { | |
| 852 MediaStreamInterface* stream = local_streams_->find(stream_label); | 851 MediaStreamInterface* stream = local_streams_->find(stream_label); |
| 853 if (!stream) { | 852 if (!stream) { |
| 854 // This is the normal case. Ie RemoveLocalStream has been called and the | 853 // This is the normal case. Ie RemoveLocalStream has been called and the |
| 855 // SessionDescriptions has been renegotiated. | 854 // SessionDescriptions has been renegotiated. |
| 856 return; | 855 return; |
| 857 } | 856 } |
| 858 // A track has been removed from the SessionDescription but the MediaStream | 857 // A track has been removed from the SessionDescription but the MediaStream |
| 859 // is still associated with MediaStreamSignaling. This only occurs if the SDP | 858 // is still associated with MediaStreamSignaling. This only occurs if the SDP |
| 860 // doesn't match with the calls to AddLocalStream and RemoveLocalStream. | 859 // doesn't match with the calls to AddLocalStream and RemoveLocalStream. |
| 861 | 860 |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 946 if (data_channel->state() == DataChannel::kClosed) { | 945 if (data_channel->state() == DataChannel::kClosed) { |
| 947 rtp_data_channels_.erase(it); | 946 rtp_data_channels_.erase(it); |
| 948 it = rtp_data_channels_.begin(); | 947 it = rtp_data_channels_.begin(); |
| 949 } else { | 948 } else { |
| 950 ++it; | 949 ++it; |
| 951 } | 950 } |
| 952 } | 951 } |
| 953 } | 952 } |
| 954 | 953 |
| 955 void MediaStreamSignaling::CreateRemoteDataChannel(const std::string& label, | 954 void MediaStreamSignaling::CreateRemoteDataChannel(const std::string& label, |
| 956 uint32 remote_ssrc) { | 955 uint32_t remote_ssrc) { |
| 957 if (!data_channel_factory_) { | 956 if (!data_channel_factory_) { |
| 958 LOG(LS_WARNING) << "Remote peer requested a DataChannel but DataChannels " | 957 LOG(LS_WARNING) << "Remote peer requested a DataChannel but DataChannels " |
| 959 << "are not supported."; | 958 << "are not supported."; |
| 960 return; | 959 return; |
| 961 } | 960 } |
| 962 scoped_refptr<DataChannel> channel( | 961 scoped_refptr<DataChannel> channel( |
| 963 data_channel_factory_->CreateDataChannel(label, NULL)); | 962 data_channel_factory_->CreateDataChannel(label, NULL)); |
| 964 if (!channel.get()) { | 963 if (!channel.get()) { |
| 965 LOG(LS_WARNING) << "Remote peer requested a DataChannel but" | 964 LOG(LS_WARNING) << "Remote peer requested a DataChannel but" |
| 966 << "CreateDataChannel failed."; | 965 << "CreateDataChannel failed."; |
| (...skipping 17 matching lines...) Expand all Loading... |
| 984 int sid; | 983 int sid; |
| 985 if (!AllocateSctpSid(role, &sid)) { | 984 if (!AllocateSctpSid(role, &sid)) { |
| 986 LOG(LS_ERROR) << "Failed to allocate SCTP sid."; | 985 LOG(LS_ERROR) << "Failed to allocate SCTP sid."; |
| 987 continue; | 986 continue; |
| 988 } | 987 } |
| 989 (*it)->SetSctpSid(sid); | 988 (*it)->SetSctpSid(sid); |
| 990 } | 989 } |
| 991 } | 990 } |
| 992 } | 991 } |
| 993 | 992 |
| 994 | 993 void MediaStreamSignaling::OnRemoteSctpDataChannelClosed(uint32_t sid) { |
| 995 void MediaStreamSignaling::OnRemoteSctpDataChannelClosed(uint32 sid) { | |
| 996 int index = FindDataChannelBySid(sid); | 994 int index = FindDataChannelBySid(sid); |
| 997 if (index < 0) { | 995 if (index < 0) { |
| 998 LOG(LS_WARNING) << "Unexpected sid " << sid | 996 LOG(LS_WARNING) << "Unexpected sid " << sid |
| 999 << " of the remotely closed DataChannel."; | 997 << " of the remotely closed DataChannel."; |
| 1000 return; | 998 return; |
| 1001 } | 999 } |
| 1002 sctp_data_channels_[index]->Close(); | 1000 sctp_data_channels_[index]->Close(); |
| 1003 } | 1001 } |
| 1004 | 1002 |
| 1005 const MediaStreamSignaling::TrackInfo* | 1003 const MediaStreamSignaling::TrackInfo* |
| (...skipping 13 matching lines...) Expand all Loading... |
| 1019 int MediaStreamSignaling::FindDataChannelBySid(int sid) const { | 1017 int MediaStreamSignaling::FindDataChannelBySid(int sid) const { |
| 1020 for (size_t i = 0; i < sctp_data_channels_.size(); ++i) { | 1018 for (size_t i = 0; i < sctp_data_channels_.size(); ++i) { |
| 1021 if (sctp_data_channels_[i]->id() == sid) { | 1019 if (sctp_data_channels_[i]->id() == sid) { |
| 1022 return static_cast<int>(i); | 1020 return static_cast<int>(i); |
| 1023 } | 1021 } |
| 1024 } | 1022 } |
| 1025 return -1; | 1023 return -1; |
| 1026 } | 1024 } |
| 1027 | 1025 |
| 1028 } // namespace webrtc | 1026 } // namespace webrtc |
| OLD | NEW |