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

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
32 bool WebrtcVideoStream::Start(
33 scoped_ptr<webrtc::DesktopCapturer> desktop_capturer,
34 scoped_refptr<webrtc::PeerConnectionInterface> connection,
35 scoped_refptr<webrtc::PeerConnectionFactoryInterface>
36 peer_connection_factory) {
37 scoped_ptr<WebrtcVideoCapturerAdapter> capturer_adapter(
38 new WebrtcVideoCapturerAdapter(std::move(desktop_capturer)));
39
40 connection_ = connection;
41
42 // Set video stream constraints.
43 webrtc::FakeConstraints video_constraints;
44 video_constraints.AddMandatory(
45 webrtc::MediaConstraintsInterface::kMinFrameRate, 5);
46
47 video_track_ =
48 peer_connection_factory->CreateVideoTrack(
49 kVideoLabel,
50 peer_connection_factory->CreateVideoSource(
51 capturer_adapter.release(),
52 &video_constraints))
53 .get();
54
55 stream_ = peer_connection_factory->CreateLocalMediaStream(kStreamLabel);
56
57 if (!stream_->AddTrack(video_track_.get()) ||
58 !connection_->AddStream(stream_.get())) {
59 video_track_ = nullptr;
60 stream_ = nullptr;
61 connection_ = nullptr;
62 return false;
63 }
64
65 return true;
26 } 66 }
27 67
28 void WebrtcVideoStream::Pause(bool pause) { 68 void WebrtcVideoStream::Pause(bool pause) {
29 NOTIMPLEMENTED(); 69 capturer_adapter()->Pause(pause);
30 } 70 }
31 71
32 void WebrtcVideoStream::OnInputEventReceived(int64_t event_timestamp) { 72 void WebrtcVideoStream::OnInputEventReceived(int64_t event_timestamp) {
33 NOTIMPLEMENTED(); 73 NOTIMPLEMENTED();
34 } 74 }
35 75
36 void WebrtcVideoStream::SetLosslessEncode(bool want_lossless) { 76 void WebrtcVideoStream::SetLosslessEncode(bool want_lossless) {
37 NOTIMPLEMENTED(); 77 NOTIMPLEMENTED();
38 } 78 }
39 79
40 void WebrtcVideoStream::SetLosslessColor(bool want_lossless) { 80 void WebrtcVideoStream::SetLosslessColor(bool want_lossless) {
41 NOTIMPLEMENTED(); 81 NOTIMPLEMENTED();
42 } 82 }
43 83
44 void WebrtcVideoStream::SetSizeCallback(const SizeCallback& size_callback) { 84 void WebrtcVideoStream::SetSizeCallback(const SizeCallback& size_callback) {
45 NOTIMPLEMENTED(); 85 capturer_adapter()->SetSizeCallback(size_callback);
86 }
87
88 WebrtcVideoCapturerAdapter* WebrtcVideoStream::capturer_adapter() {
89 WebrtcVideoCapturerAdapter* capturer_adapter =
90 reinterpret_cast<WebrtcVideoCapturerAdapter*>(
91 video_track_->GetSource()->GetVideoCapturer());
Jamie 2016/01/08 22:59:14 Is this allowed? I've never seen reinterpret_cast
Sergey Ulanov 2016/01/08 23:39:56 The VideoCapturer passed to the VideoTrack is crea
Jamie 2016/01/08 23:44:45 It's conceivable that video_track_ might wrap the
92 DCHECK(capturer_adapter);
93 return capturer_adapter;
46 } 94 }
47 95
48 } // namespace protocol 96 } // namespace protocol
49 } // namespace remoting 97 } // 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