コード例 #1
0
ファイル: MediaSource.cs プロジェクト: bjarkimg/MPExtended
 protected virtual bool CheckArguments(WebStreamMediaType mediatype, WebArtworkType filetype)
 {
     return(!(
                (mediatype == WebStreamMediaType.TV && FileType != WebArtworkType.Content) ||
                (mediatype == WebStreamMediaType.Recording && FileType != WebArtworkType.Content)
                ));
 }
コード例 #2
0
        //
        // Streaming
        private int?GetProvider(WebStreamMediaType type)
        {
            switch (type)
            {
            case WebStreamMediaType.File:
                return(Settings.ActiveSettings.FileSystemProvider);

            case WebStreamMediaType.Movie:
                return(Settings.ActiveSettings.MovieProvider);

            case WebStreamMediaType.MusicAlbum:
            case WebStreamMediaType.MusicTrack:
                return(Settings.ActiveSettings.MusicProvider);

            case WebStreamMediaType.Picture:
                return(Settings.ActiveSettings.PicturesProvider);

            case WebStreamMediaType.Recording:
            case WebStreamMediaType.TV:
                return(0);

            case WebStreamMediaType.TVEpisode:
            case WebStreamMediaType.TVSeason:
            case WebStreamMediaType.TVShow:
                return(Settings.ActiveSettings.TVShowProvider);

            default:
                // this cannot happen
                return(0);
            }
        }
コード例 #3
0
        public Stream ExtractImageResized(WebStreamMediaType type, int?provider, string itemId, int position, int maxWidth, int maxHeight)
        {
            int?calcMaxWidth  = maxWidth == 0 ? null : (int?)maxWidth;
            int?calcMaxHeight = maxHeight == 0 ? null : (int?)maxHeight;

            return(Images.ExtractImage(new MediaSource(type, provider, itemId), position, calcMaxWidth, calcMaxHeight));
        }
コード例 #4
0
        public Stream GetImageResized(WebStreamMediaType type, int?provider, string id, int maxWidth, int maxHeight)
        {
            int?calcMaxWidth  = maxWidth == 0 ? null : (int?)maxWidth;
            int?calcMaxHeight = maxHeight == 0 ? null : (int?)maxHeight;

            return(Images.GetResizedImage(new ImageMediaSource(type, provider, id, WebArtworkType.Content, 0), calcMaxWidth, calcMaxHeight));
        }
コード例 #5
0
        public Stream GetArtworkResized(WebStreamMediaType mediatype, int?provider, string id, WebArtworkType artworktype, int offset, int maxWidth, int maxHeight)
        {
            int?calcMaxWidth  = maxWidth == 0 ? null : (int?)maxWidth;
            int?calcMaxHeight = maxHeight == 0 ? null : (int?)maxHeight;

            return(Images.GetResizedImage(new ImageMediaSource(mediatype, provider, id, artworktype, offset), calcMaxWidth, calcMaxHeight));
        }
コード例 #6
0
ファイル: MediaName.cs プロジェクト: changer4/MPExtended
 public static string GetMediaName(WebStreamMediaType type, string id)
 {
     try
     {
         switch (type)
         {
             case WebStreamMediaType.Movie:
                 return MPEServices.MAS.GetMovieBasicById(Settings.ActiveSettings.MovieProvider, id).Title;
             case WebStreamMediaType.MusicAlbum:
                 return MPEServices.MAS.GetMusicAlbumBasicById(Settings.ActiveSettings.MusicProvider, id).Title;
             case WebStreamMediaType.MusicTrack:
                 return MPEServices.MAS.GetMusicTrackBasicById(Settings.ActiveSettings.MusicProvider, id).Title;
             case WebStreamMediaType.Recording:
                 return MPEServices.TAS.GetRecordingById(Int32.Parse(id)).Title;
             case WebStreamMediaType.TV:
                 return MPEServices.TAS.GetChannelBasicById(Int32.Parse(id)).DisplayName;
             case WebStreamMediaType.TVEpisode:
                 return MPEServices.MAS.GetTVEpisodeBasicById(Settings.ActiveSettings.TVShowProvider, id).Title;
             case WebStreamMediaType.TVShow:
                 return MPEServices.MAS.GetTVShowBasicById(Settings.ActiveSettings.TVShowProvider, id).Title;
             case WebStreamMediaType.TVSeason:
             default:
                 return "";
         }
     }
     catch (Exception ex)
     {
         Log.Warn("Could not load display name of media", ex);
     }
     return "";
 }
