| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 MEDIA_CAST_TEST_IN_PROCESS_RECEIVER_H_ | 5 #ifndef MEDIA_CAST_TEST_IN_PROCESS_RECEIVER_H_ |
| 6 #define MEDIA_CAST_TEST_IN_PROCESS_RECEIVER_H_ | 6 #define MEDIA_CAST_TEST_IN_PROCESS_RECEIVER_H_ |
| 7 | 7 |
| 8 #include "base/memory/ref_counted.h" | 8 #include "base/memory/ref_counted.h" |
| 9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
| 10 #include "base/memory/weak_ptr.h" | 10 #include "base/memory/weak_ptr.h" |
| 11 #include "media/base/audio_bus.h" | 11 #include "media/base/audio_bus.h" |
| 12 #include "media/cast/cast_config.h" | 12 #include "media/cast/cast_config.h" |
| 13 #include "media/cast/transport/cast_transport_config.h" | 13 #include "media/cast/net/cast_transport_config.h" |
| 14 | 14 |
| 15 namespace base { | 15 namespace base { |
| 16 class TimeTicks; | 16 class TimeTicks; |
| 17 class WaitableEvent; | 17 class WaitableEvent; |
| 18 } // namespace base | 18 } // namespace base |
| 19 | 19 |
| 20 namespace net { | 20 namespace net { |
| 21 class IPEndPoint; | 21 class IPEndPoint; |
| 22 } // namespace net | 22 } // namespace net |
| 23 | 23 |
| 24 namespace media { | 24 namespace media { |
| 25 | 25 |
| 26 class VideoFrame; | 26 class VideoFrame; |
| 27 | 27 |
| 28 namespace cast { | 28 namespace cast { |
| 29 | 29 |
| 30 class CastEnvironment; | 30 class CastEnvironment; |
| 31 class CastReceiver; | 31 class CastReceiver; |
| 32 | |
| 33 namespace transport { | |
| 34 class UdpTransport; | 32 class UdpTransport; |
| 35 } // namespace transport | |
| 36 | 33 |
| 37 // Common base functionality for an in-process Cast receiver. This is meant to | 34 // Common base functionality for an in-process Cast receiver. This is meant to |
| 38 // be subclassed with the OnAudioFrame() and OnVideoFrame() methods implemented, | 35 // be subclassed with the OnAudioFrame() and OnVideoFrame() methods implemented, |
| 39 // so that the implementor can focus on what is to be done with the frames, | 36 // so that the implementor can focus on what is to be done with the frames, |
| 40 // rather than on the boilerplate "glue" code. | 37 // rather than on the boilerplate "glue" code. |
| 41 class InProcessReceiver { | 38 class InProcessReceiver { |
| 42 public: | 39 public: |
| 43 // Construct a receiver with the given configuration. |remote_end_point| can | 40 // Construct a receiver with the given configuration. |remote_end_point| can |
| 44 // be left empty, if the transport should automatically mate with the first | 41 // be left empty, if the transport should automatically mate with the first |
| 45 // remote sender it encounters. | 42 // remote sender it encounters. |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 78 // |transport_| receiving, and requests the first audio/video frame. | 75 // |transport_| receiving, and requests the first audio/video frame. |
| 79 // Subclasses may override to provide additional start-up functionality. | 76 // Subclasses may override to provide additional start-up functionality. |
| 80 virtual void StartOnMainThread(); | 77 virtual void StartOnMainThread(); |
| 81 | 78 |
| 82 // Helper method that destroys |transport_| and |cast_receiver_|. | 79 // Helper method that destroys |transport_| and |cast_receiver_|. |
| 83 // Subclasses may override to provide additional start-up functionality. | 80 // Subclasses may override to provide additional start-up functionality. |
| 84 virtual void StopOnMainThread(base::WaitableEvent* event); | 81 virtual void StopOnMainThread(base::WaitableEvent* event); |
| 85 | 82 |
| 86 // Callback for the transport to notify of status changes. A default | 83 // Callback for the transport to notify of status changes. A default |
| 87 // implementation is provided here that simply logs socket errors. | 84 // implementation is provided here that simply logs socket errors. |
| 88 virtual void UpdateCastTransportStatus(transport::CastTransportStatus status); | 85 virtual void UpdateCastTransportStatus(CastTransportStatus status); |
| 89 | 86 |
| 90 private: | 87 private: |
| 91 friend class base::RefCountedThreadSafe<InProcessReceiver>; | 88 friend class base::RefCountedThreadSafe<InProcessReceiver>; |
| 92 | 89 |
| 93 // CastReceiver callbacks that receive a frame and then request another. See | 90 // CastReceiver callbacks that receive a frame and then request another. See |
| 94 // comments for the callbacks defined in src/media/cast/cast_receiver.h for | 91 // comments for the callbacks defined in src/media/cast/cast_receiver.h for |
| 95 // argument description and semantics. | 92 // argument description and semantics. |
| 96 void GotAudioFrame(scoped_ptr<AudioBus> audio_frame, | 93 void GotAudioFrame(scoped_ptr<AudioBus> audio_frame, |
| 97 const base::TimeTicks& playout_time, | 94 const base::TimeTicks& playout_time, |
| 98 bool is_continuous); | 95 bool is_continuous); |
| 99 void GotVideoFrame(const scoped_refptr<VideoFrame>& video_frame, | 96 void GotVideoFrame(const scoped_refptr<VideoFrame>& video_frame, |
| 100 const base::TimeTicks& playout_time, | 97 const base::TimeTicks& playout_time, |
| 101 bool is_continuous); | 98 bool is_continuous); |
| 102 void PullNextAudioFrame(); | 99 void PullNextAudioFrame(); |
| 103 void PullNextVideoFrame(); | 100 void PullNextVideoFrame(); |
| 104 | 101 |
| 105 const scoped_refptr<CastEnvironment> cast_environment_; | 102 const scoped_refptr<CastEnvironment> cast_environment_; |
| 106 const net::IPEndPoint local_end_point_; | 103 const net::IPEndPoint local_end_point_; |
| 107 const net::IPEndPoint remote_end_point_; | 104 const net::IPEndPoint remote_end_point_; |
| 108 const FrameReceiverConfig audio_config_; | 105 const FrameReceiverConfig audio_config_; |
| 109 const FrameReceiverConfig video_config_; | 106 const FrameReceiverConfig video_config_; |
| 110 | 107 |
| 111 scoped_ptr<transport::UdpTransport> transport_; | 108 scoped_ptr<UdpTransport> transport_; |
| 112 scoped_ptr<CastReceiver> cast_receiver_; | 109 scoped_ptr<CastReceiver> cast_receiver_; |
| 113 | 110 |
| 114 // NOTE: Weak pointers must be invalidated before all other member variables. | 111 // NOTE: Weak pointers must be invalidated before all other member variables. |
| 115 base::WeakPtrFactory<InProcessReceiver> weak_factory_; | 112 base::WeakPtrFactory<InProcessReceiver> weak_factory_; |
| 116 | 113 |
| 117 DISALLOW_COPY_AND_ASSIGN(InProcessReceiver); | 114 DISALLOW_COPY_AND_ASSIGN(InProcessReceiver); |
| 118 }; | 115 }; |
| 119 | 116 |
| 120 } // namespace cast | 117 } // namespace cast |
| 121 } // namespace media | 118 } // namespace media |
| 122 | 119 |
| 123 #endif // MEDIA_CAST_TEST_IN_PROCESS_RECEIVER_H_ | 120 #endif // MEDIA_CAST_TEST_IN_PROCESS_RECEIVER_H_ |
| OLD | NEW |