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 #include "media/cast/cast_sender_impl.h" | 4 #include "media/cast/cast_sender_impl.h" |
5 | 5 |
6 #include "base/bind.h" | 6 #include "base/bind.h" |
7 #include "base/callback.h" | 7 #include "base/callback.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "base/message_loop/message_loop.h" | 9 #include "base/message_loop/message_loop.h" |
10 #include "media/base/video_frame.h" | 10 #include "media/base/video_frame.h" |
(...skipping 22 matching lines...) Expand all Loading... |
33 } | 33 } |
34 | 34 |
35 virtual void InsertAudio(const AudioBus* audio_bus, | 35 virtual void InsertAudio(const AudioBus* audio_bus, |
36 const base::TimeTicks& recorded_time, | 36 const base::TimeTicks& recorded_time, |
37 const base::Closure& done_callback) OVERRIDE { | 37 const base::Closure& done_callback) OVERRIDE { |
38 cast_environment_->PostTask(CastEnvironment::MAIN, FROM_HERE, | 38 cast_environment_->PostTask(CastEnvironment::MAIN, FROM_HERE, |
39 base::Bind(&AudioSender::InsertAudio, audio_sender_, | 39 base::Bind(&AudioSender::InsertAudio, audio_sender_, |
40 audio_bus, recorded_time, done_callback)); | 40 audio_bus, recorded_time, done_callback)); |
41 } | 41 } |
42 | 42 |
43 virtual void InsertCodedAudioFrame(const EncodedAudioFrame* audio_frame, | 43 virtual void InsertCodedAudioFrame( |
44 const base::TimeTicks& recorded_time, | 44 const transport::EncodedAudioFrame* audio_frame, |
45 const base::Closure callback) OVERRIDE { | 45 const base::TimeTicks& recorded_time, |
| 46 const base::Closure callback) OVERRIDE { |
46 cast_environment_->PostTask(CastEnvironment::MAIN, FROM_HERE, | 47 cast_environment_->PostTask(CastEnvironment::MAIN, FROM_HERE, |
47 base::Bind(&AudioSender::InsertCodedAudioFrame, audio_sender_, | 48 base::Bind(&AudioSender::InsertCodedAudioFrame, audio_sender_, |
48 audio_frame, recorded_time, callback)); | 49 audio_frame, recorded_time, callback)); |
49 } | 50 } |
50 | 51 |
51 protected: | 52 protected: |
52 virtual ~LocalFrameInput() {} | 53 virtual ~LocalFrameInput() {} |
53 | 54 |
54 private: | 55 private: |
55 friend class base::RefCountedThreadSafe<LocalFrameInput>; | 56 friend class base::RefCountedThreadSafe<LocalFrameInput>; |
(...skipping 22 matching lines...) Expand all Loading... |
78 // e.g., audio encoding, over time. The SSRC identifier is a | 79 // e.g., audio encoding, over time. The SSRC identifier is a |
79 // randomly chosen value meant to be globally unique within a | 80 // randomly chosen value meant to be globally unique within a |
80 // particular RTP session (see Section 8). A participant need not | 81 // particular RTP session (see Section 8). A participant need not |
81 // use the same SSRC identifier for all the RTP sessions in a | 82 // use the same SSRC identifier for all the RTP sessions in a |
82 // multimedia session; the binding of the SSRC identifiers is | 83 // multimedia session; the binding of the SSRC identifiers is |
83 // provided through RTCP (see Section 6.5.1). If a participant | 84 // provided through RTCP (see Section 6.5.1). If a participant |
84 // generates multiple streams in one RTP session, for example from | 85 // generates multiple streams in one RTP session, for example from |
85 // separate video cameras, each MUST be identified as a different | 86 // separate video cameras, each MUST be identified as a different |
86 // SSRC. | 87 // SSRC. |
87 | 88 |
88 class LocalCastSenderPacketReceiver : public PacketReceiver { | 89 class LocalCastSenderPacketReceiver : public transport::PacketReceiver { |
89 public: | 90 public: |
90 LocalCastSenderPacketReceiver(scoped_refptr<CastEnvironment> cast_environment, | 91 LocalCastSenderPacketReceiver(scoped_refptr<CastEnvironment> cast_environment, |
91 base::WeakPtr<AudioSender> audio_sender, | 92 base::WeakPtr<AudioSender> audio_sender, |
92 base::WeakPtr<VideoSender> video_sender, | 93 base::WeakPtr<VideoSender> video_sender, |
93 uint32 ssrc_of_audio_sender, | 94 uint32 ssrc_of_audio_sender, |
94 uint32 ssrc_of_video_sender) | 95 uint32 ssrc_of_video_sender) |
95 : cast_environment_(cast_environment), | 96 : cast_environment_(cast_environment), |
96 audio_sender_(audio_sender), | 97 audio_sender_(audio_sender), |
97 video_sender_(video_sender), | 98 video_sender_(video_sender), |
98 ssrc_of_audio_sender_(ssrc_of_audio_sender), | 99 ssrc_of_audio_sender_(ssrc_of_audio_sender), |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
150 return new CastSenderImpl(cast_environment, audio_config, video_config, | 151 return new CastSenderImpl(cast_environment, audio_config, video_config, |
151 gpu_factories, packet_sender); | 152 gpu_factories, packet_sender); |
152 } | 153 } |
153 | 154 |
154 CastSenderImpl::CastSenderImpl( | 155 CastSenderImpl::CastSenderImpl( |
155 scoped_refptr<CastEnvironment> cast_environment, | 156 scoped_refptr<CastEnvironment> cast_environment, |
156 const AudioSenderConfig& audio_config, | 157 const AudioSenderConfig& audio_config, |
157 const VideoSenderConfig& video_config, | 158 const VideoSenderConfig& video_config, |
158 const scoped_refptr<GpuVideoAcceleratorFactories>& gpu_factories, | 159 const scoped_refptr<GpuVideoAcceleratorFactories>& gpu_factories, |
159 PacketSender* const packet_sender) | 160 PacketSender* const packet_sender) |
160 : pacer_(cast_environment, packet_sender), | 161 : pacer_(cast_environment->Clock(), packet_sender, |
| 162 cast_environment->GetMessageTaskRunnerForThread( |
| 163 CastEnvironment::TRANSPORT)), |
161 audio_sender_(cast_environment, audio_config, &pacer_), | 164 audio_sender_(cast_environment, audio_config, &pacer_), |
162 video_sender_(cast_environment, video_config, gpu_factories, &pacer_), | 165 video_sender_(cast_environment, video_config, gpu_factories, &pacer_), |
163 frame_input_(new LocalFrameInput(cast_environment, | 166 frame_input_(new LocalFrameInput(cast_environment, |
164 audio_sender_.AsWeakPtr(), | 167 audio_sender_.AsWeakPtr(), |
165 video_sender_.AsWeakPtr())), | 168 video_sender_.AsWeakPtr())), |
166 packet_receiver_(new LocalCastSenderPacketReceiver(cast_environment, | 169 packet_receiver_(new LocalCastSenderPacketReceiver(cast_environment, |
167 audio_sender_.AsWeakPtr(), video_sender_.AsWeakPtr(), | 170 audio_sender_.AsWeakPtr(), video_sender_.AsWeakPtr(), |
168 audio_config.incoming_feedback_ssrc, | 171 audio_config.incoming_feedback_ssrc, |
169 video_config.incoming_feedback_ssrc)) {} | 172 video_config.incoming_feedback_ssrc)) {} |
170 | 173 |
171 CastSenderImpl::~CastSenderImpl() {} | 174 CastSenderImpl::~CastSenderImpl() {} |
172 | 175 |
173 scoped_refptr<FrameInput> CastSenderImpl::frame_input() { | 176 scoped_refptr<FrameInput> CastSenderImpl::frame_input() { |
174 return frame_input_; | 177 return frame_input_; |
175 } | 178 } |
176 | 179 |
177 scoped_refptr<PacketReceiver> CastSenderImpl::packet_receiver() { | 180 scoped_refptr<transport::PacketReceiver> CastSenderImpl::packet_receiver() { |
178 return packet_receiver_; | 181 return packet_receiver_; |
179 } | 182 } |
180 | 183 |
181 } // namespace cast | 184 } // namespace cast |
182 } // namespace media | 185 } // namespace media |
OLD | NEW |