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. 7 8 #ifndef MEDIA_CAST_CAST_RECEIVER_H_ 9 #define MEDIA_CAST_CAST_RECEIVER_H_ 10 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" 18 19 namespace media { 20 class VideoFrame; 21 } 22 23 namespace media { 24 namespace cast { 25 // Callback in which the raw audio frame and play-out time will be returned 26 // once decoding is complete. 27 typedef base::Callback<void(scoped_ptr<PcmAudioFrame>, const base::TimeTicks&)> 28 AudioFrameDecodedCallback; 29 30 // Callback in which the encoded audio frame and play-out time will be returned. 31 typedef base::Callback<void(scoped_ptr<EncodedAudioFrame>, 32 const base::TimeTicks&)> AudioFrameEncodedCallback; 33 34 // Callback in which the raw frame and render time will be returned once 35 // decoding is complete. 36 typedef base::Callback<void(const scoped_refptr<media::VideoFrame>& video_frame, 37 const base::TimeTicks&)> 38 VideoFrameDecodedCallback; 39 40 // Callback in which the encoded video frame and render time will be returned. 41 typedef base::Callback<void(scoped_ptr<EncodedVideoFrame>, 42 const base::TimeTicks&)> VideoFrameEncodedCallback; 43 44 // This Class is thread safe. 45 class FrameReceiver : public base::RefCountedThreadSafe<FrameReceiver> { 46 public: 47 virtual void GetRawAudioFrame(int number_of_10ms_blocks, 48 int desired_frequency, 49 const AudioFrameDecodedCallback& callback) = 0; 50 51 virtual void GetCodedAudioFrame( 52 const AudioFrameEncodedCallback& callback) = 0; 53 54 virtual void GetRawVideoFrame(const VideoFrameDecodedCallback& callback) = 0; 55 56 virtual void GetEncodedVideoFrame( 57 const VideoFrameEncodedCallback& callback) = 0; 58 59 protected: 60 virtual ~FrameReceiver() {} 61 62 private: 63 friend class base::RefCountedThreadSafe<FrameReceiver>; 64 }; 65 66 // This Class is thread safe. 67 class CastReceiver { 68 public: 69 static CastReceiver* CreateCastReceiver( 70 scoped_refptr<CastEnvironment> cast_environment, 71 const AudioReceiverConfig& audio_config, 72 const VideoReceiverConfig& video_config, 73 PacketSender* const packet_sender); 74 75 // All received RTP and RTCP packets for the call should be inserted to this 76 // PacketReceiver. 77 virtual scoped_refptr<PacketReceiver> packet_receiver() = 0; 78 79 // Polling interface to get audio and video frames from the CastReceiver. 80 virtual scoped_refptr<FrameReceiver> frame_receiver() = 0; 81 82 virtual ~CastReceiver() {} 83 }; 84 85 } // namespace cast 86 } // namespace media 87 88 #endif // MEDIA_CAST_CAST_RECEIVER_H_ 89