1 // Copyright 2019 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 "osp/impl/presentation/presentation_common.h" 6 7 #include "absl/strings/ascii.h" 8 9 namespace openscreen { 10 namespace osp { 11 GetProtocolConnection(uint64_t endpoint_id)12std::unique_ptr<ProtocolConnection> GetProtocolConnection( 13 uint64_t endpoint_id) { 14 return NetworkServiceManager::Get() 15 ->GetProtocolConnectionServer() 16 ->CreateProtocolConnection(endpoint_id); 17 } 18 GetServerDemuxer()19MessageDemuxer* GetServerDemuxer() { 20 return NetworkServiceManager::Get() 21 ->GetProtocolConnectionServer() 22 ->message_demuxer(); 23 } 24 GetClientDemuxer()25MessageDemuxer* GetClientDemuxer() { 26 return NetworkServiceManager::Get() 27 ->GetProtocolConnectionClient() 28 ->message_demuxer(); 29 } 30 PresentationID(std::string presentation_id)31PresentationID::PresentationID(std::string presentation_id) 32 : id_(Error::Code::kParseError) { 33 // The spec dictates that the presentation ID must be composed 34 // of at least 16 ASCII characters. 35 bool is_valid = presentation_id.length() >= 16; 36 for (const char& c : presentation_id) { 37 is_valid &= absl::ascii_isprint(c); 38 } 39 40 if (is_valid) { 41 id_ = std::move(presentation_id); 42 } 43 } 44 45 } // namespace osp 46 } // namespace openscreen 47