/** Add default audio track with default configuration */ public void AddVideoTrack(VideoEncoder encoder, Android.Hardware.CameraFacing camera, VideoQuality videoQuality, bool flash) { IStream stream = null; VideoQuality.Merge(videoQuality, defaultVideoQuality); switch (encoder) { case VideoEncoder.H263: stream = new H263Stream(camera); break; case VideoEncoder.H264: throw new NotImplementedException(); //break; } if (stream != null) { //Log.d(TAG,"Quality is: "+videoQuality.resX+"x"+videoQuality.resY+"px "+videoQuality.frameRate+"fps, "+videoQuality.bitRate+"bps"); ((VideoStream)stream).SetVideoQuality(videoQuality); ((VideoStream)stream).SetPreviewDisplay(surfaceHolder); ((VideoStream)stream).SetFlashState(flash); stream.SetDestination(destination, videoPort); tracks.Add(new Track(stream, Track.VIDEO)); } else { //do something here } }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); Window.SetFormat(Format.Translucent); RequestWindowFeature(WindowFeatures.NoTitle); Window.SetFlags(WindowManagerFlags.Fullscreen, WindowManagerFlags.Fullscreen); fmanager = FragmentManager; Window.SetBackgroundDrawable(new ColorDrawable(Color.Black)); Bundle extras = Intent.Extras; if (extras != null) { TrophyName = extras.GetString("TrophyName"); } trophyFragment = TrophyFragment.newInstance(TrophyName, this); //trophyFragment.SetStyle(DialogFragmentStyle.Normal, Resource.Style.AppThemepp); trophyFragment.Show(fmanager, "fragment_edit_name"); trophyFragment.Cancelable = false; trophyFragment.OnCAptureClick += (Bitmap obj, LinearLayout linearButton) => { if (obj != null) { try { bitmaptrophy = obj; mCamera.TakePicture(null, null, mPreview); } catch (System.Exception ex) { trophyFragment.progressBarLL.Visibility = ViewStates.Gone; System.Console.WriteLine("Take Picture Exception:" + ex.ToString()); } } }; trophyFragment.ResetAcitivity += (bool obj) => { System.GC.Collect(); }; trophyFragment.BackPressEvent += (bool obj) => { trophyFragment.Dismiss(); Finish(); }; trophyFragment.ChangeCameraFace += (bool obj) => { if (previewing) { mCamera.StopPreview(); } //NB: if you don't release the current camera before switching, you app will crash mCamera.Release(); //swap the id of the camera to be used if (currentCameraId == Android.Hardware.Camera.CameraInfo.CameraFacingBack) { currentCameraId = Android.Hardware.Camera.CameraInfo.CameraFacingFront; IsFrontCamera = true; } else { currentCameraId = Android.Hardware.Camera.CameraInfo.CameraFacingBack; IsFrontCamera = false; } mCamera = Android.Hardware.Camera.Open((int)currentCameraId); SetCameraDisplayOrientation(this, (int)currentCameraId, mCamera); try { mCamera.SetPreviewDisplay(mPreview.mHolder); } catch (System.Exception exx) { System.Console.WriteLine("Exception Changeing Camera:" + exx.ToString()); } //Android.Hardware.Camera.Parameters parameters = mCamera.GetParameters(); //parameters.SetPreviewSize(mPreview.mPreviewSize.Width, mPreview.mPreviewSize.Height); //System.Console.WriteLine("Param mPreviewSize.Width:" + mPreview.mPreviewSize.Width + " mPreviewSize.height:" + mPreview.mPreviewSize.Height); //parameters.SetPictureSize(mPreview.mPreviewSize.Width, mPreview.mPreviewSize.Height); //parameters.JpegQuality = (100); //parameters.PictureFormat = (ImageFormat.Jpeg); //parameters.FocusMode = Android.Hardware.Camera.Parameters.FocusModeAuto; //if (parameters.IsZoomSupported) // parameters.Zoom = (0); //mCamera.SetParameters(parameters); //mCamera.StartPreview(); previewing = false; mPreview.Dispose(); mPreview = new Preview(this); SetContentView(mPreview); mPreview.PreviewCamera = mCamera; }; //numberOfCameras = Android.Hardware.Camera.NumberOfCameras; //// Find the ID of the default camera //Android.Hardware.Camera.CameraInfo cameraInfo = new Android.Hardware.Camera.CameraInfo(); //for (int i = 0; i < numberOfCameras; i++) //{ // Android.Hardware.Camera.GetCameraInfo(i, cameraInfo); // if (cameraInfo.Facing == CameraFacing.Back) // { // defaultCameraId = i; // } //} }
public VideoStream(Android.Hardware.CameraFacing cameraId) : base() { this.cameraId = cameraId; }
public VideoStream(Android.Hardware.CameraFacing cameraId):base() { this.cameraId = cameraId; }