#ifndef MEDIA_CAST_CAST_RECEIVER_H_
#define MEDIA_CAST_CAST_RECEIVER_H_
#include "base/basictypes.h"
#include "base/callback.h"
#include "base/memory/ref_counted.h"
#include "base/memory/scoped_ptr.h"
#include "base/time/time.h"
#include "media/base/audio_bus.h"
#include "media/cast/cast_config.h"
#include "media/cast/cast_environment.h"
namespace media {
class VideoFrame;
namespace cast {
namespace transport {
class PacketSender;
}
typedef base::Callback<void(scoped_ptr<AudioBus> audio_bus,
const base::TimeTicks& playout_time,
bool is_continuous)> AudioFrameDecodedCallback;
typedef base::Callback<void(scoped_ptr<transport::EncodedAudioFrame>,
const base::TimeTicks&)> AudioFrameEncodedCallback;
typedef base::Callback<void(const scoped_refptr<media::VideoFrame>& video_frame,
const base::TimeTicks&)> VideoFrameDecodedCallback;
typedef base::Callback<void(scoped_ptr<transport::EncodedVideoFrame>,
const base::TimeTicks&)> VideoFrameEncodedCallback;
class FrameReceiver : public base::RefCountedThreadSafe<FrameReceiver> {
public:
virtual void GetRawAudioFrame(const AudioFrameDecodedCallback& callback) = 0;
virtual void GetCodedAudioFrame(
const AudioFrameEncodedCallback& callback) = 0;
virtual void GetRawVideoFrame(const VideoFrameDecodedCallback& callback) = 0;
virtual void GetEncodedVideoFrame(
const VideoFrameEncodedCallback& callback) = 0;
protected:
virtual ~FrameReceiver() {}
private:
friend class base::RefCountedThreadSafe<FrameReceiver>;
};
class CastReceiver {
public:
static scoped_ptr<CastReceiver> Create(
scoped_refptr<CastEnvironment> cast_environment,
const AudioReceiverConfig& audio_config,
const VideoReceiverConfig& video_config,
transport::PacketSender* const packet_sender);
virtual transport::PacketReceiverCallback packet_receiver() = 0;
virtual scoped_refptr<FrameReceiver> frame_receiver() = 0;
virtual ~CastReceiver() {}
};
}
}
#endif