1 // Copyright 2014 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 #ifndef CHROME_BROWSER_MEDIA_CAST_TRANSPORT_HOST_FILTER_H_ 6 #define CHROME_BROWSER_MEDIA_CAST_TRANSPORT_HOST_FILTER_H_ 7 8 #include "base/id_map.h" 9 #include "base/memory/scoped_ptr.h" 10 #include "base/memory/weak_ptr.h" 11 #include "base/time/default_tick_clock.h" 12 #include "chrome/common/cast_messages.h" 13 #include "content/public/browser/browser_message_filter.h" 14 #include "media/cast/cast_sender.h" 15 #include "media/cast/logging/logging_defines.h" 16 #include "media/cast/net/cast_transport_sender.h" 17 18 namespace content { 19 class PowerSaveBlocker; 20 } // namespace content 21 22 namespace cast { 23 24 class CastTransportHostFilter : public content::BrowserMessageFilter { 25 public: 26 CastTransportHostFilter(); 27 private: 28 virtual ~CastTransportHostFilter(); 29 30 void NotifyStatusChange( 31 int32 channel_id, 32 media::cast::CastTransportStatus result); 33 void SendRawEvents( 34 int32 channel_id, 35 const std::vector<media::cast::PacketEvent>& packet_events, 36 const std::vector<media::cast::FrameEvent>& frame_events); 37 void SendRtt(int32 channel_id, uint32 ssrc, base::TimeDelta rtt); 38 void SendCastMessage(int32 channel_id, 39 uint32 ssrc, 40 const media::cast::RtcpCastMessage& cast_message); 41 42 // BrowserMessageFilter implementation. 43 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; 44 45 // Forwarding functions. 46 void OnInitializeAudio( 47 int32 channel_id, 48 const media::cast::CastTransportRtpConfig& config); 49 void OnInitializeVideo( 50 int32 channel_id, 51 const media::cast::CastTransportRtpConfig& config); 52 void OnInsertFrame( 53 int32 channel_id, 54 uint32 ssrc, 55 const media::cast::EncodedFrame& frame); 56 void OnSendSenderReport( 57 int32 channel_id, 58 uint32 ssrc, 59 base::TimeTicks current_time, 60 uint32 current_time_as_rtp_timestamp); 61 void OnCancelSendingFrames(int32 channel_id, uint32 ssrc, 62 const std::vector<uint32>& frame_ids); 63 void OnResendFrameForKickstart(int32 channel_id, uint32 ssrc, 64 uint32 frame_id); 65 void OnNew( 66 int32 channel_id, 67 const net::IPEndPoint& remote_end_point, 68 const base::DictionaryValue& options); 69 void OnDelete(int32 channel_id); 70 71 IDMap<media::cast::CastTransportSender, IDMapOwnPointer> id_map_; 72 73 // Clock used by Cast transport. 74 base::DefaultTickClock clock_; 75 76 // While |id_map_| is non-empty, hold an instance of 77 // content::PowerSaveBlocker. This prevents Chrome from being suspended while 78 // remoting content. 79 scoped_ptr<content::PowerSaveBlocker> power_save_blocker_; 80 81 base::WeakPtrFactory<CastTransportHostFilter> weak_factory_; 82 83 DISALLOW_COPY_AND_ASSIGN(CastTransportHostFilter); 84 }; 85 86 } // namespace cast 87 88 #endif // CHROME_BROWSER_MEDIA_CAST_TRANSPORT_HOST_FILTER_H_ 89