Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3)

Side by Side Diff: talk/app/webrtc/mediastreamsignaling.cc

Issue 1362503003: Use suffixed {uint,int}{8,16,32,64}_t types. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: google::int32 Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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
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(), 810 OnLocalTrackSeen(stream_label, track_id, it->first_ssrc(),
811 media_type); 811 media_type);
812 } 812 }
813 } 813 }
814 } 814 }
815 815
816 void MediaStreamSignaling::OnLocalTrackSeen( 816 void MediaStreamSignaling::OnLocalTrackSeen(const std::string& stream_label,
817 const std::string& stream_label, 817 const std::string& track_id,
818 const std::string& track_id, 818 uint32_t ssrc,
819 uint32 ssrc, 819 cricket::MediaType media_type) {
820 cricket::MediaType media_type) {
821 MediaStreamInterface* stream = local_streams_->find(stream_label); 820 MediaStreamInterface* stream = local_streams_->find(stream_label);
822 if (!stream) { 821 if (!stream) {
823 LOG(LS_WARNING) << "An unknown local MediaStream with label " 822 LOG(LS_WARNING) << "An unknown local MediaStream with label "
824 << stream_label << " has been configured."; 823 << stream_label << " has been configured.";
825 return; 824 return;
826 } 825 }
827 826
828 if (media_type == cricket::MEDIA_TYPE_AUDIO) { 827 if (media_type == cricket::MEDIA_TYPE_AUDIO) {
829 AudioTrackInterface* audio_track = stream->FindAudioTrack(track_id); 828 AudioTrackInterface* audio_track = stream->FindAudioTrack(track_id);
830 if (!audio_track) { 829 if (!audio_track) {
831 LOG(LS_WARNING) << "An unknown local AudioTrack with id , " 830 LOG(LS_WARNING) << "An unknown local AudioTrack with id , "
832 << track_id << " has been configured."; 831 << track_id << " has been configured.";
833 return; 832 return;
834 } 833 }
835 stream_observer_->OnAddLocalAudioTrack(stream, audio_track, ssrc); 834 stream_observer_->OnAddLocalAudioTrack(stream, audio_track, ssrc);
836 } else if (media_type == cricket::MEDIA_TYPE_VIDEO) { 835 } else if (media_type == cricket::MEDIA_TYPE_VIDEO) {
837 VideoTrackInterface* video_track = stream->FindVideoTrack(track_id); 836 VideoTrackInterface* video_track = stream->FindVideoTrack(track_id);
838 if (!video_track) { 837 if (!video_track) {
839 LOG(LS_WARNING) << "An unknown local VideoTrack with id , " 838 LOG(LS_WARNING) << "An unknown local VideoTrack with id , "
840 << track_id << " has been configured."; 839 << track_id << " has been configured.";
841 return; 840 return;
842 } 841 }
843 stream_observer_->OnAddLocalVideoTrack(stream, video_track, ssrc); 842 stream_observer_->OnAddLocalVideoTrack(stream, video_track, ssrc);
844 } else { 843 } else {
845 ASSERT(false && "Invalid media type"); 844 ASSERT(false && "Invalid media type");
846 } 845 }
847 } 846 }
848 847
849 void MediaStreamSignaling::OnLocalTrackRemoved( 848 void MediaStreamSignaling::OnLocalTrackRemoved(const std::string& stream_label,
850 const std::string& stream_label, 849 const std::string& track_id,
851 const std::string& track_id, 850 uint32_t ssrc,
852 uint32 ssrc, 851 cricket::MediaType media_type) {
853 cricket::MediaType media_type) {
854 MediaStreamInterface* stream = local_streams_->find(stream_label); 852 MediaStreamInterface* stream = local_streams_->find(stream_label);
855 if (!stream) { 853 if (!stream) {
856 // This is the normal case. Ie RemoveLocalStream has been called and the 854 // This is the normal case. Ie RemoveLocalStream has been called and the
857 // SessionDescriptions has been renegotiated. 855 // SessionDescriptions has been renegotiated.
858 return; 856 return;
859 } 857 }
860 // A track has been removed from the SessionDescription but the MediaStream 858 // A track has been removed from the SessionDescription but the MediaStream
861 // is still associated with MediaStreamSignaling. This only occurs if the SDP 859 // is still associated with MediaStreamSignaling. This only occurs if the SDP
862 // doesn't match with the calls to AddLocalStream and RemoveLocalStream. 860 // doesn't match with the calls to AddLocalStream and RemoveLocalStream.
863 861
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
948 if (data_channel->state() == DataChannel::kClosed) { 946 if (data_channel->state() == DataChannel::kClosed) {
949 rtp_data_channels_.erase(it); 947 rtp_data_channels_.erase(it);
950 it = rtp_data_channels_.begin(); 948 it = rtp_data_channels_.begin();
951 } else { 949 } else {
952 ++it; 950 ++it;
953 } 951 }
954 } 952 }
955 } 953 }
956 954
957 void MediaStreamSignaling::CreateRemoteDataChannel(const std::string& label, 955 void MediaStreamSignaling::CreateRemoteDataChannel(const std::string& label,
958 uint32 remote_ssrc) { 956 uint32_t remote_ssrc) {
959 if (!data_channel_factory_) { 957 if (!data_channel_factory_) {
960 LOG(LS_WARNING) << "Remote peer requested a DataChannel but DataChannels " 958 LOG(LS_WARNING) << "Remote peer requested a DataChannel but DataChannels "
961 << "are not supported."; 959 << "are not supported.";
962 return; 960 return;
963 } 961 }
964 scoped_refptr<DataChannel> channel( 962 scoped_refptr<DataChannel> channel(
965 data_channel_factory_->CreateDataChannel(label, NULL)); 963 data_channel_factory_->CreateDataChannel(label, NULL));
966 if (!channel.get()) { 964 if (!channel.get()) {
967 LOG(LS_WARNING) << "Remote peer requested a DataChannel but" 965 LOG(LS_WARNING) << "Remote peer requested a DataChannel but"
968 << "CreateDataChannel failed."; 966 << "CreateDataChannel failed.";
(...skipping 17 matching lines...) Expand all
986 int sid; 984 int sid;
987 if (!AllocateSctpSid(role, &sid)) { 985 if (!AllocateSctpSid(role, &sid)) {
988 LOG(LS_ERROR) << "Failed to allocate SCTP sid."; 986 LOG(LS_ERROR) << "Failed to allocate SCTP sid.";
989 continue; 987 continue;
990 } 988 }
991 (*it)->SetSctpSid(sid); 989 (*it)->SetSctpSid(sid);
992 } 990 }
993 } 991 }
994 } 992 }
995 993
996 994 void MediaStreamSignaling::OnRemoteSctpDataChannelClosed(uint32_t sid) {
997 void MediaStreamSignaling::OnRemoteSctpDataChannelClosed(uint32 sid) {
998 int index = FindDataChannelBySid(sid); 995 int index = FindDataChannelBySid(sid);
999 if (index < 0) { 996 if (index < 0) {
1000 LOG(LS_WARNING) << "Unexpected sid " << sid 997 LOG(LS_WARNING) << "Unexpected sid " << sid
1001 << " of the remotely closed DataChannel."; 998 << " of the remotely closed DataChannel.";
1002 return; 999 return;
1003 } 1000 }
1004 sctp_data_channels_[index]->Close(); 1001 sctp_data_channels_[index]->Close();
1005 } 1002 }
1006 1003
1007 const MediaStreamSignaling::TrackInfo* 1004 const MediaStreamSignaling::TrackInfo*
(...skipping 13 matching lines...) Expand all
1021 int MediaStreamSignaling::FindDataChannelBySid(int sid) const { 1018 int MediaStreamSignaling::FindDataChannelBySid(int sid) const {
1022 for (size_t i = 0; i < sctp_data_channels_.size(); ++i) { 1019 for (size_t i = 0; i < sctp_data_channels_.size(); ++i) {
1023 if (sctp_data_channels_[i]->id() == sid) { 1020 if (sctp_data_channels_[i]->id() == sid) {
1024 return static_cast<int>(i); 1021 return static_cast<int>(i);
1025 } 1022 }
1026 } 1023 }
1027 return -1; 1024 return -1;
1028 } 1025 }
1029 1026
1030 } // namespace webrtc 1027 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698