Chromium Code Reviews| 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 931 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 942 if (session_->data_channel_type() == cricket::DCT_SCTP && | 942 if (session_->data_channel_type() == cricket::DCT_SCTP && |
| 943 session_->GetSslRole(&role)) { | 943 session_->GetSslRole(&role)) { |
| 944 AllocateSctpSids(role); | 944 AllocateSctpSids(role); |
| 945 } | 945 } |
| 946 | 946 |
| 947 // Update state and SSRC of local MediaStreams and DataChannels based on the | 947 // Update state and SSRC of local MediaStreams and DataChannels based on the |
| 948 // local session description. | 948 // local session description. |
| 949 const cricket::ContentInfo* audio_content = | 949 const cricket::ContentInfo* audio_content = |
| 950 GetFirstAudioContent(desc->description()); | 950 GetFirstAudioContent(desc->description()); |
| 951 if (audio_content) { | 951 if (audio_content) { |
| 952 if (audio_content->rejected) { | |
| 953 audio_rejected_ = true; | |
| 954 } else if (audio_rejected_) { | |
|
pthatcher1
2015/11/11 00:45:02
Can we get the equivalent of audio_rejected_ by lo
Taylor Brandstetter
2015/11/11 01:33:29
It gets more complex if we go that route. We have
| |
| 955 // If going from rejected to unrejected, need to reconfigure senders and | |
| 956 // receivers. | |
| 957 audio_rejected_ = false; | |
| 958 ReconfigureSenders(cricket::MEDIA_TYPE_AUDIO); | |
| 959 ReconfigureReceivers(cricket::MEDIA_TYPE_AUDIO); | |
|
pthatcher1
2015/11/11 00:45:02
Should we have a ReconfigureSenderAndReceivers met
Taylor Brandstetter
2015/11/11 01:33:29
Done.
| |
| 960 } | |
| 952 const cricket::AudioContentDescription* audio_desc = | 961 const cricket::AudioContentDescription* audio_desc = |
| 953 static_cast<const cricket::AudioContentDescription*>( | 962 static_cast<const cricket::AudioContentDescription*>( |
| 954 audio_content->description); | 963 audio_content->description); |
| 955 UpdateLocalTracks(audio_desc->streams(), audio_desc->type()); | 964 UpdateLocalTracks(audio_desc->streams(), audio_desc->type()); |
| 956 } | 965 } |
| 957 | 966 |
| 958 const cricket::ContentInfo* video_content = | 967 const cricket::ContentInfo* video_content = |
| 959 GetFirstVideoContent(desc->description()); | 968 GetFirstVideoContent(desc->description()); |
| 960 if (video_content) { | 969 if (video_content) { |
| 970 if (video_content->rejected) { | |
| 971 video_rejected_ = true; | |
| 972 } else if (video_rejected_) { | |
| 973 // If going from rejected to unrejected, need to reconfigure senders and | |
| 974 // receivers. | |
| 975 video_rejected_ = false; | |
| 976 ReconfigureSenders(cricket::MEDIA_TYPE_VIDEO); | |
| 977 ReconfigureReceivers(cricket::MEDIA_TYPE_VIDEO); | |
| 978 } | |
| 961 const cricket::VideoContentDescription* video_desc = | 979 const cricket::VideoContentDescription* video_desc = |
| 962 static_cast<const cricket::VideoContentDescription*>( | 980 static_cast<const cricket::VideoContentDescription*>( |
| 963 video_content->description); | 981 video_content->description); |
| 964 UpdateLocalTracks(video_desc->streams(), video_desc->type()); | 982 UpdateLocalTracks(video_desc->streams(), video_desc->type()); |
| 965 } | 983 } |
| 966 | 984 |
| 967 const cricket::ContentInfo* data_content = | 985 const cricket::ContentInfo* data_content = |
| 968 GetFirstDataContent(desc->description()); | 986 GetFirstDataContent(desc->description()); |
| 969 if (data_content) { | 987 if (data_content) { |
| 970 const cricket::DataContentDescription* data_desc = | 988 const cricket::DataContentDescription* data_desc = |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1016 const cricket::SessionDescription* remote_desc = desc->description(); | 1034 const cricket::SessionDescription* remote_desc = desc->description(); |
| 1017 | 1035 |
| 1018 // We wait to signal new streams until we finish processing the description, | 1036 // We wait to signal new streams until we finish processing the description, |
| 1019 // since only at that point will new streams have all their tracks. | 1037 // since only at that point will new streams have all their tracks. |
| 1020 rtc::scoped_refptr<StreamCollection> new_streams(StreamCollection::Create()); | 1038 rtc::scoped_refptr<StreamCollection> new_streams(StreamCollection::Create()); |
| 1021 | 1039 |
| 1022 // Find all audio rtp streams and create corresponding remote AudioTracks | 1040 // Find all audio rtp streams and create corresponding remote AudioTracks |
| 1023 // and MediaStreams. | 1041 // and MediaStreams. |
| 1024 const cricket::ContentInfo* audio_content = GetFirstAudioContent(remote_desc); | 1042 const cricket::ContentInfo* audio_content = GetFirstAudioContent(remote_desc); |
| 1025 if (audio_content) { | 1043 if (audio_content) { |
| 1044 if (audio_content->rejected) { | |
| 1045 audio_rejected_ = true; | |
| 1046 } else if (audio_rejected_) { | |
| 1047 // If going from rejected to unrejected, need to reconfigure senders and | |
| 1048 // receivers. | |
| 1049 audio_rejected_ = false; | |
| 1050 ReconfigureSenders(cricket::MEDIA_TYPE_AUDIO); | |
| 1051 ReconfigureReceivers(cricket::MEDIA_TYPE_AUDIO); | |
| 1052 } | |
| 1026 const cricket::AudioContentDescription* desc = | 1053 const cricket::AudioContentDescription* desc = |
| 1027 static_cast<const cricket::AudioContentDescription*>( | 1054 static_cast<const cricket::AudioContentDescription*>( |
| 1028 audio_content->description); | 1055 audio_content->description); |
| 1029 UpdateRemoteStreamsList(GetActiveStreams(desc), desc->type(), new_streams); | 1056 UpdateRemoteStreamsList(GetActiveStreams(desc), desc->type(), new_streams); |
| 1030 remote_info_.default_audio_track_needed = | 1057 remote_info_.default_audio_track_needed = |
| 1031 !remote_desc->msid_supported() && desc->streams().empty() && | 1058 !remote_desc->msid_supported() && desc->streams().empty() && |
| 1032 MediaContentDirectionHasSend(desc->direction()); | 1059 MediaContentDirectionHasSend(desc->direction()); |
| 1033 } | 1060 } |
| 1034 | 1061 |
| 1035 // Find all video rtp streams and create corresponding remote VideoTracks | 1062 // Find all video rtp streams and create corresponding remote VideoTracks |
| 1036 // and MediaStreams. | 1063 // and MediaStreams. |
| 1037 const cricket::ContentInfo* video_content = GetFirstVideoContent(remote_desc); | 1064 const cricket::ContentInfo* video_content = GetFirstVideoContent(remote_desc); |
| 1038 if (video_content) { | 1065 if (video_content) { |
| 1066 if (video_content->rejected) { | |
| 1067 video_rejected_ = true; | |
| 1068 } else if (video_rejected_) { | |
| 1069 // If going from rejected to unrejected, need to reconfigure senders and | |
| 1070 // receivers. | |
| 1071 video_rejected_ = false; | |
| 1072 ReconfigureSenders(cricket::MEDIA_TYPE_VIDEO); | |
| 1073 ReconfigureReceivers(cricket::MEDIA_TYPE_VIDEO); | |
| 1074 } | |
| 1039 const cricket::VideoContentDescription* desc = | 1075 const cricket::VideoContentDescription* desc = |
| 1040 static_cast<const cricket::VideoContentDescription*>( | 1076 static_cast<const cricket::VideoContentDescription*>( |
| 1041 video_content->description); | 1077 video_content->description); |
| 1042 UpdateRemoteStreamsList(GetActiveStreams(desc), desc->type(), new_streams); | 1078 UpdateRemoteStreamsList(GetActiveStreams(desc), desc->type(), new_streams); |
| 1043 remote_info_.default_video_track_needed = | 1079 remote_info_.default_video_track_needed = |
| 1044 !remote_desc->msid_supported() && desc->streams().empty() && | 1080 !remote_desc->msid_supported() && desc->streams().empty() && |
| 1045 MediaContentDirectionHasSend(desc->direction()); | 1081 MediaContentDirectionHasSend(desc->direction()); |
| 1046 } | 1082 } |
| 1047 | 1083 |
| 1048 // Update the DataChannels with the information from the remote peer. | 1084 // Update the DataChannels with the information from the remote peer. |
| (...skipping 878 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1927 | 1963 |
| 1928 std::vector<rtc::scoped_refptr<RtpReceiverInterface>>::iterator | 1964 std::vector<rtc::scoped_refptr<RtpReceiverInterface>>::iterator |
| 1929 PeerConnection::FindReceiverForTrack(MediaStreamTrackInterface* track) { | 1965 PeerConnection::FindReceiverForTrack(MediaStreamTrackInterface* track) { |
| 1930 return std::find_if( | 1966 return std::find_if( |
| 1931 receivers_.begin(), receivers_.end(), | 1967 receivers_.begin(), receivers_.end(), |
| 1932 [track](const rtc::scoped_refptr<RtpReceiverInterface>& receiver) { | 1968 [track](const rtc::scoped_refptr<RtpReceiverInterface>& receiver) { |
| 1933 return receiver->track() == track; | 1969 return receiver->track() == track; |
| 1934 }); | 1970 }); |
| 1935 } | 1971 } |
| 1936 | 1972 |
| 1973 void PeerConnection::ReconfigureSenders(cricket::MediaType media_type) { | |
| 1974 for (const auto& sender : senders_) { | |
| 1975 if (sender->media_type() == media_type) { | |
| 1976 sender->Reconfigure(); | |
| 1977 } | |
| 1978 } | |
| 1979 } | |
| 1980 | |
| 1981 void PeerConnection::ReconfigureReceivers(cricket::MediaType media_type) { | |
| 1982 for (const auto& receiver : receivers_) { | |
| 1983 if (receiver->media_type() == media_type) { | |
| 1984 receiver->Reconfigure(); | |
| 1985 } | |
| 1986 } | |
| 1987 } | |
| 1988 | |
| 1937 PeerConnection::TrackInfos* PeerConnection::GetRemoteTracks( | 1989 PeerConnection::TrackInfos* PeerConnection::GetRemoteTracks( |
| 1938 cricket::MediaType media_type) { | 1990 cricket::MediaType media_type) { |
| 1939 RTC_DCHECK(media_type == cricket::MEDIA_TYPE_AUDIO || | 1991 RTC_DCHECK(media_type == cricket::MEDIA_TYPE_AUDIO || |
| 1940 media_type == cricket::MEDIA_TYPE_VIDEO); | 1992 media_type == cricket::MEDIA_TYPE_VIDEO); |
| 1941 return (media_type == cricket::MEDIA_TYPE_AUDIO) ? &remote_audio_tracks_ | 1993 return (media_type == cricket::MEDIA_TYPE_AUDIO) ? &remote_audio_tracks_ |
| 1942 : &remote_video_tracks_; | 1994 : &remote_video_tracks_; |
| 1943 } | 1995 } |
| 1944 | 1996 |
| 1945 PeerConnection::TrackInfos* PeerConnection::GetLocalTracks( | 1997 PeerConnection::TrackInfos* PeerConnection::GetLocalTracks( |
| 1946 cricket::MediaType media_type) { | 1998 cricket::MediaType media_type) { |
| (...skipping 19 matching lines...) Expand all Loading... | |
| 1966 DataChannel* PeerConnection::FindDataChannelBySid(int sid) const { | 2018 DataChannel* PeerConnection::FindDataChannelBySid(int sid) const { |
| 1967 for (const auto& channel : sctp_data_channels_) { | 2019 for (const auto& channel : sctp_data_channels_) { |
| 1968 if (channel->id() == sid) { | 2020 if (channel->id() == sid) { |
| 1969 return channel; | 2021 return channel; |
| 1970 } | 2022 } |
| 1971 } | 2023 } |
| 1972 return nullptr; | 2024 return nullptr; |
| 1973 } | 2025 } |
| 1974 | 2026 |
| 1975 } // namespace webrtc | 2027 } // namespace webrtc |
| OLD | NEW |