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 : cast_environment_(cast_environment), video_sender_(video_sender) {} |
23 | 23 |
24 virtual void InsertRawVideoFrame( | 24 virtual void InsertRawVideoFrame( |
25 const scoped_refptr<media::VideoFrame>& video_frame, | 25 const scoped_refptr<media::VideoFrame>& video_frame, |
26 const base::TimeTicks& capture_time) OVERRIDE { | 26 const base::TimeTicks& capture_time) override { |
27 cast_environment_->PostTask(CastEnvironment::MAIN, | 27 cast_environment_->PostTask(CastEnvironment::MAIN, |
28 FROM_HERE, | 28 FROM_HERE, |
29 base::Bind(&VideoSender::InsertRawVideoFrame, | 29 base::Bind(&VideoSender::InsertRawVideoFrame, |
30 video_sender_, | 30 video_sender_, |
31 video_frame, | 31 video_frame, |
32 capture_time)); | 32 capture_time)); |
33 } | 33 } |
34 | 34 |
35 protected: | 35 protected: |
36 virtual ~LocalVideoFrameInput() {} | 36 virtual ~LocalVideoFrameInput() {} |
37 | 37 |
38 private: | 38 private: |
39 friend class base::RefCountedThreadSafe<LocalVideoFrameInput>; | 39 friend class base::RefCountedThreadSafe<LocalVideoFrameInput>; |
40 | 40 |
41 scoped_refptr<CastEnvironment> cast_environment_; | 41 scoped_refptr<CastEnvironment> cast_environment_; |
42 base::WeakPtr<VideoSender> video_sender_; | 42 base::WeakPtr<VideoSender> video_sender_; |
43 | 43 |
44 DISALLOW_COPY_AND_ASSIGN(LocalVideoFrameInput); | 44 DISALLOW_COPY_AND_ASSIGN(LocalVideoFrameInput); |
45 }; | 45 }; |
46 | 46 |
47 // The LocalAudioFrameInput class posts all incoming audio frames to the main | 47 // The LocalAudioFrameInput class posts all incoming audio frames to the main |
48 // cast thread for processing. Therefore frames can be inserted from any thread. | 48 // cast thread for processing. Therefore frames can be inserted from any thread. |
49 class LocalAudioFrameInput : public AudioFrameInput { | 49 class LocalAudioFrameInput : public AudioFrameInput { |
50 public: | 50 public: |
51 LocalAudioFrameInput(scoped_refptr<CastEnvironment> cast_environment, | 51 LocalAudioFrameInput(scoped_refptr<CastEnvironment> cast_environment, |
52 base::WeakPtr<AudioSender> audio_sender) | 52 base::WeakPtr<AudioSender> audio_sender) |
53 : cast_environment_(cast_environment), audio_sender_(audio_sender) {} | 53 : cast_environment_(cast_environment), audio_sender_(audio_sender) {} |
54 | 54 |
55 virtual void InsertAudio(scoped_ptr<AudioBus> audio_bus, | 55 virtual void InsertAudio(scoped_ptr<AudioBus> audio_bus, |
56 const base::TimeTicks& recorded_time) OVERRIDE { | 56 const base::TimeTicks& recorded_time) override { |
57 cast_environment_->PostTask(CastEnvironment::MAIN, | 57 cast_environment_->PostTask(CastEnvironment::MAIN, |
58 FROM_HERE, | 58 FROM_HERE, |
59 base::Bind(&AudioSender::InsertAudio, | 59 base::Bind(&AudioSender::InsertAudio, |
60 audio_sender_, | 60 audio_sender_, |
61 base::Passed(&audio_bus), | 61 base::Passed(&audio_bus), |
62 recorded_time)); | 62 recorded_time)); |
63 } | 63 } |
64 | 64 |
65 protected: | 65 protected: |
66 virtual ~LocalAudioFrameInput() {} | 66 virtual ~LocalAudioFrameInput() {} |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
170 const CastInitializationCallback& initialization_cb, | 170 const CastInitializationCallback& initialization_cb, |
171 media::cast::CastInitializationStatus result) { | 171 media::cast::CastInitializationStatus result) { |
172 DCHECK(cast_environment_->CurrentlyOn(CastEnvironment::MAIN)); | 172 DCHECK(cast_environment_->CurrentlyOn(CastEnvironment::MAIN)); |
173 video_frame_input_ = | 173 video_frame_input_ = |
174 new LocalVideoFrameInput(cast_environment_, video_sender_->AsWeakPtr()); | 174 new LocalVideoFrameInput(cast_environment_, video_sender_->AsWeakPtr()); |
175 initialization_cb.Run(result); | 175 initialization_cb.Run(result); |
176 } | 176 } |
177 | 177 |
178 } // namespace cast | 178 } // namespace cast |
179 } // namespace media | 179 } // namespace media |
OLD | NEW |