OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "media/video/capture/screen/shared_desktop_frame.h" |
| 6 |
| 7 #include "base/memory/scoped_ptr.h" |
| 8 |
| 9 namespace media { |
| 10 |
| 11 class SharedDesktopFrame::Core : public base::RefCountedThreadSafe<Core> { |
| 12 public: |
| 13 Core(webrtc::DesktopFrame* frame) : frame_(frame) {} |
| 14 |
| 15 webrtc::DesktopFrame* frame() { return frame_.get(); } |
| 16 |
| 17 private: |
| 18 friend class base::RefCountedThreadSafe<Core>; |
| 19 virtual ~Core() {} |
| 20 |
| 21 scoped_ptr<webrtc::DesktopFrame> frame_; |
| 22 |
| 23 DISALLOW_COPY_AND_ASSIGN(Core); |
| 24 }; |
| 25 |
| 26 SharedDesktopFrame::~SharedDesktopFrame() {} |
| 27 |
| 28 // static |
| 29 SharedDesktopFrame* SharedDesktopFrame::Wrap( |
| 30 webrtc::DesktopFrame* desktop_frame) { |
| 31 return new SharedDesktopFrame(new Core(desktop_frame)); |
| 32 } |
| 33 |
| 34 webrtc::DesktopFrame* SharedDesktopFrame::GetUnderlyingFrame() { |
| 35 return core_->frame(); |
| 36 } |
| 37 |
| 38 SharedDesktopFrame* SharedDesktopFrame::Share() { |
| 39 SharedDesktopFrame* result = new SharedDesktopFrame(core_); |
| 40 result->set_dpi(dpi()); |
| 41 result->set_capture_time_ms(capture_time_ms()); |
| 42 *result->mutable_updated_region() = updated_region(); |
| 43 return result; |
| 44 } |
| 45 |
| 46 bool SharedDesktopFrame::IsNotShared() { |
| 47 return core_->HasOneRef(); |
| 48 } |
| 49 |
| 50 SharedDesktopFrame::SharedDesktopFrame(scoped_refptr<Core> core) |
| 51 : DesktopFrame(core->frame()->size(), core->frame()->stride(), |
| 52 core->frame()->data(), core->frame()->shared_memory()), |
| 53 core_(core) { |
| 54 } |
| 55 |
| 56 } // namespace media |
OLD | NEW |