chromium/third_party/blink/renderer/modules/mediarecorder/media_recorder.cc

// Copyright 2015 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "third_party/blink/renderer/modules/mediarecorder/media_recorder.h"

#include <algorithm>
#include <limits>

#include "base/time/time.h"
#include "third_party/blink/public/common/privacy_budget/identifiability_metric_builder.h"
#include "third_party/blink/public/common/privacy_budget/identifiability_study_settings.h"
#include "third_party/blink/public/common/privacy_budget/identifiable_surface.h"
#include "third_party/blink/public/platform/platform.h"
#include "third_party/blink/public/platform/task_type.h"
#include "third_party/blink/renderer/bindings/core/v8/dictionary.h"
#include "third_party/blink/renderer/bindings/core/v8/to_v8_traits.h"
#include "third_party/blink/renderer/bindings/core/v8/v8_binding_for_core.h"
#include "third_party/blink/renderer/bindings/core/v8/v8_error_event_init.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/events/error_event.h"
#include "third_party/blink/renderer/core/execution_context/execution_context.h"
#include "third_party/blink/renderer/core/fileapi/blob.h"
#include "third_party/blink/renderer/core/frame/local_dom_window.h"
#include "third_party/blink/renderer/core/inspector/console_message.h"
#include "third_party/blink/renderer/modules/event_target_modules.h"
#include "third_party/blink/renderer/modules/mediarecorder/blob_event.h"
#include "third_party/blink/renderer/modules/mediarecorder/video_track_recorder.h"
#include "third_party/blink/renderer/platform/blob/blob_data.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/network/mime/content_type.h"
#include "third_party/blink/renderer/platform/privacy_budget/identifiability_digest_helpers.h"
#include "third_party/blink/renderer/platform/wtf/functional.h"
#include "third_party/blink/renderer/platform/wtf/text/wtf_string.h"

namespace blink {

namespace {

struct MediaRecorderBitrates {};

// Boundaries of Opus SILK bitrate from https://www.opus-codec.org/.
const int kSmallestPossibleOpusBitRate =;
const int kLargestPossibleOpusBitRate =;

// Smallest Vpx bitrate that can be requested.
// 75kbps is the min bitrate recommended by VP9 VOD settings for 320x240 videos.
const int kSmallestPossibleVpxBitRate =;

// Both values come from YouTube recommended upload encoding settings and are
// used by other browser vendors. See
// https://support.google.com/youtube/answer/1722171?hl=en#zippy=%2Cbitrate
const int kDefaultVideoBitRate =;  // 2.5Mbps
const int kDefaultAudioBitRate =;   // 128kbps

String StateToString(MediaRecorder::State state) {}

String BitrateModeToString(AudioTrackRecorder::BitrateMode bitrateMode) {}

AudioTrackRecorder::BitrateMode GetBitrateModeFromOptions(
    const MediaRecorderOptions* const options) {}

void LogConsoleMessage(ExecutionContext* context, const String& message) {}

uint32_t ClampAudioBitRate(ExecutionContext* context, uint32_t audio_bps) {}

uint32_t ClampVideoBitRate(ExecutionContext* context, uint32_t video_bps) {}

// Allocates the requested bit rates from |options| into the respective
// |{audio,video}_bps| (where a value of zero indicates Platform to use
// whatever it sees fit). If |options.bitsPerSecond()| is specified, it
// overrides any specific bitrate, and the UA is free to allocate as desired:
// here a 90%/10% video/audio is used. In all cases where a value is explicited
// or calculated, values are clamped in sane ranges.
// This method throws NotSupportedError.
MediaRecorderBitrates GetBitratesFromOptions(
    ExceptionState& exception_state,
    ExecutionContext* context,
    const MediaRecorderOptions* options) {}

}  // namespace

MediaRecorder* MediaRecorder::Create(ExecutionContext* context,
                                     MediaStream* stream,
                                     ExceptionState& exception_state) {}

MediaRecorder* MediaRecorder::Create(ExecutionContext* context,
                                     MediaStream* stream,
                                     const MediaRecorderOptions* options,
                                     ExceptionState& exception_state) {}

MediaRecorder::MediaRecorder(ExecutionContext* context,
                             MediaStream* stream,
                             const MediaRecorderOptions* options,
                             ExceptionState& exception_state)
    :{}

MediaRecorder::~MediaRecorder() = default;

String MediaRecorder::state() const {}

String MediaRecorder::audioBitrateMode() const {}

void MediaRecorder::start(ExceptionState& exception_state) {}

void MediaRecorder::start(int time_slice, ExceptionState& exception_state) {}

void MediaRecorder::stop(ExceptionState& exception_state) {}

void MediaRecorder::pause(ExceptionState& exception_state) {}

void MediaRecorder::resume(ExceptionState& exception_state) {}

void MediaRecorder::requestData(ExceptionState& exception_state) {}

bool MediaRecorder::isTypeSupported(ExecutionContext* context,
                                    const String& type) {}

const AtomicString& MediaRecorder::InterfaceName() const {}

ExecutionContext* MediaRecorder::GetExecutionContext() const {}

void MediaRecorder::ContextDestroyed() {}

void MediaRecorder::WriteData(base::span<const uint8_t> data,
                              bool last_in_slice,
                              double timecode,
                              ErrorEvent* error_event) {}

void MediaRecorder::OnError(DOMExceptionCode code, const String& message) {}

void MediaRecorder::OnAllTracksEnded() {}

void MediaRecorder::OnStreamChanged(const String& message) {}

void MediaRecorder::CreateBlobEvent(Blob* blob, double timecode) {}

void MediaRecorder::StopRecording(ErrorEvent* error_event) {}

void MediaRecorder::ScheduleDispatchEvent(Event* event) {}

void MediaRecorder::DispatchScheduledEvent() {}

void MediaRecorder::Trace(Visitor* visitor) const {}

void MediaRecorder::UpdateAudioBitrate(uint32_t bits_per_second) {}

}  // namespace blink