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

Side by Side Diff: media/cast/test/utility/in_process_receiver.cc

Issue 1515023002: Simplify interface for media/cast: CastTransportSenderImpl (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 10 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 | « media/cast/test/utility/in_process_receiver.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 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 void InProcessReceiver::TransportClient::OnStatusChanged(
27 CastTransportStatus status) {
28 LOG_IF(ERROR, status == media::cast::TRANSPORT_SOCKET_ERROR)
29 << "Transport socket error occurred. InProcessReceiver is likely "
30 "dead.";
31 VLOG(1) << "CastTransportStatus is now " << status;
32 }
33
34 void InProcessReceiver::TransportClient::ProcessRtpPacket(
35 scoped_ptr<Packet> packet) {
36 in_process_receiver_->ReceivePacket(std::move(packet));
37 }
38
26 InProcessReceiver::InProcessReceiver( 39 InProcessReceiver::InProcessReceiver(
27 const scoped_refptr<CastEnvironment>& cast_environment, 40 const scoped_refptr<CastEnvironment>& cast_environment,
28 const net::IPEndPoint& local_end_point, 41 const net::IPEndPoint& local_end_point,
29 const net::IPEndPoint& remote_end_point, 42 const net::IPEndPoint& remote_end_point,
30 const FrameReceiverConfig& audio_config, 43 const FrameReceiverConfig& audio_config,
31 const FrameReceiverConfig& video_config) 44 const FrameReceiverConfig& video_config)
32 : cast_environment_(cast_environment), 45 : cast_environment_(cast_environment),
33 local_end_point_(local_end_point), 46 local_end_point_(local_end_point),
34 remote_end_point_(remote_end_point), 47 remote_end_point_(remote_end_point),
35 audio_config_(audio_config), 48 audio_config_(audio_config),
(...skipping 20 matching lines...) Expand all
56 FROM_HERE, 69 FROM_HERE,
57 base::Bind(&InProcessReceiver::StopOnMainThread, 70 base::Bind(&InProcessReceiver::StopOnMainThread,
58 base::Unretained(this), 71 base::Unretained(this),
59 &event)); 72 &event));
60 event.Wait(); 73 event.Wait();
61 } 74 }
62 } 75 }
63 76
64 void InProcessReceiver::StopOnMainThread(base::WaitableEvent* event) { 77 void InProcessReceiver::StopOnMainThread(base::WaitableEvent* event) {
65 DCHECK(cast_environment_->CurrentlyOn(CastEnvironment::MAIN)); 78 DCHECK(cast_environment_->CurrentlyOn(CastEnvironment::MAIN));
66 cast_receiver_.reset(NULL); 79 cast_receiver_.reset(nullptr);
67 transport_.reset(NULL); 80 transport_.reset(nullptr);
68 weak_factory_.InvalidateWeakPtrs(); 81 weak_factory_.InvalidateWeakPtrs();
69 event->Signal(); 82 event->Signal();
70 } 83 }
71 84
72 void InProcessReceiver::UpdateCastTransportStatus(CastTransportStatus status) { 85 void InProcessReceiver::UpdateCastTransportStatus(CastTransportStatus status) {
73 LOG_IF(ERROR, status == media::cast::TRANSPORT_SOCKET_ERROR) 86 LOG_IF(ERROR, status == media::cast::TRANSPORT_SOCKET_ERROR)
74 << "Transport socket error occurred. InProcessReceiver is likely dead."; 87 << "Transport socket error occurred. InProcessReceiver is likely dead.";
75 VLOG(1) << "CastTransportStatus is now " << status; 88 VLOG(1) << "CastTransportStatus is now " << status;
76 } 89 }
77 90
78 void InProcessReceiver::StartOnMainThread() { 91 void InProcessReceiver::StartOnMainThread() {
79 DCHECK(cast_environment_->CurrentlyOn(CastEnvironment::MAIN)); 92 DCHECK(cast_environment_->CurrentlyOn(CastEnvironment::MAIN));
80 93
81 DCHECK(!transport_ && !cast_receiver_); 94 DCHECK(!transport_ && !cast_receiver_);
82 95
83 transport_ = CastTransportSender::Create( 96 transport_ = CastTransportSender::Create(
84 NULL, 97 cast_environment_->Clock(), base::TimeDelta(),
85 cast_environment_->Clock(), 98 make_scoped_ptr(new InProcessReceiver::TransportClient(this)),
86 local_end_point_, 99 make_scoped_ptr(new UdpTransport(
87 remote_end_point_, 100 nullptr, cast_environment_->GetTaskRunner(CastEnvironment::MAIN),
88 scoped_ptr<base::DictionaryValue>(new base::DictionaryValue), 101 local_end_point_, remote_end_point_,
89 base::Bind(&InProcessReceiver::UpdateCastTransportStatus, 102 base::Bind(&InProcessReceiver::UpdateCastTransportStatus,
90 base::Unretained(this)), 103 base::Unretained(this)))),
91 BulkRawEventsCallback(),
92 base::TimeDelta(),
93 base::Bind(&InProcessReceiver::ReceivePacket,
94 base::Unretained(this)),
95 cast_environment_->GetTaskRunner(CastEnvironment::MAIN)); 104 cast_environment_->GetTaskRunner(CastEnvironment::MAIN));
96 105
97 cast_receiver_ = CastReceiver::Create( 106 cast_receiver_ = CastReceiver::Create(
98 cast_environment_, audio_config_, video_config_, transport_.get()); 107 cast_environment_, audio_config_, video_config_, transport_.get());
99 108
100 PullNextAudioFrame(); 109 PullNextAudioFrame();
101 PullNextVideoFrame(); 110 PullNextVideoFrame();
102 } 111 }
103 112
104 void InProcessReceiver::GotAudioFrame(scoped_ptr<AudioBus> audio_frame, 113 void InProcessReceiver::GotAudioFrame(scoped_ptr<AudioBus> audio_frame,
(...skipping 28 matching lines...) Expand all
133 &InProcessReceiver::GotVideoFrame, weak_factory_.GetWeakPtr())); 142 &InProcessReceiver::GotVideoFrame, weak_factory_.GetWeakPtr()));
134 } 143 }
135 144
136 void InProcessReceiver::ReceivePacket(scoped_ptr<Packet> packet) { 145 void InProcessReceiver::ReceivePacket(scoped_ptr<Packet> packet) {
137 // TODO(Hubbe): Make an InsertPacket method instead. 146 // TODO(Hubbe): Make an InsertPacket method instead.
138 cast_receiver_->ReceivePacket(std::move(packet)); 147 cast_receiver_->ReceivePacket(std::move(packet));
139 } 148 }
140 149
141 } // namespace cast 150 } // namespace cast
142 } // namespace media 151 } // namespace media
OLDNEW
« no previous file with comments | « media/cast/test/utility/in_process_receiver.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698