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 508 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 519 MaybeCreateDefaultStream(); | 519 MaybeCreateDefaultStream(); |
| 520 } | 520 } |
| 521 | 521 |
| 522 void MediaStreamSignaling::OnLocalDescriptionChanged( | 522 void MediaStreamSignaling::OnLocalDescriptionChanged( |
| 523 const SessionDescriptionInterface* desc) { | 523 const SessionDescriptionInterface* desc) { |
| 524 const cricket::ContentInfo* audio_content = | 524 const cricket::ContentInfo* audio_content = |
| 525 GetFirstAudioContent(desc->description()); | 525 GetFirstAudioContent(desc->description()); |
| 526 if (audio_content) { | 526 if (audio_content) { |
| 527 if (audio_content->rejected) { | 527 if (audio_content->rejected) { |
| 528 RejectRemoteTracks(cricket::MEDIA_TYPE_AUDIO); | 528 RejectRemoteTracks(cricket::MEDIA_TYPE_AUDIO); |
| 529 } else { | |
| 530 AcceptRemoteTracks(cricket::MEDIA_TYPE_AUDIO); | |
| 529 } | 531 } |
| 530 const cricket::AudioContentDescription* audio_desc = | 532 const cricket::AudioContentDescription* audio_desc = |
| 531 static_cast<const cricket::AudioContentDescription*>( | 533 static_cast<const cricket::AudioContentDescription*>( |
| 532 audio_content->description); | 534 audio_content->description); |
| 533 UpdateLocalTracks(audio_desc->streams(), audio_desc->type()); | 535 UpdateLocalTracks(audio_desc->streams(), audio_desc->type()); |
| 534 } | 536 } |
| 535 | 537 |
| 536 const cricket::ContentInfo* video_content = | 538 const cricket::ContentInfo* video_content = |
| 537 GetFirstVideoContent(desc->description()); | 539 GetFirstVideoContent(desc->description()); |
| 538 if (video_content) { | 540 if (video_content) { |
| 539 if (video_content->rejected) { | 541 if (video_content->rejected) { |
| 540 RejectRemoteTracks(cricket::MEDIA_TYPE_VIDEO); | 542 RejectRemoteTracks(cricket::MEDIA_TYPE_VIDEO); |
| 543 } else { | |
| 544 AcceptRemoteTracks(cricket::MEDIA_TYPE_VIDEO); | |
| 541 } | 545 } |
| 542 const cricket::VideoContentDescription* video_desc = | 546 const cricket::VideoContentDescription* video_desc = |
| 543 static_cast<const cricket::VideoContentDescription*>( | 547 static_cast<const cricket::VideoContentDescription*>( |
| 544 video_content->description); | 548 video_content->description); |
| 545 UpdateLocalTracks(video_desc->streams(), video_desc->type()); | 549 UpdateLocalTracks(video_desc->streams(), video_desc->type()); |
| 546 } | 550 } |
| 547 | 551 |
| 548 const cricket::ContentInfo* data_content = | 552 const cricket::ContentInfo* data_content = |
| 549 GetFirstDataContent(desc->description()); | 553 GetFirstDataContent(desc->description()); |
| 550 if (data_content) { | 554 if (data_content) { |
| (...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 696 VideoTrackInterface* track = stream->FindVideoTrack(info.track_id); | 700 VideoTrackInterface* track = stream->FindVideoTrack(info.track_id); |
| 697 // There's no guarantee the track is still available, e.g. the track may | 701 // There's no guarantee the track is still available, e.g. the track may |
| 698 // have been removed from the stream by javascript. | 702 // have been removed from the stream by javascript. |
| 699 if (track) { | 703 if (track) { |
| 700 track->set_state(webrtc::MediaStreamTrackInterface::kEnded); | 704 track->set_state(webrtc::MediaStreamTrackInterface::kEnded); |
| 701 } | 705 } |
| 702 } | 706 } |
| 703 } | 707 } |
| 704 } | 708 } |
| 705 | 709 |
| 710 void MediaStreamSignaling::AcceptRemoteTracks(cricket::MediaType media_type) { | |
|
pthatcher1
2015/07/08 20:45:32
Can you avoid duplication by making a helper metho
Taylor Brandstetter
2015/07/08 23:04:03
Sure, that should be fine as long as accepting/rej
| |
| 711 TrackInfos* current_tracks = GetRemoteTracks(media_type); | |
| 712 for (TrackInfos::iterator track_it = current_tracks->begin(); | |
| 713 track_it != current_tracks->end(); ++track_it) { | |
| 714 const TrackInfo& info = *track_it; | |
| 715 MediaStreamInterface* stream = remote_streams_->find(info.stream_label); | |
| 716 if (media_type == cricket::MEDIA_TYPE_AUDIO) { | |
| 717 AudioTrackInterface* track = stream->FindAudioTrack(info.track_id); | |
| 718 if (track) { | |
| 719 track->set_state(webrtc::MediaStreamTrackInterface::kLive); | |
| 720 } | |
| 721 } | |
| 722 if (media_type == cricket::MEDIA_TYPE_VIDEO) { | |
| 723 VideoTrackInterface* track = stream->FindVideoTrack(info.track_id); | |
| 724 if (track) { | |
| 725 track->set_state(webrtc::MediaStreamTrackInterface::kLive); | |
| 726 } | |
| 727 } | |
| 728 } | |
| 729 } | |
| 730 | |
| 706 void MediaStreamSignaling::UpdateEndedRemoteMediaStreams() { | 731 void MediaStreamSignaling::UpdateEndedRemoteMediaStreams() { |
| 707 std::vector<scoped_refptr<MediaStreamInterface> > streams_to_remove; | 732 std::vector<scoped_refptr<MediaStreamInterface> > streams_to_remove; |
| 708 for (size_t i = 0; i < remote_streams_->count(); ++i) { | 733 for (size_t i = 0; i < remote_streams_->count(); ++i) { |
| 709 MediaStreamInterface*stream = remote_streams_->at(i); | 734 MediaStreamInterface*stream = remote_streams_->at(i); |
| 710 if (stream->GetAudioTracks().empty() && stream->GetVideoTracks().empty()) { | 735 if (stream->GetAudioTracks().empty() && stream->GetVideoTracks().empty()) { |
| 711 streams_to_remove.push_back(stream); | 736 streams_to_remove.push_back(stream); |
| 712 } | 737 } |
| 713 } | 738 } |
| 714 | 739 |
| 715 std::vector<scoped_refptr<MediaStreamInterface> >::const_iterator it; | 740 std::vector<scoped_refptr<MediaStreamInterface> >::const_iterator it; |
| (...skipping 305 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1021 int MediaStreamSignaling::FindDataChannelBySid(int sid) const { | 1046 int MediaStreamSignaling::FindDataChannelBySid(int sid) const { |
| 1022 for (size_t i = 0; i < sctp_data_channels_.size(); ++i) { | 1047 for (size_t i = 0; i < sctp_data_channels_.size(); ++i) { |
| 1023 if (sctp_data_channels_[i]->id() == sid) { | 1048 if (sctp_data_channels_[i]->id() == sid) { |
| 1024 return static_cast<int>(i); | 1049 return static_cast<int>(i); |
| 1025 } | 1050 } |
| 1026 } | 1051 } |
| 1027 return -1; | 1052 return -1; |
| 1028 } | 1053 } |
| 1029 | 1054 |
| 1030 } // namespace webrtc | 1055 } // namespace webrtc |
| OLD | NEW |