Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(382)

Side by Side Diff: media/cast/test/utility/in_process_receiver.h

Issue 225023010: [Cast] Refactor/clean-up VideoReceiver to match AudioReceiver as closely as possible. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
68 // Destroy the sub-compontents of this class. 68 // Destroy the sub-compontents of this class.
69 // After this call, it is safe to destroy this object on any thread. 69 // After this call, it is safe to destroy this object on any thread.
70 void Stop(); 70 void Stop();
71 71
72 protected: 72 protected:
73 // To be implemented by subclasses. These are called on the Cast MAIN thread 73 // To be implemented by subclasses. These are called on the Cast MAIN thread
74 // as each frame is received. 74 // as each frame is received.
75 virtual void OnAudioFrame(scoped_ptr<PcmAudioFrame> audio_frame, 75 virtual void OnAudioFrame(scoped_ptr<PcmAudioFrame> audio_frame,
76 const base::TimeTicks& playout_time) = 0; 76 const base::TimeTicks& playout_time) = 0;
77 virtual void OnVideoFrame(const scoped_refptr<VideoFrame>& video_frame, 77 virtual void OnVideoFrame(const scoped_refptr<VideoFrame>& video_frame,
78 const base::TimeTicks& render_time) = 0; 78 const base::TimeTicks& playout_time) = 0;
79 79
80 // Helper method that creates |transport_| and |cast_receiver_|, starts 80 // Helper method that creates |transport_| and |cast_receiver_|, starts
81 // |transport_| receiving, and requests the first audio/video frame. 81 // |transport_| receiving, and requests the first audio/video frame.
82 // Subclasses may override to provide additional start-up functionality. 82 // Subclasses may override to provide additional start-up functionality.
83 virtual void StartOnMainThread(); 83 virtual void StartOnMainThread();
84 84
85 // Helper method that destroys |transport_| and |cast_receiver_|. 85 // Helper method that destroys |transport_| and |cast_receiver_|.
86 // Subclasses may override to provide additional start-up functionality. 86 // Subclasses may override to provide additional start-up functionality.
87 virtual void StopOnMainThread(base::WaitableEvent* event); 87 virtual void StopOnMainThread(base::WaitableEvent* event);
88 88
89 // Callback for the transport to notify of status changes. A default 89 // Callback for the transport to notify of status changes. A default
90 // implementation is provided here that simply logs socket errors. 90 // implementation is provided here that simply logs socket errors.
91 virtual void UpdateCastTransportStatus(transport::CastTransportStatus status); 91 virtual void UpdateCastTransportStatus(transport::CastTransportStatus status);
92 92
93 private: 93 private:
94 friend class base::RefCountedThreadSafe<InProcessReceiver>; 94 friend class base::RefCountedThreadSafe<InProcessReceiver>;
95 95
96 // CastReceiver callbacks that receive a frame and then request another. 96 // CastReceiver callbacks that receive a frame and then request another.
97 void GotAudioFrame(scoped_ptr<AudioBus> audio_frame, 97 void GotAudioFrame(scoped_ptr<AudioBus> audio_frame,
98 const base::TimeTicks& playout_time, 98 const base::TimeTicks& playout_time,
99 bool is_continuous); 99 bool is_continuous);
100 void GotVideoFrame(const scoped_refptr<VideoFrame>& video_frame, 100 void GotVideoFrame(const scoped_refptr<VideoFrame>& video_frame,
101 const base::TimeTicks& render_time); 101 const base::TimeTicks& playout_time,
102 bool is_continuous);
hubbe 2014/04/07 18:40:17 Document |is_continuous| (and perhaps the entire m
miu 2014/04/08 00:59:41 Done. But, rather than duplicate comments, I've p
102 void PullNextAudioFrame(); 103 void PullNextAudioFrame();
103 void PullNextVideoFrame(); 104 void PullNextVideoFrame();
104 105
105 // Invoked just before the destruction of |receiver| on the cast MAIN thread. 106 // Invoked just before the destruction of |receiver| on the cast MAIN thread.
106 static void WillDestroyReceiver(InProcessReceiver* receiver); 107 static void WillDestroyReceiver(InProcessReceiver* receiver);
107 108
108 const scoped_refptr<CastEnvironment> cast_environment_; 109 const scoped_refptr<CastEnvironment> cast_environment_;
109 const net::IPEndPoint local_end_point_; 110 const net::IPEndPoint local_end_point_;
110 const net::IPEndPoint remote_end_point_; 111 const net::IPEndPoint remote_end_point_;
111 const AudioReceiverConfig audio_config_; 112 const AudioReceiverConfig audio_config_;
112 const VideoReceiverConfig video_config_; 113 const VideoReceiverConfig video_config_;
113 114
114 scoped_ptr<transport::UdpTransport> transport_; 115 scoped_ptr<transport::UdpTransport> transport_;
115 scoped_ptr<CastReceiver> cast_receiver_; 116 scoped_ptr<CastReceiver> cast_receiver_;
116 117
117 // NOTE: Weak pointers must be invalidated before all other member variables. 118 // NOTE: Weak pointers must be invalidated before all other member variables.
118 base::WeakPtrFactory<InProcessReceiver> weak_factory_; 119 base::WeakPtrFactory<InProcessReceiver> weak_factory_;
119 120
120 DISALLOW_COPY_AND_ASSIGN(InProcessReceiver); 121 DISALLOW_COPY_AND_ASSIGN(InProcessReceiver);
121 }; 122 };
122 123
123 } // namespace cast 124 } // namespace cast
124 } // namespace media 125 } // namespace media
125 126
126 #endif // MEDIA_CAST_TEST_IN_PROCESS_RECEIVER_H_ 127 #endif // MEDIA_CAST_TEST_IN_PROCESS_RECEIVER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698