• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2020 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.
4 
5 #include "cast/sender/public/cast_media_source.h"
6 
7 #include <algorithm>
8 
9 #include "util/osp_logging.h"
10 
11 namespace openscreen {
12 namespace cast {
13 
14 // static
From(const std::string & source)15 ErrorOr<CastMediaSource> CastMediaSource::From(const std::string& source) {
16   // TODO(btolsch): Implement when we have URL parsing.
17   OSP_UNIMPLEMENTED();
18   return Error::Code::kUnknownError;
19 }
20 
CastMediaSource(std::string source,std::vector<std::string> app_ids)21 CastMediaSource::CastMediaSource(std::string source,
22                                  std::vector<std::string> app_ids)
23     : source_id_(std::move(source)), app_ids_(std::move(app_ids)) {}
24 
25 CastMediaSource::CastMediaSource(const CastMediaSource& other) = default;
26 CastMediaSource::CastMediaSource(CastMediaSource&& other) = default;
27 
28 CastMediaSource::~CastMediaSource() = default;
29 
30 CastMediaSource& CastMediaSource::operator=(const CastMediaSource& other) =
31     default;
32 CastMediaSource& CastMediaSource::operator=(CastMediaSource&& other) = default;
33 
ContainsAppId(const std::string & app_id) const34 bool CastMediaSource::ContainsAppId(const std::string& app_id) const {
35   return std::find(app_ids_.begin(), app_ids_.end(), app_id) != app_ids_.end();
36 }
37 
ContainsAnyAppIdFrom(const std::vector<std::string> & app_ids) const38 bool CastMediaSource::ContainsAnyAppIdFrom(
39     const std::vector<std::string>& app_ids) const {
40   return std::find_first_of(app_ids_.begin(), app_ids_.end(), app_ids.begin(),
41                             app_ids.end()) != app_ids_.end();
42 }
43 
44 }  // namespace cast
45 }  // namespace openscreen
46