chromium/chrome/browser/media/router/providers/cast/cast_internal_message_util.h

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

#ifndef CHROME_BROWSER_MEDIA_ROUTER_PROVIDERS_CAST_CAST_INTERNAL_MESSAGE_UTIL_H_
#define CHROME_BROWSER_MEDIA_ROUTER_PROVIDERS_CAST_CAST_INTERNAL_MESSAGE_UTIL_H_

#include <optional>

#include "base/containers/flat_set.h"
#include "base/values.h"
#include "third_party/blink/public/mojom/presentation/presentation.mojom.h"
#include "third_party/openscreen/src/cast/common/channel/proto/cast_channel.pb.h"

namespace media_router {

CastMessage;

class MediaSinkInternal;

// Values in the "supportedMediaCommands" list in media status messages
// sent to the Cast sender SDK.
constexpr char kMediaCommandPause[] =;
constexpr char kMediaCommandSeek[] =;
constexpr char kMediaCommandStreamVolume[] =;
constexpr char kMediaCommandStreamMute[] =;
constexpr char kMediaCommandQueueNext[] =;
constexpr char kMediaCommandQueuePrev[] =;

// Values in the "supportedMediaCommands" bit array in media status messages
// received from Cast receivers. They are converted to string values by
// SupportedMediaCommandsToListValue().
enum class MediaCommand {};

// Represents a message sent or received by the Cast SDK via a
// PresentationConnection.
class CastInternalMessage {};

// Represents a Cast session on a Cast device. Cast sessions are derived from
// RECEIVER_STATUS messages sent by Cast devices.
//
// TODO(crbug.com/1291743): Rename either this class or ::CastSession to avoid
// confusion.
class CastSession {};

// Utility methods for generating messages sent to the SDK.
// |hash_token| is a per-profile value that is used to hash the sink ID.
blink::mojom::PresentationConnectionMessagePtr CreateReceiverActionCastMessage(
    const std::string& client_id,
    const MediaSinkInternal& sink,
    const std::string& hash_token);
blink::mojom::PresentationConnectionMessagePtr CreateReceiverActionStopMessage(
    const std::string& client_id,
    const MediaSinkInternal& sink,
    const std::string& hash_token);
blink::mojom::PresentationConnectionMessagePtr CreateNewSessionMessage(
    const CastSession& session,
    const std::string& client_id,
    const MediaSinkInternal& sink,
    const std::string& hash_token);
blink::mojom::PresentationConnectionMessagePtr CreateUpdateSessionMessage(
    const CastSession& session,
    const std::string& client_id,
    const MediaSinkInternal& sink,
    const std::string& hash_token);
blink::mojom::PresentationConnectionMessagePtr CreateAppMessageAck(
    const std::string& client_id,
    int sequence_number);
blink::mojom::PresentationConnectionMessagePtr CreateAppMessage(
    const std::string& session_id,
    const std::string& client_id,
    const CastMessage& cast_message);
blink::mojom::PresentationConnectionMessagePtr CreateV2Message(
    const std::string& client_id,
    const base::Value::Dict& payload,
    std::optional<int> sequence_number);
blink::mojom::PresentationConnectionMessagePtr CreateErrorMessage(
    const std::string& client_id,
    base::Value::Dict error,
    std::optional<int> sequence_number);
blink::mojom::PresentationConnectionMessagePtr CreateLeaveSessionAckMessage(
    const std::string& client_id,
    std::optional<int> sequence_number);
blink::mojom::PresentationConnectionMessagePtr CreateLeaveSessionAckMessage(
    const std::string& client_id,
    std::optional<int> sequence_number);

base::Value::List SupportedMediaCommandsToListValue(int media_commands);

}  // namespace media_router

#endif  // CHROME_BROWSER_MEDIA_ROUTER_PROVIDERS_CAST_CAST_INTERNAL_MESSAGE_UTIL_H_