Skip to content
This repository was archived by the owner on Oct 25, 2024. It is now read-only.

Commit bf4a2f8

Browse files
committed
More renderer optmizations
1 parent 1082ec6 commit bf4a2f8

11 files changed

+29
-7
lines changed

talk/owt/sdk/base/cameravideocapturer.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ void CameraVideoCapturer::OnFrame(const webrtc::VideoFrame& frame) {
3636
return;
3737
}
3838

39-
if (out_height != frame.height() || out_width != frame.width()) {
39+
if (false/*out_height != frame.height() || out_width != frame.width()*/) {
4040
// Video adapter has requested a down-scale. Allocate a new buffer and
4141
// return scaled version.
4242
rtc::scoped_refptr<webrtc::I420Buffer> scaled_buffer =

talk/owt/sdk/base/connectionstats.cc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -694,6 +694,7 @@ RTCInboundRTPStreamStats::RTCInboundRTPStreamStats(
694694
double gap_loss_rate,
695695
double gap_discard_rate,
696696
uint32_t frames_decoded,
697+
uint32_t frames_rendered,
697698
uint32_t key_frames_decoded,
698699
double total_decode_time,
699700
double total_inter_frame_delay,
@@ -724,6 +725,7 @@ RTCInboundRTPStreamStats::RTCInboundRTPStreamStats(
724725
gap_loss_rate(gap_loss_rate),
725726
gap_discard_rate(gap_discard_rate),
726727
frames_decoded(frames_decoded),
728+
frames_rendered(frames_rendered),
727729
key_frames_decoded(key_frames_decoded),
728730
total_decode_time(total_decode_time),
729731
total_inter_frame_delay(total_inter_frame_delay),
@@ -755,6 +757,7 @@ RTCInboundRTPStreamStats::RTCInboundRTPStreamStats(
755757
gap_loss_rate(other.gap_loss_rate),
756758
gap_discard_rate(other.gap_discard_rate),
757759
frames_decoded(other.frames_decoded),
760+
frames_rendered(other.frames_rendered),
758761
key_frames_decoded(other.key_frames_decoded),
759762
total_decode_time(other.total_decode_time),
760763
total_inter_frame_delay(other.total_inter_frame_delay),

talk/owt/sdk/base/functionalobserver.cc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -612,6 +612,8 @@ void FunctionalStandardRTCStatsCollectorCallback::OnStatsDelivered(
612612
0),
613613
OWT_STATS_VALUE_OR_DEFAULT(webrtc_stats, frames_decoded, uint32_t,
614614
0),
615+
OWT_STATS_VALUE_OR_DEFAULT(webrtc_stats, frames_rendered, uint32_t,
616+
0),
615617
OWT_STATS_VALUE_OR_DEFAULT(webrtc_stats, key_frames_decoded,
616618
uint32_t, 0),
617619
OWT_STATS_VALUE_OR_DEFAULT(webrtc_stats, total_decode_time,

talk/owt/sdk/base/peerconnectionchannel.cc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
#include "talk/owt/sdk/base/peerconnectionchannel.h"
55
#include <vector>
66
#include "talk/owt/sdk/base/sdputils.h"
7+
#include "webrtc/api/peer_connection_interface.h"
78
#include "webrtc/rtc_base/logging.h"
89
#include "webrtc/rtc_base/thread.h"
910
using namespace rtc;
@@ -30,6 +31,7 @@ bool PeerConnectionChannel::InitializePeerConnection() {
3031
configuration_.enable_dtls_srtp = true;
3132
configuration_.sdp_semantics = webrtc::SdpSemantics::kUnifiedPlan;
3233
configuration_.media_config.enable_dscp = true;
34+
configuration_.bundle_policy = webrtc::PeerConnectionInterface::BundlePolicy::kBundlePolicyMaxBundle;
3335
peer_connection_ =
3436
(factory_->CreatePeerConnection(configuration_, this)).get();
3537
if (!peer_connection_.get()) {

talk/owt/sdk/base/win/msdkvideodecoder.cc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -393,6 +393,7 @@ int32_t MSDKVideoDecoder::Decode(
393393
decoded_frame.set_ntp_time_ms(inputImage.ntp_time_ms_);
394394
decoded_frame.set_timestamp(inputImage.Timestamp());
395395
callback_->Decoded(decoded_frame);
396+
RTC_LOG(LS_ERROR) << "Succeed decoding a frame.";
396397
}
397398
}
398399
} else if (MFX_ERR_MORE_DATA == sts) {

talk/owt/sdk/base/win/msdkvideodecoderfactory.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ std::unique_ptr<webrtc::VideoDecoder> MSDKVideoDecoderFactory::CreateVideoDecode
8686
}
8787
#endif
8888
}
89-
if (absl::EqualsIgnoreCase(format.name, cricket::kVp9CodecName) /*&& !vp9_hw*/) {
89+
if (absl::EqualsIgnoreCase(format.name, cricket::kVp9CodecName) && !vp9_hw) {
9090
return webrtc::VP9Decoder::Create();
9191
} else if (absl::EqualsIgnoreCase(format.name, cricket::kVp8CodecName) &&
9292
!vp8_hw) {

talk/owt/sdk/base/win/videorendererd3d11.cc

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
// SPDX-License-Identifier: Apache-2.0
44

55
#include "talk/owt/sdk/base/win/videorendererd3d11.h"
6+
#include <cstdio>
67
#include <array>
78
#include "rtc_base/logging.h"
89
#include "talk/owt/sdk/base/nativehandlebuffer.h"
@@ -18,12 +19,13 @@ struct D3dCustomVertex {
1819
float u, v;
1920
};
2021

22+
static int frame_count = 0;
2123
using namespace rtc;
2224
namespace owt {
2325
namespace base {
2426

2527
WebrtcVideoRendererD3D11Impl::WebrtcVideoRendererD3D11Impl(HWND wnd)
26-
: wnd_(wnd), width_(0), height_(0) {
28+
: wnd_(wnd), width_(0), height_(0), clock_(Clock::GetRealTimeClock()) {
2729
CreateDXGIFactory(__uuidof(IDXGIFactory2), (void**)(&dxgi_factory_));
2830
}
2931

@@ -50,6 +52,7 @@ void WebrtcVideoRendererD3D11Impl::OnFrame(
5052
uint16_t width = video_frame.video_frame_buffer()->width();
5153
uint16_t height = video_frame.video_frame_buffer()->height();
5254

55+
RTC_LOG(LS_ERROR) << "On frame." << width << "x" << height;
5356
if (width == 0 || height == 0)
5457
return;
5558

@@ -549,6 +552,11 @@ void WebrtcVideoRendererD3D11Impl::RenderToBackbuffer(int array_slice) {
549552
DXGI_PRESENT_PARAMETERS parameters = {0};
550553
swap_chain_for_hwnd_->Present1(
551554
0, 0, &parameters);
555+
int64_t current_time = clock_->TimeInMilliseconds();
556+
frame_count++;
557+
FILE* f = fopen("frames.txt", "a");
558+
fprintf(f, "timestamp: %lld, frames drawn: %d\r\n", current_time, frame_count);
559+
fclose(f);
552560
}
553561

554562
// Helper method to initialize a shader resource view

talk/owt/sdk/base/win/videorendererd3d11.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
#include <vector>
2222
#include "webrtc/api/video/video_frame.h"
2323
#include "webrtc/api/video/video_sink_interface.h"
24+
#include "webrtc/system_wrappers/include/clock.h"
2425

2526
// Holds texture coordinate of the vertex
2627
typedef struct _TEXCOORD {
@@ -113,6 +114,7 @@ class WebrtcVideoRendererD3D11Impl
113114
rtc::scoped_refptr<IDirect3DTexture9> m_texture_;
114115
rtc::scoped_refptr<IDirect3DVertexBuffer9> m_vertex_buffer_;
115116
UINT views_count = 0;
117+
webrtc::Clock* clock_;
116118

117119
};
118120
} // namespace base

talk/owt/sdk/include/cpp/owt/base/connectionstats.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -717,6 +717,7 @@ class RTCInboundRTPStreamStats final : public RTCRTPStreamStats {
717717
double gap_loss_rate,
718718
double gap_discard_rate,
719719
uint32_t frames_decoded,
720+
uint32_t frames_rendered,
720721
uint32_t key_frames_decoded,
721722
double total_decode_time,
722723
double total_inter_frame_delay,
@@ -760,6 +761,7 @@ class RTCInboundRTPStreamStats final : public RTCRTPStreamStats {
760761
// TODO: Collect and populate this value.
761762
double gap_discard_rate;
762763
uint32_t frames_decoded;
764+
uint32_t frames_rendered;
763765
uint32_t key_frames_decoded;
764766
double total_decode_time;
765767
double total_inter_frame_delay;

talk/owt/sdk/p2p/p2pclient.cc

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,8 @@ void P2PClient::OnSignalingMessage(const std::string& message,
215215
RTC_LOG(LS_WARNING) << "Non-existed chat cannot be stopped.";
216216
return;
217217
}
218-
} else if (message.find("\"type\":\"offer\"") != std::string::npos) {
218+
}
219+
else if (message.find("\"type\":\"offer\"") != std::string::npos) {
219220
auto pcc = GetPeerConnectionChannel(remote_id);
220221
if (pcc->HaveLocalOffer() && local_id_.compare(remote_id) > 0) {
221222
// Make the remote side as the publisher.
@@ -233,7 +234,8 @@ void P2PClient::OnSignalingMessage(const std::string& message,
233234
new_pcc->Publish(stream, success_callback, failure_callback);
234235
return;
235236
}
236-
} else if (message.find("\"type\":\"chat-closed\"") != std::string::npos) {
237+
}
238+
else if (message.find("\"type\":\"chat-closed\"") != std::string::npos) {
237239
int code = 0;
238240
std::string error = "";
239241
Json::Reader reader;

0 commit comments

Comments
 (0)