Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(226)

Unified Diff: remoting/protocol/webrtc_connection_to_host.cc

Issue 2200273003: Enable video stats reporting when using WebRTC (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: address feedback Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: remoting/protocol/webrtc_connection_to_host.cc
diff --git a/remoting/protocol/webrtc_connection_to_host.cc b/remoting/protocol/webrtc_connection_to_host.cc
index eda4347af7572980c0c17ceaecb212d35086c6cf..3ef3d44e7e73c50fc410961515c74cc9dea27ef3 100644
--- a/remoting/protocol/webrtc_connection_to_host.cc
+++ b/remoting/protocol/webrtc_connection_to_host.cc
@@ -6,7 +6,9 @@
#include <utility>
+#include "base/strings/string_util.h"
#include "jingle/glue/thread_wrapper.h"
+#include "remoting/base/constants.h"
#include "remoting/protocol/client_control_dispatcher.h"
#include "remoting/protocol/client_event_dispatcher.h"
#include "remoting/protocol/client_stub.h"
@@ -121,21 +123,26 @@ void WebrtcConnectionToHost::OnWebrtcTransportIncomingDataChannel(
std::unique_ptr<MessagePipe> pipe) {
if (!control_dispatcher_)
control_dispatcher_.reset(new ClientControlDispatcher());
+
if (name == control_dispatcher_->channel_name() &&
!control_dispatcher_->is_connected()) {
control_dispatcher_->set_client_stub(client_stub_);
control_dispatcher_->set_clipboard_stub(clipboard_stub_);
control_dispatcher_->Init(std::move(pipe), this);
+ } else if (base::StartsWith(name, kVideoStatsChannelNamePrefix,
+ base::CompareCase::SENSITIVE)) {
+ std::string video_stream_label =
+ name.substr(strlen(kVideoStatsChannelNamePrefix));
+ GetOrCreateVideoAdapter(video_stream_label)
+ ->SetVideoStatsChannel(std::move(pipe));
+ } else {
+ LOG(WARNING) << "Received unknown incoming data channel " << name;
}
}
void WebrtcConnectionToHost::OnWebrtcTransportMediaStreamAdded(
scoped_refptr<webrtc::MediaStreamInterface> stream) {
- if (video_adapter_) {
- LOG(WARNING)
- << "Received multiple media streams. Ignoring all except the last one.";
- }
- video_adapter_.reset(new WebrtcVideoRendererAdapter(stream, video_renderer_));
+ GetOrCreateVideoAdapter(stream->label())->SetMediaStream(stream);
}
void WebrtcConnectionToHost::OnWebrtcTransportMediaStreamRemoved(
@@ -172,6 +179,19 @@ void WebrtcConnectionToHost::NotifyIfChannelsReady() {
SetState(CONNECTED, OK);
}
+WebrtcVideoRendererAdapter* WebrtcConnectionToHost::GetOrCreateVideoAdapter(
+ const std::string& label) {
+ if (!video_adapter_ || video_adapter_->label() != label) {
+ if (video_adapter_) {
+ LOG(WARNING) << "Received multiple media streams. Ignoring all except "
+ "the last one.";
+ }
+ video_adapter_.reset(
+ new WebrtcVideoRendererAdapter(label, video_renderer_));
+ }
+ return video_adapter_.get();
+}
+
void WebrtcConnectionToHost::CloseChannels() {
clipboard_forwarder_.set_clipboard_stub(nullptr);
control_dispatcher_.reset();

Powered by Google App Engine
This is Rietveld 408576698