chromium/third_party/blink/renderer/modules/mediastream/media_stream_track_impl.cc

/*
 * Copyright (C) 2011 Google Inc. All rights reserved.
 * Copyright (C) 2011 Ericsson AB. All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 * 1.  Redistributions of source code must retain the above copyright
 *     notice, this list of conditions and the following disclaimer.
 * 2.  Redistributions in binary form must reproduce the above copyright
 *     notice, this list of conditions and the following disclaimer in the
 *     documentation and/or other materials provided with the distribution.
 *
 * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND
 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
 * DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR
 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */

#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 {

// The set of constrainable properties for image capture is available at
// https://w3c.github.io/mediacapture-image/#constrainable-properties
// TODO(guidou): Integrate image-capture constraints processing with the
// spec-compliant main implementation and remove these support functions.
// http://crbug.com/708723
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) {}

// Caller must take the ownership of the returned |WebAudioSourceProvider|
// object.
std::unique_ptr<WebAudioSourceProvider>
CreateWebAudioSourceFromMediaStreamTrack(
    MediaStreamComponent* component,
    int context_sample_rate,
    base::TimeDelta platform_buffer_duration) {}

void DidCloneMediaStreamTrack(MediaStreamComponent* clone) {}

// Returns the DisplayCaptureSurfaceType for display-capture tracks,
// std::nullopt for non-display-capture tracks.
std::optional<media::mojom::DisplayCaptureSurfaceType> GetDisplayCaptureType(
    const MediaStreamComponent* component) {}

WebString GetDisplaySurfaceString(
    media::mojom::DisplayCaptureSurfaceType value) {}

}  // namespace

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) {}

// TODO(crbug.com/1381959): Remove this helper.
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) {}

}  // namespace blink