Set the preferred DSCP value for Rtp data channel to be DSCP_AF41.
BUG=b/31996729 Review-Url: https://codereview.webrtc.org/2539813003 Cr-Commit-Position: refs/heads/master@{#15449}
This commit is contained in:
parent
66f99a4b8e
commit
ebbe4f2ed5
@ -1719,8 +1719,8 @@ bool WebRtcSession::CreateDataChannel(const cricket::ContentInfo* content,
|
||||
rtcp_mux_policy_ == PeerConnectionInterface::kRtcpMuxPolicyRequire;
|
||||
bool create_rtcp_transport_channel = !sctp && !require_rtcp_mux;
|
||||
data_channel_.reset(channel_manager_->CreateDataChannel(
|
||||
transport_controller_.get(), content->name, bundle_transport,
|
||||
create_rtcp_transport_channel, data_channel_type_));
|
||||
transport_controller_.get(), media_controller_, content->name,
|
||||
bundle_transport, create_rtcp_transport_channel, data_channel_type_));
|
||||
if (!data_channel_) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -943,7 +943,8 @@ class FakeDataEngine : public DataEngineInterface {
|
||||
public:
|
||||
FakeDataEngine() : last_channel_type_(DCT_NONE) {}
|
||||
|
||||
virtual DataMediaChannel* CreateChannel(DataChannelType data_channel_type) {
|
||||
virtual DataMediaChannel* CreateChannel(DataChannelType data_channel_type,
|
||||
const MediaConfig& config) {
|
||||
last_channel_type_ = data_channel_type;
|
||||
FakeDataMediaChannel* ch = new FakeDataMediaChannel(this, DataOptions());
|
||||
channels_.push_back(ch);
|
||||
|
||||
@ -35,13 +35,14 @@ class HybridDataEngine : public DataEngineInterface {
|
||||
second_->data_codecs().end());
|
||||
}
|
||||
|
||||
virtual DataMediaChannel* CreateChannel(DataChannelType data_channel_type) {
|
||||
virtual DataMediaChannel* CreateChannel(DataChannelType data_channel_type,
|
||||
const MediaConfig& config) {
|
||||
DataMediaChannel* channel = NULL;
|
||||
if (first_) {
|
||||
channel = first_->CreateChannel(data_channel_type);
|
||||
channel = first_->CreateChannel(data_channel_type, config);
|
||||
}
|
||||
if (!channel && second_) {
|
||||
channel = second_->CreateChannel(data_channel_type);
|
||||
channel = second_->CreateChannel(data_channel_type, config);
|
||||
}
|
||||
return channel;
|
||||
}
|
||||
|
||||
@ -1156,6 +1156,8 @@ class DataMediaChannel : public MediaChannel {
|
||||
ERROR_RECV_SRTP_REPLAY, // Packet replay detected.
|
||||
};
|
||||
|
||||
DataMediaChannel() {}
|
||||
DataMediaChannel(const MediaConfig& config) : MediaChannel(config) {}
|
||||
virtual ~DataMediaChannel() {}
|
||||
|
||||
virtual bool SetSendParameters(const DataSendParameters& params) = 0;
|
||||
|
||||
@ -170,7 +170,8 @@ enum DataChannelType { DCT_NONE = 0, DCT_RTP = 1, DCT_SCTP = 2, DCT_QUIC = 3 };
|
||||
class DataEngineInterface {
|
||||
public:
|
||||
virtual ~DataEngineInterface() {}
|
||||
virtual DataMediaChannel* CreateChannel(DataChannelType type) = 0;
|
||||
virtual DataMediaChannel* CreateChannel(DataChannelType type,
|
||||
const MediaConfig& config) = 0;
|
||||
virtual const std::vector<DataCodec>& data_codecs() = 0;
|
||||
};
|
||||
|
||||
|
||||
@ -40,11 +40,12 @@ RtpDataEngine::RtpDataEngine() {
|
||||
}
|
||||
|
||||
DataMediaChannel* RtpDataEngine::CreateChannel(
|
||||
DataChannelType data_channel_type) {
|
||||
DataChannelType data_channel_type,
|
||||
const MediaConfig& config) {
|
||||
if (data_channel_type != DCT_RTP) {
|
||||
return NULL;
|
||||
}
|
||||
return new RtpDataMediaChannel();
|
||||
return new RtpDataMediaChannel(config);
|
||||
}
|
||||
|
||||
static const DataCodec* FindCodecByName(const std::vector<DataCodec>& codecs,
|
||||
@ -56,7 +57,8 @@ static const DataCodec* FindCodecByName(const std::vector<DataCodec>& codecs,
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
RtpDataMediaChannel::RtpDataMediaChannel() {
|
||||
RtpDataMediaChannel::RtpDataMediaChannel(const MediaConfig& config)
|
||||
: DataMediaChannel(config) {
|
||||
Construct();
|
||||
}
|
||||
|
||||
@ -341,4 +343,8 @@ bool RtpDataMediaChannel::SendData(
|
||||
return true;
|
||||
}
|
||||
|
||||
rtc::DiffServCodePoint RtpDataMediaChannel::PreferredDscp() const {
|
||||
return rtc::DSCP_AF41;
|
||||
}
|
||||
|
||||
} // namespace cricket
|
||||
|
||||
@ -27,7 +27,8 @@ class RtpDataEngine : public DataEngineInterface {
|
||||
public:
|
||||
RtpDataEngine();
|
||||
|
||||
virtual DataMediaChannel* CreateChannel(DataChannelType data_channel_type);
|
||||
virtual DataMediaChannel* CreateChannel(DataChannelType data_channel_type,
|
||||
const MediaConfig& config);
|
||||
|
||||
virtual const std::vector<DataCodec>& data_codecs() {
|
||||
return data_codecs_;
|
||||
@ -61,7 +62,7 @@ class RtpClock {
|
||||
|
||||
class RtpDataMediaChannel : public DataMediaChannel {
|
||||
public:
|
||||
RtpDataMediaChannel();
|
||||
RtpDataMediaChannel(const MediaConfig& config);
|
||||
virtual ~RtpDataMediaChannel();
|
||||
|
||||
virtual bool SetSendParameters(const DataSendParameters& params);
|
||||
@ -88,6 +89,7 @@ class RtpDataMediaChannel : public DataMediaChannel {
|
||||
const SendDataParams& params,
|
||||
const rtc::CopyOnWriteBuffer& payload,
|
||||
SendDataResult* result);
|
||||
virtual rtc::DiffServCodePoint PreferredDscp() const;
|
||||
|
||||
private:
|
||||
void Construct();
|
||||
|
||||
@ -70,9 +70,10 @@ class RtpDataMediaChannelTest : public testing::Test {
|
||||
}
|
||||
|
||||
cricket::RtpDataMediaChannel* CreateChannel(cricket::RtpDataEngine* dme) {
|
||||
cricket::MediaConfig config;
|
||||
cricket::RtpDataMediaChannel* channel =
|
||||
static_cast<cricket::RtpDataMediaChannel*>(dme->CreateChannel(
|
||||
cricket::DCT_RTP));
|
||||
static_cast<cricket::RtpDataMediaChannel*>(
|
||||
dme->CreateChannel(cricket::DCT_RTP, config));
|
||||
channel->SetInterface(iface_.get());
|
||||
channel->SignalDataReceived.connect(
|
||||
receiver_.get(), &FakeDataReceiver::OnDataReceived);
|
||||
|
||||
@ -333,11 +333,12 @@ SctpDataEngine::~SctpDataEngine() {}
|
||||
|
||||
// Called on the worker thread.
|
||||
DataMediaChannel* SctpDataEngine::CreateChannel(
|
||||
DataChannelType data_channel_type) {
|
||||
DataChannelType data_channel_type,
|
||||
const MediaConfig& config) {
|
||||
if (data_channel_type != DCT_SCTP) {
|
||||
return NULL;
|
||||
}
|
||||
return new SctpDataMediaChannel(rtc::Thread::Current());
|
||||
return new SctpDataMediaChannel(rtc::Thread::Current(), config);
|
||||
}
|
||||
|
||||
// static
|
||||
@ -378,15 +379,16 @@ int SctpDataMediaChannel::SendThresholdCallback(struct socket* sock,
|
||||
return 0;
|
||||
}
|
||||
|
||||
SctpDataMediaChannel::SctpDataMediaChannel(rtc::Thread* thread)
|
||||
: worker_thread_(thread),
|
||||
SctpDataMediaChannel::SctpDataMediaChannel(rtc::Thread* thread,
|
||||
const MediaConfig& config)
|
||||
: DataMediaChannel(config),
|
||||
worker_thread_(thread),
|
||||
local_port_(kSctpDefaultPort),
|
||||
remote_port_(kSctpDefaultPort),
|
||||
sock_(NULL),
|
||||
sending_(false),
|
||||
receiving_(false),
|
||||
debug_name_("SctpDataMediaChannel") {
|
||||
}
|
||||
debug_name_("SctpDataMediaChannel") {}
|
||||
|
||||
SctpDataMediaChannel::~SctpDataMediaChannel() {
|
||||
CloseSctpSocket();
|
||||
|
||||
@ -88,7 +88,8 @@ class SctpDataEngine : public DataEngineInterface, public sigslot::has_slots<> {
|
||||
SctpDataEngine();
|
||||
~SctpDataEngine() override;
|
||||
|
||||
DataMediaChannel* CreateChannel(DataChannelType data_channel_type) override;
|
||||
DataMediaChannel* CreateChannel(DataChannelType data_channel_type,
|
||||
const MediaConfig& config) override;
|
||||
const std::vector<DataCodec>& data_codecs() override { return codecs_; }
|
||||
|
||||
private:
|
||||
@ -125,7 +126,7 @@ class SctpDataMediaChannel : public DataMediaChannel,
|
||||
|
||||
// Given a thread which will be used to post messages (received data) to this
|
||||
// SctpDataMediaChannel instance.
|
||||
explicit SctpDataMediaChannel(rtc::Thread* thread);
|
||||
explicit SctpDataMediaChannel(rtc::Thread* thread, const MediaConfig& config);
|
||||
virtual ~SctpDataMediaChannel();
|
||||
|
||||
// When SetSend is set to true, connects. When set to false, disconnects.
|
||||
|
||||
@ -265,8 +265,9 @@ class SctpDataMediaChannelTest : public testing::Test,
|
||||
|
||||
SctpDataMediaChannel* CreateChannel(SctpFakeNetworkInterface* net,
|
||||
SctpFakeDataReceiver* recv) {
|
||||
SctpDataMediaChannel* channel =
|
||||
static_cast<SctpDataMediaChannel*>(engine_->CreateChannel(DCT_SCTP));
|
||||
cricket::MediaConfig config;
|
||||
SctpDataMediaChannel* channel = static_cast<SctpDataMediaChannel*>(
|
||||
engine_->CreateChannel(DCT_SCTP, config));
|
||||
channel->SetInterface(net);
|
||||
// When data is received, pass it to the SctpFakeDataReceiver.
|
||||
channel->SignalDataReceived.connect(
|
||||
|
||||
@ -346,10 +346,22 @@ DataChannel* ChannelManager::CreateDataChannel(
|
||||
const std::string* bundle_transport_name,
|
||||
bool rtcp,
|
||||
DataChannelType channel_type) {
|
||||
return CreateDataChannel(transport_controller, nullptr, content_name,
|
||||
bundle_transport_name, rtcp, channel_type);
|
||||
}
|
||||
|
||||
DataChannel* ChannelManager::CreateDataChannel(
|
||||
TransportController* transport_controller,
|
||||
webrtc::MediaControllerInterface* media_controller,
|
||||
const std::string& content_name,
|
||||
const std::string* bundle_transport_name,
|
||||
bool rtcp,
|
||||
DataChannelType channel_type) {
|
||||
return worker_thread_->Invoke<DataChannel*>(
|
||||
RTC_FROM_HERE,
|
||||
Bind(&ChannelManager::CreateDataChannel_w, this, transport_controller,
|
||||
content_name, bundle_transport_name, rtcp, channel_type));
|
||||
content_name, bundle_transport_name, rtcp, channel_type,
|
||||
media_controller));
|
||||
}
|
||||
|
||||
DataChannel* ChannelManager::CreateDataChannel_w(
|
||||
@ -357,11 +369,16 @@ DataChannel* ChannelManager::CreateDataChannel_w(
|
||||
const std::string& content_name,
|
||||
const std::string* bundle_transport_name,
|
||||
bool rtcp,
|
||||
DataChannelType data_channel_type) {
|
||||
DataChannelType data_channel_type,
|
||||
webrtc::MediaControllerInterface* media_controller) {
|
||||
// This is ok to alloc from a thread other than the worker thread.
|
||||
ASSERT(initialized_);
|
||||
DataMediaChannel* media_channel = data_media_engine_->CreateChannel(
|
||||
data_channel_type);
|
||||
MediaConfig config;
|
||||
if (media_controller) {
|
||||
config = media_controller->config();
|
||||
}
|
||||
DataMediaChannel* media_channel =
|
||||
data_media_engine_->CreateChannel(data_channel_type, config);
|
||||
if (!media_channel) {
|
||||
LOG(LS_WARNING) << "Failed to create data channel of type "
|
||||
<< data_channel_type;
|
||||
|
||||
@ -113,6 +113,13 @@ class ChannelManager {
|
||||
const std::string* bundle_transport_name,
|
||||
bool rtcp,
|
||||
DataChannelType data_channel_type);
|
||||
DataChannel* CreateDataChannel(
|
||||
TransportController* transport_controller,
|
||||
webrtc::MediaControllerInterface* media_controller,
|
||||
const std::string& content_name,
|
||||
const std::string* bundle_transport_name,
|
||||
bool rtcp,
|
||||
DataChannelType data_channel_type);
|
||||
// Destroys a data channel created with the Create API.
|
||||
void DestroyDataChannel(DataChannel* data_channel);
|
||||
|
||||
@ -171,11 +178,13 @@ class ChannelManager {
|
||||
bool rtcp,
|
||||
const VideoOptions& options);
|
||||
void DestroyVideoChannel_w(VideoChannel* video_channel);
|
||||
DataChannel* CreateDataChannel_w(TransportController* transport_controller,
|
||||
const std::string& content_name,
|
||||
const std::string* bundle_transport_name,
|
||||
bool rtcp,
|
||||
DataChannelType data_channel_type);
|
||||
DataChannel* CreateDataChannel_w(
|
||||
TransportController* transport_controller,
|
||||
const std::string& content_name,
|
||||
const std::string* bundle_transport_name,
|
||||
bool rtcp,
|
||||
DataChannelType data_channel_type,
|
||||
webrtc::MediaControllerInterface* media_controller);
|
||||
void DestroyDataChannel_w(DataChannel* data_channel);
|
||||
|
||||
std::unique_ptr<MediaEngineInterface> media_engine_;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user