Update broken references to image assets
[chromium-blink-merge.git] / chrome / browser / media / router / media_route.h
blob0ccd0977c0cd490b59dc611a0ed40650b3079455
1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef CHROME_BROWSER_MEDIA_ROUTER_MEDIA_ROUTE_H_
6 #define CHROME_BROWSER_MEDIA_ROUTER_MEDIA_ROUTE_H_
8 #include <string>
10 #include "base/containers/small_map.h"
11 #include "base/gtest_prod_util.h"
12 #include "base/logging.h"
13 #include "base/values.h"
14 #include "chrome/browser/media/router/media_sink.h"
15 #include "chrome/browser/media/router/media_source.h"
16 #include "content/public/browser/presentation_session.h"
17 #include "url/gurl.h"
19 namespace media_router {
21 // MediaRoute objects contain the status and metadata of a routing
22 // operation. The fields are immutable and reflect the route status
23 // only at the time of object creation. Updated route statuses must
24 // be retrieved as new MediaRoute objects from the Media Router.
25 class MediaRoute {
26 public:
27 using Id = std::string;
29 // |media_route_id|: ID of the route. New route IDs should be created
30 // by the RouteIdManager class.
31 // |media_source|: Description of source of the route.
32 // |media_sink|: The sink that is receiving the media.
33 // |description|: Description of the route to be displayed.
34 // |is_local|: true if the route was created from this browser.
35 // |custom_controller_path|: custom controller path if it is given by route
36 // provider. empty otherwise.
37 MediaRoute(const MediaRoute::Id& media_route_id,
38 const MediaSource& media_source,
39 const MediaSink& media_sink,
40 const std::string& description,
41 bool is_local,
42 const std::string& custom_controller_path);
43 ~MediaRoute();
45 // The media route identifier.
46 const MediaRoute::Id& media_route_id() const { return media_route_id_; }
48 // The media source being routed.
49 const MediaSource& media_source() const { return media_source_; }
51 // The sink being routed to.
52 const MediaSink& media_sink() const { return media_sink_; }
54 // The description of the media route activity, for example
55 // "Playing Foo Bar Music All Access."
56 // TODO(kmarshall): Do we need to pass locale for bidi rendering?
57 const std::string& description() const { return description_; }
59 // Returns |true| if the route is created locally (versus discovered
60 // by a media route provider.)
61 bool is_local() const { return is_local_; }
63 // The custom controller path. This allows route provider to have custom route
64 // detail as well as its own route control features route control features in
65 // the media router dialog.
66 const std::string& custom_controller_path() const {
67 return custom_controller_path_;
70 bool Equals(const MediaRoute& other) const;
72 private:
73 MediaRoute::Id media_route_id_;
74 MediaSource media_source_;
75 MediaSink media_sink_;
76 std::string description_;
77 bool is_local_;
78 std::string custom_controller_path_;
81 class MediaRouteIdToPresentationSessionMapping {
82 public:
83 MediaRouteIdToPresentationSessionMapping();
84 ~MediaRouteIdToPresentationSessionMapping();
86 void Add(const MediaRoute::Id& route_id,
87 const content::PresentationSessionInfo& session_info);
88 void Remove(const MediaRoute::Id& route_id);
89 void Clear();
91 // Gets the PresentationSessionInfo corresponding to |route_id| or nullptr
92 // if it does not exist. Caller should not hold on to the returned pointer.
93 const content::PresentationSessionInfo* Get(
94 const MediaRoute::Id& route_id) const;
96 private:
97 base::SmallMap<std::map<MediaRoute::Id, content::PresentationSessionInfo>>
98 route_id_to_presentation_;
100 DISALLOW_COPY_AND_ASSIGN(MediaRouteIdToPresentationSessionMapping);
103 } // namespace media_router
105 #endif // CHROME_BROWSER_MEDIA_ROUTER_MEDIA_ROUTE_H_