UPnP / DLNA Media Server for MediaPortal 2 | Page 35

Discussion in 'UPnP / DLNA Media Server' started by McGoober, January 1, 2012.

  1. mrj

    mrj Portal Pro

    Joined:
    January 27, 2012
    Messages:
    245
    Likes Received:
    42
    Ratings:
    +96 / 1
    Show System Specs
    Hi
    You can replace many if/else statement testing enums with dictionaries to reduce the number of lines.
    or directly "enum.tostring().tolower()"
    mrj
    //Edit
    I just saw this.
    morpheus_xx already mentioned it


     
    Last edited: September 27, 2015
  2. Google AdSense Guest Advertisement



    to hide all adverts.
  3. morpheus_xx
    • Team MediaPortal

    morpheus_xx Lead Dev MP2

    Joined:
    March 24, 2007
    Messages:
    10,946
    Likes Received:
    4,712
    Ratings:
    +6,752 / 11
    Home Country:
    Germany Germany
    Show System Specs
    This can be even done more elegant, by using a description attribute at the enum values. There is an example: http://blog.spontaneouspublicity.com/associating-strings-with-enums-in-c.

    What's not supported by this way is to have different parameter sets for SW/Intel/NVidia, which would be easier with mapping dictionaries
     
    • Thank You! Thank You! x 1
  4. FreakyJ
    • Team MediaPortal

    FreakyJ Development Group

    Joined:
    July 25, 2010
    Messages:
    4,021
    Likes Received:
    839
    Gender:
    Male
    Ratings:
    +1,424 / 1
    Home Country:
    Germany Germany
    @henso
    we just did both the same work :D But you were 3 mins faster :ROFLMAO:
    But I am still happy, so no worries^^

    At least thank you all for the suggestions!
     
    • Like Like x 1
  5. morpheus_xx
    • Team MediaPortal

    morpheus_xx Lead Dev MP2

    Joined:
    March 24, 2007
    Messages:
    10,946
    Likes Received:
    4,712
    Ratings:
    +6,752 / 11
    Home Country:
    Germany Germany
    Show System Specs
    • Agree Agree x 1
  6. henso
    • Team MediaPortal

    henso Development Group

    Joined:
    February 16, 2012
    Messages:
    1,878
    Likes Received:
    437
    Gender:
    Male
    Ratings:
    +672 / 0
    Home Country:
    Denmark Denmark
    Agree.

    It would be better to limit the quality factor. I pushed some changes that will create smaller files.

    This is a problem with WMP AFAIK. It sends no range requests to the server. In other DLNA clients it works as expected.

    I tried that. I added 5 threads that constantly download a 70 MB file in parallel while still doing the requests like before. After a few seconds the average response time is 500 ms and 100 requests/second, The file downloads average at 4-5 seconds per file. Anything more I can try? Maybe the problem is somewhere else?

    Sorry about that. :( I thought you would look at it next week. ;)
     
  7. morpheus_xx
    • Team MediaPortal

    morpheus_xx Lead Dev MP2

    Joined:
    March 24, 2007
    Messages:
    10,946
    Likes Received:
    4,712
    Ratings:
    +6,752 / 11
    Home Country:
    Germany Germany
    Show System Specs
    @henso would you mind to make some more changes to classes?

    For codec settings lookup I suggest such kind of structure:
    Code (C#):
    1.  
    2.     public class EncodingConfig
    3.     {
    4.       public Dictionary<EncodingProfile, string> Profiles { get; set; }
    5.       public Dictionary<EncodingPreset, string> Presets { get; set; }
    6.  
    7.       public EncodingConfig()
    8.       {
    9.         Profiles = new Dictionary<EncodingProfile, string>();
    10.         Presets = new Dictionary<EncodingPreset, string>();
    11.       }
    12.     }
    13.  
    14.     public class VideoEncodingConfig : Dictionary<VideoCodec, EncodingConfig> { }
    15.  
    16.     private readonly VideoEncodingConfig IntelCodecConfig = new VideoEncodingConfig
    17.     {
    18.       {
    19.         VideoCodec.Mpeg2,
    20.         new EncodingConfig
    21.         {
    22.           Profiles = new Dictionary<EncodingProfile, string>
    23.           {
    24.             { EncodingProfile.Simple, "-profile:v simple" },
    25.             { EncodingProfile.Main, "-profile:v main" },
    26.             { EncodingProfile.High, "-profile:v high" }
    27.           },
    28.           Presets = new Dictionary<EncodingPreset, string>
    29.           {
    30.             { EncodingPreset.Default, "-preset fast" },
    31.             { EncodingPreset.Ultrafast, "-preset fast" },
    32.             { EncodingPreset.Superfast, "-preset fast" },
    33.             { EncodingPreset.Veryfast, "-preset fast" },
    34.             { EncodingPreset.Faster, "-preset fast" },
    35.             { EncodingPreset.Fast, "-preset fast" },
    36.             { EncodingPreset.Medium, "-preset medium" },
    37.             { EncodingPreset.Slow, "-preset slow" },
    38.             { EncodingPreset.Slower, "-preset slow" },
    39.             { EncodingPreset.Veryslow, "-preset slow" }
    40.           }
    41.         }
    42.       },
    43.       {
    44.         VideoCodec.H264,
    45.         new EncodingConfig
    46.         {
    47.           Profiles = new Dictionary<EncodingProfile, string>
    48.           {
    49.             { EncodingProfile.Baseline, "-profile:v baseline" },
    50.             { EncodingProfile.Main, "-profile:v main" },
    51.             { EncodingProfile.High, "-profile:v high" },
    52.             { EncodingProfile.High422, "-profile:v high" },
    53.             { EncodingProfile.High444, "-profile:v high" }
    54.           },
    55.          Presets = new Dictionary<EncodingPreset, string>
    56.           {
    57.             { EncodingPreset.Default, "-preset veryfast" },
    58.             { EncodingPreset.Ultrafast, "-preset veryfast" },
    59.             { EncodingPreset.Superfast, "-preset veryfast" },
    60.             { EncodingPreset.Veryfast, "-preset veryfast" },
    61.             { EncodingPreset.Faster, "-preset faster" },
    62.             { EncodingPreset.Fast, "-preset fast" },
    63.             { EncodingPreset.Medium, "-preset medium" },
    64.             { EncodingPreset.Slow, "-preset slow" },
    65.             { EncodingPreset.Slower, "-preset slower" },
    66.             { EncodingPreset.Veryslow, "-preset veryslow" }
    67.           }
    68.         }
    69.       }
    70.     };
    71. // TODO: NVidia, SW
    72.  
    The main difference to current situation is to have on single object for each encoder (SW, Intel, NVidia).

    This makes the later lookup even simpler, like:
    Code (C#):
    1.         VideoEncodingConfig selectedConfig;
    2.         if (isIntel)
    3.           selectedConfig = IntelCodecConfig;
    4.         else if (isNvidia)
    5.           selectedConfig = NVidiaCodecConfig;
    6.         else
    7.           selectedConfig = SWCodecConfig;
    8.  
    9.         EncodingConfig encodingConfig;
    10.         if (selectedConfig.TryGetValue(video.TargetVideoCodec, out encodingConfig))
    11.         {
    12.           string profile;
    13.           if (encodingConfig.Profiles.TryGetValue(video.TargetProfile, out profile) && !string.IsNullOrEmpty(profile))
    14.             data.OutputArguments.Add(profile);
    15.  
    16.           string preset;
    17.           if (encodingConfig.Presets.TryGetValue(video.TargetPreset, out preset) && !string.IsNullOrEmpty(preset))
    18.             data.OutputArguments.Add(profile);
    19.         }
    20.  
     
    • Like Like x 2
  8. henso
    • Team MediaPortal

    henso Development Group

    Joined:
    February 16, 2012
    Messages:
    1,878
    Likes Received:
    437
    Gender:
    Male
    Ratings:
    +672 / 0
    Home Country:
    Denmark Denmark
    I pushed some changes in that regard. ;)
     
    • Like Like x 6
  9. morpheus_xx
    • Team MediaPortal

    morpheus_xx Lead Dev MP2

    Joined:
    March 24, 2007
    Messages:
    10,946
    Likes Received:
    4,712
    Ratings:
    +6,752 / 11
    Home Country:
    Germany Germany
    Show System Specs
    Yesterday I tried the plugin. Unfortunately with no so good results here.

    First I tried the plugin with my existing MediaLibrary. This means, the DlnaAspect is not yet filled. Then I've started BubbleUPnP and tried to browse MP2. As result there is a huge list of:
    Code (Text):
    1. [2015-10-01 20:17:43,346] [91033  ] [44       ] [ERROR] - Search failed, Key: VSS:d4b7fbb0-65eb-45f8-b4c6-c24f02dceb86, Frame: Initialise at offset 100 in file:line:column d:\Coding\MP\MP2\MP2_git\MediaPortal-2-SR15\MediaPortal\Incubator\MediaServer\Objects\MediaLibrary\MediaLibraryResource.cs:51:7
    2. , Line: 51
    3. System.InvalidOperationException: Mediaitem 86f64363-4962-4c21-a196-46bbe5e87de4 contains no DLNA video information
    4.    bei MediaPortal.Extensions.MediaServer.DLNA.DlnaMediaItem..ctor(MediaItem item, EndPointSettings client) in d:\Coding\MP\MP2\MP2_git\MediaPortal-2-SR15\MediaPortal\Incubator\MediaServer\DLNA\DlnaMediaItem.cs:Zeile 74.
    5.    bei MediaPortal.Extensions.MediaServer.Profiles.EndPointSettings.GetDlnaItem(MediaItem item) in d:\Coding\MP\MP2\MP2_git\MediaPortal-2-SR15\MediaPortal\Incubator\MediaServer\Profiles\ProfileObjects.cs:Zeile 431.
    6.    bei MediaPortal.Extensions.MediaServer.Objects.MediaLibrary.MediaLibraryResource.Initialise() in d:\Coding\MP\MP2\MP2_git\MediaPortal-2-SR15\MediaPortal\Incubator\MediaServer\Objects\MediaLibrary\MediaLibraryResource.cs:Zeile 51.
    7.    bei MediaPortal.Extensions.MediaServer.Objects.MediaLibrary.MediaLibraryVideoItem..ctor(String baseKey, MediaItem item, EndPointSettings client) in d:\Coding\MP\MP2\MP2_git\MediaPortal-2-SR15\MediaPortal\Incubator\MediaServer\Objects\MediaLibrary\MediaLibraryVideoItem.cs:Zeile 97.
    8.    bei MediaPortal.Extensions.MediaServer.Objects.MediaLibrary.MediaLibraryHelper.InstansiateMediaLibraryObject(MediaItem item, String baseKey, BasicContainer parent, String title) in d:\Coding\MP\MP2\MP2_git\MediaPortal-2-SR15\MediaPortal\Incubator\MediaServer\Objects\MediaLibrary\MediaLibraryHelper.cs:Zeile 109.
    9.    bei MediaPortal.Extensions.MediaServer.Objects.MediaLibrary.MediaLibraryHelper.InstansiateMediaLibraryObject(MediaItem item, String baseKey, BasicContainer parent) in d:\Coding\MP\MP2\MP2_git\MediaPortal-2-SR15\MediaPortal\Incubator\MediaServer\Objects\MediaLibrary\MediaLibraryHelper.cs:Zeile 84.
    10.    bei MediaPortal.Extensions.MediaServer.Objects.MediaLibrary.MediaLibraryContainer.Search(String filter, String sortCriteria) in d:\Coding\MP\MP2\MP2_git\MediaPortal-2-SR15\MediaPortal\Incubator\MediaServer\Objects\MediaLibrary\MediaLibraryContainer.cs:Zeile 86.
    I think if an Item doesn't have a DlnaAspect it should be excluded before and the exceptions should be avoided. This could be achieved by adding the DlnaAspect-ID as a required MIA, then only MIs are returned that have it.

    Next try: I removed my shares and tried to let the MIs imported to fill the DlnaAspect. I've run the MP2-Server in console mode (-c as argument), not as service. My sources are network shares. During this import the log is flooded by:
    Code (Text):
    1. [2015-10-01 20:24:34,953] [502639 ] [14       ] [ERROR] - MediaAnalyzer: Failed to extract media type information for resource '\\LS-WXLD09\Media\Musik\Alben\Anastacia - Anastacia\Anastacia - Anastacia - 06 - I Do (feat. Sonny of P.O.D.).mp3', Result: , ExitCode: -2147483648, Success: False
    2. [2015-10-01 20:24:35,480] [503167 ] [85       ] [ERROR] - MediaAnalyzer: Failed to extract media type information for resource '\\LS-WXLD09\Media\Musik\Alben\Anastacia - Anastacia\Anastacia - Anastacia - 08 - [2015-10-01 20:24:36,577] [504264 ] [95       ] [INFO ] - DlnaMediaServer: Exception reading resource '{03dd2da6-4da8-4d3e-9e55-80e3165729a3}:////LS-WXLD09/Media/Musik/Alben/Anastacia - Anastacia/Anastacia - Anastacia - 09 - Sexy Single.mp3' (Text: 'Der Objektverweis wurde nicht auf eine Objektinstanz festgelegt.')
    This looks like no process is able to access the resources on UNC share. I'm not sure if this isn't a problem of our impersonation handling? @MJGraf what do you think? I will test this build as Service as next to check if it works with System account.
     
  10. henso
    • Team MediaPortal

    henso Development Group

    Joined:
    February 16, 2012
    Messages:
    1,878
    Likes Received:
    437
    Gender:
    Male
    Ratings:
    +672 / 0
    Home Country:
    Denmark Denmark
    The problem with that approach is that I'm not only searching for one type of MIA but multiple. When I want to search for all media of type Image, Video or Audio, I can't put the DLNA MIA's as required, because Images don't have DLNA aspect for audio and so on. I will catch the exception instead and write a warning in the logs or should it be a debug message?
     
  11. FreakyJ
    • Team MediaPortal

    FreakyJ Development Group

    Joined:
    July 25, 2010
    Messages:
    4,021
    Likes Received:
    839
    Gender:
    Male
    Ratings:
    +1,424 / 1
    Home Country:
    Germany Germany
    I would say warning :)
    Because there is something wrong if you don't have these aspects xD
     
Loading...

Users Viewing Thread (Users: 0, Guests: 0)

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice
  • About The Project

    The vision of the MediaPortal project is to create a free open source media centre application, which supports all advanced media centre functions, and is accessible to all Windows users.

    In reaching this goal we are working every day to make sure our software is one of the best.

             

  • Support MediaPortal!

    The team works very hard to make sure the community is running the best HTPC-software. We give away MediaPortal for free but hosting and software is not for us.

    Care to support our work with a few bucks? We'd really appreciate it!