Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(252)

Unified Diff: webrtc/api/test/fakertpsenderreceiver.h

Issue 2605033002: RTCMediaStreamTrackStats.ssrcIds collected by RTCStatsCollector. (Closed)
Patch Set: Rebase with master (reupload from other machine to create dependent patchset) Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: webrtc/api/test/fakertpsenderreceiver.h
diff --git a/webrtc/api/test/fakertpsenderreceiver.h b/webrtc/api/test/fakertpsenderreceiver.h
new file mode 100644
index 0000000000000000000000000000000000000000..495c6af78222dd207a8ab7cc49f2707e74fc791d
--- /dev/null
+++ b/webrtc/api/test/fakertpsenderreceiver.h
@@ -0,0 +1,107 @@
+/*
+ * Copyright 2016 The WebRTC project authors. All Rights Reserved.
+ *
+ * Use of this source code is governed by a BSD-style license
+ * that can be found in the LICENSE file in the root of the source
+ * tree. An additional intellectual property rights grant can be found
+ * in the file PATENTS. All contributing project authors may
+ * be found in the AUTHORS file in the root of the source tree.
+ */
+
+#ifndef WEBRTC_API_TEST_FAKERTPSENDERRECEIVER_H_
+#define WEBRTC_API_TEST_FAKERTPSENDERRECEIVER_H_
+
+#include <string>
+#include <vector>
+
+#include "webrtc/api/rtpparameters.h"
+#include "webrtc/api/rtpreceiverinterface.h"
+#include "webrtc/api/rtpsenderinterface.h"
+#include "webrtc/base/checks.h"
+#include "webrtc/base/optional.h"
+
+namespace webrtc {
+
+RtpParameters CreateRtpParametersWithSsrc(uint32_t ssrc) {
hta-webrtc 2017/01/02 15:29:47 I don't like having all this stuff in a .h file. I
pthatcher1 2017/01/03 19:29:00 I'd prefer a name like CreateRtpParametersWithOneS
+ RtpParameters params;
+ RtpEncodingParameters encoding_params;
+ encoding_params.ssrc = rtc::Optional<uint32_t>(ssrc);
+ params.encodings.push_back(encoding_params);
+ return params;
+}
+
+class FakeRtpSender : public rtc::RefCountedObject<RtpSenderInterface> {
+ public:
+ FakeRtpSender(cricket::MediaType media_type, RtpParameters parameters)
+ : media_type_(media_type), rtp_parameters_(parameters) {}
+
+ bool SetTrack(MediaStreamTrackInterface* track) override {
+ track_ = track;
+ return true;
+ }
+
+ rtc::scoped_refptr<MediaStreamTrackInterface> track() const override {
+ return track_;
+ }
+
+ uint32_t ssrc() const override {
+ RTC_DCHECK(GetParameters().encodings[0].ssrc);
+ return *GetParameters().encodings[0].ssrc;
+ }
+
+ cricket::MediaType media_type() const override { return media_type_; }
+ std::string id() const override { return "FakeRtpSender"; }
+
+ std::vector<std::string> stream_ids() const override {
+ RTC_NOTREACHED();
+ return std::vector<std::string>();
+ }
+
+ RtpParameters GetParameters() const override { return rtp_parameters_; }
+
+ bool SetParameters(const RtpParameters& parameters) override {
+ rtp_parameters_ = parameters;
+ return true;
+ }
+
+ private:
+ const cricket::MediaType media_type_;
+ RtpParameters rtp_parameters_;
+ rtc::scoped_refptr<MediaStreamTrackInterface> track_;
+};
+
+class FakeRtpReceiver : public rtc::RefCountedObject<RtpReceiverInterface> {
+ public:
+ FakeRtpReceiver(cricket::MediaType media_type, RtpParameters parameters)
+ : media_type_(media_type), rtp_parameters_(parameters) {}
+
+ void SetTrack(MediaStreamTrackInterface* track) {
+ track_ = track;
+ }
+
+ rtc::scoped_refptr<MediaStreamTrackInterface> track() const override {
+ return track_;
+ }
+
+ cricket::MediaType media_type() const override { return media_type_; }
+ std::string id() const override { return "FakeRtpReceiver"; }
+ RtpParameters GetParameters() const override { return rtp_parameters_; }
+
+ bool SetParameters(const RtpParameters& parameters) override {
+ rtp_parameters_ = parameters;
+ return true;
+ }
+
+ void SetObserver(RtpReceiverObserverInterface* observer) override {
+ RTC_NOTREACHED();
+ }
+
+ private:
+ const cricket::MediaType media_type_;
+ RtpParameters rtp_parameters_;
+ rtc::scoped_refptr<MediaStreamTrackInterface> track_;
+};
+
+} // namespace webrtc
+
+#endif // WEBRTC_API_TEST_FAKERTPSENDERRECEIVER_H_

Powered by Google App Engine
This is Rietveld 408576698