blob: b5b20ad649ac79e43b2c0b1cc239027d9f58159c [file] [log] [blame]
// Copyright 2015 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include <stddef.h>
#include <ostream>
#include <string>
#include "base/hash.h"
#include "url/gurl.h"
// TODO(mfoltz): Right now this is a wrapper for std::string. Factor methods
// from media_source_helper here so this object becomes useful; and don't just
// pass it around by Id.
namespace media_router {
class MediaSource {
using Id = std::string;
explicit MediaSource(const MediaSource::Id& id);
explicit MediaSource(const GURL& presentation_url);
// Gets the ID of the media source.
MediaSource::Id id() const;
// If MediaSource is created from a URL, return the URL; otherwise return an
// empty GURL.
GURL url() const;
// Returns true if two MediaSource objects use the same media ID.
bool operator==(const MediaSource& other) const;
// Used for logging.
std::string ToString() const;
// Hash operator for hash containers.
struct Hash {
size_t operator()(const MediaSource& source) const {
return base::Hash(;
MediaSource::Id id_;
GURL url_;
} // namespace media_router