webrtc_m130/media/base/media_channel.cc
Amit Hilbuch ea7ef2ad1d Refactoring RtpSenderInternal to share implementation for Audio & Video.
Most of the implementation in rtp_sender.cc is a copy paste for both
Audio & Video RTP senders. This change moves all the common behavior
into the base RtpSenderInternal class.
Template method pattern is used to accomodate for the very slight differences
between audio and video senders.

Bug: None
Change-Id: I6d4e93cd32fbb0fb361fd0e1883791019bde9a92
Reviewed-on: https://webrtc-review.googlesource.com/c/123411
Reviewed-by: Steve Anton <steveanton@webrtc.org>
Reviewed-by: Seth Hampson <shampson@webrtc.org>
Commit-Queue: Amit Hilbuch <amithi@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#26758}
2019-02-20 01:23:04 +00:00

135 lines
4.1 KiB
C++

/*
* Copyright (c) 2018 The WebRTC project authors. All Rights Reserved.
*
* Use of this source code is governed by a BSD-style license
* that can be found in the LICENSE file in the root of the source
* tree. An additional intellectual property rights grant can be found
* in the file PATENTS. All contributing project authors may
* be found in the AUTHORS file in the root of the source tree.
*/
#include "media/base/media_channel.h"
namespace cricket {
VideoOptions::VideoOptions() = default;
VideoOptions::~VideoOptions() = default;
MediaChannel::MediaChannel(const MediaConfig& config)
: enable_dscp_(config.enable_dscp) {}
MediaChannel::MediaChannel() : enable_dscp_(false) {}
MediaChannel::~MediaChannel() {}
void MediaChannel::SetInterface(
NetworkInterface* iface,
webrtc::MediaTransportInterface* media_transport) {
rtc::CritScope cs(&network_interface_crit_);
network_interface_ = iface;
media_transport_ = media_transport;
UpdateDscp();
}
int MediaChannel::GetRtpSendTimeExtnId() const {
return -1;
}
rtc::DiffServCodePoint MediaChannel::PreferredDscp() const {
return rtc::DSCP_DEFAULT;
}
void MediaChannel::SetFrameEncryptor(
uint32_t ssrc,
rtc::scoped_refptr<webrtc::FrameEncryptorInterface> frame_encryptor) {
// Placeholder should be pure virtual once internal supports it.
}
void MediaChannel::SetFrameDecryptor(
uint32_t ssrc,
rtc::scoped_refptr<webrtc::FrameDecryptorInterface> frame_decryptor) {
// Placeholder should be pure virtual once internal supports it.
}
MediaSenderInfo::MediaSenderInfo() = default;
MediaSenderInfo::~MediaSenderInfo() = default;
MediaReceiverInfo::MediaReceiverInfo() = default;
MediaReceiverInfo::~MediaReceiverInfo() = default;
VoiceSenderInfo::VoiceSenderInfo() = default;
VoiceSenderInfo::~VoiceSenderInfo() = default;
VoiceReceiverInfo::VoiceReceiverInfo() = default;
VoiceReceiverInfo::~VoiceReceiverInfo() = default;
VideoSenderInfo::VideoSenderInfo() = default;
VideoSenderInfo::~VideoSenderInfo() = default;
VideoReceiverInfo::VideoReceiverInfo() = default;
VideoReceiverInfo::~VideoReceiverInfo() = default;
VoiceMediaInfo::VoiceMediaInfo() = default;
VoiceMediaInfo::~VoiceMediaInfo() = default;
VideoMediaInfo::VideoMediaInfo() = default;
VideoMediaInfo::~VideoMediaInfo() = default;
DataMediaInfo::DataMediaInfo() = default;
DataMediaInfo::~DataMediaInfo() = default;
AudioSendParameters::AudioSendParameters() = default;
AudioSendParameters::~AudioSendParameters() = default;
std::map<std::string, std::string> AudioSendParameters::ToStringMap() const {
auto params = RtpSendParameters<AudioCodec>::ToStringMap();
params["options"] = options.ToString();
return params;
}
cricket::MediaType VoiceMediaChannel::media_type() const {
return cricket::MediaType::MEDIA_TYPE_AUDIO;
}
VideoSendParameters::VideoSendParameters() = default;
VideoSendParameters::~VideoSendParameters() = default;
std::map<std::string, std::string> VideoSendParameters::ToStringMap() const {
auto params = RtpSendParameters<VideoCodec>::ToStringMap();
params["conference_mode"] = (conference_mode ? "yes" : "no");
return params;
}
cricket::MediaType VideoMediaChannel::media_type() const {
return cricket::MediaType::MEDIA_TYPE_VIDEO;
}
DataMediaChannel::DataMediaChannel() = default;
DataMediaChannel::DataMediaChannel(const MediaConfig& config)
: MediaChannel(config) {}
DataMediaChannel::~DataMediaChannel() = default;
webrtc::RtpParameters DataMediaChannel::GetRtpSendParameters(
uint32_t ssrc) const {
// GetRtpSendParameters is not supported for DataMediaChannel.
RTC_NOTREACHED();
return webrtc::RtpParameters();
}
webrtc::RTCError DataMediaChannel::SetRtpSendParameters(
uint32_t ssrc,
const webrtc::RtpParameters& parameters) {
// SetRtpSendParameters is not supported for DataMediaChannel.
RTC_NOTREACHED();
return webrtc::RTCError(webrtc::RTCErrorType::UNSUPPORTED_OPERATION);
}
cricket::MediaType DataMediaChannel::media_type() const {
return cricket::MediaType::MEDIA_TYPE_DATA;
}
bool DataMediaChannel::GetStats(DataMediaInfo* info) {
return true;
}
} // namespace cricket