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 #include "chrome/browser/media/router/media_route.h"
7 #include "base/logging.h"
8 #include "chrome/browser/media/router/media_source.h"
10 namespace media_router
{
12 MediaRoute::MediaRoute(const MediaRoute::Id
& media_route_id
,
13 const MediaSource
& media_source
,
14 const MediaSink
& media_sink
,
15 const std::string
& description
,
17 const std::string
& custom_controller_path
)
18 : media_route_id_(media_route_id
),
19 media_source_(media_source
),
20 media_sink_(media_sink
),
21 description_(description
),
23 custom_controller_path_(custom_controller_path
) {}
25 MediaRoute::~MediaRoute() {
28 bool MediaRoute::Equals(const MediaRoute
& other
) const {
29 return media_route_id_
== other
.media_route_id_
;
32 MediaRouteIdToPresentationSessionMapping::
33 MediaRouteIdToPresentationSessionMapping() {
36 MediaRouteIdToPresentationSessionMapping::
37 ~MediaRouteIdToPresentationSessionMapping() {
40 void MediaRouteIdToPresentationSessionMapping::Add(
41 const MediaRoute::Id
& route_id
,
42 const content::PresentationSessionInfo
& session_info
) {
43 route_id_to_presentation_
.insert(std::make_pair(route_id
, session_info
));
46 void MediaRouteIdToPresentationSessionMapping::Remove(
47 const MediaRoute::Id
& route_id
) {
48 route_id_to_presentation_
.erase(route_id
);
51 void MediaRouteIdToPresentationSessionMapping::Clear() {
52 route_id_to_presentation_
.clear();
55 const content::PresentationSessionInfo
*
56 MediaRouteIdToPresentationSessionMapping::Get(
57 const MediaRoute::Id
& route_id
) const {
58 auto it
= route_id_to_presentation_
.find(route_id
);
59 return it
== route_id_to_presentation_
.end() ? nullptr : &it
->second
;
62 } // namespace media_router