| Index: chrome/browser/media/router/media_route.h
|
| diff --git a/chrome/browser/media/router/media_route.h b/chrome/browser/media/router/media_route.h
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..fe76acabd8c76d63b0b9eaef6941a70f8eb006d7
|
| --- /dev/null
|
| +++ b/chrome/browser/media/router/media_route.h
|
| @@ -0,0 +1,133 @@
|
| +// Copyright 2014 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.
|
| +
|
| +#ifndef CHROME_BROWSER_MEDIA_ROUTER_MEDIA_ROUTE_H_
|
| +#define CHROME_BROWSER_MEDIA_ROUTER_MEDIA_ROUTE_H_
|
| +
|
| +#include <string>
|
| +
|
| +#include "base/logging.h"
|
| +#include "base/values.h"
|
| +#include "chrome/browser/media/router/media_route_id.h"
|
| +#include "chrome/browser/media/router/media_sink.h"
|
| +#include "chrome/browser/media/router/media_source.h"
|
| +#include "url/gurl.h"
|
| +
|
| +namespace media_router {
|
| +
|
| +typedef int64 RouteRequestId;
|
| +
|
| +extern const RouteRequestId kInvalidRouteRequestId;
|
| +
|
| +// For now, a simple transition graph: NEW -> CONNECTED -> CLOSED.
|
| +enum MediaRouteState {
|
| + // The route is new and not yet connected to a sink.
|
| + MEDIA_ROUTE_STATE_NEW,
|
| + // The route is active and connected to a sink.
|
| + MEDIA_ROUTE_STATE_CONNECTED,
|
| + // The route has been disconnected.
|
| + MEDIA_ROUTE_STATE_CLOSED
|
| +};
|
| +
|
| +// TODO(mfoltz): Add errors as needed.
|
| +enum MediaRouteError {
|
| + MEDIA_ROUTE_ERROR_NONE
|
| +};
|
| +
|
| +// A MediaRoute encapsulates an application's means of routing media from a
|
| +// source to a sink.
|
| +class MediaRoute {
|
| + public:
|
| + // Ctor. Do not call directly, use MediaRouteFactory instead.
|
| + // TODO(mfoltz): Make private and friend MRF
|
| + // |media_route_id|: Uniquely identifies the route among active
|
| + // instances.
|
| + // |type|: Type of media route.
|
| + // |media_source|: Description of source of the route.
|
| + // |sink_id|: ID of the MediaSink of the route.
|
| + // |description|: Description of the route to be displayed.
|
| + // |is_local|: true if the route was created initiated from this Chrome
|
| + // instance.
|
| + MediaRoute(const MediaRouteId& media_route_id,
|
| + const MediaSource& media_source,
|
| + const MediaSinkId& sink_id,
|
| + const std::string& description,
|
| + bool is_local);
|
| +
|
| + ~MediaRoute();
|
| +
|
| + // The media route identifier.
|
| + const MediaRouteId& media_route_id() const { return media_route_id_; }
|
| +
|
| + // The state of the media route.
|
| + MediaRouteState state() const { return state_; }
|
| +
|
| + // The media source being routed.
|
| + const MediaSource& media_source() const { return media_source_; }
|
| +
|
| + // The sink being routed to.
|
| + const MediaSinkId& sink_id() const { return sink_id_; }
|
| +
|
| + // The description of the media route activity.
|
| + const std::string& description() const { return description_; }
|
| +
|
| + // Returns |true| if the route is initiated locally.
|
| + bool is_local() const { return is_local_; }
|
| +
|
| + bool operator==(const MediaRoute& other) const;
|
| + bool operator!=(const MediaRoute& other) const;
|
| +
|
| + private:
|
| + MediaRouteId media_route_id_;
|
| + MediaSource media_source_;
|
| + MediaSinkId sink_id_;
|
| + std::string description_;
|
| + bool is_local_;
|
| + MediaRouteState state_;
|
| + // TODO(imcheng): Add icon URL.
|
| +};
|
| +
|
| +// Response to a media route request to the Media Route Provider.
|
| +class MediaRouteResponse {
|
| + public:
|
| + // Creates a MediaRouteResponse object that indicates success.
|
| + // |request_id|: ID of original request.
|
| + // |route|: Route created.
|
| + static scoped_ptr<MediaRouteResponse> Success(
|
| + const RouteRequestId& request_id, const MediaRoute& route);
|
| + // Creates a MediaRouteResponse object that indicates failure.
|
| + // |request_id|: ID of original request.
|
| + // |error|: Failure reason.
|
| + static scoped_ptr<MediaRouteResponse> Error(
|
| + const RouteRequestId& request_id, const std::string& error);
|
| +
|
| + ~MediaRouteResponse();
|
| +
|
| + const RouteRequestId& request_id() const { return request_id_; }
|
| + // Returns a pointer to the route created. Returns nullptr if response
|
| + // indicates error.
|
| + const MediaRoute* route() const { return route_.get(); }
|
| + const std::string& error() const { return error_; }
|
| +
|
| + private:
|
| + MediaRouteResponse(
|
| + const RouteRequestId& request_id, const MediaRoute& route);
|
| + MediaRouteResponse(
|
| + const RouteRequestId& request_id, const std::string& error);
|
| + MediaRouteResponse(const MediaRouteResponse& other);
|
| +
|
| + // ID of original request. Set in all MediaRouteResponse objects, regardless
|
| + // of success/failure.
|
| + RouteRequestId request_id_;
|
| + // The route created as a result of the request. Points to a valid MediaRoute
|
| + // iff the response indicates success, nullptr otherwise.
|
| + scoped_ptr<MediaRoute> route_;
|
| + // Set to empty string if response indicates success, otherwise set to the
|
| + // failure reason.
|
| + std::string error_;
|
| +};
|
| +
|
| +} // namespace media_router
|
| +
|
| +#endif // CHROME_BROWSER_MEDIA_ROUTER_MEDIA_ROUTE_H_
|
|
|