StreamInfo.RestrictTracks Method

Replaces AvailableTracks with the specified list of available tracks.

Namespace: Microsoft.Web.Media.SmoothStreaming
Assembly: Microsoft.Web.Media.SmoothStreaming (in Microsoft.Web.Media.SmoothStreaming.dll)



Public Sub RestrictTracks ( _
    availableTracks As IList(Of TrackInfo) _

Dim instance As StreamInfo
Dim availableTracks As IList(Of TrackInfo)

public void RestrictTracks(
    IList<TrackInfo> availableTracks
void RestrictTracks(
    IList<TrackInfo^>^ availableTracks
member RestrictTracks : 
        availableTracks:IList<TrackInfo> -> unit 
public function RestrictTracks(
    availableTracks : IList<TrackInfo>



The RestrictTracks method is supported for video and audio tracks. It restricts decoder initialization to the given list of available tracks to avoid initializing the decoder with unsupported modes.

You can use the RestrictTracks method to enable scenarios in which multiple audio languages are present in the manifest, each with 5.1 and stereo encoding.

The SelectTracks(IList<TrackInfo>, Boolean) method will automatically be called with the given list of available tracks. Note that SelectedTracks will not be updated until after the ManifestReady event.

RestrictTracks can be used to handle scenarios in which there may be differing support for multiple-resolution content. For example, early versions of Windows Phone do not support dynamic resolution changes. For more information, see Supported Media Codecs for Windows Phone.

The following example restricts tracks to tracks of the same resolution.

void OnManifestReady(object sender, EventArgs e)
    SmoothStreamingMediaElement ssme = sender as SmoothStreamingMediaElement;

    if (ssme == null)

    // Select the highest band of tracks which all have the same resolution.
    // maxMobileBitrate depends on the encoding settings
    const ulong maxMobileBitrate = 1000000;
    foreach (SegmentInfo segment in ssme.ManifestInfo.Segments)
        foreach (StreamInfo streamInfo in segment.AvailableStreams)
            if (MediaStreamType.Video == streamInfo.Type)
                List<TrackInfo> widestBand = new List<TrackInfo>();
                List<TrackInfo> currentBand = new List<TrackInfo>();
                ulong lastHeight = 0;
                ulong lastWidth = 0;
                ulong index = 0;

                foreach (TrackInfo track in streamInfo.AvailableTracks)
                    index += 1;

                    string strMaxWidth;
                    string strMaxHeight;
                    // If can't find width/height, choose only the top bitrate.
                    ulong ulMaxWidth = index;
                    // If can't find width/height, choose only the top bitrate.
                    ulong ulMaxHeight = index;
                    // V2 manifests require "MaxWidth", while v1 manifests used "Width".
                    if (track.Attributes.TryGetValue("MaxWidth", out strMaxWidth) ||
                        track.Attributes.TryGetValue("Width", out strMaxWidth))
                        ulong.TryParse(strMaxWidth, out ulMaxWidth);

                    if (track.Attributes.TryGetValue("MaxHeight", out strMaxHeight) ||
                        track.Attributes.TryGetValue("Height", out strMaxHeight))
                        ulong.TryParse(strMaxHeight, out ulMaxHeight);

                    if (ulMaxWidth != lastWidth ||
                        ulMaxHeight != lastHeight)
                        // Current band is now finished, check if it is the widest.
                        // If same size, current band preferred over previous
                        // widest, because it will be of higher bitrate.
                        if (currentBand.Count >= widestBand.Count)
                            //  A new widest band:
                            widestBand = currentBand;
                            currentBand = new List<TrackInfo>();

                    if (track.Bitrate > maxMobileBitrate)

                    // Current track always gets added to current band.
                    lastWidth = ulMaxWidth;
                    lastHeight = ulMaxHeight;

                if (0 == widestBand.Count &&
                    0 == currentBand.Count)
                    // Lowest bitrate band is > maxMobileBitrate.
                else if (currentBand.Count >= widestBand.Count)
                    // Need to check the last band which was constructed.
                    Debug.Assert(currentBand.Count > 0);
                    widestBand = currentBand; // Winner by default.

                Debug.Assert(widestBand.Count >= 1);

Version Information


Supported in: 5

Windows Phone

Supported in: Windows Phone OS 7.1, Windows Phone OS 7.0

See Also


StreamInfo Class

Microsoft.Web.Media.SmoothStreaming Namespace