[Live-devel] Reason for protected destructor on RTSPServer?

Ross Finlayson finlayson at live555.com
Fri Aug 2 12:36:31 PDT 2019


> I notice the destructor of RTSPServer class is protected. What is the design goal here? What is the correct method of resource cleanup/recycling given this design?

The destructors of class “Medium”, and all of its subclasses (which includes “RTSPServer”) are protected, so that you don’t (can’t) remove them using “delete”.  Instead, call
	Medium::close(pointer-to-object);


>  So far, my only ‘workaround’ is to derive a class of my own from RTSPServer and make the derived class’ destructor public.
>  
> Will destruction of the (derived) RTSPServer also clean up (delete) the media sessions registered with it (it appears yes, just want to confirm).
>  
> Anything else that needs to be cleaned up?

Yes, which is why you should be calling “Medium::close()” instead.


>  Can the UsageEnvironment and the TaskScheduler have lifetimes that span many server startups & shutdowns?

Yes, of course.

In general, though, for something as large/significant as a server, it’s usually better application design to clean it up by just letting the process exit (and then creating a new process if/when you want another server), rather than deleting/recreating a server over and over again within a single process.


Ross Finlayson
Live Networks, Inc.
http://www.live555.com/




More information about the live-devel mailing list