Remove decoder-thread instantiation for senders.

Reduces number of running (high-priority) threads, even though the
thread was practically blocked all the time.

Also adding DCHECKs to make sure we're not trying to use certain
sender-only methods on receivers and vice versa.

BUG=webrtc:1675, webrtc:1695
R=stefan@webrtc.org

Review URL: https://codereview.webrtc.org/1222193003

Cr-Commit-Position: refs/heads/master@{#9534}
This commit is contained in:
pbos 2015-07-02 06:32:17 -07:00 committed by Commit bot
parent db0cf7624e
commit cd4a9bd225
2 changed files with 23 additions and 31 deletions

View File

@ -347,9 +347,7 @@ void ViEChannel::UpdateHistogramsAtStopSend() {
int32_t ViEChannel::SetSendCodec(const VideoCodec& video_codec, int32_t ViEChannel::SetSendCodec(const VideoCodec& video_codec,
bool new_stream) { bool new_stream) {
if (!sender_) { DCHECK(sender_);
return 0;
}
if (video_codec.codecType == kVideoCodecRED || if (video_codec.codecType == kVideoCodecRED ||
video_codec.codecType == kVideoCodecULPFEC) { video_codec.codecType == kVideoCodecULPFEC) {
LOG_F(LS_ERROR) << "Not a valid send codec " << video_codec.codecType; LOG_F(LS_ERROR) << "Not a valid send codec " << video_codec.codecType;
@ -571,6 +569,7 @@ int32_t ViEChannel::SetSendCodec(const VideoCodec& video_codec,
} }
int32_t ViEChannel::SetReceiveCodec(const VideoCodec& video_codec) { int32_t ViEChannel::SetReceiveCodec(const VideoCodec& video_codec) {
DCHECK(!sender_);
if (!vie_receiver_.SetReceiveCodec(video_codec)) { if (!vie_receiver_.SetReceiveCodec(video_codec)) {
return -1; return -1;
} }
@ -604,6 +603,7 @@ int32_t ViEChannel::RegisterExternalDecoder(const uint8_t pl_type,
VideoDecoder* decoder, VideoDecoder* decoder,
bool buffered_rendering, bool buffered_rendering,
int32_t render_delay) { int32_t render_delay) {
DCHECK(!sender_);
int32_t result; int32_t result;
result = vcm_->RegisterExternalDecoder(decoder, pl_type, buffered_rendering); result = vcm_->RegisterExternalDecoder(decoder, pl_type, buffered_rendering);
if (result != VCM_OK) { if (result != VCM_OK) {
@ -613,6 +613,7 @@ int32_t ViEChannel::RegisterExternalDecoder(const uint8_t pl_type,
} }
int32_t ViEChannel::DeRegisterExternalDecoder(const uint8_t pl_type) { int32_t ViEChannel::DeRegisterExternalDecoder(const uint8_t pl_type) {
DCHECK(!sender_);
VideoCodec current_receive_codec; VideoCodec current_receive_codec;
int32_t result = 0; int32_t result = 0;
result = vcm_->ReceiveCodec(&current_receive_codec); result = vcm_->ReceiveCodec(&current_receive_codec);
@ -1368,20 +1369,18 @@ bool ViEChannel::Sending() {
return rtp_rtcp_->Sending(); return rtp_rtcp_->Sending();
} }
int32_t ViEChannel::StartReceive() { void ViEChannel::StartReceive() {
if (StartDecodeThread() != 0) { if (!sender_)
vie_receiver_.StopReceive(); StartDecodeThread();
return -1;
}
vie_receiver_.StartReceive(); vie_receiver_.StartReceive();
return 0;
} }
int32_t ViEChannel::StopReceive() { void ViEChannel::StopReceive() {
vie_receiver_.StopReceive(); vie_receiver_.StopReceive();
if (!sender_) {
StopDecodeThread(); StopDecodeThread();
vcm_->ResetDecoder(); vcm_->ResetDecoder();
return 0; }
} }
int32_t ViEChannel::ReceivedRTPPacket(const void* rtp_packet, int32_t ViEChannel::ReceivedRTPPacket(const void* rtp_packet,
@ -1530,8 +1529,6 @@ bool ViEChannel::ChannelDecodeThreadFunction(void* obj) {
} }
bool ViEChannel::ChannelDecodeProcess() { bool ViEChannel::ChannelDecodeProcess() {
// TODO(pbos): Make sure the decoder thread doesn't run for send-only
// channels.
vcm_->Decode(kMaxDecodeWaitTimeMs); vcm_->Decode(kMaxDecodeWaitTimeMs);
return true; return true;
} }
@ -1628,30 +1625,25 @@ RtpRtcp* ViEChannel::CreateRtpRtcpModule() {
return RtpRtcp::CreateRtpRtcp(CreateRtpRtcpConfiguration()); return RtpRtcp::CreateRtpRtcp(CreateRtpRtcpConfiguration());
} }
int32_t ViEChannel::StartDecodeThread() { void ViEChannel::StartDecodeThread() {
DCHECK(!sender_);
// Start the decode thread // Start the decode thread
if (decode_thread_) { if (decode_thread_)
// Already started. return;
return 0;
}
decode_thread_ = ThreadWrapper::CreateThread(ChannelDecodeThreadFunction, decode_thread_ = ThreadWrapper::CreateThread(ChannelDecodeThreadFunction,
this, "DecodingThread"); this, "DecodingThread");
decode_thread_->Start(); decode_thread_->Start();
decode_thread_->SetPriority(kHighestPriority); decode_thread_->SetPriority(kHighestPriority);
return 0;
} }
int32_t ViEChannel::StopDecodeThread() { void ViEChannel::StopDecodeThread() {
if (!decode_thread_) { if (!decode_thread_)
return 0; return;
}
vcm_->TriggerDecoderShutdown(); vcm_->TriggerDecoderShutdown();
decode_thread_->Stop(); decode_thread_->Stop();
decode_thread_.reset(); decode_thread_.reset();
return 0;
} }
int32_t ViEChannel::SetVoiceChannel(int32_t ve_channel_id, int32_t ViEChannel::SetVoiceChannel(int32_t ve_channel_id,

View File

@ -265,8 +265,8 @@ class ViEChannel : public VCMFrameTypeCallback,
int32_t StartSend(); int32_t StartSend();
int32_t StopSend(); int32_t StopSend();
bool Sending(); bool Sending();
int32_t StartReceive(); void StartReceive();
int32_t StopReceive(); void StopReceive();
int32_t ReceivedRTPPacket(const void* rtp_packet, int32_t ReceivedRTPPacket(const void* rtp_packet,
const size_t rtp_packet_length, const size_t rtp_packet_length,
@ -363,8 +363,8 @@ class ViEChannel : public VCMFrameTypeCallback,
RtpRtcp::Configuration CreateRtpRtcpConfiguration(); RtpRtcp::Configuration CreateRtpRtcpConfiguration();
RtpRtcp* CreateRtpRtcpModule(); RtpRtcp* CreateRtpRtcpModule();
// Assumed to be protected. // Assumed to be protected.
int32_t StartDecodeThread(); void StartDecodeThread();
int32_t StopDecodeThread(); void StopDecodeThread();
int32_t ProcessNACKRequest(const bool enable); int32_t ProcessNACKRequest(const bool enable);
int32_t ProcessFECRequest(const bool enable, int32_t ProcessFECRequest(const bool enable,