mirror of
https://github.com/ossrs/srs.git
synced 2025-03-09 15:49:59 +00:00
The object relations:

Session manages SIP and Media object using shared resource or shared
ptr. Note that I actually use SrsExecutorCoroutine to delete the object
when each coroutine is done, because there is always a dedicate
coroutine for each object.
For SIP and Media object, they directly use the session by raw pointer,
it's safe because session always live longer than session and media
object.
---
Co-authored-by: Jacob Su <suzp1984@gmail.com>
54 lines
1.2 KiB
C++
54 lines
1.2 KiB
C++
//
|
|
// Copyright (c) 2013-2024 The SRS Authors
|
|
//
|
|
// SPDX-License-Identifier: MIT
|
|
//
|
|
|
|
#ifndef SRS_PROTOCOL_CONN_HPP
|
|
#define SRS_PROTOCOL_CONN_HPP
|
|
|
|
#include <srs_core.hpp>
|
|
|
|
#include <string>
|
|
#include <vector>
|
|
|
|
// The resource managed by ISrsResourceManager.
|
|
class ISrsResource
|
|
{
|
|
public:
|
|
ISrsResource();
|
|
virtual ~ISrsResource();
|
|
public:
|
|
// Get the context id of connection.
|
|
virtual const SrsContextId& get_id() = 0;
|
|
public:
|
|
// The resource description, optional.
|
|
virtual std::string desc();
|
|
};
|
|
|
|
// The manager for resource.
|
|
class ISrsResourceManager
|
|
{
|
|
public:
|
|
ISrsResourceManager();
|
|
virtual ~ISrsResourceManager();
|
|
public:
|
|
// Remove then free the specified connection. Note that the manager always free c resource,
|
|
// in the same coroutine or another coroutine. Some manager may support add c to a map, it
|
|
// should always free it even if it's in the map.
|
|
virtual void remove(ISrsResource* c) = 0;
|
|
};
|
|
|
|
// The connection interface for all HTTP/RTMP/RTSP object.
|
|
class ISrsConnection : public ISrsResource
|
|
{
|
|
public:
|
|
ISrsConnection();
|
|
virtual ~ISrsConnection();
|
|
public:
|
|
// Get remote ip address.
|
|
virtual std::string remote_ip() = 0;
|
|
};
|
|
|
|
#endif
|
|
|