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

Side by Side Diff: remoting/protocol/webrtc_video_renderer_adapter.cc

Issue 1846893002: Interface with webrtc through encoded frames (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressed sergey comment Created 4 years, 8 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_encoder.cc ('k') | remoting/protocol/webrtc_video_stream.h » ('j') | 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_renderer_adapter.h" 5 #include "remoting/protocol/webrtc_video_renderer_adapter.h"
6 6
7 #include <memory> 7 #include <memory>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 28 matching lines...) Expand all
39 39
40 if (video_tracks.size() > 1U) { 40 if (video_tracks.size() > 1U) {
41 LOG(WARNING) << "Received media stream with multiple video tracks."; 41 LOG(WARNING) << "Received media stream with multiple video tracks.";
42 } 42 }
43 43
44 video_tracks[0]->AddOrUpdateSink(this, rtc::VideoSinkWants()); 44 video_tracks[0]->AddOrUpdateSink(this, rtc::VideoSinkWants());
45 } 45 }
46 46
47 WebrtcVideoRendererAdapter::~WebrtcVideoRendererAdapter() { 47 WebrtcVideoRendererAdapter::~WebrtcVideoRendererAdapter() {
48 DCHECK(task_runner_->BelongsToCurrentThread()); 48 DCHECK(task_runner_->BelongsToCurrentThread());
49
50 webrtc::VideoTrackVector video_tracks = media_stream_->GetVideoTracks();
51 DCHECK(!video_tracks.empty());
52 video_tracks[0]->RemoveSink(this);
49 } 53 }
50 54
51 void WebrtcVideoRendererAdapter::OnFrame(const cricket::VideoFrame& frame) { 55 void WebrtcVideoRendererAdapter::OnFrame(const cricket::VideoFrame& frame) {
52 // TODO(sergeyu): WebRTC calls OnFrame on a separate thread it creates. 56 // TODO(sergeyu): WebRTC calls OnFrame on a separate thread it creates.
53 // FrameConsumer normally expects to be called on the network thread, so we 57 // FrameConsumer normally expects to be called on the network thread, so we
54 // cannot call FrameConsumer::AllocateFrame() here and instead 58 // cannot call FrameConsumer::AllocateFrame() here and instead
55 // BasicDesktopFrame is created directly. This will not work correctly with 59 // BasicDesktopFrame is created directly. This will not work correctly with
56 // all FrameConsumer implementations. Fix this somehow. 60 // all FrameConsumer implementations. Fix this somehow.
57 std::unique_ptr<webrtc::DesktopFrame> rgb_frame(new webrtc::BasicDesktopFrame( 61 std::unique_ptr<webrtc::DesktopFrame> rgb_frame(new webrtc::BasicDesktopFrame(
58 webrtc::DesktopSize(frame.GetWidth(), frame.GetHeight()))); 62 webrtc::DesktopSize(frame.GetWidth(), frame.GetHeight())));
59 63
60 frame.ConvertToRgbBuffer( 64 frame.ConvertToRgbBuffer(
61 output_format_fourcc_, rgb_frame->data(), 65 output_format_fourcc_, rgb_frame->data(),
62 std::abs(rgb_frame->stride()) * rgb_frame->size().height(), 66 std::abs(rgb_frame->stride()) * rgb_frame->size().height(),
63 rgb_frame->stride()); 67 rgb_frame->stride());
64 rgb_frame->mutable_updated_region()->AddRect( 68 rgb_frame->mutable_updated_region()->AddRect(
65 webrtc::DesktopRect::MakeSize(rgb_frame->size())); 69 webrtc::DesktopRect::MakeSize(rgb_frame->size()));
66 task_runner_->PostTask( 70 task_runner_->PostTask(
67 FROM_HERE, 71 FROM_HERE,
68 base::Bind(&WebrtcVideoRendererAdapter::DrawFrame, 72 base::Bind(&WebrtcVideoRendererAdapter::DrawFrame,
69 weak_factory_.GetWeakPtr(), base::Passed(&rgb_frame))); 73 weak_factory_.GetWeakPtr(), base::Passed(&rgb_frame)));
70 } 74 }
71 75
72 void WebrtcVideoRendererAdapter::DrawFrame( 76 void WebrtcVideoRendererAdapter::DrawFrame(
73 std::unique_ptr<webrtc::DesktopFrame> frame) { 77 std::unique_ptr<webrtc::DesktopFrame> frame) {
74 DCHECK(task_runner_->BelongsToCurrentThread()); 78 DCHECK(task_runner_->BelongsToCurrentThread());
75 frame_consumer_->DrawFrame(std::move(frame), base::Closure()); 79 frame_consumer_->DrawFrame(std::move(frame), base::Closure());
76 } 80 }
77 81
82 } // namespace protocol
78 } // namespace remoting 83 } // namespace remoting
79 } // namespace protocol
OLDNEW
« no previous file with comments | « remoting/protocol/webrtc_video_encoder.cc ('k') | remoting/protocol/webrtc_video_stream.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698