コード例 #7
0
 public MediaSource(WebStreamMediaType type, int? provider, string id)
 {
     this.MediaType = type;
     this.Id = id;
     this.Offset = 0;
     this.Provider = provider;
 }
コード例 #8
0
ファイル: StreamController.cs プロジェクト: aredon/MPExtended
        public ActionResult Download(WebStreamMediaType type, string item)
        {
            // Create URL to GetMediaItem
            var queryString = HttpUtility.ParseQueryString(String.Empty); // you can't instantiate that class manually for some reason
            queryString["type"] = ((int)type).ToString();
            queryString["itemId"] = item;
            string rootUrl = type == WebStreamMediaType.TV || type == WebStreamMediaType.Recording ? MPEServices.HttpTASStreamRoot : MPEServices.HttpMASStreamRoot;
            Uri fullUri = new Uri(rootUrl + "GetMediaItem?" + queryString.ToString());

            // Check stream type
            StreamType streamMode = Settings.ActiveSettings.StreamType;
            if (streamMode == StreamType.DirectWhenPossible)
            {
                streamMode = NetworkInformation.IsOnLAN(HttpContext.Request.UserHostAddress) ? StreamType.Direct : StreamType.Proxied;
            }

            // Do the actual streaming
            if (streamMode == StreamType.Proxied)
            {
                ProxyStream(fullUri.ToString());
            }
            else if (streamMode == StreamType.Direct)
            {
                return Redirect(fullUri.ToString());
            }
            return new EmptyResult();
        }
コード例 #9
0
 protected override bool CheckArguments(WebStreamMediaType mediatype, WebArtworkType filetype)
 {
     if ((mediatype == WebStreamMediaType.TV || mediatype == WebStreamMediaType.Recording) && filetype == WebArtworkType.Logo)
     {
         return(true);
     }
     return(base.CheckArguments(mediatype, filetype));
 }
コード例 #10
0
 private IWebStreamingService GetStreamControl(WebStreamMediaType type)
 {
     if (type == WebStreamMediaType.TV || type == WebStreamMediaType.Recording)
     {
         return(MPEServices.TASStreamControl);
     }
     else
     {
         return(MPEServices.MASStreamControl);
     }
 }
コード例 #11
0
ファイル: MediaSource.cs プロジェクト: bjarkimg/MPExtended
        public MediaSource(WebStreamMediaType type, int?provider, string id, WebArtworkType filetype, int offset)
        {
            this.MediaType = type;
            this.Id        = id;
            this.Provider  = provider;
            this.Offset    = offset;
            this.FileType  = filetype;

            if (!CheckArguments(type, filetype))
            {
                throw new ArgumentException("Invalid combination of mediatype and filetype");
            }
        }
コード例 #12
0
ファイル: MediaSource.cs プロジェクト: aredon/MPExtended
        public MediaSource(WebStreamMediaType type, int? provider, string id, WebArtworkType filetype, int offset)
        {
            this.MediaType = type;
            this.Id = id;
            this.Provider = provider;
            this.Offset = offset;
            this.FileType = filetype;

            if (!CheckArguments(type, filetype))
            {
                throw new ArgumentException("Invalid combination of mediatype and filetype");
            }
        }
