| 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 <map> | 8 #include <map> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| 11 #include "base/basictypes.h" | 11 #include "base/basictypes.h" |
| 12 #include "base/memory/linked_ptr.h" | 12 #include "base/memory/linked_ptr.h" |
| 13 #include "base/memory/ref_counted.h" | 13 #include "base/memory/ref_counted.h" |
| 14 #include "base/threading/thread.h" | 14 #include "base/threading/thread.h" |
| 15 #include "base/threading/thread_checker.h" | 15 #include "base/threading/thread_checker.h" |
| 16 #include "base/time/default_tick_clock.h" | 16 #include "base/time/default_tick_clock.h" |
| 17 #include "media/cast/cast_config.h" | 17 #include "media/cast/cast_config.h" |
| 18 #include "media/cast/cast_sender.h" | 18 #include "media/cast/cast_sender.h" |
| 19 | 19 |
| 20 namespace base { | 20 namespace base { |
| 21 class DictionaryValue; |
| 21 class MessageLoopProxy; | 22 class MessageLoopProxy; |
| 22 } // namespace base | 23 } // namespace base |
| 23 | 24 |
| 24 namespace media { | 25 namespace media { |
| 25 class VideoFrame; | 26 class VideoFrame; |
| 26 | 27 |
| 27 namespace cast { | 28 namespace cast { |
| 28 class CastEnvironment; | 29 class CastEnvironment; |
| 29 class EncodingEventSubscriber; | 30 class EncodingEventSubscriber; |
| 30 class FrameInput; | 31 class FrameInput; |
| 31 | 32 |
| 32 namespace transport { | 33 namespace transport { |
| 33 class CastTransportSender; | 34 class CastTransportSender; |
| 34 } // namespace transport | 35 } // namespace transport |
| 35 } // namespace cast | 36 } // namespace cast |
| 36 } // namespace media | 37 } // namespace media |
| 37 | 38 |
| 38 // This class hosts CastSender and connects it to audio/video frame input | 39 // This class hosts CastSender and connects it to audio/video frame input |
| 39 // and network socket. | 40 // and network socket. |
| 40 // This class is created on the render thread and destroyed on the IO | 41 // This class is created on the render thread and destroyed on the IO |
| 41 // thread. All methods are accessible only on the IO thread. | 42 // thread. All methods are accessible only on the IO thread. |
| 42 class CastSessionDelegate { | 43 class CastSessionDelegate { |
| 43 public: | 44 public: |
| 44 typedef base::Callback<void(const scoped_refptr<media::cast::FrameInput>&)> | 45 typedef base::Callback<void(const scoped_refptr<media::cast::FrameInput>&)> |
| 45 FrameInputAvailableCallback; | 46 FrameInputAvailableCallback; |
| 46 typedef base::Callback<void(scoped_ptr<std::string>)> EventLogsCallback; | 47 typedef base::Callback<void(scoped_ptr<std::string>)> EventLogsCallback; |
| 48 typedef base::Callback<void(scoped_ptr<base::DictionaryValue>)> StatsCallback; |
| 47 | 49 |
| 48 CastSessionDelegate(); | 50 CastSessionDelegate(); |
| 49 virtual ~CastSessionDelegate(); | 51 virtual ~CastSessionDelegate(); |
| 50 | 52 |
| 51 // After calling StartAudio() or StartVideo() encoding of that media will | 53 // After calling StartAudio() or StartVideo() encoding of that media will |
| 52 // begin as soon as data is delivered to its sink, if the second method is | 54 // begin as soon as data is delivered to its sink, if the second method is |
| 53 // called the first media will be restarted. It is strongly recommended not to | 55 // called the first media will be restarted. It is strongly recommended not to |
| 54 // deliver any data between calling the two methods. | 56 // deliver any data between calling the two methods. |
| 55 // It's OK to call only one of the two methods. | 57 // It's OK to call only one of the two methods. |
| 56 void StartAudio(const media::cast::AudioSenderConfig& config, | 58 void StartAudio(const media::cast::AudioSenderConfig& config, |
| 57 const FrameInputAvailableCallback& callback); | 59 const FrameInputAvailableCallback& callback); |
| 58 void StartVideo(const media::cast::VideoSenderConfig& config, | 60 void StartVideo(const media::cast::VideoSenderConfig& config, |
| 59 const FrameInputAvailableCallback& callback); | 61 const FrameInputAvailableCallback& callback); |
| 60 void StartUDP(const net::IPEndPoint& local_endpoint, | 62 void StartUDP(const net::IPEndPoint& local_endpoint, |
| 61 const net::IPEndPoint& remote_endpoint); | 63 const net::IPEndPoint& remote_endpoint); |
| 62 | 64 |
| 63 void ToggleLogging(bool is_audio, bool enable); | 65 void ToggleLogging(bool is_audio, bool enable); |
| 64 void GetEventLogsAndReset(bool is_audio, const EventLogsCallback& callback); | 66 void GetEventLogsAndReset(bool is_audio, const EventLogsCallback& callback); |
| 67 void GetStatsAndReset(bool is_audio, const StatsCallback& callback); |
| 65 | 68 |
| 66 protected: | 69 protected: |
| 67 // Callback with the result of the initialization. | 70 // Callback with the result of the initialization. |
| 68 // If this callback is called with STATUS_INITIALIZED it will report back | 71 // If this callback is called with STATUS_INITIALIZED it will report back |
| 69 // to the sinks that it's ready to accept incoming audio / video frames. | 72 // to the sinks that it's ready to accept incoming audio / video frames. |
| 70 void InitializationResult(media::cast::CastInitializationStatus result) const; | 73 void InitializationResult(media::cast::CastInitializationStatus result) const; |
| 71 | 74 |
| 72 private: | 75 private: |
| 73 // Start encoding threads and initialize the CastEnvironment. | 76 // Start encoding threads and initialize the CastEnvironment. |
| 74 void Initialize(); | 77 void Initialize(); |
| (...skipping 24 matching lines...) Expand all Loading... |
| 99 scoped_ptr<media::cast::EncodingEventSubscriber> audio_event_subscriber_; | 102 scoped_ptr<media::cast::EncodingEventSubscriber> audio_event_subscriber_; |
| 100 scoped_ptr<media::cast::EncodingEventSubscriber> video_event_subscriber_; | 103 scoped_ptr<media::cast::EncodingEventSubscriber> video_event_subscriber_; |
| 101 | 104 |
| 102 // Proxy to the IO message loop. | 105 // Proxy to the IO message loop. |
| 103 scoped_refptr<base::MessageLoopProxy> io_message_loop_proxy_; | 106 scoped_refptr<base::MessageLoopProxy> io_message_loop_proxy_; |
| 104 | 107 |
| 105 DISALLOW_COPY_AND_ASSIGN(CastSessionDelegate); | 108 DISALLOW_COPY_AND_ASSIGN(CastSessionDelegate); |
| 106 }; | 109 }; |
| 107 | 110 |
| 108 #endif // CHROME_RENDERER_MEDIA_CAST_SESSION_DELEGATE_H_ | 111 #endif // CHROME_RENDERER_MEDIA_CAST_SESSION_DELEGATE_H_ |
| OLD | NEW |