| 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 25 matching lines...) Expand all Loading... |
| 36 #include <vector> | 36 #include <vector> |
| 37 | 37 |
| 38 #include "talk/app/webrtc/mediastreaminterface.h" | 38 #include "talk/app/webrtc/mediastreaminterface.h" |
| 39 #include "talk/app/webrtc/mediastreamsignaling.h" | 39 #include "talk/app/webrtc/mediastreamsignaling.h" |
| 40 #include "talk/app/webrtc/peerconnectioninterface.h" | 40 #include "talk/app/webrtc/peerconnectioninterface.h" |
| 41 #include "talk/app/webrtc/statstypes.h" | 41 #include "talk/app/webrtc/statstypes.h" |
| 42 #include "talk/app/webrtc/webrtcsession.h" | 42 #include "talk/app/webrtc/webrtcsession.h" |
| 43 | 43 |
| 44 namespace webrtc { | 44 namespace webrtc { |
| 45 | 45 |
| 46 class PeerConnection; | |
| 47 | |
| 48 // Conversion function to convert candidate type string to the corresponding one | 46 // Conversion function to convert candidate type string to the corresponding one |
| 49 // from enum RTCStatsIceCandidateType. | 47 // from enum RTCStatsIceCandidateType. |
| 50 const char* IceCandidateTypeToStatsType(const std::string& candidate_type); | 48 const char* IceCandidateTypeToStatsType(const std::string& candidate_type); |
| 51 | 49 |
| 52 // Conversion function to convert adapter type to report string which are more | 50 // Conversion function to convert adapter type to report string which are more |
| 53 // fitting to the general style of http://w3c.github.io/webrtc-stats. This is | 51 // fitting to the general style of http://w3c.github.io/webrtc-stats. This is |
| 54 // only used by stats collector. | 52 // only used by stats collector. |
| 55 const char* AdapterTypeToStatsType(rtc::AdapterType type); | 53 const char* AdapterTypeToStatsType(rtc::AdapterType type); |
| 56 | 54 |
| 57 // A mapping between track ids and their StatsReport. | 55 // A mapping between track ids and their StatsReport. |
| 58 typedef std::map<std::string, StatsReport*> TrackIdMap; | 56 typedef std::map<std::string, StatsReport*> TrackIdMap; |
| 59 | 57 |
| 60 class StatsCollector { | 58 class StatsCollector { |
| 61 public: | 59 public: |
| 62 // The caller is responsible for ensuring that the pc outlives the | 60 // The caller is responsible for ensuring that the session outlives the |
| 63 // StatsCollector instance. | 61 // StatsCollector instance. |
| 64 explicit StatsCollector(PeerConnection* pc); | 62 explicit StatsCollector(WebRtcSession* session); |
| 65 virtual ~StatsCollector(); | 63 virtual ~StatsCollector(); |
| 66 | 64 |
| 67 // Adds a MediaStream with tracks that can be used as a |selector| in a call | 65 // Adds a MediaStream with tracks that can be used as a |selector| in a call |
| 68 // to GetStats. | 66 // to GetStats. |
| 69 void AddStream(MediaStreamInterface* stream); | 67 void AddStream(MediaStreamInterface* stream); |
| 70 | 68 |
| 71 // Adds a local audio track that is used for getting some voice statistics. | 69 // Adds a local audio track that is used for getting some voice statistics. |
| 72 void AddLocalAudioTrack(AudioTrackInterface* audio_track, uint32_t ssrc); | 70 void AddLocalAudioTrack(AudioTrackInterface* audio_track, uint32_t ssrc); |
| 73 | 71 |
| 74 // Removes a local audio tracks that is used for getting some voice | 72 // Removes a local audio tracks that is used for getting some voice |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 146 bool GetTrackIdBySsrc(uint32_t ssrc, | 144 bool GetTrackIdBySsrc(uint32_t ssrc, |
| 147 std::string* track_id, | 145 std::string* track_id, |
| 148 StatsReport::Direction direction); | 146 StatsReport::Direction direction); |
| 149 | 147 |
| 150 // Helper method to update the timestamp of track records. | 148 // Helper method to update the timestamp of track records. |
| 151 void UpdateTrackReports(); | 149 void UpdateTrackReports(); |
| 152 | 150 |
| 153 // A collection for all of our stats reports. | 151 // A collection for all of our stats reports. |
| 154 StatsCollection reports_; | 152 StatsCollection reports_; |
| 155 TrackIdMap track_ids_; | 153 TrackIdMap track_ids_; |
| 156 // Raw pointer to the peer connection the statistics are gathered from. | 154 // Raw pointer to the session the statistics are gathered from. |
| 157 PeerConnection* const pc_; | 155 WebRtcSession* const session_; |
| 158 double stats_gathering_started_; | 156 double stats_gathering_started_; |
| 159 cricket::ProxyTransportMap proxy_to_transport_; | 157 cricket::ProxyTransportMap proxy_to_transport_; |
| 160 | 158 |
| 161 // TODO(tommi): We appear to be holding on to raw pointers to reference | 159 // TODO(tommi): We appear to be holding on to raw pointers to reference |
| 162 // counted objects? We should be using scoped_refptr here. | 160 // counted objects? We should be using scoped_refptr here. |
| 163 typedef std::vector<std::pair<AudioTrackInterface*, uint32_t> > | 161 typedef std::vector<std::pair<AudioTrackInterface*, uint32_t> > |
| 164 LocalAudioTrackVector; | 162 LocalAudioTrackVector; |
| 165 LocalAudioTrackVector local_audio_tracks_; | 163 LocalAudioTrackVector local_audio_tracks_; |
| 166 }; | 164 }; |
| 167 | 165 |
| 168 } // namespace webrtc | 166 } // namespace webrtc |
| 169 | 167 |
| 170 #endif // TALK_APP_WEBRTC_STATSCOLLECTOR_H_ | 168 #endif // TALK_APP_WEBRTC_STATSCOLLECTOR_H_ |
| OLD | NEW |