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/macros.h" | 10 #include "base/macros.h" |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
49 } | 49 } |
50 | 50 |
51 protected: | 51 protected: |
52 ~LocalVideoFrameInput() final {} | 52 ~LocalVideoFrameInput() final {} |
53 | 53 |
54 private: | 54 private: |
55 friend class base::RefCountedThreadSafe<LocalVideoFrameInput>; | 55 friend class base::RefCountedThreadSafe<LocalVideoFrameInput>; |
56 | 56 |
57 const scoped_refptr<CastEnvironment> cast_environment_; | 57 const scoped_refptr<CastEnvironment> cast_environment_; |
58 const base::WeakPtr<VideoSender> video_sender_; | 58 const base::WeakPtr<VideoSender> video_sender_; |
59 const scoped_ptr<VideoFrameFactory> video_frame_factory_; | 59 const std::unique_ptr<VideoFrameFactory> video_frame_factory_; |
60 | 60 |
61 DISALLOW_COPY_AND_ASSIGN(LocalVideoFrameInput); | 61 DISALLOW_COPY_AND_ASSIGN(LocalVideoFrameInput); |
62 }; | 62 }; |
63 | 63 |
64 // The LocalAudioFrameInput class posts all incoming audio frames to the main | 64 // The LocalAudioFrameInput class posts all incoming audio frames to the main |
65 // cast thread for processing. Therefore frames can be inserted from any thread. | 65 // cast thread for processing. Therefore frames can be inserted from any thread. |
66 class LocalAudioFrameInput : public AudioFrameInput { | 66 class LocalAudioFrameInput : public AudioFrameInput { |
67 public: | 67 public: |
68 LocalAudioFrameInput(scoped_refptr<CastEnvironment> cast_environment, | 68 LocalAudioFrameInput(scoped_refptr<CastEnvironment> cast_environment, |
69 base::WeakPtr<AudioSender> audio_sender) | 69 base::WeakPtr<AudioSender> audio_sender) |
70 : cast_environment_(cast_environment), audio_sender_(audio_sender) {} | 70 : cast_environment_(cast_environment), audio_sender_(audio_sender) {} |
71 | 71 |
72 void InsertAudio(scoped_ptr<AudioBus> audio_bus, | 72 void InsertAudio(std::unique_ptr<AudioBus> audio_bus, |
73 const base::TimeTicks& recorded_time) final { | 73 const base::TimeTicks& recorded_time) final { |
74 cast_environment_->PostTask(CastEnvironment::MAIN, | 74 cast_environment_->PostTask(CastEnvironment::MAIN, |
75 FROM_HERE, | 75 FROM_HERE, |
76 base::Bind(&AudioSender::InsertAudio, | 76 base::Bind(&AudioSender::InsertAudio, |
77 audio_sender_, | 77 audio_sender_, |
78 base::Passed(&audio_bus), | 78 base::Passed(&audio_bus), |
79 recorded_time)); | 79 recorded_time)); |
80 } | 80 } |
81 | 81 |
82 protected: | 82 protected: |
83 ~LocalAudioFrameInput() final {} | 83 ~LocalAudioFrameInput() final {} |
84 | 84 |
85 private: | 85 private: |
86 friend class base::RefCountedThreadSafe<LocalAudioFrameInput>; | 86 friend class base::RefCountedThreadSafe<LocalAudioFrameInput>; |
87 | 87 |
88 scoped_refptr<CastEnvironment> cast_environment_; | 88 scoped_refptr<CastEnvironment> cast_environment_; |
89 base::WeakPtr<AudioSender> audio_sender_; | 89 base::WeakPtr<AudioSender> audio_sender_; |
90 | 90 |
91 DISALLOW_COPY_AND_ASSIGN(LocalAudioFrameInput); | 91 DISALLOW_COPY_AND_ASSIGN(LocalAudioFrameInput); |
92 }; | 92 }; |
93 | 93 |
94 scoped_ptr<CastSender> CastSender::Create( | 94 std::unique_ptr<CastSender> CastSender::Create( |
95 scoped_refptr<CastEnvironment> cast_environment, | 95 scoped_refptr<CastEnvironment> cast_environment, |
96 CastTransport* const transport_sender) { | 96 CastTransport* const transport_sender) { |
97 CHECK(cast_environment.get()); | 97 CHECK(cast_environment.get()); |
98 return scoped_ptr<CastSender>( | 98 return std::unique_ptr<CastSender>( |
99 new CastSenderImpl(cast_environment, transport_sender)); | 99 new CastSenderImpl(cast_environment, transport_sender)); |
100 } | 100 } |
101 | 101 |
102 CastSenderImpl::CastSenderImpl(scoped_refptr<CastEnvironment> cast_environment, | 102 CastSenderImpl::CastSenderImpl(scoped_refptr<CastEnvironment> cast_environment, |
103 CastTransport* const transport_sender) | 103 CastTransport* const transport_sender) |
104 : cast_environment_(cast_environment), | 104 : cast_environment_(cast_environment), |
105 transport_sender_(transport_sender), | 105 transport_sender_(transport_sender), |
106 weak_factory_(this) { | 106 weak_factory_(this) { |
107 CHECK(cast_environment.get()); | 107 CHECK(cast_environment.get()); |
108 } | 108 } |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
196 DCHECK(cast_environment_->CurrentlyOn(CastEnvironment::MAIN)); | 196 DCHECK(cast_environment_->CurrentlyOn(CastEnvironment::MAIN)); |
197 if (status == STATUS_INITIALIZED && !video_frame_input_) { | 197 if (status == STATUS_INITIALIZED && !video_frame_input_) { |
198 video_frame_input_ = | 198 video_frame_input_ = |
199 new LocalVideoFrameInput(cast_environment_, video_sender_->AsWeakPtr()); | 199 new LocalVideoFrameInput(cast_environment_, video_sender_->AsWeakPtr()); |
200 } | 200 } |
201 status_change_cb.Run(status); | 201 status_change_cb.Run(status); |
202 } | 202 } |
203 | 203 |
204 } // namespace cast | 204 } // namespace cast |
205 } // namespace media | 205 } // namespace media |
OLD | NEW |