From c389aa26150dd82bf37620b11f9d30c0091a55f5 Mon Sep 17 00:00:00 2001 From: "ronghuawu@google.com" Date: Wed, 21 Sep 2011 16:53:45 +0000 Subject: [PATCH] Fix the bad video issue on Window client by increasing the rtp recv buffer size. Send buffer doesn't really matter, just to keep the same as talk does. The same fix is submitted to libjingle for reivew. But I think it's worth to fix it here too as it may take while for webrtc to get from libjingle. This patch is slightly different then that one as I don't want to add the webrtcvideoengine.h back to webrtc. Review URL: http://webrtc-codereview.appspot.com/166002 git-svn-id: http://webrtc.googlecode.com/svn/trunk@634 4adac7df-926f-26a2-2b94-8c16560cd09d --- .../talk/session/phone/webrtcvideoengine.cc | 21 ++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/third_party_mods/libjingle/source/talk/session/phone/webrtcvideoengine.cc b/third_party_mods/libjingle/source/talk/session/phone/webrtcvideoengine.cc index fac9b5c62e..0452813221 100644 --- a/third_party_mods/libjingle/source/talk/session/phone/webrtcvideoengine.cc +++ b/third_party_mods/libjingle/source/talk/session/phone/webrtcvideoengine.cc @@ -46,6 +46,7 @@ namespace cricket { static const int kDefaultLogSeverity = talk_base::LS_WARNING; static const int kStartVideoBitrate = 300; static const int kMaxVideoBitrate = 1000; +static const int kMaxVideoRtpBufferSize = 0xFFFF; class WebRtcRenderAdapter : public webrtc::ExternalRenderer { public: @@ -197,7 +198,7 @@ bool WebRtcVideoEngine::InitVideoEngine() { } if (vie_wrapper_->render()->RegisterVideoRenderModule( - *render_module_.get()) != 0) { + *render_module_.get()) != 0) { LOG_RTCERR0(RegisterVideoRenderModule); return false; } @@ -299,7 +300,7 @@ void WebRtcVideoEngine::Terminate() { } if (vie_wrapper_->render()->DeRegisterVideoRenderModule( - *render_module_.get()) != 0) + *render_module_.get()) != 0) LOG_RTCERR0(DeRegisterVideoRenderModule); if ((vie_wrapper_->base()->DeregisterObserver()) != 0) @@ -359,8 +360,10 @@ bool WebRtcVideoEngine::SetCaptureDevice(const Device* cam) { char device_name[256], device_id[256]; bool found = false; for (int i = 0; i < vie_capture->NumberOfCaptureDevices(); ++i) { - if (vie_capture->GetCaptureDevice(i, device_name, sizeof(device_name), - device_id, sizeof(device_id)) == 0) { + if (vie_capture->GetCaptureDevice(i, device_name, + ARRAY_SIZE(device_name), + device_id, + ARRAY_SIZE(device_id)) == 0) { // TODO: We should only compare the device_id here, // however the devicemanager and webrtc use different format for th v4l2 // device id. So here we also compare the device_name for now. @@ -704,6 +707,14 @@ bool WebRtcVideoMediaChannel::SetRecvCodecs( ret = false; } } + if (ret && network_interface_) { + network_interface_->SetOption(NetworkInterface::ST_RTP, + talk_base::Socket::OPT_RCVBUF, + kMaxVideoRtpBufferSize); + network_interface_->SetOption(NetworkInterface::ST_RTP, + talk_base::Socket::OPT_SNDBUF, + kMaxVideoRtpBufferSize); + } return ret; } @@ -774,7 +785,7 @@ bool WebRtcVideoMediaChannel::SetSend(bool send) { // connect it now. if (!connected()) { if (engine()->video_engine()->capture()->ConnectCaptureDevice( - engine()->capture_id(), vie_channel_) != 0) { + engine()->capture_id(), vie_channel_) != 0) { LOG_RTCERR2(ConnectCaptureDevice, engine()->capture_id(), vie_channel_); ret = false; } else {