Run SPD in a single-threaded mode.
[chromium-blink-merge.git] / media / cast / cast_receiver.h
blobec4f0d30df281095c65626657f50fe173fa62247
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.
4 //
5 // This is the main interface for the cast receiver. All configuration are done
6 // at creation.
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"
19 namespace media {
20 class VideoFrame;
22 namespace cast {
24 namespace transport {
25 class PacketSender;
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> {
48 public:
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;
61 protected:
62 virtual ~FrameReceiver() {}
64 private:
65 friend class base::RefCountedThreadSafe<FrameReceiver>;
68 // This Class is thread safe.
69 class CastReceiver {
70 public:
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() {}
89 } // namespace cast
90 } // namespace media
92 #endif // MEDIA_CAST_CAST_RECEIVER_H_