Move RTP module send status outside of ViEChannel.
Removes StartSend, StopSend and SetSendCodec from ViEChannel and into VideoSendStream which uses the payload router to configure them directly. BUG=webrtc:5494 R=stefan@webrtc.org Review URL: https://codereview.webrtc.org/1758603003 . Cr-Commit-Position: refs/heads/master@{#11845}
This commit is contained in:
parent
7b19b08c18
commit
0a9fc05583
@ -333,18 +333,21 @@ VideoCaptureInput* VideoSendStream::Input() {
|
||||
}
|
||||
|
||||
void VideoSendStream::Start() {
|
||||
if (payload_router_.active())
|
||||
return;
|
||||
vie_encoder_.Pause();
|
||||
if (vie_channel_.StartSend() == 0) {
|
||||
// Was not already started, trigger a keyframe.
|
||||
vie_encoder_.SendKeyFrame();
|
||||
}
|
||||
payload_router_.set_active(true);
|
||||
// Was not already started, trigger a keyframe.
|
||||
vie_encoder_.SendKeyFrame();
|
||||
vie_encoder_.Restart();
|
||||
vie_receiver_->StartReceive();
|
||||
}
|
||||
|
||||
void VideoSendStream::Stop() {
|
||||
if (!payload_router_.active())
|
||||
return;
|
||||
// TODO(pbos): Make sure the encoder stops here.
|
||||
vie_channel_.StopSend();
|
||||
payload_router_.set_active(false);
|
||||
vie_receiver_->StopReceive();
|
||||
}
|
||||
|
||||
@ -613,10 +616,10 @@ bool VideoSendStream::SetSendCodec(VideoCodec video_codec) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (vie_channel_.SetSendCodec(video_codec, false) != 0) {
|
||||
LOG(LS_ERROR) << "Failed to set send codec.";
|
||||
return false;
|
||||
}
|
||||
size_t num_streams = video_codec.numberOfSimulcastStreams > 0
|
||||
? video_codec.numberOfSimulcastStreams
|
||||
: 1;
|
||||
payload_router_.SetSendingRtpModules(num_streams);
|
||||
|
||||
// Restart the media flow
|
||||
vie_encoder_.Restart();
|
||||
|
||||
@ -176,40 +176,6 @@ ViEChannel::~ViEChannel() {
|
||||
}
|
||||
}
|
||||
|
||||
int32_t ViEChannel::SetSendCodec(const VideoCodec& video_codec,
|
||||
bool new_stream) {
|
||||
RTC_DCHECK(sender_);
|
||||
if (video_codec.codecType == kVideoCodecRED ||
|
||||
video_codec.codecType == kVideoCodecULPFEC) {
|
||||
LOG_F(LS_ERROR) << "Not a valid send codec " << video_codec.codecType;
|
||||
return -1;
|
||||
}
|
||||
if (kMaxSimulcastStreams < video_codec.numberOfSimulcastStreams) {
|
||||
LOG_F(LS_ERROR) << "Incorrect config "
|
||||
<< video_codec.numberOfSimulcastStreams;
|
||||
return -1;
|
||||
}
|
||||
// Update the RTP module with the settings.
|
||||
// Stop and Start the RTP module -> trigger new SSRC, if an SSRC hasn't been
|
||||
// set explicitly.
|
||||
// The first layer is always active, so the first module can be checked for
|
||||
// sending status.
|
||||
bool is_sending = rtp_rtcp_modules_[0]->Sending();
|
||||
send_payload_router_->set_active(false);
|
||||
send_payload_router_->SetSendingRtpModules(0);
|
||||
|
||||
size_t num_active_modules = video_codec.numberOfSimulcastStreams > 0
|
||||
? video_codec.numberOfSimulcastStreams
|
||||
: 1;
|
||||
|
||||
// Update the packet and payload routers with the sending RtpRtcp modules.
|
||||
send_payload_router_->SetSendingRtpModules(num_active_modules);
|
||||
|
||||
send_payload_router_->set_active(is_sending);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void ViEChannel::SetProtectionMode(bool enable_nack,
|
||||
bool enable_fec,
|
||||
int payload_type_red,
|
||||
@ -326,31 +292,6 @@ void ViEChannel::RegisterSendBitrateObserver(
|
||||
send_bitrate_observer_.Set(observer);
|
||||
}
|
||||
|
||||
int32_t ViEChannel::StartSend() {
|
||||
if (rtp_rtcp_modules_[0]->Sending())
|
||||
return -1;
|
||||
|
||||
if (!sender_) {
|
||||
rtp_rtcp_modules_[0]->SetSendingStatus(true);
|
||||
} else {
|
||||
send_payload_router_->set_active(true);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int32_t ViEChannel::StopSend() {
|
||||
if (!rtp_rtcp_modules_[0]->Sending())
|
||||
return -1;
|
||||
|
||||
if (!sender_) {
|
||||
rtp_rtcp_modules_[0]->SetSendingStatus(false);
|
||||
} else {
|
||||
send_payload_router_->set_active(false);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
const std::vector<RtpRtcp*>& ViEChannel::rtp_rtcp() const {
|
||||
return rtp_rtcp_modules_;
|
||||
}
|
||||
|
||||
@ -80,10 +80,6 @@ class ViEChannel : public VCMFrameTypeCallback,
|
||||
|
||||
int32_t Init();
|
||||
|
||||
// Sets the encoder to use for the channel. |new_stream| indicates the encoder
|
||||
// type has changed and we should start a new RTP stream.
|
||||
int32_t SetSendCodec(const VideoCodec& video_codec, bool new_stream = true);
|
||||
|
||||
void SetProtectionMode(bool enable_nack,
|
||||
bool enable_fec,
|
||||
int payload_type_red,
|
||||
@ -109,9 +105,6 @@ class ViEChannel : public VCMFrameTypeCallback,
|
||||
void OnIncomingSSRCChanged(const uint32_t ssrc) override;
|
||||
void OnIncomingCSRCChanged(const uint32_t CSRC, const bool added) override;
|
||||
|
||||
int32_t StartSend();
|
||||
int32_t StopSend();
|
||||
|
||||
// Gets the modules used by the channel.
|
||||
const std::vector<RtpRtcp*>& rtp_rtcp() const;
|
||||
ViEReceiver* vie_receiver();
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user