In FakeNetworkInterface drop dependency on rtc::MessageHandler
Bug: webrtc:9702 Change-Id: Ida110c0a790ee737bcffff0dee95dd35787205e1 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/271299 Commit-Queue: Danil Chapovalov <danilchap@webrtc.org> Reviewed-by: Erik Språng <sprang@webrtc.org> Cr-Commit-Position: refs/heads/main@{#37819}
This commit is contained in:
parent
6ba4b63f3a
commit
ad4a207693
@ -494,6 +494,8 @@ if (rtc_include_tests) {
|
||||
"../api:call_api",
|
||||
"../api:fec_controller_api",
|
||||
"../api:scoped_refptr",
|
||||
"../api/task_queue",
|
||||
"../api/task_queue:pending_task_safety_flag",
|
||||
"../api/transport:field_trial_based_config",
|
||||
"../api/video:encoded_image",
|
||||
"../api/video:video_bitrate_allocation",
|
||||
|
||||
@ -13,8 +13,11 @@
|
||||
|
||||
#include <map>
|
||||
#include <set>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
#include "api/task_queue/pending_task_safety_flag.h"
|
||||
#include "api/task_queue/task_queue_base.h"
|
||||
#include "media/base/media_channel.h"
|
||||
#include "media/base/rtp_utils.h"
|
||||
#include "modules/rtp_rtcp/source/rtp_util.h"
|
||||
@ -22,15 +25,13 @@
|
||||
#include "rtc_base/checks.h"
|
||||
#include "rtc_base/copy_on_write_buffer.h"
|
||||
#include "rtc_base/dscp.h"
|
||||
#include "rtc_base/message_handler.h"
|
||||
#include "rtc_base/synchronization/mutex.h"
|
||||
#include "rtc_base/thread.h"
|
||||
|
||||
namespace cricket {
|
||||
|
||||
// Fake NetworkInterface that sends/receives RTP/RTCP packets.
|
||||
class FakeNetworkInterface : public MediaChannel::NetworkInterface,
|
||||
public rtc::MessageHandlerAutoCleanup {
|
||||
class FakeNetworkInterface : public MediaChannel::NetworkInterface {
|
||||
public:
|
||||
FakeNetworkInterface()
|
||||
: thread_(rtc::Thread::Current()),
|
||||
@ -129,10 +130,10 @@ class FakeNetworkInterface : public MediaChannel::NetworkInterface,
|
||||
if (conf_) {
|
||||
for (size_t i = 0; i < conf_sent_ssrcs_.size(); ++i) {
|
||||
SetRtpSsrc(conf_sent_ssrcs_[i], *packet);
|
||||
PostMessage(ST_RTP, *packet);
|
||||
PostPacket(*packet);
|
||||
}
|
||||
} else {
|
||||
PostMessage(ST_RTP, *packet);
|
||||
PostPacket(*packet);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@ -145,7 +146,8 @@ class FakeNetworkInterface : public MediaChannel::NetworkInterface,
|
||||
options_ = options;
|
||||
if (!conf_) {
|
||||
// don't worry about RTCP in conf mode for now
|
||||
PostMessage(ST_RTCP, *packet);
|
||||
RTC_LOG(LS_VERBOSE) << "Dropping RTCP packet, they are not handled by "
|
||||
"MediaChannel anymore.";
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@ -161,22 +163,13 @@ class FakeNetworkInterface : public MediaChannel::NetworkInterface,
|
||||
return 0;
|
||||
}
|
||||
|
||||
void PostMessage(int id, const rtc::CopyOnWriteBuffer& packet) {
|
||||
thread_->Post(RTC_FROM_HERE, this, id, rtc::WrapMessageData(packet));
|
||||
}
|
||||
|
||||
virtual void OnMessage(rtc::Message* msg) {
|
||||
rtc::TypedMessageData<rtc::CopyOnWriteBuffer>* msg_data =
|
||||
static_cast<rtc::TypedMessageData<rtc::CopyOnWriteBuffer>*>(msg->pdata);
|
||||
if (dest_) {
|
||||
if (msg->message_id == ST_RTP) {
|
||||
dest_->OnPacketReceived(msg_data->data(), rtc::TimeMicros());
|
||||
} else {
|
||||
RTC_LOG(LS_VERBOSE) << "Dropping RTCP packet, they not handled by "
|
||||
"MediaChannel anymore.";
|
||||
}
|
||||
}
|
||||
delete msg_data;
|
||||
void PostPacket(rtc::CopyOnWriteBuffer packet) {
|
||||
thread_->PostTask(
|
||||
SafeTask(safety_.flag(), [this, packet = std::move(packet)]() mutable {
|
||||
if (dest_) {
|
||||
dest_->OnPacketReceived(std::move(packet), rtc::TimeMicros());
|
||||
}
|
||||
}));
|
||||
}
|
||||
|
||||
private:
|
||||
@ -204,7 +197,7 @@ class FakeNetworkInterface : public MediaChannel::NetworkInterface,
|
||||
}
|
||||
}
|
||||
|
||||
rtc::Thread* thread_;
|
||||
webrtc::TaskQueueBase* thread_;
|
||||
MediaChannel* dest_;
|
||||
bool conf_;
|
||||
// The ssrcs used in sending out packets in conference mode.
|
||||
@ -222,6 +215,7 @@ class FakeNetworkInterface : public MediaChannel::NetworkInterface,
|
||||
rtc::DiffServCodePoint dscp_;
|
||||
// Options of the most recently sent packet.
|
||||
rtc::PacketOptions options_;
|
||||
webrtc::ScopedTaskSafety safety_;
|
||||
};
|
||||
|
||||
} // namespace cricket
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user