| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "content/renderer/media/webrtc/media_stream_track_metrics.h" | 5 #include "content/renderer/media/webrtc/media_stream_track_metrics.h" |
| 6 | 6 |
| 7 #include <inttypes.h> | 7 #include <inttypes.h> |
| 8 #include <set> | 8 #include <set> |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| (...skipping 24 matching lines...) Expand all Loading... |
| 35 MediaStreamInterface* stream() { return stream_; } | 35 MediaStreamInterface* stream() { return stream_; } |
| 36 MediaStreamTrackMetrics::StreamType stream_type() { return stream_type_; } | 36 MediaStreamTrackMetrics::StreamType stream_type() { return stream_type_; } |
| 37 | 37 |
| 38 private: | 38 private: |
| 39 typedef std::set<std::string> IdSet; | 39 typedef std::set<std::string> IdSet; |
| 40 | 40 |
| 41 // webrtc::ObserverInterface implementation. | 41 // webrtc::ObserverInterface implementation. |
| 42 virtual void OnChanged() OVERRIDE; | 42 virtual void OnChanged() OVERRIDE; |
| 43 | 43 |
| 44 template <class T> | 44 template <class T> |
| 45 IdSet GetTrackIds(const std::vector<talk_base::scoped_refptr<T> >& tracks) { | 45 IdSet GetTrackIds(const std::vector<rtc::scoped_refptr<T> >& tracks) { |
| 46 IdSet track_ids; | 46 IdSet track_ids; |
| 47 typename std::vector<talk_base::scoped_refptr<T> >::const_iterator it = | 47 typename std::vector<rtc::scoped_refptr<T> >::const_iterator it = |
| 48 tracks.begin(); | 48 tracks.begin(); |
| 49 for (; it != tracks.end(); ++it) { | 49 for (; it != tracks.end(); ++it) { |
| 50 track_ids.insert((*it)->id()); | 50 track_ids.insert((*it)->id()); |
| 51 } | 51 } |
| 52 return track_ids; | 52 return track_ids; |
| 53 } | 53 } |
| 54 | 54 |
| 55 void ReportAddedAndRemovedTracks( | 55 void ReportAddedAndRemovedTracks( |
| 56 const IdSet& new_ids, | 56 const IdSet& new_ids, |
| 57 const IdSet& old_ids, | 57 const IdSet& old_ids, |
| 58 MediaStreamTrackMetrics::TrackType track_type); | 58 MediaStreamTrackMetrics::TrackType track_type); |
| 59 | 59 |
| 60 // Sends a lifetime message for the given tracks. OK to call with an | 60 // Sends a lifetime message for the given tracks. OK to call with an |
| 61 // empty |ids|, in which case the method has no side effects. | 61 // empty |ids|, in which case the method has no side effects. |
| 62 void ReportTracks(const IdSet& ids, | 62 void ReportTracks(const IdSet& ids, |
| 63 MediaStreamTrackMetrics::TrackType track_type, | 63 MediaStreamTrackMetrics::TrackType track_type, |
| 64 MediaStreamTrackMetrics::LifetimeEvent event); | 64 MediaStreamTrackMetrics::LifetimeEvent event); |
| 65 | 65 |
| 66 // False until start/end of lifetime messages have been sent. | 66 // False until start/end of lifetime messages have been sent. |
| 67 bool has_reported_start_; | 67 bool has_reported_start_; |
| 68 bool has_reported_end_; | 68 bool has_reported_end_; |
| 69 | 69 |
| 70 // IDs of audio and video tracks in the stream being observed. | 70 // IDs of audio and video tracks in the stream being observed. |
| 71 IdSet audio_track_ids_; | 71 IdSet audio_track_ids_; |
| 72 IdSet video_track_ids_; | 72 IdSet video_track_ids_; |
| 73 | 73 |
| 74 MediaStreamTrackMetrics::StreamType stream_type_; | 74 MediaStreamTrackMetrics::StreamType stream_type_; |
| 75 talk_base::scoped_refptr<MediaStreamInterface> stream_; | 75 rtc::scoped_refptr<MediaStreamInterface> stream_; |
| 76 | 76 |
| 77 // Non-owning. | 77 // Non-owning. |
| 78 MediaStreamTrackMetrics* owner_; | 78 MediaStreamTrackMetrics* owner_; |
| 79 }; | 79 }; |
| 80 | 80 |
| 81 namespace { | 81 namespace { |
| 82 | 82 |
| 83 // Used with std::find_if. | 83 // Used with std::find_if. |
| 84 struct ObserverFinder { | 84 struct ObserverFinder { |
| 85 ObserverFinder(MediaStreamTrackMetrics::StreamType stream_type, | 85 ObserverFinder(MediaStreamTrackMetrics::StreamType stream_type, |
| (...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 323 | 323 |
| 324 uint64 MediaStreamTrackMetrics::MakeUniqueId(const std::string& track_id, | 324 uint64 MediaStreamTrackMetrics::MakeUniqueId(const std::string& track_id, |
| 325 StreamType stream_type) { | 325 StreamType stream_type) { |
| 326 return MakeUniqueIdImpl( | 326 return MakeUniqueIdImpl( |
| 327 reinterpret_cast<uint64>(reinterpret_cast<void*>(this)), | 327 reinterpret_cast<uint64>(reinterpret_cast<void*>(this)), |
| 328 track_id, | 328 track_id, |
| 329 stream_type); | 329 stream_type); |
| 330 } | 330 } |
| 331 | 331 |
| 332 } // namespace content | 332 } // namespace content |
| OLD | NEW |