MediaStreamSink::create Method |
||||||||||||||||||||||||||||||||
Creates a new MediaStreamSink. | ||||||||||||||||||||||||||||||||
Syntax: | static tMediaStreamSinkPtr create( const tMediaStreamContainerPtr& pCont, IFrameFilter* pFilter = 0 ); static tMediaStreamSinkPtr create( const tMediaStreamContainerPtr& pCont, const tFrameFilterList& lst ); static tMediaStreamSinkPtr create( const tMediaStreamContainerPtr& pCont, const smart_ptr<Codec>& pCodec, IFrameFilter* pFilter = 0 ); static tMediaStreamSinkPtr create( const tMediaStreamContainerPtr& pCont, const smart_ptr<Codec>& pCodec, const tFrameFilterList& lst ); static tMediaStreamSinkPtr create( const tMediaStreamContainerPtr& pCont, const GUID& subtype, IFrameFilter* pFilter = 0 ); static tMediaStreamSinkPtr create( const tMediaStreamContainerPtr& pCont, const GUID& subtype, const tFrameFilterList& lst ); static tMediaStreamSinkPtr create( const GUID& containerID, IFrameFilter* pFilter = 0 ); static tMediaStreamSinkPtr create( const GUID& containerID, const tFrameFilterList& lst ); static tMediaStreamSinkPtr create( const GUID& containerID, const smart_ptr<Codec>& pCodec, IFrameFilter* pFilter = 0 ); static tMediaStreamSinkPtr create( const GUID& containerID, const smart_ptr<Codec>& pCodec, const tFrameFilterList& lst ); static tMediaStreamSinkPtr create( const GUID& containerID, const GUID& subtype, IFrameFilter* pFilter = 0 ); static tMediaStreamSinkPtr create( const GUID& containerID, const GUID& subtype, const tFrameFilterList& lst ); static tMediaStreamSinkPtr create( const tCreateData& create_data ); |
|||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||
Return Value: | A pointer to the new MediaStreamSink, or 0, if an error occurred. |
|||||||||||||||||||||||||||||||
Remarks: | Some media stream containers do not work with certain codecs. On the other hand, some media stream containers do not accept uncompressed video formats. In this case, Grabber::startLive will fail and you will have to try a different container/codec combination. |
|||||||||||||||||||||||||||||||
Examples: | To record an AVI file, you have to create an AVI media stream container that is identified by MSC_AviContainer. Select a codec from the list returned by Codec::getAvailableCodecs and create the MediaStreamSink. After the sink has been created, you have to set a video filename, by calling MediaStreamSink::setFilename: // Create an AVI Media Stream Container. tMediaStreamContainerPtr pAVIContainer = MediaStreamContainer::create( MSC_AviContainer ); // Obtain a list of available codecs. tCodecListPtr pAvailableCodecList = Codec::getAvailableCodecs(); // Select the first codec. You would usually allow the user to make this choice // or hard code the search for a codec name. tCodecPtr pCodec = pAvailableCodecList->at( 0 ); // Create the media stream sink from these parameters. tMediaStreamSinkPtr pSink = MediaStreamSink::create( pAVIContainer, pCodec ); // Set a target filename. pSink->setFilename( "test.avi" ); // Set the sink. m_Grabber.setSinkType( pSink ); To get a list of the available MediaStreamContainers, use MediaStreamContainer::getAvailableMediaStreamContainers. You can find out whether a MediaStreamContainer supports codecs or uncompressed formats by calling MediaStreamContainer::isCustomCodecSupported. In this case, you can create the sink as seen above. When no custom codecs are supported, you are not allowed to specify a codec in MediaStreamSink::create. To set a matching video filename, you can call MediaStreamContainer::getPreferredFileExtension to get the default file extension for that video file format. // Get a list of the available media stream containers. tMediaStreamContainerListPtr pAvailableContainers = MediaStreamContainer::getAvailableMediaStreamContainers(); // Select the first container. You would usually allow the user to make this choice // or hard code the search for a container name. tMediaStreamContainerPtr pContainer = pAvailableContainers->at( 0 ); // Sink object to be created. tMediaStreamSinkPtr pSink; // If the container supports codecs, select one. if( pContainer->isCustomCodecSupported() ) { // Obtain a list of available codecs. tCodecListPtr pAvailableCodecList = Codec::getAvailableCodecs(); // Select the first codec. You would usually allow the user to make this choice // or hard code the search for a codec name. tCodecPtr pCodec = pAvailableCodecList->at( 0 ); // Create the media stream sink from these parameters. pSink = MediaStreamSink::create( pContainer, pCodec ); } else { // No codec support; just create the sink. pSink = MediaStreamSink::create( pContainer ); } // Create a file name from a name and the preferred extension of the container. std::string filename = "test."; filename += pContainer->getPreferredFileExtension(); pSink->setFilename( filename ); // Set the sink. m_Grabber.setSinkType( pSink ); To save uncompressed AVI, use the subtype of the desired uncompressed format as second parameter to MediaStreamSink::create. // Create an AVI Media Stream Container. tMediaStreamContainerPtr pAVIContainer = MediaStreamContainer::create( MSC_AviContainer ); // Create the media stream sink from these parameters. tMediaStreamSinkPtr pSink = MediaStreamSink::create( pAVIContainer, MEDIASUBTYPE_RGB24 ); // Set a target filename. pSink->setFilename( "test.avi" ); // Set the sink. m_Grabber.setSinkType( pSink ); |
|||||||||||||||||||||||||||||||
See also: | MediaStreamSink, MediaStreamContainer, IFrameFilter |