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 base class for an object that send frames to a receiver. | 5 // This is the base class for an object that send frames to a receiver. |
6 // TODO(hclam): Refactor such that there is no separate AudioSender vs. | 6 // TODO(hclam): Refactor such that there is no separate AudioSender vs. |
7 // VideoSender, and the functionality of both is rolled into this class. | 7 // VideoSender, and the functionality of both is rolled into this class. |
8 | 8 |
9 #ifndef MEDIA_CAST_SENDER_FRAME_SENDER_H_ | 9 #ifndef MEDIA_CAST_SENDER_FRAME_SENDER_H_ |
10 #define MEDIA_CAST_SENDER_FRAME_SENDER_H_ | 10 #define MEDIA_CAST_SENDER_FRAME_SENDER_H_ |
11 | 11 |
12 #include "base/basictypes.h" | 12 #include "base/basictypes.h" |
13 #include "base/memory/ref_counted.h" | 13 #include "base/memory/ref_counted.h" |
14 #include "base/memory/weak_ptr.h" | 14 #include "base/memory/weak_ptr.h" |
15 #include "base/time/time.h" | 15 #include "base/time/time.h" |
16 #include "media/cast/cast_environment.h" | 16 #include "media/cast/cast_environment.h" |
17 #include "media/cast/net/rtcp/rtcp.h" | 17 #include "media/cast/net/rtcp/rtcp.h" |
18 #include "media/cast/sender/rtp_timestamp_helper.h" | 18 #include "media/cast/sender/rtp_timestamp_helper.h" |
19 | 19 |
20 namespace media { | 20 namespace media { |
21 namespace cast { | 21 namespace cast { |
22 | 22 |
23 class FrameSender { | 23 class FrameSender { |
24 public: | 24 public: |
25 FrameSender(scoped_refptr<CastEnvironment> cast_environment, | 25 FrameSender(scoped_refptr<CastEnvironment> cast_environment, |
26 CastTransportSender* const transport_sender, | 26 CastTransportSender* const transport_sender, |
27 base::TimeDelta rtcp_interval, | 27 base::TimeDelta rtcp_interval, |
28 int frequency, | 28 int frequency, |
29 uint32 ssrc); | 29 uint32 ssrc, |
| 30 double max_frame_rate, |
| 31 base::TimeDelta playout_delay); |
30 virtual ~FrameSender(); | 32 virtual ~FrameSender(); |
31 | 33 |
| 34 // Calling this function is only valid if the receiver supports the |
| 35 // "extra_playout_delay", rtp extension. |
| 36 void SetTargetPlayoutDelay(base::TimeDelta new_target_playout_delay); |
| 37 |
32 protected: | 38 protected: |
33 // Schedule and execute periodic sending of RTCP report. | 39 // Schedule and execute periodic sending of RTCP report. |
34 void ScheduleNextRtcpReport(); | 40 void ScheduleNextRtcpReport(); |
35 void SendRtcpReport(bool schedule_future_reports); | 41 void SendRtcpReport(bool schedule_future_reports); |
36 | 42 |
37 void OnReceivedRtt(base::TimeDelta rtt, | 43 void OnReceivedRtt(base::TimeDelta rtt, |
38 base::TimeDelta avg_rtt, | 44 base::TimeDelta avg_rtt, |
39 base::TimeDelta min_rtt, | 45 base::TimeDelta min_rtt, |
40 base::TimeDelta max_rtt); | 46 base::TimeDelta max_rtt); |
41 | 47 |
(...skipping 14 matching lines...) Expand all Loading... |
56 // extrapolates this mapping to any other point in time. | 62 // extrapolates this mapping to any other point in time. |
57 RtpTimestampHelper rtp_timestamp_helper_; | 63 RtpTimestampHelper rtp_timestamp_helper_; |
58 | 64 |
59 // RTT information from RTCP. | 65 // RTT information from RTCP. |
60 bool rtt_available_; | 66 bool rtt_available_; |
61 base::TimeDelta rtt_; | 67 base::TimeDelta rtt_; |
62 base::TimeDelta avg_rtt_; | 68 base::TimeDelta avg_rtt_; |
63 base::TimeDelta min_rtt_; | 69 base::TimeDelta min_rtt_; |
64 base::TimeDelta max_rtt_; | 70 base::TimeDelta max_rtt_; |
65 | 71 |
66 private: | 72 protected: |
67 const base::TimeDelta rtcp_interval_; | 73 const base::TimeDelta rtcp_interval_; |
68 | 74 |
| 75 // The total amount of time between a frame's capture/recording on the sender |
| 76 // and its playback on the receiver (i.e., shown to a user). This is fixed as |
| 77 // a value large enough to give the system sufficient time to encode, |
| 78 // transmit/retransmit, receive, decode, and render; given its run-time |
| 79 // environment (sender/receiver hardware performance, network conditions, |
| 80 // etc.). |
| 81 base::TimeDelta target_playout_delay_; |
| 82 |
| 83 // If true, we transmit the target playout delay to the receiver. |
| 84 bool send_target_playout_delay_; |
| 85 |
| 86 // Max encoded frames generated per second. |
| 87 double max_frame_rate_; |
| 88 |
| 89 // Maximum number of outstanding frames before the encoding and sending of |
| 90 // new frames shall halt. |
| 91 int max_unacked_frames_; |
| 92 |
| 93 private: |
69 // NOTE: Weak pointers must be invalidated before all other member variables. | 94 // NOTE: Weak pointers must be invalidated before all other member variables. |
70 base::WeakPtrFactory<FrameSender> weak_factory_; | 95 base::WeakPtrFactory<FrameSender> weak_factory_; |
71 | 96 |
72 DISALLOW_COPY_AND_ASSIGN(FrameSender); | 97 DISALLOW_COPY_AND_ASSIGN(FrameSender); |
73 }; | 98 }; |
74 | 99 |
75 } // namespace cast | 100 } // namespace cast |
76 } // namespace media | 101 } // namespace media |
77 | 102 |
78 #endif // MEDIA_CAST_SENDER_FRAME_SENDER_H_ | 103 #endif // MEDIA_CAST_SENDER_FRAME_SENDER_H_ |
OLD | NEW |