コード例 #13
0
        public WebMediaInfo GetMediaInfo(WebStreamMediaType type, int?provider, string itemId)
        {
            if (type == WebStreamMediaType.TV)
            {
                try
                {
                    itemId = _timeshiftings[itemId].TimeShiftFileName;
                }
                catch (KeyNotFoundException)
                {
                    Log.Error("Client tried to get mediainfo for non-existing timeshifting {0}", itemId);
                    return(null);
                }
            }

            return(MediaInfo.MediaInfoWrapper.GetMediaInfo(new MediaSource(type, provider, itemId)));
        }
コード例 #14
0
        public bool InitStream(WebStreamMediaType type, int?provider, string itemId, string clientDescription, string identifier)
        {
            if (type == WebStreamMediaType.TV)
            {
                int channelId = Int32.Parse(itemId);
                lock (_timeshiftings)
                {
                    Log.Info("Starting timeshifting on channel {0} for client {1} with identifier {2}", channelId, clientDescription, identifier);
                    var card = MPEServices.TAS.SwitchTVServerToChannelAndGetVirtualCard("webstreamingservice-" + identifier, channelId);
                    Log.Debug("Timeshifting started!");
                    _timeshiftings[identifier] = card;
                    itemId = card.TimeShiftFileName;
                }
            }

            Log.Info("Called InitStream with type={0}; provider={1}; itemId={2}; clientDescription={3}; identifier={4}", type, provider, itemId, clientDescription, identifier);
            return(_stream.InitStream(identifier, clientDescription, new MediaSource(type, provider, itemId)));
        }
コード例 #15
0
        public Stream GetMediaItem(WebStreamMediaType type, int?provider, string itemId)
        {
            MediaSource source = new MediaSource(type, provider, itemId);

            try
            {
                if (!source.Exists)
                {
                    throw new FileNotFoundException();
                }
                return(source.Retrieve());
            }
            catch (Exception ex)
            {
                WCFUtil.SetResponseCode(System.Net.HttpStatusCode.NotFound);
                Log.Info(String.Format("GetMediaItem() failed for {0}", source.GetDebugName()), ex);
                return(Stream.Null);
            }
        }
コード例 #16
0
        //
        // Player
        public ActionResult Player(WebStreamMediaType type, string itemId, bool showVideo = true)
        {
            // TODO: insert proper support for non-resizing players
            // TODO: insert proper support for VLC player

            // get the profile
            string target = showVideo ? "pc-flash-video" : "pc-flash-audio";
            string preferredProfile = showVideo ? "Flash LQ" : "Flash Audio";
            string transcoderName = Request.Params["player"] != null ? Request.Params["player"] : preferredProfile;
            WebTranscoderProfile profile = MPEServices.MASStreamControl.GetTranscoderProfileByName(transcoderName);
            if (profile == null || profile.Target != target) {
                List<WebTranscoderProfile> profiles = MPEServices.MASStreamControl.GetTranscoderProfilesForTarget(target);
                if(profiles.Count == 0)
                    throw new ArgumentException("Profile does not exists");
                profile = profiles.First();
            }
            VideoPlayer player = VideoPlayer.Flash;
            string viewName = Enum.GetName(typeof(VideoPlayer), player) + "Player";

            // player size
            WebResolution playerSize;
            if (!showVideo)
            {
                playerSize = new WebResolution() { Width = 300, Height = 120 };
            }
            else
            {
                playerSize = MPEServices.MASStreamControl.GetStreamSize((WebStreamMediaType)type, GetProvider((WebStreamMediaType)type), itemId, profile.Name);
            }

            // generate url
            RouteValueDictionary parameters = new RouteValueDictionary();
            parameters["item"] = itemId;
            parameters["transcoder"] = transcoderName;

            // generate view
            return PartialView(viewName, new StreamModel
            {
                URL = Url.Action(Enum.GetName(typeof(WebStreamMediaType), type), parameters),
                Size = playerSize
            });
        }
