[Live-devel] inherit from RTSPClientSession
Ross Finlayson
finlayson at live555.com
Mon Nov 15 18:38:33 PST 2010
>this is your RTSPClientSession definition
>
>class RTSPServer: public Medium {
>protected:
> class RTSPClientSession {
>};
>};
>
>and how can i inherit a subclass from RTSPClientSession in vc6.
>
>class MyRTSPServer : public RTSPServer
>{
>public:
>class MyRTSPClientSession : public RTSPClientSession
>{
>};
>};
Because both "RTSPServer" and "RTSPClientSession" have (non-default)
constructors, you also have to define constructors for their
subclasses. The following is legal C++:
class MyRTSPServer : public RTSPServer {public:
MyRTSPServer();
class MyRTSPClientSession : public RTSPClientSession {
public:
MyRTSPClientSession();
// redefined virtual function:
virtual RTSPClientSession* createNewClientSession(unsigned
sessionId, int clientSocket, struct sockaddr_in clientAddr);
};
};
Of course, you will presumably want to add parameters to the
"MyRTSPServer" and "MyRTSPClientSession" constructors.
Note that you'll need to redefine the virtual function
"createNewClientSession()" in your "MyRTSPClientSession" subclass (as
noted in the code above), and have your (re)implementation of this
virtual function return an object of type "MyRTSPClientSession".
Also, because "MyRTSPServer" objects (just like "RTSPServer" objects)
should always be allocated on the heap (rather than on the stack),
you might also want to make the "MyRTSPServer" constructor
"protected:", and define a static "createNew()" function for creating
these objects. (This is optional, however; instead, your application
code could just do "new myRTSPServer";)
--
Ross Finlayson
Live Networks, Inc.
http://www.live555.com/
More information about the live-devel
mailing list