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 #ifndef OSP_IMPL_PRESENTATION_PRESENTATION_COMMON_H_ 6 #define OSP_IMPL_PRESENTATION_PRESENTATION_COMMON_H_ 7 8 #include <algorithm> 9 #include <memory> 10 #include <string> 11 12 #include "osp/msgs/osp_messages.h" 13 #include "osp/public/message_demuxer.h" 14 #include "osp/public/network_service_manager.h" 15 #include "osp/public/protocol_connection_server.h" 16 #include "platform/api/time.h" 17 #include "util/osp_logging.h" 18 19 namespace openscreen { 20 namespace osp { 21 22 // This method asks the singleton NetworkServiceManager 23 // to create a new protocol connection for the given endpoint. 24 // Typically, the same QuicConnection and ServiceConnectionDelegate 25 // are reused (see QuicProtocolConnection::FromExisting) for the new 26 // ProtocolConnection instance. 27 std::unique_ptr<ProtocolConnection> GetProtocolConnection(uint64_t endpoint_id); 28 29 // These methods retrieve the server and client demuxers, respectively. These 30 // are retrieved from the protocol connection server and client. The lifetime of 31 // the demuxers themselves are not well defined: currently they are created in 32 // the demo component for the ListenerDemo and PublisherDemo methods. 33 MessageDemuxer* GetServerDemuxer(); 34 MessageDemuxer* GetClientDemuxer(); 35 36 class PresentationID { 37 public: 38 explicit PresentationID(const std::string presentation_id); 39 40 operator bool() { return id_; } string()41 operator std::string() { return id_.value(); } 42 43 private: 44 ErrorOr<std::string> id_; 45 }; 46 47 } // namespace osp 48 } // namespace openscreen 49 50 #endif // OSP_IMPL_PRESENTATION_PRESENTATION_COMMON_H_ 51