#include "third_party/blink/renderer/modules/mediastream/media_stream_track_impl.h"
#include <memory>
#include "base/check_op.h"
#include "base/functional/callback_helpers.h"
#include "build/build_config.h"
#include "third_party/blink/public/common/features.h"
#include "third_party/blink/public/platform/modules/mediastream/web_media_stream_track.h"
#include "third_party/blink/public/platform/modules/webrtc/webrtc_logging.h"
#include "third_party/blink/public/web/modules/mediastream/media_stream_video_source.h"
#include "third_party/blink/renderer/bindings/core/v8/script_promise_resolver.h"
#include "third_party/blink/renderer/bindings/modules/v8/v8_double_range.h"
#include "third_party/blink/renderer/bindings/modules/v8/v8_long_range.h"
#include "third_party/blink/renderer/bindings/modules/v8/v8_media_track_capabilities.h"
#include "third_party/blink/renderer/bindings/modules/v8/v8_media_track_constraints.h"
#include "third_party/blink/renderer/bindings/modules/v8/v8_media_track_settings.h"
#include "third_party/blink/renderer/bindings/modules/v8/v8_point_2d.h"
#include "third_party/blink/renderer/bindings/modules/v8/v8_union_mediastreamtrackaudiostats_mediastreamtrackvideostats.h"
#include "third_party/blink/renderer/core/dom/dom_exception.h"
#include "third_party/blink/renderer/core/dom/events/event.h"
#include "third_party/blink/renderer/core/execution_context/execution_context.h"
#include "third_party/blink/renderer/core/frame/local_dom_window.h"
#include "third_party/blink/renderer/core/frame/local_frame.h"
#include "third_party/blink/renderer/modules/imagecapture/image_capture.h"
#include "third_party/blink/renderer/modules/mediastream/apply_constraints_request.h"
#include "third_party/blink/renderer/modules/mediastream/browser_capture_media_stream_track.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_track_audio_stats.h"
#include "third_party/blink/renderer/modules/mediastream/media_stream_track_video_stats.h"
#include "third_party/blink/renderer/modules/mediastream/media_stream_utils.h"
#include "third_party/blink/renderer/modules/mediastream/media_stream_video_track.h"
#include "third_party/blink/renderer/modules/mediastream/overconstrained_error.h"
#include "third_party/blink/renderer/modules/mediastream/processed_local_audio_source.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/mediastream/webaudio_media_stream_audio_sink.h"
#include "third_party/blink/renderer/platform/heap/collection_support/heap_vector.h"
#include "third_party/blink/renderer/platform/heap/garbage_collected.h"
#include "third_party/blink/renderer/platform/mediastream/media_stream_audio_source.h"
#include "third_party/blink/renderer/platform/mediastream/media_stream_audio_track.h"
#include "third_party/blink/renderer/platform/mediastream/media_stream_component.h"
#include "third_party/blink/renderer/platform/mediastream/media_stream_web_audio_source.h"
#include "third_party/blink/renderer/platform/runtime_enabled_features.h"
#include "third_party/blink/renderer/platform/scheduler/public/thread.h"
#include "third_party/blink/renderer/platform/wtf/vector.h"
namespace blink {
namespace {
bool ConstraintSetHasImageCapture(
const MediaTrackConstraintSet* constraint_set) { … }
bool ConstraintSetHasNonImageCapture(
const MediaTrackConstraintSet* constraint_set) { … }
bool ConstraintSetHasImageAndNonImageCapture(
const MediaTrackConstraintSet* constraint_set) { … }
bool ConstraintSetIsNonEmpty(const MediaTrackConstraintSet* constraint_set) { … }
template <typename ConstraintSetCondition>
bool ConstraintsSatisfyCondition(ConstraintSetCondition condition,
const MediaTrackConstraints* constraints) { … }
bool ConstraintsHaveImageAndNonImageCapture(
const MediaTrackConstraints* constraints) { … }
bool ConstraintsAreEmpty(const MediaTrackConstraints* constraints) { … }
bool ConstraintsHaveImageCapture(const MediaTrackConstraints* constraints) { … }
std::unique_ptr<WebAudioSourceProvider>
CreateWebAudioSourceFromMediaStreamTrack(
MediaStreamComponent* component,
int context_sample_rate,
base::TimeDelta platform_buffer_duration) { … }
void DidCloneMediaStreamTrack(MediaStreamComponent* clone) { … }
std::optional<media::mojom::DisplayCaptureSurfaceType> GetDisplayCaptureType(
const MediaStreamComponent* component) { … }
WebString GetDisplaySurfaceString(
media::mojom::DisplayCaptureSurfaceType value) { … }
}
MediaStreamTrack* MediaStreamTrackImpl::Create(ExecutionContext* context,
MediaStreamComponent* component,
base::OnceClosure callback) { … }
MediaStreamTrackImpl::MediaStreamTrackImpl(ExecutionContext* context,
MediaStreamComponent* component)
: … { … }
MediaStreamTrackImpl::MediaStreamTrackImpl(ExecutionContext* context,
MediaStreamComponent* component,
base::OnceClosure callback)
: … { … }
MediaStreamTrackImpl::MediaStreamTrackImpl(
ExecutionContext* context,
MediaStreamComponent* component,
MediaStreamSource::ReadyState ready_state,
base::OnceClosure callback,
bool is_clone)
: … { … }
MediaStreamTrackImpl::~MediaStreamTrackImpl() = default;
String MediaStreamTrackImpl::kind() const { … }
String MediaStreamTrackImpl::id() const { … }
String MediaStreamTrackImpl::label() const { … }
bool MediaStreamTrackImpl::enabled() const { … }
void MediaStreamTrackImpl::setEnabled(bool enabled) { … }
bool MediaStreamTrackImpl::muted() const { … }
String MediaStreamTrackImpl::ContentHint() const { … }
void MediaStreamTrackImpl::SetContentHint(const String& hint) { … }
String MediaStreamTrackImpl::readyState() const { … }
void MediaStreamTrackImpl::setReadyState(
MediaStreamSource::ReadyState ready_state) { … }
void MediaStreamTrackImpl::stopTrack(ExecutionContext* execution_context) { … }
MediaStreamTrack* MediaStreamTrackImpl::clone(
ExecutionContext* execution_context) { … }
MediaTrackCapabilities* MediaStreamTrackImpl::getCapabilities() const { … }
MediaTrackConstraints* MediaStreamTrackImpl::getConstraints() const { … }
MediaTrackSettings* MediaStreamTrackImpl::getSettings() const { … }
V8UnionMediaStreamTrackAudioStatsOrMediaStreamTrackVideoStats*
MediaStreamTrackImpl::stats() { … }
MediaStreamTrackPlatform::VideoFrameStats
MediaStreamTrackImpl::GetVideoFrameStats() const { … }
void MediaStreamTrackImpl::TransferAudioFrameStatsTo(
MediaStreamTrackPlatform::AudioFrameStats& destination) { … }
CaptureHandle* MediaStreamTrackImpl::getCaptureHandle() const { … }
ScriptPromise<IDLUndefined> MediaStreamTrackImpl::applyConstraints(
ScriptState* script_state,
const MediaTrackConstraints* constraints) { … }
void MediaStreamTrackImpl::SetInitialConstraints(
const MediaConstraints& constraints) { … }
void MediaStreamTrackImpl::SetConstraints(const MediaConstraints& constraints) { … }
void MediaStreamTrackImpl::SetConstraintsInternal(
const MediaConstraints& constraints,
bool initial_values) { … }
void MediaStreamTrackImpl::applyConstraints(
ScriptPromiseResolver<IDLUndefined>* resolver,
const MediaTrackConstraints* constraints) { … }
bool MediaStreamTrackImpl::Ended() const { … }
void MediaStreamTrackImpl::SourceChangedState() { … }
void MediaStreamTrackImpl::SourceChangedCaptureConfiguration() { … }
void MediaStreamTrackImpl::MaybeDispatchConfigurationChange(bool has_changed) { … }
void MediaStreamTrackImpl::SourceChangedCaptureHandle() { … }
void MediaStreamTrackImpl::PropagateTrackEnded() { … }
bool MediaStreamTrackImpl::HasPendingActivity() const { … }
std::unique_ptr<AudioSourceProvider> MediaStreamTrackImpl::CreateWebAudioSource(
int context_sample_rate,
base::TimeDelta platform_buffer_duration) { … }
std::optional<const MediaStreamDevice> MediaStreamTrackImpl::device() const { … }
void MediaStreamTrackImpl::BeingTransferred(
const base::UnguessableToken& transfer_id) { … }
bool MediaStreamTrackImpl::TransferAllowed(String& message) const { … }
void MediaStreamTrackImpl::RegisterMediaStream(MediaStream* media_stream) { … }
void MediaStreamTrackImpl::UnregisterMediaStream(MediaStream* media_stream) { … }
const AtomicString& MediaStreamTrackImpl::InterfaceName() const { … }
ExecutionContext* MediaStreamTrackImpl::GetExecutionContext() const { … }
void MediaStreamTrackImpl::AddedEventListener(
const AtomicString& event_type,
RegisteredEventListener& registered_listener) { … }
void MediaStreamTrackImpl::Trace(Visitor* visitor) const { … }
void MediaStreamTrackImpl::CloneInternal(MediaStreamTrackImpl* cloned_track) { … }
void MediaStreamTrackImpl::EnsureFeatureHandleForScheduler() { … }
void MediaStreamTrackImpl::AddObserver(MediaStreamTrack::Observer* observer) { … }
void MediaStreamTrackImpl::SendLogMessage(const WTF::String& message) { … }
}