aboutsummaryrefslogtreecommitdiff
path: root/media/base/media_channel.h
diff options
context:
space:
mode:
Diffstat (limited to 'media/base/media_channel.h')
-rw-r--r--media/base/media_channel.h87
1 files changed, 34 insertions, 53 deletions
diff --git a/media/base/media_channel.h b/media/base/media_channel.h
index d71ec9158a..e8400a58a9 100644
--- a/media/base/media_channel.h
+++ b/media/base/media_channel.h
@@ -26,7 +26,6 @@
#include "api/media_stream_interface.h"
#include "api/rtc_error.h"
#include "api/rtp_parameters.h"
-#include "api/transport/media/media_transport_config.h"
#include "api/transport/rtp/rtp_source.h"
#include "api/video/video_content_type.h"
#include "api/video/video_sink_interface.h"
@@ -46,13 +45,13 @@
#include "rtc_base/buffer.h"
#include "rtc_base/callback.h"
#include "rtc_base/copy_on_write_buffer.h"
-#include "rtc_base/critical_section.h"
#include "rtc_base/dscp.h"
#include "rtc_base/logging.h"
#include "rtc_base/network_route.h"
#include "rtc_base/socket.h"
#include "rtc_base/string_encode.h"
#include "rtc_base/strings/string_builder.h"
+#include "rtc_base/synchronization/mutex.h"
#include "rtc_base/third_party/sigslot/sigslot.h"
namespace rtc {
@@ -156,24 +155,6 @@ struct VideoOptions {
}
};
-// TODO(isheriff): Remove this once client usage is fixed to use RtpExtension.
-struct RtpHeaderExtension {
- RtpHeaderExtension() : id(0) {}
- RtpHeaderExtension(const std::string& uri, int id) : uri(uri), id(id) {}
-
- std::string ToString() const {
- rtc::StringBuilder ost;
- ost << "{";
- ost << "uri: " << uri;
- ost << ", id: " << id;
- ost << "}";
- return ost.Release();
- }
-
- std::string uri;
- int id;
-};
-
class MediaChannel : public sigslot::has_slots<> {
public:
class NetworkInterface {
@@ -195,15 +176,9 @@ class MediaChannel : public sigslot::has_slots<> {
virtual cricket::MediaType media_type() const = 0;
- // Sets the abstract interface class for sending RTP/RTCP data and
- // interface for media transport (experimental). If media transport is
- // provided, it should be used instead of RTP/RTCP.
- // TODO(sukhanov): Currently media transport can co-exist with RTP/RTCP, but
- // in the future we will refactor code to send all frames with media
- // transport.
- virtual void SetInterface(
- NetworkInterface* iface,
- const webrtc::MediaTransportConfig& media_transport_config);
+ // Sets the abstract interface class for sending RTP/RTCP data.
+ virtual void SetInterface(NetworkInterface* iface)
+ RTC_LOCKS_EXCLUDED(network_interface_mutex_);
// Called when a RTP packet is received.
virtual void OnPacketReceived(rtc::CopyOnWriteBuffer packet,
int64_t packet_time_us) = 0;
@@ -264,16 +239,9 @@ class MediaChannel : public sigslot::has_slots<> {
int SetOption(NetworkInterface::SocketType type,
rtc::Socket::Option opt,
- int option) {
- rtc::CritScope cs(&network_interface_crit_);
- if (!network_interface_)
- return -1;
-
- return network_interface_->SetOption(type, opt, option);
- }
-
- const webrtc::MediaTransportConfig& media_transport_config() const {
- return media_transport_config_;
+ int option) RTC_LOCKS_EXCLUDED(network_interface_mutex_) {
+ webrtc::MutexLock lock(&network_interface_mutex_);
+ return SetOptionLocked(type, opt, option);
}
// Corresponds to the SDP attribute extmap-allow-mixed, see RFC8285.
@@ -298,17 +266,28 @@ class MediaChannel : public sigslot::has_slots<> {
rtc::scoped_refptr<webrtc::FrameTransformerInterface> frame_transformer);
protected:
+ int SetOptionLocked(NetworkInterface::SocketType type,
+ rtc::Socket::Option opt,
+ int option)
+ RTC_EXCLUSIVE_LOCKS_REQUIRED(network_interface_mutex_) {
+ if (!network_interface_)
+ return -1;
+ return network_interface_->SetOption(type, opt, option);
+ }
+
bool DscpEnabled() const { return enable_dscp_; }
// This is the DSCP value used for both RTP and RTCP channels if DSCP is
// enabled. It can be changed at any time via |SetPreferredDscp|.
- rtc::DiffServCodePoint PreferredDscp() const {
- rtc::CritScope cs(&network_interface_crit_);
+ rtc::DiffServCodePoint PreferredDscp() const
+ RTC_LOCKS_EXCLUDED(network_interface_mutex_) {
+ webrtc::MutexLock lock(&network_interface_mutex_);
return preferred_dscp_;
}
- int SetPreferredDscp(rtc::DiffServCodePoint preferred_dscp) {
- rtc::CritScope cs(&network_interface_crit_);
+ int SetPreferredDscp(rtc::DiffServCodePoint preferred_dscp)
+ RTC_LOCKS_EXCLUDED(network_interface_mutex_) {
+ webrtc::MutexLock lock(&network_interface_mutex_);
if (preferred_dscp == preferred_dscp_) {
return 0;
}
@@ -319,20 +298,23 @@ class MediaChannel : public sigslot::has_slots<> {
private:
// Apply the preferred DSCP setting to the underlying network interface RTP
// and RTCP channels. If DSCP is disabled, then apply the default DSCP value.
- int UpdateDscp() RTC_EXCLUSIVE_LOCKS_REQUIRED(network_interface_crit_) {
+ int UpdateDscp() RTC_EXCLUSIVE_LOCKS_REQUIRED(network_interface_mutex_) {
rtc::DiffServCodePoint value =
enable_dscp_ ? preferred_dscp_ : rtc::DSCP_DEFAULT;
- int ret = SetOption(NetworkInterface::ST_RTP, rtc::Socket::OPT_DSCP, value);
+ int ret =
+ SetOptionLocked(NetworkInterface::ST_RTP, rtc::Socket::OPT_DSCP, value);
if (ret == 0) {
- ret = SetOption(NetworkInterface::ST_RTCP, rtc::Socket::OPT_DSCP, value);
+ ret = SetOptionLocked(NetworkInterface::ST_RTCP, rtc::Socket::OPT_DSCP,
+ value);
}
return ret;
}
bool DoSendPacket(rtc::CopyOnWriteBuffer* packet,
bool rtcp,
- const rtc::PacketOptions& options) {
- rtc::CritScope cs(&network_interface_crit_);
+ const rtc::PacketOptions& options)
+ RTC_LOCKS_EXCLUDED(network_interface_mutex_) {
+ webrtc::MutexLock lock(&network_interface_mutex_);
if (!network_interface_)
return false;
@@ -344,12 +326,11 @@ class MediaChannel : public sigslot::has_slots<> {
// |network_interface_| can be accessed from the worker_thread and
// from any MediaEngine threads. This critical section is to protect accessing
// of network_interface_ object.
- rtc::CriticalSection network_interface_crit_;
- NetworkInterface* network_interface_ RTC_GUARDED_BY(network_interface_crit_) =
- nullptr;
+ mutable webrtc::Mutex network_interface_mutex_;
+ NetworkInterface* network_interface_
+ RTC_GUARDED_BY(network_interface_mutex_) = nullptr;
rtc::DiffServCodePoint preferred_dscp_
- RTC_GUARDED_BY(network_interface_crit_) = rtc::DSCP_DEFAULT;
- webrtc::MediaTransportConfig media_transport_config_;
+ RTC_GUARDED_BY(network_interface_mutex_) = rtc::DSCP_DEFAULT;
bool extmap_allow_mixed_ = false;
};