Commit defa5c66 authored by Antonio Gomes's avatar Antonio Gomes Committed by Commit Bot

Switch WebMediaTrackConstraintSet away from std types

This CL migrates WebMediaTrackConstraintSet away from both std::string
and std::vector, in favor of their WTF counterparts.

Next, the class itself will be renamed from WebMediaTrackConstraintSet
to MediaTrackConstraintSetPlatform (since MediaTrackConstraintSet exists).

BUG=923394
R=guidou@chromium.org, haraken@chromium.org

Change-Id: I310362d7b8cc2694f34b23724b022f68458808e8
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1986130Reviewed-by: default avatarKentaro Hara <haraken@chromium.org>
Commit-Queue: Antonio Gomes <tonikitoo@igalia.com>
Cr-Commit-Position: refs/heads/master@{#728210}
parent aad41255
...@@ -78,7 +78,7 @@ TEST(MediaTrackConstraintsTest, ConstraintName) { ...@@ -78,7 +78,7 @@ TEST(MediaTrackConstraintsTest, ConstraintName) {
TEST(MediaTrackConstraintsTest, MandatoryChecks) { TEST(MediaTrackConstraintsTest, MandatoryChecks) {
WebMediaTrackConstraintSet the_set; WebMediaTrackConstraintSet the_set;
std::string found_name; String found_name;
EXPECT_FALSE(the_set.HasMandatory()); EXPECT_FALSE(the_set.HasMandatory());
EXPECT_FALSE(the_set.HasMandatoryOutsideSet({"width"}, found_name)); EXPECT_FALSE(the_set.HasMandatoryOutsideSet({"width"}, found_name));
EXPECT_FALSE(the_set.width.HasMandatory()); EXPECT_FALSE(the_set.width.HasMandatory());
......
...@@ -511,7 +511,7 @@ void ConvertConstraintsToWebrtcOfferOptions( ...@@ -511,7 +511,7 @@ void ConvertConstraintsToWebrtcOfferOptions(
if (constraints.IsEmpty()) { if (constraints.IsEmpty()) {
return; return;
} }
std::string failing_name; String failing_name;
if (constraints.Basic().HasMandatoryOutsideSet( if (constraints.Basic().HasMandatoryOutsideSet(
{constraints.Basic().offer_to_receive_audio.GetName(), {constraints.Basic().offer_to_receive_audio.GetName(),
constraints.Basic().offer_to_receive_video.GetName(), constraints.Basic().offer_to_receive_video.GetName(),
......
...@@ -388,61 +388,59 @@ WebMediaTrackConstraintSet::WebMediaTrackConstraintSet() ...@@ -388,61 +388,59 @@ WebMediaTrackConstraintSet::WebMediaTrackConstraintSet()
goog_payload_padding("googPayloadPadding"), goog_payload_padding("googPayloadPadding"),
goog_latency_ms("latencyMs") {} goog_latency_ms("latencyMs") {}
std::vector<const BaseConstraint*> WebMediaTrackConstraintSet::AllConstraints() Vector<const BaseConstraint*> WebMediaTrackConstraintSet::AllConstraints()
const { const {
const BaseConstraint* temp[] = {&width, return {&width,
&height, &height,
&aspect_ratio, &aspect_ratio,
&frame_rate, &frame_rate,
&facing_mode, &facing_mode,
&resize_mode, &resize_mode,
&volume, &volume,
&sample_rate, &sample_rate,
&sample_size, &sample_size,
&echo_cancellation, &echo_cancellation,
&echo_cancellation_type, &echo_cancellation_type,
&latency, &latency,
&channel_count, &channel_count,
&device_id, &device_id,
&group_id, &group_id,
&video_kind, &video_kind,
&media_stream_source, &media_stream_source,
&disable_local_echo, &disable_local_echo,
&render_to_associated_sink, &render_to_associated_sink,
&goog_echo_cancellation, &goog_echo_cancellation,
&goog_experimental_echo_cancellation, &goog_experimental_echo_cancellation,
&goog_auto_gain_control, &goog_auto_gain_control,
&goog_experimental_auto_gain_control, &goog_experimental_auto_gain_control,
&goog_noise_suppression, &goog_noise_suppression,
&goog_highpass_filter, &goog_highpass_filter,
&goog_experimental_noise_suppression, &goog_experimental_noise_suppression,
&goog_audio_mirroring, &goog_audio_mirroring,
&goog_da_echo_cancellation, &goog_da_echo_cancellation,
&goog_noise_reduction, &goog_noise_reduction,
&offer_to_receive_audio, &offer_to_receive_audio,
&offer_to_receive_video, &offer_to_receive_video,
&voice_activity_detection, &voice_activity_detection,
&ice_restart, &ice_restart,
&goog_use_rtp_mux, &goog_use_rtp_mux,
&enable_dtls_srtp, &enable_dtls_srtp,
&enable_rtp_data_channels, &enable_rtp_data_channels,
&enable_dscp, &enable_dscp,
&enable_i_pv6, &enable_i_pv6,
&goog_enable_video_suspend_below_min_bitrate, &goog_enable_video_suspend_below_min_bitrate,
&goog_num_unsignalled_recv_streams, &goog_num_unsignalled_recv_streams,
&goog_combined_audio_video_bwe, &goog_combined_audio_video_bwe,
&goog_screencast_min_bitrate, &goog_screencast_min_bitrate,
&goog_cpu_overuse_detection, &goog_cpu_overuse_detection,
&goog_cpu_underuse_threshold, &goog_cpu_underuse_threshold,
&goog_cpu_overuse_threshold, &goog_cpu_overuse_threshold,
&goog_cpu_underuse_encode_rsd_threshold, &goog_cpu_underuse_encode_rsd_threshold,
&goog_cpu_overuse_encode_rsd_threshold, &goog_cpu_overuse_encode_rsd_threshold,
&goog_cpu_overuse_encode_usage, &goog_cpu_overuse_encode_usage,
&goog_high_start_bitrate, &goog_high_start_bitrate,
&goog_payload_padding, &goog_payload_padding,
&goog_latency_ms}; &goog_latency_ms};
const int element_count = sizeof(temp) / sizeof(temp[0]);
return std::vector<const BaseConstraint*>(&temp[0], &temp[element_count]);
} }
bool WebMediaTrackConstraintSet::IsEmpty() const { bool WebMediaTrackConstraintSet::IsEmpty() const {
...@@ -454,8 +452,8 @@ bool WebMediaTrackConstraintSet::IsEmpty() const { ...@@ -454,8 +452,8 @@ bool WebMediaTrackConstraintSet::IsEmpty() const {
} }
bool WebMediaTrackConstraintSet::HasMandatoryOutsideSet( bool WebMediaTrackConstraintSet::HasMandatoryOutsideSet(
const std::vector<std::string>& good_names, const Vector<String>& good_names,
std::string& found_name) const { String& found_name) const {
for (auto* const constraint : AllConstraints()) { for (auto* const constraint : AllConstraints()) {
if (constraint->HasMandatory()) { if (constraint->HasMandatory()) {
if (std::find(good_names.begin(), good_names.end(), if (std::find(good_names.begin(), good_names.end(),
...@@ -469,8 +467,8 @@ bool WebMediaTrackConstraintSet::HasMandatoryOutsideSet( ...@@ -469,8 +467,8 @@ bool WebMediaTrackConstraintSet::HasMandatoryOutsideSet(
} }
bool WebMediaTrackConstraintSet::HasMandatory() const { bool WebMediaTrackConstraintSet::HasMandatory() const {
std::string dummy_string; String dummy_string;
return HasMandatoryOutsideSet(std::vector<std::string>(), dummy_string); return HasMandatoryOutsideSet(Vector<String>(), dummy_string);
} }
bool WebMediaTrackConstraintSet::HasMin() const { bool WebMediaTrackConstraintSet::HasMin() const {
......
...@@ -31,9 +31,6 @@ ...@@ -31,9 +31,6 @@
#ifndef THIRD_PARTY_BLINK_RENDERER_PLATFORM_MEDIASTREAM_MEDIA_CONSTRAINTS_H_ #ifndef THIRD_PARTY_BLINK_RENDERER_PLATFORM_MEDIASTREAM_MEDIA_CONSTRAINTS_H_
#define THIRD_PARTY_BLINK_RENDERER_PLATFORM_MEDIASTREAM_MEDIA_CONSTRAINTS_H_ #define THIRD_PARTY_BLINK_RENDERER_PLATFORM_MEDIASTREAM_MEDIA_CONSTRAINTS_H_
#include <string>
#include <vector>
#include "third_party/blink/public/platform/web_private_ptr.h" #include "third_party/blink/public/platform/web_private_ptr.h"
#include "third_party/blink/renderer/platform/platform_export.h" #include "third_party/blink/renderer/platform/platform_export.h"
#include "third_party/blink/renderer/platform/wtf/text/wtf_string.h" #include "third_party/blink/renderer/platform/wtf/text/wtf_string.h"
...@@ -282,14 +279,14 @@ struct WebMediaTrackConstraintSet { ...@@ -282,14 +279,14 @@ struct WebMediaTrackConstraintSet {
PLATFORM_EXPORT bool IsEmpty() const; PLATFORM_EXPORT bool IsEmpty() const;
PLATFORM_EXPORT bool HasMandatory() const; PLATFORM_EXPORT bool HasMandatory() const;
PLATFORM_EXPORT bool HasMandatoryOutsideSet(const std::vector<std::string>&, PLATFORM_EXPORT bool HasMandatoryOutsideSet(const Vector<String>&,
std::string&) const; String&) const;
PLATFORM_EXPORT bool HasMin() const; PLATFORM_EXPORT bool HasMin() const;
PLATFORM_EXPORT bool HasExact() const; PLATFORM_EXPORT bool HasExact() const;
PLATFORM_EXPORT String ToString() const; PLATFORM_EXPORT String ToString() const;
private: private:
std::vector<const BaseConstraint*> AllConstraints() const; Vector<const BaseConstraint*> AllConstraints() const;
}; };
class MediaConstraints { class MediaConstraints {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment