Chromium Code Reviews| 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..28c6f1b9d8a1e57bf9c5fbec7e28b8ddc7679049 |
| --- /dev/null |
| +++ b/chrome/browser/media/router/media_route.h |
| @@ -0,0 +1,132 @@ |
| +// 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. |
| + |
| +#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; |
|
mark a. foltz
2015/03/02 21:40:09
using is now preferred for type aliasing.
http://
Kevin M
2015/03/03 21:53:18
Done.
Kevin M
2015/03/03 21:53:19
Done.
|
| +extern const int64 kInvalidRouteRequestId; |
|
mark a. foltz
2015/03/02 21:40:09
s/int64/RouteRequestId/
Kevin M
2015/03/03 21:53:19
Done.
|
| + |
| +// 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. |
|
mark a. foltz
2015/03/02 21:40:09
Please touch base with Derek and see if there is a
Kevin M
2015/03/03 21:53:19
Removed.
|
| +enum MediaRouteError { |
| + MEDIA_ROUTE_ERROR_NONE |
| +}; |
| + |
| +// A MediaRoute encapsulates an application's means of routing media from a |
| +// source to a sink. |
| +class MediaRoute { |
|
DaleCurtis
2015/03/02 23:14:33
You'll likely need EXPORT definitions if you plan
Kevin M
2015/03/03 21:53:18
I'm building with component=shared_library and hav
|
| + public: |
| + // Ctor. Do not call directly, use MediaRouteFactory instead. |
| + // TODO(mfoltz): Make private and friend MRF |
|
mark a. foltz
2015/03/02 21:40:09
Can we do this now?
I feel we should do this to c
Kevin M
2015/03/03 21:53:19
Done.
|
| + // |media_route_id|: Uniquely identifies the route among active |
|
mark a. foltz
2015/03/02 21:40:09
For this to be true the (to be implemented) factor
Kevin M
2015/03/03 21:53:19
Done.
|
| + // 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 |
|
mark a. foltz
2015/03/02 21:40:09
"created instantiated" seems redundant.
Can you c
Kevin M
2015/03/03 21:53:18
Per browser process. Done.
|
| + // 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. |
|
mark a. foltz
2015/03/02 21:40:09
The ID of the sink...
Kevin M
2015/03/03 21:53:19
Done.
|
| + const MediaSinkId& sink_id() const { return sink_id_; } |
| + |
| + // The description of the media route activity. |
|
mark a. foltz
2015/03/02 21:40:08
An example would be helpful.
Will this need to be
Kevin M
2015/03/03 21:53:18
Good question - do you think we should push UI loc
Kevin M
2015/03/03 22:18:27
Talked with haibinlu@ about this - the description
|
| + const std::string& description() const { return description_; } |
| + |
| + // Returns |true| if the route is initiated locally. |
|
mark a. foltz
2015/03/02 21:40:09
I might elaborate a little:
"if the route was cre
Kevin M
2015/03/03 21:53:19
Done.
|
| + 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. |
|
mark a. foltz
2015/03/02 21:40:09
Still valid?
Kevin M
2015/03/03 21:53:18
Done.
|
| +}; |
| + |
| +// Response to a media route request to the Media Route Provider. |
|
mark a. foltz
2015/03/02 21:40:09
"...from a Media Route Provider"
Kevin M
2015/03/03 21:53:18
Done.
|
| +class MediaRouteResponse { |
| + public: |
| + // Creates a MediaRouteResponse object that indicates success. |
|
mark a. foltz
2015/03/02 21:40:08
Only Media Router implementations should be creati
Kevin M
2015/03/03 21:53:18
Done. Removed it from here. Will just ack the comm
|
| + // |request_id|: ID of original request. |
|
mark a. foltz
2015/03/02 21:40:09
s/request_id/route_request_id/g to be explicit abo
Kevin M
2015/03/03 21:53:18
Acknowledged.
|
| + // |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); |
|
mark a. foltz
2015/03/02 21:40:09
Should we use a MediaRouteError instead of the err
Kevin M
2015/03/03 21:53:18
Acknowledged.
|
| + |
| + ~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_; |
|
mark a. foltz
2015/03/02 21:40:09
It's odd that the response object owns the lifetim
Kevin M
2015/03/03 21:53:19
Acknowledged.
|
| + // 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_ |