コード例 #17
0
        private ActionResult GenerateStream(WebStreamMediaType type, string itemId, string transcoder)
        {
            string identifier = "webmediaportal-" + Guid.NewGuid().ToString("D");

            if (!GetStreamControl(type).InitStream((WebStreamMediaType)type, GetProvider(type), itemId, "WebMediaPortal", identifier))
            {
                Log.Error("Streaming: InitStream failed");
                return(new EmptyResult());
            }

            string url = GetStreamControl(type).StartStream(identifier, transcoder, 0);

            if (String.IsNullOrEmpty(url))
            {
                Log.Error("Streaming: StartStream failed");
                return(new EmptyResult());
            }

            // redirect user to stream (WSS has automatic stream killing now)
            return(Redirect(url));
        }
コード例 #18
0
ファイル: StreamController.cs プロジェクト: bbmjen/MPExtended
        public ActionResult Download(WebStreamMediaType type, string item)
        {
            // Create URL to GetMediaItem
            Log.Debug("User wants to download type={0}; item={1}", type, item);
            var queryString = HttpUtility.ParseQueryString(String.Empty); // you can't instantiate that class manually for some reason
            queryString["clientDescription"] = String.Format("WebMediaPortal download (user {0})", HttpContext.User.Identity.Name);
            queryString["type"] = ((int)type).ToString();
            queryString["itemId"] = item;
            string rootUrl = type == WebStreamMediaType.TV || type == WebStreamMediaType.Recording ? MPEServices.HttpTASStreamRoot : MPEServices.HttpMASStreamRoot;
            UriBuilder fullUri = new UriBuilder(rootUrl + "GetMediaItem?" + queryString.ToString());

            // Check stream type
            StreamType streamMode = Settings.ActiveSettings.StreamType;
            if (streamMode == StreamType.DirectWhenPossible)
            {
                streamMode = NetworkInformation.IsOnLAN(HttpContext.Request.UserHostAddress) ? StreamType.Direct : StreamType.Proxied;
            }

            // If we connect to the services at localhost, actually give the extern IP address to users
            if (fullUri.Host == "localhost" || fullUri.Host == "127.0.0.1")
            {
                fullUri.Host = NetworkInformation.GetIPAddresses().First();
            }

            // Do the actual streaming
            if (streamMode == StreamType.Proxied)
            {
                Log.Debug("Proxying download at {0}", fullUri.ToString());
                GetStreamControl(type).AuthorizeStreaming();
                ProxyStream(fullUri.ToString());
            }
            else if (streamMode == StreamType.Direct)
            {
                Log.Debug("Redirecting user to download at {0}", fullUri.ToString());
                GetStreamControl(type).AuthorizeRemoteHostForStreaming(HttpContext.Request.UserHostAddress);
                return Redirect(fullUri.ToString());
            }
            return new EmptyResult();
        }
コード例 #19
0
ファイル: Downloads.cs プロジェクト: bbmjen/MPExtended
        public Stream Download(string clientDescription, WebStreamMediaType type, int? provider, string itemId)
        {
            // validate source first
            MediaSource source = new MediaSource(type, provider, itemId);
            if (!source.Exists)
            {
                throw new FileNotFoundException();
            }

            // create context
            DownloadContext context = new DownloadContext()
            {
                ClientDescription = clientDescription,
                Source = source,
                StartTime = DateTime.Now,
                Stream = new ReadTrackingStreamWrapper(source.Retrieve()),
                MediaInfo = MediaInfoHelper.LoadMediaInfoOrSurrogate(source) // for playerposition view
            };

            // see comment in Streaming.cs:151
            string realIp = WCFUtil.GetHeaderValue("forwardedFor", "X-Forwarded-For");
            context.ClientIP = realIp == null ? WCFUtil.GetClientIPAddress() : String.Format("{0} (via {1})", realIp, WCFUtil.GetClientIPAddress());

            // set headers for downloading
            WCFUtil.AddHeader("Content-Disposition", "attachment; filename=\"" + source.GetFileInfo().Name + "\"");
            WCFUtil.SetContentLength(source.GetFileInfo().Size);

            // FIXME: there has to be a better way to do this
            string mime = MIME.GetFromFilename(source.GetFileInfo().Name);
            if (mime != null)
            {
                WCFUtil.SetContentType(mime);
            }

            // finally, save the context and return
            runningDownloads.Add(context);
            return context.Stream;
        }
