Commit 879306f3 authored by Antonio Gomes's avatar Antonio Gomes Committed by Commit Bot

Switch user_media_processor.cc|h away from std::vector and string

... and use the WTF counterparts, Vector and String.

BUG=704136
R=haraken@chromium.org

Change-Id: I99adf8785525376a47b1a5e52cfee345f5618d00
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1752063Reviewed-by: default avatarGuido Urdaneta <guidou@chromium.org>
Commit-Queue: Antonio Gomes <tonikitoo@igalia.com>
Auto-Submit: Antonio Gomes <tonikitoo@igalia.com>
Cr-Commit-Position: refs/heads/master@{#686523}
parent 0dc86f1a
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
#include <algorithm> #include <algorithm>
#include <utility> #include <utility>
#include <vector>
#include "base/location.h" #include "base/location.h"
#include "base/logging.h" #include "base/logging.h"
...@@ -28,6 +29,7 @@ ...@@ -28,6 +29,7 @@
#include "third_party/blink/public/platform/web_media_stream_track.h" #include "third_party/blink/public/platform/web_media_stream_track.h"
#include "third_party/blink/public/platform/web_screen_info.h" #include "third_party/blink/public/platform/web_screen_info.h"
#include "third_party/blink/public/platform/web_string.h" #include "third_party/blink/public/platform/web_string.h"
#include "third_party/blink/public/platform/web_vector.h"
#include "third_party/blink/public/web/modules/mediastream/media_stream_constraints_util.h" #include "third_party/blink/public/web/modules/mediastream/media_stream_constraints_util.h"
#include "third_party/blink/public/web/modules/mediastream/media_stream_video_track.h" #include "third_party/blink/public/web/modules/mediastream/media_stream_video_track.h"
#include "third_party/blink/public/web/modules/mediastream/processed_local_audio_source.h" #include "third_party/blink/public/web/modules/mediastream/processed_local_audio_source.h"
...@@ -93,11 +95,11 @@ void InitializeAudioTrackControls(const blink::WebUserMediaRequest& web_request, ...@@ -93,11 +95,11 @@ void InitializeAudioTrackControls(const blink::WebUserMediaRequest& web_request,
MediaStreamType* stream_type = &track_controls->stream_type; MediaStreamType* stream_type = &track_controls->stream_type;
*stream_type = MediaStreamType::NO_SERVICE; *stream_type = MediaStreamType::NO_SERVICE;
std::string source_constraint = String source_constraint =
constraints.Basic().media_stream_source.Exact().empty() constraints.Basic().media_stream_source.Exact().empty()
? std::string() ? String()
: constraints.Basic().media_stream_source.Exact()[0].Utf8(); : String(constraints.Basic().media_stream_source.Exact()[0]);
if (!source_constraint.empty()) { if (!source_constraint.IsEmpty()) {
if (source_constraint == blink::kMediaStreamSourceTab) { if (source_constraint == blink::kMediaStreamSourceTab) {
*stream_type = MediaStreamType::GUM_TAB_AUDIO_CAPTURE; *stream_type = MediaStreamType::GUM_TAB_AUDIO_CAPTURE;
} else if (source_constraint == blink::kMediaStreamSourceDesktop || } else if (source_constraint == blink::kMediaStreamSourceDesktop ||
...@@ -128,11 +130,11 @@ void InitializeVideoTrackControls(const blink::WebUserMediaRequest& web_request, ...@@ -128,11 +130,11 @@ void InitializeVideoTrackControls(const blink::WebUserMediaRequest& web_request,
MediaStreamType* stream_type = &track_controls->stream_type; MediaStreamType* stream_type = &track_controls->stream_type;
*stream_type = MediaStreamType::NO_SERVICE; *stream_type = MediaStreamType::NO_SERVICE;
std::string source_constraint = String source_constraint =
constraints.Basic().media_stream_source.Exact().empty() constraints.Basic().media_stream_source.Exact().empty()
? std::string() ? String()
: constraints.Basic().media_stream_source.Exact()[0].Utf8(); : String(constraints.Basic().media_stream_source.Exact()[0]);
if (!source_constraint.empty()) { if (!source_constraint.IsEmpty()) {
if (source_constraint == blink::kMediaStreamSourceTab) { if (source_constraint == blink::kMediaStreamSourceTab) {
*stream_type = MediaStreamType::GUM_TAB_VIDEO_CAPTURE; *stream_type = MediaStreamType::GUM_TAB_VIDEO_CAPTURE;
} else if (source_constraint == blink::kMediaStreamSourceDesktop || } else if (source_constraint == blink::kMediaStreamSourceDesktop ||
...@@ -571,7 +573,7 @@ void UserMediaProcessor::SelectAudioDeviceSettings( ...@@ -571,7 +573,7 @@ void UserMediaProcessor::SelectAudioDeviceSettings(
// will contain the same non-reconfigurable settings that limit the // will contain the same non-reconfigurable settings that limit the
// associated capabilities. // associated capabilities.
blink::MediaStreamAudioSource* audio_source = nullptr; blink::MediaStreamAudioSource* audio_source = nullptr;
auto it = auto* it =
std::find_if(local_sources_.begin(), local_sources_.end(), std::find_if(local_sources_.begin(), local_sources_.end(),
[&device](const blink::WebMediaStreamSource& web_source) { [&device](const blink::WebMediaStreamSource& web_source) {
DCHECK(!web_source.IsNull()); DCHECK(!web_source.IsNull());
...@@ -643,7 +645,7 @@ UserMediaProcessor::DetermineExistingAudioSessionId() { ...@@ -643,7 +645,7 @@ UserMediaProcessor::DetermineExistingAudioSessionId() {
// Create a copy of the blink::WebMediaStreamSource objects that are // Create a copy of the blink::WebMediaStreamSource objects that are
// associated to the same audio device capture based on its device ID. // associated to the same audio device capture based on its device ID.
std::vector<blink::WebMediaStreamSource> matching_sources; Vector<blink::WebMediaStreamSource> matching_sources;
std::copy_if(local_sources_.begin(), local_sources_.end(), std::copy_if(local_sources_.begin(), local_sources_.end(),
std::back_inserter(matching_sources), std::back_inserter(matching_sources),
[&device_id](const blink::WebMediaStreamSource& web_source) { [&device_id](const blink::WebMediaStreamSource& web_source) {
...@@ -653,7 +655,7 @@ UserMediaProcessor::DetermineExistingAudioSessionId() { ...@@ -653,7 +655,7 @@ UserMediaProcessor::DetermineExistingAudioSessionId() {
// Return the session ID associated to the source that has the same settings // Return the session ID associated to the source that has the same settings
// that have been previously selected, if one exists. // that have been previously selected, if one exists.
if (!matching_sources.empty()) { if (!matching_sources.IsEmpty()) {
for (auto& matching_source : matching_sources) { for (auto& matching_source : matching_sources) {
blink::MediaStreamAudioSource* audio_source = blink::MediaStreamAudioSource* audio_source =
static_cast<blink::MediaStreamAudioSource*>( static_cast<blink::MediaStreamAudioSource*>(
...@@ -932,7 +934,7 @@ void UserMediaProcessor::OnAudioSourceStarted( ...@@ -932,7 +934,7 @@ void UserMediaProcessor::OnAudioSourceStarted(
const String& result_name) { const String& result_name) {
DCHECK_CALLED_ON_VALID_THREAD(thread_checker_); DCHECK_CALLED_ON_VALID_THREAD(thread_checker_);
for (auto it = pending_local_sources_.begin(); for (auto* it = pending_local_sources_.begin();
it != pending_local_sources_.end(); ++it) { it != pending_local_sources_.end(); ++it) {
blink::WebPlatformMediaStreamSource* const source_extra_data = blink::WebPlatformMediaStreamSource* const source_extra_data =
it->GetPlatformSource(); it->GetPlatformSource();
...@@ -1205,17 +1207,19 @@ void UserMediaProcessor::StartTracks(const String& label) { ...@@ -1205,17 +1207,19 @@ void UserMediaProcessor::StartTracks(const String& label) {
ToStdVector(current_request_info_->video_devices()), ToStdVector(current_request_info_->video_devices()),
weak_factory_.GetWeakPtr()); weak_factory_.GetWeakPtr());
blink::WebVector<blink::WebMediaStreamTrack> audio_tracks( Vector<blink::WebMediaStreamTrack> audio_tracks(
current_request_info_->audio_devices().size()); current_request_info_->audio_devices().size());
CreateAudioTracks(current_request_info_->audio_devices(), &audio_tracks); CreateAudioTracks(current_request_info_->audio_devices(), &audio_tracks);
blink::WebVector<blink::WebMediaStreamTrack> video_tracks( Vector<blink::WebMediaStreamTrack> video_tracks(
current_request_info_->video_devices().size()); current_request_info_->video_devices().size());
CreateVideoTracks(current_request_info_->video_devices(), &video_tracks); CreateVideoTracks(current_request_info_->video_devices(), &video_tracks);
String blink_id = label; String blink_id = label;
current_request_info_->web_stream()->Initialize(blink_id, audio_tracks, current_request_info_->web_stream()->Initialize(
video_tracks); blink_id,
WebVector<WebMediaStreamTrack>(audio_tracks.data(), audio_tracks.size()),
WebVector<WebMediaStreamTrack>(video_tracks.data(), video_tracks.size()));
// Wait for the tracks to be started successfully or to fail. // Wait for the tracks to be started successfully or to fail.
current_request_info_->CallbackOnTracksStarted( current_request_info_->CallbackOnTracksStarted(
...@@ -1225,7 +1229,7 @@ void UserMediaProcessor::StartTracks(const String& label) { ...@@ -1225,7 +1229,7 @@ void UserMediaProcessor::StartTracks(const String& label) {
void UserMediaProcessor::CreateVideoTracks( void UserMediaProcessor::CreateVideoTracks(
const Vector<MediaStreamDevice>& devices, const Vector<MediaStreamDevice>& devices,
blink::WebVector<blink::WebMediaStreamTrack>* webkit_tracks) { Vector<blink::WebMediaStreamTrack>* webkit_tracks) {
DCHECK_CALLED_ON_VALID_THREAD(thread_checker_); DCHECK_CALLED_ON_VALID_THREAD(thread_checker_);
DCHECK(current_request_info_); DCHECK(current_request_info_);
DCHECK_EQ(devices.size(), webkit_tracks->size()); DCHECK_EQ(devices.size(), webkit_tracks->size());
...@@ -1240,7 +1244,7 @@ void UserMediaProcessor::CreateVideoTracks( ...@@ -1240,7 +1244,7 @@ void UserMediaProcessor::CreateVideoTracks(
void UserMediaProcessor::CreateAudioTracks( void UserMediaProcessor::CreateAudioTracks(
const Vector<MediaStreamDevice>& devices, const Vector<MediaStreamDevice>& devices,
blink::WebVector<blink::WebMediaStreamTrack>* webkit_tracks) { Vector<blink::WebMediaStreamTrack>* webkit_tracks) {
DCHECK_CALLED_ON_VALID_THREAD(thread_checker_); DCHECK_CALLED_ON_VALID_THREAD(thread_checker_);
DCHECK(current_request_info_); DCHECK(current_request_info_);
DCHECK_EQ(devices.size(), webkit_tracks->size()); DCHECK_EQ(devices.size(), webkit_tracks->size());
...@@ -1479,7 +1483,7 @@ bool UserMediaProcessor::RemoveLocalSource( ...@@ -1479,7 +1483,7 @@ bool UserMediaProcessor::RemoveLocalSource(
const blink::WebMediaStreamSource& source) { const blink::WebMediaStreamSource& source) {
DCHECK_CALLED_ON_VALID_THREAD(thread_checker_); DCHECK_CALLED_ON_VALID_THREAD(thread_checker_);
for (auto device_it = local_sources_.begin(); for (auto* device_it = local_sources_.begin();
device_it != local_sources_.end(); ++device_it) { device_it != local_sources_.end(); ++device_it) {
if (IsSameSource(*device_it, source)) { if (IsSameSource(*device_it, source)) {
local_sources_.erase(device_it); local_sources_.erase(device_it);
...@@ -1488,7 +1492,7 @@ bool UserMediaProcessor::RemoveLocalSource( ...@@ -1488,7 +1492,7 @@ bool UserMediaProcessor::RemoveLocalSource(
} }
// Check if the source was pending. // Check if the source was pending.
for (auto device_it = pending_local_sources_.begin(); for (auto* device_it = pending_local_sources_.begin();
device_it != pending_local_sources_.end(); ++device_it) { device_it != pending_local_sources_.end(); ++device_it) {
if (IsSameSource(*device_it, source)) { if (IsSameSource(*device_it, source)) {
blink::WebPlatformMediaStreamSource* const source_extra_data = blink::WebPlatformMediaStreamSource* const source_extra_data =
...@@ -1560,7 +1564,7 @@ void UserMediaProcessor::StopAllProcessing() { ...@@ -1560,7 +1564,7 @@ void UserMediaProcessor::StopAllProcessing() {
request_completed_cb_.Reset(); request_completed_cb_.Reset();
// Loop through all current local sources and stop the sources. // Loop through all current local sources and stop the sources.
auto it = local_sources_.begin(); auto* it = local_sources_.begin();
while (it != local_sources_.end()) { while (it != local_sources_.end()) {
StopLocalSource(*it, true); StopLocalSource(*it, true);
it = local_sources_.erase(it); it = local_sources_.erase(it);
...@@ -1603,7 +1607,7 @@ void UserMediaProcessor::StopLocalSource( ...@@ -1603,7 +1607,7 @@ void UserMediaProcessor::StopLocalSource(
} }
bool UserMediaProcessor::HasActiveSources() const { bool UserMediaProcessor::HasActiveSources() const {
return !local_sources_.empty(); return !local_sources_.IsEmpty();
} }
const blink::mojom::blink::MediaStreamDispatcherHostPtr& const blink::mojom::blink::MediaStreamDispatcherHostPtr&
......
...@@ -6,9 +6,7 @@ ...@@ -6,9 +6,7 @@
#define THIRD_PARTY_BLINK_RENDERER_MODULES_MEDIASTREAM_USER_MEDIA_PROCESSOR_H_ #define THIRD_PARTY_BLINK_RENDERER_MODULES_MEDIASTREAM_USER_MEDIA_PROCESSOR_H_
#include <memory> #include <memory>
#include <string>
#include <utility> #include <utility>
#include <vector>
#include "base/callback_forward.h" #include "base/callback_forward.h"
#include "base/macros.h" #include "base/macros.h"
...@@ -19,7 +17,6 @@ ...@@ -19,7 +17,6 @@
#include "third_party/blink/public/mojom/mediastream/media_devices.mojom-blink.h" #include "third_party/blink/public/mojom/mediastream/media_devices.mojom-blink.h"
#include "third_party/blink/public/mojom/mediastream/media_stream.mojom-blink.h" #include "third_party/blink/public/mojom/mediastream/media_stream.mojom-blink.h"
#include "third_party/blink/public/platform/modules/mediastream/web_platform_media_stream_source.h" #include "third_party/blink/public/platform/modules/mediastream/web_platform_media_stream_source.h"
#include "third_party/blink/public/platform/web_vector.h"
#include "third_party/blink/public/web/web_user_media_request.h" #include "third_party/blink/public/web/web_user_media_request.h"
#include "third_party/blink/renderer/modules/mediastream/media_stream_constraints_util_audio.h" #include "third_party/blink/renderer/modules/mediastream/media_stream_constraints_util_audio.h"
#include "third_party/blink/renderer/modules/modules_export.h" #include "third_party/blink/renderer/modules/modules_export.h"
...@@ -140,7 +137,7 @@ class MODULES_EXPORT UserMediaProcessor { ...@@ -140,7 +137,7 @@ class MODULES_EXPORT UserMediaProcessor {
private: private:
class RequestInfo; class RequestInfo;
using LocalStreamSources = std::vector<blink::WebMediaStreamSource>; using LocalStreamSources = Vector<blink::WebMediaStreamSource>;
void OnStreamGenerated(int request_id, void OnStreamGenerated(int request_id,
blink::mojom::blink::MediaStreamRequestResult result, blink::mojom::blink::MediaStreamRequestResult result,
...@@ -185,13 +182,11 @@ class MODULES_EXPORT UserMediaProcessor { ...@@ -185,13 +182,11 @@ class MODULES_EXPORT UserMediaProcessor {
void StartTracks(const String& label); void StartTracks(const String& label);
void CreateVideoTracks( void CreateVideoTracks(const Vector<blink::MediaStreamDevice>& devices,
const Vector<blink::MediaStreamDevice>& devices, Vector<blink::WebMediaStreamTrack>* webkit_tracks);
blink::WebVector<blink::WebMediaStreamTrack>* webkit_tracks);
void CreateAudioTracks( void CreateAudioTracks(const Vector<blink::MediaStreamDevice>& devices,
const Vector<blink::MediaStreamDevice>& devices, Vector<blink::WebMediaStreamTrack>* webkit_tracks);
blink::WebVector<blink::WebMediaStreamTrack>* webkit_tracks);
// Callback function triggered when all native versions of the // Callback function triggered when all native versions of the
// underlying media sources and tracks have been created and started. // underlying media sources and tracks have been created and started.
......
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