#include "third_party/blink/renderer/modules/mediastream/user_media_request.h"
#include <type_traits>
#include "base/metrics/histogram_functions.h"
#include "base/strings/stringprintf.h"
#include "third_party/blink/public/common/privacy_budget/identifiability_metric_builder.h"
#include "third_party/blink/public/mojom/permissions_policy/permissions_policy.mojom-blink.h"
#include "third_party/blink/public/platform/modules/webrtc/webrtc_logging.h"
#include "third_party/blink/renderer/bindings/core/v8/dictionary.h"
#include "third_party/blink/renderer/bindings/modules/v8/v8_media_stream_constraints.h"
#include "third_party/blink/renderer/bindings/modules/v8/v8_media_track_constraints.h"
#include "third_party/blink/renderer/bindings/modules/v8/v8_union_boolean_mediatrackconstraints.h"
#include "third_party/blink/renderer/bindings/modules/v8/v8_union_domexception_overconstrainederror.h"
#include "third_party/blink/renderer/core/dom/dom_exception.h"
#include "third_party/blink/renderer/core/dom/space_split_string.h"
#include "third_party/blink/renderer/core/frame/deprecation/deprecation.h"
#include "third_party/blink/renderer/core/frame/local_dom_window.h"
#include "third_party/blink/renderer/modules/mediastream/capture_controller.h"
#include "third_party/blink/renderer/modules/mediastream/identifiability_metrics.h"
#include "third_party/blink/renderer/modules/mediastream/media_constraints_impl.h"
#include "third_party/blink/renderer/modules/mediastream/media_stream.h"
#include "third_party/blink/renderer/modules/mediastream/media_stream_set.h"
#include "third_party/blink/renderer/modules/mediastream/overconstrained_error.h"
#include "third_party/blink/renderer/modules/mediastream/transferred_media_stream_track.h"
#include "third_party/blink/renderer/modules/mediastream/user_media_client.h"
#include "third_party/blink/renderer/modules/peerconnection/peer_connection_tracker.h"
#include "third_party/blink/renderer/platform/bindings/exception_state.h"
#include "third_party/blink/renderer/platform/heap/garbage_collected.h"
#include "third_party/blink/renderer/platform/mediastream/media_stream_descriptor.h"
#include "third_party/blink/renderer/platform/privacy_budget/identifiability_digest_helpers.h"
#include "third_party/blink/renderer/platform/runtime_enabled_features.h"
namespace blink {
MediaStreamType;
Result;
namespace {
enum class GetDisplayMediaIncludeExcludeConstraint { … };
enum class GetDisplayMediaConstraintsDisplaySurface { … };
enum class GetDisplayMediaBooleanConstraint { … };
void RecordUma(GetDisplayMediaConstraintsDisplaySurface value) { … }
template <typename NumericConstraint>
bool SetUsesNumericConstraint(
const MediaTrackConstraintSetPlatform& set,
NumericConstraint MediaTrackConstraintSetPlatform::*field) { … }
template <typename DiscreteConstraint>
bool SetUsesDiscreteConstraint(
const MediaTrackConstraintSetPlatform& set,
DiscreteConstraint MediaTrackConstraintSetPlatform::*field) { … }
template <typename NumericConstraint>
bool RequestUsesNumericConstraint(
const MediaConstraints& constraints,
NumericConstraint MediaTrackConstraintSetPlatform::*field) { … }
template <typename DiscreteConstraint>
bool RequestUsesDiscreteConstraint(
const MediaConstraints& constraints,
DiscreteConstraint MediaTrackConstraintSetPlatform::*field) { … }
class FeatureCounter { … };
void CountAudioConstraintUses(ExecutionContext* context,
const MediaConstraints& constraints) { … }
void CountVideoConstraintUses(ExecutionContext* context,
const MediaConstraints& constraints) { … }
void RecordGetDisplayMediaIncludeExcludeConstraintUma(
std::optional<V8DisplayMediaIncludeOrExclude::Enum> include_or_exclude,
const std::string& histogram_name) { … }
void RecordPreferredDisplaySurfaceConstraintUma(
const mojom::blink::PreferredDisplaySurface preferred_display_surface) { … }
void RecordSuppressLocalAudioPlaybackConstraintUma(
std::optional<bool> suppress_local_audio_playback) { … }
MediaConstraints ParseOptions(
ExecutionContext* execution_context,
const V8UnionBooleanOrMediaTrackConstraints* options,
ExceptionState& exception_state) { … }
}
UserMediaRequest* UserMediaRequest::Create(
ExecutionContext* context,
UserMediaClient* client,
UserMediaRequestType media_type,
const MediaStreamConstraints* options,
Callbacks* callbacks,
ExceptionState& exception_state,
IdentifiableSurface surface) { … }
UserMediaRequest* UserMediaRequest::CreateForTesting(
const MediaConstraints& audio,
const MediaConstraints& video) { … }
UserMediaRequest::UserMediaRequest(ExecutionContext* context,
UserMediaClient* client,
UserMediaRequestType media_type,
MediaConstraints audio,
MediaConstraints video,
bool should_prefer_current_tab,
bool auto_select_all_screens,
CaptureController* capture_controller,
Callbacks* callbacks,
IdentifiableSurface surface)
: … { … }
UserMediaRequest::~UserMediaRequest() = default;
UserMediaRequestType UserMediaRequest::MediaRequestType() const { … }
bool UserMediaRequest::Audio() const { … }
bool UserMediaRequest::Video() const { … }
MediaConstraints UserMediaRequest::AudioConstraints() const { … }
MediaConstraints UserMediaRequest::VideoConstraints() const { … }
MediaStreamType UserMediaRequest::AudioMediaStreamType() const { … }
MediaStreamType UserMediaRequest::VideoMediaStreamType() const { … }
bool UserMediaRequest::ShouldDisableHardwareNoiseSuppression() const { … }
bool UserMediaRequest::IsSecureContextUse(String& error_message) { … }
LocalDOMWindow* UserMediaRequest::GetWindow() { … }
void UserMediaRequest::Start() { … }
void UserMediaRequest::Succeed(
const MediaStreamDescriptorVector& streams_descriptors) { … }
void UserMediaRequest::OnMediaStreamInitialized(MediaStream* stream) { … }
void UserMediaRequest::OnMediaStreamsInitialized(MediaStreamVector streams) { … }
void UserMediaRequest::FailConstraint(const String& constraint_name,
const String& message) { … }
void UserMediaRequest::Fail(Result error, const String& message) { … }
void UserMediaRequest::ContextDestroyed() { … }
void UserMediaRequest::SetTransferredTrackComponent(
MediaStreamComponent* component) { … }
void UserMediaRequest::FinalizeTransferredTrackInitialization(
const MediaStreamDescriptorVector& streams_descriptors) { … }
void UserMediaRequest::Trace(Visitor* visitor) const { … }
}