Reland "Move stats ID generation from SSRC to local ID"
This is a reland of e357a4dd4e3b015f8281813f246de793589bd537
Original change's description:
> Move stats ID generation from SSRC to local ID
>
> This generates stats IDs for Track stats (which
> represents stats on the attachment of a track to
> a PeerConnection) from being SSRC-based to being
> based on an ID that is allocated when connecting the
> track to the PC.
>
> This is a prerequisite to generating stats before
> the PeerConnection is connected.
>
> Bug: webrtc:8673
> Change-Id: I82f6e521646b0c92b3af4dffb2cdee75e6dc10d4
> Reviewed-on: https://webrtc-review.googlesource.com/38360
> Commit-Queue: Harald Alvestrand <hta@webrtc.org>
> Reviewed-by: Fredrik Solenberg <solenberg@webrtc.org>
> Reviewed-by: Henrik Boström <hbos@webrtc.org>
> Cr-Commit-Position: refs/heads/master@{#21582}
TBR=solenberg@webrtc.org
Bug: webrtc:8673
Change-Id: I610302efc5393919569b77e3b59aa3384a9b88a5
Reviewed-on: https://webrtc-review.googlesource.com/38842
Reviewed-by: Harald Alvestrand <hta@webrtc.org>
Commit-Queue: Harald Alvestrand <hta@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#21589}
diff --git a/pc/rtpreceiver.cc b/pc/rtpreceiver.cc
index 98c501c..e318c17 100644
--- a/pc/rtpreceiver.cc
+++ b/pc/rtpreceiver.cc
@@ -21,6 +21,17 @@
namespace webrtc {
+namespace {
+
+// This function is only expected to be called on the signalling thread.
+int GenerateUniqueId() {
+ static int g_unique_id = 0;
+
+ return ++g_unique_id;
+}
+
+} // namespace
+
AudioRtpReceiver::AudioRtpReceiver(
rtc::Thread* worker_thread,
const std::string& receiver_id,
@@ -35,7 +46,8 @@
AudioTrack::Create(
receiver_id,
RemoteAudioSource::Create(worker_thread, media_channel, ssrc)))),
- cached_track_enabled_(track_->enabled()) {
+ cached_track_enabled_(track_->enabled()),
+ attachment_id_(GenerateUniqueId()) {
RTC_DCHECK(worker_thread_);
RTC_DCHECK(track_->GetSource()->remote());
track_->RegisterObserver(this);
@@ -207,7 +219,8 @@
VideoTrackSourceProxy::Create(rtc::Thread::Current(),
worker_thread,
source_),
- worker_thread))) {
+ worker_thread))),
+ attachment_id_(GenerateUniqueId()) {
RTC_DCHECK(worker_thread_);
SetStreams(streams);
source_->SetState(MediaSourceInterface::kLive);