chromium/chrome/browser/media/router/providers/cast/mirroring_activity.cc

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

#include "chrome/browser/media/router/providers/cast/mirroring_activity.h"

#include <stdint.h>

#include <cstddef>
#include <cstdint>
#include <memory>
#include <optional>
#include <string>
#include <string_view>
#include <utility>

#include "base/command_line.h"
#include "base/functional/bind.h"
#include "base/json/json_reader.h"
#include "base/json/json_writer.h"
#include "base/metrics/histogram_functions.h"
#include "base/metrics/user_metrics.h"
#include "base/metrics/user_metrics_action.h"
#include "base/strings/strcat.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/string_tokenizer.h"
#include "base/strings/stringprintf.h"
#include "base/strings/utf_string_conversions.h"
#include "base/task/bind_post_task.h"
#include "base/task/sequenced_task_runner.h"
#include "base/time/time.h"
#include "base/values.h"
#include "chrome/browser/media/cast_mirroring_service_host_factory.h"
#include "chrome/browser/media/router/data_decoder_util.h"
#include "chrome/browser/media/router/discovery/access_code/access_code_cast_feature.h"
#include "chrome/browser/media/router/media_router_feature.h"
#include "chrome/browser/media/router/providers/cast/cast_activity_manager.h"
#include "chrome/browser/media/router/providers/cast/cast_internal_message_util.h"
#include "chrome/browser/profiles/profile_manager.h"
#include "chrome/grit/generated_resources.h"
#include "components/access_code_cast/common/access_code_cast_metrics.h"
#include "components/media_router/browser/media_router_debugger.h"
#include "components/media_router/browser/mirroring_to_flinging_switcher.h"
#include "components/media_router/common/discovery/media_sink_internal.h"
#include "components/media_router/common/mojom/media_router.mojom.h"
#include "components/media_router/common/providers/cast/channel/cast_device_capability.h"
#include "components/media_router/common/providers/cast/channel/cast_message_util.h"
#include "components/media_router/common/providers/cast/channel/enum_table.h"
#include "components/media_router/common/route_request_result.h"
#include "components/mirroring/mojom/session_parameters.mojom.h"
#include "content/public/browser/browser_thread.h"
#include "media/base/media_switches.h"
#include "media/cast/cast_config.h"
#include "media/cast/constants.h"
#include "media/cast/logging/stats_event_subscriber.h"
#include "mojo/public/cpp/bindings/pending_receiver.h"
#include "mojo/public/cpp/bindings/pending_remote.h"
#include "net/base/ip_address.h"
#include "third_party/openscreen/src/cast/common/channel/proto/cast_channel.pb.h"
#include "ui/base/l10n/l10n_util.h"

PresentationConnectionMessagePtr;
Result;
MediaRouteProvider;
MediaRouter;
MirroringServiceHostFactory;
SessionError;
SessionParameters;
SessionType;

