| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 #ifndef REMOTING_HOST_DESKTOP_ENVIRONMENT_H_ | 5 #ifndef REMOTING_HOST_DESKTOP_ENVIRONMENT_H_ |
| 6 #define REMOTING_HOST_DESKTOP_ENVIRONMENT_H_ | 6 #define REMOTING_HOST_DESKTOP_ENVIRONMENT_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
| 11 #include "base/callback_forward.h" | 11 #include "base/callback_forward.h" |
| 12 #include "base/memory/ref_counted.h" |
| 12 #include "base/memory/scoped_ptr.h" | 13 #include "base/memory/scoped_ptr.h" |
| 14 #include "remoting/protocol/clipboard_stub.h" |
| 15 #include "remoting/protocol/input_stub.h" |
| 16 #include "third_party/skia/include/core/SkSize.h" |
| 17 |
| 18 namespace base { |
| 19 class SingleThreadTaskRunner; |
| 20 } // namespace base |
| 13 | 21 |
| 14 namespace remoting { | 22 namespace remoting { |
| 15 | 23 |
| 16 class AudioCapturer; | 24 class AudioEncoder; |
| 17 class EventExecutor; | 25 class VideoEncoder; |
| 18 class VideoFrameCapturer; | |
| 19 | 26 |
| 20 namespace protocol { | 27 namespace protocol { |
| 21 class ClipboardStub; | 28 class AudioStub; |
| 22 } | 29 class CursorShapeStub; |
| 30 class VideoStub; |
| 31 } // namespace protocol |
| 23 | 32 |
| 24 class DesktopEnvironment { | 33 // This interface provides audio/video capturing, input injection and clipboard |
| 34 // handling capatilities utilized by ClientSession. All public methods of |
| 35 // DesktopEnvironment must be called on the network thread. |
| 36 class DesktopEnvironment |
| 37 : public protocol::ClipboardStub, |
| 38 public protocol::InputStub { |
| 25 public: | 39 public: |
| 26 DesktopEnvironment(scoped_ptr<AudioCapturer> audio_capturer, | 40 DesktopEnvironment() {} |
| 27 scoped_ptr<EventExecutor> event_executor, | 41 virtual ~DesktopEnvironment() {} |
| 28 scoped_ptr<VideoFrameCapturer> video_capturer); | |
| 29 virtual ~DesktopEnvironment(); | |
| 30 | 42 |
| 31 AudioCapturer* audio_capturer() const { return audio_capturer_.get(); } | 43 // Starts recording audio. Recorded audio packets are ecoded by |
| 32 EventExecutor* event_executor() const { return event_executor_.get(); } | 44 // |audio_encoder| and passed to |audio_stub|. |audio_stub| must outlive |
| 33 VideoFrameCapturer* video_capturer() const { return video_capturer_.get(); } | 45 // |this|. |
| 46 virtual void StartAudio( |
| 47 scoped_refptr<base::SingleThreadTaskRunner> audio_task_runner, |
| 48 scoped_ptr<AudioEncoder> audio_encoder, |
| 49 protocol::AudioStub* audio_stub) = 0; |
| 34 | 50 |
| 35 // Starts the desktop environment passing |client_jid| of the attached | 51 // Enable or disable audio on a running session. |
| 36 // authenticated session. Registers |client_clipboard| to receive | 52 // This leaves the audio capturer running, and only affects whether or not the |
| 37 // notifications about local clipboard changes. |disconnect_callback| can be | 53 // captured audio is encoded and sent on the wire. |
| 38 // invoked by the DesktopEnvironment to request the client session to be | 54 virtual void PauseAudio(bool pause) = 0; |
| 39 // disconnected. |disconnect_callback| is invoked on the same thread Start() | 55 |
| 40 // has been called on. | 56 // Starts input injection and registers |clipboard_stub| to receive local |
| 41 virtual void Start( | 57 // clipboard updates. |clipboard_stub| must outlive |this|. |
| 42 scoped_ptr<protocol::ClipboardStub> client_clipboard, | 58 virtual void StartInput( |
| 43 const std::string& client_jid, | 59 scoped_refptr<base::SingleThreadTaskRunner> input_task_runner, |
| 44 const base::Closure& disconnect_callback); | 60 scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner, |
| 61 protocol::ClipboardStub* clipboard_stub) = 0; |
| 62 |
| 63 // Starts capturing video frames and track cursor share updates. Captured |
| 64 // video frames are encoded by |video_encoder| and passed to |video_stub|. |
| 65 // |cursor_shape_stub| will be notified about cursor shape changes. Both |
| 66 // |cursor_shape_stub| and |video_stub| must outlive |this|. |
| 67 virtual void StartVideo( |
| 68 scoped_refptr<base::SingleThreadTaskRunner> capture_task_runner, |
| 69 scoped_refptr<base::SingleThreadTaskRunner> encode_task_runner, |
| 70 scoped_ptr<VideoEncoder> video_encoder, |
| 71 protocol::CursorShapeStub* cursor_shape_stub, |
| 72 protocol::VideoStub* video_stub) = 0; |
| 73 |
| 74 // Returns the screen size for the most recently captured video frame. |
| 75 virtual SkISize GetScreenSize() const = 0; |
| 76 |
| 77 // Pauses or resumes scheduling of frame captures. Pausing/resuming captures |
| 78 // only affects capture scheduling and does not stop/start the capturer. |
| 79 virtual void PauseVideo(bool pause) = 0; |
| 80 |
| 81 // Updates the sequence number (used for performance measurements) embedded in |
| 82 // VideoPackets. |
| 83 virtual void UpdateSequenceNumber(int64 sequence_number) = 0; |
| 45 | 84 |
| 46 private: | 85 private: |
| 47 // Used to capture audio to deliver to clients. | |
| 48 scoped_ptr<AudioCapturer> audio_capturer_; | |
| 49 | |
| 50 // Executes input and clipboard events received from the client. | |
| 51 scoped_ptr<EventExecutor> event_executor_; | |
| 52 | |
| 53 // Used to capture video to deliver to clients. | |
| 54 scoped_ptr<VideoFrameCapturer> video_capturer_; | |
| 55 | |
| 56 DISALLOW_COPY_AND_ASSIGN(DesktopEnvironment); | 86 DISALLOW_COPY_AND_ASSIGN(DesktopEnvironment); |
| 57 }; | 87 }; |
| 58 | 88 |
| 59 } // namespace remoting | 89 } // namespace remoting |
| 60 | 90 |
| 61 #endif // REMOTING_HOST_DESKTOP_ENVIRONMENT_H_ | 91 #endif // REMOTING_HOST_DESKTOP_ENVIRONMENT_H_ |
| OLD | NEW |