Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(299)

Side by Side Diff: media/cast/net/cast_transport.h

Issue 1878883003: Refactor: simplify interface of SenderRtcpSession and CastTransport. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressed comments. Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 "base/callback.h" 23 #include "base/callback.h"
24 #include "base/memory/scoped_ptr.h"
25 #include "base/single_thread_task_runner.h" 24 #include "base/single_thread_task_runner.h"
26 #include "base/threading/non_thread_safe.h" 25 #include "base/threading/non_thread_safe.h"
27 #include "base/time/tick_clock.h" 26 #include "base/time/tick_clock.h"
28 #include "base/values.h" 27 #include "base/values.h"
29 #include "media/cast/logging/logging_defines.h" 28 #include "media/cast/logging/logging_defines.h"
30 #include "media/cast/net/cast_transport_config.h" 29 #include "media/cast/net/cast_transport_config.h"
31 #include "media/cast/net/cast_transport_defines.h" 30 #include "media/cast/net/cast_transport_defines.h"
32 #include "media/cast/net/rtcp/receiver_rtcp_event_subscriber.h" 31 #include "media/cast/net/rtcp/receiver_rtcp_event_subscriber.h"
33 #include "media/cast/net/rtcp/rtcp_defines.h" 32 #include "media/cast/net/rtcp/rtcp_defines.h"
34 #include "net/base/ip_endpoint.h" 33 #include "net/base/ip_endpoint.h"
35 34
36 namespace base { 35 namespace base {
37 class DictionaryValue; 36 class DictionaryValue;
38 } // namespace base 37 } // namespace base
39 38
40 namespace net { 39 namespace net {
41 class NetLog; 40 class NetLog;
42 } // namespace net 41 } // namespace net
43 42
44 namespace media { 43 namespace media {
45 namespace cast { 44 namespace cast {
46 45
47 struct RtpReceiverStatistics; 46 struct RtpReceiverStatistics;
48 struct RtcpTimeData; 47 struct RtcpTimeData;
49 48
50 // Following the initialization of either audio or video an initialization 49 // Following the initialization of either audio or video an initialization
51 // status will be sent via this callback. 50 // status will be sent via this callback.
52 typedef base::Callback<void(CastTransportStatus status)> 51 using CastTransportStatusCallback =
53 CastTransportStatusCallback; 52 base::Callback<void(CastTransportStatus status)>;
54 53
55 typedef base::Callback<void(scoped_ptr<std::vector<FrameEvent>>, 54 using BulkRawEventsCallback =
56 scoped_ptr<std::vector<PacketEvent>>)> 55 base::Callback<void(std::unique_ptr<std::vector<FrameEvent>>,
57 BulkRawEventsCallback; 56 std::unique_ptr<std::vector<PacketEvent>>)>;
57
58 // Interface to handle received RTCP messages on RTP sender.
59 class SenderRtcpObserver {
60 public:
61 virtual ~SenderRtcpObserver() {}
62
63 // Called on receiving cast message from RTP receiver.
64 virtual void OnCastMessageReceived(const RtcpCastMessage& cast_message) = 0;
65
66 // Called on receiving Rtt message from RTP receiver.
67 virtual void OnRttReceived(base::TimeDelta round_trip_time) = 0;
68
69 // Called on receiving PLI from RTP receiver.
70 virtual void OnPliReceived() = 0;
71
72 // Called on receiving RTP receiver logs.
73 virtual void OnReceiverLogReceived(const RtcpReceiverLogMessage& log){};
miu 2016/04/25 23:23:53 nit: space before {}
xjz 2016/04/29 19:15:49 Done.
74 };
58 75
59 // The application should only trigger this class from the transport thread. 76 // The application should only trigger this class from the transport thread.
60 class CastTransport : public base::NonThreadSafe { 77 class CastTransport : public base::NonThreadSafe {
61 public: 78 public:
62 // Interface used for receiving status updates, raw events, and RTP packets 79 // Interface used for receiving status updates, raw events, and RTP packets
63 // from CastTransport. 80 // from CastTransport.
64 class Client { 81 class Client {
65 public: 82 public:
66 virtual ~Client(){}; 83 virtual ~Client(){};
67 84
68 // Audio and Video transport status change is reported on this callback. 85 // Audio and Video transport status change is reported on this callback.
69 virtual void OnStatusChanged(CastTransportStatus status) = 0; 86 virtual void OnStatusChanged(CastTransportStatus status) = 0;
70 87
71 // Raw events will be invoked on this callback periodically, according to 88 // Raw events will be invoked on this callback periodically, according to
72 // the configured logging flush interval passed to 89 // the configured logging flush interval passed to
73 // CastTransport::Create(). 90 // CastTransport::Create().
74 virtual void OnLoggingEventsReceived( 91 virtual void OnLoggingEventsReceived(
75 scoped_ptr<std::vector<FrameEvent>> frame_events, 92 std::unique_ptr<std::vector<FrameEvent>> frame_events,
76 scoped_ptr<std::vector<PacketEvent>> packet_events) = 0; 93 std::unique_ptr<std::vector<PacketEvent>> packet_events) = 0;
77 94
78 // Called to pass RTP packets to the Client. 95 // Called to pass RTP packets to the Client.
79 virtual void ProcessRtpPacket(scoped_ptr<Packet> packet) = 0; 96 virtual void ProcessRtpPacket(std::unique_ptr<Packet> packet) = 0;
80 }; 97 };
81 98
82 static scoped_ptr<CastTransport> Create( 99 static std::unique_ptr<CastTransport> Create(
83 base::TickClock* clock, // Owned by the caller. 100 base::TickClock* clock, // Owned by the caller.
84 base::TimeDelta logging_flush_interval, 101 base::TimeDelta logging_flush_interval,
85 scoped_ptr<Client> client, 102 std::unique_ptr<Client> client,
86 scoped_ptr<PacketTransport> transport, 103 std::unique_ptr<PacketTransport> transport,
87 const scoped_refptr<base::SingleThreadTaskRunner>& transport_task_runner); 104 const scoped_refptr<base::SingleThreadTaskRunner>& transport_task_runner);
88 105
89 virtual ~CastTransport() {} 106 virtual ~CastTransport() {}
90 107
91 // Audio/Video initialization. 108 // Audio/Video initialization.
92 // Encoded frames cannot be transmitted until the relevant initialize method 109 // Encoded frames cannot be transmitted until the relevant initialize method
93 // is called. 110 // is called.
94 virtual void InitializeAudio(const CastTransportRtpConfig& config, 111 virtual void InitializeAudio(
95 const RtcpCastMessageCallback& cast_message_cb, 112 const CastTransportRtpConfig& config,
96 const RtcpRttCallback& rtt_cb, 113 std::unique_ptr<SenderRtcpObserver> rtcp_observer) {}
97 const RtcpPliCallback& pli_cb) = 0; 114 virtual void InitializeVideo(
98 virtual void InitializeVideo(const CastTransportRtpConfig& config, 115 const CastTransportRtpConfig& config,
99 const RtcpCastMessageCallback& cast_message_cb, 116 std::unique_ptr<SenderRtcpObserver> rtcp_observer) {}
100 const RtcpRttCallback& rtt_cb,
101 const RtcpPliCallback& pli_cb) = 0;
102 117
103 // Encrypt, packetize and transmit |frame|. |ssrc| must refer to a 118 // Encrypt, packetize and transmit |frame|. |ssrc| must refer to a
104 // a channel already established with InitializeAudio / InitializeVideo. 119 // a channel already established with InitializeAudio / InitializeVideo.
105 virtual void InsertFrame(uint32_t ssrc, const EncodedFrame& frame) = 0; 120 virtual void InsertFrame(uint32_t ssrc, const EncodedFrame& frame) = 0;
106 121
107 // Sends a RTCP sender report to the receiver. 122 // Sends a RTCP sender report to the receiver.
108 // |ssrc| is the SSRC for this report. 123 // |ssrc| is the SSRC for this report.
109 // |current_time| is the current time reported by a tick clock. 124 // |current_time| is the current time reported by a tick clock.
110 // |current_time_as_rtp_timestamp| is the corresponding RTP timestamp. 125 // |current_time_as_rtp_timestamp| is the corresponding RTP timestamp.
111 virtual void SendSenderReport(uint32_t ssrc, 126 virtual void SendSenderReport(uint32_t ssrc,
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
155 virtual void SendRtcpFromRtpReceiver() = 0; 170 virtual void SendRtcpFromRtpReceiver() = 0;
156 171
157 // Set options for the PacedSender and Wifi. 172 // Set options for the PacedSender and Wifi.
158 virtual void SetOptions(const base::DictionaryValue& options) = 0; 173 virtual void SetOptions(const base::DictionaryValue& options) = 0;
159 }; 174 };
160 175
161 } // namespace cast 176 } // namespace cast
162 } // namespace media 177 } // namespace media
163 178
164 #endif // MEDIA_CAST_NET_CAST_TRANSPORT_H_ 179 #endif // MEDIA_CAST_NET_CAST_TRANSPORT_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698