Jump to content

Unreachable code MediaFormatProfileResolver.cs


GB Utah

Recommended Posts

While trying to learn, digest, make sense of DLNA and various devices/servers/etc, I forked MBS on github and started trying to follow some of the code.

 

I initially installed Xamarin Studio to attempt to browse MBS code locally. It failed regardless of which sln I tried. I believe the error was something to the affect of unable to load MediaBrowserCommon with GUID.... if interested I'll get that info for you.

I then installed VS2013, opened sln no problem. I'm reveiwing the dev branch.

 

I'm trying to determine if/when DMR/DMP SinkProtocolInfo/GetProtocolInfo is ever used by MBS?

Failing the above, I'm looking at how MBS builds Media Format Profiles, using the DLNA Guidelines from March 2014 as a reference.

 

While doing so, I believe there is a bit of unreachable code in MediaFormatProfileResolver.cs contained in ResolveVideoMPEG2TSFormat:

 

                if (StringHelper.EqualsIgnoreCase(audioCodec, "mp3"))
                {
                    if (timestampType == TransportStreamTimestamp.None)
                    {
                        return new List<MediaFormatProfile> { ValueOf(string.Format("AVC_TS_HP_{0}D_MPEG1_L2_ISO", resolution)) };
                    }

                    return new List<MediaFormatProfile> { ValueOf(string.Format("AVC_TS_HP_{0}D_MPEG1_L2_T", resolution)) };
                }

                if (StringHelper.EqualsIgnoreCase(audioCodec, "aac"))
                    return new List<MediaFormatProfile> { ValueOf(string.Format("AVC_TS_MP_{0}D_AAC_MULT5{1}", resolution, suffix)) };

                if (StringHelper.EqualsIgnoreCase(audioCodec, "mp3"))
                    return new List<MediaFormatProfile> { ValueOf(string.Format("AVC_TS_MP_{0}D_MPEG1_L3{1}", resolution, suffix)) };

 

BTW, there are a lot of if if blocks, wouldn't it be somewhat easier to maintain using case?

 

Long story short, the second audioCodec "mp3" is unreachable, unless I'm completely off here.

 

 

EDITED: Line numbers do show in post once posted, however not in preview...

Edited by GB Utah
Link to comment
Share on other sites

Excellent catch. The first one is actually intended to be mp2. If you'd like to get a pull request under your belt feel free to submit it, otherwise i'll just make the change. thanks!

Link to comment
Share on other sites

There appear to be quite a few formats missing? 24/50/60 etc.... I don't expect that the server would handle all 1000's of them hard coded like this, but can you explain the purpose and use of this file/class?

 

In addition, in MediaBrowser.Model.Dlna the following enum is missing a fairly important one I think as it is a mandatory profile supported by all HND devices according to the DLNA Guidelines:

 

AVC_MP4_MP_SD
Link to comment
Share on other sites

it is used for a couple purposes, to fill Didl metadata in upnp xml responses, and then also for http response headers.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...