示例#1
0
        //
        // HTTP Live Streaming
        public ActionResult StartHttpLiveStream(WebMediaType type, string itemId, int fileindex, string transcoder, string continuationId)
        {
            if (!IsUserAuthenticated())
            {
                Log.Warn("User {0} (host {1}) requested a HLS stream but isn't authenticated - denying access", HttpContext.User.Identity.Name, Request.UserHostAddress);
                return(new HttpUnauthorizedResult());
            }

            var    profile    = GetProfile(GetStreamControl(type), transcoder);
            string identifier = ActuallyStartHttpLiveStream(type, itemId, fileindex, profile, 0, continuationId);

            if (identifier != null)
            {
                string url = GetStreamMode() == StreamType.Direct ? HttpLiveUrls[identifier] :
                             Url.Action(Enum.GetName(typeof(WebMediaType), type), new RouteValueDictionary()
                {
                    { "item", itemId },
                    { "fileindex", fileindex },
                    { "transcoder", transcoder },
                    { "continuationId", continuationId }
                });

                // iOS does not display poster images with relative paths
                string posterUrl = Url.AbsoluteArtwork(type, itemId);
                Log.Debug("HLS: Replying to explicit AJAX HLS start request for continuationId={0} with mode={1}; url={2}", continuationId, GetStreamMode(), url);
                return(Json(new { Success = true, URL = url, Poster = posterUrl }, JsonRequestBehavior.AllowGet));
            }
            else
            {
                return(Json(new { Succes = false }, JsonRequestBehavior.AllowGet));
            }
        }