예제 #1
0
        /// <summary>
        /// Enables processing of HTTP Web requests by a custom HttpHandler that implements the <see cref="T:System.Web.IHttpHandler"/> interface.
        /// </summary>
        /// <param name="context">An <see cref="T:System.Web.HttpContext"/> object that provides references to the intrinsic server objects (for example, Request, Response, Session, and Server) used to service HTTP requests. </param>
        public void ProcessRequest(HttpContext context)
        {
            RoleType? roleType = context.User.Identity.IsAuthenticated ? UserProfile.GetRoleForUser(context.User.Identity.Name) : new RoleType?();
            bool isAdmin = roleType.HasValue && (roleType.Value == RoleType.Admin || roleType.Value == RoleType.AdminLeader);

            string idRequest = context.Request.QueryString["id"];
            int id;
            Int32.TryParse(idRequest ?? String.Empty, out id);

            string token = context.Request.QueryString["token"];

            var server = new HttpServerUtilityWrapper(context.Server);
            var streamVideoStream = new StreamVideoStream(isAdmin, id, token, server);
            if (!streamVideoStream.IsValid)
                throw new Exception("Cannot process video stream.");

            context.Response.Clear();
            context.Response.ContentType = HttpResponseBaseService.GetContentType(streamVideoStream.VideoRelativeFilePath);
            context.Response.TransmitFile(streamVideoStream.VideoRelativeFilePath);
        }
예제 #2
0
        private ActionResult VideoData(int id, string token)
        {
            var streamVideoStream = new StreamVideoStream(IsAdmin, id, token, Server);
            if (!streamVideoStream.IsValid)
                throw new Exception("Cannot process video stream.");

            var videoFileInfo = new FileInfo(streamVideoStream.VideoAbsoluteFilePath);
            var videoContentType = HttpResponseBaseService.GetContentType(streamVideoStream.VideoRelativeFilePath);

            return new RangeFilePathResult(videoContentType, videoFileInfo.FullName, videoFileInfo.LastWriteTimeUtc, videoFileInfo.Length);
        }