コード例 #20
0
 public Stream GetArtworkResized(WebStreamMediaType mediatype, int? provider, string id, WebArtworkType artworktype, int offset, int maxWidth, int maxHeight)
 {
     return Images.GetResizedImage(new MediaSource(mediatype, provider, id, offset), artworktype, maxWidth, maxHeight);
 }
コード例 #21
0
ファイル: MediaSource.cs プロジェクト: bjarkimg/MPExtended
 public MediaSource(WebStreamMediaType type, int?provider, string id, WebArtworkType filetype)
     : this(type, provider, id, filetype, 0)
 {
 }
コード例 #22
0
        private ActionResult GenerateStream(WebStreamMediaType type, string itemId, string transcoder)
        {
            string identifier = "webmediaportal-" + Guid.NewGuid().ToString("D");
            if (!GetStreamControl(type).InitStream((WebStreamMediaType)type, GetProvider(type), itemId, "WebMediaPortal", identifier))
            {
                Log.Error("Streaming: InitStream failed");
                return new EmptyResult();
            }

            string url = GetStreamControl(type).StartStream(identifier, transcoder, 0);
            if (String.IsNullOrEmpty(url))
            {
                Log.Error("Streaming: StartStream failed");
                return new EmptyResult();
            }

            // redirect user to stream (WSS has automatic stream killing now)
            return Redirect(url);
        }
コード例 #23
0
 public WebResolution GetStreamSize(WebStreamMediaType type, int?provider, string itemId, string profile)
 {
     return(_stream.CalculateSize(Configuration.Streaming.GetTranscoderProfileByName(profile), new MediaSource(type, provider, itemId)).ToWebResolution());
 }
コード例 #24
0
 public Stream GetImage(WebStreamMediaType type, int? provider, string id)
 {
     return Images.GetImage(new ImageMediaSource(type, provider, id, WebArtworkType.Content, 0));
 }
コード例 #25
0
 public Stream GetImage(WebStreamMediaType type, int?provider, string id)
 {
     return(Images.GetImage(new ImageMediaSource(type, provider, id, WebArtworkType.Content, 0)));
 }
コード例 #26
0
        public WebMediaInfo GetMediaInfo(WebStreamMediaType type, int? provider, string itemId)
        {
            if (type == WebStreamMediaType.TV)
            {
                try
                {
                    itemId = _timeshiftings[itemId].TimeShiftFileName;
                }
                catch (KeyNotFoundException)
                {
                    Log.Error("Client tried to get mediainfo for non-existing timeshifting {0}", itemId);
                    return null;
                }
            }

            return MediaInfo.MediaInfoWrapper.GetMediaInfo(new MediaSource(type, provider, itemId));
        }
コード例 #27
0
 public WebResolution GetStreamSize(WebStreamMediaType type, int? provider, string itemId, string profile)
 {
     return _stream.CalculateSize(Configuration.Streaming.GetTranscoderProfileByName(profile), new MediaSource(type, provider, itemId)).ToWebResolution();
 }
コード例 #28
0
 public Stream ExtractImage(WebStreamMediaType type, int?provider, string itemId, int position)
 {
     return(Images.ExtractImage(new MediaSource(type, provider, itemId), position, null, null));
 }
コード例 #29
0
 private IWebStreamingService GetStreamControl(WebStreamMediaType type)
 {
     if (type == WebStreamMediaType.TV || type == WebStreamMediaType.Recording)
     {
         return MPEServices.TASStreamControl;
     }
     else
     {
         return MPEServices.MASStreamControl;
     }
 }
コード例 #30
0
ファイル: MediaSource.cs プロジェクト: bjarkimg/MPExtended
 public MediaSource(WebStreamMediaType type, int?provider, string id)
     : this(type, provider, id, WebArtworkType.Content, 0)
 {
 }