namespace media_router {

namespace {

constexpr char kHistogramSessionLaunch[] =;
constexpr char kHistogramSessionLength[] =;
constexpr char kHistogramSessionLengthAccessCode[] =;
constexpr char kHistogramSessionLengthOffscreenTab[] =;
constexpr char kHistogramSessionLengthScreen[] =;
constexpr char kHistogramSessionLengthTab[] =;
constexpr char kHistogramStartFailureAccessCodeManualEntry[] =;
constexpr char kHistogramStartFailureAccessCodeRememberedDevice[] =;
constexpr char kHistogramStartFailureNative[] =;
constexpr char kHistogramStartSuccess[] =;
constexpr char kHistogramStartSuccessAccessCodeManualEntry[] =;
constexpr char kHistogramStartSuccessAccessCodeRememberedDevice[] =;

const char kHistogramTypeAudio[] =;
const char kHistogramTypeVideo[] =;
constexpr char kHistogramTransmissionKbps[] =;
constexpr char kHistogramAverageEncodeTime[] =;
constexpr char kHistogramAverageCaptureLatency[] =;
constexpr char kHistogramAverageEndToEndLatency[] =;
constexpr char kHistogramAverageNetworkLatency[] =;
constexpr char kHistogramRetransmittedPacketsPercentage[] =;
constexpr char kHistogramExceededPlayoutDelayPacketsPercentage[] =;
constexpr char kHistogramLateFramesPercentage[] =;

constexpr char kLoggerComponent[] =;

MirroringType;

const std::string GetMirroringNamespace(const base::Value::Dict& message) {}

std::optional<MirroringActivity::MirroringType> GetMirroringType(
    const MediaRoute& route) {}

// TODO(crbug.com/1363512): Remove support for sender side letterboxing.
bool ShouldForceLetterboxing(std::string_view model_name) {}

std::optional<int> GetExceededPlayoutDelayPacketPercent(
    const base::Value::List* network_latency_ms_histo,
    int64_t target_playout_delay) {}

std::optional<double> LookupStat(
    const base::Value::Dict& mirroring_stats,
    media::cast::StatsEventSubscriber::CastStat cast_stat) {}

void MaybeRecordLatencyHistogram(const char* fmt,
                                 const char* streaming_type,
                                 std::optional<double> value) {}

void MaybeRecordMemoryHistogram(const char* fmt,
                                const char* streaming_type,
                                std::optional<double> value) {}

void RecordCastStreamingSenderUma(const base::Value::Dict& all_mirroring_stats,
                                  std::string_view stats_dict_key,
                                  int64_t target_playout_delay) {}

}  // namespace

MirroringActivity::MirroringActivity(
    const MediaRoute& route,
    const std::string& app_id,
    cast_channel::CastMessageHandler* message_handler,
    CastSessionTracker* session_tracker,
    int frame_tree_node_id,
    const CastSinkExtraData& cast_data,
    OnStopCallback callback,
    OnSourceChangedCallback source_changed_callback)
    :{}

MirroringActivity::~MirroringActivity() {}

void MirroringActivity::CreateMojoBindings(mojom::MediaRouter* media_router) {}

void MirroringActivity::CreateMirroringServiceHost(
    mirroring::MirroringServiceHostFactory* host_factory_for_test) {}

void MirroringActivity::OnError(SessionError error) {}

void MirroringActivity::DidStart() {}

void MirroringActivity::DidStop() {}

void MirroringActivity::LogInfoMessage(const std::string& message) {}

void MirroringActivity::LogErrorMessage(const std::string& message) {}

void MirroringActivity::OnSourceChanged() {}

void MirroringActivity::OnRemotingStateChanged(bool is_remoting) {}

void MirroringActivity::OnMessage(mirroring::mojom::CastMessagePtr message) {}

void MirroringActivity::OnAppMessage(
    const openscreen::cast::proto::CastMessage& message) {}

void MirroringActivity::OnInternalMessage(
    const cast_channel::InternalMessage& message) {}

void MirroringActivity::BindMediaController(
    mojo::PendingReceiver<mojom::MediaController> media_controller,
    mojo::PendingRemote<mojom::MediaStatusObserver> observer) {}

std::string MirroringActivity::GetRouteDescription(
    const CastSession& session) const {}

void MirroringActivity::HandleParseJsonResult(
    const std::string& route_id,
    data_decoder::DataDecoder::ValueOrError result) {}

void MirroringActivity::OnSessionSet(const CastSession& session) {}
void MirroringActivity::StartSession(const std::string& destination_id,
                                     bool enable_rtcp_reporting) {}

void MirroringActivity::StartOnUiThread(
    mirroring::mojom::SessionParametersPtr session_params,
    mojo::PendingRemote<mirroring::mojom::SessionObserver> observer,
    mojo::PendingRemote<mirroring::mojom::CastMessageChannel> outbound_channel,
    mojo::PendingReceiver<mirroring::mojom::CastMessageChannel> inbound_channel,
    const std::string& sink_name) {}

void MirroringActivity::StopMirroring() {}

std::string MirroringActivity::GetScrubbedLogMessage(
    const base::Value::Dict& message) {}

void MirroringActivity::ScheduleFetchMirroringStats() {}

void MirroringActivity::FetchMirroringStats() {}

void MirroringActivity::OnMirroringStats(base::Value json_stats) {}

void MirroringActivity::Play() {}

void MirroringActivity::Pause() {}

void MirroringActivity::SetPlayState(mojom::MediaStatus::PlayState play_state) {}

void MirroringActivity::NotifyMediaStatusObservers() {}

void MirroringActivity::OnMirroringPaused() {}

void MirroringActivity::OnMirroringResumed() {}

}  // namespace media_router