summaryrefslogtreecommitdiffstats
path: root/media/cast/net/cast_transport_sender_impl.h
diff options
context:
space:
mode:
authorhclam@chromium.org <hclam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-07-20 07:13:24 +0000
committerhclam@chromium.org <hclam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-07-20 07:13:24 +0000
commitabd5fb257d7dbf92f99b75e3cefad7c58ca485bb (patch)
treeb01cb29d240492a83c2e87453308bcf031cba47f /media/cast/net/cast_transport_sender_impl.h
parentc5b1db7f8e90e0d118bac3b01484c69f1c4ef5e9 (diff)
downloadchromium_src-abd5fb257d7dbf92f99b75e3cefad7c58ca485bb.zip
chromium_src-abd5fb257d7dbf92f99b75e3cefad7c58ca485bb.tar.gz
chromium_src-abd5fb257d7dbf92f99b75e3cefad7c58ca485bb.tar.bz2
Cast: Refactor RTCP handling
OBJECTIVES This change is to refactor RTCP handling in media/cast such that RTCP message parsing is done in CastTransportSender. This side effect of this refactoring is much cleaner code: RTCP handling code are grouped under one module. VideoSender and AudioSender do not handle packets directly. This also affect the architectutre in Chrome that RTCP message parsing is now done in the browser process. A parsed RTCP message is passed to the renderer instead of raw packets. REATIONALE RTCP is used as a feedback mechanism in Cast Streaming. It used to be parsed and handled by VideoSender and AudioSender in the render process. This was very ineffective because packetization and sending is done in the browser process. This created inefficiencies in packet retransmission. It also made improvement to the transport protocol / algorithm much more difficult. A side effect is very messy code. DETAILS Rtcp - This class is responsibile for maintaining a bi-directional RTCP session. It is now owned by CastTransportSender. CastTransportSender - It now performs packetization and also parsing of incoming RTCP packets. RTCP packets are small UDP packets for signaling only. Eventually retransmission can also be moved to this class. It will handle all packet level send transport. AudioSender / VideoSender - They don't handle packet directly any more. Which means render process doesn't see raw packets. FrameSender - Base class for AudioSender and VideoSender to share code for RTCP message handling. Eventually AudioSender and VideoSender will merge here but it is not the point of this change. RtcpBuilder - Removed and merged with RtcpSender. Net deleted 400 lines of code and simulation shows the same results. BUG=393042 Review URL: https://codereview.chromium.org/387933005 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@284363 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'media/cast/net/cast_transport_sender_impl.h')
-rw-r--r--media/cast/net/cast_transport_sender_impl.h79
1 files changed, 58 insertions, 21 deletions
diff --git a/media/cast/net/cast_transport_sender_impl.h b/media/cast/net/cast_transport_sender_impl.h
index 5d34fde..9cc3b46 100644
--- a/media/cast/net/cast_transport_sender_impl.h
+++ b/media/cast/net/cast_transport_sender_impl.h
@@ -2,12 +2,32 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+// This class maintains a send transport for audio and video in a Cast
+// Streaming session.
+// Audio, video frames and RTCP messages are submitted to this object
+// and then packetized and paced to the underlying UDP socket.
+//
+// The hierarchy of send transport in a Cast Streaming session:
+//
+// CastTransportSender RTP RTCP
+// ------------------------------------------------------------------
+// TransportEncryptionHandler (A/V)
+// RtpSender (A/V) Rtcp (A/V)
+// PacedSender (Shared)
+// UdpTransport (Shared)
+//
+// There are objects of TransportEncryptionHandler, RtpSender and Rtcp
+// for each audio and video stream.
+// PacedSender and UdpTransport are shared between all RTP and RTCP
+// streams.
+
#ifndef MEDIA_CAST_NET_CAST_TRANSPORT_IMPL_H_
#define MEDIA_CAST_NET_CAST_TRANSPORT_IMPL_H_
#include "base/callback.h"
#include "base/memory/ref_counted.h"
#include "base/memory/scoped_ptr.h"
+#include "base/memory/weak_ptr.h"
#include "base/time/tick_clock.h"
#include "base/time/time.h"
#include "base/timer/timer.h"
@@ -17,7 +37,7 @@
#include "media/cast/net/cast_transport_config.h"
#include "media/cast/net/cast_transport_sender.h"
#include "media/cast/net/pacing/paced_sender.h"
-#include "media/cast/net/rtcp/rtcp_builder.h"
+#include "media/cast/net/rtcp/rtcp.h"
#include "media/cast/net/rtp/rtp_sender.h"
namespace media {
@@ -27,9 +47,7 @@ class UdpTransport;
class CastTransportSenderImpl : public CastTransportSender {
public:
- // external_transport is only used for testing.
- // Note that SetPacketReceiver does not work if an external
- // transport is provided.
+ // |external_transport| is only used for testing.
// |raw_events_callback|: Raw events will be returned on this callback
// which will be invoked every |raw_events_callback_interval|.
// This can be a null callback, i.e. if user is not interested in raw events.
@@ -47,23 +65,19 @@ class CastTransportSenderImpl : public CastTransportSender {
virtual ~CastTransportSenderImpl();
- virtual void InitializeAudio(const CastTransportRtpConfig& config) OVERRIDE;
- virtual void InitializeVideo(const CastTransportRtpConfig& config) OVERRIDE;
-
- // CastTransportSender implementation.
- virtual void SetPacketReceiver(const PacketReceiverCallback& packet_receiver)
- OVERRIDE;
-
+ virtual void InitializeAudio(const CastTransportRtpConfig& config,
+ const RtcpCastMessageCallback& cast_message_cb,
+ const RtcpRttCallback& rtt_cb) OVERRIDE;
+ virtual void InitializeVideo(const CastTransportRtpConfig& config,
+ const RtcpCastMessageCallback& cast_message_cb,
+ const RtcpRttCallback& rtt_cb) OVERRIDE;
virtual void InsertCodedAudioFrame(const EncodedFrame& audio_frame) OVERRIDE;
virtual void InsertCodedVideoFrame(const EncodedFrame& video_frame) OVERRIDE;
- virtual void SendRtcpFromRtpSender(uint32 packet_type_flags,
- uint32 ntp_seconds,
- uint32 ntp_fraction,
- uint32 rtp_timestamp,
- const RtcpDlrrReportBlock& dlrr,
- uint32 sending_ssrc,
- const std::string& c_name) OVERRIDE;
+ virtual void SendSenderReport(
+ uint32 ssrc,
+ base::TimeTicks current_time,
+ uint32 current_time_as_rtp_timestamp) OVERRIDE;
virtual void ResendPackets(bool is_audio,
const MissingFramesAndPacketsMap& missing_packets,
@@ -71,22 +85,43 @@ class CastTransportSenderImpl : public CastTransportSender {
base::TimeDelta dedupe_window)
OVERRIDE;
+ virtual PacketReceiverCallback PacketReceiverForTesting() OVERRIDE;
+
private:
// If |raw_events_callback_| is non-null, calls it with events collected
// by |event_subscriber_| since last call.
void SendRawEvents();
+ // Start receiving packets.
+ void StartReceiving();
+
+ // Called when a packet is received.
+ void OnReceivedPacket(scoped_ptr<Packet> packet);
+
+ // Called when a log message is received.
+ void OnReceivedLogMessage(EventMediaType media_type,
+ const RtcpReceiverLogMessage& log);
+
base::TickClock* clock_; // Not owned by this class.
CastTransportStatusCallback status_callback_;
scoped_refptr<base::SingleThreadTaskRunner> transport_task_runner_;
- scoped_ptr<UdpTransport> transport_;
LoggingImpl logging_;
+
+ // Interface to a UDP socket.
+ scoped_ptr<UdpTransport> transport_;
+
+ // Packet sender that performs pacing.
PacedSender pacer_;
- RtcpBuilder rtcp_builder_;
+
+ // Packetizer for audio and video frames.
scoped_ptr<RtpSender> audio_sender_;
scoped_ptr<RtpSender> video_sender_;
+ // Maintains RTCP session for audio and video.
+ scoped_ptr<Rtcp> audio_rtcp_session_;
+ scoped_ptr<Rtcp> video_rtcp_session_;
+
// Encrypts data in EncodedFrames before they are sent. Note that it's
// important for the encryption to happen here, in code that would execute in
// the main browser process, for security reasons. This helps to mitigate
@@ -96,9 +131,11 @@ class CastTransportSenderImpl : public CastTransportSender {
// This is non-null iff |raw_events_callback_| is non-null.
scoped_ptr<SimpleEventSubscriber> event_subscriber_;
- base::RepeatingTimer<CastTransportSenderImpl> raw_events_timer_;
BulkRawEventsCallback raw_events_callback_;
+ base::TimeDelta raw_events_callback_interval_;
+
+ base::WeakPtrFactory<CastTransportSenderImpl> weak_factory_;
DISALLOW_COPY_AND_ASSIGN(CastTransportSenderImpl);
};