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

Unified Diff: remoting/protocol/webrtc_video_stream.cc

Issue 1571543002: Implement missing features in WebrtcVideoStream. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 11 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
« no previous file with comments | « remoting/protocol/webrtc_video_stream.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: remoting/protocol/webrtc_video_stream.cc
diff --git a/remoting/protocol/webrtc_video_stream.cc b/remoting/protocol/webrtc_video_stream.cc
index 50c6ddd2e4d2521ee05b540951739604949c27e6..0b7e8621882e728a35c8561c92336d4e977e4270 100644
--- a/remoting/protocol/webrtc_video_stream.cc
+++ b/remoting/protocol/webrtc_video_stream.cc
@@ -5,28 +5,71 @@
#include "remoting/protocol/webrtc_video_stream.h"
#include "base/logging.h"
+#include "remoting/protocol/webrtc_video_capturer_adapter.h"
#include "third_party/libjingle/source/talk/app/webrtc/mediastreaminterface.h"
#include "third_party/libjingle/source/talk/app/webrtc/peerconnectioninterface.h"
+#include "third_party/libjingle/source/talk/app/webrtc/test/fakeconstraints.h"
#include "third_party/libjingle/source/talk/app/webrtc/videosourceinterface.h"
namespace remoting {
namespace protocol {
-WebrtcVideoStream::WebrtcVideoStream(
- rtc::scoped_refptr<webrtc::PeerConnectionInterface> connection,
- rtc::scoped_refptr<webrtc::MediaStreamInterface> stream)
- : connection_(connection), stream_(stream) {}
+const char kStreamLabel[] = "screen_stream";
+const char kVideoLabel[] = "screen_video";
+
+WebrtcVideoStream::WebrtcVideoStream() {}
WebrtcVideoStream::~WebrtcVideoStream() {
- for (const auto& track : stream_->GetVideoTracks()) {
- track->GetSource()->Stop();
- stream_->RemoveTrack(track.get());
+ if (stream_) {
+ for (const auto& track : stream_->GetVideoTracks()) {
+ track->GetSource()->Stop();
+ stream_->RemoveTrack(track.get());
+ }
+ connection_->RemoveStream(stream_.get());
}
- connection_->RemoveStream(stream_.get());
+
+ // MediaStream may still outlive WebrtcVideoStream because it's
+ // ref-counted. Reset SizeCallback to make sure it won't be called again.
+ if (capturer_adapter_)
+ capturer_adapter_->SetSizeCallback(SizeCallback());
+}
+
+bool WebrtcVideoStream::Start(
+ scoped_ptr<webrtc::DesktopCapturer> desktop_capturer,
+ scoped_refptr<webrtc::PeerConnectionInterface> connection,
+ scoped_refptr<webrtc::PeerConnectionFactoryInterface>
+ peer_connection_factory) {
+ scoped_ptr<WebrtcVideoCapturerAdapter> capturer_adapter(
+ new WebrtcVideoCapturerAdapter(std::move(desktop_capturer)));
+ capturer_adapter_ = capturer_adapter_->GetWeakPtr();
+
+ connection_ = connection;
+
+ // Set video stream constraints.
+ webrtc::FakeConstraints video_constraints;
+ video_constraints.AddMandatory(
+ webrtc::MediaConstraintsInterface::kMinFrameRate, 5);
+
+ rtc::scoped_refptr<webrtc::VideoTrackInterface> video_track =
+ peer_connection_factory->CreateVideoTrack(
+ kVideoLabel, peer_connection_factory->CreateVideoSource(
+ capturer_adapter.release(), &video_constraints));
+
+ stream_ = peer_connection_factory->CreateLocalMediaStream(kStreamLabel);
+
+ if (!stream_->AddTrack(video_track.get()) ||
+ !connection_->AddStream(stream_.get())) {
+ stream_ = nullptr;
+ connection_ = nullptr;
+ return false;
+ }
+
+ return true;
}
void WebrtcVideoStream::Pause(bool pause) {
- NOTIMPLEMENTED();
+ if (capturer_adapter_)
+ capturer_adapter_->Pause(pause);
}
void WebrtcVideoStream::OnInputEventReceived(int64_t event_timestamp) {
@@ -42,7 +85,8 @@ void WebrtcVideoStream::SetLosslessColor(bool want_lossless) {
}
void WebrtcVideoStream::SetSizeCallback(const SizeCallback& size_callback) {
- NOTIMPLEMENTED();
+ if (capturer_adapter_)
+ capturer_adapter_->SetSizeCallback(size_callback);
}
} // namespace protocol
« no previous file with comments | « remoting/protocol/webrtc_video_stream.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698