Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(407)

Side by Side Diff: media/cast/cast_sender_impl.cc

Issue 906403006: [Cast] Size-Adaptable platform video encoders. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressed hubbe's comments. Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « media/cast/cast_sender.h ('k') | media/cast/cast_testing.gypi » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 #include "media/cast/sender/video_frame_factory.h" 12 #include "media/cast/sender/video_frame_factory.h"
13 13
14 namespace media { 14 namespace media {
15 namespace cast { 15 namespace cast {
16 16
17 // The LocalVideoFrameInput class posts all incoming video frames to the main 17 // The LocalVideoFrameInput class posts all incoming video frames to the main
18 // cast thread for processing. 18 // cast thread for processing.
19 class LocalVideoFrameInput : public VideoFrameInput { 19 class LocalVideoFrameInput : public VideoFrameInput {
20 public: 20 public:
21 LocalVideoFrameInput(scoped_refptr<CastEnvironment> cast_environment, 21 LocalVideoFrameInput(scoped_refptr<CastEnvironment> cast_environment,
22 base::WeakPtr<VideoSender> video_sender, 22 base::WeakPtr<VideoSender> video_sender)
23 scoped_ptr<VideoFrameFactory> video_frame_factory)
24 : cast_environment_(cast_environment), 23 : cast_environment_(cast_environment),
25 video_sender_(video_sender), 24 video_sender_(video_sender),
26 video_frame_factory_(video_frame_factory.Pass()) {} 25 video_frame_factory_(
26 video_sender.get() ?
27 video_sender->CreateVideoFrameFactory().release() : nullptr) {}
27 28
28 void InsertRawVideoFrame(const scoped_refptr<media::VideoFrame>& video_frame, 29 void InsertRawVideoFrame(const scoped_refptr<media::VideoFrame>& video_frame,
29 const base::TimeTicks& capture_time) override { 30 const base::TimeTicks& capture_time) override {
30 cast_environment_->PostTask(CastEnvironment::MAIN, 31 cast_environment_->PostTask(CastEnvironment::MAIN,
31 FROM_HERE, 32 FROM_HERE,
32 base::Bind(&VideoSender::InsertRawVideoFrame, 33 base::Bind(&VideoSender::InsertRawVideoFrame,
33 video_sender_, 34 video_sender_,
34 video_frame, 35 video_frame,
35 capture_time)); 36 capture_time));
36 } 37 }
37 38
38 scoped_refptr<VideoFrame> CreateOptimizedFrame( 39 scoped_refptr<VideoFrame> MaybeCreateOptimizedFrame(
40 const gfx::Size& frame_size,
39 base::TimeDelta timestamp) override { 41 base::TimeDelta timestamp) override {
40 DCHECK(video_frame_factory_.get()); 42 return video_frame_factory_ ?
41 return video_frame_factory_->CreateFrame(timestamp); 43 video_frame_factory_->MaybeCreateFrame(frame_size, timestamp) : nullptr;
42 } 44 }
43 45
44 bool SupportsCreateOptimizedFrame() const override { 46 bool CanCreateOptimizedFrames() const override {
45 return video_frame_factory_.get() != nullptr; 47 return video_frame_factory_.get() != nullptr;
46 } 48 }
47 49
48 protected: 50 protected:
49 ~LocalVideoFrameInput() override {} 51 ~LocalVideoFrameInput() override {}
50 52
51 private: 53 private:
52 friend class base::RefCountedThreadSafe<LocalVideoFrameInput>; 54 friend class base::RefCountedThreadSafe<LocalVideoFrameInput>;
53 55
54 scoped_refptr<CastEnvironment> cast_environment_; 56 const scoped_refptr<CastEnvironment> cast_environment_;
55 base::WeakPtr<VideoSender> video_sender_; 57 const base::WeakPtr<VideoSender> video_sender_;
56 scoped_ptr<VideoFrameFactory> video_frame_factory_; 58 const scoped_ptr<VideoFrameFactory> video_frame_factory_;
57 59
58 DISALLOW_COPY_AND_ASSIGN(LocalVideoFrameInput); 60 DISALLOW_COPY_AND_ASSIGN(LocalVideoFrameInput);
59 }; 61 };
60 62
61 // The LocalAudioFrameInput class posts all incoming audio frames to the main 63 // The LocalAudioFrameInput class posts all incoming audio frames to the main
62 // cast thread for processing. Therefore frames can be inserted from any thread. 64 // cast thread for processing. Therefore frames can be inserted from any thread.
63 class LocalAudioFrameInput : public AudioFrameInput { 65 class LocalAudioFrameInput : public AudioFrameInput {
64 public: 66 public:
65 LocalAudioFrameInput(scoped_refptr<CastEnvironment> cast_environment, 67 LocalAudioFrameInput(scoped_refptr<CastEnvironment> cast_environment,
66 base::WeakPtr<AudioSender> audio_sender) 68 base::WeakPtr<AudioSender> audio_sender)
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
187 } 189 }
188 status_change_cb.Run(status); 190 status_change_cb.Run(status);
189 } 191 }
190 192
191 void CastSenderImpl::OnVideoStatusChange( 193 void CastSenderImpl::OnVideoStatusChange(
192 const StatusChangeCallback& status_change_cb, 194 const StatusChangeCallback& status_change_cb,
193 OperationalStatus status) { 195 OperationalStatus status) {
194 DCHECK(cast_environment_->CurrentlyOn(CastEnvironment::MAIN)); 196 DCHECK(cast_environment_->CurrentlyOn(CastEnvironment::MAIN));
195 if (status == STATUS_INITIALIZED && !video_frame_input_) { 197 if (status == STATUS_INITIALIZED && !video_frame_input_) {
196 video_frame_input_ = 198 video_frame_input_ =
197 new LocalVideoFrameInput(cast_environment_, video_sender_->AsWeakPtr(), 199 new LocalVideoFrameInput(cast_environment_, video_sender_->AsWeakPtr());
198 video_sender_->CreateVideoFrameFactory());
199 } 200 }
200 status_change_cb.Run(status); 201 status_change_cb.Run(status);
201 } 202 }
202 203
203 } // namespace cast 204 } // namespace cast
204 } // namespace media 205 } // namespace media
OLDNEW
« no previous file with comments | « media/cast/cast_sender.h ('k') | media/cast/cast_testing.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698