OLD | NEW |
(Empty) | |
| 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 // 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. |
| 7 // VideoSender, and the functionality of both is rolled into this class. |
| 8 |
| 9 #ifndef MEDIA_CAST_SENDER_FRAME_SENDER_H_ |
| 10 #define MEDIA_CAST_SENDER_FRAME_SENDER_H_ |
| 11 |
| 12 #include "base/basictypes.h" |
| 13 #include "base/memory/ref_counted.h" |
| 14 #include "base/memory/weak_ptr.h" |
| 15 #include "base/time/time.h" |
| 16 #include "media/cast/cast_environment.h" |
| 17 #include "media/cast/net/rtcp/rtcp.h" |
| 18 #include "media/cast/sender/rtp_timestamp_helper.h" |
| 19 |
| 20 namespace media { |
| 21 namespace cast { |
| 22 |
| 23 class FrameSender { |
| 24 public: |
| 25 FrameSender(scoped_refptr<CastEnvironment> cast_environment, |
| 26 CastTransportSender* const transport_sender, |
| 27 base::TimeDelta rtcp_interval, |
| 28 int frequency, |
| 29 uint32 ssrc); |
| 30 virtual ~FrameSender(); |
| 31 |
| 32 protected: |
| 33 // Schedule and execute periodic sending of RTCP report. |
| 34 void ScheduleNextRtcpReport(); |
| 35 void SendRtcpReport(bool schedule_future_reports); |
| 36 |
| 37 void OnReceivedRtt(base::TimeDelta rtt, |
| 38 base::TimeDelta avg_rtt, |
| 39 base::TimeDelta min_rtt, |
| 40 base::TimeDelta max_rtt); |
| 41 |
| 42 bool is_rtt_available() const { return rtt_available_; } |
| 43 |
| 44 const scoped_refptr<CastEnvironment> cast_environment_; |
| 45 |
| 46 // Sends encoded frames over the configured transport (e.g., UDP). In |
| 47 // Chromium, this could be a proxy that first sends the frames from a renderer |
| 48 // process to the browser process over IPC, with the browser process being |
| 49 // responsible for "packetizing" the frames and pushing packets into the |
| 50 // network layer. |
| 51 CastTransportSender* const transport_sender_; |
| 52 |
| 53 // Records lip-sync (i.e., mapping of RTP <--> NTP timestamps), and |
| 54 // extrapolates this mapping to any other point in time. |
| 55 RtpTimestampHelper rtp_timestamp_helper_; |
| 56 |
| 57 // RTT information from RTCP. |
| 58 bool rtt_available_; |
| 59 base::TimeDelta rtt_; |
| 60 base::TimeDelta avg_rtt_; |
| 61 base::TimeDelta min_rtt_; |
| 62 base::TimeDelta max_rtt_; |
| 63 |
| 64 private: |
| 65 const base::TimeDelta rtcp_interval_; |
| 66 const uint32 ssrc_; |
| 67 |
| 68 // NOTE: Weak pointers must be invalidated before all other member variables. |
| 69 base::WeakPtrFactory<FrameSender> weak_factory_; |
| 70 |
| 71 DISALLOW_COPY_AND_ASSIGN(FrameSender); |
| 72 }; |
| 73 |
| 74 } // namespace cast |
| 75 } // namespace media |
| 76 |
| 77 #endif // MEDIA_CAST_SENDER_FRAME_SENDER_H_ |
OLD | NEW |