mediaCapture set resolution

http://social.msdn.microsoft.com/Forums/en-SG/winappswithcsharp/thread/751b8d83-e646-4ce9-b019-f3c8599e18e0


private MediaCapture mediaCapture_;
bool DEBUG_ = true;
...
this.mediaCapture_ = new MediaCapture();
await this.mediaCapture_.InitializeAsync();
...

public async Task SetResolution()
        {
            System.Collections.Generic.IReadOnlyList<IMediaEncodingProperties> res;
            res = this.mediaCapture_.VideoDeviceController.GetAvailableMediaStreamProperties(MediaStreamType.VideoPreview);
            uint maxResolution = 0;
            int indexMaxResolution = 0;
            string s = "";

            if (res.Count >= 1)
            {
                for (int i = 0; i < res.Count; i++)
                {
                    VideoEncodingProperties vp = (VideoEncodingProperties)res[i];
                    var frameRate = (vp.FrameRate.Numerator / vp.FrameRate.Denominator);
                    

                    s = i + ") " + vp.Subtype + ", ";
                    s = s + vp.Width;
                    s = s + " x " + vp.Height;
                    s = s + " , Frame/s: " + frameRate;
                    
                    if (vp.Width > maxResolution && vp.Subtype.Equals("YUY2"))
                    {
                        indexMaxResolution = i;
                        maxResolution = vp.Width;

                    }
                    if (DEBUG_)
                    {
                        Debug.WriteLine(s);
                    }
                    s = "";
                }

                //setting resolution
                await mediaCapture_.VideoDeviceController.SetMediaStreamPropertiesAsync(MediaStreamType.VideoPreview, res[maxResolution]);


            }
        }


你可能感兴趣的:(mediaCapture set resolution)