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

Unified Diff: media/cast/test/utility/in_process_receiver.h

Issue 184813009: Cast Streaming API end-to-end browser_test. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 10 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 side-by-side diff with in-line comments
Download patch
Index: media/cast/test/utility/in_process_receiver.h
diff --git a/media/cast/test/utility/in_process_receiver.h b/media/cast/test/utility/in_process_receiver.h
new file mode 100644
index 0000000000000000000000000000000000000000..4eeecaf894efc26ea5086d0c36bbdf756fcafd95
--- /dev/null
+++ b/media/cast/test/utility/in_process_receiver.h
@@ -0,0 +1,107 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef MEDIA_CAST_TEST_IN_PROCESS_RECEIVER_H_
+#define MEDIA_CAST_TEST_IN_PROCESS_RECEIVER_H_
+
+#include "base/memory/weak_ptr.h"
+#include "media/cast/cast_config.h"
+#include "media/cast/transport/cast_transport_config.h"
+
+namespace base {
+class TimeTicks;
+} // namespace base
+
+namespace net {
+class IPEndPoint;
+} // namespace net
+
+namespace media {
+
+class VideoFrame;
+
+namespace cast {
+
+class CastEnvironment;
+class CastReceiver;
+
+namespace transport {
+class UdpTransport;
+} // namespace transport
+
+// Common base functionality for an in-process Cast receiver. This is meant to
+// be subclassed with the OnAudioFrame() and OnVideoFrame() methods implemented,
+// so that the implementor can focus on what is to be done with the frames,
+// rather than on the boilerplate "glue" code.
+class InProcessReceiver {
+ public:
+ // Construct a receiver with the given configuration. |remote_end_point| can
+ // be left empty, if the transport should automatically mate with the first
+ // remote sender it encounters.
+ InProcessReceiver(const scoped_refptr<CastEnvironment>& cast_environment,
+ const net::IPEndPoint& local_end_point,
+ const net::IPEndPoint& remote_end_point,
+ const AudioReceiverConfig& audio_config,
+ const VideoReceiverConfig& video_config);
+ virtual ~InProcessReceiver();
+
+ // Convenience accessor to CastEnvironment.
+ CastEnvironment* cast_env() const { return cast_environment_.get(); }
hubbe 2014/03/04 22:42:26 Maybe return a scoped_refptr?
miu 2014/03/06 06:09:15 Done.
+
+ // Begin delivering any received audio/video frames to the OnXXXFrame()
+ // methods.
+ virtual void Start();
+
+ // Returns configurations with the most-commonly used values. These specify
+ // 48 kHz, 2-channel Opus-coded audio, and VP8-coded video.
+ static AudioReceiverConfig GetDefaultAudioConfig();
hubbe 2014/03/04 22:42:26 I don't think these functions belong in this class
miu 2014/03/06 06:09:15 Done. Moved to a test utility module.
+ static VideoReceiverConfig GetDefaultVideoConfig();
+
+ protected:
+ // To be implemented by subclasses. These are called on the Cast MAIN thread
+ // as each frame is received.
+ virtual void OnAudioFrame(scoped_ptr<PcmAudioFrame> audio_frame,
+ const base::TimeTicks& playout_time) = 0;
+ virtual void OnVideoFrame(const scoped_refptr<VideoFrame>& video_frame,
+ const base::TimeTicks& render_time) = 0;
+
+ // Callback for the transport to notify of status changes. A default
+ // implementation is provided here that simply logs socket errors.
+ virtual void UpdateCastTransportStatus(transport::CastTransportStatus status);
+
+ private:
+ // Helper method to complete the initialization of components that must be
+ // constructed on the Cast MAIN thread.
+ void InitializeOnMainThread(const net::IPEndPoint& local_end_point,
+ const net::IPEndPoint& remote_end_point,
+ const AudioReceiverConfig& audio_config,
+ const VideoReceiverConfig& video_config);
+
+ // Helper method that starts |transport_| receiving and requests the first
+ // audio/video frame.
+ void StartOnMainThread();
+
+ // CastReceiver callbacks that receive a frame and then request another.
+ void GotAudioFrame(scoped_ptr<PcmAudioFrame> audio_frame,
+ const base::TimeTicks& playout_time);
+ void GotVideoFrame(const scoped_refptr<VideoFrame>& video_frame,
+ const base::TimeTicks& render_time);
+ void PullNextAudioFrame();
+ void PullNextVideoFrame();
+
+ const scoped_refptr<CastEnvironment> cast_environment_;
+ const int audio_sampling_frequency_;
+ scoped_ptr<transport::UdpTransport> transport_;
+ scoped_ptr<CastReceiver> cast_receiver_;
+
+ // For shutdown safety, this member must be last:
+ base::WeakPtrFactory<InProcessReceiver> weak_factory_;
+
+ DISALLOW_COPY_AND_ASSIGN(InProcessReceiver);
+};
+
+} // namespace cast
+} // namespace media
+
+#endif // MEDIA_CAST_TEST_IN_PROCESS_RECEIVER_H_

Powered by Google App Engine
This is Rietveld 408576698