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

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

Issue 1229283003: Refactor the relationship between BaseChannel and MediaChannel so that we send over all the paramet… (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: remove duplication Created 5 years, 5 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 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
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/16 14:46:47 Don't add "," to end of string. Also should this b
pthatcher1 2015/07/16 22:48:00 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
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
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
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 template <class Codec>
1010 struct RtpParameters {
pbos-webrtc 2015/07/16 14:39:17 This is part of another CL and shouldn't be landed
pthatcher1 2015/07/16 22:48:00 Acknowledged.
1011 virtual std::string ToString() {
1012 std::ostringstream ost;
1013 ost << "{";
1014 ost << "codecs: " << VectorToString(codecs) << ", ";
1015 ost << "extensions: " << VectorToString(extensions);
1016 ost << "}";
1017 return ost.str();
1018 }
1019
1020 std::vector<Codec> codecs;
1021 std::vector<RtpHeaderExtension> extensions;
1022 // TODO(pthatcher): Add streams.
1023 };
1024
1025 template <class Codec, class Options>
1026 struct RtpSendParameters : RtpParameters<Codec> {
1027 std::string ToString() override {
1028 std::ostringstream ost;
1029 ost << "{";
1030 ost << "codecs: " << VectorToString(this->codecs) << ", ";
1031 ost << "extensions: " << VectorToString(this->extensions) << ", ";
1032 ost << "max_bandiwidth_bps: " << max_bandwidth_bps << ", ";
1033 ost << "options: " << options.ToString();
1034 ost << "}";
1035 return ost.str();
1036 }
1037
1038 int max_bandwidth_bps = -1;
1039 Options options;
1040 };
1041
1042 struct AudioSendParameters : RtpSendParameters<AudioCodec, AudioOptions> {
1043 };
1044
1045 struct AudioRecvParameters : RtpParameters<AudioCodec> {
1046 };
1047
992 class VoiceMediaChannel : public MediaChannel { 1048 class VoiceMediaChannel : public MediaChannel {
993 public: 1049 public:
994 enum Error { 1050 enum Error {
995 ERROR_NONE = 0, // No error. 1051 ERROR_NONE = 0, // No error.
996 ERROR_OTHER, // Other errors. 1052 ERROR_OTHER, // Other errors.
997 ERROR_REC_DEVICE_OPEN_FAILED = 100, // Could not open mic. 1053 ERROR_REC_DEVICE_OPEN_FAILED = 100, // Could not open mic.
998 ERROR_REC_DEVICE_MUTED, // Mic was muted by OS. 1054 ERROR_REC_DEVICE_MUTED, // Mic was muted by OS.
999 ERROR_REC_DEVICE_SILENT, // No background noise picked up. 1055 ERROR_REC_DEVICE_SILENT, // No background noise picked up.
1000 ERROR_REC_DEVICE_SATURATION, // Mic input is clipping. 1056 ERROR_REC_DEVICE_SATURATION, // Mic input is clipping.
1001 ERROR_REC_DEVICE_REMOVED, // Mic was removed while active. 1057 ERROR_REC_DEVICE_REMOVED, // Mic was removed while active.
1002 ERROR_REC_RUNTIME_ERROR, // Processing is encountering errors. 1058 ERROR_REC_RUNTIME_ERROR, // Processing is encountering errors.
1003 ERROR_REC_SRTP_ERROR, // Generic SRTP failure. 1059 ERROR_REC_SRTP_ERROR, // Generic SRTP failure.
1004 ERROR_REC_SRTP_AUTH_FAILED, // Failed to authenticate packets. 1060 ERROR_REC_SRTP_AUTH_FAILED, // Failed to authenticate packets.
1005 ERROR_REC_TYPING_NOISE_DETECTED, // Typing noise is detected. 1061 ERROR_REC_TYPING_NOISE_DETECTED, // Typing noise is detected.
1006 ERROR_PLAY_DEVICE_OPEN_FAILED = 200, // Could not open playout. 1062 ERROR_PLAY_DEVICE_OPEN_FAILED = 200, // Could not open playout.
1007 ERROR_PLAY_DEVICE_MUTED, // Playout muted by OS. 1063 ERROR_PLAY_DEVICE_MUTED, // Playout muted by OS.
1008 ERROR_PLAY_DEVICE_REMOVED, // Playout removed while active. 1064 ERROR_PLAY_DEVICE_REMOVED, // Playout removed while active.
1009 ERROR_PLAY_RUNTIME_ERROR, // Errors in voice processing. 1065 ERROR_PLAY_RUNTIME_ERROR, // Errors in voice processing.
1010 ERROR_PLAY_SRTP_ERROR, // Generic SRTP failure. 1066 ERROR_PLAY_SRTP_ERROR, // Generic SRTP failure.
1011 ERROR_PLAY_SRTP_AUTH_FAILED, // Failed to authenticate packets. 1067 ERROR_PLAY_SRTP_AUTH_FAILED, // Failed to authenticate packets.
1012 ERROR_PLAY_SRTP_REPLAY, // Packet replay detected. 1068 ERROR_PLAY_SRTP_REPLAY, // Packet replay detected.
1013 }; 1069 };
1014 1070
1015 VoiceMediaChannel() {} 1071 VoiceMediaChannel() {}
1016 virtual ~VoiceMediaChannel() {} 1072 virtual ~VoiceMediaChannel() {}
1073 // TODO(pthatcher): Remove SetSendCodecs,
1074 // SetSendRtpHeaderExtensions, SetMaxSendBandwidth, and SetOptions
1075 // once all implementations implement SetSendParameters.
1076 virtual bool SetSendParameters(const AudioSendParameters& params) {
1077 return (SetSendCodecs(params.codecs) &&
1078 SetSendRtpHeaderExtensions(params.extensions) &&
1079 SetMaxSendBandwidth(params.max_bandwidth_bps) &&
1080 SetOptions(params.options));
1081 }
1082 // TODO(pthatcher): Remove SetRecvCodecs and
1083 // SetRecvRtpHeaderExtensions once all implementations implement
1084 // SetRecvParameters.
1085 virtual bool SetRecvParameters(const AudioRecvParameters& params) {
1086 return (SetRecvCodecs(params.codecs) &&
1087 SetRecvRtpHeaderExtensions(params.extensions));
1088 }
1017 // Sets the codecs/payload types to be used for incoming media. 1089 // Sets the codecs/payload types to be used for incoming media.
1018 virtual bool SetRecvCodecs(const std::vector<AudioCodec>& codecs) = 0; 1090 virtual bool SetRecvCodecs(const std::vector<AudioCodec>& codecs) = 0;
1019 // Sets the codecs/payload types to be used for outgoing media. 1091 // Sets the codecs/payload types to be used for outgoing media.
1020 virtual bool SetSendCodecs(const std::vector<AudioCodec>& codecs) = 0; 1092 virtual bool SetSendCodecs(const std::vector<AudioCodec>& codecs) = 0;
1021 // Starts or stops playout of received audio. 1093 // Starts or stops playout of received audio.
1022 virtual bool SetPlayout(bool playout) = 0; 1094 virtual bool SetPlayout(bool playout) = 0;
1023 // Starts or stops sending (and potentially capture) of local audio. 1095 // Starts or stops sending (and potentially capture) of local audio.
1024 virtual bool SetSend(SendFlags flag) = 0; 1096 virtual bool SetSend(SendFlags flag) = 0;
1025 // Sets the renderer object to be used for the specified remote audio stream. 1097 // Sets the renderer object to be used for the specified remote audio stream.
1026 virtual bool SetRemoteRenderer(uint32 ssrc, AudioRenderer* renderer) = 0; 1098 virtual bool SetRemoteRenderer(uint32 ssrc, AudioRenderer* renderer) = 0;
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
1062 } 1134 }
1063 // Sets the media options to use. 1135 // Sets the media options to use.
1064 virtual bool SetOptions(const AudioOptions& options) = 0; 1136 virtual bool SetOptions(const AudioOptions& options) = 0;
1065 virtual bool GetOptions(AudioOptions* options) const = 0; 1137 virtual bool GetOptions(AudioOptions* options) const = 0;
1066 1138
1067 // Signal errors from MediaChannel. Arguments are: 1139 // Signal errors from MediaChannel. Arguments are:
1068 // ssrc(uint32), and error(VoiceMediaChannel::Error). 1140 // ssrc(uint32), and error(VoiceMediaChannel::Error).
1069 sigslot::signal2<uint32, VoiceMediaChannel::Error> SignalMediaError; 1141 sigslot::signal2<uint32, VoiceMediaChannel::Error> SignalMediaError;
1070 }; 1142 };
1071 1143
1144 struct VideoSendParameters : RtpSendParameters<VideoCodec, VideoOptions> {
1145 };
1146
1147 struct VideoRecvParameters : RtpParameters<VideoCodec> {
1148 };
1149
1072 class VideoMediaChannel : public MediaChannel { 1150 class VideoMediaChannel : public MediaChannel {
1073 public: 1151 public:
1074 enum Error { 1152 enum Error {
1075 ERROR_NONE = 0, // No error. 1153 ERROR_NONE = 0, // No error.
1076 ERROR_OTHER, // Other errors. 1154 ERROR_OTHER, // Other errors.
1077 ERROR_REC_DEVICE_OPEN_FAILED = 100, // Could not open camera. 1155 ERROR_REC_DEVICE_OPEN_FAILED = 100, // Could not open camera.
1078 ERROR_REC_DEVICE_NO_DEVICE, // No camera. 1156 ERROR_REC_DEVICE_NO_DEVICE, // No camera.
1079 ERROR_REC_DEVICE_IN_USE, // Device is in already use. 1157 ERROR_REC_DEVICE_IN_USE, // Device is in already use.
1080 ERROR_REC_DEVICE_REMOVED, // Device is removed. 1158 ERROR_REC_DEVICE_REMOVED, // Device is removed.
1081 ERROR_REC_SRTP_ERROR, // Generic sender SRTP failure. 1159 ERROR_REC_SRTP_ERROR, // Generic sender SRTP failure.
1082 ERROR_REC_SRTP_AUTH_FAILED, // Failed to authenticate packets. 1160 ERROR_REC_SRTP_AUTH_FAILED, // Failed to authenticate packets.
1083 ERROR_REC_CPU_MAX_CANT_DOWNGRADE, // Can't downgrade capture anymore. 1161 ERROR_REC_CPU_MAX_CANT_DOWNGRADE, // Can't downgrade capture anymore.
1084 ERROR_PLAY_SRTP_ERROR = 200, // Generic receiver SRTP failure. 1162 ERROR_PLAY_SRTP_ERROR = 200, // Generic receiver SRTP failure.
1085 ERROR_PLAY_SRTP_AUTH_FAILED, // Failed to authenticate packets. 1163 ERROR_PLAY_SRTP_AUTH_FAILED, // Failed to authenticate packets.
1086 ERROR_PLAY_SRTP_REPLAY, // Packet replay detected. 1164 ERROR_PLAY_SRTP_REPLAY, // Packet replay detected.
1087 }; 1165 };
1088 1166
1089 VideoMediaChannel() : renderer_(NULL) {} 1167 VideoMediaChannel() : renderer_(NULL) {}
1090 virtual ~VideoMediaChannel() {} 1168 virtual ~VideoMediaChannel() {}
1091 // Allow video channel to unhook itself from an associated voice channel. 1169 // Allow video channel to unhook itself from an associated voice channel.
1092 virtual void DetachVoiceChannel() = 0; 1170 virtual void DetachVoiceChannel() = 0;
1171 // TODO(pthatcher): Remove SetSendCodecs,
1172 // SetSendRtpHeaderExtensions, SetMaxSendBandwidth, and SetOptions
1173 // once all implementations implement SetSendParameters.
1174 virtual bool SetSendParameters(const VideoSendParameters& params) {
1175 return (SetSendCodecs(params.codecs) &&
1176 SetSendRtpHeaderExtensions(params.extensions) &&
1177 SetMaxSendBandwidth(params.max_bandwidth_bps) &&
1178 SetOptions(params.options));
1179 }
1180 // TODO(pthatcher): Remove SetRecvCodecs and
1181 // SetRecvRtpHeaderExtensions once all implementations implement
1182 // SetRecvParameters.
1183 virtual bool SetRecvParameters(const VideoRecvParameters& params) {
1184 return (SetRecvCodecs(params.codecs) &&
1185 SetRecvRtpHeaderExtensions(params.extensions));
1186 }
1093 // Sets the codecs/payload types to be used for incoming media. 1187 // Sets the codecs/payload types to be used for incoming media.
1094 virtual bool SetRecvCodecs(const std::vector<VideoCodec>& codecs) = 0; 1188 virtual bool SetRecvCodecs(const std::vector<VideoCodec>& codecs) = 0;
1095 // Sets the codecs/payload types to be used for outgoing media. 1189 // Sets the codecs/payload types to be used for outgoing media.
1096 virtual bool SetSendCodecs(const std::vector<VideoCodec>& codecs) = 0; 1190 virtual bool SetSendCodecs(const std::vector<VideoCodec>& codecs) = 0;
1097 // Gets the currently set codecs/payload types to be used for outgoing media. 1191 // Gets the currently set codecs/payload types to be used for outgoing media.
1098 virtual bool GetSendCodec(VideoCodec* send_codec) = 0; 1192 virtual bool GetSendCodec(VideoCodec* send_codec) = 0;
1099 // Sets the format of a specified outgoing stream. 1193 // Sets the format of a specified outgoing stream.
1100 virtual bool SetSendStreamFormat(uint32 ssrc, const VideoFormat& format) = 0; 1194 virtual bool SetSendStreamFormat(uint32 ssrc, const VideoFormat& format) = 0;
1101 // Starts or stops playout of received video. 1195 // Starts or stops playout of received video.
1102 virtual bool SetRender(bool render) = 0; 1196 virtual bool SetRender(bool render) = 0;
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
1186 // TODO(pthatcher): Make these true by default? 1280 // TODO(pthatcher): Make these true by default?
1187 ordered(false), 1281 ordered(false),
1188 reliable(false), 1282 reliable(false),
1189 max_rtx_count(0), 1283 max_rtx_count(0),
1190 max_rtx_ms(0) { 1284 max_rtx_ms(0) {
1191 } 1285 }
1192 }; 1286 };
1193 1287
1194 enum SendDataResult { SDR_SUCCESS, SDR_ERROR, SDR_BLOCK }; 1288 enum SendDataResult { SDR_SUCCESS, SDR_ERROR, SDR_BLOCK };
1195 1289
1290 struct DataOptions {
1291 std::string ToString() {
1292 return "{}";
1293 }
1294 };
1295
1296 struct DataSendParameters : RtpSendParameters<DataCodec, DataOptions> {
1297 std::string ToString() {
1298 std::ostringstream ost;
1299 // Options and extensions aren't used.
1300 ost << "{";
1301 ost << "codecs: " << VectorToString(codecs) << ", ";
1302 ost << "max_bandiwidth_bps: " << max_bandwidth_bps;
1303 ost << "}";
1304 return ost.str();
1305 }
1306 };
1307
1308 struct DataRecvParameters : RtpParameters<DataCodec> {
1309 };
1310
1196 class DataMediaChannel : public MediaChannel { 1311 class DataMediaChannel : public MediaChannel {
1197 public: 1312 public:
1198 enum Error { 1313 enum Error {
1199 ERROR_NONE = 0, // No error. 1314 ERROR_NONE = 0, // No error.
1200 ERROR_OTHER, // Other errors. 1315 ERROR_OTHER, // Other errors.
1201 ERROR_SEND_SRTP_ERROR = 200, // Generic SRTP failure. 1316 ERROR_SEND_SRTP_ERROR = 200, // Generic SRTP failure.
1202 ERROR_SEND_SRTP_AUTH_FAILED, // Failed to authenticate packets. 1317 ERROR_SEND_SRTP_AUTH_FAILED, // Failed to authenticate packets.
1203 ERROR_RECV_SRTP_ERROR, // Generic SRTP failure. 1318 ERROR_RECV_SRTP_ERROR, // Generic SRTP failure.
1204 ERROR_RECV_SRTP_AUTH_FAILED, // Failed to authenticate packets. 1319 ERROR_RECV_SRTP_AUTH_FAILED, // Failed to authenticate packets.
1205 ERROR_RECV_SRTP_REPLAY, // Packet replay detected. 1320 ERROR_RECV_SRTP_REPLAY, // Packet replay detected.
1206 }; 1321 };
1207 1322
1208 virtual ~DataMediaChannel() {} 1323 virtual ~DataMediaChannel() {}
1209 1324
1325 // TODO(pthatcher): Remove SetSendCodecs,
1326 // SetSendRtpHeaderExtensions, SetMaxSendBandwidth, and SetOptions
1327 // once all implementations implement SetSendParameters.
1328 virtual bool SetSendParameters(const DataSendParameters& params) {
1329 return (SetSendCodecs(params.codecs) &&
1330 SetMaxSendBandwidth(params.max_bandwidth_bps));
1331 }
1332 // TODO(pthatcher): Remove SetRecvCodecs and
1333 // SetRecvRtpHeaderExtensions once all implementations implement
1334 // SetRecvParameters.
1335 virtual bool SetRecvParameters(const DataRecvParameters& params) {
1336 return SetRecvCodecs(params.codecs);
1337 }
1210 virtual bool SetSendCodecs(const std::vector<DataCodec>& codecs) = 0; 1338 virtual bool SetSendCodecs(const std::vector<DataCodec>& codecs) = 0;
1211 virtual bool SetRecvCodecs(const std::vector<DataCodec>& codecs) = 0; 1339 virtual bool SetRecvCodecs(const std::vector<DataCodec>& codecs) = 0;
1212 1340
1213 virtual bool MuteStream(uint32 ssrc, bool on) { return false; } 1341 virtual bool MuteStream(uint32 ssrc, bool on) { return false; }
1214 // TODO(pthatcher): Implement this. 1342 // TODO(pthatcher): Implement this.
1215 virtual bool GetStats(DataMediaInfo* info) { return true; } 1343 virtual bool GetStats(DataMediaInfo* info) { return true; }
1216 1344
1217 virtual bool SetSend(bool send) = 0; 1345 virtual bool SetSend(bool send) = 0;
1218 virtual bool SetReceive(bool receive) = 0; 1346 virtual bool SetReceive(bool receive) = 0;
1219 1347
(...skipping 11 matching lines...) Expand all
1231 // Signal when the media channel is ready to send the stream. Arguments are: 1359 // Signal when the media channel is ready to send the stream. Arguments are:
1232 // writable(bool) 1360 // writable(bool)
1233 sigslot::signal1<bool> SignalReadyToSend; 1361 sigslot::signal1<bool> SignalReadyToSend;
1234 // Signal for notifying that the remote side has closed the DataChannel. 1362 // Signal for notifying that the remote side has closed the DataChannel.
1235 sigslot::signal1<uint32> SignalStreamClosedRemotely; 1363 sigslot::signal1<uint32> SignalStreamClosedRemotely;
1236 }; 1364 };
1237 1365
1238 } // namespace cricket 1366 } // namespace cricket
1239 1367
1240 #endif // TALK_MEDIA_BASE_MEDIACHANNEL_H_ 1368 #endif // TALK_MEDIA_BASE_MEDIACHANNEL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698