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 | |
46 // Conversion function to convert candidate type string to the corresponding one | 48 // Conversion function to convert candidate type string to the corresponding one |
47 // from enum RTCStatsIceCandidateType. | 49 // from enum RTCStatsIceCandidateType. |
48 const char* IceCandidateTypeToStatsType(const std::string& candidate_type); | 50 const char* IceCandidateTypeToStatsType(const std::string& candidate_type); |
49 | 51 |
50 // Conversion function to convert adapter type to report string which are more | 52 // Conversion function to convert adapter type to report string which are more |
51 // fitting to the general style of http://w3c.github.io/webrtc-stats. This is | 53 // fitting to the general style of http://w3c.github.io/webrtc-stats. This is |
52 // only used by stats collector. | 54 // only used by stats collector. |
53 const char* AdapterTypeToStatsType(rtc::AdapterType type); | 55 const char* AdapterTypeToStatsType(rtc::AdapterType type); |
54 | 56 |
55 // A mapping between track ids and their StatsReport. | 57 // A mapping between track ids and their StatsReport. |
56 typedef std::map<std::string, StatsReport*> TrackIdMap; | 58 typedef std::map<std::string, StatsReport*> TrackIdMap; |
57 | 59 |
58 class StatsCollector { | 60 class StatsCollector { |
59 public: | 61 public: |
60 // The caller is responsible for ensuring that the session outlives the | 62 // The caller is responsible for ensuring that the pc and session |
61 // StatsCollector instance. | 63 // outlive the StatsCollector instance. |
62 explicit StatsCollector(WebRtcSession* session); | 64 explicit StatsCollector(PeerConnection* pc, WebRtcSession* session); |
Taylor Brandstetter
2015/10/07 00:26:19
I don't really like passing the StatsCollector a P
pthatcher1
2015/10/07 02:50:51
It makes sense to pass a PeerConnection in. It's
pthatcher1
2015/10/08 22:05:36
Or maybe pc_->session()?
Taylor Brandstetter
2015/10/09 19:54:09
Done.
| |
63 virtual ~StatsCollector(); | 65 virtual ~StatsCollector(); |
64 | 66 |
65 // Adds a MediaStream with tracks that can be used as a |selector| in a call | 67 // Adds a MediaStream with tracks that can be used as a |selector| in a call |
66 // to GetStats. | 68 // to GetStats. |
67 void AddStream(MediaStreamInterface* stream); | 69 void AddStream(MediaStreamInterface* stream); |
68 | 70 |
69 // Adds a local audio track that is used for getting some voice statistics. | 71 // Adds a local audio track that is used for getting some voice statistics. |
70 void AddLocalAudioTrack(AudioTrackInterface* audio_track, uint32 ssrc); | 72 void AddLocalAudioTrack(AudioTrackInterface* audio_track, uint32 ssrc); |
71 | 73 |
72 // Removes a local audio tracks that is used for getting some voice | 74 // Removes a local audio tracks that is used for getting some voice |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
141 // |direction| tells if the track is for sending or receiving. | 143 // |direction| tells if the track is for sending or receiving. |
142 bool GetTrackIdBySsrc(uint32 ssrc, std::string* track_id, | 144 bool GetTrackIdBySsrc(uint32 ssrc, std::string* track_id, |
143 StatsReport::Direction direction); | 145 StatsReport::Direction direction); |
144 | 146 |
145 // Helper method to update the timestamp of track records. | 147 // Helper method to update the timestamp of track records. |
146 void UpdateTrackReports(); | 148 void UpdateTrackReports(); |
147 | 149 |
148 // A collection for all of our stats reports. | 150 // A collection for all of our stats reports. |
149 StatsCollection reports_; | 151 StatsCollection reports_; |
150 TrackIdMap track_ids_; | 152 TrackIdMap track_ids_; |
151 // Raw pointer to the session the statistics are gathered from. | 153 // Raw pointers to the peer connection and session the statistics are |
154 // gathered from. | |
155 PeerConnection* const pc_; | |
152 WebRtcSession* const session_; | 156 WebRtcSession* const session_; |
153 double stats_gathering_started_; | 157 double stats_gathering_started_; |
154 cricket::ProxyTransportMap proxy_to_transport_; | 158 cricket::ProxyTransportMap proxy_to_transport_; |
155 | 159 |
156 // TODO(tommi): We appear to be holding on to raw pointers to reference | 160 // TODO(tommi): We appear to be holding on to raw pointers to reference |
157 // counted objects? We should be using scoped_refptr here. | 161 // counted objects? We should be using scoped_refptr here. |
158 typedef std::vector<std::pair<AudioTrackInterface*, uint32> > | 162 typedef std::vector<std::pair<AudioTrackInterface*, uint32> > |
159 LocalAudioTrackVector; | 163 LocalAudioTrackVector; |
160 LocalAudioTrackVector local_audio_tracks_; | 164 LocalAudioTrackVector local_audio_tracks_; |
161 }; | 165 }; |
162 | 166 |
163 } // namespace webrtc | 167 } // namespace webrtc |
164 | 168 |
165 #endif // TALK_APP_WEBRTC_STATSCOLLECTOR_H_ | 169 #endif // TALK_APP_WEBRTC_STATSCOLLECTOR_H_ |
OLD | NEW |