Move the decoder thread into VideoReceiveStream.
BUG=webrtc:5494 R=stefan@webrtc.org Review URL: https://codereview.webrtc.org/1691793002 . Cr-Commit-Position: refs/heads/master@{#11580}
This commit is contained in:
parent
8e16e61d64
commit
ca8352541a
@ -106,9 +106,7 @@ std::string VideoReceiveStream::Config::Rtp::ToString() const {
|
||||
return ss.str();
|
||||
}
|
||||
|
||||
namespace internal {
|
||||
namespace {
|
||||
|
||||
VideoCodec CreateDecoderVideoCodec(const VideoReceiveStream::Decoder& decoder) {
|
||||
VideoCodec codec;
|
||||
memset(&codec, 0, sizeof(codec));
|
||||
@ -142,6 +140,7 @@ VideoCodec CreateDecoderVideoCodec(const VideoReceiveStream::Decoder& decoder) {
|
||||
}
|
||||
} // namespace
|
||||
|
||||
namespace internal {
|
||||
VideoReceiveStream::VideoReceiveStream(
|
||||
int num_cpu_cores,
|
||||
CongestionController* congestion_controller,
|
||||
@ -155,6 +154,7 @@ VideoReceiveStream::VideoReceiveStream(
|
||||
config_(config),
|
||||
process_thread_(process_thread),
|
||||
clock_(Clock::GetRealTimeClock()),
|
||||
decode_thread_(DecodeThreadFunction, this, "DecodingThread"),
|
||||
congestion_controller_(congestion_controller),
|
||||
call_stats_(call_stats),
|
||||
remb_(remb),
|
||||
@ -307,7 +307,8 @@ VideoReceiveStream::VideoReceiveStream(
|
||||
|
||||
VideoReceiveStream::~VideoReceiveStream() {
|
||||
LOG(LS_INFO) << "~VideoReceiveStream: " << config_.ToString();
|
||||
incoming_video_stream_.Stop();
|
||||
Stop();
|
||||
|
||||
process_thread_->DeRegisterModule(vcm_.get());
|
||||
vie_channel_.RegisterPreRenderCallback(nullptr);
|
||||
vcm_->RegisterPreDecodeImageCallback(nullptr);
|
||||
@ -321,14 +322,21 @@ VideoReceiveStream::~VideoReceiveStream() {
|
||||
}
|
||||
|
||||
void VideoReceiveStream::Start() {
|
||||
if (decode_thread_.IsRunning())
|
||||
return;
|
||||
transport_adapter_.Enable();
|
||||
incoming_video_stream_.Start();
|
||||
vie_channel_.StartReceive();
|
||||
// Start the decode thread
|
||||
decode_thread_.Start();
|
||||
decode_thread_.SetPriority(rtc::kHighestPriority);
|
||||
vie_receiver_->StartReceive();
|
||||
}
|
||||
|
||||
void VideoReceiveStream::Stop() {
|
||||
incoming_video_stream_.Stop();
|
||||
vie_channel_.StopReceive();
|
||||
vie_receiver_->StopReceive();
|
||||
vcm_->TriggerDecoderShutdown();
|
||||
decode_thread_.Stop();
|
||||
transport_adapter_.Disable();
|
||||
}
|
||||
|
||||
@ -403,5 +411,15 @@ void VideoReceiveStream::SignalNetworkState(NetworkState state) {
|
||||
: RtcpMode::kOff);
|
||||
}
|
||||
|
||||
bool VideoReceiveStream::DecodeThreadFunction(void* ptr) {
|
||||
static_cast<VideoReceiveStream*>(ptr)->Decode();
|
||||
return true;
|
||||
}
|
||||
|
||||
void VideoReceiveStream::Decode() {
|
||||
static const int kMaxDecodeWaitTimeMs = 50;
|
||||
vcm_->Decode(kMaxDecodeWaitTimeMs);
|
||||
}
|
||||
|
||||
} // namespace internal
|
||||
} // namespace webrtc
|
||||
|
||||
@ -80,12 +80,17 @@ class VideoReceiveStream : public webrtc::VideoReceiveStream,
|
||||
void SetSyncChannel(VoiceEngine* voice_engine, int audio_channel_id);
|
||||
|
||||
private:
|
||||
static bool DecodeThreadFunction(void* ptr);
|
||||
void Decode();
|
||||
|
||||
TransportAdapter transport_adapter_;
|
||||
EncodedFrameCallbackAdapter encoded_frame_proxy_;
|
||||
const VideoReceiveStream::Config config_;
|
||||
ProcessThread* const process_thread_;
|
||||
Clock* const clock_;
|
||||
|
||||
rtc::PlatformThread decode_thread_;
|
||||
|
||||
CongestionController* const congestion_controller_;
|
||||
CallStats* const call_stats_;
|
||||
VieRemb* const remb_;
|
||||
|
||||
@ -262,6 +262,8 @@ VideoSendStream::VideoSendStream(
|
||||
|
||||
VideoSendStream::~VideoSendStream() {
|
||||
LOG(LS_INFO) << "~VideoSendStream: " << config_.ToString();
|
||||
Stop();
|
||||
|
||||
module_process_thread_->DeRegisterModule(&overuse_detector_);
|
||||
// Remove vcm_protection_callback (part of vie_channel_) before destroying
|
||||
// ViEChannel. vcm_ is owned by ViEEncoder and the registered callback does
|
||||
@ -302,13 +304,13 @@ void VideoSendStream::Start() {
|
||||
vie_encoder_.SendKeyFrame();
|
||||
}
|
||||
vie_encoder_.Restart();
|
||||
vie_channel_.StartReceive();
|
||||
vie_receiver_->StartReceive();
|
||||
}
|
||||
|
||||
void VideoSendStream::Stop() {
|
||||
// TODO(pbos): Make sure the encoder stops here.
|
||||
vie_channel_.StopSend();
|
||||
vie_channel_.StopReceive();
|
||||
vie_receiver_->StopReceive();
|
||||
transport_adapter_.Disable();
|
||||
}
|
||||
|
||||
|
||||
@ -36,7 +36,6 @@
|
||||
|
||||
namespace webrtc {
|
||||
|
||||
const int kMaxDecodeWaitTimeMs = 50;
|
||||
static const int kMaxTargetDelayMs = 10000;
|
||||
const int kMinSendSidePacketHistorySize = 600;
|
||||
const int kMaxPacketAgeToNack = 450;
|
||||
@ -106,7 +105,6 @@ ViEChannel::ViEChannel(Transport* transport,
|
||||
packet_router_(packet_router),
|
||||
bandwidth_observer_(bandwidth_observer),
|
||||
transport_feedback_observer_(transport_feedback_observer),
|
||||
decode_thread_(ChannelDecodeThreadFunction, this, "DecodingThread"),
|
||||
nack_history_size_sender_(kMinSendSidePacketHistorySize),
|
||||
max_nack_reordering_threshold_(kMaxPacketAgeToNack),
|
||||
pre_render_callback_(NULL),
|
||||
@ -189,8 +187,6 @@ ViEChannel::~ViEChannel() {
|
||||
module_process_thread_->DeRegisterModule(rtp_rtcp);
|
||||
delete rtp_rtcp;
|
||||
}
|
||||
if (!sender_)
|
||||
StopDecodeThread();
|
||||
}
|
||||
|
||||
void ViEChannel::UpdateHistograms() {
|
||||
@ -817,22 +813,6 @@ int32_t ViEChannel::StopSend() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool ViEChannel::Sending() {
|
||||
return rtp_rtcp_modules_[0]->Sending();
|
||||
}
|
||||
|
||||
void ViEChannel::StartReceive() {
|
||||
if (!sender_)
|
||||
StartDecodeThread();
|
||||
vie_receiver_.StartReceive();
|
||||
}
|
||||
|
||||
void ViEChannel::StopReceive() {
|
||||
vie_receiver_.StopReceive();
|
||||
if (!sender_)
|
||||
StopDecodeThread();
|
||||
}
|
||||
|
||||
int32_t ViEChannel::SetMTU(uint16_t mtu) {
|
||||
RTC_DCHECK(sender_);
|
||||
for (RtpRtcp* rtp_rtcp : rtp_rtcp_modules_)
|
||||
@ -937,16 +917,6 @@ int32_t ViEChannel::ResendPackets(const uint16_t* sequence_numbers,
|
||||
return rtp_rtcp_modules_[0]->SendNACK(sequence_numbers, length);
|
||||
}
|
||||
|
||||
bool ViEChannel::ChannelDecodeThreadFunction(void* obj) {
|
||||
return static_cast<ViEChannel*>(obj)->ChannelDecodeProcess();
|
||||
}
|
||||
|
||||
bool ViEChannel::ChannelDecodeProcess() {
|
||||
RTC_DCHECK(!sender_);
|
||||
vcm_->Decode(kMaxDecodeWaitTimeMs);
|
||||
return true;
|
||||
}
|
||||
|
||||
void ViEChannel::OnRttUpdate(int64_t avg_rtt_ms, int64_t max_rtt_ms) {
|
||||
if (!sender_)
|
||||
vcm_->SetReceiveChannelParameters(max_rtt_ms);
|
||||
@ -1033,22 +1003,6 @@ std::vector<RtpRtcp*> ViEChannel::CreateRtpRtcpModules(
|
||||
return modules;
|
||||
}
|
||||
|
||||
void ViEChannel::StartDecodeThread() {
|
||||
RTC_DCHECK(!sender_);
|
||||
if (decode_thread_.IsRunning())
|
||||
return;
|
||||
// Start the decode thread
|
||||
decode_thread_.Start();
|
||||
decode_thread_.SetPriority(rtc::kHighestPriority);
|
||||
}
|
||||
|
||||
void ViEChannel::StopDecodeThread() {
|
||||
RTC_DCHECK(!sender_);
|
||||
vcm_->TriggerDecoderShutdown();
|
||||
|
||||
decode_thread_.Stop();
|
||||
}
|
||||
|
||||
int32_t ViEChannel::SetVoiceChannel(int32_t ve_channel_id,
|
||||
VoEVideoSync* ve_sync_interface) {
|
||||
RTC_DCHECK(!sender_);
|
||||
|
||||
@ -46,7 +46,6 @@ class RtcpRttStats;
|
||||
class ViEChannelProtectionCallback;
|
||||
class ViERTPObserver;
|
||||
class VideoCodingModule;
|
||||
class VideoDecoder;
|
||||
class VideoRenderCallback;
|
||||
class VoEVideoSync;
|
||||
|
||||
@ -163,9 +162,6 @@ class ViEChannel : public VCMFrameTypeCallback,
|
||||
|
||||
int32_t StartSend();
|
||||
int32_t StopSend();
|
||||
bool Sending();
|
||||
void StartReceive();
|
||||
void StopReceive();
|
||||
|
||||
// Sets the maximum transfer unit size for the network link, i.e. including
|
||||
// IP, UDP and RTP headers.
|
||||
@ -229,9 +225,6 @@ class ViEChannel : public VCMFrameTypeCallback,
|
||||
void SetIncomingVideoStream(IncomingVideoStream* incoming_video_stream);
|
||||
|
||||
protected:
|
||||
static bool ChannelDecodeThreadFunction(void* obj);
|
||||
bool ChannelDecodeProcess();
|
||||
|
||||
void OnRttUpdate(int64_t avg_rtt_ms, int64_t max_rtt_ms);
|
||||
|
||||
int ProtectionRequest(const FecProtectionParams* delta_fec_params,
|
||||
@ -383,8 +376,6 @@ class ViEChannel : public VCMFrameTypeCallback,
|
||||
const rtc::scoped_ptr<RtcpBandwidthObserver> bandwidth_observer_;
|
||||
TransportFeedbackObserver* const transport_feedback_observer_;
|
||||
|
||||
rtc::PlatformThread decode_thread_;
|
||||
|
||||
int nack_history_size_sender_;
|
||||
int max_nack_reordering_threshold_;
|
||||
I420FrameCallback* pre_render_callback_ GUARDED_BY(crit_);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user