Пример #1
0
        /// <summary>
        /// Helper method that creates a user friendly type from the internal interop structure.
        /// </summary>
        /// <param name="s">TrackDescriptionStructure from interop</param>
        /// <returns>public TrackDescription to be consumed by the user</returns>
        internal static MediaTrack Build(this MediaTrackStructure s)
        {
            AudioTrack    audioTrack    = default;
            VideoTrack    videoTrack    = default;
            SubtitleTrack subtitleTrack = default;

            switch (s.TrackType)
            {
            case TrackType.Audio:
                audioTrack = MarshalUtils.PtrToStructure <AudioTrack>(s.TrackData);
                break;

            case TrackType.Video:
                videoTrack = MarshalUtils.PtrToStructure <VideoTrack>(s.TrackData);
                break;

            case TrackType.Text:
                subtitleTrack = MarshalUtils.PtrToStructure <SubtitleTrackStructure>(s.TrackData).Build();
                break;

            case TrackType.Unknown:
                break;
            }

            return(new MediaTrack(s.Codec,
                                  s.OriginalFourcc,
                                  s.Id,
                                  s.TrackType,
                                  s.Profile,
                                  s.Level,
                                  new MediaTrackData(audioTrack, videoTrack, subtitleTrack), s.Bitrate,
                                  s.Language.FromUtf8(),
                                  s.Description.FromUtf8()));
        }
Пример #2
0
        /// <summary>
        /// Helper method that creates a user friendly type from the internal interop structure.
        /// </summary>
        /// <param name="s">TrackDescriptionStructure from interop</param>
        /// <returns>public TrackDescription to be consumed by the user</returns>
        internal static MediaTrack Build(this MediaTrackStructure s)
        {
            AudioTrack    audioTrack    = default;
            VideoTrack    videoTrack    = default;
            SubtitleTrack subtitleTrack = default;

            switch (s.TrackType)
            {
            case TrackType.Audio:
                audioTrack = MarshalUtils.PtrToStructure <AudioTrack>(s.TrackData);
                break;

            case TrackType.Video:
                videoTrack = MarshalUtils.PtrToStructure <VideoTrack>(s.TrackData);
                break;

            case TrackType.Text:
                subtitleTrack = MarshalUtils.PtrToStructure <SubtitleTrackStructure>(s.TrackData).Build();
                break;

            case TrackType.Unknown:
                break;
            }

            var language = Utf8StringMarshaler.GetInstance().MarshalNativeToManaged(s.Language) as string;
            var des      = Utf8StringMarshaler.GetInstance().MarshalNativeToManaged(s.Description) as string;

            return(new MediaTrack(s.Codec,
                                  s.OriginalFourcc,
                                  s.Id,
                                  s.TrackType,
                                  s.Profile,
                                  s.Level,
                                  new MediaTrackData(audioTrack, videoTrack, subtitleTrack), s.Bitrate,
                                  language,
                                  des));
        }