OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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_session.h" | 5 #include "chrome/renderer/media/cast_session.h" |
6 | 6 |
| 7 #include "base/bind_to_current_loop.h" |
7 #include "base/message_loop/message_loop_proxy.h" | 8 #include "base/message_loop/message_loop_proxy.h" |
8 #include "chrome/renderer/media/cast_session_delegate.h" | 9 #include "chrome/renderer/media/cast_session_delegate.h" |
9 #include "content/public/renderer/render_thread.h" | 10 #include "content/public/renderer/render_thread.h" |
10 #include "content/public/renderer/video_encode_accelerator.h" | 11 #include "content/public/renderer/video_encode_accelerator.h" |
11 #include "media/base/bind_to_current_loop.h" | |
12 #include "media/base/video_frame.h" | 12 #include "media/base/video_frame.h" |
13 #include "media/cast/cast_config.h" | 13 #include "media/cast/cast_config.h" |
14 #include "media/cast/cast_sender.h" | 14 #include "media/cast/cast_sender.h" |
15 #include "media/cast/logging/logging_defines.h" | 15 #include "media/cast/logging/logging_defines.h" |
16 | 16 |
17 namespace { | 17 namespace { |
18 | 18 |
19 void CreateVideoEncodeAccelerator( | 19 void CreateVideoEncodeAccelerator( |
20 const media::cast::ReceiveVideoEncodeAcceleratorCallback& callback) { | 20 const media::cast::ReceiveVideoEncodeAcceleratorCallback& callback) { |
21 DCHECK(content::RenderThread::Get()); | 21 DCHECK(content::RenderThread::Get()); |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
54 const AudioFrameInputAvailableCallback& callback, | 54 const AudioFrameInputAvailableCallback& callback, |
55 const ErrorCallback& error_callback) { | 55 const ErrorCallback& error_callback) { |
56 DCHECK(content::RenderThread::Get() | 56 DCHECK(content::RenderThread::Get() |
57 ->GetTaskRunner()->BelongsToCurrentThread()); | 57 ->GetTaskRunner()->BelongsToCurrentThread()); |
58 | 58 |
59 io_message_loop_proxy_->PostTask( | 59 io_message_loop_proxy_->PostTask( |
60 FROM_HERE, | 60 FROM_HERE, |
61 base::Bind(&CastSessionDelegate::StartAudio, | 61 base::Bind(&CastSessionDelegate::StartAudio, |
62 base::Unretained(delegate_.get()), | 62 base::Unretained(delegate_.get()), |
63 config, | 63 config, |
64 media::BindToCurrentLoop(callback), | 64 base::BindToCurrentLoop(callback), |
65 media::BindToCurrentLoop(error_callback))); | 65 base::BindToCurrentLoop(error_callback))); |
66 } | 66 } |
67 | 67 |
68 void CastSession::StartVideo(const media::cast::VideoSenderConfig& config, | 68 void CastSession::StartVideo(const media::cast::VideoSenderConfig& config, |
69 const VideoFrameInputAvailableCallback& callback, | 69 const VideoFrameInputAvailableCallback& callback, |
70 const ErrorCallback& error_callback) { | 70 const ErrorCallback& error_callback) { |
71 DCHECK(content::RenderThread::Get() | 71 DCHECK(content::RenderThread::Get() |
72 ->GetTaskRunner()->BelongsToCurrentThread()); | 72 ->GetTaskRunner()->BelongsToCurrentThread()); |
73 | 73 |
74 io_message_loop_proxy_->PostTask( | 74 io_message_loop_proxy_->PostTask( |
75 FROM_HERE, | 75 FROM_HERE, |
76 base::Bind(&CastSessionDelegate::StartVideo, | 76 base::Bind(&CastSessionDelegate::StartVideo, |
77 base::Unretained(delegate_.get()), | 77 base::Unretained(delegate_.get()), |
78 config, | 78 config, |
79 media::BindToCurrentLoop(callback), | 79 base::BindToCurrentLoop(callback), |
80 media::BindToCurrentLoop(error_callback), | 80 base::BindToCurrentLoop(error_callback), |
81 media::BindToCurrentLoop( | 81 base::BindToCurrentLoop( |
82 base::Bind(&CreateVideoEncodeAccelerator)), | 82 base::Bind(&CreateVideoEncodeAccelerator)), |
83 media::BindToCurrentLoop( | 83 base::BindToCurrentLoop( |
84 base::Bind(&CreateVideoEncodeMemory)))); | 84 base::Bind(&CreateVideoEncodeMemory)))); |
85 } | 85 } |
86 | 86 |
87 void CastSession::StartUDP(const net::IPEndPoint& remote_endpoint, | 87 void CastSession::StartUDP(const net::IPEndPoint& remote_endpoint, |
88 scoped_ptr<base::DictionaryValue> options, | 88 scoped_ptr<base::DictionaryValue> options, |
89 const ErrorCallback& error_callback) { | 89 const ErrorCallback& error_callback) { |
90 io_message_loop_proxy_->PostTask( | 90 io_message_loop_proxy_->PostTask( |
91 FROM_HERE, | 91 FROM_HERE, |
92 base::Bind( | 92 base::Bind( |
93 &CastSessionDelegate::StartUDP, | 93 &CastSessionDelegate::StartUDP, |
94 base::Unretained(delegate_.get()), | 94 base::Unretained(delegate_.get()), |
95 net::IPEndPoint(), | 95 net::IPEndPoint(), |
96 remote_endpoint, | 96 remote_endpoint, |
97 base::Passed(&options), | 97 base::Passed(&options), |
98 media::BindToCurrentLoop(error_callback))); | 98 base::BindToCurrentLoop(error_callback))); |
99 } | 99 } |
100 | 100 |
101 void CastSession::ToggleLogging(bool is_audio, bool enable) { | 101 void CastSession::ToggleLogging(bool is_audio, bool enable) { |
102 io_message_loop_proxy_->PostTask( | 102 io_message_loop_proxy_->PostTask( |
103 FROM_HERE, | 103 FROM_HERE, |
104 base::Bind(&CastSessionDelegate::ToggleLogging, | 104 base::Bind(&CastSessionDelegate::ToggleLogging, |
105 base::Unretained(delegate_.get()), | 105 base::Unretained(delegate_.get()), |
106 is_audio, | 106 is_audio, |
107 enable)); | 107 enable)); |
108 } | 108 } |
109 | 109 |
110 void CastSession::GetEventLogsAndReset( | 110 void CastSession::GetEventLogsAndReset( |
111 bool is_audio, const std::string& extra_data, | 111 bool is_audio, const std::string& extra_data, |
112 const EventLogsCallback& callback) { | 112 const EventLogsCallback& callback) { |
113 io_message_loop_proxy_->PostTask( | 113 io_message_loop_proxy_->PostTask( |
114 FROM_HERE, | 114 FROM_HERE, |
115 base::Bind(&CastSessionDelegate::GetEventLogsAndReset, | 115 base::Bind(&CastSessionDelegate::GetEventLogsAndReset, |
116 base::Unretained(delegate_.get()), | 116 base::Unretained(delegate_.get()), |
117 is_audio, | 117 is_audio, |
118 extra_data, | 118 extra_data, |
119 media::BindToCurrentLoop(callback))); | 119 base::BindToCurrentLoop(callback))); |
120 } | 120 } |
121 | 121 |
122 void CastSession::GetStatsAndReset(bool is_audio, | 122 void CastSession::GetStatsAndReset(bool is_audio, |
123 const StatsCallback& callback) { | 123 const StatsCallback& callback) { |
124 io_message_loop_proxy_->PostTask( | 124 io_message_loop_proxy_->PostTask( |
125 FROM_HERE, | 125 FROM_HERE, |
126 base::Bind(&CastSessionDelegate::GetStatsAndReset, | 126 base::Bind(&CastSessionDelegate::GetStatsAndReset, |
127 base::Unretained(delegate_.get()), | 127 base::Unretained(delegate_.get()), |
128 is_audio, | 128 is_audio, |
129 media::BindToCurrentLoop(callback))); | 129 base::BindToCurrentLoop(callback))); |
130 } | 130 } |
OLD | NEW |