private void AssignDlnaMetadata(MetadataContainer info, int edition)
        {
            if (info == null)
            {
                return;
            }

            List <string> profileList = new List <string>();

            if (TranscodingParameter == null)
            {
                Metadata  = info.Metadata[edition];
                Video     = info.Video[edition];
                Audio     = info.Audio[edition];
                Image     = info.Image[edition];
                Subtitles = info.Subtitles[edition];
            }
            else
            {
                if (IsImage)
                {
                    ImageTranscoding        image    = (ImageTranscoding)TranscodingParameter;
                    TranscodedImageMetadata metadata = MediaConverter.GetTranscodedImageMetadata(image);
                    Metadata = new MetadataStream
                    {
                        Mime = info.Metadata[edition].Mime,
                        ImageContainerType = metadata.TargetImageCodec,
                        Size = Client.EstimateTransodedSize ? info.Metadata[edition].Size : 0,
                    };
                    Image = new ImageStream
                    {
                        Height          = metadata.TargetMaxHeight,
                        Orientation     = metadata.TargetOrientation,
                        PixelFormatType = metadata.TargetPixelFormat,
                        Width           = metadata.TargetMaxWidth
                    };
                }
                else if (IsAudio)
                {
                    AudioTranscoding        audio    = (AudioTranscoding)TranscodingParameter;
                    TranscodedAudioMetadata metadata = MediaConverter.GetTranscodedAudioMetadata(audio);
                    Metadata = new MetadataStream
                    {
                        Mime = info.Metadata[edition].Mime,
                        AudioContainerType = metadata.TargetAudioContainer,
                        Bitrate            = metadata.TargetAudioBitrate > 0 ? metadata.TargetAudioBitrate : null,
                        Duration           = info.Metadata[edition].Duration,
                        Size = Client.EstimateTransodedSize ? (metadata.TargetAudioBitrate > 0 ? Convert.ToInt64((metadata.TargetAudioBitrate * 1024 * info.Metadata[edition].Duration) / 8.0) : (long?)null) : null,
                    };
                    AudioStream audioStream = new AudioStream();
                    audioStream.Bitrate   = metadata.TargetAudioBitrate;
                    audioStream.Channels  = metadata.TargetAudioChannels;
                    audioStream.Codec     = metadata.TargetAudioCodec;
                    audioStream.Frequency = metadata.TargetAudioFrequency;
                    Audio = new List <AudioStream> {
                        audioStream
                    };
                }
                else if (IsVideo)
                {
                    VideoTranscoding        video    = (VideoTranscoding)TranscodingParameter;
                    TranscodedVideoMetadata metadata = MediaConverter.GetTranscodedVideoMetadata(video);
                    Metadata = new MetadataStream
                    {
                        Mime = info.Metadata[edition].Mime,
                        VideoContainerType = metadata.TargetVideoContainer,
                        Bitrate            = metadata.TargetAudioBitrate > 0 && metadata.TargetVideoBitrate > 0 ? metadata.TargetAudioBitrate + metadata.TargetVideoBitrate : null,
                        Duration           = info.Metadata[edition].Duration,
                        Size = Client.EstimateTransodedSize ? (metadata.TargetAudioBitrate > 0 && info.Metadata[edition].Duration > 0 ? Convert.ToInt64((metadata.TargetAudioBitrate * 1024 * info.Metadata[edition].Duration) / 8.0) : (long?)null) : null,
                    };
                    Video = new VideoStream
                    {
                        AspectRatio      = metadata.TargetVideoAspectRatio,
                        Bitrate          = metadata.TargetVideoBitrate,
                        Codec            = metadata.TargetVideoCodec,
                        Framerate        = metadata.TargetVideoFrameRate,
                        HeaderLevel      = metadata.TargetLevel,
                        ProfileType      = metadata.TargetProfile,
                        RefLevel         = metadata.TargetLevel,
                        Height           = metadata.TargetVideoMaxHeight,
                        PixelAspectRatio = metadata.TargetVideoPixelAspectRatio,
                        PixelFormatType  = metadata.TargetVideoPixelFormat,
                        TimestampType    = metadata.TargetVideoTimestamp,
                        Width            = metadata.TargetVideoMaxWidth,
                    };
                    AudioStream audioStream = new AudioStream();
                    audioStream.Bitrate   = metadata.TargetAudioBitrate;
                    audioStream.Channels  = metadata.TargetAudioChannels;
                    audioStream.Codec     = metadata.TargetAudioCodec;
                    audioStream.Frequency = metadata.TargetAudioFrequency;
                    Audio = new List <AudioStream> {
                        audioStream
                    };
                }
            }

            if (IsImage)
            {
                profileList = DlnaProfiles.ResolveImageProfile(Metadata.ImageContainerType, Image.Width, Image.Height);
            }
            else if (IsAudio)
            {
                var audio = Audio.FirstOrDefault();
                profileList = DlnaProfiles.ResolveAudioProfile(Metadata.AudioContainerType, audio?.Codec ?? AudioCodec.Unknown, audio?.Bitrate, audio?.Frequency, audio?.Channels);
            }
            else if (IsVideo)
            {
                var audio = Audio.FirstOrDefault();
                profileList = DlnaProfiles.ResolveVideoProfile(Metadata.VideoContainerType, Video.Codec, audio?.Codec ?? AudioCodec.Unknown, Video.ProfileType, Video.HeaderLevel,
                                                               Video.Framerate, Video.Width, Video.Height, Video.Bitrate, audio?.Bitrate, Video.TimestampType);
            }

            string profile = "";
            string mime    = info.Metadata[edition].Mime;

            if (DlnaProfiles.TryFindCompatibleProfile(Client, profileList, ref profile, ref mime))
            {
                DlnaMime    = mime;
                DlnaProfile = profile;
            }
        }