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 "media/cast/cast_sender_impl.h" | 5 #include "media/cast/cast_sender_impl.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/callback.h" | 8 #include "base/callback.h" |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/message_loop/message_loop.h" | 10 #include "base/message_loop/message_loop.h" |
11 #include "media/base/video_frame.h" | 11 #include "media/base/video_frame.h" |
12 | 12 |
13 namespace media { | 13 namespace media { |
14 namespace cast { | 14 namespace cast { |
15 | 15 |
16 // The LocalVideoFrameInput class posts all incoming video frames to the main | 16 // The LocalVideoFrameInput class posts all incoming video frames to the main |
17 // cast thread for processing. | 17 // cast thread for processing. |
18 class LocalVideoFrameInput : public VideoFrameInput { | 18 class LocalVideoFrameInput : public VideoFrameInput { |
19 public: | 19 public: |
20 LocalVideoFrameInput(scoped_refptr<CastEnvironment> cast_environment, | 20 LocalVideoFrameInput(scoped_refptr<CastEnvironment> cast_environment, |
21 base::WeakPtr<VideoSender> video_sender) | 21 base::WeakPtr<VideoSender> video_sender, |
22 : cast_environment_(cast_environment), video_sender_(video_sender) {} | 22 scoped_refptr<VideoFrameFactory> video_frame_factory) |
23 : cast_environment_(cast_environment), | |
24 video_sender_(video_sender), | |
25 video_frame_factory_(video_frame_factory) {} | |
23 | 26 |
24 void InsertRawVideoFrame(const scoped_refptr<media::VideoFrame>& video_frame, | 27 void InsertRawVideoFrame(const scoped_refptr<media::VideoFrame>& video_frame, |
25 const base::TimeTicks& capture_time) override { | 28 const base::TimeTicks& capture_time) override { |
26 cast_environment_->PostTask(CastEnvironment::MAIN, | 29 cast_environment_->PostTask(CastEnvironment::MAIN, |
27 FROM_HERE, | 30 FROM_HERE, |
28 base::Bind(&VideoSender::InsertRawVideoFrame, | 31 base::Bind(&VideoSender::InsertRawVideoFrame, |
29 video_sender_, | 32 video_sender_, |
30 video_frame, | 33 video_frame, |
31 capture_time)); | 34 capture_time)); |
32 } | 35 } |
33 | 36 |
37 scoped_refptr<VideoFrame> CreateFrame(base::TimeDelta timestamp) override { | |
38 return video_frame_factory_->CreateFrame(timestamp); | |
Alpha Left Google
2014/11/17 20:23:14
Why not create VideoFrame through VideoSender?
jfroy
2014/11/17 21:23:06
My understanding is that VideoFrameInput is ref co
Alpha Left Google
2014/11/18 02:57:58
In a latter comment you mentioned that the created
jfroy
2014/11/18 18:03:58
That sounds pretty good.
| |
39 } | |
40 | |
34 protected: | 41 protected: |
35 ~LocalVideoFrameInput() override {} | 42 ~LocalVideoFrameInput() override {} |
36 | 43 |
37 private: | 44 private: |
38 friend class base::RefCountedThreadSafe<LocalVideoFrameInput>; | 45 friend class base::RefCountedThreadSafe<LocalVideoFrameInput>; |
39 | 46 |
40 scoped_refptr<CastEnvironment> cast_environment_; | 47 scoped_refptr<CastEnvironment> cast_environment_; |
41 base::WeakPtr<VideoSender> video_sender_; | 48 base::WeakPtr<VideoSender> video_sender_; |
49 scoped_refptr<VideoFrameFactory> video_frame_factory_; | |
Alpha Left Google
2014/11/17 20:23:14
Please don't save VideoFrameFactory. It's an inter
jfroy
2014/11/17 21:23:06
See my note above. I made VideoFrameFactory a thre
| |
42 | 50 |
43 DISALLOW_COPY_AND_ASSIGN(LocalVideoFrameInput); | 51 DISALLOW_COPY_AND_ASSIGN(LocalVideoFrameInput); |
44 }; | 52 }; |
45 | 53 |
46 // The LocalAudioFrameInput class posts all incoming audio frames to the main | 54 // The LocalAudioFrameInput class posts all incoming audio frames to the main |
47 // cast thread for processing. Therefore frames can be inserted from any thread. | 55 // cast thread for processing. Therefore frames can be inserted from any thread. |
48 class LocalAudioFrameInput : public AudioFrameInput { | 56 class LocalAudioFrameInput : public AudioFrameInput { |
49 public: | 57 public: |
50 LocalAudioFrameInput(scoped_refptr<CastEnvironment> cast_environment, | 58 LocalAudioFrameInput(scoped_refptr<CastEnvironment> cast_environment, |
51 base::WeakPtr<AudioSender> audio_sender) | 59 base::WeakPtr<AudioSender> audio_sender) |
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
163 if (video_sender_) { | 171 if (video_sender_) { |
164 video_sender_->SetTargetPlayoutDelay(new_target_playout_delay); | 172 video_sender_->SetTargetPlayoutDelay(new_target_playout_delay); |
165 } | 173 } |
166 } | 174 } |
167 | 175 |
168 void CastSenderImpl::OnVideoInitialized( | 176 void CastSenderImpl::OnVideoInitialized( |
169 const CastInitializationCallback& initialization_cb, | 177 const CastInitializationCallback& initialization_cb, |
170 media::cast::CastInitializationStatus result) { | 178 media::cast::CastInitializationStatus result) { |
171 DCHECK(cast_environment_->CurrentlyOn(CastEnvironment::MAIN)); | 179 DCHECK(cast_environment_->CurrentlyOn(CastEnvironment::MAIN)); |
172 video_frame_input_ = | 180 video_frame_input_ = |
173 new LocalVideoFrameInput(cast_environment_, video_sender_->AsWeakPtr()); | 181 new LocalVideoFrameInput(cast_environment_, |
182 video_sender_->AsWeakPtr(), | |
183 video_sender_->video_frame_factory()); | |
174 initialization_cb.Run(result); | 184 initialization_cb.Run(result); |
175 } | 185 } |
176 | 186 |
177 } // namespace cast | 187 } // namespace cast |
178 } // namespace media | 188 } // namespace media |
OLD | NEW |