| 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 // This is the main interface for the cast transport sender. It accepts encoded | 5 // This is the main interface for the cast transport sender. It accepts encoded |
| 6 // frames (both audio and video), encrypts their encoded data, packetizes them | 6 // frames (both audio and video), encrypts their encoded data, packetizes them |
| 7 // and feeds them into a transport (e.g., UDP). | 7 // and feeds them into a transport (e.g., UDP). |
| 8 | 8 |
| 9 // Construction of the Cast Sender and the Cast Transport should be done | 9 // Construction of the Cast Sender and the Cast Transport should be done |
| 10 // in the following order: | 10 // in the following order: |
| 11 // 1. Create CastTransport. | 11 // 1. Create CastTransport. |
| 12 // 2. Create CastSender (accepts CastTransport as an input). | 12 // 2. Create CastSender (accepts CastTransport as an input). |
| 13 | 13 |
| 14 // Destruction: The CastTransport is assumed to be valid as long as the | 14 // Destruction: The CastTransport is assumed to be valid as long as the |
| 15 // CastSender is alive. Therefore the CastSender should be destructed before the | 15 // CastSender is alive. Therefore the CastSender should be destructed before the |
| 16 // CastTransport. | 16 // CastTransport. |
| 17 | 17 |
| 18 #ifndef MEDIA_CAST_NET_CAST_TRANSPORT_H_ | 18 #ifndef MEDIA_CAST_NET_CAST_TRANSPORT_H_ |
| 19 #define MEDIA_CAST_NET_CAST_TRANSPORT_H_ | 19 #define MEDIA_CAST_NET_CAST_TRANSPORT_H_ |
| 20 | 20 |
| 21 #include <stdint.h> | 21 #include <stdint.h> |
| 22 | 22 |
| 23 #include <memory> |
| 24 |
| 23 #include "base/callback.h" | 25 #include "base/callback.h" |
| 24 #include "base/memory/scoped_ptr.h" | |
| 25 #include "base/single_thread_task_runner.h" | 26 #include "base/single_thread_task_runner.h" |
| 26 #include "base/threading/non_thread_safe.h" | 27 #include "base/threading/non_thread_safe.h" |
| 27 #include "base/time/tick_clock.h" | 28 #include "base/time/tick_clock.h" |
| 28 #include "base/values.h" | 29 #include "base/values.h" |
| 29 #include "media/cast/logging/logging_defines.h" | 30 #include "media/cast/logging/logging_defines.h" |
| 30 #include "media/cast/net/cast_transport_config.h" | 31 #include "media/cast/net/cast_transport_config.h" |
| 31 #include "media/cast/net/cast_transport_defines.h" | 32 #include "media/cast/net/cast_transport_defines.h" |
| 32 #include "media/cast/net/rtcp/receiver_rtcp_event_subscriber.h" | 33 #include "media/cast/net/rtcp/receiver_rtcp_event_subscriber.h" |
| 33 #include "media/cast/net/rtcp/rtcp_defines.h" | 34 #include "media/cast/net/rtcp/rtcp_defines.h" |
| 34 #include "net/base/ip_endpoint.h" | 35 #include "net/base/ip_endpoint.h" |
| (...skipping 10 matching lines...) Expand all Loading... |
| 45 namespace cast { | 46 namespace cast { |
| 46 | 47 |
| 47 struct RtpReceiverStatistics; | 48 struct RtpReceiverStatistics; |
| 48 struct RtcpTimeData; | 49 struct RtcpTimeData; |
| 49 | 50 |
| 50 // Following the initialization of either audio or video an initialization | 51 // Following the initialization of either audio or video an initialization |
| 51 // status will be sent via this callback. | 52 // status will be sent via this callback. |
| 52 typedef base::Callback<void(CastTransportStatus status)> | 53 typedef base::Callback<void(CastTransportStatus status)> |
| 53 CastTransportStatusCallback; | 54 CastTransportStatusCallback; |
| 54 | 55 |
| 55 typedef base::Callback<void(scoped_ptr<std::vector<FrameEvent>>, | 56 typedef base::Callback<void(std::unique_ptr<std::vector<FrameEvent>>, |
| 56 scoped_ptr<std::vector<PacketEvent>>)> | 57 std::unique_ptr<std::vector<PacketEvent>>)> |
| 57 BulkRawEventsCallback; | 58 BulkRawEventsCallback; |
| 58 | 59 |
| 59 // The application should only trigger this class from the transport thread. | 60 // The application should only trigger this class from the transport thread. |
| 60 class CastTransport : public base::NonThreadSafe { | 61 class CastTransport : public base::NonThreadSafe { |
| 61 public: | 62 public: |
| 62 // Interface used for receiving status updates, raw events, and RTP packets | 63 // Interface used for receiving status updates, raw events, and RTP packets |
| 63 // from CastTransport. | 64 // from CastTransport. |
| 64 class Client { | 65 class Client { |
| 65 public: | 66 public: |
| 66 virtual ~Client(){}; | 67 virtual ~Client(){}; |
| 67 | 68 |
| 68 // Audio and Video transport status change is reported on this callback. | 69 // Audio and Video transport status change is reported on this callback. |
| 69 virtual void OnStatusChanged(CastTransportStatus status) = 0; | 70 virtual void OnStatusChanged(CastTransportStatus status) = 0; |
| 70 | 71 |
| 71 // Raw events will be invoked on this callback periodically, according to | 72 // Raw events will be invoked on this callback periodically, according to |
| 72 // the configured logging flush interval passed to | 73 // the configured logging flush interval passed to |
| 73 // CastTransport::Create(). | 74 // CastTransport::Create(). |
| 74 virtual void OnLoggingEventsReceived( | 75 virtual void OnLoggingEventsReceived( |
| 75 scoped_ptr<std::vector<FrameEvent>> frame_events, | 76 std::unique_ptr<std::vector<FrameEvent>> frame_events, |
| 76 scoped_ptr<std::vector<PacketEvent>> packet_events) = 0; | 77 std::unique_ptr<std::vector<PacketEvent>> packet_events) = 0; |
| 77 | 78 |
| 78 // Called to pass RTP packets to the Client. | 79 // Called to pass RTP packets to the Client. |
| 79 virtual void ProcessRtpPacket(scoped_ptr<Packet> packet) = 0; | 80 virtual void ProcessRtpPacket(std::unique_ptr<Packet> packet) = 0; |
| 80 }; | 81 }; |
| 81 | 82 |
| 82 static scoped_ptr<CastTransport> Create( | 83 static std::unique_ptr<CastTransport> Create( |
| 83 base::TickClock* clock, // Owned by the caller. | 84 base::TickClock* clock, // Owned by the caller. |
| 84 base::TimeDelta logging_flush_interval, | 85 base::TimeDelta logging_flush_interval, |
| 85 scoped_ptr<Client> client, | 86 std::unique_ptr<Client> client, |
| 86 scoped_ptr<PacketTransport> transport, | 87 std::unique_ptr<PacketTransport> transport, |
| 87 const scoped_refptr<base::SingleThreadTaskRunner>& transport_task_runner); | 88 const scoped_refptr<base::SingleThreadTaskRunner>& transport_task_runner); |
| 88 | 89 |
| 89 virtual ~CastTransport() {} | 90 virtual ~CastTransport() {} |
| 90 | 91 |
| 91 // Audio/Video initialization. | 92 // Audio/Video initialization. |
| 92 // Encoded frames cannot be transmitted until the relevant initialize method | 93 // Encoded frames cannot be transmitted until the relevant initialize method |
| 93 // is called. | 94 // is called. |
| 94 virtual void InitializeAudio(const CastTransportRtpConfig& config, | 95 virtual void InitializeAudio(const CastTransportRtpConfig& config, |
| 95 const RtcpCastMessageCallback& cast_message_cb, | 96 const RtcpCastMessageCallback& cast_message_cb, |
| 96 const RtcpRttCallback& rtt_cb, | 97 const RtcpRttCallback& rtt_cb, |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 155 virtual void SendRtcpFromRtpReceiver() = 0; | 156 virtual void SendRtcpFromRtpReceiver() = 0; |
| 156 | 157 |
| 157 // Set options for the PacedSender and Wifi. | 158 // Set options for the PacedSender and Wifi. |
| 158 virtual void SetOptions(const base::DictionaryValue& options) = 0; | 159 virtual void SetOptions(const base::DictionaryValue& options) = 0; |
| 159 }; | 160 }; |
| 160 | 161 |
| 161 } // namespace cast | 162 } // namespace cast |
| 162 } // namespace media | 163 } // namespace media |
| 163 | 164 |
| 164 #endif // MEDIA_CAST_NET_CAST_TRANSPORT_H_ | 165 #endif // MEDIA_CAST_NET_CAST_TRANSPORT_H_ |
| OLD | NEW |