コード例 #31
0
 public Stream GetArtwork(WebStreamMediaType mediatype, int?provider, string id, WebArtworkType artworktype, int offset)
 {
     return(Images.GetImage(new ImageMediaSource(mediatype, provider, id, artworktype, offset)));
 }
コード例 #32
0
 public ImageMediaSource(WebStreamMediaType type, int?provider, string id, WebArtworkType filetype, int offset)
     : base(type, provider, id, filetype, offset)
 {
 }
コード例 #33
0
 public Stream GetArtwork(WebStreamMediaType mediatype, int? provider, string id, WebArtworkType artworktype, int offset)
 {
     return Images.GetImage(new ImageMediaSource(mediatype, provider, id, artworktype, offset));
 }
コード例 #34
0
 public Stream ExtractImage(WebStreamMediaType type, int? provider, string itemId, int position)
 {
     return Images.ExtractImage(new MediaSource(type, provider, itemId), position, null, null);
 }
コード例 #35
0
 public Stream GetArtworkResized(WebStreamMediaType mediatype, int? provider, string id, WebArtworkType artworktype, int offset, int maxWidth, int maxHeight)
 {
     int? calcMaxWidth = maxWidth == 0 ? null : (int?)maxWidth;
     int? calcMaxHeight = maxHeight == 0 ? null : (int?)maxHeight;
     return Images.GetResizedImage(new ImageMediaSource(mediatype, provider, id, artworktype, offset), calcMaxWidth, calcMaxHeight);
 }
コード例 #36
0
ファイル: Images.cs プロジェクト: bjarkimg/MPExtended
 protected override bool CheckArguments(WebStreamMediaType mediatype, WebArtworkType filetype)
 {
     if ((mediatype == WebStreamMediaType.TV || mediatype == WebStreamMediaType.Recording) && filetype == WebArtworkType.Logo)
         return true;
     return base.CheckArguments(mediatype, filetype);
 }
コード例 #37
0
 public Stream GetImageResized(WebStreamMediaType type, int? provider, string id, int maxWidth, int maxHeight)
 {
     int? calcMaxWidth = maxWidth == 0 ? null : (int?)maxWidth;
     int? calcMaxHeight = maxHeight == 0 ? null : (int?)maxHeight;
     return Images.GetResizedImage(new ImageMediaSource(type, provider, id, WebArtworkType.Content, 0), calcMaxWidth, calcMaxHeight);
 }
コード例 #38
0
        public ActionResult Player(WebStreamMediaType type, string itemId, bool video = true)
        {
            // get transcoding profile
            IWebStreamingService streamControl = GetStreamControl(type);
            WebTranscoderProfile profile       = null;

            if (Request.QueryString["transcoder"] != null)
            {
                profile = GetStreamControl(type).GetTranscoderProfileByName(Request.QueryString["transcoder"]);
            }
            if (Request.Form["transcoder"] != null)
            {
                profile = GetStreamControl(type).GetTranscoderProfileByName(Request.Form["transcoder"]);
            }
            if (profile == null)
            {
                string defaultName = "";
                if (type == WebStreamMediaType.TV || type == WebStreamMediaType.Recording)
                {
                    defaultName = Settings.ActiveSettings.DefaultTVProfile;
                }
                else if (video)
                {
                    defaultName = Settings.ActiveSettings.DefaultMediaProfile;
                }
                else
                {
                    defaultName = Settings.ActiveSettings.DefaultAudioProfile;
                }
                profile = GetStreamControl(type).GetTranscoderProfileByName(defaultName);
            }

            // get all transcoder profiles
            List <StreamTarget> targets  = video ? StreamTarget.GetVideoTargets() : StreamTarget.GetAudioTargets();
            List <string>       profiles = new List <string>();

            foreach (StreamTarget target in targets)
            {
                profiles = profiles.Concat(GetStreamControl(type).GetTranscoderProfilesForTarget(target.Name).Select(x => x.Name)).ToList();
            }

            // get view properties
            VideoPlayer player   = targets.First(x => x.Name == profile.Target).Player;
            string      viewName = Enum.GetName(typeof(VideoPlayer), player) + "Player";

            // player size
            WebResolution playerSize;

            if (!video)
            {
                playerSize = new WebResolution()
                {
                    Width = 300, Height = 150
                };
            }
            else
            {
                playerSize = GetStreamControl(type).GetStreamSize(type, GetProvider(type), itemId, profile.Name);
            }

            // generate url
            RouteValueDictionary parameters = new RouteValueDictionary();

            parameters["item"]       = itemId;
            parameters["transcoder"] = profile.Name;

            // generate view
            return(PartialView(new PlayerViewModel
            {
                Transcoders = profiles,
                Transcoder = profile.Name,
                Player = player,
                PlayerViewName = viewName,
                URL = Url.Action(Enum.GetName(typeof(WebStreamMediaType), type), parameters),
                Size = playerSize
            }));
        }
