| 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 #ifndef MEDIA_CAST_TRANSPORT_CAST_TRANSPORT_CONFIG_H_ | 5 #ifndef MEDIA_CAST_TRANSPORT_CAST_TRANSPORT_CONFIG_H_ |
| 6 #define MEDIA_CAST_TRANSPORT_CAST_TRANSPORT_CONFIG_H_ | 6 #define MEDIA_CAST_TRANSPORT_CAST_TRANSPORT_CONFIG_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| 11 #include "base/basictypes.h" | 11 #include "base/basictypes.h" |
| 12 #include "base/callback.h" | 12 #include "base/callback.h" |
| 13 #include "base/memory/linked_ptr.h" | 13 #include "base/memory/linked_ptr.h" |
| 14 #include "base/memory/ref_counted.h" | 14 #include "base/memory/ref_counted.h" |
| 15 #include "base/stl_util.h" |
| 15 #include "media/cast/transport/cast_transport_defines.h" | 16 #include "media/cast/transport/cast_transport_defines.h" |
| 16 #include "net/base/ip_endpoint.h" | 17 #include "net/base/ip_endpoint.h" |
| 17 | 18 |
| 18 namespace media { | 19 namespace media { |
| 19 namespace cast { | 20 namespace cast { |
| 20 namespace transport { | 21 namespace transport { |
| 21 | 22 |
| 22 enum RtcpMode { | 23 enum RtcpMode { |
| 23 kRtcpCompound, // Compound RTCP mode is described by RFC 4585. | 24 kRtcpCompound, // Compound RTCP mode is described by RFC 4585. |
| 24 kRtcpReducedSize, // Reduced-size RTCP mode is described by RFC 5506. | 25 kRtcpReducedSize, // Reduced-size RTCP mode is described by RFC 5506. |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 62 }; | 63 }; |
| 63 | 64 |
| 64 struct CastTransportVideoConfig { | 65 struct CastTransportVideoConfig { |
| 65 CastTransportVideoConfig(); | 66 CastTransportVideoConfig(); |
| 66 ~CastTransportVideoConfig(); | 67 ~CastTransportVideoConfig(); |
| 67 | 68 |
| 68 CastTransportRtpConfig rtp; | 69 CastTransportRtpConfig rtp; |
| 69 VideoCodec codec; | 70 VideoCodec codec; |
| 70 }; | 71 }; |
| 71 | 72 |
| 72 struct EncodedVideoFrame { | 73 // A combination of metadata and data for one encoded frame. This can contain |
| 73 EncodedVideoFrame(); | 74 // audio data or video data or other. |
| 74 ~EncodedVideoFrame(); | 75 struct EncodedFrame { |
| 76 enum Dependency { |
| 77 // "null" value, used to indicate whether |dependency| has been set. |
| 78 UNKNOWN_DEPENDENCY, |
| 75 | 79 |
| 76 VideoCodec codec; | 80 // Not decodable without the reference frame indicated by |
| 77 bool key_frame; | 81 // |referenced_frame_id|. |
| 82 DEPENDENT, |
| 83 |
| 84 // Independently decodable. |
| 85 INDEPENDENT, |
| 86 |
| 87 // Independently decodable, and no future frames will depend on any frames |
| 88 // before this one. |
| 89 KEY, |
| 90 |
| 91 DEPENDENCY_LAST = KEY |
| 92 }; |
| 93 |
| 94 EncodedFrame(); |
| 95 ~EncodedFrame(); |
| 96 |
| 97 // Convenience accessors to data as an array of uint8 elements. |
| 98 const uint8* bytes() const { |
| 99 return reinterpret_cast<uint8*>(string_as_array( |
| 100 const_cast<std::string*>(&data))); |
| 101 } |
| 102 uint8* mutable_bytes() { |
| 103 return reinterpret_cast<uint8*>(string_as_array(&data)); |
| 104 } |
| 105 |
| 106 // This frame's dependency relationship with respect to other frames. |
| 107 Dependency dependency; |
| 108 |
| 109 // The label associated with this frame. Implies an ordering relative to |
| 110 // other frames in the same stream. |
| 78 uint32 frame_id; | 111 uint32 frame_id; |
| 79 uint32 last_referenced_frame_id; | 112 |
| 113 // The label associated with the frame upon which this frame depends. If |
| 114 // this frame does not require any other frame in order to become decodable |
| 115 // (e.g., key frames), |referenced_frame_id| must equal |frame_id|. |
| 116 uint32 referenced_frame_id; |
| 117 |
| 118 // The stream timestamp, on the timeline of the signal data. For example, RTP |
| 119 // timestamps for audio are usually defined as the total number of audio |
| 120 // samples encoded in all prior frames. A playback system uses this value to |
| 121 // detect gaps in the stream, and otherwise stretch the signal to match |
| 122 // playout targets. |
| 80 uint32 rtp_timestamp; | 123 uint32 rtp_timestamp; |
| 124 |
| 125 // The common reference clock timestamp for this frame. This value originates |
| 126 // from a sender and is used to provide lip synchronization between streams in |
| 127 // a receiver. Thus, in the sender context, this is set to the time at which |
| 128 // the frame was captured/recorded. In the receiver context, this is set to |
| 129 // the target playout time. Over a sequence of frames, this time value is |
| 130 // expected to drift with respect to the elapsed time implied by the RTP |
| 131 // timestamps; and it may not necessarily increment with precise regularity. |
| 132 base::TimeTicks reference_time; |
| 133 |
| 134 // The encoded signal data. |
| 81 std::string data; | 135 std::string data; |
| 82 }; | 136 }; |
| 83 | 137 |
| 84 struct EncodedAudioFrame { | |
| 85 EncodedAudioFrame(); | |
| 86 ~EncodedAudioFrame(); | |
| 87 | |
| 88 AudioCodec codec; | |
| 89 uint32 frame_id; // Needed to release the frame. | |
| 90 uint32 rtp_timestamp; | |
| 91 // Support for max sampling rate of 48KHz, 2 channels, 100 ms duration. | |
| 92 static const int kMaxNumberOfSamples = 48 * 2 * 100; | |
| 93 std::string data; | |
| 94 }; | |
| 95 | |
| 96 typedef std::vector<uint8> Packet; | 138 typedef std::vector<uint8> Packet; |
| 97 typedef scoped_refptr<base::RefCountedData<Packet> > PacketRef; | 139 typedef scoped_refptr<base::RefCountedData<Packet> > PacketRef; |
| 98 typedef std::vector<PacketRef> PacketList; | 140 typedef std::vector<PacketRef> PacketList; |
| 99 | 141 |
| 100 typedef base::Callback<void(scoped_ptr<Packet> packet)> PacketReceiverCallback; | 142 typedef base::Callback<void(scoped_ptr<Packet> packet)> PacketReceiverCallback; |
| 101 | 143 |
| 102 class PacketSender { | 144 class PacketSender { |
| 103 public: | 145 public: |
| 104 // Send a packet to the network. Returns false if the network is blocked | 146 // Send a packet to the network. Returns false if the network is blocked |
| 105 // and we should wait for |cb| to be called. It is not allowed to called | 147 // and we should wait for |cb| to be called. It is not allowed to called |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 161 lhs.rtp_timestamp == rhs.rtp_timestamp && | 203 lhs.rtp_timestamp == rhs.rtp_timestamp && |
| 162 lhs.send_packet_count == rhs.send_packet_count && | 204 lhs.send_packet_count == rhs.send_packet_count && |
| 163 lhs.send_octet_count == rhs.send_octet_count; | 205 lhs.send_octet_count == rhs.send_octet_count; |
| 164 } | 206 } |
| 165 | 207 |
| 166 } // namespace transport | 208 } // namespace transport |
| 167 } // namespace cast | 209 } // namespace cast |
| 168 } // namespace media | 210 } // namespace media |
| 169 | 211 |
| 170 #endif // MEDIA_CAST_TRANSPORT_CAST_TRANSPORT_CONFIG_H_ | 212 #endif // MEDIA_CAST_TRANSPORT_CAST_TRANSPORT_CONFIG_H_ |
| OLD | NEW |