OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2011 The WebRTC project authors. All Rights Reserved. | 2 * Copyright 2011 The WebRTC project authors. All Rights Reserved. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
9 */ | 9 */ |
10 | 10 |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
50 } | 50 } |
51 | 51 |
52 bool MediaStream::RemoveTrack(VideoTrackInterface* track) { | 52 bool MediaStream::RemoveTrack(VideoTrackInterface* track) { |
53 return RemoveTrack<VideoTrackVector>(&video_tracks_, track); | 53 return RemoveTrack<VideoTrackVector>(&video_tracks_, track); |
54 } | 54 } |
55 | 55 |
56 rtc::scoped_refptr<AudioTrackInterface> | 56 rtc::scoped_refptr<AudioTrackInterface> |
57 MediaStream::FindAudioTrack(const std::string& track_id) { | 57 MediaStream::FindAudioTrack(const std::string& track_id) { |
58 AudioTrackVector::iterator it = FindTrack(&audio_tracks_, track_id); | 58 AudioTrackVector::iterator it = FindTrack(&audio_tracks_, track_id); |
59 if (it == audio_tracks_.end()) | 59 if (it == audio_tracks_.end()) |
60 return NULL; | 60 return nullptr; |
61 return *it; | 61 return *it; |
62 } | 62 } |
63 | 63 |
64 rtc::scoped_refptr<VideoTrackInterface> | 64 rtc::scoped_refptr<VideoTrackInterface> |
65 MediaStream::FindVideoTrack(const std::string& track_id) { | 65 MediaStream::FindVideoTrack(const std::string& track_id) { |
66 VideoTrackVector::iterator it = FindTrack(&video_tracks_, track_id); | 66 VideoTrackVector::iterator it = FindTrack(&video_tracks_, track_id); |
67 if (it == video_tracks_.end()) | 67 if (it == video_tracks_.end()) |
68 return NULL; | 68 return nullptr; |
69 return *it; | 69 return *it; |
70 } | 70 } |
71 | 71 |
72 template <typename TrackVector, typename Track> | 72 template <typename TrackVector, typename Track> |
73 bool MediaStream::AddTrack(TrackVector* tracks, Track* track) { | 73 bool MediaStream::AddTrack(TrackVector* tracks, Track* track) { |
74 typename TrackVector::iterator it = FindTrack(tracks, track->id()); | 74 typename TrackVector::iterator it = FindTrack(tracks, track->id()); |
75 if (it != tracks->end()) | 75 if (it != tracks->end()) |
76 return false; | 76 return false; |
77 tracks->push_back(track); | 77 tracks->push_back(track); |
78 FireOnChanged(); | 78 FireOnChanged(); |
79 return true; | 79 return true; |
80 } | 80 } |
81 | 81 |
82 template <typename TrackVector> | 82 template <typename TrackVector> |
83 bool MediaStream::RemoveTrack(TrackVector* tracks, | 83 bool MediaStream::RemoveTrack(TrackVector* tracks, |
84 MediaStreamTrackInterface* track) { | 84 MediaStreamTrackInterface* track) { |
85 RTC_DCHECK(tracks != NULL); | 85 RTC_DCHECK(tracks != nullptr); |
86 if (!track) | 86 if (!track) |
87 return false; | 87 return false; |
88 typename TrackVector::iterator it = FindTrack(tracks, track->id()); | 88 typename TrackVector::iterator it = FindTrack(tracks, track->id()); |
89 if (it == tracks->end()) | 89 if (it == tracks->end()) |
90 return false; | 90 return false; |
91 tracks->erase(it); | 91 tracks->erase(it); |
92 FireOnChanged(); | 92 FireOnChanged(); |
93 return true; | 93 return true; |
94 } | 94 } |
95 | 95 |
96 } // namespace webrtc | 96 } // namespace webrtc |
OLD | NEW |