| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef CHROME_BROWSER_MEDIA_CAST_TRANSPORT_HOST_FILTER_H_ | 5 #ifndef CHROME_BROWSER_MEDIA_CAST_TRANSPORT_HOST_FILTER_H_ |
| 6 #define CHROME_BROWSER_MEDIA_CAST_TRANSPORT_HOST_FILTER_H_ | 6 #define CHROME_BROWSER_MEDIA_CAST_TRANSPORT_HOST_FILTER_H_ |
| 7 | 7 |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <memory> | 10 #include <memory> |
| 11 | 11 |
| 12 #include "base/id_map.h" | 12 #include "base/id_map.h" |
| 13 #include "base/macros.h" | 13 #include "base/macros.h" |
| 14 #include "base/memory/weak_ptr.h" | 14 #include "base/memory/weak_ptr.h" |
| 15 #include "base/time/default_tick_clock.h" | 15 #include "base/time/default_tick_clock.h" |
| 16 #include "chrome/browser/media/cast_remoting_sender.h" |
| 16 #include "content/public/browser/browser_message_filter.h" | 17 #include "content/public/browser/browser_message_filter.h" |
| 17 #include "media/cast/cast_sender.h" | 18 #include "media/cast/cast_sender.h" |
| 18 #include "media/cast/logging/logging_defines.h" | 19 #include "media/cast/logging/logging_defines.h" |
| 19 #include "media/cast/net/cast_transport.h" | 20 #include "media/cast/net/cast_transport.h" |
| 20 #include "media/cast/net/udp_transport.h" | 21 #include "media/cast/net/udp_transport.h" |
| 21 | 22 |
| 22 namespace device { | 23 namespace device { |
| 23 class PowerSaveBlocker; | 24 class PowerSaveBlocker; |
| 24 } // namespace device | 25 } // namespace device |
| 25 | 26 |
| 26 namespace cast { | 27 namespace cast { |
| 27 | 28 |
| 28 class CastTransportHostFilter : public content::BrowserMessageFilter { | 29 class CastTransportHostFilter : public content::BrowserMessageFilter { |
| 29 public: | 30 public: |
| 30 CastTransportHostFilter(); | 31 CastTransportHostFilter(); |
| 31 | 32 |
| 32 private: | 33 private: |
| 33 ~CastTransportHostFilter() override; | 34 ~CastTransportHostFilter() override; |
| 34 | 35 |
| 35 // Status callback to create UdpTransport. | 36 // Status callback to create UdpTransport. |
| 36 void OnStatusChanged(int32_t channel_id, | 37 void OnStatusChanged(int32_t channel_id, |
| 37 media::cast::CastTransportStatus status); | 38 media::cast::CastTransportStatus status); |
| 38 | 39 |
| 39 // BrowserMessageFilter implementation. | 40 // BrowserMessageFilter implementation. |
| 40 bool OnMessageReceived(const IPC::Message& message) override; | 41 bool OnMessageReceived(const IPC::Message& message) override; |
| 41 | 42 |
| 42 // Forwarding functions. | 43 // Forwarding functions. |
| 44 // For remoting RTP streams, calling this will create a CastRemotingSender for |
| 45 // the stream, which will be automatically destroyed when the associated |
| 46 // chanel is deleted. |
| 43 void OnInitializeStream(int32_t channel_id, | 47 void OnInitializeStream(int32_t channel_id, |
| 44 const media::cast::CastTransportRtpConfig& config); | 48 const media::cast::CastTransportRtpConfig& config); |
| 49 |
| 45 void OnInsertFrame(int32_t channel_id, | 50 void OnInsertFrame(int32_t channel_id, |
| 46 uint32_t ssrc, | 51 uint32_t ssrc, |
| 47 const media::cast::EncodedFrame& frame); | 52 const media::cast::EncodedFrame& frame); |
| 48 void OnSendSenderReport( | 53 void OnSendSenderReport( |
| 49 int32_t channel_id, | 54 int32_t channel_id, |
| 50 uint32_t ssrc, | 55 uint32_t ssrc, |
| 51 base::TimeTicks current_time, | 56 base::TimeTicks current_time, |
| 52 media::cast::RtpTimeTicks current_time_as_rtp_timestamp); | 57 media::cast::RtpTimeTicks current_time_as_rtp_timestamp); |
| 53 void OnCancelSendingFrames( | 58 void OnCancelSendingFrames( |
| 54 int32_t channel_id, | 59 int32_t channel_id, |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 86 IDMap<media::cast::CastTransport, IDMapOwnPointer> id_map_; | 91 IDMap<media::cast::CastTransport, IDMapOwnPointer> id_map_; |
| 87 | 92 |
| 88 // Clock used by Cast transport. | 93 // Clock used by Cast transport. |
| 89 base::DefaultTickClock clock_; | 94 base::DefaultTickClock clock_; |
| 90 | 95 |
| 91 // While |id_map_| is non-empty, hold an instance of | 96 // While |id_map_| is non-empty, hold an instance of |
| 92 // device::PowerSaveBlocker. This prevents Chrome from being suspended while | 97 // device::PowerSaveBlocker. This prevents Chrome from being suspended while |
| 93 // remoting content. | 98 // remoting content. |
| 94 std::unique_ptr<device::PowerSaveBlocker> power_save_blocker_; | 99 std::unique_ptr<device::PowerSaveBlocker> power_save_blocker_; |
| 95 | 100 |
| 101 // This map records all active remoting senders. It uses the unique RTP |
| 102 // stream ID as the key. |
| 103 IDMap<CastRemotingSender, IDMapOwnPointer> remoting_sender_map_; |
| 104 |
| 105 // This map stores all active remoting streams for each channel. It uses the |
| 106 // channel ID as the key. |
| 107 std::multimap<int32_t, int32_t> stream_id_map_; |
| 108 |
| 96 base::WeakPtrFactory<CastTransportHostFilter> weak_factory_; | 109 base::WeakPtrFactory<CastTransportHostFilter> weak_factory_; |
| 97 | 110 |
| 98 DISALLOW_COPY_AND_ASSIGN(CastTransportHostFilter); | 111 DISALLOW_COPY_AND_ASSIGN(CastTransportHostFilter); |
| 99 }; | 112 }; |
| 100 | 113 |
| 101 } // namespace cast | 114 } // namespace cast |
| 102 | 115 |
| 103 #endif // CHROME_BROWSER_MEDIA_CAST_TRANSPORT_HOST_FILTER_H_ | 116 #endif // CHROME_BROWSER_MEDIA_CAST_TRANSPORT_HOST_FILTER_H_ |
| OLD | NEW |