Streaming Video files

Topics: Web Api
Jan 20, 2012 at 1:00 PM

Hi,

Is it recommended to use WCF Web APIs for streaming (System.IO.Stream) large video files?

Are there any good examples on how to do this?

Thanks.

Jan 21, 2012 at 3:13 PM
Edited Jan 21, 2012 at 3:16 PM

Anybody there?

I am trying to convert a gblock written code(http://blogs.msdn.com/b/endpoint/archive/2010/11/24/streaming-over-http-with-wcf.aspx) to work with the APIs.

My code so far looks like below

 [ServiceContract]
    public class VideoResource
    {

        [WebGet(UriTemplate = "")]
        public Stream Get()
        {
            FileStream stream = new FileStream(@"C:\Users\Public\Videos\Sample Videos\Wildlife.wmv", FileMode.Open, FileAccess.Read);
           
            return stream;
        }

       
    }
}
and my global.asax is 
 protected void Application_Start(object sender, EventArgs e)
        {
            RouteTable.Routes.MapServiceRoute<VideoResource>("video");

        }
I am not using any HTTPConfiguration stuff yet.
When I looked at gblock's old code, response content-type is application/octet-stream.
I am not sure if I need to add a mediaformatter. If it's the case what's it's implementation?
web.config is -
<system.web>
    <compilation debug="true" targetFramework="4.0" />
    <httpRuntime maxRequestLength="2147483647"/>
  </system.web>
  <system.serviceModel>
    <serviceHostingEnvironment aspNetCompatibilityEnabled="true" />
    <bindings>
      <basicHttpBinding>
        <binding maxReceivedMessageSize="2147483647" maxBufferSize="2147483647" transferMode="Streamed" messageEncoding="Mtom"/>
      </basicHttpBinding>
    </bindings>
  </system.serviceModel>

 

please help.