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

Side by Side Diff: talk/media/base/fakemediaengine.h

Issue 1362503003: Use suffixed {uint,int}{8,16,32,64}_t types. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: google::int32 Created 5 years, 3 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
OLDNEW
1 /* 1 /*
2 * libjingle 2 * libjingle
3 * Copyright 2004 Google Inc. 3 * Copyright 2004 Google Inc.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met: 6 * modification, are permitted provided that the following conditions are met:
7 * 7 *
8 * 1. Redistributions of source code must retain the above copyright notice, 8 * 1. Redistributions of source code must retain the above copyright notice,
9 * this list of conditions and the following disclaimer. 9 * this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright notice, 10 * 2. Redistributions in binary form must reproduce the above copyright notice,
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
106 void set_fail_set_send_codecs(bool fail) { fail_set_send_codecs_ = fail; } 106 void set_fail_set_send_codecs(bool fail) { fail_set_send_codecs_ = fail; }
107 void set_fail_set_recv_codecs(bool fail) { fail_set_recv_codecs_ = fail; } 107 void set_fail_set_recv_codecs(bool fail) { fail_set_recv_codecs_ = fail; }
108 virtual bool AddSendStream(const StreamParams& sp) { 108 virtual bool AddSendStream(const StreamParams& sp) {
109 if (std::find(send_streams_.begin(), send_streams_.end(), sp) != 109 if (std::find(send_streams_.begin(), send_streams_.end(), sp) !=
110 send_streams_.end()) { 110 send_streams_.end()) {
111 return false; 111 return false;
112 } 112 }
113 send_streams_.push_back(sp); 113 send_streams_.push_back(sp);
114 return true; 114 return true;
115 } 115 }
116 virtual bool RemoveSendStream(uint32 ssrc) { 116 virtual bool RemoveSendStream(uint32_t ssrc) {
117 return RemoveStreamBySsrc(&send_streams_, ssrc); 117 return RemoveStreamBySsrc(&send_streams_, ssrc);
118 } 118 }
119 virtual bool AddRecvStream(const StreamParams& sp) { 119 virtual bool AddRecvStream(const StreamParams& sp) {
120 if (std::find(receive_streams_.begin(), receive_streams_.end(), sp) != 120 if (std::find(receive_streams_.begin(), receive_streams_.end(), sp) !=
121 receive_streams_.end()) { 121 receive_streams_.end()) {
122 return false; 122 return false;
123 } 123 }
124 receive_streams_.push_back(sp); 124 receive_streams_.push_back(sp);
125 return true; 125 return true;
126 } 126 }
127 virtual bool RemoveRecvStream(uint32 ssrc) { 127 virtual bool RemoveRecvStream(uint32_t ssrc) {
128 return RemoveStreamBySsrc(&receive_streams_, ssrc); 128 return RemoveStreamBySsrc(&receive_streams_, ssrc);
129 } 129 }
130 bool IsStreamMuted(uint32 ssrc) const { 130 bool IsStreamMuted(uint32_t ssrc) const {
131 bool ret = muted_streams_.find(ssrc) != muted_streams_.end(); 131 bool ret = muted_streams_.find(ssrc) != muted_streams_.end();
132 // If |ssrc = 0| check if the first send stream is muted. 132 // If |ssrc = 0| check if the first send stream is muted.
133 if (!ret && ssrc == 0 && !send_streams_.empty()) { 133 if (!ret && ssrc == 0 && !send_streams_.empty()) {
134 return muted_streams_.find(send_streams_[0].first_ssrc()) != 134 return muted_streams_.find(send_streams_[0].first_ssrc()) !=
135 muted_streams_.end(); 135 muted_streams_.end();
136 } 136 }
137 return ret; 137 return ret;
138 } 138 }
139 const std::vector<StreamParams>& send_streams() const { 139 const std::vector<StreamParams>& send_streams() const {
140 return send_streams_; 140 return send_streams_;
141 } 141 }
142 const std::vector<StreamParams>& recv_streams() const { 142 const std::vector<StreamParams>& recv_streams() const {
143 return receive_streams_; 143 return receive_streams_;
144 } 144 }
145 bool HasRecvStream(uint32 ssrc) const { 145 bool HasRecvStream(uint32_t ssrc) const {
146 return GetStreamBySsrc(receive_streams_, ssrc) != nullptr; 146 return GetStreamBySsrc(receive_streams_, ssrc) != nullptr;
147 } 147 }
148 bool HasSendStream(uint32 ssrc) const { 148 bool HasSendStream(uint32_t ssrc) const {
149 return GetStreamBySsrc(send_streams_, ssrc) != nullptr; 149 return GetStreamBySsrc(send_streams_, ssrc) != nullptr;
150 } 150 }
151 // TODO(perkj): This is to support legacy unit test that only check one 151 // TODO(perkj): This is to support legacy unit test that only check one
152 // sending stream. 152 // sending stream.
153 uint32 send_ssrc() const { 153 uint32_t send_ssrc() const {
154 if (send_streams_.empty()) 154 if (send_streams_.empty())
155 return 0; 155 return 0;
156 return send_streams_[0].first_ssrc(); 156 return send_streams_[0].first_ssrc();
157 } 157 }
158 158
159 // TODO(perkj): This is to support legacy unit test that only check one 159 // TODO(perkj): This is to support legacy unit test that only check one
160 // sending stream. 160 // sending stream.
161 const std::string rtcp_cname() { 161 const std::string rtcp_cname() {
162 if (send_streams_.empty()) 162 if (send_streams_.empty())
163 return ""; 163 return "";
164 return send_streams_[0].cname; 164 return send_streams_[0].cname;
165 } 165 }
166 166
167 bool ready_to_send() const { 167 bool ready_to_send() const {
168 return ready_to_send_; 168 return ready_to_send_;
169 } 169 }
170 170
171 protected: 171 protected:
172 bool MuteStream(uint32 ssrc, bool mute) { 172 bool MuteStream(uint32_t ssrc, bool mute) {
173 if (!HasSendStream(ssrc) && ssrc != 0) { 173 if (!HasSendStream(ssrc) && ssrc != 0) {
174 return false; 174 return false;
175 } 175 }
176 if (mute) { 176 if (mute) {
177 muted_streams_.insert(ssrc); 177 muted_streams_.insert(ssrc);
178 } else { 178 } else {
179 muted_streams_.erase(ssrc); 179 muted_streams_.erase(ssrc);
180 } 180 }
181 return true; 181 return true;
182 } 182 }
(...skipping 28 matching lines...) Expand all
211 211
212 private: 212 private:
213 bool sending_; 213 bool sending_;
214 bool playout_; 214 bool playout_;
215 std::vector<RtpHeaderExtension> recv_extensions_; 215 std::vector<RtpHeaderExtension> recv_extensions_;
216 std::vector<RtpHeaderExtension> send_extensions_; 216 std::vector<RtpHeaderExtension> send_extensions_;
217 std::list<std::string> rtp_packets_; 217 std::list<std::string> rtp_packets_;
218 std::list<std::string> rtcp_packets_; 218 std::list<std::string> rtcp_packets_;
219 std::vector<StreamParams> send_streams_; 219 std::vector<StreamParams> send_streams_;
220 std::vector<StreamParams> receive_streams_; 220 std::vector<StreamParams> receive_streams_;
221 std::set<uint32> muted_streams_; 221 std::set<uint32_t> muted_streams_;
222 bool fail_set_send_codecs_; 222 bool fail_set_send_codecs_;
223 bool fail_set_recv_codecs_; 223 bool fail_set_recv_codecs_;
224 uint32 send_ssrc_; 224 uint32_t send_ssrc_;
225 std::string rtcp_cname_; 225 std::string rtcp_cname_;
226 bool ready_to_send_; 226 bool ready_to_send_;
227 }; 227 };
228 228
229 class FakeVoiceMediaChannel : public RtpHelper<VoiceMediaChannel> { 229 class FakeVoiceMediaChannel : public RtpHelper<VoiceMediaChannel> {
230 public: 230 public:
231 struct DtmfInfo { 231 struct DtmfInfo {
232 DtmfInfo(uint32 ssrc, int event_code, int duration, int flags) 232 DtmfInfo(uint32_t ssrc, int event_code, int duration, int flags)
233 : ssrc(ssrc), event_code(event_code), duration(duration), flags(flags) { 233 : ssrc(ssrc),
234 } 234 event_code(event_code),
235 uint32 ssrc; 235 duration(duration),
236 flags(flags) {}
237 uint32_t ssrc;
236 int event_code; 238 int event_code;
237 int duration; 239 int duration;
238 int flags; 240 int flags;
239 }; 241 };
240 explicit FakeVoiceMediaChannel(FakeVoiceEngine* engine, 242 explicit FakeVoiceMediaChannel(FakeVoiceEngine* engine,
241 const AudioOptions& options) 243 const AudioOptions& options)
242 : engine_(engine), 244 : engine_(engine),
243 fail_set_send_(false), 245 fail_set_send_(false),
244 ringback_tone_ssrc_(0), 246 ringback_tone_ssrc_(0),
245 ringback_tone_play_(false), 247 ringback_tone_play_(false),
246 ringback_tone_loop_(false), 248 ringback_tone_loop_(false),
247 time_since_last_typing_(-1) { 249 time_since_last_typing_(-1) {
248 output_scalings_[0] = OutputScaling(); // For default channel. 250 output_scalings_[0] = OutputScaling(); // For default channel.
249 SetOptions(options); 251 SetOptions(options);
250 } 252 }
251 ~FakeVoiceMediaChannel(); 253 ~FakeVoiceMediaChannel();
252 const std::vector<AudioCodec>& recv_codecs() const { return recv_codecs_; } 254 const std::vector<AudioCodec>& recv_codecs() const { return recv_codecs_; }
253 const std::vector<AudioCodec>& send_codecs() const { return send_codecs_; } 255 const std::vector<AudioCodec>& send_codecs() const { return send_codecs_; }
254 const std::vector<AudioCodec>& codecs() const { return send_codecs(); } 256 const std::vector<AudioCodec>& codecs() const { return send_codecs(); }
255 const std::vector<DtmfInfo>& dtmf_info_queue() const { 257 const std::vector<DtmfInfo>& dtmf_info_queue() const {
256 return dtmf_info_queue_; 258 return dtmf_info_queue_;
257 } 259 }
258 const AudioOptions& options() const { return options_; } 260 const AudioOptions& options() const { return options_; }
259 261
260 uint32 ringback_tone_ssrc() const { return ringback_tone_ssrc_; } 262 uint32_t ringback_tone_ssrc() const { return ringback_tone_ssrc_; }
261 bool ringback_tone_play() const { return ringback_tone_play_; } 263 bool ringback_tone_play() const { return ringback_tone_play_; }
262 bool ringback_tone_loop() const { return ringback_tone_loop_; } 264 bool ringback_tone_loop() const { return ringback_tone_loop_; }
263 265
264 virtual bool SetSendParameters(const AudioSendParameters& params) { 266 virtual bool SetSendParameters(const AudioSendParameters& params) {
265 return (SetSendCodecs(params.codecs) && 267 return (SetSendCodecs(params.codecs) &&
266 SetSendRtpHeaderExtensions(params.extensions) && 268 SetSendRtpHeaderExtensions(params.extensions) &&
267 SetMaxSendBandwidth(params.max_bandwidth_bps) && 269 SetMaxSendBandwidth(params.max_bandwidth_bps) &&
268 SetOptions(params.options)); 270 SetOptions(params.options));
269 } 271 }
270 272
271 virtual bool SetRecvParameters(const AudioRecvParameters& params) { 273 virtual bool SetRecvParameters(const AudioRecvParameters& params) {
272 return (SetRecvCodecs(params.codecs) && 274 return (SetRecvCodecs(params.codecs) &&
273 SetRecvRtpHeaderExtensions(params.extensions)); 275 SetRecvRtpHeaderExtensions(params.extensions));
274 } 276 }
275 virtual bool SetPlayout(bool playout) { 277 virtual bool SetPlayout(bool playout) {
276 set_playout(playout); 278 set_playout(playout);
277 return true; 279 return true;
278 } 280 }
279 virtual bool SetSend(SendFlags flag) { 281 virtual bool SetSend(SendFlags flag) {
280 if (fail_set_send_) { 282 if (fail_set_send_) {
281 return false; 283 return false;
282 } 284 }
283 return set_sending(flag != SEND_NOTHING); 285 return set_sending(flag != SEND_NOTHING);
284 } 286 }
285 virtual bool SetAudioSend(uint32 ssrc, bool mute, 287 virtual bool SetAudioSend(uint32_t ssrc,
288 bool mute,
286 const AudioOptions* options, 289 const AudioOptions* options,
287 AudioRenderer* renderer) { 290 AudioRenderer* renderer) {
288 if (!SetLocalRenderer(ssrc, renderer)) { 291 if (!SetLocalRenderer(ssrc, renderer)) {
289 return false; 292 return false;
290 } 293 }
291 if (!RtpHelper<VoiceMediaChannel>::MuteStream(ssrc, mute)) { 294 if (!RtpHelper<VoiceMediaChannel>::MuteStream(ssrc, mute)) {
292 return false; 295 return false;
293 } 296 }
294 if (!mute && options) { 297 if (!mute && options) {
295 return SetOptions(*options); 298 return SetOptions(*options);
296 } 299 }
297 return true; 300 return true;
298 } 301 }
299 virtual bool AddRecvStream(const StreamParams& sp) { 302 virtual bool AddRecvStream(const StreamParams& sp) {
300 if (!RtpHelper<VoiceMediaChannel>::AddRecvStream(sp)) 303 if (!RtpHelper<VoiceMediaChannel>::AddRecvStream(sp))
301 return false; 304 return false;
302 output_scalings_[sp.first_ssrc()] = OutputScaling(); 305 output_scalings_[sp.first_ssrc()] = OutputScaling();
303 return true; 306 return true;
304 } 307 }
305 virtual bool RemoveRecvStream(uint32 ssrc) { 308 virtual bool RemoveRecvStream(uint32_t ssrc) {
306 if (!RtpHelper<VoiceMediaChannel>::RemoveRecvStream(ssrc)) 309 if (!RtpHelper<VoiceMediaChannel>::RemoveRecvStream(ssrc))
307 return false; 310 return false;
308 output_scalings_.erase(ssrc); 311 output_scalings_.erase(ssrc);
309 return true; 312 return true;
310 } 313 }
311 virtual bool SetRemoteRenderer(uint32 ssrc, AudioRenderer* renderer) { 314 virtual bool SetRemoteRenderer(uint32_t ssrc, AudioRenderer* renderer) {
312 std::map<uint32, AudioRenderer*>::iterator it = 315 std::map<uint32_t, AudioRenderer*>::iterator it =
313 remote_renderers_.find(ssrc); 316 remote_renderers_.find(ssrc);
314 if (renderer) { 317 if (renderer) {
315 if (it != remote_renderers_.end()) { 318 if (it != remote_renderers_.end()) {
316 ASSERT(it->second == renderer); 319 ASSERT(it->second == renderer);
317 } else { 320 } else {
318 remote_renderers_.insert(std::make_pair(ssrc, renderer)); 321 remote_renderers_.insert(std::make_pair(ssrc, renderer));
319 renderer->AddChannel(0); 322 renderer->AddChannel(0);
320 } 323 }
321 } else { 324 } else {
322 if (it != remote_renderers_.end()) { 325 if (it != remote_renderers_.end()) {
323 it->second->RemoveChannel(0); 326 it->second->RemoveChannel(0);
324 remote_renderers_.erase(it); 327 remote_renderers_.erase(it);
325 } else { 328 } else {
326 return false; 329 return false;
327 } 330 }
328 } 331 }
329 return true; 332 return true;
330 } 333 }
331 334
332 virtual bool GetActiveStreams(AudioInfo::StreamList* streams) { return true; } 335 virtual bool GetActiveStreams(AudioInfo::StreamList* streams) { return true; }
333 virtual int GetOutputLevel() { return 0; } 336 virtual int GetOutputLevel() { return 0; }
334 void set_time_since_last_typing(int ms) { time_since_last_typing_ = ms; } 337 void set_time_since_last_typing(int ms) { time_since_last_typing_ = ms; }
335 virtual int GetTimeSinceLastTyping() { return time_since_last_typing_; } 338 virtual int GetTimeSinceLastTyping() { return time_since_last_typing_; }
336 virtual void SetTypingDetectionParameters( 339 virtual void SetTypingDetectionParameters(
337 int time_window, int cost_per_typing, int reporting_threshold, 340 int time_window, int cost_per_typing, int reporting_threshold,
338 int penalty_decay, int type_event_delay) {} 341 int penalty_decay, int type_event_delay) {}
339 342
340 virtual bool SetRingbackTone(const char* buf, int len) { return true; } 343 virtual bool SetRingbackTone(const char* buf, int len) { return true; }
341 virtual bool PlayRingbackTone(uint32 ssrc, bool play, bool loop) { 344 virtual bool PlayRingbackTone(uint32_t ssrc, bool play, bool loop) {
342 ringback_tone_ssrc_ = ssrc; 345 ringback_tone_ssrc_ = ssrc;
343 ringback_tone_play_ = play; 346 ringback_tone_play_ = play;
344 ringback_tone_loop_ = loop; 347 ringback_tone_loop_ = loop;
345 return true; 348 return true;
346 } 349 }
347 350
348 virtual bool CanInsertDtmf() { 351 virtual bool CanInsertDtmf() {
349 for (std::vector<AudioCodec>::const_iterator it = send_codecs_.begin(); 352 for (std::vector<AudioCodec>::const_iterator it = send_codecs_.begin();
350 it != send_codecs_.end(); ++it) { 353 it != send_codecs_.end(); ++it) {
351 // Find the DTMF telephone event "codec". 354 // Find the DTMF telephone event "codec".
352 if (_stricmp(it->name.c_str(), "telephone-event") == 0) { 355 if (_stricmp(it->name.c_str(), "telephone-event") == 0) {
353 return true; 356 return true;
354 } 357 }
355 } 358 }
356 return false; 359 return false;
357 } 360 }
358 virtual bool InsertDtmf(uint32 ssrc, int event_code, int duration, 361 virtual bool InsertDtmf(uint32_t ssrc,
362 int event_code,
363 int duration,
359 int flags) { 364 int flags) {
360 dtmf_info_queue_.push_back(DtmfInfo(ssrc, event_code, duration, flags)); 365 dtmf_info_queue_.push_back(DtmfInfo(ssrc, event_code, duration, flags));
361 return true; 366 return true;
362 } 367 }
363 368
364 virtual bool SetOutputScaling(uint32 ssrc, double left, double right) { 369 virtual bool SetOutputScaling(uint32_t ssrc, double left, double right) {
365 if (0 == ssrc) { 370 if (0 == ssrc) {
366 std::map<uint32, OutputScaling>::iterator it; 371 std::map<uint32_t, OutputScaling>::iterator it;
367 for (it = output_scalings_.begin(); it != output_scalings_.end(); ++it) { 372 for (it = output_scalings_.begin(); it != output_scalings_.end(); ++it) {
368 it->second.left = left; 373 it->second.left = left;
369 it->second.right = right; 374 it->second.right = right;
370 } 375 }
371 return true; 376 return true;
372 } else if (output_scalings_.find(ssrc) != output_scalings_.end()) { 377 } else if (output_scalings_.find(ssrc) != output_scalings_.end()) {
373 output_scalings_[ssrc].left = left; 378 output_scalings_[ssrc].left = left;
374 output_scalings_[ssrc].right = right; 379 output_scalings_[ssrc].right = right;
375 return true; 380 return true;
376 } 381 }
377 return false; 382 return false;
378 } 383 }
379 bool GetOutputScaling(uint32 ssrc, double* left, double* right) { 384 bool GetOutputScaling(uint32_t ssrc, double* left, double* right) {
380 if (output_scalings_.find(ssrc) == output_scalings_.end()) 385 if (output_scalings_.find(ssrc) == output_scalings_.end())
381 return false; 386 return false;
382 *left = output_scalings_[ssrc].left; 387 *left = output_scalings_[ssrc].left;
383 *right = output_scalings_[ssrc].right; 388 *right = output_scalings_[ssrc].right;
384 return true; 389 return true;
385 } 390 }
386 391
387 virtual bool GetStats(VoiceMediaInfo* info) { return false; } 392 virtual bool GetStats(VoiceMediaInfo* info) { return false; }
388 virtual void GetLastMediaError(uint32* ssrc, 393 virtual void GetLastMediaError(uint32_t* ssrc,
389 VoiceMediaChannel::Error* error) { 394 VoiceMediaChannel::Error* error) {
390 *ssrc = 0; 395 *ssrc = 0;
391 *error = fail_set_send_ ? VoiceMediaChannel::ERROR_REC_DEVICE_OPEN_FAILED 396 *error = fail_set_send_ ? VoiceMediaChannel::ERROR_REC_DEVICE_OPEN_FAILED
392 : VoiceMediaChannel::ERROR_NONE; 397 : VoiceMediaChannel::ERROR_NONE;
393 } 398 }
394 399
395 void set_fail_set_send(bool fail) { fail_set_send_ = fail; } 400 void set_fail_set_send(bool fail) { fail_set_send_ = fail; }
396 void TriggerError(uint32 ssrc, VoiceMediaChannel::Error error) { 401 void TriggerError(uint32_t ssrc, VoiceMediaChannel::Error error) {
397 VoiceMediaChannel::SignalMediaError(ssrc, error); 402 VoiceMediaChannel::SignalMediaError(ssrc, error);
398 } 403 }
399 404
400 private: 405 private:
401 struct OutputScaling { 406 struct OutputScaling {
402 OutputScaling() : left(1.0), right(1.0) {} 407 OutputScaling() : left(1.0), right(1.0) {}
403 double left, right; 408 double left, right;
404 }; 409 };
405 410
406 class VoiceChannelAudioSink : public AudioRenderer::Sink { 411 class VoiceChannelAudioSink : public AudioRenderer::Sink {
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
443 } 448 }
444 send_codecs_ = codecs; 449 send_codecs_ = codecs;
445 return true; 450 return true;
446 } 451 }
447 bool SetMaxSendBandwidth(int bps) { return true; } 452 bool SetMaxSendBandwidth(int bps) { return true; }
448 bool SetOptions(const AudioOptions& options) { 453 bool SetOptions(const AudioOptions& options) {
449 // Does a "merge" of current options and set options. 454 // Does a "merge" of current options and set options.
450 options_.SetAll(options); 455 options_.SetAll(options);
451 return true; 456 return true;
452 } 457 }
453 bool SetLocalRenderer(uint32 ssrc, AudioRenderer* renderer) { 458 bool SetLocalRenderer(uint32_t ssrc, AudioRenderer* renderer) {
454 auto it = local_renderers_.find(ssrc); 459 auto it = local_renderers_.find(ssrc);
455 if (renderer) { 460 if (renderer) {
456 if (it != local_renderers_.end()) { 461 if (it != local_renderers_.end()) {
457 ASSERT(it->second->renderer() == renderer); 462 ASSERT(it->second->renderer() == renderer);
458 } else { 463 } else {
459 local_renderers_.insert(std::make_pair( 464 local_renderers_.insert(std::make_pair(
460 ssrc, new VoiceChannelAudioSink(renderer))); 465 ssrc, new VoiceChannelAudioSink(renderer)));
461 } 466 }
462 } else { 467 } else {
463 if (it != local_renderers_.end()) { 468 if (it != local_renderers_.end()) {
464 delete it->second; 469 delete it->second;
465 local_renderers_.erase(it); 470 local_renderers_.erase(it);
466 } 471 }
467 } 472 }
468 return true; 473 return true;
469 } 474 }
470 475
471 FakeVoiceEngine* engine_; 476 FakeVoiceEngine* engine_;
472 std::vector<AudioCodec> recv_codecs_; 477 std::vector<AudioCodec> recv_codecs_;
473 std::vector<AudioCodec> send_codecs_; 478 std::vector<AudioCodec> send_codecs_;
474 std::map<uint32, OutputScaling> output_scalings_; 479 std::map<uint32_t, OutputScaling> output_scalings_;
475 std::vector<DtmfInfo> dtmf_info_queue_; 480 std::vector<DtmfInfo> dtmf_info_queue_;
476 bool fail_set_send_; 481 bool fail_set_send_;
477 uint32 ringback_tone_ssrc_; 482 uint32_t ringback_tone_ssrc_;
478 bool ringback_tone_play_; 483 bool ringback_tone_play_;
479 bool ringback_tone_loop_; 484 bool ringback_tone_loop_;
480 int time_since_last_typing_; 485 int time_since_last_typing_;
481 AudioOptions options_; 486 AudioOptions options_;
482 std::map<uint32, VoiceChannelAudioSink*> local_renderers_; 487 std::map<uint32_t, VoiceChannelAudioSink*> local_renderers_;
483 std::map<uint32, AudioRenderer*> remote_renderers_; 488 std::map<uint32_t, AudioRenderer*> remote_renderers_;
484 }; 489 };
485 490
486 // A helper function to compare the FakeVoiceMediaChannel::DtmfInfo. 491 // A helper function to compare the FakeVoiceMediaChannel::DtmfInfo.
487 inline bool CompareDtmfInfo(const FakeVoiceMediaChannel::DtmfInfo& info, 492 inline bool CompareDtmfInfo(const FakeVoiceMediaChannel::DtmfInfo& info,
488 uint32 ssrc, int event_code, int duration, 493 uint32_t ssrc,
494 int event_code,
495 int duration,
489 int flags) { 496 int flags) {
490 return (info.duration == duration && info.event_code == event_code && 497 return (info.duration == duration && info.event_code == event_code &&
491 info.flags == flags && info.ssrc == ssrc); 498 info.flags == flags && info.ssrc == ssrc);
492 } 499 }
493 500
494 class FakeVideoMediaChannel : public RtpHelper<VideoMediaChannel> { 501 class FakeVideoMediaChannel : public RtpHelper<VideoMediaChannel> {
495 public: 502 public:
496 explicit FakeVideoMediaChannel(FakeVideoEngine* engine, 503 explicit FakeVideoMediaChannel(FakeVideoEngine* engine,
497 const VideoOptions& options) 504 const VideoOptions& options)
498 : engine_(engine), 505 : engine_(engine),
499 sent_intra_frame_(false), 506 sent_intra_frame_(false),
500 requested_intra_frame_(false), 507 requested_intra_frame_(false),
501 max_bps_(-1) { 508 max_bps_(-1) {
502 SetOptions(options); 509 SetOptions(options);
503 } 510 }
504 511
505 ~FakeVideoMediaChannel(); 512 ~FakeVideoMediaChannel();
506 513
507 const std::vector<VideoCodec>& recv_codecs() const { return recv_codecs_; } 514 const std::vector<VideoCodec>& recv_codecs() const { return recv_codecs_; }
508 const std::vector<VideoCodec>& send_codecs() const { return send_codecs_; } 515 const std::vector<VideoCodec>& send_codecs() const { return send_codecs_; }
509 const std::vector<VideoCodec>& codecs() const { return send_codecs(); } 516 const std::vector<VideoCodec>& codecs() const { return send_codecs(); }
510 bool rendering() const { return playout(); } 517 bool rendering() const { return playout(); }
511 const VideoOptions& options() const { return options_; } 518 const VideoOptions& options() const { return options_; }
512 const std::map<uint32, VideoRenderer*>& renderers() const { 519 const std::map<uint32_t, VideoRenderer*>& renderers() const {
513 return renderers_; 520 return renderers_;
514 } 521 }
515 int max_bps() const { return max_bps_; } 522 int max_bps() const { return max_bps_; }
516 bool GetSendStreamFormat(uint32 ssrc, VideoFormat* format) { 523 bool GetSendStreamFormat(uint32_t ssrc, VideoFormat* format) {
517 if (send_formats_.find(ssrc) == send_formats_.end()) { 524 if (send_formats_.find(ssrc) == send_formats_.end()) {
518 return false; 525 return false;
519 } 526 }
520 *format = send_formats_[ssrc]; 527 *format = send_formats_[ssrc];
521 return true; 528 return true;
522 } 529 }
523 virtual bool SetSendStreamFormat(uint32 ssrc, const VideoFormat& format) { 530 virtual bool SetSendStreamFormat(uint32_t ssrc, const VideoFormat& format) {
524 if (send_formats_.find(ssrc) == send_formats_.end()) { 531 if (send_formats_.find(ssrc) == send_formats_.end()) {
525 return false; 532 return false;
526 } 533 }
527 send_formats_[ssrc] = format; 534 send_formats_[ssrc] = format;
528 return true; 535 return true;
529 } 536 }
530 virtual bool SetSendParameters(const VideoSendParameters& params) { 537 virtual bool SetSendParameters(const VideoSendParameters& params) {
531 return (SetSendCodecs(params.codecs) && 538 return (SetSendCodecs(params.codecs) &&
532 SetSendRtpHeaderExtensions(params.extensions) && 539 SetSendRtpHeaderExtensions(params.extensions) &&
533 SetMaxSendBandwidth(params.max_bandwidth_bps) && 540 SetMaxSendBandwidth(params.max_bandwidth_bps) &&
534 SetOptions(params.options)); 541 SetOptions(params.options));
535 } 542 }
536 543
537 virtual bool SetRecvParameters(const VideoRecvParameters& params) { 544 virtual bool SetRecvParameters(const VideoRecvParameters& params) {
538 return (SetRecvCodecs(params.codecs) && 545 return (SetRecvCodecs(params.codecs) &&
539 SetRecvRtpHeaderExtensions(params.extensions)); 546 SetRecvRtpHeaderExtensions(params.extensions));
540 } 547 }
541 virtual bool AddSendStream(const StreamParams& sp) { 548 virtual bool AddSendStream(const StreamParams& sp) {
542 if (!RtpHelper<VideoMediaChannel>::AddSendStream(sp)) { 549 if (!RtpHelper<VideoMediaChannel>::AddSendStream(sp)) {
543 return false; 550 return false;
544 } 551 }
545 SetSendStreamDefaultFormat(sp.first_ssrc()); 552 SetSendStreamDefaultFormat(sp.first_ssrc());
546 return true; 553 return true;
547 } 554 }
548 virtual bool RemoveSendStream(uint32 ssrc) { 555 virtual bool RemoveSendStream(uint32_t ssrc) {
549 send_formats_.erase(ssrc); 556 send_formats_.erase(ssrc);
550 return RtpHelper<VideoMediaChannel>::RemoveSendStream(ssrc); 557 return RtpHelper<VideoMediaChannel>::RemoveSendStream(ssrc);
551 } 558 }
552 559
553 virtual bool GetSendCodec(VideoCodec* send_codec) { 560 virtual bool GetSendCodec(VideoCodec* send_codec) {
554 if (send_codecs_.empty()) { 561 if (send_codecs_.empty()) {
555 return false; 562 return false;
556 } 563 }
557 *send_codec = send_codecs_[0]; 564 *send_codec = send_codecs_[0];
558 return true; 565 return true;
559 } 566 }
560 virtual bool SetRender(bool render) { 567 virtual bool SetRender(bool render) {
561 set_playout(render); 568 set_playout(render);
562 return true; 569 return true;
563 } 570 }
564 virtual bool SetRenderer(uint32 ssrc, VideoRenderer* r) { 571 virtual bool SetRenderer(uint32_t ssrc, VideoRenderer* r) {
565 if (ssrc != 0 && renderers_.find(ssrc) == renderers_.end()) { 572 if (ssrc != 0 && renderers_.find(ssrc) == renderers_.end()) {
566 return false; 573 return false;
567 } 574 }
568 if (ssrc != 0) { 575 if (ssrc != 0) {
569 renderers_[ssrc] = r; 576 renderers_[ssrc] = r;
570 } 577 }
571 return true; 578 return true;
572 } 579 }
573 580
574 virtual bool SetSend(bool send) { return set_sending(send); } 581 virtual bool SetSend(bool send) { return set_sending(send); }
575 virtual bool SetVideoSend(uint32 ssrc, bool mute, 582 virtual bool SetVideoSend(uint32_t ssrc,
583 bool mute,
576 const VideoOptions* options) { 584 const VideoOptions* options) {
577 if (!RtpHelper<VideoMediaChannel>::MuteStream(ssrc, mute)) { 585 if (!RtpHelper<VideoMediaChannel>::MuteStream(ssrc, mute)) {
578 return false; 586 return false;
579 } 587 }
580 if (!mute && options) { 588 if (!mute && options) {
581 return SetOptions(*options); 589 return SetOptions(*options);
582 } 590 }
583 return true; 591 return true;
584 } 592 }
585 virtual bool SetCapturer(uint32 ssrc, VideoCapturer* capturer) { 593 virtual bool SetCapturer(uint32_t ssrc, VideoCapturer* capturer) {
586 capturers_[ssrc] = capturer; 594 capturers_[ssrc] = capturer;
587 return true; 595 return true;
588 } 596 }
589 bool HasCapturer(uint32 ssrc) const { 597 bool HasCapturer(uint32_t ssrc) const {
590 return capturers_.find(ssrc) != capturers_.end(); 598 return capturers_.find(ssrc) != capturers_.end();
591 } 599 }
592 virtual bool AddRecvStream(const StreamParams& sp) { 600 virtual bool AddRecvStream(const StreamParams& sp) {
593 if (!RtpHelper<VideoMediaChannel>::AddRecvStream(sp)) 601 if (!RtpHelper<VideoMediaChannel>::AddRecvStream(sp))
594 return false; 602 return false;
595 renderers_[sp.first_ssrc()] = NULL; 603 renderers_[sp.first_ssrc()] = NULL;
596 return true; 604 return true;
597 } 605 }
598 virtual bool RemoveRecvStream(uint32 ssrc) { 606 virtual bool RemoveRecvStream(uint32_t ssrc) {
599 if (!RtpHelper<VideoMediaChannel>::RemoveRecvStream(ssrc)) 607 if (!RtpHelper<VideoMediaChannel>::RemoveRecvStream(ssrc))
600 return false; 608 return false;
601 renderers_.erase(ssrc); 609 renderers_.erase(ssrc);
602 return true; 610 return true;
603 } 611 }
604 612
605 virtual bool GetStats(VideoMediaInfo* info) { return false; } 613 virtual bool GetStats(VideoMediaInfo* info) { return false; }
606 virtual bool SendIntraFrame() { 614 virtual bool SendIntraFrame() {
607 sent_intra_frame_ = true; 615 sent_intra_frame_ = true;
608 return true; 616 return true;
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
642 bool SetOptions(const VideoOptions& options) { 650 bool SetOptions(const VideoOptions& options) {
643 options_ = options; 651 options_ = options;
644 return true; 652 return true;
645 } 653 }
646 bool SetMaxSendBandwidth(int bps) { 654 bool SetMaxSendBandwidth(int bps) {
647 max_bps_ = bps; 655 max_bps_ = bps;
648 return true; 656 return true;
649 } 657 }
650 658
651 // Be default, each send stream uses the first send codec format. 659 // Be default, each send stream uses the first send codec format.
652 void SetSendStreamDefaultFormat(uint32 ssrc) { 660 void SetSendStreamDefaultFormat(uint32_t ssrc) {
653 if (!send_codecs_.empty()) { 661 if (!send_codecs_.empty()) {
654 send_formats_[ssrc] = VideoFormat( 662 send_formats_[ssrc] = VideoFormat(
655 send_codecs_[0].width, send_codecs_[0].height, 663 send_codecs_[0].width, send_codecs_[0].height,
656 cricket::VideoFormat::FpsToInterval(send_codecs_[0].framerate), 664 cricket::VideoFormat::FpsToInterval(send_codecs_[0].framerate),
657 cricket::FOURCC_I420); 665 cricket::FOURCC_I420);
658 } 666 }
659 } 667 }
660 668
661 FakeVideoEngine* engine_; 669 FakeVideoEngine* engine_;
662 std::vector<VideoCodec> recv_codecs_; 670 std::vector<VideoCodec> recv_codecs_;
663 std::vector<VideoCodec> send_codecs_; 671 std::vector<VideoCodec> send_codecs_;
664 std::map<uint32, VideoRenderer*> renderers_; 672 std::map<uint32_t, VideoRenderer*> renderers_;
665 std::map<uint32, VideoFormat> send_formats_; 673 std::map<uint32_t, VideoFormat> send_formats_;
666 std::map<uint32, VideoCapturer*> capturers_; 674 std::map<uint32_t, VideoCapturer*> capturers_;
667 bool sent_intra_frame_; 675 bool sent_intra_frame_;
668 bool requested_intra_frame_; 676 bool requested_intra_frame_;
669 VideoOptions options_; 677 VideoOptions options_;
670 int max_bps_; 678 int max_bps_;
671 }; 679 };
672 680
673 class FakeDataMediaChannel : public RtpHelper<DataMediaChannel> { 681 class FakeDataMediaChannel : public RtpHelper<DataMediaChannel> {
674 public: 682 public:
675 explicit FakeDataMediaChannel(void* unused, const DataOptions& options) 683 explicit FakeDataMediaChannel(void* unused, const DataOptions& options)
676 : send_blocked_(false), max_bps_(-1) {} 684 : send_blocked_(false), max_bps_(-1) {}
(...skipping 13 matching lines...) Expand all
690 virtual bool SetSend(bool send) { return set_sending(send); } 698 virtual bool SetSend(bool send) { return set_sending(send); }
691 virtual bool SetReceive(bool receive) { 699 virtual bool SetReceive(bool receive) {
692 set_playout(receive); 700 set_playout(receive);
693 return true; 701 return true;
694 } 702 }
695 virtual bool AddRecvStream(const StreamParams& sp) { 703 virtual bool AddRecvStream(const StreamParams& sp) {
696 if (!RtpHelper<DataMediaChannel>::AddRecvStream(sp)) 704 if (!RtpHelper<DataMediaChannel>::AddRecvStream(sp))
697 return false; 705 return false;
698 return true; 706 return true;
699 } 707 }
700 virtual bool RemoveRecvStream(uint32 ssrc) { 708 virtual bool RemoveRecvStream(uint32_t ssrc) {
701 if (!RtpHelper<DataMediaChannel>::RemoveRecvStream(ssrc)) 709 if (!RtpHelper<DataMediaChannel>::RemoveRecvStream(ssrc))
702 return false; 710 return false;
703 return true; 711 return true;
704 } 712 }
705 713
706 virtual bool SendData(const SendDataParams& params, 714 virtual bool SendData(const SendDataParams& params,
707 const rtc::Buffer& payload, 715 const rtc::Buffer& payload,
708 SendDataResult* result) { 716 SendDataResult* result) {
709 if (send_blocked_) { 717 if (send_blocked_) {
710 *result = SDR_BLOCK; 718 *result = SDR_BLOCK;
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
851 options_changed_ = true; 859 options_changed_ = true;
852 return true; 860 return true;
853 } 861 }
854 862
855 int GetInputLevel() { return 0; } 863 int GetInputLevel() { return 0; }
856 864
857 bool SetLocalMonitor(bool enable) { return true; } 865 bool SetLocalMonitor(bool enable) { return true; }
858 866
859 bool StartAecDump(rtc::PlatformFile file) { return false; } 867 bool StartAecDump(rtc::PlatformFile file) { return false; }
860 868
861 bool RegisterProcessor(uint32 ssrc, VoiceProcessor* voice_processor, 869 bool RegisterProcessor(uint32_t ssrc,
870 VoiceProcessor* voice_processor,
862 MediaProcessorDirection direction) { 871 MediaProcessorDirection direction) {
863 if (direction == MPD_RX) { 872 if (direction == MPD_RX) {
864 rx_processor_ = voice_processor; 873 rx_processor_ = voice_processor;
865 return true; 874 return true;
866 } else if (direction == MPD_TX) { 875 } else if (direction == MPD_TX) {
867 tx_processor_ = voice_processor; 876 tx_processor_ = voice_processor;
868 return true; 877 return true;
869 } 878 }
870 return false; 879 return false;
871 } 880 }
872 881
873 bool UnregisterProcessor(uint32 ssrc, VoiceProcessor* voice_processor, 882 bool UnregisterProcessor(uint32_t ssrc,
883 VoiceProcessor* voice_processor,
874 MediaProcessorDirection direction) { 884 MediaProcessorDirection direction) {
875 bool unregistered = false; 885 bool unregistered = false;
876 if (direction & MPD_RX) { 886 if (direction & MPD_RX) {
877 rx_processor_ = NULL; 887 rx_processor_ = NULL;
878 unregistered = true; 888 unregistered = true;
879 } 889 }
880 if (direction & MPD_TX) { 890 if (direction & MPD_TX) {
881 tx_processor_ = NULL; 891 tx_processor_ = NULL;
882 unregistered = true; 892 unregistered = true;
883 } 893 }
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after
1091 1101
1092 private: 1102 private:
1093 std::vector<FakeDataMediaChannel*> channels_; 1103 std::vector<FakeDataMediaChannel*> channels_;
1094 std::vector<DataCodec> data_codecs_; 1104 std::vector<DataCodec> data_codecs_;
1095 DataChannelType last_channel_type_; 1105 DataChannelType last_channel_type_;
1096 }; 1106 };
1097 1107
1098 } // namespace cricket 1108 } // namespace cricket
1099 1109
1100 #endif // TALK_MEDIA_BASE_FAKEMEDIAENGINE_H_ 1110 #endif // TALK_MEDIA_BASE_FAKEMEDIAENGINE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698