diff options
Diffstat (limited to 'media/cast/cast_sender.h')
-rw-r--r-- | media/cast/cast_sender.h | 60 |
1 files changed, 47 insertions, 13 deletions
diff --git a/media/cast/cast_sender.h b/media/cast/cast_sender.h index b5a3bcb..254370b 100644 --- a/media/cast/cast_sender.h +++ b/media/cast/cast_sender.h @@ -1,38 +1,70 @@ // Copyright 2013 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. +// +// This is the main interface for the cast sender. All configuration are done +// at creation. +// +// The FrameInput and PacketReciever interfaces should normally be accessed from +// the IO thread. However they are allowed to be called from any thread. #ifndef MEDIA_CAST_CAST_SENDER_H_ #define MEDIA_CAST_CAST_SENDER_H_ #include "base/basictypes.h" +#include "base/callback.h" +#include "base/memory/ref_counted.h" #include "base/time/time.h" #include "media/cast/cast_config.h" +#include "media/cast/cast_thread.h" namespace media { namespace cast { +// This Class is thread safe. class FrameInput { public: - virtual void InsertRawVideoFrame(const I420VideoFrame& video_frame, - base::TimeTicks capture_time) = 0; + // 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. + virtual void InsertRawVideoFrame(const I420VideoFrame* video_frame, + const base::TimeTicks& capture_time, + const base::Closure callback) = 0; - virtual void InsertCodedVideoFrame(const EncodedVideoFrame& video_frame, - base::TimeTicks capture_time) = 0; + // The video_frame must be valid until the callback is called. + // The callback is called from the main cast thread as soon as + // the cast sender is done with the frame; it does not mean that the encoded + // frame has been sent out. + virtual void InsertCodedVideoFrame(const EncodedVideoFrame* video_frame, + const base::TimeTicks& capture_time, + const base::Closure callback) = 0; - virtual void InsertRawAudioFrame(const PcmAudioFrame& audio_frame, - base::TimeTicks recorded_time) = 0; + // The audio_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. + virtual void InsertRawAudioFrame(const PcmAudioFrame* audio_frame, + const base::TimeTicks& recorded_time, + const base::Closure callback) = 0; - virtual void InsertCodedAudioFrame(const EncodedAudioFrame& audio_frame, - base::TimeTicks recorded_time) = 0; + // The audio_frame must be valid until the callback is called. + // The callback is called from the main cast thread as soon as + // the cast sender is done with the frame; it does not mean that the encoded + // frame has been sent out. + virtual void InsertCodedAudioFrame(const EncodedAudioFrame* audio_frame, + const base::TimeTicks& recorded_time, + const base::Closure callback) = 0; protected: virtual ~FrameInput() {} }; +// This Class is thread safe. class CastSender { public: static CastSender* CreateCastSender( + scoped_refptr<CastThread> cast_thread, const AudioSenderConfig& audio_config, const VideoSenderConfig& video_config, VideoEncoderController* const video_encoder_controller, @@ -40,12 +72,14 @@ class CastSender { virtual ~CastSender() {}; - virtual FrameInput* frame_input() = 0; + // 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 RTCP packets for the call should be inserted to this - // PacketReceiver. The PacketReceiver pointer is valid as long as the - // CastSender instance exists. - virtual PacketReceiver* packet_receiver() = 0; + // All RTCP packets for the session should be inserted to this object. + // Can be called from any thread. + virtual scoped_refptr<PacketReceiver> packet_receiver() = 0; }; } // namespace cast |