public bool Equals(VideoQuality quality) { if (quality==null) return false; return (quality.ResX == this.ResX & quality.ResY == this.ResY & quality.FrameRate == this.FrameRate & quality.BitRate == this.BitRate ); }
public bool Start(string address, int port, int videoPort, VideoQuality videoQuality) { bool ok = true; this.port = port; this.videoPort = videoPort; //this.videoQuality = videoQuality; try{ TcpClient tcpClient = new TcpClient(address, port); stream = tcpClient.GetStream(); this.session = new Session(Java.Net.InetAddress.GetByName(address), videoPort + 5); session.AddVideoTrack(VideoEncoder.H263, CameraFacing.Back, videoQuality, false); session.StreamStarted += OnStreamStarted; session.StreamStoped += OnStreamStoped; workThread = new Thread(new ThreadStart(Run)); running = true; workThread.IsBackground = true; workThread.Start(); } catch (Exception e) { Console.WriteLine(e.Message); ok = false; } return(ok); }
/** 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 } }
public void SetVideoQuality(VideoQuality videoQuality) { if (!quality.Equals(videoQuality)) { quality = videoQuality; qualityHasChanged = true; } }
public bool Equals(VideoQuality quality) { if (quality == null) { return(false); } return(quality.ResX == this.ResX & quality.ResY == this.ResY & quality.FrameRate == this.FrameRate & quality.BitRate == this.BitRate); }
public static VideoQuality ParseQuality(String str) { VideoQuality quality = new VideoQuality(0,0,0,0); if (str != null) { String[] config = str.Split('-'); try { quality.BitRate = int.Parse(config[0])*1000; // conversion to bit/s quality.FrameRate = int.Parse(config[1]); quality.ResX = int.Parse(config[2]); quality.ResY = int.Parse(config[3]); } catch (Exception) {} } return quality; }
public static VideoQuality ParseQuality(String str) { VideoQuality quality = new VideoQuality(0, 0, 0, 0); if (str != null) { String[] config = str.Split('-'); try { quality.BitRate = int.Parse(config[0]) * 1000; // conversion to bit/s quality.FrameRate = int.Parse(config[1]); quality.ResX = int.Parse(config[2]); quality.ResY = int.Parse(config[3]); } catch (Exception) {} } return(quality); }
public static void Merge(VideoQuality videoQuality, VideoQuality defaultVideoQuality) { if (videoQuality.ResX == 0) { videoQuality.ResX = defaultVideoQuality.ResX; } if (videoQuality.ResY == 0) { videoQuality.ResY = defaultVideoQuality.ResY; } if (videoQuality.FrameRate == 0) { videoQuality.FrameRate = defaultVideoQuality.FrameRate; } if (videoQuality.BitRate == 0) { videoQuality.BitRate = defaultVideoQuality.BitRate; } }
public bool Start(string address, int port, int videoPort, VideoQuality videoQuality){ bool ok = true; this.port = port; this.videoPort = videoPort; //this.videoQuality = videoQuality; try{ TcpClient tcpClient = new TcpClient(address, port); stream = tcpClient.GetStream(); this.session = new Session(Java.Net.InetAddress.GetByName(address), videoPort+5); session.AddVideoTrack(VideoEncoder.H263,CameraFacing.Back,videoQuality,false); session.StreamStarted += OnStreamStarted; session.StreamStoped += OnStreamStoped; workThread = new Thread(new ThreadStart(Run)); running = true; workThread.IsBackground = true; workThread.Start(); } catch(Exception e){ Console.WriteLine(e.Message); ok = false; } return ok; }
/** 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 } }
/** Set default video stream quality, it will be used by addVideoTrack */ public static void SetDefaultVideoQuality(VideoQuality quality) { defaultVideoQuality = quality; }
public static void Merge(VideoQuality videoQuality, VideoQuality defaultVideoQuality) { if (videoQuality.ResX==0) videoQuality.ResX = defaultVideoQuality.ResX; if (videoQuality.ResY==0) videoQuality.ResY = defaultVideoQuality.ResY; if (videoQuality.FrameRate==0) videoQuality.FrameRate = defaultVideoQuality.FrameRate; if (videoQuality.BitRate==0) videoQuality.BitRate = defaultVideoQuality.BitRate; }