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 330 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
341 << " is already added."; | 341 << " is already added."; |
342 return false; | 342 return false; |
343 } | 343 } |
344 return true; | 344 return true; |
345 } | 345 } |
346 | 346 |
347 bool MediaContentDirectionHasSend(cricket::MediaContentDirection dir) { | 347 bool MediaContentDirectionHasSend(cricket::MediaContentDirection dir) { |
348 return dir == cricket::MD_SENDONLY || dir == cricket::MD_SENDRECV; | 348 return dir == cricket::MD_SENDONLY || dir == cricket::MD_SENDRECV; |
349 } | 349 } |
350 | 350 |
| 351 // If the direction is "recvonly" or "inactive", treat the description |
| 352 // as containing no streams. |
| 353 // See: https://code.google.com/p/webrtc/issues/detail?id=5054 |
| 354 std::vector<cricket::StreamParams> GetActiveStreams( |
| 355 const cricket::MediaContentDescription* desc) { |
| 356 return MediaContentDirectionHasSend(desc->direction()) |
| 357 ? desc->streams() |
| 358 : std::vector<cricket::StreamParams>(); |
| 359 } |
| 360 |
351 bool IsValidOfferToReceiveMedia(int value) { | 361 bool IsValidOfferToReceiveMedia(int value) { |
352 typedef PeerConnectionInterface::RTCOfferAnswerOptions Options; | 362 typedef PeerConnectionInterface::RTCOfferAnswerOptions Options; |
353 return (value >= Options::kUndefined) && | 363 return (value >= Options::kUndefined) && |
354 (value <= Options::kMaxOfferToReceiveMedia); | 364 (value <= Options::kMaxOfferToReceiveMedia); |
355 } | 365 } |
356 | 366 |
357 // Add the stream and RTP data channel info to |session_options|. | 367 // Add the stream and RTP data channel info to |session_options|. |
358 void SetStreams(cricket::MediaSessionOptions* session_options, | 368 void SetStreams(cricket::MediaSessionOptions* session_options, |
359 rtc::scoped_refptr<StreamCollection> streams, | 369 rtc::scoped_refptr<StreamCollection> streams, |
360 const std::map<std::string, rtc::scoped_refptr<DataChannel>>& | 370 const std::map<std::string, rtc::scoped_refptr<DataChannel>>& |
(...skipping 661 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1022 // since only at that point will new streams have all their tracks. | 1032 // since only at that point will new streams have all their tracks. |
1023 rtc::scoped_refptr<StreamCollection> new_streams(StreamCollection::Create()); | 1033 rtc::scoped_refptr<StreamCollection> new_streams(StreamCollection::Create()); |
1024 | 1034 |
1025 // Find all audio rtp streams and create corresponding remote AudioTracks | 1035 // Find all audio rtp streams and create corresponding remote AudioTracks |
1026 // and MediaStreams. | 1036 // and MediaStreams. |
1027 const cricket::ContentInfo* audio_content = GetFirstAudioContent(remote_desc); | 1037 const cricket::ContentInfo* audio_content = GetFirstAudioContent(remote_desc); |
1028 if (audio_content) { | 1038 if (audio_content) { |
1029 const cricket::AudioContentDescription* desc = | 1039 const cricket::AudioContentDescription* desc = |
1030 static_cast<const cricket::AudioContentDescription*>( | 1040 static_cast<const cricket::AudioContentDescription*>( |
1031 audio_content->description); | 1041 audio_content->description); |
1032 UpdateRemoteStreamsList(desc->streams(), desc->type(), new_streams); | 1042 UpdateRemoteStreamsList(GetActiveStreams(desc), desc->type(), new_streams); |
1033 remote_info_.default_audio_track_needed = | 1043 remote_info_.default_audio_track_needed = |
1034 MediaContentDirectionHasSend(desc->direction()) && | 1044 MediaContentDirectionHasSend(desc->direction()) && |
1035 desc->streams().empty(); | 1045 desc->streams().empty(); |
1036 } | 1046 } |
1037 | 1047 |
1038 // Find all video rtp streams and create corresponding remote VideoTracks | 1048 // Find all video rtp streams and create corresponding remote VideoTracks |
1039 // and MediaStreams. | 1049 // and MediaStreams. |
1040 const cricket::ContentInfo* video_content = GetFirstVideoContent(remote_desc); | 1050 const cricket::ContentInfo* video_content = GetFirstVideoContent(remote_desc); |
1041 if (video_content) { | 1051 if (video_content) { |
1042 const cricket::VideoContentDescription* desc = | 1052 const cricket::VideoContentDescription* desc = |
1043 static_cast<const cricket::VideoContentDescription*>( | 1053 static_cast<const cricket::VideoContentDescription*>( |
1044 video_content->description); | 1054 video_content->description); |
1045 UpdateRemoteStreamsList(desc->streams(), desc->type(), new_streams); | 1055 UpdateRemoteStreamsList(GetActiveStreams(desc), desc->type(), new_streams); |
1046 remote_info_.default_video_track_needed = | 1056 remote_info_.default_video_track_needed = |
1047 MediaContentDirectionHasSend(desc->direction()) && | 1057 MediaContentDirectionHasSend(desc->direction()) && |
1048 desc->streams().empty(); | 1058 desc->streams().empty(); |
1049 } | 1059 } |
1050 | 1060 |
1051 // Update the DataChannels with the information from the remote peer. | 1061 // Update the DataChannels with the information from the remote peer. |
1052 const cricket::ContentInfo* data_content = GetFirstDataContent(remote_desc); | 1062 const cricket::ContentInfo* data_content = GetFirstDataContent(remote_desc); |
1053 if (data_content) { | 1063 if (data_content) { |
1054 const cricket::DataContentDescription* data_desc = | 1064 const cricket::DataContentDescription* desc = |
1055 static_cast<const cricket::DataContentDescription*>( | 1065 static_cast<const cricket::DataContentDescription*>( |
1056 data_content->description); | 1066 data_content->description); |
1057 if (rtc::starts_with(data_desc->protocol().data(), | 1067 if (rtc::starts_with(desc->protocol().data(), |
1058 cricket::kMediaProtocolRtpPrefix)) { | 1068 cricket::kMediaProtocolRtpPrefix)) { |
1059 UpdateRemoteRtpDataChannels(data_desc->streams()); | 1069 UpdateRemoteRtpDataChannels(GetActiveStreams(desc)); |
1060 } | 1070 } |
1061 } | 1071 } |
1062 | 1072 |
1063 // Iterate new_streams and notify the observer about new MediaStreams. | 1073 // Iterate new_streams and notify the observer about new MediaStreams. |
1064 for (size_t i = 0; i < new_streams->count(); ++i) { | 1074 for (size_t i = 0; i < new_streams->count(); ++i) { |
1065 MediaStreamInterface* new_stream = new_streams->at(i); | 1075 MediaStreamInterface* new_stream = new_streams->at(i); |
1066 stats_->AddStream(new_stream); | 1076 stats_->AddStream(new_stream); |
1067 observer_->OnAddStream(new_stream); | 1077 observer_->OnAddStream(new_stream); |
1068 } | 1078 } |
1069 | 1079 |
(...skipping 879 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1949 DataChannel* PeerConnection::FindDataChannelBySid(int sid) const { | 1959 DataChannel* PeerConnection::FindDataChannelBySid(int sid) const { |
1950 for (const auto& channel : sctp_data_channels_) { | 1960 for (const auto& channel : sctp_data_channels_) { |
1951 if (channel->id() == sid) { | 1961 if (channel->id() == sid) { |
1952 return channel; | 1962 return channel; |
1953 } | 1963 } |
1954 } | 1964 } |
1955 return nullptr; | 1965 return nullptr; |
1956 } | 1966 } |
1957 | 1967 |
1958 } // namespace webrtc | 1968 } // namespace webrtc |
OLD | NEW |