OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 "services/video_capture/receiver_mojo_to_media_adapter.h" | 5 #include "services/video_capture/receiver_mojo_to_media_adapter.h" |
6 | 6 |
7 #include "media/mojo/common/media_type_converters.h" | 7 #include "media/mojo/common/media_type_converters.h" |
8 #include "media/mojo/common/mojo_shared_buffer_video_frame.h" | 8 #include "media/mojo/common/mojo_shared_buffer_video_frame.h" |
9 | 9 |
10 namespace video_capture { | 10 namespace video_capture { |
11 | 11 |
12 ReceiverMojoToMediaAdapter::ReceiverMojoToMediaAdapter( | 12 ReceiverMojoToMediaAdapter::ReceiverMojoToMediaAdapter( |
13 mojom::VideoFrameReceiverPtr receiver) | 13 mojom::VideoFrameReceiverPtr receiver) |
14 : receiver_(std::move(receiver)) {} | 14 : receiver_(std::move(receiver)) {} |
15 | 15 |
16 ReceiverMojoToMediaAdapter::~ReceiverMojoToMediaAdapter() = default; | 16 ReceiverMojoToMediaAdapter::~ReceiverMojoToMediaAdapter() = default; |
17 | 17 |
18 void ReceiverMojoToMediaAdapter::OnIncomingCapturedVideoFrame( | 18 void ReceiverMojoToMediaAdapter::OnIncomingCapturedVideoFrame( |
19 std::unique_ptr<media::VideoCaptureDevice::Client::Buffer> buffer, | 19 std::unique_ptr<media::VideoCaptureDevice::Client::Buffer> buffer, |
20 const scoped_refptr<media::VideoFrame>& frame) { | 20 scoped_refptr<media::VideoFrame> frame) { |
21 // O: |frame| should already be backed by a MojoSharedBufferVideoFrame | 21 // O: |frame| should already be backed by a MojoSharedBufferVideoFrame |
22 // assuming we have used the correct buffer factory with the pool. | 22 // assuming we have used the correct buffer factory with the pool. |
23 auto video_frame_ptr = media::mojom::VideoFrame::From(frame); | 23 auto video_frame_ptr = media::mojom::VideoFrame::From(std::move(frame)); |
24 receiver_->OnIncomingCapturedVideoFrame(std::move(video_frame_ptr)); | 24 receiver_->OnIncomingCapturedVideoFrame(std::move(video_frame_ptr)); |
25 } | 25 } |
26 | 26 |
27 void ReceiverMojoToMediaAdapter::OnError() { | 27 void ReceiverMojoToMediaAdapter::OnError() { |
28 receiver_->OnError(); | 28 receiver_->OnError(); |
29 } | 29 } |
30 | 30 |
31 void ReceiverMojoToMediaAdapter::OnLog(const std::string& message) { | 31 void ReceiverMojoToMediaAdapter::OnLog(const std::string& message) { |
32 receiver_->OnLog(message); | 32 receiver_->OnLog(message); |
33 } | 33 } |
34 | 34 |
35 void ReceiverMojoToMediaAdapter::OnBufferDestroyed(int buffer_id_to_drop) { | 35 void ReceiverMojoToMediaAdapter::OnBufferDestroyed(int buffer_id_to_drop) { |
36 // Nothing to do here. | 36 // Nothing to do here. |
37 // This call is only needed for clients who need to explicitly share buffers | 37 // This call is only needed for clients who need to explicitly share buffers |
38 // with other processes and keep track of which buffers the buffer pool is | 38 // with other processes and keep track of which buffers the buffer pool is |
39 // no longer going to reuse/resurrect. | 39 // no longer going to reuse/resurrect. |
40 // In the world of Mojo, we do not need to share buffers explicitly. | 40 // In the world of Mojo, we do not need to share buffers explicitly. |
41 } | 41 } |
42 | 42 |
43 } // namespace video_capture | 43 } // namespace video_capture |
OLD | NEW |