Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "media/cast/test/utility/in_process_receiver.h" | 5 #include "media/cast/test/utility/in_process_receiver.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/bind_helpers.h" | 9 #include "base/bind_helpers.h" |
| 10 #include "base/synchronization/waitable_event.h" | 10 #include "base/synchronization/waitable_event.h" |
| 11 #include "base/time/time.h" | 11 #include "base/time/time.h" |
| 12 #include "base/values.h" | 12 #include "base/values.h" |
| 13 #include "media/base/video_frame.h" | 13 #include "media/base/video_frame.h" |
| 14 #include "media/cast/cast_config.h" | 14 #include "media/cast/cast_config.h" |
| 15 #include "media/cast/cast_environment.h" | 15 #include "media/cast/cast_environment.h" |
| 16 #include "media/cast/cast_receiver.h" | 16 #include "media/cast/cast_receiver.h" |
| 17 #include "media/cast/net/cast_transport_config.h" | 17 #include "media/cast/net/cast_transport_config.h" |
| 18 #include "media/cast/net/udp_transport.h" | 18 #include "media/cast/net/udp_transport.h" |
| 19 | 19 |
| 20 using media::cast::CastTransportStatus; | 20 using media::cast::CastTransportStatus; |
| 21 using media::cast::UdpTransport; | 21 using media::cast::UdpTransport; |
| 22 | 22 |
| 23 namespace media { | 23 namespace media { |
| 24 namespace cast { | 24 namespace cast { |
| 25 | 25 |
| 26 namespace { | |
| 27 class TransportClient : public CastTransportSender::Client { | |
| 28 public: | |
| 29 TransportClient(InProcessReceiver* in_process_receiver) | |
|
miu
2016/02/22 22:38:48
Need 'explicit' keyword here.
xjz
2016/02/23 21:51:47
Done.
| |
| 30 : in_process_receiver_(in_process_receiver) {} | |
| 31 | |
| 32 void OnStatusChanged(CastTransportStatus status) final { | |
| 33 LOG_IF(ERROR, status == media::cast::TRANSPORT_SOCKET_ERROR) | |
| 34 << "Transport socket error occurred. InProcessReceiver is likely " | |
| 35 "dead."; | |
| 36 VLOG(1) << "CastTransportStatus is now " << status; | |
| 37 }; | |
| 38 void OnLoggingEventsReceived( | |
| 39 scoped_ptr<std::vector<FrameEvent>> frame_events, | |
| 40 scoped_ptr<std::vector<PacketEvent>> packet_events) final{}; | |
| 41 void ProcessRtpPacket(scoped_ptr<Packet> packet) final { | |
| 42 in_process_receiver_->ReceivePacket(std::move(packet)); | |
| 43 }; | |
| 44 | |
| 45 private: | |
| 46 InProcessReceiver* const in_process_receiver_; | |
| 47 | |
| 48 DISALLOW_COPY_AND_ASSIGN(TransportClient); | |
| 49 }; | |
| 50 | |
| 51 } // namespace | |
| 52 | |
| 26 InProcessReceiver::InProcessReceiver( | 53 InProcessReceiver::InProcessReceiver( |
| 27 const scoped_refptr<CastEnvironment>& cast_environment, | 54 const scoped_refptr<CastEnvironment>& cast_environment, |
| 28 const net::IPEndPoint& local_end_point, | 55 const net::IPEndPoint& local_end_point, |
| 29 const net::IPEndPoint& remote_end_point, | 56 const net::IPEndPoint& remote_end_point, |
| 30 const FrameReceiverConfig& audio_config, | 57 const FrameReceiverConfig& audio_config, |
| 31 const FrameReceiverConfig& video_config) | 58 const FrameReceiverConfig& video_config) |
| 32 : cast_environment_(cast_environment), | 59 : cast_environment_(cast_environment), |
| 33 local_end_point_(local_end_point), | 60 local_end_point_(local_end_point), |
| 34 remote_end_point_(remote_end_point), | 61 remote_end_point_(remote_end_point), |
| 35 audio_config_(audio_config), | 62 audio_config_(audio_config), |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 74 << "Transport socket error occurred. InProcessReceiver is likely dead."; | 101 << "Transport socket error occurred. InProcessReceiver is likely dead."; |
| 75 VLOG(1) << "CastTransportStatus is now " << status; | 102 VLOG(1) << "CastTransportStatus is now " << status; |
| 76 } | 103 } |
| 77 | 104 |
| 78 void InProcessReceiver::StartOnMainThread() { | 105 void InProcessReceiver::StartOnMainThread() { |
| 79 DCHECK(cast_environment_->CurrentlyOn(CastEnvironment::MAIN)); | 106 DCHECK(cast_environment_->CurrentlyOn(CastEnvironment::MAIN)); |
| 80 | 107 |
| 81 DCHECK(!transport_ && !cast_receiver_); | 108 DCHECK(!transport_ && !cast_receiver_); |
| 82 | 109 |
| 83 transport_ = CastTransportSender::Create( | 110 transport_ = CastTransportSender::Create( |
| 84 NULL, | 111 cast_environment_->Clock(), base::TimeDelta(), |
| 85 cast_environment_->Clock(), | 112 make_scoped_ptr(new TransportClient(this)), |
| 86 local_end_point_, | 113 make_scoped_ptr(new UdpTransport( |
| 87 remote_end_point_, | 114 NULL, cast_environment_->GetTaskRunner(CastEnvironment::MAIN), |
|
miu
2016/02/22 22:38:48
nit: Please change NULLs to nullptr whenever you c
xjz
2016/02/23 21:51:47
Done.
| |
| 88 scoped_ptr<base::DictionaryValue>(new base::DictionaryValue), | 115 local_end_point_, remote_end_point_, |
| 89 base::Bind(&InProcessReceiver::UpdateCastTransportStatus, | 116 base::Bind(&InProcessReceiver::UpdateCastTransportStatus, |
| 90 base::Unretained(this)), | 117 base::Unretained(this)))), |
| 91 BulkRawEventsCallback(), | |
| 92 base::TimeDelta(), | |
| 93 base::Bind(&InProcessReceiver::ReceivePacket, | |
| 94 base::Unretained(this)), | |
| 95 cast_environment_->GetTaskRunner(CastEnvironment::MAIN)); | 118 cast_environment_->GetTaskRunner(CastEnvironment::MAIN)); |
| 96 | 119 |
| 97 cast_receiver_ = CastReceiver::Create( | 120 cast_receiver_ = CastReceiver::Create( |
| 98 cast_environment_, audio_config_, video_config_, transport_.get()); | 121 cast_environment_, audio_config_, video_config_, transport_.get()); |
| 99 | 122 |
| 100 PullNextAudioFrame(); | 123 PullNextAudioFrame(); |
| 101 PullNextVideoFrame(); | 124 PullNextVideoFrame(); |
| 102 } | 125 } |
| 103 | 126 |
| 104 void InProcessReceiver::GotAudioFrame(scoped_ptr<AudioBus> audio_frame, | 127 void InProcessReceiver::GotAudioFrame(scoped_ptr<AudioBus> audio_frame, |
| (...skipping 28 matching lines...) Expand all Loading... | |
| 133 &InProcessReceiver::GotVideoFrame, weak_factory_.GetWeakPtr())); | 156 &InProcessReceiver::GotVideoFrame, weak_factory_.GetWeakPtr())); |
| 134 } | 157 } |
| 135 | 158 |
| 136 void InProcessReceiver::ReceivePacket(scoped_ptr<Packet> packet) { | 159 void InProcessReceiver::ReceivePacket(scoped_ptr<Packet> packet) { |
| 137 // TODO(Hubbe): Make an InsertPacket method instead. | 160 // TODO(Hubbe): Make an InsertPacket method instead. |
| 138 cast_receiver_->ReceivePacket(std::move(packet)); | 161 cast_receiver_->ReceivePacket(std::move(packet)); |
| 139 } | 162 } |
| 140 | 163 |
| 141 } // namespace cast | 164 } // namespace cast |
| 142 } // namespace media | 165 } // namespace media |
| OLD | NEW |