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 EncodedFrame(); | |
77 ~EncodedFrame(); | |
75 | 78 |
76 VideoCodec codec; | 79 // Convenience accessors to data as an array of uint8 elements. |
77 bool key_frame; | 80 const uint8* bytes() const { |
81 return reinterpret_cast<uint8*>(string_as_array( | |
82 const_cast<std::string*>(&data))); | |
83 } | |
84 uint8* mutable_bytes() { | |
85 return reinterpret_cast<uint8*>(string_as_array(&data)); | |
86 } | |
87 | |
88 // The label associated with this frame. Implies an ordering relative to | |
89 // other frames in the same stream. | |
78 uint32 frame_id; | 90 uint32 frame_id; |
79 uint32 last_referenced_frame_id; | 91 |
92 // The label associated with the frame upon which this frame is based. If | |
93 // this frame does not require any other frame in order to become decodable | |
94 // (e.g., key frames), |base_frame_id| must equal |frame_id|. | |
95 uint32 base_frame_id; | |
Alpha Left Google
2014/05/15 22:11:23
I actually prefer the name before, i.e. referenced
miu
2014/05/16 04:27:25
Done. After looking around more in the codec APIs
| |
96 | |
97 // The stream timestamp, on the timeline of the signal data. For example, RTP | |
98 // timestamps for audio are usually defined as the total number of audio | |
99 // samples encoded in all prior frames. A playback system uses this value to | |
100 // detect gaps in the stream, and otherwise stretch the signal to match | |
101 // playout targets. | |
80 uint32 rtp_timestamp; | 102 uint32 rtp_timestamp; |
103 | |
104 // Reference time used for synchronization between streams. In the sender | |
Alpha Left Google
2014/05/15 22:11:23
In the sender the time is not used for synchroniza
miu
2014/05/16 04:27:25
I've clarified the comment (that the sender genera
| |
105 // implementation, this is the frame capture time. In the receiver | |
106 // implementation, this is the target playout time. Over a sequence of | |
107 // frames, this time value is expected to drift with respect to the elapsed | |
108 // time implied by the RTP timestamps; and it may not necessarily increment | |
109 // with precise regularity. | |
110 base::TimeTicks reference_time; | |
Alpha Left Google
2014/05/15 22:11:23
Calling it reference_time doesn't seem to fit eith
miu
2014/05/16 04:27:25
This is exactly the terminology used in Chapter 7
| |
111 | |
112 // The encoded signal data. | |
81 std::string data; | 113 std::string data; |
82 }; | 114 }; |
83 | 115 |
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; | 116 typedef std::vector<uint8> Packet; |
97 typedef scoped_refptr<base::RefCountedData<Packet> > PacketRef; | 117 typedef scoped_refptr<base::RefCountedData<Packet> > PacketRef; |
98 typedef std::vector<PacketRef> PacketList; | 118 typedef std::vector<PacketRef> PacketList; |
99 | 119 |
100 typedef base::Callback<void(scoped_ptr<Packet> packet)> PacketReceiverCallback; | 120 typedef base::Callback<void(scoped_ptr<Packet> packet)> PacketReceiverCallback; |
101 | 121 |
102 class PacketSender { | 122 class PacketSender { |
103 public: | 123 public: |
104 // Send a packet to the network. Returns false if the network is blocked | 124 // 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 | 125 // and we should wait for |cb| to be called. It is not allowed to called |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
158 lhs.rtp_timestamp == rhs.rtp_timestamp && | 178 lhs.rtp_timestamp == rhs.rtp_timestamp && |
159 lhs.send_packet_count == rhs.send_packet_count && | 179 lhs.send_packet_count == rhs.send_packet_count && |
160 lhs.send_octet_count == rhs.send_octet_count; | 180 lhs.send_octet_count == rhs.send_octet_count; |
161 } | 181 } |
162 | 182 |
163 } // namespace transport | 183 } // namespace transport |
164 } // namespace cast | 184 } // namespace cast |
165 } // namespace media | 185 } // namespace media |
166 | 186 |
167 #endif // MEDIA_CAST_TRANSPORT_CAST_TRANSPORT_CONFIG_H_ | 187 #endif // MEDIA_CAST_TRANSPORT_CAST_TRANSPORT_CONFIG_H_ |
OLD | NEW |