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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: talk/media/base/mediachannel.h
diff --git a/talk/media/base/mediachannel.h b/talk/media/base/mediachannel.h
index e7af7a76aa6368529a26d0dc19e53eaac2956824..d46d9b72ba9f4580b97965c544bcad51cba44667 100644
--- a/talk/media/base/mediachannel.h
+++ b/talk/media/base/mediachannel.h
@@ -138,6 +138,17 @@ static std::string ToStringIfSet(const char* key, const Settable<T>& val) {
return str;
}
+template <class T>
+static std::string VectorToString(const std::vector<T>& vals) {
+ std::ostringstream ost;
+ ost << "[";
+ for (const T& val : vals) {
+ 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.
+ }
+ ost << "]";
+ return ost.str();
+}
+
// Options that can be applied to a VoiceMediaChannel or a VoiceMediaEngine.
// Used to be flags, but that makes it hard to selectively apply options.
// We are moving all of the setting of options to structs like this,
@@ -327,7 +338,6 @@ struct VideoOptions {
change.system_low_adaptation_threshhold);
system_high_adaptation_threshhold.SetFrom(
change.system_high_adaptation_threshhold);
- buffered_mode_latency.SetFrom(change.buffered_mode_latency);
dscp.SetFrom(change.dscp);
suspend_below_min_bitrate.SetFrom(change.suspend_below_min_bitrate);
unsignalled_recv_stream_limit.SetFrom(change.unsignalled_recv_stream_limit);
@@ -356,7 +366,7 @@ struct VideoOptions {
o.system_low_adaptation_threshhold &&
system_high_adaptation_threshhold ==
o.system_high_adaptation_threshhold &&
- buffered_mode_latency == o.buffered_mode_latency && dscp == o.dscp &&
+ dscp == o.dscp &&
suspend_below_min_bitrate == o.suspend_below_min_bitrate &&
unsignalled_recv_stream_limit == o.unsignalled_recv_stream_limit &&
use_simulcast_adapter == o.use_simulcast_adapter &&
@@ -385,7 +395,6 @@ struct VideoOptions {
ost << ToStringIfSet("process", process_adaptation_threshhold);
ost << ToStringIfSet("low", system_low_adaptation_threshhold);
ost << ToStringIfSet("high", system_high_adaptation_threshhold);
- ost << ToStringIfSet("buffered mode latency", buffered_mode_latency);
ost << ToStringIfSet("dscp", dscp);
ost << ToStringIfSet("suspend below min bitrate",
suspend_below_min_bitrate);
@@ -439,8 +448,6 @@ struct VideoOptions {
Settable<float> system_low_adaptation_threshhold;
// High threshhold for cpu adaptation. (Adapt down)
Settable<float> system_high_adaptation_threshhold;
- // Specify buffered mode latency in milliseconds.
- Settable<int> buffered_mode_latency;
// Set DSCP value for packet sent from video channel.
Settable<bool> dscp;
// Enable WebRTC suspension of video. No video frames will be sent when the
@@ -457,9 +464,6 @@ struct VideoOptions {
struct RtpHeaderExtension {
RtpHeaderExtension() : id(0) {}
RtpHeaderExtension(const std::string& u, int i) : uri(u), id(i) {}
- std::string uri;
- int id;
- // TODO(juberti): SendRecv direction;
bool operator==(const RtpHeaderExtension& ext) const {
// id is a reserved word in objective-c. Therefore the id attribute has to
@@ -467,6 +471,19 @@ struct RtpHeaderExtension {
return this->id == ext.id &&
uri == ext.uri;
}
+
+ std::string ToString() const {
+ std::ostringstream ost;
+ ost << "{";
+ ost << "id: , " << id;
+ ost << "uri: " << uri;
+ ost << "}";
+ return ost.str();
+ }
+
+ std::string uri;
+ int id;
+ // TODO(juberti): SendRecv direction;
};
// Returns the named header extension if found among all extensions, NULL
@@ -989,6 +1006,45 @@ struct DataMediaInfo {
std::vector<DataReceiverInfo> receivers;
};
+template <class Codec>
+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.
+ virtual std::string ToString() {
+ std::ostringstream ost;
+ ost << "{";
+ ost << "codecs: " << VectorToString(codecs) << ", ";
+ ost << "extensions: " << VectorToString(extensions);
+ ost << "}";
+ return ost.str();
+ }
+
+ std::vector<Codec> codecs;
+ std::vector<RtpHeaderExtension> extensions;
+ // TODO(pthatcher): Add streams.
+};
+
+template <class Codec, class Options>
+struct RtpSendParameters : RtpParameters<Codec> {
+ std::string ToString() override {
+ std::ostringstream ost;
+ ost << "{";
+ ost << "codecs: " << VectorToString(this->codecs) << ", ";
+ ost << "extensions: " << VectorToString(this->extensions) << ", ";
+ ost << "max_bandiwidth_bps: " << max_bandwidth_bps << ", ";
+ ost << "options: " << options.ToString();
+ ost << "}";
+ return ost.str();
+ }
+
+ int max_bandwidth_bps = -1;
+ Options options;
+};
+
+struct AudioSendParameters : RtpSendParameters<AudioCodec, AudioOptions> {
+};
+
+struct AudioRecvParameters : RtpParameters<AudioCodec> {
+};
+
class VoiceMediaChannel : public MediaChannel {
public:
enum Error {
@@ -1014,6 +1070,22 @@ class VoiceMediaChannel : public MediaChannel {
VoiceMediaChannel() {}
virtual ~VoiceMediaChannel() {}
+ // TODO(pthatcher): Remove SetSendCodecs,
+ // SetSendRtpHeaderExtensions, SetMaxSendBandwidth, and SetOptions
+ // once all implementations implement SetSendParameters.
+ virtual bool SetSendParameters(const AudioSendParameters& params) {
+ return (SetSendCodecs(params.codecs) &&
+ SetSendRtpHeaderExtensions(params.extensions) &&
+ SetMaxSendBandwidth(params.max_bandwidth_bps) &&
+ SetOptions(params.options));
+ }
+ // TODO(pthatcher): Remove SetRecvCodecs and
+ // SetRecvRtpHeaderExtensions once all implementations implement
+ // SetRecvParameters.
+ virtual bool SetRecvParameters(const AudioRecvParameters& params) {
+ return (SetRecvCodecs(params.codecs) &&
+ SetRecvRtpHeaderExtensions(params.extensions));
+ }
// Sets the codecs/payload types to be used for incoming media.
virtual bool SetRecvCodecs(const std::vector<AudioCodec>& codecs) = 0;
// Sets the codecs/payload types to be used for outgoing media.
@@ -1069,6 +1141,12 @@ class VoiceMediaChannel : public MediaChannel {
sigslot::signal2<uint32, VoiceMediaChannel::Error> SignalMediaError;
};
+struct VideoSendParameters : RtpSendParameters<VideoCodec, VideoOptions> {
+};
+
+struct VideoRecvParameters : RtpParameters<VideoCodec> {
+};
+
class VideoMediaChannel : public MediaChannel {
public:
enum Error {
@@ -1090,6 +1168,22 @@ class VideoMediaChannel : public MediaChannel {
virtual ~VideoMediaChannel() {}
// Allow video channel to unhook itself from an associated voice channel.
virtual void DetachVoiceChannel() = 0;
+ // TODO(pthatcher): Remove SetSendCodecs,
+ // SetSendRtpHeaderExtensions, SetMaxSendBandwidth, and SetOptions
+ // once all implementations implement SetSendParameters.
+ virtual bool SetSendParameters(const VideoSendParameters& params) {
+ return (SetSendCodecs(params.codecs) &&
+ SetSendRtpHeaderExtensions(params.extensions) &&
+ SetMaxSendBandwidth(params.max_bandwidth_bps) &&
+ SetOptions(params.options));
+ }
+ // TODO(pthatcher): Remove SetRecvCodecs and
+ // SetRecvRtpHeaderExtensions once all implementations implement
+ // SetRecvParameters.
+ virtual bool SetRecvParameters(const VideoRecvParameters& params) {
+ return (SetRecvCodecs(params.codecs) &&
+ SetRecvRtpHeaderExtensions(params.extensions));
+ }
// Sets the codecs/payload types to be used for incoming media.
virtual bool SetRecvCodecs(const std::vector<VideoCodec>& codecs) = 0;
// Sets the codecs/payload types to be used for outgoing media.
@@ -1193,6 +1287,27 @@ struct SendDataParams {
enum SendDataResult { SDR_SUCCESS, SDR_ERROR, SDR_BLOCK };
+struct DataOptions {
+ std::string ToString() {
+ return "{}";
+ }
+};
+
+struct DataSendParameters : RtpSendParameters<DataCodec, DataOptions> {
+ std::string ToString() {
+ std::ostringstream ost;
+ // Options and extensions aren't used.
+ ost << "{";
+ ost << "codecs: " << VectorToString(codecs) << ", ";
+ ost << "max_bandiwidth_bps: " << max_bandwidth_bps;
+ ost << "}";
+ return ost.str();
+ }
+};
+
+struct DataRecvParameters : RtpParameters<DataCodec> {
+};
+
class DataMediaChannel : public MediaChannel {
public:
enum Error {
@@ -1207,6 +1322,19 @@ class DataMediaChannel : public MediaChannel {
virtual ~DataMediaChannel() {}
+ // TODO(pthatcher): Remove SetSendCodecs,
+ // SetSendRtpHeaderExtensions, SetMaxSendBandwidth, and SetOptions
+ // once all implementations implement SetSendParameters.
+ virtual bool SetSendParameters(const DataSendParameters& params) {
+ return (SetSendCodecs(params.codecs) &&
+ SetMaxSendBandwidth(params.max_bandwidth_bps));
+ }
+ // TODO(pthatcher): Remove SetRecvCodecs and
+ // SetRecvRtpHeaderExtensions once all implementations implement
+ // SetRecvParameters.
+ virtual bool SetRecvParameters(const DataRecvParameters& params) {
+ return SetRecvCodecs(params.codecs);
+ }
virtual bool SetSendCodecs(const std::vector<DataCodec>& codecs) = 0;
virtual bool SetRecvCodecs(const std::vector<DataCodec>& codecs) = 0;

Powered by Google App Engine
This is Rietveld 408576698