Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(24)

Side by Side Diff: media/cast/cast_config.h

Issue 109413004: Cast:Adding cast_transport_config and cleaning up (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Injecting TaskRunner Created 6 years, 12 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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_CAST_CONFIG_H_ 5 #ifndef MEDIA_CAST_CAST_CONFIG_H_
6 #define MEDIA_CAST_CAST_CONFIG_H_ 6 #define MEDIA_CAST_CAST_CONFIG_H_
7 7
8 #include <list> 8 #include <list>
9 #include <string> 9 #include <string>
10 #include <vector> 10 #include <vector>
11 11
12 #include "base/basictypes.h" 12 #include "base/basictypes.h"
13 #include "base/callback.h" 13 #include "base/callback.h"
14 #include "base/memory/ref_counted.h" 14 #include "base/memory/ref_counted.h"
15 #include "media/cast/cast_defines.h" 15 #include "media/cast/cast_defines.h"
16 #include "media/cast/transport/cast_transport_config.h"
16 17
17 namespace media { 18 namespace media {
18 namespace cast { 19 namespace cast {
19 20
20 enum RtcpMode { 21 enum RtcpMode {
21 kRtcpCompound, // Compound RTCP mode is described by RFC 4585. 22 kRtcpCompound, // Compound RTCP mode is described by RFC 4585.
22 kRtcpReducedSize, // Reduced-size RTCP mode is described by RFC 5506. 23 kRtcpReducedSize, // Reduced-size RTCP mode is described by RFC 5506.
23 }; 24 };
24 25
25 enum VideoCodec {
26 kVp8,
27 kH264,
28 kExternalVideo,
29 };
30
31 enum AudioCodec {
32 kOpus,
33 kPcm16,
34 kExternalAudio,
35 };
36
37 struct AudioSenderConfig { 26 struct AudioSenderConfig {
38 AudioSenderConfig(); 27 AudioSenderConfig();
39 28
40 uint32 sender_ssrc; 29 uint32 sender_ssrc;
41 uint32 incoming_feedback_ssrc; 30 uint32 incoming_feedback_ssrc;
42 31
43 int rtcp_interval; 32 int rtcp_interval;
44 std::string rtcp_c_name; 33 std::string rtcp_c_name;
45 RtcpMode rtcp_mode; 34 RtcpMode rtcp_mode;
46 35
47 int rtp_history_ms; // The time RTP packets are stored for retransmissions. 36 int rtp_history_ms; // The time RTP packets are stored for retransmissions.
48 int rtp_max_delay_ms; 37 int rtp_max_delay_ms;
49 int rtp_payload_type; 38 int rtp_payload_type;
50 39
51 bool use_external_encoder; 40 bool use_external_encoder;
52 int frequency; 41 int frequency;
53 int channels; 42 int channels;
54 int bitrate; // Set to <= 0 for "auto variable bitrate" (libopus knows best). 43 int bitrate; // Set to <= 0 for "auto variable bitrate" (libopus knows best).
55 AudioCodec codec; 44 transport::AudioCodec codec;
56 45
57 std::string aes_key; // Binary string of size kAesKeySize. 46 std::string aes_key; // Binary string of size kAesKeySize.
58 std::string aes_iv_mask; // Binary string of size kAesKeySize. 47 std::string aes_iv_mask; // Binary string of size kAesKeySize.
59 }; 48 };
60 49
61 struct VideoSenderConfig { 50 struct VideoSenderConfig {
62 VideoSenderConfig(); 51 VideoSenderConfig();
63 52
64 uint32 sender_ssrc; 53 uint32 sender_ssrc;
65 uint32 incoming_feedback_ssrc; 54 uint32 incoming_feedback_ssrc;
(...skipping 11 matching lines...) Expand all
77 int height; 66 int height;
78 67
79 float congestion_control_back_off; 68 float congestion_control_back_off;
80 int max_bitrate; 69 int max_bitrate;
81 int min_bitrate; 70 int min_bitrate;
82 int start_bitrate; 71 int start_bitrate;
83 int max_qp; 72 int max_qp;
84 int min_qp; 73 int min_qp;
85 int max_frame_rate; 74 int max_frame_rate;
86 int max_number_of_video_buffers_used; // Max value depend on codec. 75 int max_number_of_video_buffers_used; // Max value depend on codec.
87 VideoCodec codec; 76 transport::VideoCodec codec;
88 int number_of_cores; 77 int number_of_cores;
89 78
90 std::string aes_key; // Binary string of size kAesKeySize. 79 std::string aes_key; // Binary string of size kAesKeySize.
91 std::string aes_iv_mask; // Binary string of size kAesKeySize. 80 std::string aes_iv_mask; // Binary string of size kAesKeySize.
92 }; 81 };
93 82
94 struct AudioReceiverConfig { 83 struct AudioReceiverConfig {
95 AudioReceiverConfig(); 84 AudioReceiverConfig();
96 85
97 uint32 feedback_ssrc; 86 uint32 feedback_ssrc;
98 uint32 incoming_ssrc; 87 uint32 incoming_ssrc;
99 88
100 int rtcp_interval; 89 int rtcp_interval;
101 std::string rtcp_c_name; 90 std::string rtcp_c_name;
102 RtcpMode rtcp_mode; 91 RtcpMode rtcp_mode;
103 92
104 // The time the receiver is prepared to wait for retransmissions. 93 // The time the receiver is prepared to wait for retransmissions.
105 int rtp_max_delay_ms; 94 int rtp_max_delay_ms;
106 int rtp_payload_type; 95 int rtp_payload_type;
107 96
108 bool use_external_decoder; 97 bool use_external_decoder;
109 int frequency; 98 int frequency;
110 int channels; 99 int channels;
111 AudioCodec codec; 100 transport::AudioCodec codec;
112 101
113 std::string aes_key; // Binary string of size kAesKeySize. 102 std::string aes_key; // Binary string of size kAesKeySize.
114 std::string aes_iv_mask; // Binary string of size kAesKeySize. 103 std::string aes_iv_mask; // Binary string of size kAesKeySize.
115 }; 104 };
116 105
117 struct VideoReceiverConfig { 106 struct VideoReceiverConfig {
118 VideoReceiverConfig(); 107 VideoReceiverConfig();
119 108
120 uint32 feedback_ssrc; 109 uint32 feedback_ssrc;
121 uint32 incoming_ssrc; 110 uint32 incoming_ssrc;
122 111
123 int rtcp_interval; 112 int rtcp_interval;
124 std::string rtcp_c_name; 113 std::string rtcp_c_name;
125 RtcpMode rtcp_mode; 114 RtcpMode rtcp_mode;
126 115
127 // The time the receiver is prepared to wait for retransmissions. 116 // The time the receiver is prepared to wait for retransmissions.
128 int rtp_max_delay_ms; 117 int rtp_max_delay_ms;
129 int rtp_payload_type; 118 int rtp_payload_type;
130 119
131 bool use_external_decoder; 120 bool use_external_decoder;
132 int max_frame_rate; 121 int max_frame_rate;
133 122
134 // Some HW decoders can not run faster than the frame rate, preventing it 123 // Some HW decoders can not run faster than the frame rate, preventing it
135 // from catching up after a glitch. 124 // from catching up after a glitch.
136 bool decoder_faster_than_max_frame_rate; 125 bool decoder_faster_than_max_frame_rate;
137 VideoCodec codec; 126 transport::VideoCodec codec;
138 127
139 std::string aes_key; // Binary string of size kAesKeySize. 128 std::string aes_key; // Binary string of size kAesKeySize.
140 std::string aes_iv_mask; // Binary string of size kAesKeySize. 129 std::string aes_iv_mask; // Binary string of size kAesKeySize.
141 }; 130 };
142 131
143 struct EncodedVideoFrame {
144 EncodedVideoFrame();
145 ~EncodedVideoFrame();
146
147 VideoCodec codec;
148 bool key_frame;
149 uint32 frame_id;
150 uint32 last_referenced_frame_id;
151 std::string data;
152 };
153
154 // DEPRECATED: Do not use in new code. Please migrate existing code to use 132 // DEPRECATED: Do not use in new code. Please migrate existing code to use
155 // media::AudioBus. 133 // media::AudioBus.
156 struct PcmAudioFrame { 134 struct PcmAudioFrame {
157 PcmAudioFrame(); 135 PcmAudioFrame();
158 ~PcmAudioFrame(); 136 ~PcmAudioFrame();
159 137
160 int channels; // Samples in interleaved stereo format. L0, R0, L1 ,R1 ,... 138 int channels; // Samples in interleaved stereo format. L0, R0, L1 ,R1 ,...
161 int frequency; 139 int frequency;
162 std::vector<int16> samples; 140 std::vector<int16> samples;
163 }; 141 };
164 142
165 struct EncodedAudioFrame {
166 EncodedAudioFrame();
167 ~EncodedAudioFrame();
168
169 AudioCodec codec;
170 uint32 frame_id; // Needed to release the frame.
171 int samples; // Needed send side to advance the RTP timestamp.
172 // Not used receive side.
173 // Support for max sampling rate of 48KHz, 2 channels, 100 ms duration.
174 static const int kMaxNumberOfSamples = 48 * 2 * 100;
175 std::string data;
176 };
177
178 typedef std::vector<uint8> Packet; 143 typedef std::vector<uint8> Packet;
179 typedef std::vector<Packet> PacketList; 144 typedef std::vector<Packet> PacketList;
180 145
181 class PacketSender { 146 class PacketSender {
182 public: 147 public:
183 // All packets to be sent to the network will be delivered via these 148 // All packets to be sent to the network will be delivered via these
184 // functions. 149 // functions.
185 virtual bool SendPackets(const PacketList& packets) = 0; 150 virtual bool SendPackets(const PacketList& packets) = 0;
186 151
187 virtual bool SendPacket(const Packet& packet) = 0; 152 virtual bool SendPacket(const Packet& packet) = 0;
188 153
189 virtual ~PacketSender() {} 154 virtual ~PacketSender() {}
190 }; 155 };
191 156
192 class PacketReceiver : public base::RefCountedThreadSafe<PacketReceiver> {
193 public:
194 // All packets received from the network should be delivered via this
195 // function.
196 virtual void ReceivedPacket(const uint8* packet, size_t length,
197 const base::Closure callback) = 0;
198
199 static void DeletePacket(const uint8* packet);
200
201 protected:
202 virtual ~PacketReceiver() {}
203
204 private:
205 friend class base::RefCountedThreadSafe<PacketReceiver>;
206 };
207
208 class VideoEncoderController { 157 class VideoEncoderController {
209 public: 158 public:
210 // Inform the encoder about the new target bit rate. 159 // Inform the encoder about the new target bit rate.
211 virtual void SetBitRate(int new_bit_rate) = 0; 160 virtual void SetBitRate(int new_bit_rate) = 0;
212 161
213 // Inform the encoder to not encode the next frame. 162 // Inform the encoder to not encode the next frame.
214 // Note: this setting is sticky and should last until called with false. 163 // Note: this setting is sticky and should last until called with false.
215 virtual void SkipNextFrame(bool skip_next_frame) = 0; 164 virtual void SkipNextFrame(bool skip_next_frame) = 0;
216 165
217 // Inform the encoder to encode the next frame as a key frame. 166 // Inform the encoder to encode the next frame as a key frame.
218 virtual void GenerateKeyFrame() = 0; 167 virtual void GenerateKeyFrame() = 0;
219 168
220 // Inform the encoder to only reference frames older or equal to frame_id; 169 // Inform the encoder to only reference frames older or equal to frame_id;
221 virtual void LatestFrameIdToReference(uint32 frame_id) = 0; 170 virtual void LatestFrameIdToReference(uint32 frame_id) = 0;
222 171
223 // Query the codec about how many frames it has skipped due to slow ACK. 172 // Query the codec about how many frames it has skipped due to slow ACK.
224 virtual int NumberOfSkippedFrames() const = 0; 173 virtual int NumberOfSkippedFrames() const = 0;
225 174
226 protected: 175 protected:
227 virtual ~VideoEncoderController() {} 176 virtual ~VideoEncoderController() {}
228 }; 177 };
229 178
230 } // namespace cast 179 } // namespace cast
231 } // namespace media 180 } // namespace media
232 181
233 #endif // MEDIA_CAST_CAST_CONFIG_H_ 182 #endif // MEDIA_CAST_CAST_CONFIG_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698