1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 // This is the main interface for the cast receiver. All configuration are done
8 #ifndef MEDIA_CAST_CAST_RECEIVER_H_
9 #define MEDIA_CAST_CAST_RECEIVER_H_
11 #include "base/basictypes.h"
12 #include "base/callback.h"
13 #include "base/memory/ref_counted.h"
14 #include "base/memory/scoped_ptr.h"
15 #include "base/time/time.h"
16 #include "media/cast/cast_config.h"
17 #include "media/cast/cast_environment.h"
28 // Callback in which the raw audio frame and play-out time will be returned
29 // once decoding is complete.
30 typedef base::Callback
<void(scoped_ptr
<PcmAudioFrame
>, const base::TimeTicks
&)>
31 AudioFrameDecodedCallback
;
33 // Callback in which the encoded audio frame and play-out time will be returned.
34 typedef base::Callback
<void(scoped_ptr
<transport::EncodedAudioFrame
>,
35 const base::TimeTicks
&)> AudioFrameEncodedCallback
;
37 // Callback in which the raw frame and render time will be returned once
38 // decoding is complete.
39 typedef base::Callback
<void(const scoped_refptr
<media::VideoFrame
>& video_frame
,
40 const base::TimeTicks
&)> VideoFrameDecodedCallback
;
42 // Callback in which the encoded video frame and render time will be returned.
43 typedef base::Callback
<void(scoped_ptr
<transport::EncodedVideoFrame
>,
44 const base::TimeTicks
&)> VideoFrameEncodedCallback
;
46 // This Class is thread safe.
47 class FrameReceiver
: public base::RefCountedThreadSafe
<FrameReceiver
> {
49 virtual void GetRawAudioFrame(int number_of_10ms_blocks
,
50 int desired_frequency
,
51 const AudioFrameDecodedCallback
& callback
) = 0;
53 virtual void GetCodedAudioFrame(
54 const AudioFrameEncodedCallback
& callback
) = 0;
56 virtual void GetRawVideoFrame(const VideoFrameDecodedCallback
& callback
) = 0;
58 virtual void GetEncodedVideoFrame(
59 const VideoFrameEncodedCallback
& callback
) = 0;
62 virtual ~FrameReceiver() {}
65 friend class base::RefCountedThreadSafe
<FrameReceiver
>;
68 // This Class is thread safe.
71 static CastReceiver
* CreateCastReceiver(
72 scoped_refptr
<CastEnvironment
> cast_environment
,
73 const AudioReceiverConfig
& audio_config
,
74 const VideoReceiverConfig
& video_config
,
75 transport::PacketSender
* const packet_sender
);
77 // All received RTP and RTCP packets for the call should be sent to this
78 // PacketReceiver. Can be called from any function.
79 // TODO(hubbe): Replace with:
80 // virtual void ReceivePacket(scoped_ptr<Packet> packet) = 0;
81 virtual transport::PacketReceiverCallback
packet_receiver() = 0;
83 // Polling interface to get audio and video frames from the CastReceiver.
84 virtual scoped_refptr
<FrameReceiver
> frame_receiver() = 0;
86 virtual ~CastReceiver() {}
92 #endif // MEDIA_CAST_CAST_RECEIVER_H_