Exemplo n.º 1
0
        /////////////////////////////////////////////////////////////////////
        // Name: SelectVideoStream
        //
        // Selects the first video stream for parsing with the ASF splitter.
        //
        // pContentInfo: Pointer to an initialized instance of the ASF
        //               content information object.
        // pSplitter:    Pointer to the ASF splitter.
        // pbHasVideo:   Receives TRUE if there is a video stream, or FALSE
        //               otherwise.
        /////////////////////////////////////////////////////////////////////

        void SelectVideoStream(
            IMFASFContentInfo pContentInfo,
            IMFASFSplitter pSplitter,
            out bool pbHasVideo
            )
        {
            int   cStreams;
            short wStreamID = 33;

            short[] wStreamIDs = new short[1];
            Guid    streamType;
            bool    bFoundVideo = false;
            HResult hr;

            IMFASFProfile      pProfile;
            IMFASFStreamConfig pStream;

            // Get the ASF profile from the content information object.
            hr = pContentInfo.GetProfile(out pProfile);
            MFError.ThrowExceptionForHR(hr);

            try
            {
                // Loop through all of the streams in the profile.
                hr = pProfile.GetStreamCount(out cStreams);
                MFError.ThrowExceptionForHR(hr);

                for (int i = 0; i < cStreams; i++)
                {
                    // Get the stream type and stream identifier.
                    hr = pProfile.GetStream(i, out wStreamID, out pStream);
                    MFError.ThrowExceptionForHR(hr);

                    try
                    {
                        hr = pStream.GetStreamType(out streamType);
                        MFError.ThrowExceptionForHR(hr);

                        if (streamType == MFMediaType.Video)
                        {
                            bFoundVideo = true;
                            break;
                        }
                    }
                    finally
                    {
                        SafeRelease(pStream);
                    }
                }
            }
            finally
            {
                SafeRelease(pProfile);
            }

            // Select the video stream, if found.
            if (bFoundVideo)
            {
                // SelectStreams takes an array of stream identifiers.
                wStreamIDs[0] = wStreamID;
                hr            = pSplitter.SelectStreams(wStreamIDs, 1);
                MFError.ThrowExceptionForHR(hr);
            }

            pbHasVideo = bFoundVideo;
        }
Exemplo n.º 2
0
        /////////////////////////////////////////////////////////////////////
        // Name: SelectVideoStream
        //
        // Selects the first video stream for parsing with the ASF splitter.
        //
        // pContentInfo: Pointer to an initialized instance of the ASF
        //               content information object.
        // pSplitter:    Pointer to the ASF splitter.
        // pbHasVideo:   Receives TRUE if there is a video stream, or FALSE
        //               otherwise.
        /////////////////////////////////////////////////////////////////////
        void SelectVideoStream(
            IMFASFContentInfo pContentInfo,
            IMFASFSplitter pSplitter,
            out bool pbHasVideo
            )
        {
            int cStreams;
            short wStreamID = 33;
            short[] wStreamIDs = new short[1];
            Guid streamType;
            bool bFoundVideo = false;

            IMFASFProfile pProfile;
            IMFASFStreamConfig pStream;

            // Get the ASF profile from the content information object.
            int hr = pContentInfo.GetProfile(out pProfile);
            MFError.ThrowExceptionForHR(hr);

            try
            {
                // Loop through all of the streams in the profile.
                hr = pProfile.GetStreamCount(out cStreams);
                MFError.ThrowExceptionForHR(hr);

                for (int i = 0; i < cStreams; i++)
                {
                    // Get the stream type and stream identifier.
                    hr = pProfile.GetStream(i, out wStreamID, out pStream);
                    MFError.ThrowExceptionForHR(hr);

                    try
                    {
                        hr = pStream.GetStreamType(out streamType);
                        MFError.ThrowExceptionForHR(hr);

                        if (streamType == MFMediaType.Video)
                        {
                            bFoundVideo = true;
                            break;
                        }
                    }
                    finally
                    {
                        SafeRelease(pStream);
                    }
                }
            }
            finally
            {
                SafeRelease(pProfile);
            }

            // Select the video stream, if found.
            if (bFoundVideo)
            {
                // SelectStreams takes an array of stream identifiers.
                wStreamIDs[0] = wStreamID;
                hr = pSplitter.SelectStreams(wStreamIDs, 1);
                MFError.ThrowExceptionForHR(hr);
            }

            pbHasVideo = bFoundVideo;
        }