xref: /aosp_15_r20/external/openscreen/osp/impl/presentation/presentation_common.h (revision 3f982cf4871df8771c9d4abe6e9a6f8d829b2736)
1*3f982cf4SFabien Sanglard // Copyright 2019 The Chromium Authors. All rights reserved.
2*3f982cf4SFabien Sanglard // Use of this source code is governed by a BSD-style license that can be
3*3f982cf4SFabien Sanglard // found in the LICENSE file.
4*3f982cf4SFabien Sanglard 
5*3f982cf4SFabien Sanglard #ifndef OSP_IMPL_PRESENTATION_PRESENTATION_COMMON_H_
6*3f982cf4SFabien Sanglard #define OSP_IMPL_PRESENTATION_PRESENTATION_COMMON_H_
7*3f982cf4SFabien Sanglard 
8*3f982cf4SFabien Sanglard #include <algorithm>
9*3f982cf4SFabien Sanglard #include <memory>
10*3f982cf4SFabien Sanglard #include <string>
11*3f982cf4SFabien Sanglard 
12*3f982cf4SFabien Sanglard #include "osp/msgs/osp_messages.h"
13*3f982cf4SFabien Sanglard #include "osp/public/message_demuxer.h"
14*3f982cf4SFabien Sanglard #include "osp/public/network_service_manager.h"
15*3f982cf4SFabien Sanglard #include "osp/public/protocol_connection_server.h"
16*3f982cf4SFabien Sanglard #include "platform/api/time.h"
17*3f982cf4SFabien Sanglard #include "util/osp_logging.h"
18*3f982cf4SFabien Sanglard 
19*3f982cf4SFabien Sanglard namespace openscreen {
20*3f982cf4SFabien Sanglard namespace osp {
21*3f982cf4SFabien Sanglard 
22*3f982cf4SFabien Sanglard // This method asks the singleton NetworkServiceManager
23*3f982cf4SFabien Sanglard // to create a new protocol connection for the given endpoint.
24*3f982cf4SFabien Sanglard // Typically, the same QuicConnection and ServiceConnectionDelegate
25*3f982cf4SFabien Sanglard // are reused (see QuicProtocolConnection::FromExisting) for the new
26*3f982cf4SFabien Sanglard // ProtocolConnection instance.
27*3f982cf4SFabien Sanglard std::unique_ptr<ProtocolConnection> GetProtocolConnection(uint64_t endpoint_id);
28*3f982cf4SFabien Sanglard 
29*3f982cf4SFabien Sanglard // These methods retrieve the server and client demuxers, respectively. These
30*3f982cf4SFabien Sanglard // are retrieved from the protocol connection server and client. The lifetime of
31*3f982cf4SFabien Sanglard // the demuxers themselves are not well defined: currently they are created in
32*3f982cf4SFabien Sanglard // the demo component for the ListenerDemo and PublisherDemo methods.
33*3f982cf4SFabien Sanglard MessageDemuxer* GetServerDemuxer();
34*3f982cf4SFabien Sanglard MessageDemuxer* GetClientDemuxer();
35*3f982cf4SFabien Sanglard 
36*3f982cf4SFabien Sanglard class PresentationID {
37*3f982cf4SFabien Sanglard  public:
38*3f982cf4SFabien Sanglard   explicit PresentationID(const std::string presentation_id);
39*3f982cf4SFabien Sanglard 
40*3f982cf4SFabien Sanglard   operator bool() { return id_; }
string()41*3f982cf4SFabien Sanglard   operator std::string() { return id_.value(); }
42*3f982cf4SFabien Sanglard 
43*3f982cf4SFabien Sanglard  private:
44*3f982cf4SFabien Sanglard   ErrorOr<std::string> id_;
45*3f982cf4SFabien Sanglard };
46*3f982cf4SFabien Sanglard 
47*3f982cf4SFabien Sanglard }  // namespace osp
48*3f982cf4SFabien Sanglard }  // namespace openscreen
49*3f982cf4SFabien Sanglard 
50*3f982cf4SFabien Sanglard #endif  // OSP_IMPL_PRESENTATION_PRESENTATION_COMMON_H_
51