Restricting video tracks

Apr 13, 2012 at 10:42 AM

Hi

I am trying to restrict 1080p tracks from being played as we are seeing performance issues with those.

I have the following snippet ind my OnManifestReady:

                MediaStream videoStream =
                    ActiveAdaptiveMediaPlugin.CurrentSegment.SelectedStreams.Where(i => i.Type == StreamType.Video)
                        .Cast<MediaStream>()
                        .FirstOrDefault();

                if (videoStream != null && videoStream.AvailableTracks.Any())
                {
                    IEnumerable<IMediaTrack> videoTracks = from track in videoStream.AvailableTracks
                                                           where
                                                               track.Resolution.Height <= 720 ||
                                                               track.Resolution.Width <= 1280
                                                           select track;

                    if (videoTracks.Any()) videoStream.SetSelectedTracks(videoTracks);
                }

But for some reason, we still see the player jumping up to the 1080p stream sometimes, am i missing something?

- Loke

Apr 14, 2012 at 9:05 AM

I'm seeing some weird behavior myself:

 protected override void OnMediaPluginLoaded()
        {
            base.OnMediaPluginLoaded();
            
            SmoothStreamingMediaPlugin ssmp = (SmoothStreamingMediaPlugin)ActiveMediaPlugin;
            ssmp.VideoPlaybackTrackChanged += logger_VideoPlaybackTrackChanged;

        }

void logger_VideoPlaybackTrackChanged(IAdaptiveMediaPlugin a, IMediaTrack b)
        {
            System.Diagnostics.Debug.WriteLine("~~~~~~~~~~~~~~~~~~ logger_VideoPlaybackTrackChanged " + b.Bitrate.ToString());

            SmoothStreamingMediaPlugin ssmp = (SmoothStreamingMediaPlugin)a;
            System.Diagnostics.Debug.WriteLine("____________________ segs " + ssmp.Segments);
            IEnumerator<ISegment> segs = ssmp.Segments.GetEnumerator();
            segs.MoveNext();
            System.Diagnostics.Debug.WriteLine("____________________ streams " + segs.Current.AvailableStreams);
            IEnumerator<IMediaStream> streams = segs.Current.AvailableStreams.GetEnumerator();
            streams.MoveNext();
            System.Diagnostics.Debug.WriteLine("____________________ traks " + streams.Current.AvailableTracks);
            IEnumerator<IMediaTrack> traks = streams.Current.AvailableTracks.GetEnumerator();
            traks.MoveNext();
            System.Diagnostics.Debug.WriteLine("____________________ bitrate" + traks.Current.Bitrate.ToString());
        }

 

logger output looks like this -- obviously something isn't right here since there is only ever 1 track but it is clearly changing over time:

~~~~~~~~~~~~~~~~~~ logger_VideoPlaybackTrackChanged 300000
____________________ segs System.Collections.Generic.List`1[Microsoft.SilverlightMediaFramework.Plugins.Primitives.ISegment]
____________________ streams System.Collections.Generic.List`1[Microsoft.SilverlightMediaFramework.Plugins.Primitives.IMediaStream]
____________________ traks System.Collections.Generic.List`1[Microsoft.SilverlightMediaFramework.Plugins.Primitives.IMediaTrack]
____________________ bitrate300000
~~~~~~~~~~~~~~~~~~ logger_VideoPlaybackTrackChanged 866000
____________________ segs System.Collections.Generic.List`1[Microsoft.SilverlightMediaFramework.Plugins.Primitives.ISegment]
____________________ streams System.Collections.Generic.List`1[Microsoft.SilverlightMediaFramework.Plugins.Primitives.IMediaStream]
____________________ traks System.Collections.Generic.List`1[Microsoft.SilverlightMediaFramework.Plugins.Primitives.IMediaTrack]
____________________ bitrate300000
~~~~~~~~~~~~~~~~~~ logger_VideoPlaybackTrackChanged 2436000
____________________ segs System.Collections.Generic.List`1[Microsoft.SilverlightMediaFramework.Plugins.Primitives.ISegment]
____________________ streams System.Collections.Generic.List`1[Microsoft.SilverlightMediaFramework.Plugins.Primitives.IMediaStream]
____________________ traks System.Collections.Generic.List`1[Microsoft.SilverlightMediaFramework.Plugins.Primitives.IMediaTrack]
____________________ bitrate300000