Chromium Code Reviews| 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 #ifndef CHROME_RENDERER_MEDIA_CAST_SESSION_DELEGATE_H_ | 5 #ifndef CHROME_RENDERER_MEDIA_CAST_SESSION_DELEGATE_H_ |
| 6 #define CHROME_RENDERER_MEDIA_CAST_SESSION_DELEGATE_H_ | 6 #define CHROME_RENDERER_MEDIA_CAST_SESSION_DELEGATE_H_ |
| 7 | 7 |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
| 11 #include "base/memory/ref_counted.h" | 11 #include "base/memory/ref_counted.h" |
| 12 #include "base/memory/weak_ptr.h" | |
| 12 #include "base/threading/thread.h" | 13 #include "base/threading/thread.h" |
| 13 #include "base/threading/thread_checker.h" | 14 #include "base/threading/thread_checker.h" |
| 14 #include "base/time/default_tick_clock.h" | 15 #include "base/time/default_tick_clock.h" |
| 15 #include "media/cast/cast_config.h" | 16 #include "media/cast/cast_config.h" |
| 16 #include "media/cast/cast_sender.h" | 17 #include "media/cast/cast_sender.h" |
| 17 | 18 |
| 18 namespace base { | 19 namespace base { |
| 19 class MessageLoopProxy; | 20 class MessageLoopProxy; |
| 20 } // namespace base | 21 } // namespace base |
| 21 | 22 |
| 22 namespace media { | 23 namespace media { |
| 23 class VideoFrame; | 24 class VideoFrame; |
| 24 | 25 |
| 25 namespace cast { | 26 namespace cast { |
| 26 class CastEnvironment; | 27 class CastEnvironment; |
| 27 class FrameInput; | 28 class FrameInput; |
| 28 | 29 |
| 29 namespace transport { | 30 namespace transport { |
| 30 class CastTransportSender; | 31 class CastTransportSender; |
| 31 } // namespace transport | 32 } // namespace transport |
| 32 } // namespace cast | 33 } // namespace cast |
| 33 } // namespace media | 34 } // namespace media |
| 34 | 35 |
| 35 // This class hosts CastSender and connects it to audio/video frame input | 36 // This class hosts CastSender and connects it to audio/video frame input |
| 36 // and network socket. | 37 // and network socket. |
| 37 // This class is created on the render thread and destroyed on the IO | 38 // This class is created on the render thread and destroyed on the IO |
| 38 // thread. All methods are accessible only on the IO thread. | 39 // thread. All methods are accessible only on the IO thread. |
| 39 class CastSessionDelegate { | 40 class CastSessionDelegate { |
| 40 public: | 41 public: |
| 41 typedef base::Callback<void(const scoped_refptr<media::cast::FrameInput>&)> | 42 typedef base::Callback<void(const scoped_refptr<media::cast::FrameInput>&)> |
|
Alpha Left Google
2014/02/18 22:28:13
There's no more FrameInput isn't it?
mikhal1
2014/03/05 21:44:05
Done.
| |
| 42 FrameInputAvailableCallback; | 43 FrameInputAvailableCallback; |
| 43 | 44 |
| 44 CastSessionDelegate(); | 45 CastSessionDelegate(); |
| 45 virtual ~CastSessionDelegate(); | 46 virtual ~CastSessionDelegate(); |
| 46 | 47 |
| 47 // After calling StartAudio() or StartVideo() encoding of that media will | 48 // After calling StartAudio() or StartVideo() encoding of that media will |
| 48 // begin as soon as data is delivered to its sink, if the second method is | 49 // begin as soon as data is delivered to its sink, if the second method is |
| 49 // called the first media will be restarted. It is strongly recommended not to | 50 // called the first media will be restarted. It is strongly recommended not to |
| 50 // deliver any data between calling the two methods. | 51 // deliver any data between calling the two methods. |
| 51 // It's OK to call only one of the two methods. | 52 // It's OK to call only one of the two methods. |
| 52 void StartAudio(const media::cast::AudioSenderConfig& config, | 53 void StartAudio(const media::cast::AudioSenderConfig& config, |
| 53 const FrameInputAvailableCallback& callback); | 54 const FrameInputAvailableCallback& callback); |
| 54 void StartVideo(const media::cast::VideoSenderConfig& config, | 55 void StartVideo(const media::cast::VideoSenderConfig& config, |
| 55 const FrameInputAvailableCallback& callback); | 56 const FrameInputAvailableCallback& callback); |
| 56 | 57 |
| 57 protected: | 58 protected: |
| 58 // Callback with the result of the initialization. | 59 // Callback with the result of the initialization. If this callback is called |
| 59 // If this callback is called with STATUS_INITIALIZED it will report back | 60 // with STATUS_AUDIO_INITIALIZED and/or STATUS_VIDEO_INITIALIZED it will |
| 60 // to the sinks that it's ready to accept incoming audio / video frames. | 61 // report back to the sinks that it's ready to accept incoming audio / video |
| 62 // frames. | |
| 61 void InitializationResult(media::cast::CastInitializationStatus result) const; | 63 void InitializationResult(media::cast::CastInitializationStatus result) const; |
| 62 | 64 |
| 63 private: | 65 private: |
| 64 // Start encoding threads and initialize the CastEnvironment. | |
| 65 void Initialize(); | |
| 66 | |
| 67 // Configure CastSender. It is ready to accept audio / video frames after | |
| 68 // receiving a successful call to InitializationResult. | |
| 69 void StartSendingInternal(const FrameInputAvailableCallback& callback, | |
| 70 bool is_audio); | |
| 71 | |
| 72 base::ThreadChecker thread_checker_; | 66 base::ThreadChecker thread_checker_; |
| 73 scoped_refptr<media::cast::CastEnvironment> cast_environment_; | 67 scoped_refptr<media::cast::CastEnvironment> cast_environment_; |
| 74 scoped_ptr<media::cast::CastSender> cast_sender_; | 68 scoped_ptr<media::cast::CastSender> cast_sender_; |
| 75 scoped_ptr<media::cast::transport::CastTransportSender> cast_transport_; | 69 scoped_ptr<media::cast::transport::CastTransportSender> cast_transport_; |
| 76 | 70 |
| 77 // Utilities threads owned by this class. They are used by CastSender for | 71 // Utilities threads owned by this class. They are used by CastSender for |
| 78 // encoding. | 72 // encoding. |
| 79 // TODO(hclam): See crbug.com/317006 for more details. | 73 // TODO(hclam): See crbug.com/317006 for more details. |
| 80 // This class shouldn't create and own threads. | 74 // This class shouldn't create and own threads. |
| 81 base::Thread audio_encode_thread_; | 75 base::Thread audio_encode_thread_; |
| 82 base::Thread video_encode_thread_; | 76 base::Thread video_encode_thread_; |
| 83 | 77 |
| 84 // Configuration for audio and video. | |
| 85 scoped_ptr<media::cast::AudioSenderConfig> audio_config_; | |
| 86 scoped_ptr<media::cast::VideoSenderConfig> video_config_; | |
| 87 | |
| 88 scoped_ptr<FrameInputAvailableCallback> audio_frame_input_available_callback_; | 78 scoped_ptr<FrameInputAvailableCallback> audio_frame_input_available_callback_; |
|
Alpha Left Google
2014/02/18 22:28:13
I don't you didn't change this line but this looks
mikhal1
2014/03/05 21:44:05
Changes by rebasing.
On 2014/02/18 22:28:13, Alpha
| |
| 89 scoped_ptr<FrameInputAvailableCallback> video_frame_input_available_callback_; | 79 scoped_ptr<FrameInputAvailableCallback> video_frame_input_available_callback_; |
| 90 | 80 |
| 91 // Proxy to the IO message loop. | 81 // Proxy to the IO message loop. |
| 92 scoped_refptr<base::MessageLoopProxy> io_message_loop_proxy_; | 82 scoped_refptr<base::MessageLoopProxy> io_message_loop_proxy_; |
| 93 | 83 |
| 84 // Weak pointer bound to io_message_loop_proxy_. | |
|
Alpha Left Google
2014/02/18 22:28:13
nit: |io_message_loop_proxy_|.
| |
| 85 base::WeakPtrFactory<CastSessionDelegate> weak_factory_; | |
| 86 | |
| 94 DISALLOW_COPY_AND_ASSIGN(CastSessionDelegate); | 87 DISALLOW_COPY_AND_ASSIGN(CastSessionDelegate); |
| 95 }; | 88 }; |
| 96 | 89 |
| 97 #endif // CHROME_RENDERER_MEDIA_CAST_SESSION_DELEGATE_H_ | 90 #endif // CHROME_RENDERER_MEDIA_CAST_SESSION_DELEGATE_H_ |
| OLD | NEW |