OLD | NEW |
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 "chrome/renderer/media/cast_receiver_session_delegate.h" | 5 #include "chrome/renderer/media/cast_receiver_session_delegate.h" |
6 | 6 |
| 7 #include <utility> |
| 8 |
7 #include "base/bind.h" | 9 #include "base/bind.h" |
8 #include "base/synchronization/waitable_event.h" | 10 #include "base/synchronization/waitable_event.h" |
9 #include "base/values.h" | 11 #include "base/values.h" |
10 | 12 |
11 CastReceiverSessionDelegate::CastReceiverSessionDelegate() | 13 CastReceiverSessionDelegate::CastReceiverSessionDelegate() |
12 : weak_factory_(this) { | 14 : weak_factory_(this) { |
13 } | 15 } |
14 CastReceiverSessionDelegate::~CastReceiverSessionDelegate() {} | 16 CastReceiverSessionDelegate::~CastReceiverSessionDelegate() {} |
15 | 17 |
16 void CastReceiverSessionDelegate::Start( | 18 void CastReceiverSessionDelegate::Start( |
17 const media::cast::FrameReceiverConfig& audio_config, | 19 const media::cast::FrameReceiverConfig& audio_config, |
18 const media::cast::FrameReceiverConfig& video_config, | 20 const media::cast::FrameReceiverConfig& video_config, |
19 const net::IPEndPoint& local_endpoint, | 21 const net::IPEndPoint& local_endpoint, |
20 const net::IPEndPoint& remote_endpoint, | 22 const net::IPEndPoint& remote_endpoint, |
21 scoped_ptr<base::DictionaryValue> options, | 23 scoped_ptr<base::DictionaryValue> options, |
22 const media::VideoCaptureFormat& format, | 24 const media::VideoCaptureFormat& format, |
23 const ErrorCallback& error_callback) { | 25 const ErrorCallback& error_callback) { |
24 format_ = format; | 26 format_ = format; |
25 DCHECK(io_task_runner_->BelongsToCurrentThread()); | 27 DCHECK(io_task_runner_->BelongsToCurrentThread()); |
26 CastSessionDelegateBase::StartUDP(local_endpoint, | 28 CastSessionDelegateBase::StartUDP(local_endpoint, remote_endpoint, |
27 remote_endpoint, | 29 std::move(options), error_callback); |
28 options.Pass(), | |
29 error_callback); | |
30 cast_receiver_ = media::cast::CastReceiver::Create(cast_environment_, | 30 cast_receiver_ = media::cast::CastReceiver::Create(cast_environment_, |
31 audio_config, | 31 audio_config, |
32 video_config, | 32 video_config, |
33 cast_transport_.get()); | 33 cast_transport_.get()); |
34 on_audio_decoded_cb_ = base::Bind( | 34 on_audio_decoded_cb_ = base::Bind( |
35 &CastReceiverSessionDelegate::OnDecodedAudioFrame, | 35 &CastReceiverSessionDelegate::OnDecodedAudioFrame, |
36 weak_factory_.GetWeakPtr()); | 36 weak_factory_.GetWeakPtr()); |
37 on_video_decoded_cb_ = base::Bind( | 37 on_video_decoded_cb_ = base::Bind( |
38 &CastReceiverSessionDelegate::OnDecodedVideoFrame, | 38 &CastReceiverSessionDelegate::OnDecodedVideoFrame, |
39 weak_factory_.GetWeakPtr()); | 39 weak_factory_.GetWeakPtr()); |
40 } | 40 } |
41 | 41 |
42 void CastReceiverSessionDelegate::ReceivePacket( | 42 void CastReceiverSessionDelegate::ReceivePacket( |
43 scoped_ptr<media::cast::Packet> packet) { | 43 scoped_ptr<media::cast::Packet> packet) { |
44 cast_receiver_->ReceivePacket(packet.Pass()); | 44 cast_receiver_->ReceivePacket(std::move(packet)); |
45 } | 45 } |
46 | 46 |
47 void CastReceiverSessionDelegate::StartAudio( | 47 void CastReceiverSessionDelegate::StartAudio( |
48 scoped_refptr<CastReceiverAudioValve> audio_valve) { | 48 scoped_refptr<CastReceiverAudioValve> audio_valve) { |
49 DCHECK(io_task_runner_->BelongsToCurrentThread()); | 49 DCHECK(io_task_runner_->BelongsToCurrentThread()); |
50 audio_valve_ = audio_valve; | 50 audio_valve_ = audio_valve; |
51 cast_receiver_->RequestDecodedAudioFrame(on_audio_decoded_cb_); | 51 cast_receiver_->RequestDecodedAudioFrame(on_audio_decoded_cb_); |
52 } | 52 } |
53 | 53 |
54 void CastReceiverSessionDelegate::OnDecodedAudioFrame( | 54 void CastReceiverSessionDelegate::OnDecodedAudioFrame( |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
89 | 89 |
90 void CastReceiverSessionDelegate::OnDecodedVideoFrame( | 90 void CastReceiverSessionDelegate::OnDecodedVideoFrame( |
91 const scoped_refptr<media::VideoFrame>& video_frame, | 91 const scoped_refptr<media::VideoFrame>& video_frame, |
92 const base::TimeTicks& playout_time, | 92 const base::TimeTicks& playout_time, |
93 bool is_continous) { | 93 bool is_continous) { |
94 if (frame_callback_.is_null()) | 94 if (frame_callback_.is_null()) |
95 return; | 95 return; |
96 frame_callback_.Run(video_frame, playout_time); | 96 frame_callback_.Run(video_frame, playout_time); |
97 cast_receiver_->RequestDecodedVideoFrame(on_video_decoded_cb_); | 97 cast_receiver_->RequestDecodedVideoFrame(on_video_decoded_cb_); |
98 } | 98 } |
OLD | NEW |