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

Unified Diff: media/cast/cast_sender.h

Issue 163553006: Cast: Refactoring Cast API's (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 6 years, 9 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
« no previous file with comments | « media/cast/cast_receiver_impl.cc ('k') | media/cast/cast_sender_impl.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: media/cast/cast_sender.h
diff --git a/media/cast/cast_sender.h b/media/cast/cast_sender.h
index a15e6d31ee3d090dc21e2eda1d54e337ee14fc01..33b9393844325b8dec5b865da2130015e30c4c43 100644
--- a/media/cast/cast_sender.h
+++ b/media/cast/cast_sender.h
@@ -2,11 +2,10 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//
-// This is the main interface for the cast sender. All configuration are done
-// at creation.
+// This is the main interface for the cast sender.
//
-// The FrameInput and PacketReciever interfaces should normally be accessed from
-// the IO thread. However they are allowed to be called from any thread.
+// The AudioFrameInput, VideoFrameInput and PacketReciever interfaces should
+// be accessed from the main thread.
#ifndef MEDIA_CAST_CAST_SENDER_H_
#define MEDIA_CAST_CAST_SENDER_H_
@@ -23,23 +22,32 @@
namespace media {
class AudioBus;
+class GpuVideoAcceleratorFactories;
class VideoFrame;
-}
-namespace media {
namespace cast {
+class AudioSender;
+class VideoSender;
-// This Class is thread safe.
-class FrameInput : public base::RefCountedThreadSafe<FrameInput> {
+class VideoFrameInput : public base::RefCountedThreadSafe<VideoFrameInput> {
public:
- // The video_frame must be valid until the callback is called.
- // The callback is called from the main cast thread as soon as
- // the encoder is done with the frame; it does not mean that the encoded frame
- // has been sent out.
+ // Insert video frames into Cast sender. Frames will be encoded, packetized
+ // and sent to the network.
virtual void InsertRawVideoFrame(
const scoped_refptr<media::VideoFrame>& video_frame,
const base::TimeTicks& capture_time) = 0;
+ protected:
+ virtual ~VideoFrameInput() {}
+
+ private:
+ friend class base::RefCountedThreadSafe<VideoFrameInput>;
+};
+
+class AudioFrameInput : public base::RefCountedThreadSafe<AudioFrameInput> {
+ public:
+ // Insert audio frames into Cast sender. Frames will be encoded, packetized
+ // and sent to the network.
// The |audio_bus| must be valid until the |done_callback| is called.
// The callback is called from the main cast thread as soon as the encoder is
// done with |audio_bus|; it does not mean that the encoded data has been
@@ -49,36 +57,44 @@ class FrameInput : public base::RefCountedThreadSafe<FrameInput> {
const base::Closure& done_callback) = 0;
protected:
- virtual ~FrameInput() {}
+ virtual ~AudioFrameInput() {}
private:
- friend class base::RefCountedThreadSafe<FrameInput>;
+ friend class base::RefCountedThreadSafe<AudioFrameInput>;
};
-// This Class is thread safe.
-// The provided CastTransportSender object will always be called from the main
-// cast thread.
-// At least one of AudioSenderConfig and VideoSenderConfig have to be provided.
+// The provided CastTransportSender and the CastSender should be called from the
+// main thread.
class CastSender {
public:
- static CastSender* CreateCastSender(
+ static scoped_ptr<CastSender> Create(
scoped_refptr<CastEnvironment> cast_environment,
- const AudioSenderConfig* audio_config,
- const VideoSenderConfig* video_config,
- const scoped_refptr<GpuVideoAcceleratorFactories>& gpu_factories,
- const CastInitializationCallback& cast_initialization,
transport::CastTransportSender* const transport_sender);
virtual ~CastSender() {}
- // All audio and video frames for the session should be inserted to this
- // object.
- // Can be called from any thread.
- virtual scoped_refptr<FrameInput> frame_input() = 0;
+ // All video frames for the session should be inserted to this object.
+ virtual scoped_refptr<VideoFrameInput> video_frame_input() = 0;
+
+ // All audio frames for the session should be inserted to this object.
+ virtual scoped_refptr<AudioFrameInput> audio_frame_input() = 0;
// All RTCP packets for the session should be inserted to this object.
- // Can be called from any thread.
+ // This function and the callback must be called on the main thread.
virtual transport::PacketReceiverCallback packet_receiver() = 0;
+
+ // Initialize the audio stack. Must be called in order to send audio frames.
+ // Status of the initialization will be returned on cast_initialization_cb.
+ virtual void InitializeAudio(
+ const AudioSenderConfig& audio_config,
+ const CastInitializationCallback& cast_initialization_cb) = 0;
+
+ // Initialize the video stack. Must be called in order to send video frames.
+ // Status of the initialization will be returned on cast_initialization_cb.
+ virtual void InitializeVideo(
+ const VideoSenderConfig& video_config,
+ const CastInitializationCallback& cast_initialization_cb,
+ const scoped_refptr<GpuVideoAcceleratorFactories>& gpu_factories) = 0;
};
} // namespace cast
« no previous file with comments | « media/cast/cast_receiver_impl.cc ('k') | media/cast/cast_sender_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698