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