/// <summary>
        /// Queries the underlying Sink Writer object.
        /// </summary>
        /// <param name="captureSink">A valid IMFCaptureSink instance.</param>
        /// <param name="sinkStreamIndex">The zero-based index of the streamIndex to query. The index is returned in the sinkStreamIndex parameter of the <see cref="IMFCaptureSink.AddStream"/> method.</param>
        /// <param name="sourceReader">Receives an instance of the underlying Sink Writer.</param>
        /// <returns>If this function succeeds, it returns the S_OK member. Otherwise, it returns another HResult's member that describe the error.</returns>
        public static HResult GetService(this IMFCaptureSink captureSink, int sinkStreamIndex, out IMFSinkWriter sinkWriter)
        {
            if (captureSink == null)
            {
                throw new ArgumentNullException("captureSink");
            }

            object tmp;

            HResult hr = captureSink.GetService(sinkStreamIndex, Guid.Empty, typeof(IMFSinkWriterExtensions).GUID, out tmp);

            sinkWriter = hr.Succeeded() ? tmp as IMFSinkWriter : null;

            return(hr);
        }