| 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" | 
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 71   // After this call, it is safe to destroy this object on any thread. | 71   // After this call, it is safe to destroy this object on any thread. | 
| 72   void Stop(); | 72   void Stop(); | 
| 73 | 73 | 
| 74  protected: | 74  protected: | 
| 75   // To be implemented by subclasses.  These are called on the Cast MAIN thread | 75   // To be implemented by subclasses.  These are called on the Cast MAIN thread | 
| 76   // as each frame is received. | 76   // as each frame is received. | 
| 77   virtual void OnAudioFrame(scoped_ptr<AudioBus> audio_frame, | 77   virtual void OnAudioFrame(scoped_ptr<AudioBus> audio_frame, | 
| 78                             const base::TimeTicks& playout_time, | 78                             const base::TimeTicks& playout_time, | 
| 79                             bool is_continuous) = 0; | 79                             bool is_continuous) = 0; | 
| 80   virtual void OnVideoFrame(const scoped_refptr<VideoFrame>& video_frame, | 80   virtual void OnVideoFrame(const scoped_refptr<VideoFrame>& video_frame, | 
| 81                             const base::TimeTicks& render_time, | 81                             const base::TimeTicks& playout_time, | 
| 82                             bool is_continuous) = 0; | 82                             bool is_continuous) = 0; | 
| 83 | 83 | 
| 84   // Helper method that creates |transport_| and |cast_receiver_|, starts | 84   // Helper method that creates |transport_| and |cast_receiver_|, starts | 
| 85   // |transport_| receiving, and requests the first audio/video frame. | 85   // |transport_| receiving, and requests the first audio/video frame. | 
| 86   // Subclasses may override to provide additional start-up functionality. | 86   // Subclasses may override to provide additional start-up functionality. | 
| 87   virtual void StartOnMainThread(); | 87   virtual void StartOnMainThread(); | 
| 88 | 88 | 
| 89   // Helper method that destroys |transport_| and |cast_receiver_|. | 89   // Helper method that destroys |transport_| and |cast_receiver_|. | 
| 90   // Subclasses may override to provide additional start-up functionality. | 90   // Subclasses may override to provide additional start-up functionality. | 
| 91   virtual void StopOnMainThread(base::WaitableEvent* event); | 91   virtual void StopOnMainThread(base::WaitableEvent* event); | 
| 92 | 92 | 
| 93   // Callback for the transport to notify of status changes.  A default | 93   // Callback for the transport to notify of status changes.  A default | 
| 94   // implementation is provided here that simply logs socket errors. | 94   // implementation is provided here that simply logs socket errors. | 
| 95   virtual void UpdateCastTransportStatus(transport::CastTransportStatus status); | 95   virtual void UpdateCastTransportStatus(transport::CastTransportStatus status); | 
| 96 | 96 | 
| 97  private: | 97  private: | 
| 98   friend class base::RefCountedThreadSafe<InProcessReceiver>; | 98   friend class base::RefCountedThreadSafe<InProcessReceiver>; | 
| 99 | 99 | 
| 100   // CastReceiver callbacks that receive a frame and then request another. | 100   // CastReceiver callbacks that receive a frame and then request another.  See | 
|  | 101   // comments for the callbacks defined in src/media/cast/cast_receiver.h for | 
|  | 102   // argument description and semantics. | 
| 101   void GotAudioFrame(scoped_ptr<AudioBus> audio_frame, | 103   void GotAudioFrame(scoped_ptr<AudioBus> audio_frame, | 
| 102                      const base::TimeTicks& playout_time, | 104                      const base::TimeTicks& playout_time, | 
| 103                      bool is_continuous); | 105                      bool is_continuous); | 
| 104   void GotVideoFrame(const scoped_refptr<VideoFrame>& video_frame, | 106   void GotVideoFrame(const scoped_refptr<VideoFrame>& video_frame, | 
| 105                      const base::TimeTicks& render_time); | 107                      const base::TimeTicks& playout_time, | 
|  | 108                      bool is_continuous); | 
| 106   void PullNextAudioFrame(); | 109   void PullNextAudioFrame(); | 
| 107   void PullNextVideoFrame(); | 110   void PullNextVideoFrame(); | 
| 108 | 111 | 
| 109   // Invoked just before the destruction of |receiver| on the cast MAIN thread. | 112   // Invoked just before the destruction of |receiver| on the cast MAIN thread. | 
| 110   static void WillDestroyReceiver(InProcessReceiver* receiver); | 113   static void WillDestroyReceiver(InProcessReceiver* receiver); | 
| 111 | 114 | 
| 112   const scoped_refptr<CastEnvironment> cast_environment_; | 115   const scoped_refptr<CastEnvironment> cast_environment_; | 
| 113   const net::IPEndPoint local_end_point_; | 116   const net::IPEndPoint local_end_point_; | 
| 114   const net::IPEndPoint remote_end_point_; | 117   const net::IPEndPoint remote_end_point_; | 
| 115   const AudioReceiverConfig audio_config_; | 118   const AudioReceiverConfig audio_config_; | 
| 116   const VideoReceiverConfig video_config_; | 119   const VideoReceiverConfig video_config_; | 
| 117 | 120 | 
| 118   scoped_ptr<transport::UdpTransport> transport_; | 121   scoped_ptr<transport::UdpTransport> transport_; | 
| 119   scoped_ptr<CastReceiver> cast_receiver_; | 122   scoped_ptr<CastReceiver> cast_receiver_; | 
| 120 | 123 | 
| 121   // NOTE: Weak pointers must be invalidated before all other member variables. | 124   // NOTE: Weak pointers must be invalidated before all other member variables. | 
| 122   base::WeakPtrFactory<InProcessReceiver> weak_factory_; | 125   base::WeakPtrFactory<InProcessReceiver> weak_factory_; | 
| 123 | 126 | 
| 124   DISALLOW_COPY_AND_ASSIGN(InProcessReceiver); | 127   DISALLOW_COPY_AND_ASSIGN(InProcessReceiver); | 
| 125 }; | 128 }; | 
| 126 | 129 | 
| 127 }  // namespace cast | 130 }  // namespace cast | 
| 128 }  // namespace media | 131 }  // namespace media | 
| 129 | 132 | 
| 130 #endif  // MEDIA_CAST_TEST_IN_PROCESS_RECEIVER_H_ | 133 #endif  // MEDIA_CAST_TEST_IN_PROCESS_RECEIVER_H_ | 
| OLD | NEW | 
|---|