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.
5 #ifndef MEDIA_CAST_TRANSPORT_CAST_TRANSPORT_CONFIG_H_
6 #define MEDIA_CAST_TRANSPORT_CAST_TRANSPORT_CONFIG_H_
11 #include "base/basictypes.h"
12 #include "base/callback.h"
13 #include "base/memory/ref_counted.h"
14 #include "media/cast/transport/cast_transport_defines.h"
15 #include "net/base/ip_endpoint.h"
22 kRtcpCompound, // Compound RTCP mode is described by RFC 4585.
23 kRtcpReducedSize, // Reduced-size RTCP mode is described by RFC 5506.
26 enum VideoCodec { kVp8, kH264, };
28 enum AudioCodec { kOpus, kPcm16, kExternalAudio, };
32 int history_ms; // The time RTP packets are stored for retransmissions.
37 struct CastTransportConfig {
38 CastTransportConfig();
39 ~CastTransportConfig();
41 // Transport: Local receiver.
42 net::IPEndPoint receiver_endpoint;
43 net::IPEndPoint local_endpoint;
48 VideoCodec video_codec;
49 AudioCodec audio_codec;
52 RtpConfig audio_rtp_config;
53 RtpConfig video_rtp_config;
58 std::string aes_key; // Binary string of size kAesKeySize.
59 std::string aes_iv_mask; // Binary string of size kAesBlockSize.
62 struct EncodedVideoFrame {
69 uint32 last_referenced_frame_id;
74 struct EncodedAudioFrame {
79 uint32 frame_id; // Needed to release the frame.
81 // Support for max sampling rate of 48KHz, 2 channels, 100 ms duration.
82 static const int kMaxNumberOfSamples = 48 * 2 * 100;
86 typedef std::vector<uint8> Packet;
87 typedef std::vector<Packet> PacketList;
89 typedef base::Callback<void(scoped_ptr<Packet> packet)> PacketReceiverCallback;
93 // All packets to be sent to the network will be delivered via these
95 virtual bool SendPacket(const transport::Packet& packet) = 0;
97 virtual ~PacketSender() {}
100 // Log messages form sender to receiver.
101 // TODO(mikhal): Refactor to Chromium style (MACRO_STYLE).
102 enum RtcpSenderFrameStatus {
103 kRtcpSenderFrameStatusUnknown = 0,
104 kRtcpSenderFrameStatusDroppedByEncoder = 1,
105 kRtcpSenderFrameStatusDroppedByFlowControl = 2,
106 kRtcpSenderFrameStatusSentToNetwork = 3,
109 struct RtcpSenderFrameLogMessage {
110 RtcpSenderFrameLogMessage();
111 ~RtcpSenderFrameLogMessage();
112 RtcpSenderFrameStatus frame_status;
113 uint32 rtp_timestamp;
116 typedef std::vector<RtcpSenderFrameLogMessage> RtcpSenderLogMessage;
118 struct RtcpSenderInfo {
121 // First three members are used for lipsync.
122 // First two members are used for rtt.
125 uint32 rtp_timestamp;
126 uint32 send_packet_count;
127 size_t send_octet_count;
130 struct RtcpReportBlock {
133 uint32 remote_ssrc; // SSRC of sender of this report.
134 uint32 media_ssrc; // SSRC of the RTP packet sender.
136 uint32 cumulative_lost; // 24 bits valid.
137 uint32 extended_high_sequence_number;
140 uint32 delay_since_last_sr;
143 struct RtcpDlrrReportBlock {
144 RtcpDlrrReportBlock();
145 ~RtcpDlrrReportBlock();
147 uint32 delay_since_last_rr;
150 // This is only needed because IPC messages don't support more than
152 struct SendRtcpFromRtpSenderData {
153 SendRtcpFromRtpSenderData();
154 ~SendRtcpFromRtpSenderData();
155 uint32 packet_type_flags;
160 inline bool operator==(RtcpSenderInfo lhs, RtcpSenderInfo rhs) {
161 return lhs.ntp_seconds == rhs.ntp_seconds &&
162 lhs.ntp_fraction == rhs.ntp_fraction &&
163 lhs.rtp_timestamp == rhs.rtp_timestamp &&
164 lhs.send_packet_count == rhs.send_packet_count &&
165 lhs.send_octet_count == rhs.send_octet_count;
168 } // namespace transport
172 #endif // MEDIA_CAST_TRANSPORT_CAST_TRANSPORT_CONFIG_H_