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_
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"
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.
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 // |for_display|: Set to true if this route should be displayed for
38 // |media_sink_id| in UI.
39 MediaRoute(const MediaRoute::Id
& media_route_id
,
40 const MediaSource
& media_source
,
41 const MediaSink::Id
& media_sink_id
,
42 const std::string
& description
,
44 const std::string
& custom_controller_path
,
48 // The media route identifier.
49 const MediaRoute::Id
& media_route_id() const { return media_route_id_
; }
51 // The media source being routed.
52 const MediaSource
& media_source() const { return media_source_
; }
54 // The ID of sink being routed to.
55 const MediaSink::Id
& media_sink_id() const { return media_sink_id_
; }
57 // The description of the media route activity, for example
58 // "Playing Foo Bar Music All Access."
59 // TODO(kmarshall): Do we need to pass locale for bidi rendering?
60 const std::string
& description() const { return description_
; }
62 // Returns |true| if the route is created locally (versus discovered
63 // by a media route provider.)
64 bool is_local() const { return is_local_
; }
66 // The custom controller path. This allows route provider to have custom route
67 // detail as well as its own route control features route control features in
68 // the media router dialog.
69 const std::string
& custom_controller_path() const {
70 return custom_controller_path_
;
73 bool for_display() const { return for_display_
; }
75 bool Equals(const MediaRoute
& other
) const;
78 MediaRoute::Id media_route_id_
;
79 MediaSource media_source_
;
80 MediaSink::Id media_sink_id_
;
81 std::string description_
;
83 std::string custom_controller_path_
;
87 class MediaRouteIdToPresentationSessionMapping
{
89 MediaRouteIdToPresentationSessionMapping();
90 ~MediaRouteIdToPresentationSessionMapping();
92 void Add(const MediaRoute::Id
& route_id
,
93 const content::PresentationSessionInfo
& session_info
);
94 void Remove(const MediaRoute::Id
& route_id
);
97 // Gets the PresentationSessionInfo corresponding to |route_id| or nullptr
98 // if it does not exist. Caller should not hold on to the returned pointer.
99 const content::PresentationSessionInfo
* Get(
100 const MediaRoute::Id
& route_id
) const;
103 base::SmallMap
<std::map
<MediaRoute::Id
, content::PresentationSessionInfo
>>
104 route_id_to_presentation_
;
106 DISALLOW_COPY_AND_ASSIGN(MediaRouteIdToPresentationSessionMapping
);
109 } // namespace media_router
111 #endif // CHROME_BROWSER_MEDIA_ROUTER_MEDIA_ROUTE_H_