コード例 #39
0
 public Stream GetMediaItem(WebStreamMediaType type, int? provider, string itemId)
 {
     MediaSource source = new MediaSource(type, provider, itemId);
     try
     {
         if (!source.Exists)
         {
             throw new FileNotFoundException();
         }
         return source.Retrieve();
     }
     catch (Exception ex)
     {
         WCFUtil.SetResponseCode(System.Net.HttpStatusCode.NotFound);
         Log.Info(String.Format("GetMediaItem() failed for {0}", source.GetDebugName()), ex);
         return Stream.Null;
     }
 }
コード例 #40
0
ファイル: MediaSource.cs プロジェクト: aredon/MPExtended
 public MediaSource(WebStreamMediaType type, int? provider, string id)
     : this(type, provider, id, WebArtworkType.Content, 0)
 {
 }
コード例 #41
0
        public bool InitStream(WebStreamMediaType type, int? provider, string itemId, string clientDescription, string identifier)
        {
            if (type == WebStreamMediaType.TV)
            {
                int channelId = Int32.Parse(itemId);
                lock (_timeshiftings)
                {
                    Log.Info("Starting timeshifting on channel {0} for client {1} with identifier {2}", channelId, clientDescription, identifier);
                    var card = MPEServices.TAS.SwitchTVServerToChannelAndGetVirtualCard("webstreamingservice-" + identifier, channelId);
                    Log.Debug("Timeshifting started!");
                    _timeshiftings[identifier] = card;
                    itemId = card.TimeShiftFileName;
                }
            }

            Log.Info("Called InitStream with type={0}; provider={1}; itemId={2}; clientDescription={3}; identifier={4}", type, provider, itemId, clientDescription, identifier);
            return _stream.InitStream(identifier, clientDescription, new MediaSource(type, provider, itemId));
        }
コード例 #42
0
 public Stream GetImage(WebStreamMediaType type, int? provider, string id)
 {
     return Images.GetImage(new MediaSource(type, provider, id));
 }
コード例 #43
0
 public Stream ExtractImageResized(WebStreamMediaType type, int? provider, string itemId, int position, int maxWidth, int maxHeight)
 {
     int? calcMaxWidth = maxWidth == 0 ? null : (int?)maxWidth;
     int? calcMaxHeight = maxHeight == 0 ? null : (int?)maxHeight;
     return Images.ExtractImage(new MediaSource(type, provider, itemId), position, calcMaxWidth, calcMaxHeight);
 }
コード例 #44
0
 public Stream GetImageResized(WebStreamMediaType type, int? provider, string id, int maxWidth, int maxHeight)
 {
     return Images.GetResizedImage(new MediaSource(type, provider, id), maxWidth, maxHeight);
 }
コード例 #45
0
ファイル: Images.cs プロジェクト: bjarkimg/MPExtended
 public ImageMediaSource(WebStreamMediaType type, int? provider, string id, WebArtworkType filetype, int offset)
     : base(type, provider, id, filetype, offset)
 {
 }
コード例 #46
0
 public Stream GetMediaItem(WebStreamMediaType type, int? provider, string itemId)
 {
     MediaSource source = new MediaSource(type, provider, itemId);
     return source.Retrieve();
 }
