| 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 #ifndef MEDIA_CAST_TRANSPORT_CAST_TRANSPORT_CONFIG_H_ | |
| 6 #define MEDIA_CAST_TRANSPORT_CAST_TRANSPORT_CONFIG_H_ | |
| 7 | |
| 8 #include <string> | |
| 9 #include <vector> | |
| 10 | |
| 11 #include "base/basictypes.h" | |
| 12 #include "base/callback.h" | |
| 13 #include "base/memory/linked_ptr.h" | |
| 14 #include "base/memory/ref_counted.h" | |
| 15 #include "base/stl_util.h" | |
| 16 #include "media/cast/transport/cast_transport_defines.h" | |
| 17 #include "net/base/ip_endpoint.h" | |
| 18 | |
| 19 namespace media { | |
| 20 namespace cast { | |
| 21 namespace transport { | |
| 22 | |
| 23 enum RtcpMode { | |
| 24 kRtcpCompound, // Compound RTCP mode is described by RFC 4585. | |
| 25 kRtcpReducedSize, // Reduced-size RTCP mode is described by RFC 5506. | |
| 26 }; | |
| 27 | |
| 28 enum Codec { | |
| 29 CODEC_UNKNOWN, | |
| 30 CODEC_AUDIO_OPUS, | |
| 31 CODEC_AUDIO_PCM16, | |
| 32 CODEC_VIDEO_FAKE, | |
| 33 CODEC_VIDEO_VP8, | |
| 34 CODEC_VIDEO_H264, | |
| 35 CODEC_LAST = CODEC_VIDEO_H264 | |
| 36 }; | |
| 37 | |
| 38 struct CastTransportRtpConfig { | |
| 39 CastTransportRtpConfig(); | |
| 40 ~CastTransportRtpConfig(); | |
| 41 | |
| 42 // Identifier refering to this sender. | |
| 43 uint32 ssrc; | |
| 44 | |
| 45 // RTP payload type enum: Specifies the type/encoding of frame data. | |
| 46 int rtp_payload_type; | |
| 47 | |
| 48 // The number of most-recent frames that must be stored in the transport | |
| 49 // layer, to facilitate re-transmissions. | |
| 50 int stored_frames; | |
| 51 | |
| 52 // The AES crypto key and initialization vector. Each of these strings | |
| 53 // contains the data in binary form, of size kAesKeySize. If they are empty | |
| 54 // strings, crypto is not being used. | |
| 55 std::string aes_key; | |
| 56 std::string aes_iv_mask; | |
| 57 }; | |
| 58 | |
| 59 // A combination of metadata and data for one encoded frame. This can contain | |
| 60 // audio data or video data or other. | |
| 61 struct EncodedFrame { | |
| 62 enum Dependency { | |
| 63 // "null" value, used to indicate whether |dependency| has been set. | |
| 64 UNKNOWN_DEPENDENCY, | |
| 65 | |
| 66 // Not decodable without the reference frame indicated by | |
| 67 // |referenced_frame_id|. | |
| 68 DEPENDENT, | |
| 69 | |
| 70 // Independently decodable. | |
| 71 INDEPENDENT, | |
| 72 | |
| 73 // Independently decodable, and no future frames will depend on any frames | |
| 74 // before this one. | |
| 75 KEY, | |
| 76 | |
| 77 DEPENDENCY_LAST = KEY | |
| 78 }; | |
| 79 | |
| 80 EncodedFrame(); | |
| 81 ~EncodedFrame(); | |
| 82 | |
| 83 // Convenience accessors to data as an array of uint8 elements. | |
| 84 const uint8* bytes() const { | |
| 85 return reinterpret_cast<uint8*>(string_as_array( | |
| 86 const_cast<std::string*>(&data))); | |
| 87 } | |
| 88 uint8* mutable_bytes() { | |
| 89 return reinterpret_cast<uint8*>(string_as_array(&data)); | |
| 90 } | |
| 91 | |
| 92 // Copies all data members except |data| to |dest|. | |
| 93 // Does not modify |dest->data|. | |
| 94 void CopyMetadataTo(EncodedFrame* dest) const; | |
| 95 | |
| 96 // This frame's dependency relationship with respect to other frames. | |
| 97 Dependency dependency; | |
| 98 | |
| 99 // The label associated with this frame. Implies an ordering relative to | |
| 100 // other frames in the same stream. | |
| 101 uint32 frame_id; | |
| 102 | |
| 103 // The label associated with the frame upon which this frame depends. If | |
| 104 // this frame does not require any other frame in order to become decodable | |
| 105 // (e.g., key frames), |referenced_frame_id| must equal |frame_id|. | |
| 106 uint32 referenced_frame_id; | |
| 107 | |
| 108 // The stream timestamp, on the timeline of the signal data. For example, RTP | |
| 109 // timestamps for audio are usually defined as the total number of audio | |
| 110 // samples encoded in all prior frames. A playback system uses this value to | |
| 111 // detect gaps in the stream, and otherwise stretch the signal to match | |
| 112 // playout targets. | |
| 113 uint32 rtp_timestamp; | |
| 114 | |
| 115 // The common reference clock timestamp for this frame. This value originates | |
| 116 // from a sender and is used to provide lip synchronization between streams in | |
| 117 // a receiver. Thus, in the sender context, this is set to the time at which | |
| 118 // the frame was captured/recorded. In the receiver context, this is set to | |
| 119 // the target playout time. Over a sequence of frames, this time value is | |
| 120 // expected to drift with respect to the elapsed time implied by the RTP | |
| 121 // timestamps; and it may not necessarily increment with precise regularity. | |
| 122 base::TimeTicks reference_time; | |
| 123 | |
| 124 // The encoded signal data. | |
| 125 std::string data; | |
| 126 }; | |
| 127 | |
| 128 typedef std::vector<uint8> Packet; | |
| 129 typedef scoped_refptr<base::RefCountedData<Packet> > PacketRef; | |
| 130 typedef std::vector<PacketRef> PacketList; | |
| 131 | |
| 132 typedef base::Callback<void(scoped_ptr<Packet> packet)> PacketReceiverCallback; | |
| 133 | |
| 134 class PacketSender { | |
| 135 public: | |
| 136 // Send a packet to the network. Returns false if the network is blocked | |
| 137 // and we should wait for |cb| to be called. It is not allowed to called | |
| 138 // SendPacket again until |cb| has been called. Any other errors that | |
| 139 // occur will be reported through side channels, in such cases, this function | |
| 140 // will return true indicating that the channel is not blocked. | |
| 141 virtual bool SendPacket(PacketRef packet, const base::Closure& cb) = 0; | |
| 142 virtual ~PacketSender() {} | |
| 143 }; | |
| 144 | |
| 145 struct RtcpSenderInfo { | |
| 146 RtcpSenderInfo(); | |
| 147 ~RtcpSenderInfo(); | |
| 148 // First three members are used for lipsync. | |
| 149 // First two members are used for rtt. | |
| 150 uint32 ntp_seconds; | |
| 151 uint32 ntp_fraction; | |
| 152 uint32 rtp_timestamp; | |
| 153 uint32 send_packet_count; | |
| 154 size_t send_octet_count; | |
| 155 }; | |
| 156 | |
| 157 struct RtcpReportBlock { | |
| 158 RtcpReportBlock(); | |
| 159 ~RtcpReportBlock(); | |
| 160 uint32 remote_ssrc; // SSRC of sender of this report. | |
| 161 uint32 media_ssrc; // SSRC of the RTP packet sender. | |
| 162 uint8 fraction_lost; | |
| 163 uint32 cumulative_lost; // 24 bits valid. | |
| 164 uint32 extended_high_sequence_number; | |
| 165 uint32 jitter; | |
| 166 uint32 last_sr; | |
| 167 uint32 delay_since_last_sr; | |
| 168 }; | |
| 169 | |
| 170 struct RtcpDlrrReportBlock { | |
| 171 RtcpDlrrReportBlock(); | |
| 172 ~RtcpDlrrReportBlock(); | |
| 173 uint32 last_rr; | |
| 174 uint32 delay_since_last_rr; | |
| 175 }; | |
| 176 | |
| 177 // This is only needed because IPC messages don't support more than | |
| 178 // 5 arguments. | |
| 179 struct SendRtcpFromRtpSenderData { | |
| 180 SendRtcpFromRtpSenderData(); | |
| 181 ~SendRtcpFromRtpSenderData(); | |
| 182 uint32 packet_type_flags; | |
| 183 uint32 sending_ssrc; | |
| 184 std::string c_name; | |
| 185 uint32 ntp_seconds; | |
| 186 uint32 ntp_fraction; | |
| 187 uint32 rtp_timestamp; | |
| 188 }; | |
| 189 | |
| 190 inline bool operator==(RtcpSenderInfo lhs, RtcpSenderInfo rhs) { | |
| 191 return lhs.ntp_seconds == rhs.ntp_seconds && | |
| 192 lhs.ntp_fraction == rhs.ntp_fraction && | |
| 193 lhs.rtp_timestamp == rhs.rtp_timestamp && | |
| 194 lhs.send_packet_count == rhs.send_packet_count && | |
| 195 lhs.send_octet_count == rhs.send_octet_count; | |
| 196 } | |
| 197 | |
| 198 } // namespace transport | |
| 199 } // namespace cast | |
| 200 } // namespace media | |
| 201 | |
| 202 #endif // MEDIA_CAST_TRANSPORT_CAST_TRANSPORT_CONFIG_H_ | |
| OLD | NEW |