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

Side by Side 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 3 years, 11 months 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 unified diff | Download patch
OLDNEW
(Empty)
1 /*
2 * Copyright 2016 The WebRTC project authors. All Rights Reserved.
3 *
4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree.
9 */
10
11 #ifndef WEBRTC_API_TEST_FAKERTPSENDERRECEIVER_H_
12 #define WEBRTC_API_TEST_FAKERTPSENDERRECEIVER_H_
13
14 #include <string>
15 #include <vector>
16
17 #include "webrtc/api/rtpparameters.h"
18 #include "webrtc/api/rtpreceiverinterface.h"
19 #include "webrtc/api/rtpsenderinterface.h"
20 #include "webrtc/base/checks.h"
21 #include "webrtc/base/optional.h"
22
23 namespace webrtc {
24
25 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
26 RtpParameters params;
27 RtpEncodingParameters encoding_params;
28 encoding_params.ssrc = rtc::Optional<uint32_t>(ssrc);
29 params.encodings.push_back(encoding_params);
30 return params;
31 }
32
33 class FakeRtpSender : public rtc::RefCountedObject<RtpSenderInterface> {
34 public:
35 FakeRtpSender(cricket::MediaType media_type, RtpParameters parameters)
36 : media_type_(media_type), rtp_parameters_(parameters) {}
37
38 bool SetTrack(MediaStreamTrackInterface* track) override {
39 track_ = track;
40 return true;
41 }
42
43 rtc::scoped_refptr<MediaStreamTrackInterface> track() const override {
44 return track_;
45 }
46
47 uint32_t ssrc() const override {
48 RTC_DCHECK(GetParameters().encodings[0].ssrc);
49 return *GetParameters().encodings[0].ssrc;
50 }
51
52 cricket::MediaType media_type() const override { return media_type_; }
53 std::string id() const override { return "FakeRtpSender"; }
54
55 std::vector<std::string> stream_ids() const override {
56 RTC_NOTREACHED();
57 return std::vector<std::string>();
58 }
59
60 RtpParameters GetParameters() const override { return rtp_parameters_; }
61
62 bool SetParameters(const RtpParameters& parameters) override {
63 rtp_parameters_ = parameters;
64 return true;
65 }
66
67 private:
68 const cricket::MediaType media_type_;
69 RtpParameters rtp_parameters_;
70 rtc::scoped_refptr<MediaStreamTrackInterface> track_;
71 };
72
73 class FakeRtpReceiver : public rtc::RefCountedObject<RtpReceiverInterface> {
74 public:
75 FakeRtpReceiver(cricket::MediaType media_type, RtpParameters parameters)
76 : media_type_(media_type), rtp_parameters_(parameters) {}
77
78 void SetTrack(MediaStreamTrackInterface* track) {
79 track_ = track;
80 }
81
82 rtc::scoped_refptr<MediaStreamTrackInterface> track() const override {
83 return track_;
84 }
85
86 cricket::MediaType media_type() const override { return media_type_; }
87 std::string id() const override { return "FakeRtpReceiver"; }
88 RtpParameters GetParameters() const override { return rtp_parameters_; }
89
90 bool SetParameters(const RtpParameters& parameters) override {
91 rtp_parameters_ = parameters;
92 return true;
93 }
94
95 void SetObserver(RtpReceiverObserverInterface* observer) override {
96 RTC_NOTREACHED();
97 }
98
99 private:
100 const cricket::MediaType media_type_;
101 RtpParameters rtp_parameters_;
102 rtc::scoped_refptr<MediaStreamTrackInterface> track_;
103 };
104
105 } // namespace webrtc
106
107 #endif // WEBRTC_API_TEST_FAKERTPSENDERRECEIVER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698