Using VS2010 and C++, I am using a supplier library to interface to their USB industrial camera.
The library has an base abstract class for data stream sinks called GrabberSinkType
, and one of derived classes from that is MediaStreamSink
which deals with writing streams to video files. One of the methods supported by MediaStreamSink
(not a virtual function of the base class) is getFilename()
which simply returns the name of the file being written to.
The main Grabber
class which handles streaming has a method getSinkTypePtr()
, which returns a pointer to the sink in current use, defined as smart_ptr<GrabberSinkType> getSinkTypePtr() const;
.
What I need to do is check if is a MediaStreamSink, and if so, get the filename. And I cannot get it to compile. Having checked if it is a media stream type, all I am doing is
CString SinkPath = dynamic_cast<tMediaStreamSinkPtr>(m_cGrabber.getSinkTypePtr())->getFilename().c_str();
(tMediaStreamSinkPtr
is typedef'd assmart_ptr<MediaStreamSink>
). This results in error 2680:
"error C2680: 'DShowLib::tMediaStreamSinkPtr' : invalid target type for dynamic_cast target type must be a pointer or reference to a defined class"
I have tried every possible combination of dynamic casts, static casts, old style casts I can think of, and whilst the error changes, I cannot get it to compile.
I clearly don't know what I'm doing here, how do I get a pointer to the dervied class and successfully call its getFilename()
method?