コード例 #47
0
 //
 // Streaming
 private int? GetProvider(WebStreamMediaType type)
 {
     switch (type)
     {
         case WebStreamMediaType.File:
             return Settings.ActiveSettings.FileSystemProvider;
         case WebStreamMediaType.Movie:
             return Settings.ActiveSettings.MovieProvider;
         case WebStreamMediaType.MusicAlbum:
         case WebStreamMediaType.MusicTrack:
             return Settings.ActiveSettings.MusicProvider;
         case WebStreamMediaType.Picture:
             return Settings.ActiveSettings.PicturesProvider;
         case WebStreamMediaType.Recording:
         case WebStreamMediaType.TV:
             return 0;
         case WebStreamMediaType.TVEpisode:
         case WebStreamMediaType.TVSeason:
         case WebStreamMediaType.TVShow:
             return Settings.ActiveSettings.TVShowProvider;
         default:
             // this cannot happen
             return 0;
     }
 }
コード例 #48
0
 public Stream ExtractImageResized(WebStreamMediaType type, int? provider, string itemId, int position, int maxWidth, int maxHeight)
 {
     return Images.ExtractImage(new MediaSource(type, provider, itemId), position, maxWidth, maxHeight);
 }
コード例 #49
0
        public ActionResult Player(WebStreamMediaType type, string itemId, bool video = true)
        {
            // get transcoding profile
            IWebStreamingService streamControl = GetStreamControl(type);
            WebTranscoderProfile profile = null;
            if (Request.QueryString["transcoder"] != null)
                profile = GetStreamControl(type).GetTranscoderProfileByName(Request.QueryString["transcoder"]);
            if (Request.Form["transcoder"] != null)
                profile = GetStreamControl(type).GetTranscoderProfileByName(Request.Form["transcoder"]);
            if (profile == null)
            {
                string defaultName = "";
                if(type == WebStreamMediaType.TV || type == WebStreamMediaType.Recording)
                {
                    defaultName = Settings.ActiveSettings.DefaultTVProfile;
                }
                else if(video)
                {
                    defaultName = Settings.ActiveSettings.DefaultMediaProfile;
                }
                else
                {
                    defaultName = Settings.ActiveSettings.DefaultAudioProfile;
                }
                profile = GetStreamControl(type).GetTranscoderProfileByName(defaultName);
            }

            // get all transcoder profiles
            List<StreamTarget> targets = video ? StreamTarget.GetVideoTargets() : StreamTarget.GetAudioTargets();
            List<string> profiles = new List<string>();
            foreach (StreamTarget target in targets)
            {
                profiles = profiles.Concat(GetStreamControl(type).GetTranscoderProfilesForTarget(target.Name).Select(x => x.Name)).ToList();
            }

            // get view properties
            VideoPlayer player = targets.First(x => x.Name == profile.Target).Player;
            string viewName = Enum.GetName(typeof(VideoPlayer), player) + "Player";

            // player size
            WebResolution playerSize;
            if (!video)
            {
                playerSize = new WebResolution() { Width = 300, Height = 150 };
            }
            else
            {
                playerSize = GetStreamControl(type).GetStreamSize(type, GetProvider(type), itemId, profile.Name);
            }

            // generate url
            RouteValueDictionary parameters = new RouteValueDictionary();
            parameters["item"] = itemId;
            parameters["transcoder"] = profile.Name;

            // generate view
            return PartialView(new PlayerViewModel
            {
                Transcoders = profiles,
                Transcoder = profile.Name,
                Player = player,
                PlayerViewName = viewName,
                URL = Url.Action(Enum.GetName(typeof(WebStreamMediaType), type), parameters),
                Size = playerSize
            });
        }
コード例 #50
0
ファイル: MediaSource.cs プロジェクト: aredon/MPExtended
 public MediaSource(WebStreamMediaType type, int? provider, string id, WebArtworkType filetype)
     : this(type, provider, id, filetype, 0)
 {
 }