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

Side by Side 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 unified diff | Download patch
« no previous file with comments | « remoting/protocol/webrtc_video_stream.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "remoting/protocol/webrtc_video_stream.h" 5 #include "remoting/protocol/webrtc_video_stream.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "remoting/protocol/webrtc_video_capturer_adapter.h"
8 #include "third_party/libjingle/source/talk/app/webrtc/mediastreaminterface.h" 9 #include "third_party/libjingle/source/talk/app/webrtc/mediastreaminterface.h"
9 #include "third_party/libjingle/source/talk/app/webrtc/peerconnectioninterface.h " 10 #include "third_party/libjingle/source/talk/app/webrtc/peerconnectioninterface.h "
11 #include "third_party/libjingle/source/talk/app/webrtc/test/fakeconstraints.h"
10 #include "third_party/libjingle/source/talk/app/webrtc/videosourceinterface.h" 12 #include "third_party/libjingle/source/talk/app/webrtc/videosourceinterface.h"
11 13
12 namespace remoting { 14 namespace remoting {
13 namespace protocol { 15 namespace protocol {
14 16
15 WebrtcVideoStream::WebrtcVideoStream( 17 const char kStreamLabel[] = "screen_stream";
16 rtc::scoped_refptr<webrtc::PeerConnectionInterface> connection, 18 const char kVideoLabel[] = "screen_video";
17 rtc::scoped_refptr<webrtc::MediaStreamInterface> stream) 19
18 : connection_(connection), stream_(stream) {} 20 WebrtcVideoStream::WebrtcVideoStream() {}
19 21
20 WebrtcVideoStream::~WebrtcVideoStream() { 22 WebrtcVideoStream::~WebrtcVideoStream() {
21 for (const auto& track : stream_->GetVideoTracks()) { 23 if (stream_) {
22 track->GetSource()->Stop(); 24 for (const auto& track : stream_->GetVideoTracks()) {
23 stream_->RemoveTrack(track.get()); 25 track->GetSource()->Stop();
26 stream_->RemoveTrack(track.get());
27 }
28 connection_->RemoveStream(stream_.get());
24 } 29 }
25 connection_->RemoveStream(stream_.get()); 30
31 // MediaStream may still outlive WebrtcVideoStream because it's
32 // ref-counted. Reset SizeCallback to make sure it won't be called again.
33 if (capturer_adapter_)
34 capturer_adapter_->SetSizeCallback(SizeCallback());
35 }
36
37 bool WebrtcVideoStream::Start(
38 scoped_ptr<webrtc::DesktopCapturer> desktop_capturer,
39 scoped_refptr<webrtc::PeerConnectionInterface> connection,
40 scoped_refptr<webrtc::PeerConnectionFactoryInterface>
41 peer_connection_factory) {
42 scoped_ptr<WebrtcVideoCapturerAdapter> capturer_adapter(
43 new WebrtcVideoCapturerAdapter(std::move(desktop_capturer)));
44 capturer_adapter_ = capturer_adapter_->GetWeakPtr();
45
46 connection_ = connection;
47
48 // Set video stream constraints.
49 webrtc::FakeConstraints video_constraints;
50 video_constraints.AddMandatory(
51 webrtc::MediaConstraintsInterface::kMinFrameRate, 5);
52
53 rtc::scoped_refptr<webrtc::VideoTrackInterface> video_track =
54 peer_connection_factory->CreateVideoTrack(
55 kVideoLabel, peer_connection_factory->CreateVideoSource(
56 capturer_adapter.release(), &video_constraints));
57
58 stream_ = peer_connection_factory->CreateLocalMediaStream(kStreamLabel);
59
60 if (!stream_->AddTrack(video_track.get()) ||
61 !connection_->AddStream(stream_.get())) {
62 stream_ = nullptr;
63 connection_ = nullptr;
64 return false;
65 }
66
67 return true;
26 } 68 }
27 69
28 void WebrtcVideoStream::Pause(bool pause) { 70 void WebrtcVideoStream::Pause(bool pause) {
29 NOTIMPLEMENTED(); 71 if (capturer_adapter_)
72 capturer_adapter_->Pause(pause);
30 } 73 }
31 74
32 void WebrtcVideoStream::OnInputEventReceived(int64_t event_timestamp) { 75 void WebrtcVideoStream::OnInputEventReceived(int64_t event_timestamp) {
33 NOTIMPLEMENTED(); 76 NOTIMPLEMENTED();
34 } 77 }
35 78
36 void WebrtcVideoStream::SetLosslessEncode(bool want_lossless) { 79 void WebrtcVideoStream::SetLosslessEncode(bool want_lossless) {
37 NOTIMPLEMENTED(); 80 NOTIMPLEMENTED();
38 } 81 }
39 82
40 void WebrtcVideoStream::SetLosslessColor(bool want_lossless) { 83 void WebrtcVideoStream::SetLosslessColor(bool want_lossless) {
41 NOTIMPLEMENTED(); 84 NOTIMPLEMENTED();
42 } 85 }
43 86
44 void WebrtcVideoStream::SetSizeCallback(const SizeCallback& size_callback) { 87 void WebrtcVideoStream::SetSizeCallback(const SizeCallback& size_callback) {
45 NOTIMPLEMENTED(); 88 if (capturer_adapter_)
89 capturer_adapter_->SetSizeCallback(size_callback);
46 } 90 }
47 91
48 } // namespace protocol 92 } // namespace protocol
49 } // namespace remoting 93 } // namespace remoting
OLDNEW
« 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