OLD | NEW |
---|---|
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 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
131 std::string str; | 131 std::string str; |
132 if (val.IsSet()) { | 132 if (val.IsSet()) { |
133 str = key; | 133 str = key; |
134 str += ": "; | 134 str += ": "; |
135 str += val.ToString(); | 135 str += val.ToString(); |
136 str += ", "; | 136 str += ", "; |
137 } | 137 } |
138 return str; | 138 return str; |
139 } | 139 } |
140 | 140 |
141 template <class T> | |
142 static std::string VectorToString(const std::vector<T>& vals) { | |
143 std::ostringstream ost; | |
144 ost << "["; | |
145 for (const T& val : vals) { | |
146 ost << val.ToString() << ","; | |
pbos-webrtc
2015/07/14 08:25:01
Don't add "," at the end.
pthatcher1
2015/07/16 10:47:11
Done.
| |
147 } | |
148 ost << "]"; | |
149 return ost.str(); | |
150 } | |
151 | |
141 // Options that can be applied to a VoiceMediaChannel or a VoiceMediaEngine. | 152 // Options that can be applied to a VoiceMediaChannel or a VoiceMediaEngine. |
142 // Used to be flags, but that makes it hard to selectively apply options. | 153 // Used to be flags, but that makes it hard to selectively apply options. |
143 // We are moving all of the setting of options to structs like this, | 154 // We are moving all of the setting of options to structs like this, |
144 // but some things currently still use flags. | 155 // but some things currently still use flags. |
145 struct AudioOptions { | 156 struct AudioOptions { |
146 void SetAll(const AudioOptions& change) { | 157 void SetAll(const AudioOptions& change) { |
147 echo_cancellation.SetFrom(change.echo_cancellation); | 158 echo_cancellation.SetFrom(change.echo_cancellation); |
148 auto_gain_control.SetFrom(change.auto_gain_control); | 159 auto_gain_control.SetFrom(change.auto_gain_control); |
149 rx_auto_gain_control.SetFrom(change.rx_auto_gain_control); | 160 rx_auto_gain_control.SetFrom(change.rx_auto_gain_control); |
150 noise_suppression.SetFrom(change.noise_suppression); | 161 noise_suppression.SetFrom(change.noise_suppression); |
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
320 change.cpu_underuse_encode_rsd_threshold); | 331 change.cpu_underuse_encode_rsd_threshold); |
321 cpu_overuse_encode_rsd_threshold.SetFrom( | 332 cpu_overuse_encode_rsd_threshold.SetFrom( |
322 change.cpu_overuse_encode_rsd_threshold); | 333 change.cpu_overuse_encode_rsd_threshold); |
323 cpu_overuse_encode_usage.SetFrom(change.cpu_overuse_encode_usage); | 334 cpu_overuse_encode_usage.SetFrom(change.cpu_overuse_encode_usage); |
324 conference_mode.SetFrom(change.conference_mode); | 335 conference_mode.SetFrom(change.conference_mode); |
325 process_adaptation_threshhold.SetFrom(change.process_adaptation_threshhold); | 336 process_adaptation_threshhold.SetFrom(change.process_adaptation_threshhold); |
326 system_low_adaptation_threshhold.SetFrom( | 337 system_low_adaptation_threshhold.SetFrom( |
327 change.system_low_adaptation_threshhold); | 338 change.system_low_adaptation_threshhold); |
328 system_high_adaptation_threshhold.SetFrom( | 339 system_high_adaptation_threshhold.SetFrom( |
329 change.system_high_adaptation_threshhold); | 340 change.system_high_adaptation_threshhold); |
330 buffered_mode_latency.SetFrom(change.buffered_mode_latency); | |
331 dscp.SetFrom(change.dscp); | 341 dscp.SetFrom(change.dscp); |
332 suspend_below_min_bitrate.SetFrom(change.suspend_below_min_bitrate); | 342 suspend_below_min_bitrate.SetFrom(change.suspend_below_min_bitrate); |
333 unsignalled_recv_stream_limit.SetFrom(change.unsignalled_recv_stream_limit); | 343 unsignalled_recv_stream_limit.SetFrom(change.unsignalled_recv_stream_limit); |
334 use_simulcast_adapter.SetFrom(change.use_simulcast_adapter); | 344 use_simulcast_adapter.SetFrom(change.use_simulcast_adapter); |
335 screencast_min_bitrate.SetFrom(change.screencast_min_bitrate); | 345 screencast_min_bitrate.SetFrom(change.screencast_min_bitrate); |
336 } | 346 } |
337 | 347 |
338 bool operator==(const VideoOptions& o) const { | 348 bool operator==(const VideoOptions& o) const { |
339 return adapt_input_to_cpu_usage == o.adapt_input_to_cpu_usage && | 349 return adapt_input_to_cpu_usage == o.adapt_input_to_cpu_usage && |
340 adapt_cpu_with_smoothing == o.adapt_cpu_with_smoothing && | 350 adapt_cpu_with_smoothing == o.adapt_cpu_with_smoothing && |
341 video_adapt_third == o.video_adapt_third && | 351 video_adapt_third == o.video_adapt_third && |
342 video_noise_reduction == o.video_noise_reduction && | 352 video_noise_reduction == o.video_noise_reduction && |
343 video_start_bitrate == o.video_start_bitrate && | 353 video_start_bitrate == o.video_start_bitrate && |
344 video_highest_bitrate == o.video_highest_bitrate && | 354 video_highest_bitrate == o.video_highest_bitrate && |
345 cpu_overuse_detection == o.cpu_overuse_detection && | 355 cpu_overuse_detection == o.cpu_overuse_detection && |
346 cpu_underuse_threshold == o.cpu_underuse_threshold && | 356 cpu_underuse_threshold == o.cpu_underuse_threshold && |
347 cpu_overuse_threshold == o.cpu_overuse_threshold && | 357 cpu_overuse_threshold == o.cpu_overuse_threshold && |
348 cpu_underuse_encode_rsd_threshold == | 358 cpu_underuse_encode_rsd_threshold == |
349 o.cpu_underuse_encode_rsd_threshold && | 359 o.cpu_underuse_encode_rsd_threshold && |
350 cpu_overuse_encode_rsd_threshold == | 360 cpu_overuse_encode_rsd_threshold == |
351 o.cpu_overuse_encode_rsd_threshold && | 361 o.cpu_overuse_encode_rsd_threshold && |
352 cpu_overuse_encode_usage == o.cpu_overuse_encode_usage && | 362 cpu_overuse_encode_usage == o.cpu_overuse_encode_usage && |
353 conference_mode == o.conference_mode && | 363 conference_mode == o.conference_mode && |
354 process_adaptation_threshhold == o.process_adaptation_threshhold && | 364 process_adaptation_threshhold == o.process_adaptation_threshhold && |
355 system_low_adaptation_threshhold == | 365 system_low_adaptation_threshhold == |
356 o.system_low_adaptation_threshhold && | 366 o.system_low_adaptation_threshhold && |
357 system_high_adaptation_threshhold == | 367 system_high_adaptation_threshhold == |
358 o.system_high_adaptation_threshhold && | 368 o.system_high_adaptation_threshhold && |
359 buffered_mode_latency == o.buffered_mode_latency && dscp == o.dscp && | 369 dscp == o.dscp && |
360 suspend_below_min_bitrate == o.suspend_below_min_bitrate && | 370 suspend_below_min_bitrate == o.suspend_below_min_bitrate && |
361 unsignalled_recv_stream_limit == o.unsignalled_recv_stream_limit && | 371 unsignalled_recv_stream_limit == o.unsignalled_recv_stream_limit && |
362 use_simulcast_adapter == o.use_simulcast_adapter && | 372 use_simulcast_adapter == o.use_simulcast_adapter && |
363 screencast_min_bitrate == o.screencast_min_bitrate; | 373 screencast_min_bitrate == o.screencast_min_bitrate; |
364 } | 374 } |
365 | 375 |
366 std::string ToString() const { | 376 std::string ToString() const { |
367 std::ostringstream ost; | 377 std::ostringstream ost; |
368 ost << "VideoOptions {"; | 378 ost << "VideoOptions {"; |
369 ost << ToStringIfSet("cpu adaption", adapt_input_to_cpu_usage); | 379 ost << ToStringIfSet("cpu adaption", adapt_input_to_cpu_usage); |
370 ost << ToStringIfSet("cpu adaptation smoothing", adapt_cpu_with_smoothing); | 380 ost << ToStringIfSet("cpu adaptation smoothing", adapt_cpu_with_smoothing); |
371 ost << ToStringIfSet("video adapt third", video_adapt_third); | 381 ost << ToStringIfSet("video adapt third", video_adapt_third); |
372 ost << ToStringIfSet("noise reduction", video_noise_reduction); | 382 ost << ToStringIfSet("noise reduction", video_noise_reduction); |
373 ost << ToStringIfSet("start bitrate", video_start_bitrate); | 383 ost << ToStringIfSet("start bitrate", video_start_bitrate); |
374 ost << ToStringIfSet("highest video bitrate", video_highest_bitrate); | 384 ost << ToStringIfSet("highest video bitrate", video_highest_bitrate); |
375 ost << ToStringIfSet("cpu overuse detection", cpu_overuse_detection); | 385 ost << ToStringIfSet("cpu overuse detection", cpu_overuse_detection); |
376 ost << ToStringIfSet("cpu underuse threshold", cpu_underuse_threshold); | 386 ost << ToStringIfSet("cpu underuse threshold", cpu_underuse_threshold); |
377 ost << ToStringIfSet("cpu overuse threshold", cpu_overuse_threshold); | 387 ost << ToStringIfSet("cpu overuse threshold", cpu_overuse_threshold); |
378 ost << ToStringIfSet("cpu underuse encode rsd threshold", | 388 ost << ToStringIfSet("cpu underuse encode rsd threshold", |
379 cpu_underuse_encode_rsd_threshold); | 389 cpu_underuse_encode_rsd_threshold); |
380 ost << ToStringIfSet("cpu overuse encode rsd threshold", | 390 ost << ToStringIfSet("cpu overuse encode rsd threshold", |
381 cpu_overuse_encode_rsd_threshold); | 391 cpu_overuse_encode_rsd_threshold); |
382 ost << ToStringIfSet("cpu overuse encode usage", | 392 ost << ToStringIfSet("cpu overuse encode usage", |
383 cpu_overuse_encode_usage); | 393 cpu_overuse_encode_usage); |
384 ost << ToStringIfSet("conference mode", conference_mode); | 394 ost << ToStringIfSet("conference mode", conference_mode); |
385 ost << ToStringIfSet("process", process_adaptation_threshhold); | 395 ost << ToStringIfSet("process", process_adaptation_threshhold); |
386 ost << ToStringIfSet("low", system_low_adaptation_threshhold); | 396 ost << ToStringIfSet("low", system_low_adaptation_threshhold); |
387 ost << ToStringIfSet("high", system_high_adaptation_threshhold); | 397 ost << ToStringIfSet("high", system_high_adaptation_threshhold); |
388 ost << ToStringIfSet("buffered mode latency", buffered_mode_latency); | |
389 ost << ToStringIfSet("dscp", dscp); | 398 ost << ToStringIfSet("dscp", dscp); |
390 ost << ToStringIfSet("suspend below min bitrate", | 399 ost << ToStringIfSet("suspend below min bitrate", |
391 suspend_below_min_bitrate); | 400 suspend_below_min_bitrate); |
392 ost << ToStringIfSet("num channels for early receive", | 401 ost << ToStringIfSet("num channels for early receive", |
393 unsignalled_recv_stream_limit); | 402 unsignalled_recv_stream_limit); |
394 ost << ToStringIfSet("use simulcast adapter", use_simulcast_adapter); | 403 ost << ToStringIfSet("use simulcast adapter", use_simulcast_adapter); |
395 ost << ToStringIfSet("screencast min bitrate", screencast_min_bitrate); | 404 ost << ToStringIfSet("screencast min bitrate", screencast_min_bitrate); |
396 ost << "}"; | 405 ost << "}"; |
397 return ost.str(); | 406 return ost.str(); |
398 } | 407 } |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
432 // Use encode usage for cpu detection. | 441 // Use encode usage for cpu detection. |
433 Settable<bool> cpu_overuse_encode_usage; | 442 Settable<bool> cpu_overuse_encode_usage; |
434 // Use conference mode? | 443 // Use conference mode? |
435 Settable<bool> conference_mode; | 444 Settable<bool> conference_mode; |
436 // Threshhold for process cpu adaptation. (Process limit) | 445 // Threshhold for process cpu adaptation. (Process limit) |
437 Settable<float> process_adaptation_threshhold; | 446 Settable<float> process_adaptation_threshhold; |
438 // Low threshhold for cpu adaptation. (Adapt up) | 447 // Low threshhold for cpu adaptation. (Adapt up) |
439 Settable<float> system_low_adaptation_threshhold; | 448 Settable<float> system_low_adaptation_threshhold; |
440 // High threshhold for cpu adaptation. (Adapt down) | 449 // High threshhold for cpu adaptation. (Adapt down) |
441 Settable<float> system_high_adaptation_threshhold; | 450 Settable<float> system_high_adaptation_threshhold; |
442 // Specify buffered mode latency in milliseconds. | |
443 Settable<int> buffered_mode_latency; | |
444 // Set DSCP value for packet sent from video channel. | 451 // Set DSCP value for packet sent from video channel. |
445 Settable<bool> dscp; | 452 Settable<bool> dscp; |
446 // Enable WebRTC suspension of video. No video frames will be sent when the | 453 // Enable WebRTC suspension of video. No video frames will be sent when the |
447 // bitrate is below the configured minimum bitrate. | 454 // bitrate is below the configured minimum bitrate. |
448 Settable<bool> suspend_below_min_bitrate; | 455 Settable<bool> suspend_below_min_bitrate; |
449 // Limit on the number of early receive channels that can be created. | 456 // Limit on the number of early receive channels that can be created. |
450 Settable<int> unsignalled_recv_stream_limit; | 457 Settable<int> unsignalled_recv_stream_limit; |
451 // Enable use of simulcast adapter. | 458 // Enable use of simulcast adapter. |
452 Settable<bool> use_simulcast_adapter; | 459 Settable<bool> use_simulcast_adapter; |
453 // Force screencast to use a minimum bitrate | 460 // Force screencast to use a minimum bitrate |
454 Settable<int> screencast_min_bitrate; | 461 Settable<int> screencast_min_bitrate; |
455 }; | 462 }; |
456 | 463 |
457 struct RtpHeaderExtension { | 464 struct RtpHeaderExtension { |
458 RtpHeaderExtension() : id(0) {} | 465 RtpHeaderExtension() : id(0) {} |
459 RtpHeaderExtension(const std::string& u, int i) : uri(u), id(i) {} | 466 RtpHeaderExtension(const std::string& u, int i) : uri(u), id(i) {} |
460 std::string uri; | |
461 int id; | |
462 // TODO(juberti): SendRecv direction; | |
463 | 467 |
464 bool operator==(const RtpHeaderExtension& ext) const { | 468 bool operator==(const RtpHeaderExtension& ext) const { |
465 // id is a reserved word in objective-c. Therefore the id attribute has to | 469 // id is a reserved word in objective-c. Therefore the id attribute has to |
466 // be a fully qualified name in order to compile on IOS. | 470 // be a fully qualified name in order to compile on IOS. |
467 return this->id == ext.id && | 471 return this->id == ext.id && |
468 uri == ext.uri; | 472 uri == ext.uri; |
469 } | 473 } |
474 | |
475 std::string ToString() const { | |
476 std::ostringstream ost; | |
477 ost << "{"; | |
478 ost << "id: , " << id; | |
479 ost << "uri: " << uri; | |
480 ost << "}"; | |
481 return ost.str(); | |
482 } | |
483 | |
484 std::string uri; | |
485 int id; | |
486 // TODO(juberti): SendRecv direction; | |
470 }; | 487 }; |
471 | 488 |
472 // Returns the named header extension if found among all extensions, NULL | 489 // Returns the named header extension if found among all extensions, NULL |
473 // otherwise. | 490 // otherwise. |
474 inline const RtpHeaderExtension* FindHeaderExtension( | 491 inline const RtpHeaderExtension* FindHeaderExtension( |
475 const std::vector<RtpHeaderExtension>& extensions, | 492 const std::vector<RtpHeaderExtension>& extensions, |
476 const std::string& name) { | 493 const std::string& name) { |
477 for (std::vector<RtpHeaderExtension>::const_iterator it = extensions.begin(); | 494 for (std::vector<RtpHeaderExtension>::const_iterator it = extensions.begin(); |
478 it != extensions.end(); ++it) { | 495 it != extensions.end(); ++it) { |
479 if (it->uri == name) | 496 if (it->uri == name) |
(...skipping 502 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
982 | 999 |
983 struct DataMediaInfo { | 1000 struct DataMediaInfo { |
984 void Clear() { | 1001 void Clear() { |
985 senders.clear(); | 1002 senders.clear(); |
986 receivers.clear(); | 1003 receivers.clear(); |
987 } | 1004 } |
988 std::vector<DataSenderInfo> senders; | 1005 std::vector<DataSenderInfo> senders; |
989 std::vector<DataReceiverInfo> receivers; | 1006 std::vector<DataReceiverInfo> receivers; |
990 }; | 1007 }; |
991 | 1008 |
1009 struct AudioSendParameters { | |
1010 std::string ToString() { | |
1011 std::ostringstream ost; | |
1012 ost << "{"; | |
1013 ost << "codecs: " << VectorToString(codecs) << ", "; | |
1014 ost << "extensions: " << VectorToString(extensions) << ", "; | |
1015 ost << "max_bandiwidth_bps: " << max_bandwidth_bps << ", "; | |
1016 ost << "options: " << options.ToString(); | |
1017 ost << "}"; | |
1018 return ost.str(); | |
1019 } | |
1020 | |
1021 std::vector<AudioCodec> codecs; | |
1022 std::vector<RtpHeaderExtension> extensions; | |
1023 // TODO(pthatcher): Move max_bandwidth_bps into AudioOptions. | |
1024 int max_bandwidth_bps; | |
1025 AudioOptions options; | |
1026 // TODO(pthatcher): Add "remote" streams. | |
1027 }; | |
1028 | |
1029 struct AudioRecvParameters { | |
1030 std::string ToString() { | |
1031 std::ostringstream ost; | |
1032 ost << "{"; | |
1033 ost << "codecs: " << VectorToString(codecs) << ", "; | |
1034 ost << "extensions: " << VectorToString(extensions); | |
1035 ost << "}"; | |
1036 return ost.str(); | |
1037 } | |
1038 | |
1039 std::vector<AudioCodec> codecs; | |
1040 std::vector<RtpHeaderExtension> extensions; | |
1041 // TODO(pthatcher): Add "local" streams. | |
1042 }; | |
1043 | |
992 class VoiceMediaChannel : public MediaChannel { | 1044 class VoiceMediaChannel : public MediaChannel { |
993 public: | 1045 public: |
994 enum Error { | 1046 enum Error { |
995 ERROR_NONE = 0, // No error. | 1047 ERROR_NONE = 0, // No error. |
996 ERROR_OTHER, // Other errors. | 1048 ERROR_OTHER, // Other errors. |
997 ERROR_REC_DEVICE_OPEN_FAILED = 100, // Could not open mic. | 1049 ERROR_REC_DEVICE_OPEN_FAILED = 100, // Could not open mic. |
998 ERROR_REC_DEVICE_MUTED, // Mic was muted by OS. | 1050 ERROR_REC_DEVICE_MUTED, // Mic was muted by OS. |
999 ERROR_REC_DEVICE_SILENT, // No background noise picked up. | 1051 ERROR_REC_DEVICE_SILENT, // No background noise picked up. |
1000 ERROR_REC_DEVICE_SATURATION, // Mic input is clipping. | 1052 ERROR_REC_DEVICE_SATURATION, // Mic input is clipping. |
1001 ERROR_REC_DEVICE_REMOVED, // Mic was removed while active. | 1053 ERROR_REC_DEVICE_REMOVED, // Mic was removed while active. |
1002 ERROR_REC_RUNTIME_ERROR, // Processing is encountering errors. | 1054 ERROR_REC_RUNTIME_ERROR, // Processing is encountering errors. |
1003 ERROR_REC_SRTP_ERROR, // Generic SRTP failure. | 1055 ERROR_REC_SRTP_ERROR, // Generic SRTP failure. |
1004 ERROR_REC_SRTP_AUTH_FAILED, // Failed to authenticate packets. | 1056 ERROR_REC_SRTP_AUTH_FAILED, // Failed to authenticate packets. |
1005 ERROR_REC_TYPING_NOISE_DETECTED, // Typing noise is detected. | 1057 ERROR_REC_TYPING_NOISE_DETECTED, // Typing noise is detected. |
1006 ERROR_PLAY_DEVICE_OPEN_FAILED = 200, // Could not open playout. | 1058 ERROR_PLAY_DEVICE_OPEN_FAILED = 200, // Could not open playout. |
1007 ERROR_PLAY_DEVICE_MUTED, // Playout muted by OS. | 1059 ERROR_PLAY_DEVICE_MUTED, // Playout muted by OS. |
1008 ERROR_PLAY_DEVICE_REMOVED, // Playout removed while active. | 1060 ERROR_PLAY_DEVICE_REMOVED, // Playout removed while active. |
1009 ERROR_PLAY_RUNTIME_ERROR, // Errors in voice processing. | 1061 ERROR_PLAY_RUNTIME_ERROR, // Errors in voice processing. |
1010 ERROR_PLAY_SRTP_ERROR, // Generic SRTP failure. | 1062 ERROR_PLAY_SRTP_ERROR, // Generic SRTP failure. |
1011 ERROR_PLAY_SRTP_AUTH_FAILED, // Failed to authenticate packets. | 1063 ERROR_PLAY_SRTP_AUTH_FAILED, // Failed to authenticate packets. |
1012 ERROR_PLAY_SRTP_REPLAY, // Packet replay detected. | 1064 ERROR_PLAY_SRTP_REPLAY, // Packet replay detected. |
1013 }; | 1065 }; |
1014 | 1066 |
1015 VoiceMediaChannel() {} | 1067 VoiceMediaChannel() {} |
1016 virtual ~VoiceMediaChannel() {} | 1068 virtual ~VoiceMediaChannel() {} |
1069 // TODO(pthatcher): Remove SetSendCodecs, | |
1070 // SetSendRtpHeaderExtensions, SetMaxSendBandwidth, and SetOptions | |
1071 // once all implementations implement SetSendParameters. | |
1072 virtual bool SetSendParameters(const AudioSendParameters& params) { | |
1073 return (SetSendCodecs(params.codecs) && | |
1074 SetSendRtpHeaderExtensions(params.extensions) && | |
1075 SetMaxSendBandwidth(params.max_bandwidth_bps) && | |
1076 SetOptions(params.options)); | |
1077 } | |
1078 // TODO(pthatcher): Remove SetRecvCodecs and | |
1079 // SetRecvRtpHeaderExtensions once all implementations implement | |
1080 // SetRecvParameters. | |
1081 virtual bool SetRecvParameters(const AudioRecvParameters& params) { | |
1082 return (SetRecvCodecs(params.codecs) && | |
1083 SetRecvRtpHeaderExtensions(params.extensions)); | |
1084 } | |
1017 // Sets the codecs/payload types to be used for incoming media. | 1085 // Sets the codecs/payload types to be used for incoming media. |
1018 virtual bool SetRecvCodecs(const std::vector<AudioCodec>& codecs) = 0; | 1086 virtual bool SetRecvCodecs(const std::vector<AudioCodec>& codecs) = 0; |
1019 // Sets the codecs/payload types to be used for outgoing media. | 1087 // Sets the codecs/payload types to be used for outgoing media. |
1020 virtual bool SetSendCodecs(const std::vector<AudioCodec>& codecs) = 0; | 1088 virtual bool SetSendCodecs(const std::vector<AudioCodec>& codecs) = 0; |
1021 // Starts or stops playout of received audio. | 1089 // Starts or stops playout of received audio. |
1022 virtual bool SetPlayout(bool playout) = 0; | 1090 virtual bool SetPlayout(bool playout) = 0; |
1023 // Starts or stops sending (and potentially capture) of local audio. | 1091 // Starts or stops sending (and potentially capture) of local audio. |
1024 virtual bool SetSend(SendFlags flag) = 0; | 1092 virtual bool SetSend(SendFlags flag) = 0; |
1025 // Sets the renderer object to be used for the specified remote audio stream. | 1093 // Sets the renderer object to be used for the specified remote audio stream. |
1026 virtual bool SetRemoteRenderer(uint32 ssrc, AudioRenderer* renderer) = 0; | 1094 virtual bool SetRemoteRenderer(uint32 ssrc, AudioRenderer* renderer) = 0; |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1062 } | 1130 } |
1063 // Sets the media options to use. | 1131 // Sets the media options to use. |
1064 virtual bool SetOptions(const AudioOptions& options) = 0; | 1132 virtual bool SetOptions(const AudioOptions& options) = 0; |
1065 virtual bool GetOptions(AudioOptions* options) const = 0; | 1133 virtual bool GetOptions(AudioOptions* options) const = 0; |
1066 | 1134 |
1067 // Signal errors from MediaChannel. Arguments are: | 1135 // Signal errors from MediaChannel. Arguments are: |
1068 // ssrc(uint32), and error(VoiceMediaChannel::Error). | 1136 // ssrc(uint32), and error(VoiceMediaChannel::Error). |
1069 sigslot::signal2<uint32, VoiceMediaChannel::Error> SignalMediaError; | 1137 sigslot::signal2<uint32, VoiceMediaChannel::Error> SignalMediaError; |
1070 }; | 1138 }; |
1071 | 1139 |
1140 struct VideoSendParameters { | |
1141 std::string ToString() { | |
1142 std::ostringstream ost; | |
1143 ost << "{"; | |
1144 ost << "codecs: " << VectorToString(codecs) << ", "; | |
1145 ost << "extensions: " << VectorToString(extensions) << ", "; | |
1146 ost << "max_bandiwidth_bps: " << max_bandwidth_bps << ", "; | |
1147 ost << "options: " << options.ToString(); | |
1148 ost << "}"; | |
1149 return ost.str(); | |
1150 } | |
1151 | |
1152 std::vector<VideoCodec> codecs; | |
1153 std::vector<RtpHeaderExtension> extensions; | |
1154 // TODO(pthatcher): Move max_bandwidth_bps into VideoOptions. | |
1155 int max_bandwidth_bps; | |
1156 VideoOptions options; | |
1157 // TODO(pthatcher): Add "remote" streams. | |
1158 }; | |
1159 | |
1160 struct VideoRecvParameters { | |
1161 std::string ToString() { | |
1162 std::ostringstream ost; | |
1163 ost << "{"; | |
1164 ost << "codecs: " << VectorToString(codecs) << ", "; | |
1165 ost << "extensions: " << VectorToString(extensions); | |
1166 ost << "}"; | |
1167 return ost.str(); | |
1168 } | |
1169 | |
1170 std::vector<VideoCodec> codecs; | |
1171 std::vector<RtpHeaderExtension> extensions; | |
1172 // TODO(pthatcher): Add "local" streams. | |
1173 }; | |
1174 | |
1072 class VideoMediaChannel : public MediaChannel { | 1175 class VideoMediaChannel : public MediaChannel { |
1073 public: | 1176 public: |
1074 enum Error { | 1177 enum Error { |
1075 ERROR_NONE = 0, // No error. | 1178 ERROR_NONE = 0, // No error. |
1076 ERROR_OTHER, // Other errors. | 1179 ERROR_OTHER, // Other errors. |
1077 ERROR_REC_DEVICE_OPEN_FAILED = 100, // Could not open camera. | 1180 ERROR_REC_DEVICE_OPEN_FAILED = 100, // Could not open camera. |
1078 ERROR_REC_DEVICE_NO_DEVICE, // No camera. | 1181 ERROR_REC_DEVICE_NO_DEVICE, // No camera. |
1079 ERROR_REC_DEVICE_IN_USE, // Device is in already use. | 1182 ERROR_REC_DEVICE_IN_USE, // Device is in already use. |
1080 ERROR_REC_DEVICE_REMOVED, // Device is removed. | 1183 ERROR_REC_DEVICE_REMOVED, // Device is removed. |
1081 ERROR_REC_SRTP_ERROR, // Generic sender SRTP failure. | 1184 ERROR_REC_SRTP_ERROR, // Generic sender SRTP failure. |
1082 ERROR_REC_SRTP_AUTH_FAILED, // Failed to authenticate packets. | 1185 ERROR_REC_SRTP_AUTH_FAILED, // Failed to authenticate packets. |
1083 ERROR_REC_CPU_MAX_CANT_DOWNGRADE, // Can't downgrade capture anymore. | 1186 ERROR_REC_CPU_MAX_CANT_DOWNGRADE, // Can't downgrade capture anymore. |
1084 ERROR_PLAY_SRTP_ERROR = 200, // Generic receiver SRTP failure. | 1187 ERROR_PLAY_SRTP_ERROR = 200, // Generic receiver SRTP failure. |
1085 ERROR_PLAY_SRTP_AUTH_FAILED, // Failed to authenticate packets. | 1188 ERROR_PLAY_SRTP_AUTH_FAILED, // Failed to authenticate packets. |
1086 ERROR_PLAY_SRTP_REPLAY, // Packet replay detected. | 1189 ERROR_PLAY_SRTP_REPLAY, // Packet replay detected. |
1087 }; | 1190 }; |
1088 | 1191 |
1089 VideoMediaChannel() : renderer_(NULL) {} | 1192 VideoMediaChannel() : renderer_(NULL) {} |
1090 virtual ~VideoMediaChannel() {} | 1193 virtual ~VideoMediaChannel() {} |
1091 // Allow video channel to unhook itself from an associated voice channel. | 1194 // Allow video channel to unhook itself from an associated voice channel. |
1092 virtual void DetachVoiceChannel() = 0; | 1195 virtual void DetachVoiceChannel() = 0; |
1196 // TODO(pthatcher): Remove SetSendCodecs, | |
1197 // SetSendRtpHeaderExtensions, SetMaxSendBandwidth, and SetOptions | |
1198 // once all implementations implement SetSendParameters. | |
1199 virtual bool SetSendParameters(const VideoSendParameters& params) { | |
1200 return (SetSendCodecs(params.codecs) && | |
1201 SetSendRtpHeaderExtensions(params.extensions) && | |
1202 SetMaxSendBandwidth(params.max_bandwidth_bps) && | |
1203 SetOptions(params.options)); | |
1204 } | |
1205 // TODO(pthatcher): Remove SetRecvCodecs and | |
1206 // SetRecvRtpHeaderExtensions once all implementations implement | |
1207 // SetRecvParameters. | |
1208 virtual bool SetRecvParameters(const VideoRecvParameters& params) { | |
1209 return (SetRecvCodecs(params.codecs) && | |
1210 SetRecvRtpHeaderExtensions(params.extensions)); | |
1211 } | |
1093 // Sets the codecs/payload types to be used for incoming media. | 1212 // Sets the codecs/payload types to be used for incoming media. |
1094 virtual bool SetRecvCodecs(const std::vector<VideoCodec>& codecs) = 0; | 1213 virtual bool SetRecvCodecs(const std::vector<VideoCodec>& codecs) = 0; |
1095 // Sets the codecs/payload types to be used for outgoing media. | 1214 // Sets the codecs/payload types to be used for outgoing media. |
1096 virtual bool SetSendCodecs(const std::vector<VideoCodec>& codecs) = 0; | 1215 virtual bool SetSendCodecs(const std::vector<VideoCodec>& codecs) = 0; |
1097 // Gets the currently set codecs/payload types to be used for outgoing media. | 1216 // Gets the currently set codecs/payload types to be used for outgoing media. |
1098 virtual bool GetSendCodec(VideoCodec* send_codec) = 0; | 1217 virtual bool GetSendCodec(VideoCodec* send_codec) = 0; |
1099 // Sets the format of a specified outgoing stream. | 1218 // Sets the format of a specified outgoing stream. |
1100 virtual bool SetSendStreamFormat(uint32 ssrc, const VideoFormat& format) = 0; | 1219 virtual bool SetSendStreamFormat(uint32 ssrc, const VideoFormat& format) = 0; |
1101 // Starts or stops playout of received video. | 1220 // Starts or stops playout of received video. |
1102 virtual bool SetRender(bool render) = 0; | 1221 virtual bool SetRender(bool render) = 0; |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1186 // TODO(pthatcher): Make these true by default? | 1305 // TODO(pthatcher): Make these true by default? |
1187 ordered(false), | 1306 ordered(false), |
1188 reliable(false), | 1307 reliable(false), |
1189 max_rtx_count(0), | 1308 max_rtx_count(0), |
1190 max_rtx_ms(0) { | 1309 max_rtx_ms(0) { |
1191 } | 1310 } |
1192 }; | 1311 }; |
1193 | 1312 |
1194 enum SendDataResult { SDR_SUCCESS, SDR_ERROR, SDR_BLOCK }; | 1313 enum SendDataResult { SDR_SUCCESS, SDR_ERROR, SDR_BLOCK }; |
1195 | 1314 |
1315 struct DataSendParameters { | |
1316 std::string ToString() { | |
1317 std::ostringstream ost; | |
1318 ost << "{"; | |
1319 ost << "codecs: " << VectorToString(codecs) << ", "; | |
1320 ost << "max_bandiwidth_bps: " << max_bandwidth_bps; | |
1321 ost << "}"; | |
1322 return ost.str(); | |
1323 } | |
1324 | |
1325 std::vector<DataCodec> codecs; | |
1326 // TODO(pthatcher): Move max_bandwidth_bps into DataOptions. | |
1327 int max_bandwidth_bps; | |
1328 // TODO(pthatcher): Add "remote" streams. | |
1329 }; | |
1330 | |
1331 struct DataRecvParameters { | |
1332 std::string ToString() { | |
1333 std::ostringstream ost; | |
1334 ost << "{"; | |
1335 ost << "codecs: " << VectorToString(codecs); | |
1336 ost << "}"; | |
1337 return ost.str(); | |
1338 } | |
1339 | |
1340 std::vector<DataCodec> codecs; | |
1341 // TODO(pthatcher): Add "local" streams. | |
1342 }; | |
1343 | |
1196 class DataMediaChannel : public MediaChannel { | 1344 class DataMediaChannel : public MediaChannel { |
1197 public: | 1345 public: |
1198 enum Error { | 1346 enum Error { |
1199 ERROR_NONE = 0, // No error. | 1347 ERROR_NONE = 0, // No error. |
1200 ERROR_OTHER, // Other errors. | 1348 ERROR_OTHER, // Other errors. |
1201 ERROR_SEND_SRTP_ERROR = 200, // Generic SRTP failure. | 1349 ERROR_SEND_SRTP_ERROR = 200, // Generic SRTP failure. |
1202 ERROR_SEND_SRTP_AUTH_FAILED, // Failed to authenticate packets. | 1350 ERROR_SEND_SRTP_AUTH_FAILED, // Failed to authenticate packets. |
1203 ERROR_RECV_SRTP_ERROR, // Generic SRTP failure. | 1351 ERROR_RECV_SRTP_ERROR, // Generic SRTP failure. |
1204 ERROR_RECV_SRTP_AUTH_FAILED, // Failed to authenticate packets. | 1352 ERROR_RECV_SRTP_AUTH_FAILED, // Failed to authenticate packets. |
1205 ERROR_RECV_SRTP_REPLAY, // Packet replay detected. | 1353 ERROR_RECV_SRTP_REPLAY, // Packet replay detected. |
1206 }; | 1354 }; |
1207 | 1355 |
1208 virtual ~DataMediaChannel() {} | 1356 virtual ~DataMediaChannel() {} |
1209 | 1357 |
1358 // TODO(pthatcher): Remove SetSendCodecs, | |
1359 // SetSendRtpHeaderExtensions, SetMaxSendBandwidth, and SetOptions | |
1360 // once all implementations implement SetSendParameters. | |
1361 virtual bool SetSendParameters(const DataSendParameters& params) { | |
1362 return (SetSendCodecs(params.codecs) && | |
1363 SetMaxSendBandwidth(params.max_bandwidth_bps)); | |
1364 } | |
1365 // TODO(pthatcher): Remove SetRecvCodecs and | |
1366 // SetRecvRtpHeaderExtensions once all implementations implement | |
1367 // SetRecvParameters. | |
1368 virtual bool SetRecvParameters(const DataRecvParameters& params) { | |
1369 return SetRecvCodecs(params.codecs); | |
1370 } | |
1210 virtual bool SetSendCodecs(const std::vector<DataCodec>& codecs) = 0; | 1371 virtual bool SetSendCodecs(const std::vector<DataCodec>& codecs) = 0; |
1211 virtual bool SetRecvCodecs(const std::vector<DataCodec>& codecs) = 0; | 1372 virtual bool SetRecvCodecs(const std::vector<DataCodec>& codecs) = 0; |
1212 | 1373 |
1213 virtual bool MuteStream(uint32 ssrc, bool on) { return false; } | 1374 virtual bool MuteStream(uint32 ssrc, bool on) { return false; } |
1214 // TODO(pthatcher): Implement this. | 1375 // TODO(pthatcher): Implement this. |
1215 virtual bool GetStats(DataMediaInfo* info) { return true; } | 1376 virtual bool GetStats(DataMediaInfo* info) { return true; } |
1216 | 1377 |
1217 virtual bool SetSend(bool send) = 0; | 1378 virtual bool SetSend(bool send) = 0; |
1218 virtual bool SetReceive(bool receive) = 0; | 1379 virtual bool SetReceive(bool receive) = 0; |
1219 | 1380 |
(...skipping 11 matching lines...) Expand all Loading... | |
1231 // Signal when the media channel is ready to send the stream. Arguments are: | 1392 // Signal when the media channel is ready to send the stream. Arguments are: |
1232 // writable(bool) | 1393 // writable(bool) |
1233 sigslot::signal1<bool> SignalReadyToSend; | 1394 sigslot::signal1<bool> SignalReadyToSend; |
1234 // Signal for notifying that the remote side has closed the DataChannel. | 1395 // Signal for notifying that the remote side has closed the DataChannel. |
1235 sigslot::signal1<uint32> SignalStreamClosedRemotely; | 1396 sigslot::signal1<uint32> SignalStreamClosedRemotely; |
1236 }; | 1397 }; |
1237 | 1398 |
1238 } // namespace cricket | 1399 } // namespace cricket |
1239 | 1400 |
1240 #endif // TALK_MEDIA_BASE_MEDIACHANNEL_H_ | 1401 #endif // TALK_MEDIA_BASE_MEDIACHANNEL_H_ |
OLD | NEW |