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

Unified Diff: webrtc/media/base/fakemediaengine.h

Issue 2981513002: Wire up RTP keep-alive in ortc api. (Closed)
Patch Set: Test Created 3 years, 5 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 side-by-side diff with in-line comments
Download patch
Index: webrtc/media/base/fakemediaengine.h
diff --git a/webrtc/media/base/fakemediaengine.h b/webrtc/media/base/fakemediaengine.h
index 0082391d768c17fe8bbaeceec9cb8ce5e27f9041..c8d54a545151a1600fce245b3a655f457f95548d 100644
--- a/webrtc/media/base/fakemediaengine.h
+++ b/webrtc/media/base/fakemediaengine.h
@@ -23,11 +23,13 @@
#include "webrtc/media/base/mediaengine.h"
#include "webrtc/media/base/rtputils.h"
#include "webrtc/media/base/streamparams.h"
+#include "webrtc/media/engine/webrtcvideoengine.h"
#include "webrtc/modules/audio_processing/include/audio_processing.h"
#include "webrtc/p2p/base/sessiondescription.h"
#include "webrtc/rtc_base/checks.h"
#include "webrtc/rtc_base/copyonwritebuffer.h"
#include "webrtc/rtc_base/networkroute.h"
+#include "webrtc/rtc_base/ptr_util.h"
#include "webrtc/rtc_base/stringutils.h"
using webrtc::RtpExtension;
@@ -47,7 +49,10 @@ template <class Base> class RtpHelper : public Base {
fail_set_send_codecs_(false),
fail_set_recv_codecs_(false),
send_ssrc_(0),
- ready_to_send_(false) {}
+ ready_to_send_(false),
+ transport_overhead_per_packet_(0),
+ num_network_route_changes_(0) {}
+ virtual ~RtpHelper() = default;
const std::vector<RtpExtension>& recv_extensions() {
return recv_extensions_;
}
@@ -299,7 +304,7 @@ template <class Base> class RtpHelper : public Base {
bool ready_to_send_;
int transport_overhead_per_packet_;
rtc::NetworkRoute last_network_route_;
- int num_network_route_changes_ = 0;
+ int num_network_route_changes_;
};
class FakeVoiceMediaChannel : public RtpHelper<VoiceMediaChannel> {
@@ -517,9 +522,14 @@ inline bool CompareDtmfInfo(const FakeVoiceMediaChannel::DtmfInfo& info,
class FakeVideoMediaChannel : public RtpHelper<VideoMediaChannel> {
public:
- explicit FakeVideoMediaChannel(FakeVideoEngine* engine,
- const VideoOptions& options)
- : engine_(engine), max_bps_(-1) {
+ FakeVideoMediaChannel(FakeVideoEngine* engine, const VideoOptions& options)
+ : FakeVideoMediaChannel(engine,
+ options,
+ std::unique_ptr<WebRtcVideoChannel>()) {}
+ FakeVideoMediaChannel(FakeVideoEngine* engine,
+ const VideoOptions& options,
+ std::unique_ptr<WebRtcVideoChannel> real_channel)
+ : engine_(engine), max_bps_(-1), real_channel_(std::move(real_channel)) {
SetOptions(options);
}
@@ -536,6 +546,8 @@ class FakeVideoMediaChannel : public RtpHelper<VideoMediaChannel> {
}
int max_bps() const { return max_bps_; }
bool SetSendParameters(const VideoSendParameters& params) override {
+ if (real_channel_)
+ real_channel_->SetSendParameters(params);
set_send_rtcp_parameters(params.rtcp);
return (SetSendCodecs(params.codecs) &&
SetSendRtpHeaderExtensions(params.extensions) &&
@@ -547,9 +559,13 @@ class FakeVideoMediaChannel : public RtpHelper<VideoMediaChannel> {
SetRecvRtpHeaderExtensions(params.extensions));
}
bool AddSendStream(const StreamParams& sp) override {
+ if (real_channel_)
+ real_channel_->AddSendStream(sp);
return RtpHelper<VideoMediaChannel>::AddSendStream(sp);
}
bool RemoveSendStream(uint32_t ssrc) override {
+ if (real_channel_)
+ real_channel_->RemoveSendStream(ssrc);
return RtpHelper<VideoMediaChannel>::RemoveSendStream(ssrc);
}
@@ -574,12 +590,20 @@ class FakeVideoMediaChannel : public RtpHelper<VideoMediaChannel> {
return sinks_.find(ssrc) != sinks_.end() && sinks_.at(ssrc) != nullptr;
}
- bool SetSend(bool send) override { return set_sending(send); }
+ bool SetSend(bool send) override {
+ if (real_channel_)
+ real_channel_->SetSend(send);
+ return set_sending(send);
+ }
+
bool SetVideoSend(
uint32_t ssrc,
bool enable,
const VideoOptions* options,
rtc::VideoSourceInterface<webrtc::VideoFrame>* source) override {
+ if (real_channel_)
+ real_channel_->SetVideoSend(ssrc, enable, options, source);
+
if (!RtpHelper<VideoMediaChannel>::MuteStream(ssrc, !enable)) {
return false;
}
@@ -646,6 +670,7 @@ class FakeVideoMediaChannel : public RtpHelper<VideoMediaChannel> {
std::map<uint32_t, rtc::VideoSourceInterface<webrtc::VideoFrame>*> sources_;
VideoOptions options_;
int max_bps_;
+ std::unique_ptr<WebRtcVideoChannel> real_channel_;
};
// Dummy option class, needed for the DataTraits abstraction in
@@ -833,12 +858,14 @@ class FakeVoiceEngine : public FakeBaseEngine {
class FakeVideoEngine : public FakeBaseEngine {
public:
- FakeVideoEngine() : capture_(false) {
+ FakeVideoEngine() : capture_(false), create_real_channels_(false) {
// Add a fake video codec. Note that the name must not be "" as there are
// sanity checks against that.
codecs_.push_back(VideoCodec(0, "fake_video_codec"));
}
+
void Init() {}
+
bool SetOptions(const VideoOptions& options) {
options_ = options;
options_changed_ = true;
@@ -849,21 +876,30 @@ class FakeVideoEngine : public FakeBaseEngine {
const MediaConfig& config,
const VideoOptions& options) {
if (fail_create_channel_) {
- return NULL;
+ return nullptr;
}
- FakeVideoMediaChannel* ch = new FakeVideoMediaChannel(this, options);
- channels_.push_back(ch);
- return ch;
+ channels_.emplace_back(new FakeVideoMediaChannel(
+ this, options,
+ std::unique_ptr<WebRtcVideoChannel>(
+ create_real_channels_ ? new WebRtcVideoChannel(
+ call, config, options, nullptr, nullptr)
+ : nullptr)));
+ return channels_.back();
}
+
FakeVideoMediaChannel* GetChannel(size_t index) {
- return (channels_.size() > index) ? channels_[index] : NULL;
+ return (channels_.size() > index) ? channels_[index] : nullptr;
}
+
void UnregisterChannel(VideoMediaChannel* channel) {
- channels_.erase(std::find(channels_.begin(), channels_.end(), channel));
+ auto it = std::find(channels_.begin(), channels_.end(), channel);
+ RTC_DCHECK(it != channels_.end());
+ channels_.erase(it);
}
const std::vector<VideoCodec>& codecs() const { return codecs_; }
+
void SetCodecs(const std::vector<VideoCodec> codecs) { codecs_ = codecs; }
bool SetCapture(bool capture) {
@@ -871,11 +907,16 @@ class FakeVideoEngine : public FakeBaseEngine {
return true;
}
+ void SetCreateRealChannel(bool do_create) {
+ create_real_channels_ = do_create;
+ }
+
private:
std::vector<FakeVideoMediaChannel*> channels_;
std::vector<VideoCodec> codecs_;
bool capture_;
VideoOptions options_;
+ bool create_real_channels_;
friend class FakeMediaEngine;
};
@@ -934,6 +975,8 @@ class FakeMediaEngine :
voice_.set_fail_create_channel(fail);
video_.set_fail_create_channel(fail);
}
+
+ FakeVideoEngine* GetVideoEngine() { return &video_; }
};
// Have to come afterwards due to declaration order

Powered by Google App Engine
This is Rietveld 408576698