#include "pc/channel.h"
#include <algorithm>
#include <cstdint>
#include <string>
#include <type_traits>
#include <utility>
#include "absl/algorithm/container.h"
#include "absl/strings/string_view.h"
#include "api/rtp_parameters.h"
#include "api/sequence_checker.h"
#include "api/task_queue/pending_task_safety_flag.h"
#include "api/units/timestamp.h"
#include "media/base/codec.h"
#include "media/base/rid_description.h"
#include "media/base/rtp_utils.h"
#include "modules/rtp_rtcp/source/rtp_packet_received.h"
#include "p2p/base/dtls_transport_internal.h"
#include "pc/rtp_media_utils.h"
#include "rtc_base/checks.h"
#include "rtc_base/copy_on_write_buffer.h"
#include "rtc_base/logging.h"
#include "rtc_base/network_route.h"
#include "rtc_base/strings/string_format.h"
#include "rtc_base/trace_event.h"
namespace cricket {
namespace {
StringFormat;
UniqueRandomIdGenerator;
PendingTaskSafetyFlag;
SdpType;
struct StreamFinder { … };
}
void MediaChannelParametersFromMediaDescription(
const MediaContentDescription* desc,
const RtpHeaderExtensions& extensions,
bool is_stream_active,
MediaChannelParameters* params) { … }
void RtpSendParametersFromMediaDescription(
const MediaContentDescription* desc,
webrtc::RtpExtension::Filter extensions_filter,
SenderParameters* send_params) { … }
BaseChannel::BaseChannel(
webrtc::TaskQueueBase* worker_thread,
rtc::Thread* network_thread,
webrtc::TaskQueueBase* signaling_thread,
std::unique_ptr<MediaSendChannelInterface> send_media_channel_impl,
std::unique_ptr<MediaReceiveChannelInterface> receive_media_channel_impl,
absl::string_view mid,
bool srtp_required,
webrtc::CryptoOptions crypto_options,
UniqueRandomIdGenerator* ssrc_generator)
: … { … }
BaseChannel::~BaseChannel() { … }
std::string BaseChannel::ToString() const { … }
bool BaseChannel::ConnectToRtpTransport_n() { … }
void BaseChannel::DisconnectFromRtpTransport_n() { … }
bool BaseChannel::SetRtpTransport(webrtc::RtpTransportInternal* rtp_transport) { … }
void BaseChannel::Enable(bool enable) { … }
bool BaseChannel::SetLocalContent(const MediaContentDescription* content,
SdpType type,
std::string& error_desc) { … }
bool BaseChannel::SetRemoteContent(const MediaContentDescription* content,
SdpType type,
std::string& error_desc) { … }
bool BaseChannel::SetPayloadTypeDemuxingEnabled(bool enabled) { … }
bool BaseChannel::IsReadyToSendMedia_w() const { … }
bool BaseChannel::SendPacket(rtc::CopyOnWriteBuffer* packet,
const rtc::PacketOptions& options) { … }
bool BaseChannel::SendRtcp(rtc::CopyOnWriteBuffer* packet,
const rtc::PacketOptions& options) { … }
int BaseChannel::SetOption(SocketType type,
rtc::Socket::Option opt,
int value) { … }
void BaseChannel::OnWritableState(bool writable) { … }
void BaseChannel::OnNetworkRouteChanged(
absl::optional<rtc::NetworkRoute> network_route) { … }
void BaseChannel::SetFirstPacketReceivedCallback(
std::function<void()> callback) { … }
void BaseChannel::OnTransportReadyToSend(bool ready) { … }
bool BaseChannel::SendPacket(bool rtcp,
rtc::CopyOnWriteBuffer* packet,
const rtc::PacketOptions& options) { … }
void BaseChannel::OnRtpPacket(const webrtc::RtpPacketReceived& parsed_packet) { … }
bool BaseChannel::MaybeUpdateDemuxerAndRtpExtensions_w(
bool update_demuxer,
absl::optional<RtpHeaderExtensions> extensions,
std::string& error_desc) { … }
bool BaseChannel::RegisterRtpDemuxerSink_w() { … }
void BaseChannel::EnableMedia_w() { … }
void BaseChannel::DisableMedia_w() { … }
void BaseChannel::UpdateWritableState_n() { … }
void BaseChannel::ChannelWritable_n() { … }
void BaseChannel::ChannelNotWritable_n() { … }
bool BaseChannel::SetPayloadTypeDemuxingEnabled_w(bool enabled) { … }
bool BaseChannel::UpdateLocalStreams_w(const std::vector<StreamParams>& streams,
SdpType type,
std::string& error_desc) { … }
bool BaseChannel::UpdateRemoteStreams_w(const MediaContentDescription* content,
SdpType type,
std::string& error_desc) { … }
RtpHeaderExtensions BaseChannel::GetDeduplicatedRtpHeaderExtensions(
const RtpHeaderExtensions& extensions) { … }
bool BaseChannel::MaybeAddHandledPayloadType(int payload_type) { … }
bool BaseChannel::ClearHandledPayloadTypes() { … }
void BaseChannel::SignalSentPacket_n(const rtc::SentPacket& sent_packet) { … }
VoiceChannel::VoiceChannel(
webrtc::TaskQueueBase* worker_thread,
rtc::Thread* network_thread,
webrtc::TaskQueueBase* signaling_thread,
std::unique_ptr<VoiceMediaSendChannelInterface> media_send_channel,
std::unique_ptr<VoiceMediaReceiveChannelInterface> media_receive_channel,
absl::string_view mid,
bool srtp_required,
webrtc::CryptoOptions crypto_options,
UniqueRandomIdGenerator* ssrc_generator)
: … { … }
VoiceChannel::~VoiceChannel() { … }
void VoiceChannel::UpdateMediaSendRecvState_w() { … }
bool VoiceChannel::SetLocalContent_w(const MediaContentDescription* content,
SdpType type,
std::string& error_desc) { … }
bool VoiceChannel::SetRemoteContent_w(const MediaContentDescription* content,
SdpType type,
std::string& error_desc) { … }
VideoChannel::VideoChannel(
webrtc::TaskQueueBase* worker_thread,
rtc::Thread* network_thread,
webrtc::TaskQueueBase* signaling_thread,
std::unique_ptr<VideoMediaSendChannelInterface> media_send_channel,
std::unique_ptr<VideoMediaReceiveChannelInterface> media_receive_channel,
absl::string_view mid,
bool srtp_required,
webrtc::CryptoOptions crypto_options,
UniqueRandomIdGenerator* ssrc_generator)
: … { … }
VideoChannel::~VideoChannel() { … }
void VideoChannel::UpdateMediaSendRecvState_w() { … }
bool VideoChannel::SetLocalContent_w(const MediaContentDescription* content,
SdpType type,
std::string& error_desc) { … }
bool VideoChannel::SetRemoteContent_w(const MediaContentDescription* content,
SdpType type,
std::string& error_desc) { … }
}